From 7d1f51a8937e0a86486267437d444696e81e8aa0 Mon Sep 17 00:00:00 2001 From: Jakub <53441451+kuba6000@users.noreply.github.com> Date: Mon, 29 Aug 2022 16:04:28 +0200 Subject: Buildscript + Spotless (#318) * Convert AES.java to readable class * Buildscript * Spotless --- src/main/java/gtPlusPlus/core/block/ModBlocks.java | 266 +- .../gtPlusPlus/core/block/base/AdvancedBlock.java | 63 +- .../gtPlusPlus/core/block/base/BasicBlock.java | 134 +- .../core/block/base/BasicTileBlockWithTooltip.java | 576 +- .../gtPlusPlus/core/block/base/BlockBaseFluid.java | 147 +- .../core/block/base/BlockBaseModular.java | 399 +- .../gtPlusPlus/core/block/base/BlockBaseNBT.java | 114 +- .../gtPlusPlus/core/block/base/BlockBaseOre.java | 418 +- .../java/gtPlusPlus/core/block/base/MetaBlock.java | 45 +- .../core/block/base/MultiTextureBlock.java | 48 +- .../block/general/BlockCompressedObsidian.java | 149 +- .../gtPlusPlus/core/block/general/BlockNet.java | 53 +- .../core/block/general/BlockSuperLight.java | 384 +- .../core/block/general/BlockTankXpConverter.java | 350 +- .../gtPlusPlus/core/block/general/FirePit.java | 429 +- .../core/block/general/FluidTankInfinite.java | 208 +- .../gtPlusPlus/core/block/general/HellFire.java | 1088 +-- .../gtPlusPlus/core/block/general/LightGlass.java | 233 +- .../core/block/general/MiningExplosives.java | 325 +- .../gtPlusPlus/core/block/general/PlayerDoors.java | 895 +-- .../block/general/antigrief/BlockWitherProof.java | 308 +- .../core/block/general/antigrief/TowerDevice.java | 519 +- .../block/general/fluids/BlockFluidSludge.java | 93 +- .../general/redstone/BlockGenericRedstone.java | 689 +- .../redstone/BlockGenericRedstoneDetector.java | 226 +- .../redstone/BlockGenericRedstoneEmitter.java | 4 +- .../general/redstone/BlockGenericRedstoneTest.java | 359 +- .../core/block/machine/BlockGtFrameBox.java | 67 +- .../core/block/machine/CircuitProgrammer.java | 279 +- .../core/block/machine/DecayablesChest.java | 387 +- .../java/gtPlusPlus/core/block/machine/EggBox.java | 306 +- .../gtPlusPlus/core/block/machine/FishTrap.java | 281 +- .../core/block/machine/HeliumGenerator.java | 147 +- .../block/machine/Machine_ModularityTable.java | 162 +- .../core/block/machine/Machine_PestKiller.java | 233 +- .../core/block/machine/Machine_PooCollector.java | 319 +- .../core/block/machine/Machine_ProjectTable.java | 294 +- .../core/block/machine/Machine_RoundRobinator.java | 227 +- .../core/block/machine/Machine_SuperJukebox.java | 1061 ++- .../core/block/machine/Machine_TradeTable.java | 132 +- .../core/block/machine/Machine_WireiusDeletus.java | 3 +- .../core/block/machine/VolumetricFlaskSetter.java | 285 +- .../block/machine/bedrock/Mining_Head_Fake.java | 298 +- .../block/machine/bedrock/Mining_Pipe_Fake.java | 234 +- .../core/chunkloading/GTPP_ChunkManager.java | 147 +- .../gtPlusPlus/core/client/CustomTextureSet.java | 37 +- .../gtPlusPlus/core/client/model/ModelBatKing.java | 59 +- .../core/client/model/ModelDecayChest.java | 11 +- .../gtPlusPlus/core/client/model/ModelEggBox.java | 50 +- .../core/client/model/ModelGiantChicken.java | 61 +- .../core/client/model/ModelSickBlaze.java | 58 +- .../core/client/model/ModelStaballoyConstruct.java | 66 +- .../core/client/model/tabula/ModelTabulaBase.java | 16 +- .../client/renderer/CustomItemBlockRenderer.java | 99 +- .../client/renderer/CustomOreBlockRenderer.java | 3572 +++++---- .../core/client/renderer/RenderBatKing.java | 292 +- .../core/client/renderer/RenderDecayChest.java | 118 +- .../core/client/renderer/RenderGiantChicken.java | 5 +- .../renderer/RenderMiningExplosivesPrimed.java | 196 +- .../core/client/renderer/RenderPlasmaBolt.java | 317 +- .../core/client/renderer/RenderPotionthrow.java | 42 +- .../core/client/renderer/RenderSickBlaze.java | 76 +- .../client/renderer/RenderStaballoyConstruct.java | 293 +- .../core/client/renderer/RenderToxinball.java | 47 +- .../renderer/particle/EntityDropParticleFX.java | 175 +- .../client/renderer/tabula/RenderTabulaBase.java | 59 +- .../core/commands/CommandDebugChunks.java | 266 +- .../commands/CommandEnableDebugWhileRunning.java | 451 +- .../java/gtPlusPlus/core/commands/CommandMath.java | 166 +- .../gtPlusPlus/core/commands/CommandUtils.java | 20 +- .../java/gtPlusPlus/core/common/BasePlayer.java | 402 +- .../java/gtPlusPlus/core/common/CommonProxy.java | 515 +- .../core/common/compat/COMPAT_Baubles.java | 89 +- .../core/common/compat/COMPAT_BigReactors.java | 21 +- .../common/compat/COMPAT_CompactWindmills.java | 372 +- .../core/common/compat/COMPAT_EnderIO.java | 33 +- .../core/common/compat/COMPAT_ExtraUtils.java | 47 +- .../core/common/compat/COMPAT_HarvestCraft.java | 13 +- .../gtPlusPlus/core/common/compat/COMPAT_IC2.java | 108 +- .../core/common/compat/COMPAT_MorePlanets.java | 56 +- .../core/common/compat/COMPAT_OpenBlocks.java | 35 +- .../core/common/compat/COMPAT_PlayerAPI.java | 55 +- .../core/common/compat/COMPAT_PneumaticCraft.java | 17 +- .../core/common/compat/COMPAT_RFTools.java | 18 +- .../core/common/compat/COMPAT_Railcraft.java | 12 +- .../core/common/compat/COMPAT_SimplyJetpacks.java | 18 +- .../core/common/compat/COMPAT_Thaumcraft.java | 74 +- .../core/common/compat/COMPAT_Witchery.java | 29 +- .../java/gtPlusPlus/core/config/ConfigHandler.java | 754 +- .../core/container/Container_BackpackBase.java | 381 +- .../container/Container_CircuitProgrammer.java | 352 +- .../core/container/Container_DecayablesChest.java | 238 +- .../core/container/Container_EggBox.java | 238 +- .../core/container/Container_FishTrap.java | 247 +- .../core/container/Container_Grindle.java | 305 +- .../core/container/Container_HeliumGenerator.java | 341 +- .../core/container/Container_ModularityTable.java | 443 +- .../core/container/Container_PestKiller.java | 257 +- .../core/container/Container_ProjectTable.java | 405 +- .../core/container/Container_RoundRobinator.java | 442 +- .../core/container/Container_SuperJukebox.java | 452 +- .../core/container/Container_TradeTable.java | 414 +- .../container/Container_VolumetricFlaskSetter.java | 326 +- .../core/container/box/LunchBoxContainer.java | 12 +- .../core/container/box/MagicBagContainer.java | 12 +- .../core/container/box/ToolBoxContainer.java | 8 +- .../gtPlusPlus/core/creative/AddToCreativeTab.java | 50 +- .../creative/tabs/MiscUtilCreativeTabBlock.java | 26 +- .../creative/tabs/MiscUtilCreativeTabMachines.java | 18 +- .../creative/tabs/MiscUtilCreativeTabMisc.java | 17 +- .../creative/tabs/MiscUtilCreativeTabOther.java | 17 +- .../creative/tabs/MiscUtilCreativeTabTools.java | 17 +- .../core/entity/EntityPrimedMiningExplosive.java | 597 +- .../gtPlusPlus/core/entity/EntityTeleportFX.java | 460 +- .../core/entity/EntityTeslaTowerLightning.java | 313 +- .../core/entity/InternalEntityRegistry.java | 168 +- .../entity/ai/batking/EntityAIBatKingAttack.java | 810 +- .../core/entity/item/ItemEntityGiantEgg.java | 210 +- .../core/entity/monster/EntityBatKing.java | 1358 ++-- .../entity/monster/EntityGiantChickenBase.java | 285 +- .../core/entity/monster/EntitySickBlaze.java | 427 +- .../entity/monster/EntityStaballoyConstruct.java | 1136 +-- .../projectile/EntityHydrofluoricAcidPotion.java | 237 +- .../entity/projectile/EntityLightningAttack.java | 93 +- .../projectile/EntitySulfuricAcidPotion.java | 220 +- .../entity/projectile/EntityThrowableBomb.java | 410 +- .../core/entity/projectile/EntityToxinball.java | 627 +- .../entity/projectile/EntityToxinballSmall.java | 147 +- .../gtPlusPlus/core/fluids/BlockFluidBase.java | 167 +- .../java/gtPlusPlus/core/fluids/FactoryFluid.java | 105 +- .../java/gtPlusPlus/core/fluids/FluidFactory.java | 349 +- .../java/gtPlusPlus/core/fluids/FluidPackage.java | 83 +- .../core/fluids/FluidRegistryHandler.java | 80 +- .../core/fluids/ItemGenericFluidBucket.java | 582 +- .../gtPlusPlus/core/gui/GUI_Base_Tile_Entity.java | 11 +- .../gtPlusPlus/core/gui/beta/Gui_ID_Registry.java | 96 +- .../java/gtPlusPlus/core/gui/beta/Gui_Types.java | 11 +- .../java/gtPlusPlus/core/gui/beta/MU_GuiId.java | 43 +- .../gtPlusPlus/core/gui/item/GuiBaseBackpack.java | 205 +- .../gtPlusPlus/core/gui/item/GuiBaseGrindle.java | 1125 +-- .../gtPlusPlus/core/gui/item/GuiScreenGrindle.java | 957 +-- .../gtPlusPlus/core/gui/item/box/GuiBaseBox.java | 198 +- .../gtPlusPlus/core/gui/item/box/LunchBoxGui.java | 6 +- .../gtPlusPlus/core/gui/item/box/MagicBagGui.java | 6 +- .../gtPlusPlus/core/gui/item/box/ToolBoxGui.java | 6 +- .../core/gui/machine/GUI_CircuitProgrammer.java | 64 +- .../core/gui/machine/GUI_DecayablesChest.java | 90 +- .../gtPlusPlus/core/gui/machine/GUI_EggBox.java | 89 +- .../gtPlusPlus/core/gui/machine/GUI_FishTrap.java | 90 +- .../core/gui/machine/GUI_HeliumGenerator.java | 53 +- .../core/gui/machine/GUI_ModularityTable.java | 132 +- .../core/gui/machine/GUI_PestKiller.java | 257 +- .../core/gui/machine/GUI_ProjectTable.java | 98 +- .../core/gui/machine/GUI_RoundRobinator.java | 201 +- .../core/gui/machine/GUI_ScrollTest.java | 146 +- .../core/gui/machine/GUI_SuperJukebox.java | 135 +- .../core/gui/machine/GUI_TradeTable.java | 75 +- .../gui/machine/GUI_VolumetricFlaskSetter.java | 473 +- .../gtPlusPlus/core/gui/widget/GuiValueField.java | 172 +- .../core/handler/AchievementHandler.java | 787 +- .../java/gtPlusPlus/core/handler/BookHandler.java | 774 +- .../core/handler/BurnableFuelHandler.java | 45 +- .../gtPlusPlus/core/handler/COMPAT_HANDLER.java | 500 +- .../core/handler/COMPAT_IntermodStaging.java | 124 +- .../gtPlusPlus/core/handler/CraftingManager.java | 16 +- .../gtPlusPlus/core/handler/EnumHelperHandler.java | 18 +- .../java/gtPlusPlus/core/handler/GuiHandler.java | 383 +- .../java/gtPlusPlus/core/handler/MobMentality.java | 85 +- .../gtPlusPlus/core/handler/OldCircuitHandler.java | 119 +- .../gtPlusPlus/core/handler/PacketHandler.java | 132 +- .../core/handler/Recipes/DecayableRecipe.java | 50 +- .../handler/Recipes/LateRegistrationHandler.java | 33 +- .../core/handler/Recipes/RegistrationHandler.java | 31 +- .../handler/StopAnnoyingFuckingAchievements.java | 66 +- .../core/handler/events/BlockEventHandler.java | 411 +- .../core/handler/events/CustomMovementHandler.java | 279 +- .../handler/events/EnderDragonDeathHandler.java | 95 +- .../core/handler/events/EntityDeathHandler.java | 211 +- .../handler/events/GeneralTooltipEventHandler.java | 228 +- .../core/handler/events/LoginEventHandler.java | 225 +- .../core/handler/events/MissingMappingsEvent.java | 81 +- .../events/PickaxeBlockBreakEventHandler.java | 132 +- .../handler/events/PlayerSleepEventHandler.java | 168 +- .../core/handler/events/PlayerTickHandler.java | 12 +- .../core/handler/events/SneakManager.java | 241 +- .../handler/events/UnbreakableBlockManager.java | 242 +- .../events/ZombieBackupSpawnEventHandler.java | 82 +- .../core/handler/render/CapeHandler.java | 201 +- .../core/handler/render/FirepitModel.java | 223 +- .../core/handler/render/FirepitRender.java | 89 +- .../workbench/Workbench_CraftingHandler.java | 340 +- .../handler/workbench/Workbench_RecipeSorter.java | 65 +- .../gtPlusPlus/core/interfaces/IGuiManager.java | 10 +- .../core/interfaces/IGuiManagerMiscUtils.java | 2 +- .../gtPlusPlus/core/interfaces/IItemBlueprint.java | 79 +- .../core/inventories/BaseInventoryBackpack.java | 435 +- .../core/inventories/BaseInventoryGrindle.java | 420 +- .../inventories/InventoryCircuitProgrammer.java | 311 +- .../core/inventories/InventoryFishTrap.java | 318 +- .../core/inventories/InventoryHeliumGenerator.java | 318 +- .../core/inventories/InventoryPestKiller.java | 318 +- .../core/inventories/InventoryWorkbenchChest.java | 333 +- .../inventories/InventoryWorkbenchCrafting.java | 359 +- .../InventoryWorkbenchHoloCrafting.java | 294 +- .../inventories/InventoryWorkbenchHoloSlots.java | 435 +- .../core/inventories/InventoryWorkbenchTools.java | 332 +- .../InventoryWorkbenchToolsElectric.java | 340 +- .../inventories/Inventory_DecayablesChest.java | 318 +- .../core/inventories/Inventory_EggBox.java | 318 +- .../core/inventories/Inventory_RoundRobinator.java | 311 +- .../core/inventories/Inventory_SuperJukebox.java | 311 +- .../Inventory_VolumetricFlaskSetter.java | 311 +- .../core/inventories/box/LunchBoxInventory.java | 15 +- .../core/inventories/box/MagicBagInventory.java | 15 +- .../core/inventories/box/ToolBoxInventory.java | 15 +- .../modulartable/InventoryModularMain.java | 361 +- .../modulartable/InventoryModularOutput.java | 359 +- .../projecttable/InventoryProjectMain.java | 359 +- .../projecttable/InventoryProjectOutput.java | 333 +- .../inventories/tradetable/InventoryTradeMain.java | 359 +- .../tradetable/InventoryTradeOutput.java | 333 +- src/main/java/gtPlusPlus/core/item/ModItems.java | 2664 ++++--- .../java/gtPlusPlus/core/item/base/BaseEuItem.java | 1197 +-- .../core/item/base/BaseItemBackpack.java | 149 +- .../gtPlusPlus/core/item/base/BaseItemBrain.java | 167 +- .../core/item/base/BaseItemBurnable.java | 75 +- .../core/item/base/BaseItemColourable.java | 169 +- .../core/item/base/BaseItemComponent.java | 2048 +++-- .../core/item/base/BaseItemDamageable.java | 368 +- .../gtPlusPlus/core/item/base/BaseItemGeneric.java | 34 +- .../gtPlusPlus/core/item/base/BaseItemLoot.java | 193 +- .../gtPlusPlus/core/item/base/BaseItemTCShard.java | 137 +- .../core/item/base/BaseItemTickable.java | 645 +- .../core/item/base/BaseItemWithCharge.java | 113 +- .../core/item/base/BaseItemWithDamageValue.java | 38 +- .../gtPlusPlus/core/item/base/BasicSpawnEgg.java | 458 +- .../java/gtPlusPlus/core/item/base/CoreItem.java | 535 +- .../core/item/base/bolts/BaseItemBolt.java | 8 +- .../core/item/base/cell/BaseItemCell.java | 97 +- .../core/item/base/cell/BaseItemPlasmaCell.java | 126 +- .../core/item/base/dusts/BaseItemDust.java | 267 +- .../core/item/base/dusts/BaseItemDustAbstract.java | 68 +- .../core/item/base/dusts/BaseItemDustEx.java | 209 +- .../core/item/base/dusts/BaseItemDustUnique.java | 288 +- .../item/base/dusts/decimal/BaseItemCentidust.java | 94 +- .../item/base/dusts/decimal/BaseItemDecidust.java | 94 +- .../core/item/base/foil/BaseItemFoil.java | 8 +- .../core/item/base/foods/BaseItemFood.java | 81 +- .../core/item/base/foods/BaseItemHotFood.java | 131 +- .../core/item/base/gears/BaseItemGear.java | 8 +- .../core/item/base/gears/BaseItemSmallGear.java | 8 +- .../core/item/base/ingots/BaseItemIngot.java | 23 +- .../core/item/base/ingots/BaseItemIngotHot.java | 193 +- .../core/item/base/ingots/BaseItemIngot_OLD.java | 173 +- .../core/item/base/itemblock/FluidItemBlock.java | 111 +- .../item/base/itemblock/ItemBlockBasicTile.java | 106 +- .../core/item/base/itemblock/ItemBlockDoor.java | 191 +- .../item/base/itemblock/ItemBlockEntityBase.java | 57 +- .../core/item/base/itemblock/ItemBlockGtBlock.java | 337 +- .../item/base/itemblock/ItemBlockGtFrameBox.java | 149 +- .../core/item/base/itemblock/ItemBlockMeta.java | 173 +- .../core/item/base/itemblock/ItemBlockNBT.java | 180 +- .../core/item/base/itemblock/ItemBlockOre.java | 291 +- .../base/itemblock/ItemBlockRoundRobinator.java | 202 +- .../core/item/base/itemblock/ItemBlockSpawner.java | 51 +- .../core/item/base/misc/BaseItemMisc.java | 304 +- .../core/item/base/misc/BaseItemParticle.java | 94 +- .../core/item/base/nugget/BaseItemNugget.java | 9 +- .../base/ore/BaseItemCentrifugedCrushedOre.java | 8 +- .../core/item/base/ore/BaseItemCrushedOre.java | 8 +- .../core/item/base/ore/BaseItemImpureDust.java | 8 +- .../core/item/base/ore/BaseItemMilledOre.java | 26 +- .../item/base/ore/BaseItemPurifiedCrushedOre.java | 8 +- .../core/item/base/ore/BaseItemPurifiedDust.java | 8 +- .../core/item/base/ore/BaseOreComponent.java | 501 +- .../core/item/base/plates/BaseItemPlate.java | 22 +- .../core/item/base/plates/BaseItemPlateDouble.java | 22 +- .../core/item/base/plates/BaseItemPlateHeavy.java | 70 +- .../core/item/base/plates/BaseItemPlate_OLD.java | 157 +- .../core/item/base/rings/BaseItemRing.java | 9 +- .../core/item/base/rods/BaseItemRod.java | 9 +- .../core/item/base/rods/BaseItemRodLong.java | 17 +- .../core/item/base/rotors/BaseItemRotor.java | 8 +- .../core/item/base/screws/BaseItemScrew.java | 9 +- .../core/item/base/wire/BaseItemFineWire.java | 9 +- .../gtPlusPlus/core/item/bauble/BaseBauble.java | 338 +- .../core/item/bauble/BatteryPackBaseBauble.java | 457 +- .../core/item/bauble/ElectricBaseBauble.java | 352 +- .../core/item/bauble/FireProtectionBauble.java | 234 +- .../core/item/bauble/HealthBoostBauble.java | 46 +- .../gtPlusPlus/core/item/bauble/ModularBauble.java | 786 +- .../core/item/bauble/MonsterKillerBaseBauble.java | 298 +- .../core/item/chemistry/AgriculturalChem.java | 1196 +-- .../gtPlusPlus/core/item/chemistry/CoalTar.java | 710 +- .../core/item/chemistry/GenericChem.java | 2366 +++--- .../core/item/chemistry/IonParticles.java | 277 +- .../core/item/chemistry/MilledOreProcessing.java | 1565 ++-- .../core/item/chemistry/NuclearChem.java | 198 +- .../gtPlusPlus/core/item/chemistry/OilChem.java | 66 +- .../core/item/chemistry/RocketFuels.java | 2223 +++--- .../core/item/chemistry/StandardBaseParticles.java | 286 +- .../chemistry/general/ItemGenericChemBase.java | 587 +- .../chemistry/general/ItemNuclearChemBase.java | 260 +- .../core/item/circuit/ItemAdvancedChip.java | 432 +- .../core/item/crafting/ItemDummyResearch.java | 169 +- .../gtPlusPlus/core/item/effects/RarityEffect.java | 32 +- .../gtPlusPlus/core/item/effects/RarityEpic.java | 28 +- .../gtPlusPlus/core/item/effects/RarityRare.java | 28 +- .../core/item/effects/RarityUncommon.java | 20 +- .../core/item/food/BaseItemMetaFood.java | 928 ++- .../core/item/general/BaseItemGrindle.java | 117 +- .../core/item/general/BedLocator_Base.java | 184 +- .../gtPlusPlus/core/item/general/BufferCore.java | 100 +- .../core/item/general/ItemAirFilter.java | 247 +- .../core/item/general/ItemAreaClear.java | 371 +- .../core/item/general/ItemBasicFirestarter.java | 157 +- .../item/general/ItemBasicScrubberTurbine.java | 272 +- .../core/item/general/ItemBlueprint.java | 516 +- .../core/item/general/ItemCloakingDevice.java | 496 +- .../core/item/general/ItemControlCore.java | 202 +- .../core/item/general/ItemCreativeTab.java | 88 +- .../gtPlusPlus/core/item/general/ItemEmpty.java | 22 +- .../core/item/general/ItemGemShards.java | 139 +- .../core/item/general/ItemGenericToken.java | 341 +- .../gtPlusPlus/core/item/general/ItemGiantEgg.java | 515 +- .../core/item/general/ItemHalfCompleteCasings.java | 97 +- .../core/item/general/ItemHealingDevice.java | 748 +- .../core/item/general/ItemLavaFilter.java | 201 +- .../core/item/general/ItemMagicFeather.java | 447 +- .../core/item/general/ItemSlowBuildingRing.java | 245 +- .../core/item/general/ItemSunnariumBit.java | 19 +- .../core/item/general/NuclearFuelRodBase.java | 366 +- .../core/item/general/RF2EU_Battery.java | 595 +- .../core/item/general/books/ItemBaseBook.java | 199 +- .../item/general/capture/ItemEntityCatcher.java | 463 +- .../item/general/chassis/ItemBoilerChassis.java | 127 +- .../item/general/chassis/ItemDehydratorCoil.java | 140 +- .../general/chassis/ItemDehydratorCoilWire.java | 140 +- .../core/item/general/fuelrods/FuelRod_Base.java | 412 +- .../item/general/fuelrods/FuelRod_Thorium.java | 17 +- .../general/rfchargingpack/ChargingPackBase.java | 133 +- .../item/general/spawn/ItemCustomSpawnEgg.java | 534 +- .../throwables/ItemHydrofluoricAcidPotion.java | 49 +- .../general/throwables/ItemSulfuricAcidPotion.java | 49 +- .../item/general/throwables/ItemThrowableBomb.java | 190 +- .../java/gtPlusPlus/core/item/init/ItemsFoods.java | 113 +- .../gtPlusPlus/core/item/init/ItemsMultiTools.java | 102 +- .../core/item/materials/DustDecayable.java | 159 +- .../core/item/materials/MaterialHandler.java | 7 +- .../core/item/tool/misc/ConnectedBlockFinder.java | 248 +- .../core/item/tool/misc/DebugScanner.java | 168 +- .../core/item/tool/misc/FakeGregtechTool.java | 109 +- .../core/item/tool/misc/GregtechPump.java | 2562 +++---- .../core/item/tool/misc/SandstoneHammer.java | 131 +- .../core/item/tool/misc/box/AutoLunchBox.java | 16 +- .../core/item/tool/misc/box/BaseBoxItem.java | 90 +- .../core/item/tool/misc/box/ContainerBoxBase.java | 634 +- .../item/tool/misc/box/CustomBoxInventory.java | 433 +- .../core/item/tool/misc/box/MagicToolBag.java | 14 +- .../core/item/tool/misc/box/UniversalToolBox.java | 17 +- .../core/item/tool/staballoy/MultiPickaxeBase.java | 585 +- .../core/item/tool/staballoy/MultiSpadeBase.java | 237 +- .../core/item/tool/staballoy/StaballoyAxe.java | 648 +- .../core/item/tool/staballoy/StaballoyPickaxe.java | 884 ++- .../core/item/tool/staballoy/StaballoySpade.java | 789 +- .../core/item/wearable/WearableLoader.java | 15 +- .../core/item/wearable/armour/ArmourLoader.java | 56 +- .../core/item/wearable/armour/base/BaseArmour.java | 7 +- .../item/wearable/armour/base/BaseArmourBoots.java | 9 +- .../item/wearable/armour/base/BaseArmourChest.java | 9 +- .../item/wearable/armour/base/BaseArmourHelm.java | 9 +- .../item/wearable/armour/base/BaseArmourLegs.java | 9 +- .../item/wearable/armour/hazmat/ArmourHazmat.java | 186 +- .../wearable/armour/tinfoil/ArmourTinFoilHat.java | 290 +- .../core/item/wearable/base/BaseItemWearable.java | 100 +- .../item/wearable/hazmat/ItemArmorHazmatEx.java | 37 +- src/main/java/gtPlusPlus/core/lib/CORE.java | 669 +- src/main/java/gtPlusPlus/core/lib/LoadedMods.java | 725 +- .../java/gtPlusPlus/core/lib/VanillaColours.java | 51 +- src/main/java/gtPlusPlus/core/material/ALLOY.java | 2003 +++-- .../java/gtPlusPlus/core/material/ELEMENT.java | 1157 ++- src/main/java/gtPlusPlus/core/material/Ion.java | 44 +- .../gtPlusPlus/core/material/MISC_MATERIALS.java | 1188 ++- .../java/gtPlusPlus/core/material/Material.java | 3296 ++++---- .../core/material/MaterialGenerator.java | 767 +- .../gtPlusPlus/core/material/MaterialStack.java | 214 +- .../java/gtPlusPlus/core/material/NONMATERIAL.java | 70 +- src/main/java/gtPlusPlus/core/material/ORES.java | 1669 +++-- .../java/gtPlusPlus/core/material/Particle.java | 280 +- .../core/material/gregtech/CustomGTMaterials.java | 148 +- .../core/material/nuclear/FLUORIDES.java | 510 +- .../gtPlusPlus/core/material/nuclear/NUCLIDE.java | 686 +- .../core/material/state/MaterialState.java | 30 +- .../handler/AbstractClientMessageHandler.java | 9 +- .../network/handler/AbstractMessageHandler.java | 45 +- .../handler/AbstractServerMessageHandler.java | 7 +- .../core/network/packet/AbstractPacket.java | 3 +- .../network/packet/Packet_VolumetricFlaskGui.java | 224 +- .../network/packet/Packet_VolumetricFlaskGui2.java | 222 +- .../java/gtPlusPlus/core/players/FakeFarmer.java | 133 +- .../gtPlusPlus/core/potion/GtPotionEffect.java | 7 +- .../java/gtPlusPlus/core/proxy/ClientProxy.java | 460 +- .../java/gtPlusPlus/core/proxy/ServerProxy.java | 34 +- .../core/recipe/Gregtech_Recipe_Adder.java | 175 +- .../core/recipe/LOADER_Machine_Components.java | 467 +- .../gtPlusPlus/core/recipe/RECIPES_Extruder.java | 81 +- .../gtPlusPlus/core/recipe/RECIPES_GREGTECH.java | 4834 ++++++------ .../gtPlusPlus/core/recipe/RECIPES_General.java | 1227 +-- .../core/recipe/RECIPES_LaserEngraver.java | 293 +- .../gtPlusPlus/core/recipe/RECIPES_MTWRAPPER.java | 40 +- .../core/recipe/RECIPES_MachineComponents.java | 1140 ++- .../gtPlusPlus/core/recipe/RECIPES_Machines.java | 7875 +++++++++++--------- .../core/recipe/RECIPES_Old_Circuits.java | 1092 +-- .../core/recipe/RECIPES_RareEarthProcessing.java | 429 +- .../core/recipe/RECIPES_SeleniumProcessing.java | 319 +- .../gtPlusPlus/core/recipe/RECIPES_Shapeless.java | 50 +- .../java/gtPlusPlus/core/recipe/RECIPES_Tools.java | 358 +- .../gtPlusPlus/core/recipe/RECIPE_Batteries.java | 85 +- .../gtPlusPlus/core/recipe/ShapedRecipeObject.java | 80 +- .../java/gtPlusPlus/core/recipe/common/CI.java | 2589 +++---- .../java/gtPlusPlus/core/slots/SlotAirFilter.java | 35 +- .../java/gtPlusPlus/core/slots/SlotBlueprint.java | 38 +- .../java/gtPlusPlus/core/slots/SlotBuzzSaw.java | 122 +- .../core/slots/SlotChemicalPlantInput.java | 57 +- .../java/gtPlusPlus/core/slots/SlotCrafting.java | 279 +- .../core/slots/SlotCraftingNoCollect.java | 271 +- .../java/gtPlusPlus/core/slots/SlotDataStick.java | 59 +- .../java/gtPlusPlus/core/slots/SlotElectric.java | 71 +- src/main/java/gtPlusPlus/core/slots/SlotFrame.java | 27 +- .../java/gtPlusPlus/core/slots/SlotFuelRod.java | 88 +- .../java/gtPlusPlus/core/slots/SlotGeneric.java | 23 +- .../java/gtPlusPlus/core/slots/SlotGtTool.java | 44 +- .../gtPlusPlus/core/slots/SlotGtToolElectric.java | 169 +- .../core/slots/SlotIntegratedCircuit.java | 175 +- .../gtPlusPlus/core/slots/SlotItemBackpackInv.java | 35 +- .../java/gtPlusPlus/core/slots/SlotJukebox.java | 52 +- .../gtPlusPlus/core/slots/SlotLockedInput.java | 94 +- .../java/gtPlusPlus/core/slots/SlotLunchBox.java | 40 +- .../gtPlusPlus/core/slots/SlotMagicToolBag.java | 39 +- .../gtPlusPlus/core/slots/SlotModularBauble.java | 44 +- .../core/slots/SlotModularBaubleUpgrades.java | 85 +- .../java/gtPlusPlus/core/slots/SlotNoInput.java | 23 +- .../gtPlusPlus/core/slots/SlotNoInputLogging.java | 44 +- .../java/gtPlusPlus/core/slots/SlotOutput.java | 159 +- .../core/slots/SlotPollutionScrubber.java | 95 +- src/main/java/gtPlusPlus/core/slots/SlotRTG.java | 27 +- .../java/gtPlusPlus/core/slots/SlotToolBox.java | 204 +- .../gtPlusPlus/core/slots/SlotVolumetricFlask.java | 30 +- .../core/tileentities/ModTileEntities.java | 75 +- .../core/tileentities/base/TILE_ENTITY_BASE.java | 56 +- .../core/tileentities/base/TileBasicTank.java | 278 +- .../core/tileentities/base/TileEntityBase.java | 2017 ++--- .../core/tileentities/base/TilePoweredGT.java | 95 +- .../general/TileEntityCircuitProgrammer.java | 578 +- .../general/TileEntityDecayablesChest.java | 692 +- .../tileentities/general/TileEntityEggBox.java | 692 +- .../tileentities/general/TileEntityFirepit.java | 48 +- .../tileentities/general/TileEntityFishTrap.java | 797 +- .../general/TileEntityHeliumGenerator.java | 224 +- .../general/TileEntityInfiniteFluid.java | 249 +- .../general/TileEntityPlayerDoorBase.java | 487 +- .../tileentities/general/TileEntityReverter.java | 558 +- .../general/TileEntityVolumetricFlaskSetter.java | 764 +- .../general/TileEntityXpConverter.java | 518 +- .../redstone/TileEntityRedstoneHandler.java | 762 +- .../machines/TileEntityAdvPooCollector.java | 231 +- .../machines/TileEntityBaseFluidCollector.java | 411 +- .../machines/TileEntityModularityTable.java | 922 ++- .../machines/TileEntityPestKiller.java | 927 ++- .../machines/TileEntityPooCollector.java | 216 +- .../machines/TileEntityProjectTable.java | 558 +- .../machines/TileEntityRoundRobinator.java | 1348 ++-- .../machines/TileEntityTradeTable.java | 235 +- .../gtPlusPlus/core/util/MovingAverageLong.java | 3 +- src/main/java/gtPlusPlus/core/util/Utils.java | 1808 ++--- src/main/java/gtPlusPlus/core/util/data/AES.java | 154 +- .../java/gtPlusPlus/core/util/data/ArrayUtils.java | 192 +- .../java/gtPlusPlus/core/util/data/EnumUtils.java | 75 +- .../java/gtPlusPlus/core/util/data/FileUtils.java | 164 +- .../gtPlusPlus/core/util/data/LocaleUtils.java | 136 +- .../gtPlusPlus/core/util/data/LoggingUtils.java | 76 +- .../gtPlusPlus/core/util/data/StringUtils.java | 425 +- .../java/gtPlusPlus/core/util/data/UUIDUtils.java | 29 +- .../gtPlusPlus/core/util/debug/DEBUG_INIT.java | 51 +- .../core/util/debug/DEBUG_ITEM_ShapeSpawner.java | 83 +- .../util/debug/DEBUG_MULTIBLOCK_ShapeSpawner.java | 1849 ++--- .../core/util/debug/DEBUG_ScreenOverlay.java | 54 +- .../core/util/debug/DEBUG_TimerThread.java | 104 +- .../core/util/debug/UtilityGL11Debug.java | 1426 +++- .../java/gtPlusPlus/core/util/math/MathUtils.java | 1559 ++-- .../core/util/minecraft/ClientUtils.java | 15 +- .../core/util/minecraft/EnchantingUtils.java | 173 +- .../core/util/minecraft/EnergyUtils.java | 233 +- .../core/util/minecraft/EntityUtils.java | 458 +- .../gtPlusPlus/core/util/minecraft/FluidUtils.java | 1446 ++-- .../gtPlusPlus/core/util/minecraft/FoodUtils.java | 94 +- .../core/util/minecraft/HazmatUtils.java | 1141 ++- .../core/util/minecraft/InventoryUtils.java | 131 +- .../gtPlusPlus/core/util/minecraft/ItemUtils.java | 2777 +++---- .../gtPlusPlus/core/util/minecraft/LangUtils.java | 264 +- .../core/util/minecraft/MaterialUtils.java | 1012 +-- .../core/util/minecraft/MiningUtils.java | 483 +- .../core/util/minecraft/ModularArmourUtils.java | 305 +- .../gtPlusPlus/core/util/minecraft/NBTUtils.java | 1128 ++- .../core/util/minecraft/OreDictUtils.java | 29 +- .../core/util/minecraft/PlayerUtils.java | 460 +- .../core/util/minecraft/RecipeUtils.java | 1538 ++-- .../core/util/minecraft/ShapelessUtils.java | 72 +- .../util/minecraft/gregtech/PollutionUtils.java | 322 +- .../gregtech/material/MaterialBuilder.java | 482 +- .../gregtech/recipehandlers/GregtechRecipe.java | 2 +- .../core/util/minecraft/network/CustomPacket.java | 52 +- .../core/util/minecraft/network/PacketBuilder.java | 33 +- .../util/minecraft/network/PacketDispatcher.java | 127 +- .../core/util/minecraft/network/PacketHandler.java | 94 +- .../util/minecraft/network/PacketTileEntity.java | 114 +- .../minecraft/particles/BlockBreakParticles.java | 16 +- .../particles/EntityParticleFXMysterious.java | 25 +- .../gtPlusPlus/core/util/player/PlayerCache.java | 289 +- .../core/util/reflect/AddGregtechRecipe.java | 466 +- .../gtPlusPlus/core/util/reflect/ProxyFinder.java | 90 +- .../core/util/reflect/ReflectionUtils.java | 2172 +++--- .../gtPlusPlus/core/util/sys/KeyboardUtils.java | 61 +- src/main/java/gtPlusPlus/core/util/sys/Log.java | 26 +- .../java/gtPlusPlus/core/util/sys/SystemUtils.java | 153 +- .../core/world/damage/BaseCustomDamageSource.java | 23 +- .../core/world/explosions/ExplosionHandler.java | 58 +- .../core/world/explosions/MiningExplosion.java | 626 +- 528 files changed, 91655 insertions(+), 86723 deletions(-) (limited to 'src/main/java/gtPlusPlus/core') diff --git a/src/main/java/gtPlusPlus/core/block/ModBlocks.java b/src/main/java/gtPlusPlus/core/block/ModBlocks.java index 4842cb891e..1a93d35ce2 100644 --- a/src/main/java/gtPlusPlus/core/block/ModBlocks.java +++ b/src/main/java/gtPlusPlus/core/block/ModBlocks.java @@ -36,136 +36,136 @@ import net.minecraftforge.fluids.Fluid; public final class ModBlocks { - public static Block blockRoundRobinator; - public static Block blockCircuitProgrammer; - public static Block blockVolumetricFlaskSetter; - public static Block blockFakeMiningPipe; - public static Block blockFakeMiningHead; - - public static Block blockFishTrap; - public static Block blockDecayablesChest; - public static Block blockEggBox; - - //Blocks - //public static Block blockBloodSteel; - //public static Block blockStaballoy; - // WIP TODO public static Block blockToolBuilder; - public static Block blockGriefSaver; - - public static Block blockCasingsMisc; - public static Block blockCasings2Misc; - public static Block blockCasings3Misc; - public static Block blockCasings4Misc; - public static Block blockCasings5Misc; - public static Block blockCasingsTieredGTPP; - public static Block blockSpecialMultiCasings; - public static Block blockSpecialMultiCasings2; - public static Block blockCustomMachineCasings; - public static Block blockCustomPipeGearCasings; - - public static Block blockMetaTileEntity; - public static Block blockHeliumGenerator; - public static Block blockNHG; - public static Block blockCharger; - - public static Block MatterFabricatorEffectBlock; - - public static Fluid fluidSludge = new Fluid("fluid.sludge"); - public static Block blockFluidSludge; - - public static Block blockFirePit; - - public static Block blockOreFluorite; - - public static Block blockMiningExplosive; - - public static Block blockHellfire; - public static Block blockInfiniteFLuidTank; - public static Block blockProjectTable; - public static Block blockTradeTable; - public static Block blockModularTable; - - public static Block blockWitherGuard; - public static Block blockXpConverter; - public static Block blockCompressedObsidian; - public static Block blockNet; - - public static Block blockPlayerDoorWooden; - public static Block blockPlayerDoorIron; - public static Block blockPlayerDoorCustom_Glass; - public static Block blockPlayerDoorCustom_Ice; - public static Block blockPlayerDoorCustom_Cactus; - - public static Block blockCustomMobSpawner; - public static Block blockCustomSuperLight; - public static Block blockCustomJukebox; - - public static Block blockPooCollector; - - public static Block blockPestKiller; - - public static void init() { - Logger.INFO("Initializing Blocks."); - //blockGriefSaver = new TowerDevice().setBlockName("blockGriefSaver").setCreativeTab(AddToCreativeTab.tabBlock).setBlockTextureName("blockDefault"); - - registerBlocks(); - } - - public static void registerBlocks(){ - - Logger.INFO("Registering Blocks."); - MatterFabricatorEffectBlock = new LightGlass(false); - - //Fluids - FluidRegistryHandler.registerFluids(); - - //Workbench - blockHeliumGenerator = new HeliumGenerator(); - blockFirePit = new FirePit(); - blockFishTrap = new FishTrap(); - blockInfiniteFLuidTank = new FluidTankInfinite(); - //blockOreFluorite = new BlockBaseOre.oldOreBlock("oreFluorite", "Fluorite", Material.rock, BlockTypes.ORE, Utils.rgbtoHexValue(120, 120, 30), 3); - blockMiningExplosive = new MiningExplosives(); - blockHellfire = new HellFire(); - blockProjectTable = new Machine_ProjectTable(); - blockTradeTable = new Machine_TradeTable(); - blockModularTable = new Machine_ModularityTable(); - blockWitherGuard = new BlockWitherProof(); - blockXpConverter = new BlockTankXpConverter(); - blockCompressedObsidian = new BlockCompressedObsidian(); - blockNet = new BlockNet(); - - blockFakeMiningPipe = new Mining_Pipe_Fake(); - blockFakeMiningHead = new Mining_Head_Fake(); - - blockCircuitProgrammer = new CircuitProgrammer(); - - blockDecayablesChest = new DecayablesChest(); - blockEggBox = new EggBox(); - - blockPlayerDoorWooden = new PlayerDoors(Material.wood, "door_wood", true); - blockPlayerDoorIron = new PlayerDoors(Material.iron, "door_iron", true); - blockPlayerDoorCustom_Glass = new PlayerDoors(Material.glass, "door_glass", false); - blockPlayerDoorCustom_Ice = new PlayerDoors(Material.ice, "door_ice", false); - blockPlayerDoorCustom_Cactus = new PlayerDoors(Material.cactus, "door_cactus", false, 0.6f, Block.soundTypeGrass, "Cactus"); - - //blockCustomSuperLight = new BlockSuperLight(); - blockCustomJukebox = new Machine_SuperJukebox(); - - blockPooCollector = new Machine_PooCollector(); - - blockPestKiller = new Machine_PestKiller(); - - blockRoundRobinator = new Machine_RoundRobinator(); - - if (Meta_GT_Proxy.sDoesVolumetricFlaskExist) { - blockVolumetricFlaskSetter = new VolumetricFlaskSetter(); - } - - new BlockGenericRedstoneDetector(); - new BlockGenericRedstoneTest(); - - } - - -} \ No newline at end of file + public static Block blockRoundRobinator; + public static Block blockCircuitProgrammer; + public static Block blockVolumetricFlaskSetter; + public static Block blockFakeMiningPipe; + public static Block blockFakeMiningHead; + + public static Block blockFishTrap; + public static Block blockDecayablesChest; + public static Block blockEggBox; + + // Blocks + // public static Block blockBloodSteel; + // public static Block blockStaballoy; + // WIP TODO public static Block blockToolBuilder; + public static Block blockGriefSaver; + + public static Block blockCasingsMisc; + public static Block blockCasings2Misc; + public static Block blockCasings3Misc; + public static Block blockCasings4Misc; + public static Block blockCasings5Misc; + public static Block blockCasingsTieredGTPP; + public static Block blockSpecialMultiCasings; + public static Block blockSpecialMultiCasings2; + public static Block blockCustomMachineCasings; + public static Block blockCustomPipeGearCasings; + + public static Block blockMetaTileEntity; + public static Block blockHeliumGenerator; + public static Block blockNHG; + public static Block blockCharger; + + public static Block MatterFabricatorEffectBlock; + + public static Fluid fluidSludge = new Fluid("fluid.sludge"); + public static Block blockFluidSludge; + + public static Block blockFirePit; + + public static Block blockOreFluorite; + + public static Block blockMiningExplosive; + + public static Block blockHellfire; + public static Block blockInfiniteFLuidTank; + public static Block blockProjectTable; + public static Block blockTradeTable; + public static Block blockModularTable; + + public static Block blockWitherGuard; + public static Block blockXpConverter; + public static Block blockCompressedObsidian; + public static Block blockNet; + + public static Block blockPlayerDoorWooden; + public static Block blockPlayerDoorIron; + public static Block blockPlayerDoorCustom_Glass; + public static Block blockPlayerDoorCustom_Ice; + public static Block blockPlayerDoorCustom_Cactus; + + public static Block blockCustomMobSpawner; + public static Block blockCustomSuperLight; + public static Block blockCustomJukebox; + + public static Block blockPooCollector; + + public static Block blockPestKiller; + + public static void init() { + Logger.INFO("Initializing Blocks."); + // blockGriefSaver = new + // TowerDevice().setBlockName("blockGriefSaver").setCreativeTab(AddToCreativeTab.tabBlock).setBlockTextureName("blockDefault"); + + registerBlocks(); + } + + public static void registerBlocks() { + + Logger.INFO("Registering Blocks."); + MatterFabricatorEffectBlock = new LightGlass(false); + + // Fluids + FluidRegistryHandler.registerFluids(); + + // Workbench + blockHeliumGenerator = new HeliumGenerator(); + blockFirePit = new FirePit(); + blockFishTrap = new FishTrap(); + blockInfiniteFLuidTank = new FluidTankInfinite(); + // blockOreFluorite = new BlockBaseOre.oldOreBlock("oreFluorite", "Fluorite", Material.rock, BlockTypes.ORE, + // Utils.rgbtoHexValue(120, 120, 30), 3); + blockMiningExplosive = new MiningExplosives(); + blockHellfire = new HellFire(); + blockProjectTable = new Machine_ProjectTable(); + blockTradeTable = new Machine_TradeTable(); + blockModularTable = new Machine_ModularityTable(); + blockWitherGuard = new BlockWitherProof(); + blockXpConverter = new BlockTankXpConverter(); + blockCompressedObsidian = new BlockCompressedObsidian(); + blockNet = new BlockNet(); + + blockFakeMiningPipe = new Mining_Pipe_Fake(); + blockFakeMiningHead = new Mining_Head_Fake(); + + blockCircuitProgrammer = new CircuitProgrammer(); + + blockDecayablesChest = new DecayablesChest(); + blockEggBox = new EggBox(); + + blockPlayerDoorWooden = new PlayerDoors(Material.wood, "door_wood", true); + blockPlayerDoorIron = new PlayerDoors(Material.iron, "door_iron", true); + blockPlayerDoorCustom_Glass = new PlayerDoors(Material.glass, "door_glass", false); + blockPlayerDoorCustom_Ice = new PlayerDoors(Material.ice, "door_ice", false); + blockPlayerDoorCustom_Cactus = + new PlayerDoors(Material.cactus, "door_cactus", false, 0.6f, Block.soundTypeGrass, "Cactus"); + + // blockCustomSuperLight = new BlockSuperLight(); + blockCustomJukebox = new Machine_SuperJukebox(); + + blockPooCollector = new Machine_PooCollector(); + + blockPestKiller = new Machine_PestKiller(); + + blockRoundRobinator = new Machine_RoundRobinator(); + + if (Meta_GT_Proxy.sDoesVolumetricFlaskExist) { + blockVolumetricFlaskSetter = new VolumetricFlaskSetter(); + } + + new BlockGenericRedstoneDetector(); + new BlockGenericRedstoneTest(); + } +} diff --git a/src/main/java/gtPlusPlus/core/block/base/AdvancedBlock.java b/src/main/java/gtPlusPlus/core/block/base/AdvancedBlock.java index f63762a2d7..61c7071a3e 100644 --- a/src/main/java/gtPlusPlus/core/block/base/AdvancedBlock.java +++ b/src/main/java/gtPlusPlus/core/block/base/AdvancedBlock.java @@ -1,5 +1,6 @@ package gtPlusPlus.core.block.base; +import gtPlusPlus.core.lib.CORE; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; @@ -8,32 +9,46 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import gtPlusPlus.core.lib.CORE; - public class AdvancedBlock extends Block { - protected AdvancedBlock(final String unlocalizedName, final Material material, final CreativeTabs x, final float blockHardness, final float blockResistance, final float blockLightLevel, - final String blockHarvestTool, final int blockHarvestLevel, final SoundType BlockSound) { - super(material); - this.setBlockName(unlocalizedName); - this.setBlockTextureName(CORE.MODID + ":" + unlocalizedName); - this.setCreativeTab(x); - this.setHardness(blockHardness); //block Hardness - this.setResistance(blockResistance); - this.setLightLevel(blockLightLevel); - this.setHarvestLevel(blockHarvestTool, blockHarvestLevel); - this.setStepSound(BlockSound); - } - - @Override - public boolean onBlockActivated(final World p_149727_1_, final int p_149727_2_, final int p_149727_3_, final int p_149727_4_, final EntityPlayer p_149727_5_, final int p_149727_6_, final float p_149727_7_, final float p_149727_8_, final float p_149727_9_) - { - return false; - } + protected AdvancedBlock( + final String unlocalizedName, + final Material material, + final CreativeTabs x, + final float blockHardness, + final float blockResistance, + final float blockLightLevel, + final String blockHarvestTool, + final int blockHarvestLevel, + final SoundType BlockSound) { + super(material); + this.setBlockName(unlocalizedName); + this.setBlockTextureName(CORE.MODID + ":" + unlocalizedName); + this.setCreativeTab(x); + this.setHardness(blockHardness); // block Hardness + this.setResistance(blockResistance); + this.setLightLevel(blockLightLevel); + this.setHarvestLevel(blockHarvestTool, blockHarvestLevel); + this.setStepSound(BlockSound); + } - @Override - public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { - return false; - } + @Override + public boolean onBlockActivated( + final World p_149727_1_, + final int p_149727_2_, + final int p_149727_3_, + final int p_149727_4_, + final EntityPlayer p_149727_5_, + final int p_149727_6_, + final float p_149727_7_, + final float p_149727_8_, + final float p_149727_9_) { + return false; + } + @Override + public boolean canCreatureSpawn( + final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } } diff --git a/src/main/java/gtPlusPlus/core/block/base/BasicBlock.java b/src/main/java/gtPlusPlus/core/block/base/BasicBlock.java index 6014388cda..876f27e5b6 100644 --- a/src/main/java/gtPlusPlus/core/block/base/BasicBlock.java +++ b/src/main/java/gtPlusPlus/core/block/base/BasicBlock.java @@ -1,5 +1,8 @@ package gtPlusPlus.core.block.base; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.entity.EnumCreatureType; @@ -7,75 +10,68 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; - public class BasicBlock extends BlockContainer { - public BasicBlock(final String unlocalizedName, final Material material) { - this(BlockTypes.STANDARD, unlocalizedName, material, 2); - } - - public BasicBlock(final BlockTypes type, final String unlocalizedName, final Material material) { - this(type, unlocalizedName, material, 2); - } - - public BasicBlock(BlockTypes type, final String unlocalizedName, final Material material, final int harvestLevel) { - super(material); - this.setBlockName(Utils.sanitizeString(unlocalizedName)); - - if (type != BlockTypes.ORE && !unlocalizedName.toLowerCase().contains("ore")) { - this.setBlockTextureName(CORE.MODID + ":" + unlocalizedName); - } - - this.setCreativeTab(AddToCreativeTab.tabBlock); - this.setResistance(6.0F); - this.setLightLevel(0.0F); - this.setHardness(1.0f*harvestLevel); - this.setHarvestLevel("pickaxe", harvestLevel); - this.setStepSound(soundTypeMetal); - } - - - public static enum BlockTypes { - STANDARD("blockBlock", "pickaxe", soundTypeMetal), - FRAME("blockFrameGt", "wrench", soundTypeMetal), - ORE("blockStone", "pickaxe", soundTypeStone); - - private String TEXTURE_NAME; - private String HARVEST_TOOL; - private SoundType soundOfBlock; - private BlockTypes (final String textureName, final String harvestTool, final SoundType blockSound) - { - this.TEXTURE_NAME = textureName; - this.HARVEST_TOOL = harvestTool; - this.soundOfBlock = blockSound; - } - - public String getTexture() { - return this.TEXTURE_NAME; - } - - public String getHarvestTool(){ - return this.HARVEST_TOOL; - } - - public SoundType getBlockSoundType(){ - return this.soundOfBlock; - } - - } - - - @Override - public TileEntity createNewTileEntity(final World p_149915_1_, final int p_149915_2_) { - return null; - } - - @Override - public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { - return false; - } - + public BasicBlock(final String unlocalizedName, final Material material) { + this(BlockTypes.STANDARD, unlocalizedName, material, 2); + } + + public BasicBlock(final BlockTypes type, final String unlocalizedName, final Material material) { + this(type, unlocalizedName, material, 2); + } + + public BasicBlock(BlockTypes type, final String unlocalizedName, final Material material, final int harvestLevel) { + super(material); + this.setBlockName(Utils.sanitizeString(unlocalizedName)); + + if (type != BlockTypes.ORE && !unlocalizedName.toLowerCase().contains("ore")) { + this.setBlockTextureName(CORE.MODID + ":" + unlocalizedName); + } + + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setResistance(6.0F); + this.setLightLevel(0.0F); + this.setHardness(1.0f * harvestLevel); + this.setHarvestLevel("pickaxe", harvestLevel); + this.setStepSound(soundTypeMetal); + } + + public static enum BlockTypes { + STANDARD("blockBlock", "pickaxe", soundTypeMetal), + FRAME("blockFrameGt", "wrench", soundTypeMetal), + ORE("blockStone", "pickaxe", soundTypeStone); + + private String TEXTURE_NAME; + private String HARVEST_TOOL; + private SoundType soundOfBlock; + + private BlockTypes(final String textureName, final String harvestTool, final SoundType blockSound) { + this.TEXTURE_NAME = textureName; + this.HARVEST_TOOL = harvestTool; + this.soundOfBlock = blockSound; + } + + public String getTexture() { + return this.TEXTURE_NAME; + } + + public String getHarvestTool() { + return this.HARVEST_TOOL; + } + + public SoundType getBlockSoundType() { + return this.soundOfBlock; + } + } + + @Override + public TileEntity createNewTileEntity(final World p_149915_1_, final int p_149915_2_) { + return null; + } + + @Override + public boolean canCreatureSpawn( + final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } } diff --git a/src/main/java/gtPlusPlus/core/block/base/BasicTileBlockWithTooltip.java b/src/main/java/gtPlusPlus/core/block/base/BasicTileBlockWithTooltip.java index 2bfd09d848..05a995cbb5 100644 --- a/src/main/java/gtPlusPlus/core/block/base/BasicTileBlockWithTooltip.java +++ b/src/main/java/gtPlusPlus/core/block/base/BasicTileBlockWithTooltip.java @@ -1,9 +1,5 @@ package gtPlusPlus.core.block.base; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -16,6 +12,9 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.InventoryUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -32,297 +31,284 @@ import net.minecraft.world.World; public abstract class BasicTileBlockWithTooltip extends BlockContainer implements ITileTooltip { - /** - * Each mapped object holds the data for the six sides. - */ - @SideOnly(Side.CLIENT) - private AutoMap> mSidedTextureArray; - - /** - * Holds the data for the six sides, each side holds an array of data for each respective meta. - */ - @SideOnly(Side.CLIENT) - private AutoMap> mSidedTexturePathArray; - - /** - * Does this block have any meta at all? - * @return - */ - public final boolean hasMeta() { - return getMetaCount() > 0; - } - - /** - * The amount of meta this block has. - * @return - */ - public abstract int getMetaCount(); - - /** - * Does this {@link Block} require special {@link ItemBlock} handling? - * @return The {@link Class} that will be used for this {@link Block}. - */ - public Class getItemBlockClass() { - return ItemBlock.class; - } - - /** - * A lazy way to declare the unlocal name for the block, makes boilerplating easy. - * @return The internal name for this block. - */ - public abstract String getUnlocalBlockName(); - - /** - * Does this Block have {@link ITileTooltip} support? - * @return {@link boolean} that represents if this block supports {@link ITileTooltip} or not. - */ - public final boolean hasTooltip() { - return getTooltipID() >= -1; - } - - /** - * Lazy Boilerplating. - * @return Block Hardness. - */ - protected abstract float initBlockHardness(); - - /** - * Lazy Boilerplating. - * @return Block Resistance. - */ - protected abstract float initBlockResistance(); - - /** - * Lazy Boilerplating. - * @return The {@link CreativeTab} this Block is shown on. - */ - protected abstract CreativeTabs initCreativeTab(); - - /** - * The ID used by the {@link ITileTooltip} handler. Return -1 if you are not providing a custom {@link ItemBlock} in {@link #getItemBlockClass}(). - * @return - */ - @Override - public abstract int getTooltipID(); - - public BasicTileBlockWithTooltip(Material aBlockMat){ - super(aBlockMat); - //Use Abstract method values - this.setHardness(initBlockHardness()); - this.setResistance(initBlockResistance()); - this.setBlockName(getUnlocalBlockName()); - this.setCreativeTab(initCreativeTab()); - // Register the block last. - GameRegistry.registerBlock(this, getItemBlockClass(), getUnlocalBlockName()); - Logger.INFO("Registered "+getTileEntityName()+"."); - if (Utils.isClient()) { - // Handle Textures - handleTextures(); - } - } - - /** - * The name of the Tile Entity. - * @return - */ - protected abstract String getTileEntityName(); - - /** - * The String used for texture pathing. - * @return Sanitized {@link String}, containing no spaces or illegal characters. - */ - private final String getTileEntityNameForTexturePathing() { - return Utils.sanitizeString(getTileEntityName().replace(" ", "")); - } - - /** - * An array of CubicObjects, one for each meta, else just a single cell array. - * Expected to be null regularly, as the default texture handling should suffice. - * Handy if re-using textures or using a non-standard structure for them. FULL texture path must be used, - * inclusive of the MODID and a colon. - * @return - */ - public CubicObject[] getCustomTextureDirectoryObject(){ - return null; - } - - @Override - @SideOnly(Side.CLIENT) - public final IIcon getIcon(final int aSide, final int aMeta) { - return mSidedTextureArray.get(aMeta).get(aSide).getIcon(); - } - - @Override - public IIcon getIcon(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { - return super.getIcon(aWorld, aX, aY, aZ, aSide); - } - - @SideOnly(Side.CLIENT) - private final void handleTextures() { - - Logger.INFO("[TeTexture] Building Texture Maps for "+getTileEntityName()+"."); - - // Init on the Client side only, to prevent Field initialisers existing in the Server side bytecode. - mSidedTextureArray = new AutoMap>(); - mSidedTexturePathArray = new AutoMap>(); - - - //Store them in forge order - //DOWN, UP, NORTH, SOUTH, WEST, EAST - - // Default Path Name, this will make us look inside 'miscutils\textures\blocks' - final String aPrefixTexPath = CORE.MODID + ":"; - // Default Path Name, this will make us look in the sub-directory for this Tile Entity. - final String aTexPathMid = "TileEntities"+CORE.SEPERATOR+getTileEntityNameForTexturePathing()+CORE.SEPERATOR; - // Construct a full path - String aTexPathBuilt = aPrefixTexPath + aTexPathMid; - // File Name Suffixes, without meta tags - String aStringBot; - String aStringTop; - String aStringBack; - String aStringFront; - String aStringLeft; - String aStringRight; - // Do we provide a matrix of custom data to be used for texture processing instead? - if (getCustomTextureDirectoryObject() != null) { - // Get custom provided texture data. - CubicObject[] aDataMap = getCustomTextureDirectoryObject(); - Logger.INFO("[TeTexture] Found custom texture data, using this instead. Size: "+aDataMap.length); - // Map each meta string data to the main map. - for (int i=0;i aMetaBlob = new CubicObject(aStringBot, aStringTop, aStringBack, aStringFront, aStringLeft, aStringRight); - mSidedTexturePathArray.put(aMetaBlob); - Logger.INFO("[TeTexture] Added Texture Path data to map for meta "+i); - } - } - Logger.INFO("[TeTexture] Map size for pathing: "+mSidedTexturePathArray.size()); - - // Iteration Index - int aIndex = 0; - - // Iterate each CubicObject, holding the six texture paths for each meta. - for (CubicObject aMetaBlob : mSidedTexturePathArray) { - // Make a Safe Texture for each side - SafeTexture aBottom = SafeTexture.register(aMetaBlob.DOWN); - SafeTexture aTop = SafeTexture.register(aMetaBlob.UP); - SafeTexture aBack = SafeTexture.register(aMetaBlob.NORTH); - SafeTexture aFont = SafeTexture.register(aMetaBlob.SOUTH); - SafeTexture aWest = SafeTexture.register(aMetaBlob.WEST); - SafeTexture aEast = SafeTexture.register(aMetaBlob.EAST); - // Store them in an Array - SafeTexture[] aInjectBlob = new SafeTexture[] { - aBottom, - aTop, - aBack, - aFont, - aWest, - aEast - }; - // Convenience Blob - CubicObject aMetaBlob2 = new CubicObject(aInjectBlob); - // Store this Blob into - mSidedTextureArray.put(aMetaBlob2); - Logger.INFO("[TeTexture] Added SafeTexture data to map for meta "+(aIndex++)); - } - Logger.INFO("[TeTexture] Map size for registration: "+mSidedTextureArray.size()); - - - } - - @Override - @SideOnly(Side.CLIENT) - public final void registerBlockIcons(final IIconRegister aRegisterer){ - this.blockIcon = aRegisterer.registerIcon(CORE.MODID + ":" + "net"); - } - - @Override - public abstract TileEntity createNewTileEntity(final World world, final int p_149915_2_); - - /** - * Called when {@link #breakBlock}() is called, but before {@link InventoryUtils#dropInventoryItems} and the super call. - */ - public void onBlockBreak() { - - } - - @Override - public final void breakBlock(final World world, final int x, final int y, final int z, final Block block, final int number) { - onBlockBreak(); - InventoryUtils.dropInventoryItems(world, x, y, z, block); - super.breakBlock(world, x, y, z, block, number); - } - - @SuppressWarnings({"unchecked", "rawtypes"}) - @Override - public final void getSubBlocks(Item aItem, CreativeTabs p_149666_2_, List aList) { - if (hasMeta()) { - for (int i=0;i> mSidedTextureArray; + + /** + * Holds the data for the six sides, each side holds an array of data for each respective meta. + */ + @SideOnly(Side.CLIENT) + private AutoMap> mSidedTexturePathArray; + + /** + * Does this block have any meta at all? + * @return + */ + public final boolean hasMeta() { + return getMetaCount() > 0; + } + + /** + * The amount of meta this block has. + * @return + */ + public abstract int getMetaCount(); + + /** + * Does this {@link Block} require special {@link ItemBlock} handling? + * @return The {@link Class} that will be used for this {@link Block}. + */ + public Class getItemBlockClass() { + return ItemBlock.class; + } + + /** + * A lazy way to declare the unlocal name for the block, makes boilerplating easy. + * @return The internal name for this block. + */ + public abstract String getUnlocalBlockName(); + + /** + * Does this Block have {@link ITileTooltip} support? + * @return {@link boolean} that represents if this block supports {@link ITileTooltip} or not. + */ + public final boolean hasTooltip() { + return getTooltipID() >= -1; + } + + /** + * Lazy Boilerplating. + * @return Block Hardness. + */ + protected abstract float initBlockHardness(); + + /** + * Lazy Boilerplating. + * @return Block Resistance. + */ + protected abstract float initBlockResistance(); + + /** + * Lazy Boilerplating. + * @return The {@link CreativeTab} this Block is shown on. + */ + protected abstract CreativeTabs initCreativeTab(); + + /** + * The ID used by the {@link ITileTooltip} handler. Return -1 if you are not providing a custom {@link ItemBlock} in {@link #getItemBlockClass}(). + * @return + */ + @Override + public abstract int getTooltipID(); + + public BasicTileBlockWithTooltip(Material aBlockMat) { + super(aBlockMat); + // Use Abstract method values + this.setHardness(initBlockHardness()); + this.setResistance(initBlockResistance()); + this.setBlockName(getUnlocalBlockName()); + this.setCreativeTab(initCreativeTab()); + // Register the block last. + GameRegistry.registerBlock(this, getItemBlockClass(), getUnlocalBlockName()); + Logger.INFO("Registered " + getTileEntityName() + "."); + if (Utils.isClient()) { + // Handle Textures + handleTextures(); + } + } + + /** + * The name of the Tile Entity. + * @return + */ + protected abstract String getTileEntityName(); + + /** + * The String used for texture pathing. + * @return Sanitized {@link String}, containing no spaces or illegal characters. + */ + private final String getTileEntityNameForTexturePathing() { + return Utils.sanitizeString(getTileEntityName().replace(" ", "")); + } + + /** + * An array of CubicObjects, one for each meta, else just a single cell array. + * Expected to be null regularly, as the default texture handling should suffice. + * Handy if re-using textures or using a non-standard structure for them. FULL texture path must be used, + * inclusive of the MODID and a colon. + * @return + */ + public CubicObject[] getCustomTextureDirectoryObject() { + return null; + } + + @Override + @SideOnly(Side.CLIENT) + public final IIcon getIcon(final int aSide, final int aMeta) { + return mSidedTextureArray.get(aMeta).get(aSide).getIcon(); + } + + @Override + public IIcon getIcon(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { + return super.getIcon(aWorld, aX, aY, aZ, aSide); + } + + @SideOnly(Side.CLIENT) + private final void handleTextures() { + + Logger.INFO("[TeTexture] Building Texture Maps for " + getTileEntityName() + "."); + + // Init on the Client side only, to prevent Field initialisers existing in the Server side bytecode. + mSidedTextureArray = new AutoMap>(); + mSidedTexturePathArray = new AutoMap>(); + + // Store them in forge order + // DOWN, UP, NORTH, SOUTH, WEST, EAST + + // Default Path Name, this will make us look inside 'miscutils\textures\blocks' + final String aPrefixTexPath = CORE.MODID + ":"; + // Default Path Name, this will make us look in the sub-directory for this Tile Entity. + final String aTexPathMid = + "TileEntities" + CORE.SEPERATOR + getTileEntityNameForTexturePathing() + CORE.SEPERATOR; + // Construct a full path + String aTexPathBuilt = aPrefixTexPath + aTexPathMid; + // File Name Suffixes, without meta tags + String aStringBot; + String aStringTop; + String aStringBack; + String aStringFront; + String aStringLeft; + String aStringRight; + // Do we provide a matrix of custom data to be used for texture processing instead? + if (getCustomTextureDirectoryObject() != null) { + // Get custom provided texture data. + CubicObject[] aDataMap = getCustomTextureDirectoryObject(); + Logger.INFO("[TeTexture] Found custom texture data, using this instead. Size: " + aDataMap.length); + // Map each meta string data to the main map. + for (int i = 0; i < aDataMap.length; i++) { + mSidedTexturePathArray.put(aDataMap[i]); + Logger.INFO("Mapped value for meta " + i + "."); + } + } else { + Logger.INFO("[TeTexture] Processing " + (1 + getMetaCount()) + " sets."); + // Iterate once for each meta + for (int i = 0; i < (1 + getMetaCount()); i++) { + + // File Name Suffixes, without meta tags + aStringBot = "Bottom"; + aStringTop = "Top"; + aStringBack = "Back"; + aStringFront = "Front"; + aStringLeft = "Left"; + aStringRight = "Right"; + + // Add tails if we have meta + if (hasMeta()) { + aStringBot = aStringBot + "_" + i; + aStringTop = aStringTop + "_" + i; + aStringBack = aStringBack + "_" + i; + aStringFront = aStringFront + "_" + i; + aStringLeft = aStringLeft + "_" + i; + aStringRight = aStringRight + "_" + i; + } + // Append the full path + aStringBot = aTexPathBuilt + aStringBot; + aStringTop = aTexPathBuilt + aStringTop; + aStringBack = aTexPathBuilt + aStringBack; + aStringFront = aTexPathBuilt + aStringFront; + aStringLeft = aTexPathBuilt + aStringLeft; + aStringRight = aTexPathBuilt + aStringRight; + // Convenience Blob + CubicObject aMetaBlob = new CubicObject( + aStringBot, aStringTop, aStringBack, aStringFront, aStringLeft, aStringRight); + mSidedTexturePathArray.put(aMetaBlob); + Logger.INFO("[TeTexture] Added Texture Path data to map for meta " + i); + } + } + Logger.INFO("[TeTexture] Map size for pathing: " + mSidedTexturePathArray.size()); + + // Iteration Index + int aIndex = 0; + + // Iterate each CubicObject, holding the six texture paths for each meta. + for (CubicObject aMetaBlob : mSidedTexturePathArray) { + // Make a Safe Texture for each side + SafeTexture aBottom = SafeTexture.register(aMetaBlob.DOWN); + SafeTexture aTop = SafeTexture.register(aMetaBlob.UP); + SafeTexture aBack = SafeTexture.register(aMetaBlob.NORTH); + SafeTexture aFont = SafeTexture.register(aMetaBlob.SOUTH); + SafeTexture aWest = SafeTexture.register(aMetaBlob.WEST); + SafeTexture aEast = SafeTexture.register(aMetaBlob.EAST); + // Store them in an Array + SafeTexture[] aInjectBlob = new SafeTexture[] {aBottom, aTop, aBack, aFont, aWest, aEast}; + // Convenience Blob + CubicObject aMetaBlob2 = new CubicObject(aInjectBlob); + // Store this Blob into + mSidedTextureArray.put(aMetaBlob2); + Logger.INFO("[TeTexture] Added SafeTexture data to map for meta " + (aIndex++)); + } + Logger.INFO("[TeTexture] Map size for registration: " + mSidedTextureArray.size()); + } + + @Override + @SideOnly(Side.CLIENT) + public final void registerBlockIcons(final IIconRegister aRegisterer) { + this.blockIcon = aRegisterer.registerIcon(CORE.MODID + ":" + "net"); + } + + @Override + public abstract TileEntity createNewTileEntity(final World world, final int p_149915_2_); + + /** + * Called when {@link #breakBlock}() is called, but before {@link InventoryUtils#dropInventoryItems} and the super call. + */ + public void onBlockBreak() {} + + @Override + public final void breakBlock( + final World world, final int x, final int y, final int z, final Block block, final int number) { + onBlockBreak(); + InventoryUtils.dropInventoryItems(world, x, y, z, block); + super.breakBlock(world, x, y, z, block, number); + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public final void getSubBlocks(Item aItem, CreativeTabs p_149666_2_, List aList) { + if (hasMeta()) { + for (int i = 0; i < getMetaCount(); i++) { + aList.add(ItemUtils.simpleMetaStack(aItem, i, 1)); + } + } else { + aList.add(ItemUtils.getSimpleStack(aItem)); + } + } + + @Override + public boolean canCreatureSpawn( + final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + /** + * Get the block's damage value (for use with pick block). + */ + @Override + public int getDamageValue(World aWorld, int aX, int aY, int aZ) { + int l = aWorld.getBlockMetadata(aX, aY, aZ); + return l; + } + + public Item getItemDropped(int meta, Random rand, int p_149650_3_) { return ItemUtils.getSimpleStack(this, 1).getItem(); } - - public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune){ - ArrayList drops = new ArrayList(); - drops.add(ItemUtils.simpleMetaStack(this, metadata, 1)); - return drops; + + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + ArrayList drops = new ArrayList(); + drops.add(ItemUtils.simpleMetaStack(this, metadata, 1)); + return drops; } -} \ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/core/block/base/BlockBaseFluid.java b/src/main/java/gtPlusPlus/core/block/base/BlockBaseFluid.java index db37e18a32..f48601447a 100644 --- a/src/main/java/gtPlusPlus/core/block/base/BlockBaseFluid.java +++ b/src/main/java/gtPlusPlus/core/block/base/BlockBaseFluid.java @@ -1,103 +1,104 @@ package gtPlusPlus.core.block.base; -import java.util.Random; - import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.common.Optional; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.core.client.renderer.particle.EntityDropParticleFX; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.itemblock.ItemBlockMeta; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import java.util.Random; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EnumCreatureType; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import gtPlusPlus.core.client.renderer.particle.EntityDropParticleFX; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.item.base.itemblock.ItemBlockMeta; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.BlockFluidClassic; import net.minecraftforge.fluids.Fluid; public class BlockBaseFluid extends BlockFluidClassic { - private final String name; - private final IIcon textureArray[] = new IIcon[6]; - - protected float particleRed = 1.0F; - protected float particleGreen = 1.0F; - protected float particleBlue = 1.0F; - - public BlockBaseFluid(String materialName, Fluid fluid, Material material) { - super(fluid, material); - this.setLightOpacity(2); - this.name = Utils.sanitizeString(materialName); - this.setBlockName("fluid"+this.name); - this.setCreativeTab(AddToCreativeTab.tabBlock); - GameRegistry.registerBlock(this, ItemBlockMeta.class, "fluid"+this.name); - } + private final String name; + private final IIcon textureArray[] = new IIcon[6]; - public BlockFluidClassic setParticleColor(int arg0) { - return this.setParticleColor((arg0 >> 16 & 255) / 255.0F, (arg0 >> 8 & 255) / 255.0F, - (arg0 >> 0 & 255) / 255.0F); - } + protected float particleRed = 1.0F; + protected float particleGreen = 1.0F; + protected float particleBlue = 1.0F; - public BlockFluidClassic setParticleColor(float arg0, float arg1, float arg2) { - this.particleRed = arg0; - this.particleGreen = arg1; - this.particleBlue = arg2; - return this; - } + public BlockBaseFluid(String materialName, Fluid fluid, Material material) { + super(fluid, material); + this.setLightOpacity(2); + this.name = Utils.sanitizeString(materialName); + this.setBlockName("fluid" + this.name); + this.setCreativeTab(AddToCreativeTab.tabBlock); + GameRegistry.registerBlock(this, ItemBlockMeta.class, "fluid" + this.name); + } - @Override - public boolean canCreatureSpawn(EnumCreatureType arg0, IBlockAccess arg1, int arg2, int arg3, int arg4) { - return false; - } + public BlockFluidClassic setParticleColor(int arg0) { + return this.setParticleColor( + (arg0 >> 16 & 255) / 255.0F, (arg0 >> 8 & 255) / 255.0F, (arg0 >> 0 & 255) / 255.0F); + } - public boolean preInit() { - return true; - } + public BlockFluidClassic setParticleColor(float arg0, float arg1, float arg2) { + this.particleRed = arg0; + this.particleGreen = arg1; + this.particleBlue = arg2; + return this; + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int meta) { - return side <= 1 ? this.textureArray[0] : this.textureArray[1]; - } + @Override + public boolean canCreatureSpawn(EnumCreatureType arg0, IBlockAccess arg1, int arg2, int arg3, int arg4) { + return false; + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister iicon) { - this.textureArray[0] = iicon.registerIcon(CORE.MODID + ":" + "fluid/" + "Fluid_" + this.name + "_Still"); - this.textureArray[1] = iicon.registerIcon(CORE.MODID + ":" + "fluid/" + "Fluid_" + this.name + "_Flow"); - //IconRegistry.addIcon("Fluid" + this.name, this.modName + ":fluid/Fluid_" + this.name + "_Still", arg0); - //IconRegistry.addIcon("Fluid" + this.name + "1", this.modName + ":fluid/Fluid_" + this.name + "_Flow", arg0); - } + public boolean preInit() { + return true; + } - @Override - @Optional.Method(modid = "CoFHCore") - @SideOnly(Side.CLIENT) - public void randomDisplayTick(World arg0, int arg1, int arg2, int arg3, Random arg4) { - super.randomDisplayTick(arg0, arg1, arg2, arg3, arg4); - double arg5 = arg1 + arg4.nextFloat(); - double arg7 = arg2 - 1.05D; - double arg9 = arg3 + arg4.nextFloat(); - if (super.density < 0) { - arg7 = arg2 + 2.1D; - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + return side <= 1 ? this.textureArray[0] : this.textureArray[1]; + } - if (arg4.nextInt(20) == 0 - && arg0.isSideSolid(arg1, arg2 + super.densityDir, arg3, - super.densityDir == -1 ? ForgeDirection.UP : ForgeDirection.DOWN) - && !arg0.getBlock(arg1, arg2 + 2 * super.densityDir, arg3).getMaterial().blocksMovement()) { - EntityDropParticleFX arg11 = new EntityDropParticleFX(arg0, arg5, arg7, arg9, this.particleRed, - this.particleGreen, this.particleBlue, super.densityDir); - FMLClientHandler.instance().getClient().effectRenderer.addEffect(arg11); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iicon) { + this.textureArray[0] = iicon.registerIcon(CORE.MODID + ":" + "fluid/" + "Fluid_" + this.name + "_Still"); + this.textureArray[1] = iicon.registerIcon(CORE.MODID + ":" + "fluid/" + "Fluid_" + this.name + "_Flow"); + // IconRegistry.addIcon("Fluid" + this.name, this.modName + ":fluid/Fluid_" + this.name + "_Still", arg0); + // IconRegistry.addIcon("Fluid" + this.name + "1", this.modName + ":fluid/Fluid_" + this.name + "_Flow", arg0); + } - } + @Override + @Optional.Method(modid = "CoFHCore") + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World arg0, int arg1, int arg2, int arg3, Random arg4) { + super.randomDisplayTick(arg0, arg1, arg2, arg3, arg4); + double arg5 = arg1 + arg4.nextFloat(); + double arg7 = arg2 - 1.05D; + double arg9 = arg3 + arg4.nextFloat(); + if (super.density < 0) { + arg7 = arg2 + 2.1D; + } + if (arg4.nextInt(20) == 0 + && arg0.isSideSolid( + arg1, + arg2 + super.densityDir, + arg3, + super.densityDir == -1 ? ForgeDirection.UP : ForgeDirection.DOWN) + && !arg0.getBlock(arg1, arg2 + 2 * super.densityDir, arg3) + .getMaterial() + .blocksMovement()) { + EntityDropParticleFX arg11 = new EntityDropParticleFX( + arg0, arg5, arg7, arg9, this.particleRed, this.particleGreen, this.particleBlue, super.densityDir); + FMLClientHandler.instance().getClient().effectRenderer.addEffect(arg11); + } + } } diff --git a/src/main/java/gtPlusPlus/core/block/base/BlockBaseModular.java b/src/main/java/gtPlusPlus/core/block/base/BlockBaseModular.java index f1e415ae76..14e4fb6067 100644 --- a/src/main/java/gtPlusPlus/core/block/base/BlockBaseModular.java +++ b/src/main/java/gtPlusPlus/core/block/base/BlockBaseModular.java @@ -1,8 +1,5 @@ package gtPlusPlus.core.block.base; -import java.util.HashMap; -import java.util.Map; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -17,6 +14,8 @@ import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import java.util.HashMap; +import java.util.Map; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; @@ -24,195 +23,207 @@ import net.minecraft.world.IBlockAccess; public class BlockBaseModular extends BasicBlock { - protected Material blockMaterial; - - protected int blockColour; - public BlockTypes thisBlock; - protected String thisBlockMaterial; - protected final String thisBlockType; - - private static HashMap sBlockCache = new HashMap(); - - public static Block getMaterialBlock(Material aMaterial, BlockTypes aType) { - return sBlockCache.get(aMaterial.getUnlocalizedName()+"."+aType.name()); - } - - public BlockBaseModular(final Material material, final BlockTypes blockType) { - this(material, blockType, material.getRgbAsHex()); - } - - public BlockBaseModular(final Material material, final BlockTypes blockType, final int colour) { - this(material.getUnlocalizedName(), material.getLocalizedName(), net.minecraft.block.material.Material.iron, - blockType, colour, Math.min(Math.max(material.vTier, 1), 6)); - blockMaterial = material; - registerComponent(); - if (material != null) { - sBlockCache.put(material.getUnlocalizedName()+"."+blockType.name(), this); - } - } - - protected BlockBaseModular(final String unlocalizedName, final String blockMaterialString, - final net.minecraft.block.material.Material vanillaMaterial, final BlockTypes blockType, final int colour, - final int miningLevel) { - super(blockType, unlocalizedName, vanillaMaterial, miningLevel); - this.setHarvestLevel(blockType.getHarvestTool(), miningLevel); - this.setBlockTextureName(CORE.MODID + ":" + blockType.getTexture()); - this.blockColour = colour; - this.thisBlock = blockType; - this.thisBlockMaterial = blockMaterialString; - this.thisBlockType = blockType.name().toUpperCase(); - this.setBlockName(this.GetProperName()); - int fx = getBlockTypeMeta(); - //ItemBlockGtBlock.sNameCache.put("block."+blockMaterial.getUnlocalizedName()+"."+this.thisBlock.name().toLowerCase(), GetProperName()); - GameRegistry.registerBlock(this, ItemBlockGtBlock.class, Utils.sanitizeString(blockType.getTexture() + unlocalizedName)); - if (fx == 0) { - GT_OreDictUnificator.registerOre("block" + unifyMaterialName(thisBlockMaterial), ItemUtils.getSimpleStack(this)); - } - else if (fx == 1) { - GT_OreDictUnificator.registerOre("frameGt" + unifyMaterialName(thisBlockMaterial), ItemUtils.getSimpleStack(this)); - } - else if (fx == 2) { - GT_OreDictUnificator.registerOre("frameGt" + unifyMaterialName(thisBlockMaterial), ItemUtils.getSimpleStack(this)); - } - } - - public static String unifyMaterialName(String rawMaterName) { - return rawMaterName.replace(" ", "").replace("-", "").replace("_", ""); - } - - public boolean registerComponent() { - Logger.MATERIALS("Attempting to register "+this.getUnlocalizedName()+"."); - if (this.blockMaterial == null) { - Logger.MATERIALS("Tried to register "+this.getUnlocalizedName()+" but the material was null."); - return false; - } - String aName = blockMaterial.getUnlocalizedName(); - //Register Component - Map aMap = Material.mComponentMap.get(aName); - if (aMap == null) { - aMap = new HashMap(); - } - int fx = getBlockTypeMeta(); - String aKey = (fx == 0 ? OrePrefixes.block.name() : ( fx == 1 ? OrePrefixes.frameGt.name() : OrePrefixes.ore.name())); - ItemStack x = aMap.get(aKey); - if (x == null) { - aMap.put(aKey, ItemUtils.getSimpleStack(this)); - Logger.MATERIALS("Registering a material component. Item: ["+aName+"] Map: ["+aKey+"]"); - Material.mComponentMap.put(aName, aMap); - return true; - } - else { - //Bad - Logger.MATERIALS("Tried to double register a material component."); - return false; - } - } - - public int getBlockTypeMeta() { - if (this.thisBlockType.equals(BlockTypes.STANDARD.name().toUpperCase())) { - return 0; - } - else if (this.thisBlockType.equals(BlockTypes.FRAME.name().toUpperCase())) { - return 1; - } - else if (this.thisBlockType.equals(BlockTypes.ORE.name().toUpperCase())) { - return 2; - } - return 0; - } - - /** - * Returns which pass should this block be rendered on. 0 for solids and 1 - * for alpha - */ - @Override - @SideOnly(Side.CLIENT) - public int getRenderBlockPass() { - if (this.thisBlock == BlockTypes.FRAME) { - return 1; - } - return 0; - } - - public String GetProperName() { - String tempIngot = null; - if (this.thisBlock == BlockTypes.STANDARD) { - tempIngot = "Block of " + this.thisBlockMaterial; - } - else if (this.thisBlock == BlockTypes.FRAME) { - tempIngot = this.thisBlockMaterial + " Frame Box"; - } - else if (this.thisBlock == BlockTypes.ORE) { - tempIngot = this.thisBlockMaterial + " Ore [Old]"; - } - return tempIngot; - } - - @Override - public String getLocalizedName() { - String aFormattedLangName = GetProperName(); - return GT_LanguageManager.addStringLocalization("block."+blockMaterial.getUnlocalizedName()+"."+this.thisBlock.name().toLowerCase()+".name", aFormattedLangName); - } - - @Override - public String getUnlocalizedName() { - return "block."+blockMaterial.getUnlocalizedName()+"."+this.thisBlock.name().toLowerCase(); - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - public Material getMaterialEx(){ - return this.blockMaterial; - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister iIcon) { - if (!CORE.ConfigSwitches.useGregtechTextures || this.blockMaterial == null || this.thisBlock == BlockTypes.ORE){ - this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + this.thisBlock.getTexture()); - } - String metType = "9j4852jyo3rjmh3owlhw9oe"; - if (this.blockMaterial != null) { - TextureSet u = this.blockMaterial.getTextureSet(); - if (u != null) { - metType = u.mSetName; - } - } - metType = (metType.equals("9j4852jyo3rjmh3owlhw9oe") ? "METALLIC" : metType); - int tier = blockMaterial != null ? this.blockMaterial.vTier : 0; - String aType = (this.thisBlock == BlockTypes.FRAME) ? "frameGt" : (tier <= 4 ? "block1" : "block5"); - this.blockIcon = iIcon.registerIcon("gregtech" + ":" + "materialicons/"+ metType +"/" + aType); - } - - @Override - public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4) { - - if (this.blockColour == 0) { - return MathUtils.generateSingularRandomHexValue(); - } - - return this.blockColour; - } - - @Override - public int getRenderColor(final int aMeta) { - if (this.blockColour == 0) { - return MathUtils.generateSingularRandomHexValue(); - } - - return this.blockColour; - } - - @Override - public int getBlockColor() { - if (this.blockColour == 0) { - return MathUtils.generateSingularRandomHexValue(); - } - - return this.blockColour; - } - + protected Material blockMaterial; + + protected int blockColour; + public BlockTypes thisBlock; + protected String thisBlockMaterial; + protected final String thisBlockType; + + private static HashMap sBlockCache = new HashMap(); + + public static Block getMaterialBlock(Material aMaterial, BlockTypes aType) { + return sBlockCache.get(aMaterial.getUnlocalizedName() + "." + aType.name()); + } + + public BlockBaseModular(final Material material, final BlockTypes blockType) { + this(material, blockType, material.getRgbAsHex()); + } + + public BlockBaseModular(final Material material, final BlockTypes blockType, final int colour) { + this( + material.getUnlocalizedName(), + material.getLocalizedName(), + net.minecraft.block.material.Material.iron, + blockType, + colour, + Math.min(Math.max(material.vTier, 1), 6)); + blockMaterial = material; + registerComponent(); + if (material != null) { + sBlockCache.put(material.getUnlocalizedName() + "." + blockType.name(), this); + } + } + + protected BlockBaseModular( + final String unlocalizedName, + final String blockMaterialString, + final net.minecraft.block.material.Material vanillaMaterial, + final BlockTypes blockType, + final int colour, + final int miningLevel) { + super(blockType, unlocalizedName, vanillaMaterial, miningLevel); + this.setHarvestLevel(blockType.getHarvestTool(), miningLevel); + this.setBlockTextureName(CORE.MODID + ":" + blockType.getTexture()); + this.blockColour = colour; + this.thisBlock = blockType; + this.thisBlockMaterial = blockMaterialString; + this.thisBlockType = blockType.name().toUpperCase(); + this.setBlockName(this.GetProperName()); + int fx = getBlockTypeMeta(); + // ItemBlockGtBlock.sNameCache.put("block."+blockMaterial.getUnlocalizedName()+"."+this.thisBlock.name().toLowerCase(), GetProperName()); + GameRegistry.registerBlock( + this, ItemBlockGtBlock.class, Utils.sanitizeString(blockType.getTexture() + unlocalizedName)); + if (fx == 0) { + GT_OreDictUnificator.registerOre( + "block" + unifyMaterialName(thisBlockMaterial), ItemUtils.getSimpleStack(this)); + } else if (fx == 1) { + GT_OreDictUnificator.registerOre( + "frameGt" + unifyMaterialName(thisBlockMaterial), ItemUtils.getSimpleStack(this)); + } else if (fx == 2) { + GT_OreDictUnificator.registerOre( + "frameGt" + unifyMaterialName(thisBlockMaterial), ItemUtils.getSimpleStack(this)); + } + } + + public static String unifyMaterialName(String rawMaterName) { + return rawMaterName.replace(" ", "").replace("-", "").replace("_", ""); + } + + public boolean registerComponent() { + Logger.MATERIALS("Attempting to register " + this.getUnlocalizedName() + "."); + if (this.blockMaterial == null) { + Logger.MATERIALS("Tried to register " + this.getUnlocalizedName() + " but the material was null."); + return false; + } + String aName = blockMaterial.getUnlocalizedName(); + // Register Component + Map aMap = Material.mComponentMap.get(aName); + if (aMap == null) { + aMap = new HashMap(); + } + int fx = getBlockTypeMeta(); + String aKey = + (fx == 0 ? OrePrefixes.block.name() : (fx == 1 ? OrePrefixes.frameGt.name() : OrePrefixes.ore.name())); + ItemStack x = aMap.get(aKey); + if (x == null) { + aMap.put(aKey, ItemUtils.getSimpleStack(this)); + Logger.MATERIALS("Registering a material component. Item: [" + aName + "] Map: [" + aKey + "]"); + Material.mComponentMap.put(aName, aMap); + return true; + } else { + // Bad + Logger.MATERIALS("Tried to double register a material component."); + return false; + } + } + + public int getBlockTypeMeta() { + if (this.thisBlockType.equals(BlockTypes.STANDARD.name().toUpperCase())) { + return 0; + } else if (this.thisBlockType.equals(BlockTypes.FRAME.name().toUpperCase())) { + return 1; + } else if (this.thisBlockType.equals(BlockTypes.ORE.name().toUpperCase())) { + return 2; + } + return 0; + } + + /** + * Returns which pass should this block be rendered on. 0 for solids and 1 + * for alpha + */ + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() { + if (this.thisBlock == BlockTypes.FRAME) { + return 1; + } + return 0; + } + + public String GetProperName() { + String tempIngot = null; + if (this.thisBlock == BlockTypes.STANDARD) { + tempIngot = "Block of " + this.thisBlockMaterial; + } else if (this.thisBlock == BlockTypes.FRAME) { + tempIngot = this.thisBlockMaterial + " Frame Box"; + } else if (this.thisBlock == BlockTypes.ORE) { + tempIngot = this.thisBlockMaterial + " Ore [Old]"; + } + return tempIngot; + } + + @Override + public String getLocalizedName() { + String aFormattedLangName = GetProperName(); + return GT_LanguageManager.addStringLocalization( + "block." + blockMaterial.getUnlocalizedName() + "." + + this.thisBlock.name().toLowerCase() + ".name", + aFormattedLangName); + } + + @Override + public String getUnlocalizedName() { + return "block." + blockMaterial.getUnlocalizedName() + "." + + this.thisBlock.name().toLowerCase(); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + public Material getMaterialEx() { + return this.blockMaterial; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iIcon) { + if (!CORE.ConfigSwitches.useGregtechTextures + || this.blockMaterial == null + || this.thisBlock == BlockTypes.ORE) { + this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + this.thisBlock.getTexture()); + } + String metType = "9j4852jyo3rjmh3owlhw9oe"; + if (this.blockMaterial != null) { + TextureSet u = this.blockMaterial.getTextureSet(); + if (u != null) { + metType = u.mSetName; + } + } + metType = (metType.equals("9j4852jyo3rjmh3owlhw9oe") ? "METALLIC" : metType); + int tier = blockMaterial != null ? this.blockMaterial.vTier : 0; + String aType = (this.thisBlock == BlockTypes.FRAME) ? "frameGt" : (tier <= 4 ? "block1" : "block5"); + this.blockIcon = iIcon.registerIcon("gregtech" + ":" + "materialicons/" + metType + "/" + aType); + } + + @Override + public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4) { + + if (this.blockColour == 0) { + return MathUtils.generateSingularRandomHexValue(); + } + + return this.blockColour; + } + + @Override + public int getRenderColor(final int aMeta) { + if (this.blockColour == 0) { + return MathUtils.generateSingularRandomHexValue(); + } + + return this.blockColour; + } + + @Override + public int getBlockColor() { + if (this.blockColour == 0) { + return MathUtils.generateSingularRandomHexValue(); + } + + return this.blockColour; + } } diff --git a/src/main/java/gtPlusPlus/core/block/base/BlockBaseNBT.java b/src/main/java/gtPlusPlus/core/block/base/BlockBaseNBT.java index e4dff82ec4..1697244ff5 100644 --- a/src/main/java/gtPlusPlus/core/block/base/BlockBaseNBT.java +++ b/src/main/java/gtPlusPlus/core/block/base/BlockBaseNBT.java @@ -3,7 +3,8 @@ package gtPlusPlus.core.block.base; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.itemblock.ItemBlockNBT; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -15,67 +16,72 @@ import net.minecraft.world.Explosion; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.item.base.itemblock.ItemBlockNBT; +public abstract class BlockBaseNBT extends BlockContainer { + @SideOnly(Side.CLIENT) + private IIcon textureTop; -public abstract class BlockBaseNBT extends BlockContainer -{ - @SideOnly(Side.CLIENT) - private IIcon textureTop; - @SideOnly(Side.CLIENT) - private IIcon textureBottom; - @SideOnly(Side.CLIENT) - private IIcon textureFront; + @SideOnly(Side.CLIENT) + private IIcon textureBottom; - @SuppressWarnings("deprecation") - public BlockBaseNBT(final Material material, final String unlocalName, final String displayName){ - super(material); - this.setBlockName(unlocalName); - this.setCreativeTab(AddToCreativeTab.tabMachines); - GameRegistry.registerBlock(this, ItemBlockNBT.class, unlocalName); - //LanguageRegistry.addName(this, displayName); - } + @SideOnly(Side.CLIENT) + private IIcon textureFront; - /** - * Gets the block's texture. Args: side, meta - */ - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(final int p_149691_1_, final int p_149691_2_){ - return p_149691_1_ == 1 ? this.textureTop : (p_149691_1_ == 0 ? this.textureBottom : ((p_149691_1_ != 2) && (p_149691_1_ != 4) ? this.blockIcon : this.textureFront)); - } + @SuppressWarnings("deprecation") + public BlockBaseNBT(final Material material, final String unlocalName, final String displayName) { + super(material); + this.setBlockName(unlocalName); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockNBT.class, unlocalName); + // LanguageRegistry.addName(this, displayName); + } - @Override - public abstract TileEntity createNewTileEntity(final World world, final int p_149915_2_); + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) { + return p_149691_1_ == 1 + ? this.textureTop + : (p_149691_1_ == 0 + ? this.textureBottom + : ((p_149691_1_ != 2) && (p_149691_1_ != 4) ? this.blockIcon : this.textureFront)); + } - @Override - public void breakBlock(final World world, final int x, final int y, final int z, final Block block, final int meta) { - super.breakBlock(world, x, y, z, block, meta); - } + @Override + public abstract TileEntity createNewTileEntity(final World world, final int p_149915_2_); - @Override - public void onBlockDestroyedByPlayer(final World world, final int x, final int y, final int z, final int meta) { - super.onBlockDestroyedByPlayer(world, x, y, z, meta); - } + @Override + public void breakBlock( + final World world, final int x, final int y, final int z, final Block block, final int meta) { + super.breakBlock(world, x, y, z, block, meta); + } - @Override - public void onBlockDestroyedByExplosion(final World world, final int x, final int y, final int z, final Explosion explosion) { - super.onBlockDestroyedByExplosion(world, x, y, z, explosion); - } + @Override + public void onBlockDestroyedByPlayer(final World world, final int x, final int y, final int z, final int meta) { + super.onBlockDestroyedByPlayer(world, x, y, z, meta); + } - @Override - public void onBlockHarvested(final World world, final int x, final int y, final int z, final int meta, final EntityPlayer player) { - super.onBlockHarvested(world, x, y, z, meta, player); - } + @Override + public void onBlockDestroyedByExplosion( + final World world, final int x, final int y, final int z, final Explosion explosion) { + super.onBlockDestroyedByExplosion(world, x, y, z, explosion); + } - @Override - public void onBlockExploded(final World world, final int x, final int y, final int z, final Explosion explosion) { - super.onBlockExploded(world, x, y, z, explosion); - } + @Override + public void onBlockHarvested( + final World world, final int x, final int y, final int z, final int meta, final EntityPlayer player) { + super.onBlockHarvested(world, x, y, z, meta, player); + } - @Override - public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { - return false; - } + @Override + public void onBlockExploded(final World world, final int x, final int y, final int z, final Explosion explosion) { + super.onBlockExploded(world, x, y, z, explosion); + } -} \ No newline at end of file + @Override + public boolean canCreatureSpawn( + final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/core/block/base/BlockBaseOre.java b/src/main/java/gtPlusPlus/core/block/base/BlockBaseOre.java index df69a050a6..81f1737f8c 100644 --- a/src/main/java/gtPlusPlus/core/block/base/BlockBaseOre.java +++ b/src/main/java/gtPlusPlus/core/block/base/BlockBaseOre.java @@ -1,7 +1,5 @@ package gtPlusPlus.core.block.base; -import java.lang.reflect.Field; - import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.Textures; @@ -18,6 +16,7 @@ import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.objects.GTPP_CopiedBlockTexture; import gtPlusPlus.xmod.gregtech.api.objects.GTPP_RenderedTexture; +import java.lang.reflect.Field; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EnumCreatureType; @@ -27,203 +26,220 @@ import net.minecraft.world.IBlockAccess; public class BlockBaseOre extends BasicBlock implements ITexturedBlock { - private final Material blockMaterial; - - public BlockBaseOre(final Material material, final BlockTypes blockType, final int colour) { - super(blockType, Utils.sanitizeString(material.getUnlocalizedName()), net.minecraft.block.material.Material.rock, Math.min(Math.max(material.vTier, 1), 6)); - int aMaterialTierForMining = Math.min(Math.max(material.vTier, 1), 6); - this.blockMaterial = material; - this.setHardness(1.0f*aMaterialTierForMining); - this.setResistance(6.0F); - this.setLightLevel(0.0F); - this.setHarvestLevel("pickaxe", aMaterialTierForMining); - this.setStepSound(soundTypeStone); - this.setBlockName("Ore"+Utils.sanitizeString(Utils.sanitizeString(material.getUnlocalizedName()))); - this.setBlockTextureName("stone"); - try { - GameRegistry.registerBlock(this, ItemBlockOre.class, Utils.sanitizeString("ore"+Utils.sanitizeString(this.blockMaterial.getLocalizedName()))); - GT_OreDictUnificator.registerOre("ore"+Utils.sanitizeString(this.blockMaterial.getLocalizedName()), ItemUtils.getSimpleStack(this)); - } - catch (Throwable t){ - t.printStackTrace(); - } - } - - @Override - public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { - return false; - } - - public Material getMaterialEx(){ - return this.blockMaterial; - } - - @Override - public int getRenderType() { - try { - if (CustomOreBlockRenderer.INSTANCE != null){ - return CustomOreBlockRenderer.INSTANCE.mRenderID; - } - return super.getRenderType(); - } - catch (NullPointerException n) { - return 0; - } - } - - @Override - public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int aSide) { - return Blocks.stone.getIcon(0, 0); - } - - @Override - public IIcon getIcon(int aSide, int aMeta) { - return Blocks.stone.getIcon(0, 0); - } - - /** - * GT Texture Handler - */ - - //.08 compat - public static IIconContainer[] hiddenTextureArray; - public ITexture[] getTexture(byte arg0) { - return getTexture(null, arg0); - } - - public ITexture[] getTexture(Block block, byte side) { - if (this.blockMaterial != null){ - GTPP_RenderedTexture aIconSet = new GTPP_RenderedTexture(blockMaterial.getTextureSet().mTextures[OrePrefixes.ore.mTextureIndex], this.blockMaterial.getRGBA()); - if (aIconSet != null){ - return new ITexture[]{new GTPP_CopiedBlockTexture(Blocks.stone, 0, 0), aIconSet}; - } - } - - if (hiddenTextureArray == null){ - if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ - hiddenTextureArray = Textures.BlockIcons.GRANITES; - } - else { - try { - Field o = ReflectionUtils.getField(Textures.BlockIcons.class, "STONES"); - if (o != null){ - hiddenTextureArray = (IIconContainer[]) o.get(Textures.BlockIcons.class); - } - if (hiddenTextureArray == null){ - hiddenTextureArray = new IIconContainer[6]; - } - } - catch (IllegalArgumentException | IllegalAccessException e) { - hiddenTextureArray = new IIconContainer[6]; - } - } - } - return new ITexture[]{new GTPP_RenderedTexture(hiddenTextureArray[0], new short[]{240, 240, 240, 0})}; - } - - @Override - public void registerBlockIcons(IIconRegister p_149651_1_) { - - } - - public static class oldOreBlock extends BlockBaseModular implements ITexturedBlock{ - - public oldOreBlock(final String unlocalizedName, final String blockMaterial, final BlockTypes blockType, final int colour) { - this(unlocalizedName, blockMaterial, net.minecraft.block.material.Material.iron, blockType, colour, 2); - } - - public oldOreBlock(final String unlocalizedName, final String blockMaterial, final net.minecraft.block.material.Material vanillaMaterial, final BlockTypes blockType, final int colour, final int miningLevel) { - super(unlocalizedName, blockMaterial, vanillaMaterial, blockType, colour, miningLevel); - } - - /*@Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister iIcon) - { - this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + this.thisBlock.getTexture()); - //this.base = iIcon.registerIcon(CORE.MODID + ":" + "blockStone"); - //this.overlay = iIcon.registerIcon(CORE.MODID + ":" + "blockOre_Overlay"); - } - - @Override - public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4){ - if (this.blockColour == 0){ - return MathUtils.generateSingularRandomHexValue(); - } - return this.blockColour; - } - - @Override - public int getRenderColor(final int aMeta) { - if (this.blockColour == 0){ - return MathUtils.generateSingularRandomHexValue(); - } - return this.blockColour; - }*/ - - @Override - public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { - return false; - } - - @Override - public int getRenderType() { - if (CustomOreBlockRenderer.INSTANCE != null){ - return CustomOreBlockRenderer.INSTANCE.mRenderID; - } - return super.getRenderType(); - } - - @Override - public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int aSide) { - return Blocks.stone.getIcon(0, 0); - } - - @Override - public IIcon getIcon(int aSide, int aMeta) { - return Blocks.stone.getIcon(0, 0); - } - - /** - * GT Texture Handler - */ - - //.08 compat - IIconContainer[] hiddenTextureArray; - public ITexture[] getTexture(byte arg0) { - return getTexture(null, arg0); - } - - public ITexture[] getTexture(Block block, byte side) { - if (this.blockMaterial != null){ - GTPP_RenderedTexture aIconSet = new GTPP_RenderedTexture(blockMaterial.getTextureSet().mTextures[OrePrefixes.ore.mTextureIndex], this.blockMaterial.getRGBA()); - if (aIconSet != null){ - return new ITexture[]{new GTPP_CopiedBlockTexture(Blocks.stone, 0, 0), aIconSet}; - } - } - - if (hiddenTextureArray == null){ - if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ - hiddenTextureArray = Textures.BlockIcons.GRANITES; - } - else { - try { - Field o = ReflectionUtils.getField(Textures.BlockIcons.class, "STONES"); - if (o != null){ - hiddenTextureArray = (IIconContainer[]) o.get(Textures.BlockIcons.class); - } - if (hiddenTextureArray == null){ - hiddenTextureArray = new IIconContainer[6]; - } - } - catch (IllegalArgumentException | IllegalAccessException e) { - hiddenTextureArray = new IIconContainer[6]; - } - } - } - return new ITexture[]{new GTPP_RenderedTexture(hiddenTextureArray[0], new short[]{240, 240, 240, 0})}; - } - - } - + private final Material blockMaterial; + + public BlockBaseOre(final Material material, final BlockTypes blockType, final int colour) { + super( + blockType, + Utils.sanitizeString(material.getUnlocalizedName()), + net.minecraft.block.material.Material.rock, + Math.min(Math.max(material.vTier, 1), 6)); + int aMaterialTierForMining = Math.min(Math.max(material.vTier, 1), 6); + this.blockMaterial = material; + this.setHardness(1.0f * aMaterialTierForMining); + this.setResistance(6.0F); + this.setLightLevel(0.0F); + this.setHarvestLevel("pickaxe", aMaterialTierForMining); + this.setStepSound(soundTypeStone); + this.setBlockName("Ore" + Utils.sanitizeString(Utils.sanitizeString(material.getUnlocalizedName()))); + this.setBlockTextureName("stone"); + try { + GameRegistry.registerBlock( + this, + ItemBlockOre.class, + Utils.sanitizeString("ore" + Utils.sanitizeString(this.blockMaterial.getLocalizedName()))); + GT_OreDictUnificator.registerOre( + "ore" + Utils.sanitizeString(this.blockMaterial.getLocalizedName()), + ItemUtils.getSimpleStack(this)); + } catch (Throwable t) { + t.printStackTrace(); + } + } + + @Override + public boolean canCreatureSpawn( + final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + public Material getMaterialEx() { + return this.blockMaterial; + } + + @Override + public int getRenderType() { + try { + if (CustomOreBlockRenderer.INSTANCE != null) { + return CustomOreBlockRenderer.INSTANCE.mRenderID; + } + return super.getRenderType(); + } catch (NullPointerException n) { + return 0; + } + } + + @Override + public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int aSide) { + return Blocks.stone.getIcon(0, 0); + } + + @Override + public IIcon getIcon(int aSide, int aMeta) { + return Blocks.stone.getIcon(0, 0); + } + + /** + * GT Texture Handler + */ + + // .08 compat + public static IIconContainer[] hiddenTextureArray; + + public ITexture[] getTexture(byte arg0) { + return getTexture(null, arg0); + } + + public ITexture[] getTexture(Block block, byte side) { + if (this.blockMaterial != null) { + GTPP_RenderedTexture aIconSet = new GTPP_RenderedTexture( + blockMaterial.getTextureSet().mTextures[OrePrefixes.ore.mTextureIndex], + this.blockMaterial.getRGBA()); + if (aIconSet != null) { + return new ITexture[] {new GTPP_CopiedBlockTexture(Blocks.stone, 0, 0), aIconSet}; + } + } + + if (hiddenTextureArray == null) { + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + hiddenTextureArray = Textures.BlockIcons.GRANITES; + } else { + try { + Field o = ReflectionUtils.getField(Textures.BlockIcons.class, "STONES"); + if (o != null) { + hiddenTextureArray = (IIconContainer[]) o.get(Textures.BlockIcons.class); + } + if (hiddenTextureArray == null) { + hiddenTextureArray = new IIconContainer[6]; + } + } catch (IllegalArgumentException | IllegalAccessException e) { + hiddenTextureArray = new IIconContainer[6]; + } + } + } + return new ITexture[] {new GTPP_RenderedTexture(hiddenTextureArray[0], new short[] {240, 240, 240, 0})}; + } + + @Override + public void registerBlockIcons(IIconRegister p_149651_1_) {} + + public static class oldOreBlock extends BlockBaseModular implements ITexturedBlock { + + public oldOreBlock( + final String unlocalizedName, + final String blockMaterial, + final BlockTypes blockType, + final int colour) { + this(unlocalizedName, blockMaterial, net.minecraft.block.material.Material.iron, blockType, colour, 2); + } + + public oldOreBlock( + final String unlocalizedName, + final String blockMaterial, + final net.minecraft.block.material.Material vanillaMaterial, + final BlockTypes blockType, + final int colour, + final int miningLevel) { + super(unlocalizedName, blockMaterial, vanillaMaterial, blockType, colour, miningLevel); + } + + /*@Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iIcon) + { + this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + this.thisBlock.getTexture()); + //this.base = iIcon.registerIcon(CORE.MODID + ":" + "blockStone"); + //this.overlay = iIcon.registerIcon(CORE.MODID + ":" + "blockOre_Overlay"); + } + + @Override + public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4){ + if (this.blockColour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return this.blockColour; + } + + @Override + public int getRenderColor(final int aMeta) { + if (this.blockColour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return this.blockColour; + }*/ + + @Override + public boolean canCreatureSpawn( + final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + @Override + public int getRenderType() { + if (CustomOreBlockRenderer.INSTANCE != null) { + return CustomOreBlockRenderer.INSTANCE.mRenderID; + } + return super.getRenderType(); + } + + @Override + public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int aSide) { + return Blocks.stone.getIcon(0, 0); + } + + @Override + public IIcon getIcon(int aSide, int aMeta) { + return Blocks.stone.getIcon(0, 0); + } + + /** + * GT Texture Handler + */ + + // .08 compat + IIconContainer[] hiddenTextureArray; + + public ITexture[] getTexture(byte arg0) { + return getTexture(null, arg0); + } + + public ITexture[] getTexture(Block block, byte side) { + if (this.blockMaterial != null) { + GTPP_RenderedTexture aIconSet = new GTPP_RenderedTexture( + blockMaterial.getTextureSet().mTextures[OrePrefixes.ore.mTextureIndex], + this.blockMaterial.getRGBA()); + if (aIconSet != null) { + return new ITexture[] {new GTPP_CopiedBlockTexture(Blocks.stone, 0, 0), aIconSet}; + } + } + + if (hiddenTextureArray == null) { + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + hiddenTextureArray = Textures.BlockIcons.GRANITES; + } else { + try { + Field o = ReflectionUtils.getField(Textures.BlockIcons.class, "STONES"); + if (o != null) { + hiddenTextureArray = (IIconContainer[]) o.get(Textures.BlockIcons.class); + } + if (hiddenTextureArray == null) { + hiddenTextureArray = new IIconContainer[6]; + } + } catch (IllegalArgumentException | IllegalAccessException e) { + hiddenTextureArray = new IIconContainer[6]; + } + } + } + return new ITexture[] {new GTPP_RenderedTexture(hiddenTextureArray[0], new short[] {240, 240, 240, 0})}; + } + } } diff --git a/src/main/java/gtPlusPlus/core/block/base/MetaBlock.java b/src/main/java/gtPlusPlus/core/block/base/MetaBlock.java index 880bb3a597..68ddd47547 100644 --- a/src/main/java/gtPlusPlus/core/block/base/MetaBlock.java +++ b/src/main/java/gtPlusPlus/core/block/base/MetaBlock.java @@ -1,7 +1,6 @@ package gtPlusPlus.core.block.base; import java.util.List; - import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EnumCreatureType; @@ -11,25 +10,25 @@ import net.minecraft.world.IBlockAccess; public class MetaBlock extends MultiTextureBlock { - protected MetaBlock(final String unlocalizedName, final Material material, final SoundType soundType) { - super(unlocalizedName, material, soundType); - } - - @Override - public int damageDropped(final int meta) { - return meta; - } - - @Override - public void getSubBlocks(final Item item, final CreativeTabs tab, final List list) { - for (int i = 0; i < 6; i ++) { - list.add(new ItemStack(item, 1, i)); - } - } - - @Override - public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { - return false; - } - -} \ No newline at end of file + protected MetaBlock(final String unlocalizedName, final Material material, final SoundType soundType) { + super(unlocalizedName, material, soundType); + } + + @Override + public int damageDropped(final int meta) { + return meta; + } + + @Override + public void getSubBlocks(final Item item, final CreativeTabs tab, final List list) { + for (int i = 0; i < 6; i++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + public boolean canCreatureSpawn( + final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/core/block/base/MultiTextureBlock.java b/src/main/java/gtPlusPlus/core/block/base/MultiTextureBlock.java index a04bf841ba..dfacc26b62 100644 --- a/src/main/java/gtPlusPlus/core/block/base/MultiTextureBlock.java +++ b/src/main/java/gtPlusPlus/core/block/base/MultiTextureBlock.java @@ -1,37 +1,35 @@ package gtPlusPlus.core.block.base; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; - public class MultiTextureBlock extends Block { - public IIcon[] icons = new IIcon[6]; + public IIcon[] icons = new IIcon[6]; - protected MultiTextureBlock(final String unlocalizedName, final Material material, final SoundType blockSound) - { - super(material); - this.setBlockName(unlocalizedName); - this.setBlockTextureName(CORE.MODID + ":" + unlocalizedName); - this.setCreativeTab(AddToCreativeTab.tabBlock); - this.setHardness(2.0F); - this.setResistance(6.0F); - this.setStepSound(blockSound); - } + protected MultiTextureBlock(final String unlocalizedName, final Material material, final SoundType blockSound) { + super(material); + this.setBlockName(unlocalizedName); + this.setBlockTextureName(CORE.MODID + ":" + unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setHardness(2.0F); + this.setResistance(6.0F); + this.setStepSound(blockSound); + } - @Override - public void registerBlockIcons(final IIconRegister reg) { - for (int i = 0; i < 6; i ++) { - this.icons[i] = reg.registerIcon(this.textureName + "_" + i); - } - } + @Override + public void registerBlockIcons(final IIconRegister reg) { + for (int i = 0; i < 6; i++) { + this.icons[i] = reg.registerIcon(this.textureName + "_" + i); + } + } - @Override - public IIcon getIcon(final int side, final int meta) { - return this.icons[side]; - } -} \ No newline at end of file + @Override + public IIcon getIcon(final int side, final int meta) { + return this.icons[side]; + } +} diff --git a/src/main/java/gtPlusPlus/core/block/general/BlockCompressedObsidian.java b/src/main/java/gtPlusPlus/core/block/general/BlockCompressedObsidian.java index 2cf40160a3..3bb09962b5 100644 --- a/src/main/java/gtPlusPlus/core/block/general/BlockCompressedObsidian.java +++ b/src/main/java/gtPlusPlus/core/block/general/BlockCompressedObsidian.java @@ -1,13 +1,14 @@ package gtPlusPlus.core.block.general; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.itemblock.ItemBlockMeta; +import gtPlusPlus.core.lib.CORE; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; import net.minecraft.block.BlockObsidian; import net.minecraft.block.material.MapColor; import net.minecraft.client.renderer.texture.IIconRegister; @@ -17,86 +18,80 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.World; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.item.base.itemblock.ItemBlockMeta; -import gtPlusPlus.core.lib.CORE; - public class BlockCompressedObsidian extends BlockObsidian { - private final IIcon textureArray[] = new IIcon[11]; - - public BlockCompressedObsidian() { - this.setBlockName("blockCompressedObsidian"); - this.setHardness(50.0F); - this.setResistance(2000.0F); - this.setStepSound(soundTypePiston); - this.setCreativeTab(AddToCreativeTab.tabMachines); - GameRegistry.registerBlock(this, ItemBlockMeta.class, "blockCompressedObsidian"); - } + private final IIcon textureArray[] = new IIcon[11]; - @Override - public MapColor getMapColor(final int meta) { - if (meta < 5) { - return MapColor.obsidianColor; - } - if (meta > 5) { - return MapColor.goldColor; - } - else { - return MapColor.sandColor; - } - } + public BlockCompressedObsidian() { + this.setBlockName("blockCompressedObsidian"); + this.setHardness(50.0F); + this.setResistance(2000.0F); + this.setStepSound(soundTypePiston); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockMeta.class, "blockCompressedObsidian"); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister iicon) { - this.textureArray[0] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian1"); - this.textureArray[1] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian2"); - this.textureArray[2] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian3"); - this.textureArray[3] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian4"); - this.textureArray[4] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian5"); - this.textureArray[5] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian_invert"); - this.textureArray[6] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "glowstone1"); - this.textureArray[7] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "glowstone2"); - this.textureArray[8] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "glowstone3"); - this.textureArray[9] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "glowstone4"); - this.textureArray[10] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "glowstone5"); - } + @Override + public MapColor getMapColor(final int meta) { + if (meta < 5) { + return MapColor.obsidianColor; + } + if (meta > 5) { + return MapColor.goldColor; + } else { + return MapColor.sandColor; + } + } - /** - * Gets the block's texture. Args: side, meta - */ - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(final int side, final int meta) { - return this.textureArray[meta]; - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iicon) { + this.textureArray[0] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian1"); + this.textureArray[1] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian2"); + this.textureArray[2] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian3"); + this.textureArray[3] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian4"); + this.textureArray[4] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian5"); + this.textureArray[5] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian_invert"); + this.textureArray[6] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "glowstone1"); + this.textureArray[7] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "glowstone2"); + this.textureArray[8] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "glowstone3"); + this.textureArray[9] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "glowstone4"); + this.textureArray[10] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "glowstone5"); + } - @Override - public int damageDropped(final int damage) { - return damage; - } + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int side, final int meta) { + return this.textureArray[meta]; + } - @Override - public void getSubBlocks(final Item item, final CreativeTabs tab, final List list) { - for (int i = 0; i < 11; i++) { - list.add(new ItemStack(item, 1, i)); - } - } + @Override + public int damageDropped(final int damage) { + return damage; + } - @Override - public Item getItemDropped(final int meta, final Random rand, final int fortune) { - return Item.getItemFromBlock(this); - } + @Override + public void getSubBlocks(final Item item, final CreativeTabs tab, final List list) { + for (int i = 0; i < 11; i++) { + list.add(new ItemStack(item, 1, i)); + } + } - @Override - public ArrayList getDrops(final World world, final int x, final int y, final int z, final int metadata, - final int fortune) { - int m = metadata; - if (m == 5) { - m = 1; - } - return super.getDrops(world, x, y, z, m, fortune); - } + @Override + public Item getItemDropped(final int meta, final Random rand, final int fortune) { + return Item.getItemFromBlock(this); + } + @Override + public ArrayList getDrops( + final World world, final int x, final int y, final int z, final int metadata, final int fortune) { + int m = metadata; + if (m == 5) { + m = 1; + } + return super.getDrops(world, x, y, z, m, fortune); + } } diff --git a/src/main/java/gtPlusPlus/core/block/general/BlockNet.java b/src/main/java/gtPlusPlus/core/block/general/BlockNet.java index 1f0f145392..53adacac84 100644 --- a/src/main/java/gtPlusPlus/core/block/general/BlockNet.java +++ b/src/main/java/gtPlusPlus/core/block/general/BlockNet.java @@ -1,37 +1,34 @@ package gtPlusPlus.core.block.general; -import java.util.Random; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.block.BlockWeb; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.item.Item; - import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.CORE; +import java.util.Random; +import net.minecraft.block.BlockWeb; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.Item; -public class BlockNet extends BlockWeb{ - - public BlockNet(){ - this.setCreativeTab(AddToCreativeTab.tabBlock); - this.setLightOpacity(1); - this.setHardness(4.0F); - this.setBlockName("blockNet"); - GameRegistry.registerBlock(this, "blockNet"); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister iIcon){ - this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + "net"); - } - - @Override - public Item getItemDropped(final int p_149650_1_, final Random p_149650_2_, final int p_149650_3_){ - return ModItems.itemRope; - } - -} \ No newline at end of file +public class BlockNet extends BlockWeb { + + public BlockNet() { + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setLightOpacity(1); + this.setHardness(4.0F); + this.setBlockName("blockNet"); + GameRegistry.registerBlock(this, "blockNet"); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iIcon) { + this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + "net"); + } + + @Override + public Item getItemDropped(final int p_149650_1_, final Random p_149650_2_, final int p_149650_3_) { + return ModItems.itemRope; + } +} diff --git a/src/main/java/gtPlusPlus/core/block/general/BlockSuperLight.java b/src/main/java/gtPlusPlus/core/block/general/BlockSuperLight.java index a1ba3be487..5357bd2622 100644 --- a/src/main/java/gtPlusPlus/core/block/general/BlockSuperLight.java +++ b/src/main/java/gtPlusPlus/core/block/general/BlockSuperLight.java @@ -23,198 +23,196 @@ import net.minecraft.world.World; public class BlockSuperLight extends BlockContainer { - @SideOnly(Side.CLIENT) - private IIcon textureFront; - - //propecia (Inhibit DHD - recover hair get depression) - - public BlockSuperLight() { - super(Material.circuits); - this.setBlockName("blockSuperLight"); - this.setCreativeTab(CreativeTabs.tabRedstone); - GameRegistry.registerBlock(this, "blockSuperLight"); - LanguageRegistry.addName(this, "Shining Star"); - } - - /** - * Gets the block's texture. Args: side, meta - */ - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) { - return this.blockIcon; - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister p_149651_1_) { - this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlBigBlue"); - } - - /** - * Returns a new instance of a block's tile entity class. Called on placing the - * block. - */ - public TileEntity createNewTileEntity(World aWorld, int p_149915_2_) { - return new TileEntitySuperLight(); - } - - public static class TileEntitySuperLight extends TileEntity { - - private long mCreated; - - private long mLastUpdateTick = 0; - - private int mLitBlockCount = 0; - - private int[][][][] aLitBlocks = new int[50][10][50][1]; - - private boolean mPowered = false; - - public TileEntitySuperLight() { - mCreated = System.currentTimeMillis(); - Logger.INFO("Created Super-Lamp"); - } - - public void readFromNBT(NBTTagCompound aNBT) { - super.readFromNBT(aNBT); - mCreated = aNBT.getLong("mCreated"); - mPowered = aNBT.getBoolean("mPowered"); - NBTTagCompound aLightingData = aNBT.getCompoundTag("lighting"); - for (int x = 0; x < 50; x++) { - for (int y = 0; y < 10; y++) { - for (int z = 0; z < 50; z++) { - int aData = aLightingData.getInteger("["+x+"]["+y+"]["+z+"]"); - aLitBlocks[x][y][z][0] = aData; - } - } - } - } - - public void writeToNBT(NBTTagCompound aNBT) { - super.writeToNBT(aNBT); - aNBT.setLong("mCreated", mCreated); - aNBT.setBoolean("mPowered", mPowered); - NBTTagCompound aLightingData = new NBTTagCompound(); - for (int x = 0; x < 50; x++) { - for (int y = 0; y < 10; y++) { - for (int z = 0; z < 50; z++) { - int aFlag = aLitBlocks[x][y][z][0]; - aLightingData.setInteger("["+x+"]["+y+"]["+z+"]", aFlag); - } - } - } - aNBT.setTag("lighting", aLightingData); - } - - @Override - public void updateEntity() { - super.updateEntity(); - - if (this.worldObj.isRemote) { - return; - } - - try { - if (mLastUpdateTick == 0 || (System.currentTimeMillis() - mLastUpdateTick) >= 30000) { - boolean powered = (this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord)); - boolean aLastState = mPowered; - //Logger.INFO("Powered: "+powered); - mPowered = powered; - if (mPowered != aLastState) { - updateLighting(powered); - } - } - } catch (Throwable t) { - } - } - - @Override - public void markDirty() { - super.markDirty(); - } - - @Override - public boolean canUpdate() { - return super.canUpdate(); - } - - public void updateLighting(boolean enable) { - - - mLastUpdateTick = System.currentTimeMillis(); - - if (false) { - return; - } - - aLitBlocks = new int[50][10][50][1]; - int aLitCounter = 0; - AutoMap aBlocksToUpdate = new AutoMap(); - Logger.INFO("Trying to relight area."); - - BlockPos aStartIterationPoint = new BlockPos(this.xCoord-24, this.yCoord-4, this.zCoord-24, this.worldObj); - for (int x = 0; x < 50; x++) { - for (int y = 0; y < 10; y++) { - for (int z = 0; z < 50; z++) { - int xOff = aStartIterationPoint.xPos + x; - int yOff = aStartIterationPoint.yPos + y; - int zOff = aStartIterationPoint.zPos + z; - Block aBlockGet = this.worldObj.getBlock(xOff, yOff, zOff); - if (aBlockGet != null) { - if (aBlockGet instanceof BlockAir || aBlockGet instanceof LightGlass) { - - int aLight = aBlockGet.getLightValue(); - - //Don't Need to relight anything. - if ((enable && aLight > 0) || (!enable && aLight == 0)) { - continue; - } - //Turning Lights on - else if (enable && aLight == 0) { - aBlocksToUpdate.put(new BlockPos(xOff, yOff, zOff, this.worldObj)); - if (aBlockGet instanceof BlockAir) { - Logger.INFO("Lit air."); - this.worldObj.setBlock(xOff, yOff, zOff, ModBlocks.MatterFabricatorEffectBlock, 0, 3); - } - //aBlockGet.setLightLevel(15); - aLitCounter++; - } - //Turning Lights off - else if (!enable && aLight > 0) { - aBlocksToUpdate.put(new BlockPos(xOff, yOff, zOff, this.worldObj)); - if (aBlockGet instanceof LightGlass) { - Logger.INFO("Dimmed air."); - this.worldObj.setBlock(xOff, yOff, zOff, Blocks.air, 0, 3); - } - //aBlockGet.setLightLevel(0); - } - aLitBlocks[x][y][z][0] = enable ? 15 : 0; - } - else { - aLitBlocks[x][y][z][0] = -1; - } - } - else { - aLitBlocks[x][y][z][0] = -1; - } - } - } - } - mLitBlockCount = aLitCounter; - doLargeBlockUpdate(aBlocksToUpdate); - } - - public void doLargeBlockUpdate(AutoMap aUpdateMap) { - if (aUpdateMap.isEmpty()) { - return; - } - for (BlockPos p : aUpdateMap) { - //this.worldObj.markBlockForUpdate(p.xPos, p.yPos, p.zPos); - //this.worldObj.markBlocksDirtyVertical(p_72975_1_, p_72975_2_, p_72975_3_, p_72975_4_); - } - } - - } + @SideOnly(Side.CLIENT) + private IIcon textureFront; + // propecia (Inhibit DHD - recover hair get depression) + + public BlockSuperLight() { + super(Material.circuits); + this.setBlockName("blockSuperLight"); + this.setCreativeTab(CreativeTabs.tabRedstone); + GameRegistry.registerBlock(this, "blockSuperLight"); + LanguageRegistry.addName(this, "Shining Star"); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) { + return this.blockIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlBigBlue"); + } + + /** + * Returns a new instance of a block's tile entity class. Called on placing the + * block. + */ + public TileEntity createNewTileEntity(World aWorld, int p_149915_2_) { + return new TileEntitySuperLight(); + } + + public static class TileEntitySuperLight extends TileEntity { + + private long mCreated; + + private long mLastUpdateTick = 0; + + private int mLitBlockCount = 0; + + private int[][][][] aLitBlocks = new int[50][10][50][1]; + + private boolean mPowered = false; + + public TileEntitySuperLight() { + mCreated = System.currentTimeMillis(); + Logger.INFO("Created Super-Lamp"); + } + + public void readFromNBT(NBTTagCompound aNBT) { + super.readFromNBT(aNBT); + mCreated = aNBT.getLong("mCreated"); + mPowered = aNBT.getBoolean("mPowered"); + NBTTagCompound aLightingData = aNBT.getCompoundTag("lighting"); + for (int x = 0; x < 50; x++) { + for (int y = 0; y < 10; y++) { + for (int z = 0; z < 50; z++) { + int aData = aLightingData.getInteger("[" + x + "][" + y + "][" + z + "]"); + aLitBlocks[x][y][z][0] = aData; + } + } + } + } + + public void writeToNBT(NBTTagCompound aNBT) { + super.writeToNBT(aNBT); + aNBT.setLong("mCreated", mCreated); + aNBT.setBoolean("mPowered", mPowered); + NBTTagCompound aLightingData = new NBTTagCompound(); + for (int x = 0; x < 50; x++) { + for (int y = 0; y < 10; y++) { + for (int z = 0; z < 50; z++) { + int aFlag = aLitBlocks[x][y][z][0]; + aLightingData.setInteger("[" + x + "][" + y + "][" + z + "]", aFlag); + } + } + } + aNBT.setTag("lighting", aLightingData); + } + + @Override + public void updateEntity() { + super.updateEntity(); + + if (this.worldObj.isRemote) { + return; + } + + try { + if (mLastUpdateTick == 0 || (System.currentTimeMillis() - mLastUpdateTick) >= 30000) { + boolean powered = + (this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord)); + boolean aLastState = mPowered; + // Logger.INFO("Powered: "+powered); + mPowered = powered; + if (mPowered != aLastState) { + updateLighting(powered); + } + } + } catch (Throwable t) { + } + } + + @Override + public void markDirty() { + super.markDirty(); + } + + @Override + public boolean canUpdate() { + return super.canUpdate(); + } + + public void updateLighting(boolean enable) { + + mLastUpdateTick = System.currentTimeMillis(); + + if (false) { + return; + } + + aLitBlocks = new int[50][10][50][1]; + int aLitCounter = 0; + AutoMap aBlocksToUpdate = new AutoMap(); + Logger.INFO("Trying to relight area."); + + BlockPos aStartIterationPoint = + new BlockPos(this.xCoord - 24, this.yCoord - 4, this.zCoord - 24, this.worldObj); + for (int x = 0; x < 50; x++) { + for (int y = 0; y < 10; y++) { + for (int z = 0; z < 50; z++) { + int xOff = aStartIterationPoint.xPos + x; + int yOff = aStartIterationPoint.yPos + y; + int zOff = aStartIterationPoint.zPos + z; + Block aBlockGet = this.worldObj.getBlock(xOff, yOff, zOff); + if (aBlockGet != null) { + if (aBlockGet instanceof BlockAir || aBlockGet instanceof LightGlass) { + + int aLight = aBlockGet.getLightValue(); + + // Don't Need to relight anything. + if ((enable && aLight > 0) || (!enable && aLight == 0)) { + continue; + } + // Turning Lights on + else if (enable && aLight == 0) { + aBlocksToUpdate.put(new BlockPos(xOff, yOff, zOff, this.worldObj)); + if (aBlockGet instanceof BlockAir) { + Logger.INFO("Lit air."); + this.worldObj.setBlock( + xOff, yOff, zOff, ModBlocks.MatterFabricatorEffectBlock, 0, 3); + } + // aBlockGet.setLightLevel(15); + aLitCounter++; + } + // Turning Lights off + else if (!enable && aLight > 0) { + aBlocksToUpdate.put(new BlockPos(xOff, yOff, zOff, this.worldObj)); + if (aBlockGet instanceof LightGlass) { + Logger.INFO("Dimmed air."); + this.worldObj.setBlock(xOff, yOff, zOff, Blocks.air, 0, 3); + } + // aBlockGet.setLightLevel(0); + } + aLitBlocks[x][y][z][0] = enable ? 15 : 0; + } else { + aLitBlocks[x][y][z][0] = -1; + } + } else { + aLitBlocks[x][y][z][0] = -1; + } + } + } + } + mLitBlockCount = aLitCounter; + doLargeBlockUpdate(aBlocksToUpdate); + } + + public void doLargeBlockUpdate(AutoMap aUpdateMap) { + if (aUpdateMap.isEmpty()) { + return; + } + for (BlockPos p : aUpdateMap) { + // this.worldObj.markBlockForUpdate(p.xPos, p.yPos, p.zPos); + // this.worldObj.markBlocksDirtyVertical(p_72975_1_, p_72975_2_, p_72975_3_, p_72975_4_); + } + } + } } diff --git a/src/main/java/gtPlusPlus/core/block/general/BlockTankXpConverter.java b/src/main/java/gtPlusPlus/core/block/general/BlockTankXpConverter.java index f7f0b446ce..05d83cf133 100644 --- a/src/main/java/gtPlusPlus/core/block/general/BlockTankXpConverter.java +++ b/src/main/java/gtPlusPlus/core/block/general/BlockTankXpConverter.java @@ -1,7 +1,5 @@ package gtPlusPlus.core.block.general; -import java.util.Random; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; @@ -9,6 +7,7 @@ import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.item.base.itemblock.ItemBlockEntityBase; import gtPlusPlus.core.lib.CORE; +import java.util.Random; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -21,172 +20,183 @@ import net.minecraft.world.World; public class BlockTankXpConverter extends BlockContainer { - @SideOnly(Side.CLIENT) - private IIcon textureTop; - @SideOnly(Side.CLIENT) - private IIcon textureBottom; - @SideOnly(Side.CLIENT) - private IIcon textureFront; - - @SuppressWarnings("deprecation") - public BlockTankXpConverter() { - super(Material.iron); - this.setBlockName("blockTankXpConverter"); - this.setCreativeTab(AddToCreativeTab.tabMachines); - GameRegistry.registerBlock(this, ItemBlockEntityBase.class, "blockTankXpConverter"); - LanguageRegistry.addName(this, "Xp Converter"); - this.generateRainbowMap(); - if (!this.getTickRandomly()) { - this.setTickRandomly(true); - } - } - - /** - * Gets the block's texture. Args: side, meta - */ - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) { - return p_149691_1_ == 1 ? this.textureTop - : (p_149691_1_ == 0 ? this.textureBottom - : ((p_149691_1_ != 2) && (p_149691_1_ != 4) ? this.blockIcon : this.textureFront)); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister p_149651_1_) { - this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlGray"); - this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlGray"); - this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlGray"); - this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlGray"); - } - - /** - * Called upon block activation (right click on the block.) - */ - @Override - public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, - final int side, final float lx, final float ly, final float lz) { - - return true; - - /* - if (world.isRemote) { - return true; - } - else { - boolean mDidScrewDriver = false; - // Check For Screwdriver - try { - final ItemStack mHandStack = PlayerUtils.getItemStackInPlayersHand(world, player.getDisplayName()); - final Item mHandItem = mHandStack.getItem(); - if (((mHandItem instanceof GT_MetaGenerated_Tool_01) - && ((mHandItem.getDamage(mHandStack) == 22) || (mHandItem.getDamage(mHandStack) == 150)))) { - final TileEntityXpConverter tile = (TileEntityXpConverter) world.getTileEntity(x, y, z); - if (tile != null) { - mDidScrewDriver = true; - tile.onScrewdriverRightClick((byte) side, player, x, y, z); - } - - } - } - catch (final Throwable t) { - mDidScrewDriver = false; - } - - if (!mDidScrewDriver) { - - try { - final TileEntityXpConverter tile = (TileEntityXpConverter) world.getTileEntity(x, y, z); - if (tile != null) { - tile.onRightClick((byte) side, player, x, y, z); - } - } - catch (final Throwable t) { - } - - final TileEntityXpConverter tank = (TileEntityXpConverter) world.getTileEntity(x, y, z); - if (tank != null) { - if (tank.tankEssence.getFluid() != null) { - PlayerUtils.messagePlayer(player, "This tank contains " + tank.tankEssence.getFluidAmount() - + "L of " + tank.tankEssence.getFluid().getLocalizedName()); - } - if (tank.tankLiquidXp.getFluid() != null) { - PlayerUtils.messagePlayer(player, "This tank contains " + tank.tankLiquidXp.getFluidAmount() - + "L of " + tank.tankLiquidXp.getFluid().getLocalizedName()); - } - if ((tank.tankEssence.getFluid() != null) && (tank.tankLiquidXp.getFluid() != null)) { - PlayerUtils.messagePlayer(player, "This is worth " - + EnchantingUtils.getLevelForLiquid(tank.tankLiquidXp.getFluidAmount()) + " levels."); - } - } - } - } - return true; - */} - - @Override - public int getRenderBlockPass() { - return 1; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { - //return new TileEntityXpConverter(); - return null; - } - - @Override - public void onBlockAdded(final World world, final int x, final int y, final int z) { - super.onBlockAdded(world, x, y, z); - } - - @Override - public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, - final int z) { - return false; - } - - private final boolean generateRainbowMap() { - return true; - } - - @Override - public int getBlockColor() { - return super.getBlockColor(); - } - - @Override - public int colorMultiplier(final IBlockAccess p_149720_1_, final int p_149720_2_, final int p_149720_3_, - final int p_149720_4_) { - return super.colorMultiplier(p_149720_1_, p_149720_2_, p_149720_3_, p_149720_4_); - } - - @Override - public void updateTick(final World world, final int x, final int y, final int z, final Random rand) { - // this.mRainbowTick++; - super.updateTick(world, x, y, z, rand); - } - - @Override - public void randomDisplayTick(final World world, final int x, final int y, final int z, final Random rand) { - //this.mRainbowTick++; - super.randomDisplayTick(world, x, y, z, rand); - } - - @Override - public int tickRate(final World p_149738_1_) { - return 20; - } - - @Override - public int getLightValue() { - return 6; - } - + @SideOnly(Side.CLIENT) + private IIcon textureTop; + + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + @SuppressWarnings("deprecation") + public BlockTankXpConverter() { + super(Material.iron); + this.setBlockName("blockTankXpConverter"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockEntityBase.class, "blockTankXpConverter"); + LanguageRegistry.addName(this, "Xp Converter"); + this.generateRainbowMap(); + if (!this.getTickRandomly()) { + this.setTickRandomly(true); + } + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) { + return p_149691_1_ == 1 + ? this.textureTop + : (p_149691_1_ == 0 + ? this.textureBottom + : ((p_149691_1_ != 2) && (p_149691_1_ != 4) ? this.blockIcon : this.textureFront)); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlGray"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlGray"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlGray"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlGray"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated( + final World world, + final int x, + final int y, + final int z, + final EntityPlayer player, + final int side, + final float lx, + final float ly, + final float lz) { + + return true; + + /* + if (world.isRemote) { + return true; + } + else { + boolean mDidScrewDriver = false; + // Check For Screwdriver + try { + final ItemStack mHandStack = PlayerUtils.getItemStackInPlayersHand(world, player.getDisplayName()); + final Item mHandItem = mHandStack.getItem(); + if (((mHandItem instanceof GT_MetaGenerated_Tool_01) + && ((mHandItem.getDamage(mHandStack) == 22) || (mHandItem.getDamage(mHandStack) == 150)))) { + final TileEntityXpConverter tile = (TileEntityXpConverter) world.getTileEntity(x, y, z); + if (tile != null) { + mDidScrewDriver = true; + tile.onScrewdriverRightClick((byte) side, player, x, y, z); + } + + } + } + catch (final Throwable t) { + mDidScrewDriver = false; + } + + if (!mDidScrewDriver) { + + try { + final TileEntityXpConverter tile = (TileEntityXpConverter) world.getTileEntity(x, y, z); + if (tile != null) { + tile.onRightClick((byte) side, player, x, y, z); + } + } + catch (final Throwable t) { + } + + final TileEntityXpConverter tank = (TileEntityXpConverter) world.getTileEntity(x, y, z); + if (tank != null) { + if (tank.tankEssence.getFluid() != null) { + PlayerUtils.messagePlayer(player, "This tank contains " + tank.tankEssence.getFluidAmount() + + "L of " + tank.tankEssence.getFluid().getLocalizedName()); + } + if (tank.tankLiquidXp.getFluid() != null) { + PlayerUtils.messagePlayer(player, "This tank contains " + tank.tankLiquidXp.getFluidAmount() + + "L of " + tank.tankLiquidXp.getFluid().getLocalizedName()); + } + if ((tank.tankEssence.getFluid() != null) && (tank.tankLiquidXp.getFluid() != null)) { + PlayerUtils.messagePlayer(player, "This is worth " + + EnchantingUtils.getLevelForLiquid(tank.tankLiquidXp.getFluidAmount()) + " levels."); + } + } + } + } + return true; + */ } + + @Override + public int getRenderBlockPass() { + return 1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + // return new TileEntityXpConverter(); + return null; + } + + @Override + public void onBlockAdded(final World world, final int x, final int y, final int z) { + super.onBlockAdded(world, x, y, z); + } + + @Override + public boolean canCreatureSpawn( + final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + private final boolean generateRainbowMap() { + return true; + } + + @Override + public int getBlockColor() { + return super.getBlockColor(); + } + + @Override + public int colorMultiplier( + final IBlockAccess p_149720_1_, final int p_149720_2_, final int p_149720_3_, final int p_149720_4_) { + return super.colorMultiplier(p_149720_1_, p_149720_2_, p_149720_3_, p_149720_4_); + } + + @Override + public void updateTick(final World world, final int x, final int y, final int z, final Random rand) { + // this.mRainbowTick++; + super.updateTick(world, x, y, z, rand); + } + + @Override + public void randomDisplayTick(final World world, final int x, final int y, final int z, final Random rand) { + // this.mRainbowTick++; + super.randomDisplayTick(world, x, y, z, rand); + } + + @Override + public int tickRate(final World p_149738_1_) { + return 20; + } + + @Override + public int getLightValue() { + return 6; + } } diff --git a/src/main/java/gtPlusPlus/core/block/general/FirePit.java b/src/main/java/gtPlusPlus/core/block/general/FirePit.java index 6f35715c48..92a22c5d7f 100644 --- a/src/main/java/gtPlusPlus/core/block/general/FirePit.java +++ b/src/main/java/gtPlusPlus/core/block/general/FirePit.java @@ -2,14 +2,15 @@ package gtPlusPlus.core.block.general; import static net.minecraftforge.common.util.ForgeDirection.*; -import java.util.List; -import java.util.Random; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.core.block.base.BasicBlock; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.tileentities.general.TileEntityFirepit; +import java.util.List; +import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -20,211 +21,221 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; - -import gtPlusPlus.core.block.base.BasicBlock; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.tileentities.general.TileEntityFirepit; import net.minecraftforge.common.util.ForgeDirection; -public class FirePit extends BasicBlock{ - private static IIcon[] TEXTURE; - public static final int META_ANTIBUILDER = 2; - private int meta; - - @SuppressWarnings("deprecation") - public FirePit() { - super("blockFirePit", Material.wood); - this.setBlockName("blockFirePit"); - this.setCreativeTab(AddToCreativeTab.tabMachines); - this.setHardness(10.0F); - this.setResistance(35.0F); - this.setStepSound(Block.soundTypeWood); - GameRegistry.registerBlock(this, "blockFirePit"); - LanguageRegistry.addName(this, "Fire Pit"); - } - - @Override - public int tickRate(final World aParWorld) { - return 30; - } - - @Override - public TileEntity createNewTileEntity(final World world, final int i) { - return new TileEntityFirepit(); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister par1IconRegister){ - TEXTURE = new IIcon[] {par1IconRegister.registerIcon(this.getTextureName() + "_layer_0"), par1IconRegister.registerIcon(this.getTextureName() + "_layer_1")}; - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - public void getSubBlocks(final Item par1, final CreativeTabs par2CreativeTabs, final List par3List){ - par3List.add(new ItemStack(par1, 1, 2)); - } - - @Override - public void updateTick(final World par1World, final int x, final int y, final int z, final Random par5Random){ - if (!par1World.isRemote){ - //Sets meta. - this.meta = par1World.getBlockMetadata(x, y, z); - //If Raining, Put out. - if (par1World.isRaining() - && (par1World.canLightningStrikeAt(x, y, z) - || par1World.canLightningStrikeAt(x - 1, y, z) - || par1World.canLightningStrikeAt(x + 1, y, z) - || par1World.canLightningStrikeAt(x, y, z - 1) - || par1World.canLightningStrikeAt(x, y, z + 1))){ - //Fire goes out - par1World.setBlockMetadataWithNotify(x, y, z, 1, 4); - } - if (isNeighborBurning(par1World, x, y, z)){ - //Fire can ignite from a nearby flame source. - par1World.setBlockMetadataWithNotify(x, y, z, 2, 4); - } - } - } - - @Override - public Item getItemDropped(final int meta, final Random par2Random, final int par3){ - switch (meta){ - case 0: - return null; - default: - break; - } - return Item.getItemFromBlock(this); - } - - @Override - public int damageDropped(final int meta){ - return meta; - } - - @Override - public boolean isOpaqueCube(){ - return false; - } - - @Override - public int getRenderType(){ - return -1; - } - - @Override - @SideOnly(Side.CLIENT) - public int getRenderBlockPass(){ - return 1; - } - - @Override - public boolean renderAsNormalBlock(){ - return false; - } - - /*@Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World aParWorld, int x, int y, int z){ - return null; - }*/ - - @Override - protected boolean canSilkHarvest(){ - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public void randomDisplayTick(final World p_149734_1_, final int p_149734_2_, final int p_149734_3_, final int p_149734_4_, final Random p_149734_5_){ - int l; - float f; - float f1; - float f2; - if (this.meta == 2) { - if (p_149734_5_.nextInt(24) == 0){ - p_149734_1_.playSound(p_149734_2_ + 0.5F, p_149734_3_ + 0.5F, p_149734_4_ + 0.5F, "fire.fire", 1.0F + p_149734_5_.nextFloat(), (p_149734_5_.nextFloat() * 0.7F) + 0.3F, false); - } - } - if (this.meta == 2) { - if (!World.doesBlockHaveSolidTopSurface(p_149734_1_, p_149734_2_, p_149734_3_ - 1, p_149734_4_) && !Blocks.fire.canCatchFire(p_149734_1_, p_149734_2_, p_149734_3_ - 1, p_149734_4_, UP)){ - if (Blocks.fire.canCatchFire(p_149734_1_, p_149734_2_ - 1, p_149734_3_, p_149734_4_, EAST)){ - for (l = 0; l < 2; ++l){ - f = p_149734_2_ + (p_149734_5_.nextFloat() * 0.1F); - f1 = p_149734_3_ + p_149734_5_.nextFloat(); - f2 = p_149734_4_ + p_149734_5_.nextFloat(); - p_149734_1_.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); - } - } - if (Blocks.fire.canCatchFire(p_149734_1_, p_149734_2_ + 1, p_149734_3_, p_149734_4_, WEST)){ - for (l = 0; l < 2; ++l){ - f = p_149734_2_ + 1 - (p_149734_5_.nextFloat() * 0.1F); - f1 = p_149734_3_ + p_149734_5_.nextFloat(); - f2 = p_149734_4_ + p_149734_5_.nextFloat(); - p_149734_1_.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); - } - } - if (Blocks.fire.canCatchFire(p_149734_1_, p_149734_2_, p_149734_3_, p_149734_4_ - 1, SOUTH)){ - for (l = 0; l < 2; ++l){ - f = p_149734_2_ + p_149734_5_.nextFloat(); - f1 = p_149734_3_ + p_149734_5_.nextFloat(); - f2 = p_149734_4_ + (p_149734_5_.nextFloat() * 0.1F); - p_149734_1_.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); - } - } - if (Blocks.fire.canCatchFire(p_149734_1_, p_149734_2_, p_149734_3_, p_149734_4_ + 1, NORTH)){ - for (l = 0; l < 2; ++l){ - f = p_149734_2_ + p_149734_5_.nextFloat(); - f1 = p_149734_3_ + p_149734_5_.nextFloat(); - f2 = p_149734_4_ + 1 - (p_149734_5_.nextFloat() * 0.1F); - p_149734_1_.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); - } - } - if (Blocks.fire.canCatchFire(p_149734_1_, p_149734_2_, p_149734_3_ + 1, p_149734_4_, DOWN)){ - for (l = 0; l < 2; ++l){ - f = p_149734_2_ + p_149734_5_.nextFloat(); - f1 = p_149734_3_ + 1 - (p_149734_5_.nextFloat() * 0.1F); - f2 = p_149734_4_ + p_149734_5_.nextFloat(); - p_149734_1_.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); - } - } - } - else{ - if (this.meta == 2) { - for (l = 0; l < 3; ++l){ - f = p_149734_2_ + p_149734_5_.nextFloat(); - f1 = p_149734_3_ + (p_149734_5_.nextFloat() * 0.5F) + 0.5F; - f2 = p_149734_4_ + p_149734_5_.nextFloat(); - p_149734_1_.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); - } - } - } - } - } - - @SideOnly(Side.CLIENT) - public static IIcon getFireIcon(final int p_149840_1_){ - return FirePit.TEXTURE[p_149840_1_]; - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(final int p_149691_1_, final int p_149691_2_){ - return FirePit.TEXTURE[0]; - } - - private static boolean isNeighborBurning(final World world, final int x, final int y, final int z){ - return canCatchFire(world, x + 1, y, z, WEST ) || - canCatchFire(world, x - 1, y, z, EAST ) || - canCatchFire(world, x, y - 1, z, UP ) || - canCatchFire(world, x, y + 1, z, DOWN ) || - canCatchFire(world, x, y, z - 1, SOUTH) || - canCatchFire(world, x, y, z + 1, NORTH); - } - - public static boolean canCatchFire(final World world, final int x, final int y, final int z, final ForgeDirection face) - { - return world.getBlock(x, y, z).isFireSource(world, x, y, z, face); - } - +public class FirePit extends BasicBlock { + private static IIcon[] TEXTURE; + public static final int META_ANTIBUILDER = 2; + private int meta; + + @SuppressWarnings("deprecation") + public FirePit() { + super("blockFirePit", Material.wood); + this.setBlockName("blockFirePit"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setHardness(10.0F); + this.setResistance(35.0F); + this.setStepSound(Block.soundTypeWood); + GameRegistry.registerBlock(this, "blockFirePit"); + LanguageRegistry.addName(this, "Fire Pit"); + } + + @Override + public int tickRate(final World aParWorld) { + return 30; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int i) { + return new TileEntityFirepit(); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister par1IconRegister) { + TEXTURE = new IIcon[] { + par1IconRegister.registerIcon(this.getTextureName() + "_layer_0"), + par1IconRegister.registerIcon(this.getTextureName() + "_layer_1") + }; + } + + @SuppressWarnings({"rawtypes", "unchecked"}) + @Override + public void getSubBlocks(final Item par1, final CreativeTabs par2CreativeTabs, final List par3List) { + par3List.add(new ItemStack(par1, 1, 2)); + } + + @Override + public void updateTick(final World par1World, final int x, final int y, final int z, final Random par5Random) { + if (!par1World.isRemote) { + // Sets meta. + this.meta = par1World.getBlockMetadata(x, y, z); + // If Raining, Put out. + if (par1World.isRaining() + && (par1World.canLightningStrikeAt(x, y, z) + || par1World.canLightningStrikeAt(x - 1, y, z) + || par1World.canLightningStrikeAt(x + 1, y, z) + || par1World.canLightningStrikeAt(x, y, z - 1) + || par1World.canLightningStrikeAt(x, y, z + 1))) { + // Fire goes out + par1World.setBlockMetadataWithNotify(x, y, z, 1, 4); + } + if (isNeighborBurning(par1World, x, y, z)) { + // Fire can ignite from a nearby flame source. + par1World.setBlockMetadataWithNotify(x, y, z, 2, 4); + } + } + } + + @Override + public Item getItemDropped(final int meta, final Random par2Random, final int par3) { + switch (meta) { + case 0: + return null; + default: + break; + } + return Item.getItemFromBlock(this); + } + + @Override + public int damageDropped(final int meta) { + return meta; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public int getRenderType() { + return -1; + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() { + return 1; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + /*@Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World aParWorld, int x, int y, int z){ + return null; + }*/ + + @Override + protected boolean canSilkHarvest() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick( + final World p_149734_1_, + final int p_149734_2_, + final int p_149734_3_, + final int p_149734_4_, + final Random p_149734_5_) { + int l; + float f; + float f1; + float f2; + if (this.meta == 2) { + if (p_149734_5_.nextInt(24) == 0) { + p_149734_1_.playSound( + p_149734_2_ + 0.5F, + p_149734_3_ + 0.5F, + p_149734_4_ + 0.5F, + "fire.fire", + 1.0F + p_149734_5_.nextFloat(), + (p_149734_5_.nextFloat() * 0.7F) + 0.3F, + false); + } + } + if (this.meta == 2) { + if (!World.doesBlockHaveSolidTopSurface(p_149734_1_, p_149734_2_, p_149734_3_ - 1, p_149734_4_) + && !Blocks.fire.canCatchFire(p_149734_1_, p_149734_2_, p_149734_3_ - 1, p_149734_4_, UP)) { + if (Blocks.fire.canCatchFire(p_149734_1_, p_149734_2_ - 1, p_149734_3_, p_149734_4_, EAST)) { + for (l = 0; l < 2; ++l) { + f = p_149734_2_ + (p_149734_5_.nextFloat() * 0.1F); + f1 = p_149734_3_ + p_149734_5_.nextFloat(); + f2 = p_149734_4_ + p_149734_5_.nextFloat(); + p_149734_1_.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + } + } + if (Blocks.fire.canCatchFire(p_149734_1_, p_149734_2_ + 1, p_149734_3_, p_149734_4_, WEST)) { + for (l = 0; l < 2; ++l) { + f = p_149734_2_ + 1 - (p_149734_5_.nextFloat() * 0.1F); + f1 = p_149734_3_ + p_149734_5_.nextFloat(); + f2 = p_149734_4_ + p_149734_5_.nextFloat(); + p_149734_1_.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + } + } + if (Blocks.fire.canCatchFire(p_149734_1_, p_149734_2_, p_149734_3_, p_149734_4_ - 1, SOUTH)) { + for (l = 0; l < 2; ++l) { + f = p_149734_2_ + p_149734_5_.nextFloat(); + f1 = p_149734_3_ + p_149734_5_.nextFloat(); + f2 = p_149734_4_ + (p_149734_5_.nextFloat() * 0.1F); + p_149734_1_.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + } + } + if (Blocks.fire.canCatchFire(p_149734_1_, p_149734_2_, p_149734_3_, p_149734_4_ + 1, NORTH)) { + for (l = 0; l < 2; ++l) { + f = p_149734_2_ + p_149734_5_.nextFloat(); + f1 = p_149734_3_ + p_149734_5_.nextFloat(); + f2 = p_149734_4_ + 1 - (p_149734_5_.nextFloat() * 0.1F); + p_149734_1_.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + } + } + if (Blocks.fire.canCatchFire(p_149734_1_, p_149734_2_, p_149734_3_ + 1, p_149734_4_, DOWN)) { + for (l = 0; l < 2; ++l) { + f = p_149734_2_ + p_149734_5_.nextFloat(); + f1 = p_149734_3_ + 1 - (p_149734_5_.nextFloat() * 0.1F); + f2 = p_149734_4_ + p_149734_5_.nextFloat(); + p_149734_1_.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + } + } + } else { + if (this.meta == 2) { + for (l = 0; l < 3; ++l) { + f = p_149734_2_ + p_149734_5_.nextFloat(); + f1 = p_149734_3_ + (p_149734_5_.nextFloat() * 0.5F) + 0.5F; + f2 = p_149734_4_ + p_149734_5_.nextFloat(); + p_149734_1_.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + } + } + } + } + } + + @SideOnly(Side.CLIENT) + public static IIcon getFireIcon(final int p_149840_1_) { + return FirePit.TEXTURE[p_149840_1_]; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) { + return FirePit.TEXTURE[0]; + } + + private static boolean isNeighborBurning(final World world, final int x, final int y, final int z) { + return canCatchFire(world, x + 1, y, z, WEST) + || canCatchFire(world, x - 1, y, z, EAST) + || canCatchFire(world, x, y - 1, z, UP) + || canCatchFire(world, x, y + 1, z, DOWN) + || canCatchFire(world, x, y, z - 1, SOUTH) + || canCatchFire(world, x, y, z + 1, NORTH); + } + + public static boolean canCatchFire( + final World world, final int x, final int y, final int z, final ForgeDirection face) { + return world.getBlock(x, y, z).isFireSource(world, x, y, z, face); + } } diff --git a/src/main/java/gtPlusPlus/core/block/general/FluidTankInfinite.java b/src/main/java/gtPlusPlus/core/block/general/FluidTankInfinite.java index b979f7864b..3f4a057221 100644 --- a/src/main/java/gtPlusPlus/core/block/general/FluidTankInfinite.java +++ b/src/main/java/gtPlusPlus/core/block/general/FluidTankInfinite.java @@ -24,113 +24,125 @@ import net.minecraftforge.fluids.ItemFluidContainer; public class FluidTankInfinite extends BlockContainer { - @SideOnly(Side.CLIENT) - private IIcon textureTop; - @SideOnly(Side.CLIENT) - private IIcon textureBottom; - @SideOnly(Side.CLIENT) - private IIcon textureFront; + @SideOnly(Side.CLIENT) + private IIcon textureTop; - @SuppressWarnings("deprecation") - public FluidTankInfinite() { - super(Material.iron); - this.setBlockName("blockInfiniteFluidTank"); - this.setCreativeTab(AddToCreativeTab.tabMachines); - GameRegistry.registerBlock(this, "blockInfiniteFluidTank"); - LanguageRegistry.addName(this, "Infinite Fluid Tank"); + @SideOnly(Side.CLIENT) + private IIcon textureBottom; - } + @SideOnly(Side.CLIENT) + private IIcon textureFront; - /** - * Gets the block's texture. Args: side, meta - */ - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) { - return p_149691_1_ == 1 ? this.textureTop - : (p_149691_1_ == 0 ? this.textureBottom - : ((p_149691_1_ != 2) && (p_149691_1_ != 4) ? this.blockIcon : this.textureFront)); - } + @SuppressWarnings("deprecation") + public FluidTankInfinite() { + super(Material.iron); + this.setBlockName("blockInfiniteFluidTank"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, "blockInfiniteFluidTank"); + LanguageRegistry.addName(this, "Infinite Fluid Tank"); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister p_149651_1_) { - this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "Generic_Creative_Texture"); - this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "Generic_Creative_Texture"); - this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "Generic_Creative_Texture"); - this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "Generic_Creative_Texture"); - } + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) { + return p_149691_1_ == 1 + ? this.textureTop + : (p_149691_1_ == 0 + ? this.textureBottom + : ((p_149691_1_ != 2) && (p_149691_1_ != 4) ? this.blockIcon : this.textureFront)); + } - /** - * Called upon block activation (right click on the block.) - */ - @Override - public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, - final int side, final float lx, final float ly, final float lz) { - if (world.isRemote) { - return true; - } else { - TileEntityInfiniteFluid tank = (TileEntityInfiniteFluid) world.getTileEntity(x, y, z); - if (tank != null) { - Item handItem; - try { - handItem = player.getHeldItem().getItem(); - } catch (Throwable t) { - handItem = null; - } - if (handItem != null - && (handItem instanceof IFluidContainerItem || handItem instanceof ItemFluidContainer - || FluidContainerRegistry.isFilledContainer(player.getHeldItem()))) { - if (tank.tank.getFluid() == null) { - try { - if (!FluidContainerRegistry.isFilledContainer(player.getHeldItem())) { - ItemStack handItemStack = player.getHeldItem(); - IFluidContainerItem container = (IFluidContainerItem) handItem; - FluidStack containerFluid = container.getFluid(handItemStack); - container.drain(handItemStack, container.getFluid(handItemStack).amount, true); - tank.tank.setFluid(containerFluid); - } else { - ItemStack handItemStack = player.getHeldItem(); - FluidContainerRegistry.drainFluidContainer(handItemStack); - FluidStack containerFluid = FluidContainerRegistry.getFluidForFilledItem(handItemStack); - ItemStack emptyContainer = FluidContainerRegistry.drainFluidContainer(handItemStack); - player.setItemInUse(emptyContainer, 0); + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "Generic_Creative_Texture"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "Generic_Creative_Texture"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "Generic_Creative_Texture"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "Generic_Creative_Texture"); + } - tank.tank.setFluid(containerFluid); - } - } catch (Throwable t) { - t.printStackTrace(); - } - } + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated( + final World world, + final int x, + final int y, + final int z, + final EntityPlayer player, + final int side, + final float lx, + final float ly, + final float lz) { + if (world.isRemote) { + return true; + } else { + TileEntityInfiniteFluid tank = (TileEntityInfiniteFluid) world.getTileEntity(x, y, z); + if (tank != null) { + Item handItem; + try { + handItem = player.getHeldItem().getItem(); + } catch (Throwable t) { + handItem = null; + } + if (handItem != null + && (handItem instanceof IFluidContainerItem + || handItem instanceof ItemFluidContainer + || FluidContainerRegistry.isFilledContainer(player.getHeldItem()))) { + if (tank.tank.getFluid() == null) { + try { + if (!FluidContainerRegistry.isFilledContainer(player.getHeldItem())) { + ItemStack handItemStack = player.getHeldItem(); + IFluidContainerItem container = (IFluidContainerItem) handItem; + FluidStack containerFluid = container.getFluid(handItemStack); + container.drain(handItemStack, container.getFluid(handItemStack).amount, true); + tank.tank.setFluid(containerFluid); + } else { + ItemStack handItemStack = player.getHeldItem(); + FluidContainerRegistry.drainFluidContainer(handItemStack); + FluidStack containerFluid = FluidContainerRegistry.getFluidForFilledItem(handItemStack); + ItemStack emptyContainer = FluidContainerRegistry.drainFluidContainer(handItemStack); + player.setItemInUse(emptyContainer, 0); - } - if (tank.tank.getFluid() != null) { - PlayerUtils.messagePlayer(player, "This tank contains " + tank.tank.getFluidAmount() + "L of " - + tank.tank.getFluid().getLocalizedName()); - } - } - } - return true; - } + tank.tank.setFluid(containerFluid); + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + } + if (tank.tank.getFluid() != null) { + PlayerUtils.messagePlayer( + player, + "This tank contains " + tank.tank.getFluidAmount() + "L of " + + tank.tank.getFluid().getLocalizedName()); + } + } + } + return true; + } - @Override - public int getRenderBlockPass() { - return 1; - } + @Override + public int getRenderBlockPass() { + return 1; + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { - return new TileEntityInfiniteFluid(); - } - - @Override - public void onBlockAdded(World world, int x, int y, int z) { - super.onBlockAdded(world, x, y, z); - } + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityInfiniteFluid(); + } + @Override + public void onBlockAdded(World world, int x, int y, int z) { + super.onBlockAdded(world, x, y, z); + } } diff --git a/src/main/java/gtPlusPlus/core/block/general/HellFire.java b/src/main/java/gtPlusPlus/core/block/general/HellFire.java index 233f200815..f2c9c1a319 100644 --- a/src/main/java/gtPlusPlus/core/block/general/HellFire.java +++ b/src/main/java/gtPlusPlus/core/block/general/HellFire.java @@ -2,17 +2,18 @@ package gtPlusPlus.core.block.general; import static net.minecraftforge.common.util.ForgeDirection.*; -import java.util.IdentityHashMap; -import java.util.Map.Entry; -import java.util.Random; - import com.google.common.collect.Maps; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.api.objects.random.XSTR; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.math.MathUtils; +import java.util.IdentityHashMap; +import java.util.Map.Entry; +import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.BlockFire; import net.minecraft.block.material.MapColor; @@ -23,535 +24,552 @@ import net.minecraft.init.Blocks; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; - -import gtPlusPlus.api.objects.random.XSTR; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.math.MathUtils; import net.minecraftforge.common.util.ForgeDirection; public class HellFire extends BlockFire { - @Deprecated - private final int[] field_149849_a = new int[Short.MAX_VALUE]; - @Deprecated - private final int[] field_149848_b = new int[Short.MAX_VALUE]; - @SideOnly(Side.CLIENT) - private IIcon[] IIconArray; - - public HellFire() { - this.setTickRandomly(true); - this.setLightLevel(1F); - this.setLightOpacity(0); - //this.setBlockTextureName(CORE.MODID + "hellfire/blockHellFire"); - this.setBlockName("blockHellFire"); - this.setCreativeTab(AddToCreativeTab.tabBlock); - GameRegistry.registerBlock(this, "blockHellFire"); - LanguageRegistry.addName(this, "Hellish Fire"); - this.enableBrutalFire(); - } - - private void enableBrutalFire() { - for (final Object o : Block.blockRegistry.getKeys()) - { - - try { - - final String name = (String)o; - final Block b = Block.getBlockFromName(name); - if (b != Blocks.air) - { - final int spread = Blocks.fire.getEncouragement(b); - final int flamm = Blocks.fire.getFlammability(b); - if (flamm > 0 && spread > 0) { - this.setFireInfo(b, spread * 4, flamm * 4); - } - } - - } - catch (Throwable t) { - t.printStackTrace(); - } - } - - //Special Case madness - this.setFireInfo(Blocks.brown_mushroom_block, 20, 100); - this.setFireInfo(Blocks.red_mushroom_block, 20, 100); - this.setFireInfo(Blocks.grass, 20, 100); - this.setFireInfo(Blocks.mycelium, 20, 100); - - } - - /** - * How many world ticks before ticking - */ - @Override - public int tickRate(final World world) { - return 5; - } - - /** - * Ticks the block if it's been scheduled - */ - @Override - public void updateTick(final World world, final int x, final int y, final int z, Random random) { - - random = new XSTR(); - - if (world.getGameRules().getGameRuleBooleanValue("doFireTick")) { - final boolean flag = world.getBlock(x, y - 1, z).isFireSource(world, x, y - 1, z, UP); - - if (!this.canPlaceBlockAt(world, x, y, z)) { - world.setBlockToAir(x, y, z); - } - - if (!flag && world.isRaining() - && (world.canLightningStrikeAt(x, y, z) || world.canLightningStrikeAt(x - 1, y, z) - || world.canLightningStrikeAt(x + 1, y, z) || world.canLightningStrikeAt(x, y, z - 1) - || world.canLightningStrikeAt(x, y, z + 1))) { - - if (MathUtils.randInt(0, 100) >= 90){ - world.setBlockToAir(x, y, z); - } - } - else { - final int blockMeta = world.getBlockMetadata(x, y, z); - - if (blockMeta < 15) { - world.setBlockMetadataWithNotify(x, y, z, blockMeta + (random.nextInt(3) / 2), 4); - } - - world.scheduleBlockUpdate(x, y, z, this, this.tickRate(world) + random.nextInt(10)); - - if (!flag && !this.canNeighborBurn(world, x, y, z)) { - if (!World.doesBlockHaveSolidTopSurface(world, x, y - 1, z) || (blockMeta > 3)) { - world.setBlockToAir(x, y, z); - } - } - else if (!flag && !this.canCatchFire(world, x, y - 1, z, UP) && (blockMeta == 15) && (random.nextInt(4) == 0)) { - world.setBlockToAir(x, y, z); - } - else { - final boolean flag1 = world.isBlockHighHumidity(x, y, z); - byte b0 = 0; - - if (flag1) { - b0 = -50; - } - - this.tryCatchFire(world, x + 1, y, z, 300 + b0, random, blockMeta, WEST); - this.tryCatchFire(world, x - 1, y, z, 300 + b0, random, blockMeta, EAST); - this.tryCatchFire(world, x, y - 1, z, 250 + b0, random, blockMeta, UP); - this.tryCatchFire(world, x, y + 1, z, 250 + b0, random, blockMeta, DOWN); - this.tryCatchFire(world, x, y, z - 1, 300 + b0, random, blockMeta, SOUTH); - this.tryCatchFire(world, x, y, z + 1, 300 + b0, random, blockMeta, NORTH); - - for (int i1 = x - 1; i1 <= (x + 1); ++i1) { - for (int j1 = z - 1; j1 <= (z + 1); ++j1) { - for (int k1 = y - 1; k1 <= (y + 4); ++k1) { - if ((i1 != x) || (k1 != y) || (j1 != z)) { - int l1 = 100; - - if (k1 > (y + 1)) { - l1 += (k1 - (y + 1)) * 100; - } - - final int neighbourFireChance = this.getChanceOfNeighborsEncouragingFire(world, i1, k1, j1); - - if (neighbourFireChance > 0) { - int j2 = (neighbourFireChance + 40 + (world.difficultySetting.getDifficultyId() * 14)) / (blockMeta + 30); - - if (flag1) { - j2 /= 2; - } - - if ((j2 > 0) && (random.nextInt(l1) <= j2) - && (!world.isRaining() || !world.canLightningStrikeAt(i1, k1, j1)) - && !world.canLightningStrikeAt(i1 - 1, k1, z) - && !world.canLightningStrikeAt(i1 + 1, k1, j1) - && !world.canLightningStrikeAt(i1, k1, j1 - 1) - && !world.canLightningStrikeAt(i1, k1, j1 + 1)) { - int k2 = blockMeta + (random.nextInt(5) / 4); - - if (k2 > 15) { - k2 = 15; - } - - world.setBlock(i1, k1, j1, this, k2, 3); - } - } - } - } - } - } - } - } - } - } - - private void tryCatchFire(final World world, final int p_149841_2_, final int p_149841_3_, final int p_149841_4_, final int p_149841_5_, final Random p_149841_6_, final int p_149841_7_, final ForgeDirection face) { - final int j1 = world.getBlock(p_149841_2_, p_149841_3_, p_149841_4_).getFlammability(world, p_149841_2_, - p_149841_3_, p_149841_4_, face); - - if (p_149841_6_.nextInt(p_149841_5_) < j1) { - final boolean flag = world.getBlock(p_149841_2_, p_149841_3_, p_149841_4_) == Blocks.tnt; - - if ((p_149841_6_.nextInt(p_149841_7_ + 10) < 5) - && !world.canLightningStrikeAt(p_149841_2_, p_149841_3_, p_149841_4_)) { - int k1 = p_149841_7_ + (p_149841_6_.nextInt(5) / 4); - - if (k1 > 15) { - k1 = 15; - } - - world.setBlock(p_149841_2_, p_149841_3_, p_149841_4_, this, k1, 3); - } - else { - world.setBlockToAir(p_149841_2_, p_149841_3_, p_149841_4_); - } - - if (flag) { - Blocks.tnt.onBlockDestroyedByPlayer(world, p_149841_2_, p_149841_3_, p_149841_4_, 1); - } - } - } - - /** - * Returns true if at least one block next to this one can burn. - */ - private boolean canNeighborBurn(final World world, final int x, final int y, final int z) { - return this.canCatchFire(world, x + 1, y, z, WEST) - || this.canCatchFire(world, x - 1, y, z, EAST) - || this.canCatchFire(world, x, y - 1, z, UP) - || this.canCatchFire(world, x, y + 1, z, DOWN) - || this.canCatchFire(world, x, y, z - 1, SOUTH) - || this.canCatchFire(world, x, y, z + 1, NORTH); - } - - /** - * Gets the highest chance of a neighbor block encouraging this block to - * catch fire - */ - private int getChanceOfNeighborsEncouragingFire(final World world, final int x, final int y, final int z) { - final byte b0 = 0; - - if (!world.isAirBlock(x, y, z)) { - return 0; - } - else { - int l = b0; - l = this.getChanceToEncourageFire(world, x + 1, y, z, l, WEST); - l = this.getChanceToEncourageFire(world, x - 1, y, z, l, EAST); - l = this.getChanceToEncourageFire(world, x, y - 1, z, l, UP); - l = this.getChanceToEncourageFire(world, x, y + 1, z, l, DOWN); - l = this.getChanceToEncourageFire(world, x, y, z - 1, l, SOUTH); - l = this.getChanceToEncourageFire(world, x, y, z + 1, l, NORTH); - return l; - } - } - - /** - * Checks the specified block coordinate to see if it can catch fire. Args: - * blockAccess, x, y, z - */ - @Override - @Deprecated - public boolean canBlockCatchFire(final IBlockAccess p_149844_1_, final int p_149844_2_, final int p_149844_3_, final int p_149844_4_) { - return this.canCatchFire(p_149844_1_, p_149844_2_, p_149844_3_, p_149844_4_, UP); - } - - /** - * Checks to see if its valid to put this block at the specified - * coordinates. Args: world, x, y, z - */ - @Override - public boolean canPlaceBlockAt(final World worldObj, final int x, final int y, final int z) { - return World.doesBlockHaveSolidTopSurface(worldObj, x, y - 1, z) - || this.canNeighborBurn(worldObj, x, y, z); - } - - /** - * Lets the block know when one of its neighbor changes. Doesn't know which - * neighbor changed (coordinates passed are their own) Args: x, y, z, - * neighbor Block - */ - @Override - public void onNeighborBlockChange(final World worldObj, final int x, final int y, final int z, final Block blockObj) { - if (!World.doesBlockHaveSolidTopSurface(worldObj, x, y - 1, z) - && !this.canNeighborBurn(worldObj, x, y, z)) { - worldObj.setBlockToAir(x, y, z); - } - } - - /** - * Called whenever the block is added into the world. Args: world, x, y, z - */ - @Override - public void onBlockAdded(final World world, final int x, final int y, final int z) { - if ((world.provider.dimensionId > 0) - || !Blocks.portal.func_150000_e(world, x, y, z)) { - if (!World.doesBlockHaveSolidTopSurface(world, x, y - 1, z) - && !this.canNeighborBurn(world, x, y, z)) { - world.setBlockToAir(x, y, z); - } - else { - world.scheduleBlockUpdate(x, y, z, this, - this.tickRate(world) + world.rand.nextInt(10)); - } - } - } - - //Burn - @Override - public void onEntityWalking(final World world, final int i, final int j, final int k, final Entity entity) { - entity.setFire(10); - } - - @Override - public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { - return false; - } - - //Burn - @Override - public void onEntityCollidedWithBlock(final World world, final int i, final int j, final int k, final Entity entity) { - entity.setFire(10); - } - - /** - * A randomly called display update to be able to add particles or other - * items for display - */ - @Override - @SideOnly(Side.CLIENT) - public void randomDisplayTick(final World world, final int x, final int y, final int z, Random randomObj) { - - randomObj = new XSTR(); - - if (randomObj.nextInt(24) == 0) { - world.playSound(x + 0.5F, y + 0.5F, z + 0.5F, "fire.fire", - 1.0F + randomObj.nextFloat(), (randomObj.nextFloat() * 0.7F) + 0.3F, false); - } - - int l; - float f; - float f1; - float f2; - - if (!World.doesBlockHaveSolidTopSurface(world, x, y - 1, z) - && !Blocks.fire.canCatchFire(world, x, y - 1, z, UP)) { - if (Blocks.fire.canCatchFire(world, x - 1, y, z, EAST)) { - for (l = 0; l < 2; ++l) { - f = x + (randomObj.nextFloat() * 0.1F); - f1 = y + randomObj.nextFloat(); - f2 = z + randomObj.nextFloat(); - world.spawnParticle("witchMagic", f, f1, f2, 0.0D, 0.0D, 0.0D); - world.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); - world.spawnParticle("largesmoke", f, f1+0.5F, f2, 0.0D, 0.0D, 0.0D); - - } - } - - if (Blocks.fire.canCatchFire(world, x + 1, y, z, WEST)) { - for (l = 0; l < 2; ++l) { - f = (x + 1) - (randomObj.nextFloat() * 0.1F); - f1 = y + randomObj.nextFloat(); - f2 = z + randomObj.nextFloat(); - world.spawnParticle("witchMagic", f, f1, f2, 0.0D, 0.0D, 0.0D); - world.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); - world.spawnParticle("largesmoke", f, f1+0.5F, f2, 0.0D, 0.0D, 0.0D); - } - } - - if (Blocks.fire.canCatchFire(world, x, y, z - 1, SOUTH)) { - for (l = 0; l < 2; ++l) { - f = x + randomObj.nextFloat(); - f1 = y + randomObj.nextFloat(); - f2 = z + (randomObj.nextFloat() * 0.1F); - world.spawnParticle("witchMagic", f, f1, f2, 0.0D, 0.0D, 0.0D); - world.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); - world.spawnParticle("largesmoke", f, f1+0.5F, f2, 0.0D, 0.0D, 0.0D); - } - } - - if (Blocks.fire.canCatchFire(world, x, y, z + 1, NORTH)) { - for (l = 0; l < 2; ++l) { - f = x + randomObj.nextFloat(); - f1 = y + randomObj.nextFloat(); - f2 = (z + 1) - (randomObj.nextFloat() * 0.1F); - world.spawnParticle("witchMagic", f, f1, f2, 0.0D, 0.0D, 0.0D); - world.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); - world.spawnParticle("largesmoke", f, f1+0.5F, f2, 0.0D, 0.0D, 0.0D); - } - } - - if (Blocks.fire.canCatchFire(world, x, y + 1, z, DOWN)) { - for (l = 0; l < 2; ++l) { - f = x + randomObj.nextFloat(); - f1 = (y + 1) - (randomObj.nextFloat() * 0.1F); - f2 = z + randomObj.nextFloat(); - world.spawnParticle("witchMagic", f, f1, f2, 0.0D, 0.0D, 0.0D); - world.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); - world.spawnParticle("largesmoke", f, f1+0.5F, f2, 0.0D, 0.0D, 0.0D); - } - } - } - else { - for (l = 0; l < 5; ++l) { - f = x + randomObj.nextFloat(); - f1 = y + (randomObj.nextFloat() * 0.5F) + 0.5F; - f2 = z + randomObj.nextFloat(); - world.spawnParticle("witchMagic", f, f1, f2, 0.0D, 0.0D, 0.0D); - world.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); - world.spawnParticle("largesmoke", f, f1+0.5F, f2, 0.0D, 0.0D, 0.0D); - } - } - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister IIconRegister) { - this.IIconArray = new IIcon[] { - IIconRegister.registerIcon(CORE.MODID + ":" + "hellfire/" + "blockHellFire" + "_layer_0"), - IIconRegister.registerIcon(CORE.MODID + ":" + "hellfire/" + "blockHellFire" + "_layer_1") }; - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getFireIcon(final int p_149840_1_) { - return this.IIconArray[p_149840_1_]; - } - - /** - * Gets the block's texture. Args: side, meta - */ - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) { - return this.IIconArray[0]; - } - - @Override - public MapColor getMapColor(final int p_149728_1_) { - return MapColor.snowColor; - } - - /* - * ================================= Forge Start - * ====================================== - */ - private static class FireInfo { - private int encouragement = 0; - private int flammibility = 0; - } - - private final IdentityHashMap blockInfo = Maps.newIdentityHashMap(); - - @Override - public void setFireInfo(final Block block, final int encouragement, final int flammibility) { - try { - if (block == Blocks.air) { - throw new IllegalArgumentException("Tried to set air on fire... This is bad."); - } - final int id = Block.getIdFromBlock(block); - if (id >= 4096 || id >= field_149849_a.length || id >= field_149848_b.length) { - return; - } - this.field_149849_a[id] = encouragement; - this.field_149848_b[id] = flammibility; - - final FireInfo info = this.getInfo(block, true); - info.encouragement = encouragement; - info.flammibility = flammibility; - } - catch (Throwable t) {} - } - - private FireInfo getInfo(final Block block, final boolean garentee) { - FireInfo ret = this.blockInfo.get(block); - if ((ret == null) && garentee) { - ret = new FireInfo(); - this.blockInfo.put(block, ret); - } - return ret; - } - - @Override - public void rebuildFireInfo() { - for (int x = 0; x < 4096; x++) { - // If we care.. we could detect changes in here and make sure we - // keep them, however - // it's my thinking that anyone who hacks into the private variables - // should DIAF and we don't care about them. - this.field_149849_a[x] = 0; - this.field_149848_b[x] = 0; - } - - for (final Entry e : this.blockInfo.entrySet()) { - final int id = Block.getIdFromBlock(e.getKey()); - if ((id >= 0) && (id < 4096)) { - this.field_149849_a[id] = e.getValue().encouragement; - this.field_149848_b[id] = e.getValue().flammibility; - } - } - } - - @Override - public int getFlammability(final Block block) { - final int id = Block.getIdFromBlock(block); - return (id >= 0) && (id < 4096) ? this.field_149848_b[id] : 0; - } - - @Override - public int getEncouragement(final Block block) { - final int id = Block.getIdFromBlock(block); - return (id >= 0) && (id < 4096) ? this.field_149849_a[id] : 0; - } - - /** - * Side sensitive version that calls the block function. - * - * @param world - * The current world - * @param x - * X Position - * @param y - * Y Position - * @param z - * Z Position - * @param face - * The side the fire is coming from - * @return True if the face can catch fire. - */ - @Override - public boolean canCatchFire(final IBlockAccess world, final int x, final int y, final int z, final ForgeDirection face) { - return world.getBlock(x, y, z).isFlammable(world, x, y, z, face); - } - - /** - * Side sensitive version that calls the block function. - * - * @param world - * The current world - * @param x - * X Position - * @param y - * Y Position - * @param z - * Z Position - * @param oldChance - * The previous maximum chance. - * @param face - * The side the fire is coming from - * @return The chance of the block catching fire, or oldChance if it is - * higher - */ - @Override - public int getChanceToEncourageFire(final IBlockAccess world, final int x, final int y, final int z, final int oldChance, final ForgeDirection face) { - final int newChance = world.getBlock(x, y, z).getFireSpreadSpeed(world, x, y, z, face); - return (newChance > oldChance ? newChance : oldChance); - } - /* - * ================================= Forge Start - * ====================================== - */ -} \ No newline at end of file + @Deprecated + private final int[] field_149849_a = new int[Short.MAX_VALUE]; + + @Deprecated + private final int[] field_149848_b = new int[Short.MAX_VALUE]; + + @SideOnly(Side.CLIENT) + private IIcon[] IIconArray; + + public HellFire() { + this.setTickRandomly(true); + this.setLightLevel(1F); + this.setLightOpacity(0); + // this.setBlockTextureName(CORE.MODID + "hellfire/blockHellFire"); + this.setBlockName("blockHellFire"); + this.setCreativeTab(AddToCreativeTab.tabBlock); + GameRegistry.registerBlock(this, "blockHellFire"); + LanguageRegistry.addName(this, "Hellish Fire"); + this.enableBrutalFire(); + } + + private void enableBrutalFire() { + for (final Object o : Block.blockRegistry.getKeys()) { + + try { + + final String name = (String) o; + final Block b = Block.getBlockFromName(name); + if (b != Blocks.air) { + final int spread = Blocks.fire.getEncouragement(b); + final int flamm = Blocks.fire.getFlammability(b); + if (flamm > 0 && spread > 0) { + this.setFireInfo(b, spread * 4, flamm * 4); + } + } + + } catch (Throwable t) { + t.printStackTrace(); + } + } + + // Special Case madness + this.setFireInfo(Blocks.brown_mushroom_block, 20, 100); + this.setFireInfo(Blocks.red_mushroom_block, 20, 100); + this.setFireInfo(Blocks.grass, 20, 100); + this.setFireInfo(Blocks.mycelium, 20, 100); + } + + /** + * How many world ticks before ticking + */ + @Override + public int tickRate(final World world) { + return 5; + } + + /** + * Ticks the block if it's been scheduled + */ + @Override + public void updateTick(final World world, final int x, final int y, final int z, Random random) { + + random = new XSTR(); + + if (world.getGameRules().getGameRuleBooleanValue("doFireTick")) { + final boolean flag = world.getBlock(x, y - 1, z).isFireSource(world, x, y - 1, z, UP); + + if (!this.canPlaceBlockAt(world, x, y, z)) { + world.setBlockToAir(x, y, z); + } + + if (!flag + && world.isRaining() + && (world.canLightningStrikeAt(x, y, z) + || world.canLightningStrikeAt(x - 1, y, z) + || world.canLightningStrikeAt(x + 1, y, z) + || world.canLightningStrikeAt(x, y, z - 1) + || world.canLightningStrikeAt(x, y, z + 1))) { + + if (MathUtils.randInt(0, 100) >= 90) { + world.setBlockToAir(x, y, z); + } + } else { + final int blockMeta = world.getBlockMetadata(x, y, z); + + if (blockMeta < 15) { + world.setBlockMetadataWithNotify(x, y, z, blockMeta + (random.nextInt(3) / 2), 4); + } + + world.scheduleBlockUpdate(x, y, z, this, this.tickRate(world) + random.nextInt(10)); + + if (!flag && !this.canNeighborBurn(world, x, y, z)) { + if (!World.doesBlockHaveSolidTopSurface(world, x, y - 1, z) || (blockMeta > 3)) { + world.setBlockToAir(x, y, z); + } + } else if (!flag + && !this.canCatchFire(world, x, y - 1, z, UP) + && (blockMeta == 15) + && (random.nextInt(4) == 0)) { + world.setBlockToAir(x, y, z); + } else { + final boolean flag1 = world.isBlockHighHumidity(x, y, z); + byte b0 = 0; + + if (flag1) { + b0 = -50; + } + + this.tryCatchFire(world, x + 1, y, z, 300 + b0, random, blockMeta, WEST); + this.tryCatchFire(world, x - 1, y, z, 300 + b0, random, blockMeta, EAST); + this.tryCatchFire(world, x, y - 1, z, 250 + b0, random, blockMeta, UP); + this.tryCatchFire(world, x, y + 1, z, 250 + b0, random, blockMeta, DOWN); + this.tryCatchFire(world, x, y, z - 1, 300 + b0, random, blockMeta, SOUTH); + this.tryCatchFire(world, x, y, z + 1, 300 + b0, random, blockMeta, NORTH); + + for (int i1 = x - 1; i1 <= (x + 1); ++i1) { + for (int j1 = z - 1; j1 <= (z + 1); ++j1) { + for (int k1 = y - 1; k1 <= (y + 4); ++k1) { + if ((i1 != x) || (k1 != y) || (j1 != z)) { + int l1 = 100; + + if (k1 > (y + 1)) { + l1 += (k1 - (y + 1)) * 100; + } + + final int neighbourFireChance = + this.getChanceOfNeighborsEncouragingFire(world, i1, k1, j1); + + if (neighbourFireChance > 0) { + int j2 = (neighbourFireChance + + 40 + + (world.difficultySetting.getDifficultyId() * 14)) + / (blockMeta + 30); + + if (flag1) { + j2 /= 2; + } + + if ((j2 > 0) + && (random.nextInt(l1) <= j2) + && (!world.isRaining() || !world.canLightningStrikeAt(i1, k1, j1)) + && !world.canLightningStrikeAt(i1 - 1, k1, z) + && !world.canLightningStrikeAt(i1 + 1, k1, j1) + && !world.canLightningStrikeAt(i1, k1, j1 - 1) + && !world.canLightningStrikeAt(i1, k1, j1 + 1)) { + int k2 = blockMeta + (random.nextInt(5) / 4); + + if (k2 > 15) { + k2 = 15; + } + + world.setBlock(i1, k1, j1, this, k2, 3); + } + } + } + } + } + } + } + } + } + } + + private void tryCatchFire( + final World world, + final int p_149841_2_, + final int p_149841_3_, + final int p_149841_4_, + final int p_149841_5_, + final Random p_149841_6_, + final int p_149841_7_, + final ForgeDirection face) { + final int j1 = world.getBlock(p_149841_2_, p_149841_3_, p_149841_4_) + .getFlammability(world, p_149841_2_, p_149841_3_, p_149841_4_, face); + + if (p_149841_6_.nextInt(p_149841_5_) < j1) { + final boolean flag = world.getBlock(p_149841_2_, p_149841_3_, p_149841_4_) == Blocks.tnt; + + if ((p_149841_6_.nextInt(p_149841_7_ + 10) < 5) + && !world.canLightningStrikeAt(p_149841_2_, p_149841_3_, p_149841_4_)) { + int k1 = p_149841_7_ + (p_149841_6_.nextInt(5) / 4); + + if (k1 > 15) { + k1 = 15; + } + + world.setBlock(p_149841_2_, p_149841_3_, p_149841_4_, this, k1, 3); + } else { + world.setBlockToAir(p_149841_2_, p_149841_3_, p_149841_4_); + } + + if (flag) { + Blocks.tnt.onBlockDestroyedByPlayer(world, p_149841_2_, p_149841_3_, p_149841_4_, 1); + } + } + } + + /** + * Returns true if at least one block next to this one can burn. + */ + private boolean canNeighborBurn(final World world, final int x, final int y, final int z) { + return this.canCatchFire(world, x + 1, y, z, WEST) + || this.canCatchFire(world, x - 1, y, z, EAST) + || this.canCatchFire(world, x, y - 1, z, UP) + || this.canCatchFire(world, x, y + 1, z, DOWN) + || this.canCatchFire(world, x, y, z - 1, SOUTH) + || this.canCatchFire(world, x, y, z + 1, NORTH); + } + + /** + * Gets the highest chance of a neighbor block encouraging this block to + * catch fire + */ + private int getChanceOfNeighborsEncouragingFire(final World world, final int x, final int y, final int z) { + final byte b0 = 0; + + if (!world.isAirBlock(x, y, z)) { + return 0; + } else { + int l = b0; + l = this.getChanceToEncourageFire(world, x + 1, y, z, l, WEST); + l = this.getChanceToEncourageFire(world, x - 1, y, z, l, EAST); + l = this.getChanceToEncourageFire(world, x, y - 1, z, l, UP); + l = this.getChanceToEncourageFire(world, x, y + 1, z, l, DOWN); + l = this.getChanceToEncourageFire(world, x, y, z - 1, l, SOUTH); + l = this.getChanceToEncourageFire(world, x, y, z + 1, l, NORTH); + return l; + } + } + + /** + * Checks the specified block coordinate to see if it can catch fire. Args: + * blockAccess, x, y, z + */ + @Override + @Deprecated + public boolean canBlockCatchFire( + final IBlockAccess p_149844_1_, final int p_149844_2_, final int p_149844_3_, final int p_149844_4_) { + return this.canCatchFire(p_149844_1_, p_149844_2_, p_149844_3_, p_149844_4_, UP); + } + + /** + * Checks to see if its valid to put this block at the specified + * coordinates. Args: world, x, y, z + */ + @Override + public boolean canPlaceBlockAt(final World worldObj, final int x, final int y, final int z) { + return World.doesBlockHaveSolidTopSurface(worldObj, x, y - 1, z) || this.canNeighborBurn(worldObj, x, y, z); + } + + /** + * Lets the block know when one of its neighbor changes. Doesn't know which + * neighbor changed (coordinates passed are their own) Args: x, y, z, + * neighbor Block + */ + @Override + public void onNeighborBlockChange( + final World worldObj, final int x, final int y, final int z, final Block blockObj) { + if (!World.doesBlockHaveSolidTopSurface(worldObj, x, y - 1, z) && !this.canNeighborBurn(worldObj, x, y, z)) { + worldObj.setBlockToAir(x, y, z); + } + } + + /** + * Called whenever the block is added into the world. Args: world, x, y, z + */ + @Override + public void onBlockAdded(final World world, final int x, final int y, final int z) { + if ((world.provider.dimensionId > 0) || !Blocks.portal.func_150000_e(world, x, y, z)) { + if (!World.doesBlockHaveSolidTopSurface(world, x, y - 1, z) && !this.canNeighborBurn(world, x, y, z)) { + world.setBlockToAir(x, y, z); + } else { + world.scheduleBlockUpdate(x, y, z, this, this.tickRate(world) + world.rand.nextInt(10)); + } + } + } + + // Burn + @Override + public void onEntityWalking(final World world, final int i, final int j, final int k, final Entity entity) { + entity.setFire(10); + } + + @Override + public boolean canCreatureSpawn( + final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + // Burn + @Override + public void onEntityCollidedWithBlock( + final World world, final int i, final int j, final int k, final Entity entity) { + entity.setFire(10); + } + + /** + * A randomly called display update to be able to add particles or other + * items for display + */ + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick(final World world, final int x, final int y, final int z, Random randomObj) { + + randomObj = new XSTR(); + + if (randomObj.nextInt(24) == 0) { + world.playSound( + x + 0.5F, + y + 0.5F, + z + 0.5F, + "fire.fire", + 1.0F + randomObj.nextFloat(), + (randomObj.nextFloat() * 0.7F) + 0.3F, + false); + } + + int l; + float f; + float f1; + float f2; + + if (!World.doesBlockHaveSolidTopSurface(world, x, y - 1, z) + && !Blocks.fire.canCatchFire(world, x, y - 1, z, UP)) { + if (Blocks.fire.canCatchFire(world, x - 1, y, z, EAST)) { + for (l = 0; l < 2; ++l) { + f = x + (randomObj.nextFloat() * 0.1F); + f1 = y + randomObj.nextFloat(); + f2 = z + randomObj.nextFloat(); + world.spawnParticle("witchMagic", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1 + 0.5F, f2, 0.0D, 0.0D, 0.0D); + } + } + + if (Blocks.fire.canCatchFire(world, x + 1, y, z, WEST)) { + for (l = 0; l < 2; ++l) { + f = (x + 1) - (randomObj.nextFloat() * 0.1F); + f1 = y + randomObj.nextFloat(); + f2 = z + randomObj.nextFloat(); + world.spawnParticle("witchMagic", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1 + 0.5F, f2, 0.0D, 0.0D, 0.0D); + } + } + + if (Blocks.fire.canCatchFire(world, x, y, z - 1, SOUTH)) { + for (l = 0; l < 2; ++l) { + f = x + randomObj.nextFloat(); + f1 = y + randomObj.nextFloat(); + f2 = z + (randomObj.nextFloat() * 0.1F); + world.spawnParticle("witchMagic", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1 + 0.5F, f2, 0.0D, 0.0D, 0.0D); + } + } + + if (Blocks.fire.canCatchFire(world, x, y, z + 1, NORTH)) { + for (l = 0; l < 2; ++l) { + f = x + randomObj.nextFloat(); + f1 = y + randomObj.nextFloat(); + f2 = (z + 1) - (randomObj.nextFloat() * 0.1F); + world.spawnParticle("witchMagic", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1 + 0.5F, f2, 0.0D, 0.0D, 0.0D); + } + } + + if (Blocks.fire.canCatchFire(world, x, y + 1, z, DOWN)) { + for (l = 0; l < 2; ++l) { + f = x + randomObj.nextFloat(); + f1 = (y + 1) - (randomObj.nextFloat() * 0.1F); + f2 = z + randomObj.nextFloat(); + world.spawnParticle("witchMagic", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1 + 0.5F, f2, 0.0D, 0.0D, 0.0D); + } + } + } else { + for (l = 0; l < 5; ++l) { + f = x + randomObj.nextFloat(); + f1 = y + (randomObj.nextFloat() * 0.5F) + 0.5F; + f2 = z + randomObj.nextFloat(); + world.spawnParticle("witchMagic", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D); + world.spawnParticle("largesmoke", f, f1 + 0.5F, f2, 0.0D, 0.0D, 0.0D); + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister IIconRegister) { + this.IIconArray = new IIcon[] { + IIconRegister.registerIcon(CORE.MODID + ":" + "hellfire/" + "blockHellFire" + "_layer_0"), + IIconRegister.registerIcon(CORE.MODID + ":" + "hellfire/" + "blockHellFire" + "_layer_1") + }; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getFireIcon(final int p_149840_1_) { + return this.IIconArray[p_149840_1_]; + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) { + return this.IIconArray[0]; + } + + @Override + public MapColor getMapColor(final int p_149728_1_) { + return MapColor.snowColor; + } + + /* + * ================================= Forge Start + * ====================================== + */ + private static class FireInfo { + private int encouragement = 0; + private int flammibility = 0; + } + + private final IdentityHashMap blockInfo = Maps.newIdentityHashMap(); + + @Override + public void setFireInfo(final Block block, final int encouragement, final int flammibility) { + try { + if (block == Blocks.air) { + throw new IllegalArgumentException("Tried to set air on fire... This is bad."); + } + final int id = Block.getIdFromBlock(block); + if (id >= 4096 || id >= field_149849_a.length || id >= field_149848_b.length) { + return; + } + this.field_149849_a[id] = encouragement; + this.field_149848_b[id] = flammibility; + + final FireInfo info = this.getInfo(block, true); + info.encouragement = encouragement; + info.flammibility = flammibility; + } catch (Throwable t) { + } + } + + private FireInfo getInfo(final Block block, final boolean garentee) { + FireInfo ret = this.blockInfo.get(block); + if ((ret == null) && garentee) { + ret = new FireInfo(); + this.blockInfo.put(block, ret); + } + return ret; + } + + @Override + public void rebuildFireInfo() { + for (int x = 0; x < 4096; x++) { + // If we care.. we could detect changes in here and make sure we + // keep them, however + // it's my thinking that anyone who hacks into the private variables + // should DIAF and we don't care about them. + this.field_149849_a[x] = 0; + this.field_149848_b[x] = 0; + } + + for (final Entry e : this.blockInfo.entrySet()) { + final int id = Block.getIdFromBlock(e.getKey()); + if ((id >= 0) && (id < 4096)) { + this.field_149849_a[id] = e.getValue().encouragement; + this.field_149848_b[id] = e.getValue().flammibility; + } + } + } + + @Override + public int getFlammability(final Block block) { + final int id = Block.getIdFromBlock(block); + return (id >= 0) && (id < 4096) ? this.field_149848_b[id] : 0; + } + + @Override + public int getEncouragement(final Block block) { + final int id = Block.getIdFromBlock(block); + return (id >= 0) && (id < 4096) ? this.field_149849_a[id] : 0; + } + + /** + * Side sensitive version that calls the block function. + * + * @param world + * The current world + * @param x + * X Position + * @param y + * Y Position + * @param z + * Z Position + * @param face + * The side the fire is coming from + * @return True if the face can catch fire. + */ + @Override + public boolean canCatchFire( + final IBlockAccess world, final int x, final int y, final int z, final ForgeDirection face) { + return world.getBlock(x, y, z).isFlammable(world, x, y, z, face); + } + + /** + * Side sensitive version that calls the block function. + * + * @param world + * The current world + * @param x + * X Position + * @param y + * Y Position + * @param z + * Z Position + * @param oldChance + * The previous maximum chance. + * @param face + * The side the fire is coming from + * @return The chance of the block catching fire, or oldChance if it is + * higher + */ + @Override + public int getChanceToEncourageFire( + final IBlockAccess world, + final int x, + final int y, + final int z, + final int oldChance, + final ForgeDirection face) { + final int newChance = world.getBlock(x, y, z).getFireSpreadSpeed(world, x, y, z, face); + return (newChance > oldChance ? newChance : oldChance); + } + /* + * ================================= Forge Start + * ====================================== + */ +} diff --git a/src/main/java/gtPlusPlus/core/block/general/LightGlass.java b/src/main/java/gtPlusPlus/core/block/general/LightGlass.java index 30da7f1d56..df2ec518ce 100644 --- a/src/main/java/gtPlusPlus/core/block/general/LightGlass.java +++ b/src/main/java/gtPlusPlus/core/block/general/LightGlass.java @@ -1,144 +1,135 @@ package gtPlusPlus.core.block.general; -import java.util.Random; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.BlockAir; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; - /*public class LightGlass extends BlockBreakable {*/ -public class LightGlass extends BlockAir -{ +public class LightGlass extends BlockAir { + + private int state = 0; + private final int a = 255; + private int r = 255; + private int g = 0; + private int b = 0; + private int hex; -private int state = 0; - private final int a = 255; - private int r = 255; - private int g = 0; - private int b = 0; - private int hex; + public LightGlass(final boolean bool) { + // super("blockMFEffect", Material.air, bool); + super(); + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setBlockName("blockMFEffect"); + this.setLightLevel(12F); + setHardness(0.1F); + setBlockTextureName(CORE.MODID + ":" + "blockMFEffect"); + setStepSound(Block.soundTypeGlass); + GameRegistry.registerBlock(this, "blockMFEffect"); - public LightGlass(final boolean bool) - { - //super("blockMFEffect", Material.air, bool); - super(); - this.setCreativeTab(AddToCreativeTab.tabBlock); - this.setBlockName("blockMFEffect"); - this.setLightLevel(12F); - setHardness(0.1F); - setBlockTextureName(CORE.MODID + ":" + "blockMFEffect"); - setStepSound(Block.soundTypeGlass); - GameRegistry.registerBlock(this, "blockMFEffect"); - - /* - this.setLightOpacity(0); - this.setTickRandomly(true); - this.setResistance(1);*/ - } + /* + this.setLightOpacity(0); + this.setTickRandomly(true); + this.setResistance(1);*/ + } - /** - * Returns the quantity of items to drop on block destruction. - */ - @Override - public int quantityDropped(final Random rand) - { - return 0; - } + /** + * Returns the quantity of items to drop on block destruction. + */ + @Override + public int quantityDropped(final Random rand) { + return 0; + } - /** - * Returns which pass should this block be rendered on. 0 for solids and 1 for alpha - */ - @Override - @SideOnly(Side.CLIENT) - public int getRenderBlockPass() - { - return 0; - } + /** + * Returns which pass should this block be rendered on. 0 for solids and 1 for alpha + */ + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() { + return 0; + } - /** - * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) - */ - @Override - public boolean renderAsNormalBlock() - { - return false; - } + /** + * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) + */ + @Override + public boolean renderAsNormalBlock() { + return false; + } - /** - * Return true if a player with Silk Touch can harvest this block directly, and not its normal drops. - */ - @Override - protected boolean canSilkHarvest() - { - return false; - } + /** + * Return true if a player with Silk Touch can harvest this block directly, and not its normal drops. + */ + @Override + protected boolean canSilkHarvest() { + return false; + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister iIcon) - { - this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + "blockMFEffect"); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iIcon) { + this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + "blockMFEffect"); + } - @Override - //http://stackoverflow.com/questions/31784658/how-can-i-loop-through-all-rgb-combinations-in-rainbow-order-in-java - public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4) - { - if(this.state == 0){ - this.g++; - if(this.g == 255) { - this.state = 1; - } - } - if(this.state == 1){ - this.r--; - if(this.r == 0) { - this.state = 2; - } - } - if(this.state == 2){ - this.b++; - if(this.b == 255) { - this.state = 3; - } - } - if(this.state == 3){ - this.g--; - if(this.g == 0) { - this.state = 4; - } - } - if(this.state == 4){ - this.r++; - if(this.r == 255) { - this.state = 5; - } - } - if(this.state == 5){ - this.b--; - if(this.b == 0) { - this.state = 0; - } - } - this.hex = (this.a << 24) + (this.r << 16) + (this.g << 8) + (this.b); - return this.hex; - } + @Override + // http://stackoverflow.com/questions/31784658/how-can-i-loop-through-all-rgb-combinations-in-rainbow-order-in-java + public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4) { + if (this.state == 0) { + this.g++; + if (this.g == 255) { + this.state = 1; + } + } + if (this.state == 1) { + this.r--; + if (this.r == 0) { + this.state = 2; + } + } + if (this.state == 2) { + this.b++; + if (this.b == 255) { + this.state = 3; + } + } + if (this.state == 3) { + this.g--; + if (this.g == 0) { + this.state = 4; + } + } + if (this.state == 4) { + this.r++; + if (this.r == 255) { + this.state = 5; + } + } + if (this.state == 5) { + this.b--; + if (this.b == 0) { + this.state = 0; + } + } + this.hex = (this.a << 24) + (this.r << 16) + (this.g << 8) + (this.b); + return this.hex; + } - /** - * A randomly called display update to be able to add particles or other items for display - */ - @Override - @SideOnly(Side.CLIENT) - public void randomDisplayTick(final World world, final int posX, final int posY, final int posZ, final Random random){ - //Utils.spawnFX(world, posX, posY, posZ, "smoke", "cloud"); + /** + * A randomly called display update to be able to add particles or other items for display + */ + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick( + final World world, final int posX, final int posY, final int posZ, final Random random) { + // Utils.spawnFX(world, posX, posY, posZ, "smoke", "cloud"); - } -} \ No newline at end of file + } +} diff --git a/src/main/java/gtPlusPlus/core/block/general/MiningExplosives.java b/src/main/java/gtPlusPlus/core/block/general/MiningExplosives.java index 8925962e4e..2b71f12f6d 100644 --- a/src/main/java/gtPlusPlus/core/block/general/MiningExplosives.java +++ b/src/main/java/gtPlusPlus/core/block/general/MiningExplosives.java @@ -1,12 +1,13 @@ package gtPlusPlus.core.block.general; -import java.util.Random; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.entity.EntityPrimedMiningExplosive; +import gtPlusPlus.core.lib.CORE; +import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.BlockTNT; import net.minecraft.client.renderer.texture.IIconRegister; @@ -19,154 +20,172 @@ import net.minecraft.util.IIcon; import net.minecraft.world.Explosion; import net.minecraft.world.World; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.entity.EntityPrimedMiningExplosive; -import gtPlusPlus.core.lib.CORE; - public class MiningExplosives extends BlockTNT { - @SideOnly(Side.CLIENT) - private IIcon textureTop; - @SideOnly(Side.CLIENT) - private IIcon textureBottom; - - public MiningExplosives(){ - this.setBlockName("blockMiningExplosives"); - GameRegistry.registerBlock(this, "blockMiningExplosives"); - LanguageRegistry.addName(this, "Earth Blasting Explosives"); - this.setCreativeTab(AddToCreativeTab.tabMachines); - } - - /** - * Gets the block's texture. Args: side, meta - */ - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(final int p_149691_1_, final int p_149691_2_){ - return p_149691_1_ == 0 ? this.textureBottom : (p_149691_1_ == 1 ? this.textureTop : this.blockIcon); - } - - /** - * Called whenever the block is added into the world. Args: world, x, y, z - */ - @Override - public void onBlockAdded(final World world, final int x, final int y, final int z){ - super.onBlockAdded(world, x, y, z); - - if (world.isBlockIndirectlyGettingPowered(x, y, z)) - { - this.onBlockDestroyedByPlayer(world, x, y, z, 1); - world.setBlockToAir(x, y, z); - } - } - - /** - * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are - * their own) Args: x, y, z, neighbor Block - */ - @Override - public void onNeighborBlockChange(final World world, final int x, final int y, final int z, final Block neighbourblock){ - if (world.isBlockIndirectlyGettingPowered(x, y, z)) - { - this.onBlockDestroyedByPlayer(world, x, y, z, 1); - world.setBlockToAir(x, y, z); - } - } - - /** - * Returns the quantity of items to drop on block destruction. - */ - @Override - public int quantityDropped(final Random random){ - return 1; - } - - /** - * Called upon the block being destroyed by an explosion - */ - @Override - public void onBlockDestroyedByExplosion(final World world, final int x, final int y, final int z, final Explosion bang){ - if (!world.isRemote) - { - final EntityPrimedMiningExplosive EntityPrimedMiningExplosive = new EntityPrimedMiningExplosive(world, x + 0.5F, y + 0.5F, z + 0.5F, bang.getExplosivePlacedBy()); - EntityPrimedMiningExplosive.fuse = world.rand.nextInt(EntityPrimedMiningExplosive.fuse / 4) + (EntityPrimedMiningExplosive.fuse / 8); - world.spawnEntityInWorld(EntityPrimedMiningExplosive); - } - } - - /** - * Called right before the block is destroyed by a player. Args: world, x, y, z, metaData - */ - @Override - public void onBlockDestroyedByPlayer(final World world, final int x, final int y, final int z, final int meta){ - this.func_150114_a(world, x, y, z, meta, (EntityLivingBase)null); - } - - //TODO Spawns Primed TNT? - @Override - public void func_150114_a(final World world, final int p_150114_2_, final int p_150114_3_, final int p_150114_4_, final int p_150114_5_, final EntityLivingBase entityLiving){ - if (!world.isRemote) - { - if ((p_150114_5_ & 1) == 1) - { - final EntityPrimedMiningExplosive EntityPrimedMiningExplosive = new EntityPrimedMiningExplosive(world, p_150114_2_ + 0.5F, p_150114_3_ + 0.5F, p_150114_4_ + 0.5F, entityLiving); - world.spawnEntityInWorld(EntityPrimedMiningExplosive); - world.playSoundAtEntity(EntityPrimedMiningExplosive, "game.tnt.primed", 1.0F, 1.0F); - } - } - } - - /** - * Called upon block activation (right click on the block.) - */ - @Override - public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer clickingPlayer, final int p_149727_6_, final float p_149727_7_, final float p_149727_8_, final float p_149727_9_){ - if ((clickingPlayer.getCurrentEquippedItem() != null) && (clickingPlayer.getCurrentEquippedItem().getItem() == Items.flint_and_steel)) - { - this.func_150114_a(world, x, y, z, 1, clickingPlayer); - world.setBlockToAir(x, y, z); - clickingPlayer.getCurrentEquippedItem().damageItem(1, clickingPlayer); - return true; - } - else - { - return super.onBlockActivated(world, x, y, z, clickingPlayer, p_149727_6_, p_149727_7_, p_149727_8_, p_149727_9_); - } - } - - /** - * Triggered whenever an entity collides with this block (enters into the block). Args: world, x, y, z, entity - */ - @Override - public void onEntityCollidedWithBlock(final World world, final int x, final int y, final int z, final Entity entityTriggering){ - if ((entityTriggering instanceof EntityArrow) && !world.isRemote) - { - final EntityArrow entityarrow = (EntityArrow)entityTriggering; - - if (entityarrow.isBurning()) - { - this.func_150114_a(world, x, y, z, 1, entityarrow.shootingEntity instanceof EntityLivingBase ? (EntityLivingBase)entityarrow.shootingEntity : null); - world.setBlockToAir(x, y, z); - } - } - } - - /** - * Return whether this block can drop from an explosion. - */ - @Override - public boolean canDropFromExplosion(final Explosion bang){ - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister iconRegister){ - // - /*this.blockIcon = iconRegister.registerIcon(this.getTextureName() + "_side"); - this.textureTop = iconRegister.registerIcon(this.getTextureName() + "_top"); - this.textureBottom = iconRegister.registerIcon(this.getTextureName() + "_bottom");*/ - this.blockIcon = iconRegister.registerIcon(CORE.MODID + ":" + "chrono/" + "MetalSheet2"); - this.textureTop = iconRegister.registerIcon(CORE.MODID + ":" + "chrono/" + "MetalFunnel"); - this.textureBottom = iconRegister.registerIcon(CORE.MODID + ":" + "chrono/" + "MetalPanel"); - } -} \ No newline at end of file + @SideOnly(Side.CLIENT) + private IIcon textureTop; + + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + + public MiningExplosives() { + this.setBlockName("blockMiningExplosives"); + GameRegistry.registerBlock(this, "blockMiningExplosives"); + LanguageRegistry.addName(this, "Earth Blasting Explosives"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) { + return p_149691_1_ == 0 ? this.textureBottom : (p_149691_1_ == 1 ? this.textureTop : this.blockIcon); + } + + /** + * Called whenever the block is added into the world. Args: world, x, y, z + */ + @Override + public void onBlockAdded(final World world, final int x, final int y, final int z) { + super.onBlockAdded(world, x, y, z); + + if (world.isBlockIndirectlyGettingPowered(x, y, z)) { + this.onBlockDestroyedByPlayer(world, x, y, z, 1); + world.setBlockToAir(x, y, z); + } + } + + /** + * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are + * their own) Args: x, y, z, neighbor Block + */ + @Override + public void onNeighborBlockChange( + final World world, final int x, final int y, final int z, final Block neighbourblock) { + if (world.isBlockIndirectlyGettingPowered(x, y, z)) { + this.onBlockDestroyedByPlayer(world, x, y, z, 1); + world.setBlockToAir(x, y, z); + } + } + + /** + * Returns the quantity of items to drop on block destruction. + */ + @Override + public int quantityDropped(final Random random) { + return 1; + } + + /** + * Called upon the block being destroyed by an explosion + */ + @Override + public void onBlockDestroyedByExplosion( + final World world, final int x, final int y, final int z, final Explosion bang) { + if (!world.isRemote) { + final EntityPrimedMiningExplosive EntityPrimedMiningExplosive = + new EntityPrimedMiningExplosive(world, x + 0.5F, y + 0.5F, z + 0.5F, bang.getExplosivePlacedBy()); + EntityPrimedMiningExplosive.fuse = + world.rand.nextInt(EntityPrimedMiningExplosive.fuse / 4) + (EntityPrimedMiningExplosive.fuse / 8); + world.spawnEntityInWorld(EntityPrimedMiningExplosive); + } + } + + /** + * Called right before the block is destroyed by a player. Args: world, x, y, z, metaData + */ + @Override + public void onBlockDestroyedByPlayer(final World world, final int x, final int y, final int z, final int meta) { + this.func_150114_a(world, x, y, z, meta, (EntityLivingBase) null); + } + + // TODO Spawns Primed TNT? + @Override + public void func_150114_a( + final World world, + final int p_150114_2_, + final int p_150114_3_, + final int p_150114_4_, + final int p_150114_5_, + final EntityLivingBase entityLiving) { + if (!world.isRemote) { + if ((p_150114_5_ & 1) == 1) { + final EntityPrimedMiningExplosive EntityPrimedMiningExplosive = new EntityPrimedMiningExplosive( + world, p_150114_2_ + 0.5F, p_150114_3_ + 0.5F, p_150114_4_ + 0.5F, entityLiving); + world.spawnEntityInWorld(EntityPrimedMiningExplosive); + world.playSoundAtEntity(EntityPrimedMiningExplosive, "game.tnt.primed", 1.0F, 1.0F); + } + } + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated( + final World world, + final int x, + final int y, + final int z, + final EntityPlayer clickingPlayer, + final int p_149727_6_, + final float p_149727_7_, + final float p_149727_8_, + final float p_149727_9_) { + if ((clickingPlayer.getCurrentEquippedItem() != null) + && (clickingPlayer.getCurrentEquippedItem().getItem() == Items.flint_and_steel)) { + this.func_150114_a(world, x, y, z, 1, clickingPlayer); + world.setBlockToAir(x, y, z); + clickingPlayer.getCurrentEquippedItem().damageItem(1, clickingPlayer); + return true; + } else { + return super.onBlockActivated( + world, x, y, z, clickingPlayer, p_149727_6_, p_149727_7_, p_149727_8_, p_149727_9_); + } + } + + /** + * Triggered whenever an entity collides with this block (enters into the block). Args: world, x, y, z, entity + */ + @Override + public void onEntityCollidedWithBlock( + final World world, final int x, final int y, final int z, final Entity entityTriggering) { + if ((entityTriggering instanceof EntityArrow) && !world.isRemote) { + final EntityArrow entityarrow = (EntityArrow) entityTriggering; + + if (entityarrow.isBurning()) { + this.func_150114_a( + world, + x, + y, + z, + 1, + entityarrow.shootingEntity instanceof EntityLivingBase + ? (EntityLivingBase) entityarrow.shootingEntity + : null); + world.setBlockToAir(x, y, z); + } + } + } + + /** + * Return whether this block can drop from an explosion. + */ + @Override + public boolean canDropFromExplosion(final Explosion bang) { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iconRegister) { + // + /*this.blockIcon = iconRegister.registerIcon(this.getTextureName() + "_side"); + this.textureTop = iconRegister.registerIcon(this.getTextureName() + "_top"); + this.textureBottom = iconRegister.registerIcon(this.getTextureName() + "_bottom");*/ + this.blockIcon = iconRegister.registerIcon(CORE.MODID + ":" + "chrono/" + "MetalSheet2"); + this.textureTop = iconRegister.registerIcon(CORE.MODID + ":" + "chrono/" + "MetalFunnel"); + this.textureBottom = iconRegister.registerIcon(CORE.MODID + ":" + "chrono/" + "MetalPanel"); + } +} diff --git a/src/main/java/gtPlusPlus/core/block/general/PlayerDoors.java b/src/main/java/gtPlusPlus/core/block/general/PlayerDoors.java index a4c0c1a0a5..01e63676cc 100644 --- a/src/main/java/gtPlusPlus/core/block/general/PlayerDoors.java +++ b/src/main/java/gtPlusPlus/core/block/general/PlayerDoors.java @@ -1,16 +1,14 @@ package gtPlusPlus.core.block.general; -import java.util.HashMap; -import java.util.Random; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.item.base.itemblock.ItemBlockDoor; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.tileentities.general.TileEntityPlayerDoorBase; import gtPlusPlus.core.util.Utils; +import java.util.HashMap; +import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.BlockDoor; import net.minecraft.block.ITileEntityProvider; @@ -29,439 +27,458 @@ import net.minecraft.world.World; public class PlayerDoors extends BlockDoor implements ITileEntityProvider { - @SideOnly(Side.CLIENT) - private IIcon[] aTextureUpper; - @SideOnly(Side.CLIENT) - private IIcon[] aTextureLower; - - private final static HashMap mDoorMap = new HashMap(); - - public PlayerDoors(Material aMaterial, String aTextureName, boolean vanillaType) { - this(aMaterial, aTextureName, vanillaType, 0f, null, null); - } - - public PlayerDoors(Material aMaterial, String aTextureName, boolean vanillaType, float aHardness, - SoundType aStepSound, String aBlockExtensionName) { - super(aMaterial); - this.disableStats(); - this.isBlockContainer = true; - if (mDoorMap.get(aMaterial) == null) { - mDoorMap.put(aMaterial, this); - } - float f = 0.5F; - float f1 = 1.0F; - this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f); - - this.setBlockName("playerDoor_" + aTextureName); - if (aMaterial == Material.wood) { - setHardness(3.0F); - setStepSound(soundTypeWood); - setBlockName("playerDoor" + "Wood"); - this.setHarvestLevel("axe", 1); - } else if (aMaterial == Material.iron) { - setHardness(5.0F); - setStepSound(Block.soundTypeMetal); - setBlockName("playerDoor" + "Iron"); - this.setHarvestLevel("pickaxe", 1); - - } else if (aMaterial == Material.glass) { - setHardness(0.1F); - setStepSound(Block.soundTypeGlass); - setBlockName("playerDoor" + "Glass"); - this.setHarvestLevel("pickaxe", 1); - - } else if (aMaterial == Material.ice) { - setHardness(0.5F); - setStepSound(Block.soundTypeSnow); - setBlockName("playerDoor" + "Ice"); - this.setHarvestLevel("pickaxe", 1); - } else { - setHardness(aHardness); - setStepSound(aStepSound); - setBlockName("playerDoor" + aBlockExtensionName); - this.setHarvestLevel("axe", 1); - - } - this.setBlockTextureName(vanillaType ? aTextureName : CORE.MODID + ":" + aTextureName); - GameRegistry.registerBlock(this, ItemBlockDoor.class, Utils.sanitizeString(this.getUnlocalizedName())); - } - - /** - * Gets the block's texture. Args: side, meta - */ - @SideOnly(Side.CLIENT) - public IIcon getIcon(int p_149691_1_, int p_149691_2_) { - return this.aTextureLower[0]; - } - - @SideOnly(Side.CLIENT) - public IIcon getIcon(IBlockAccess aAccess, int p_149673_2_, int p_149673_3_, int p_149673_4_, int p_149673_5_) { - if (p_149673_5_ != 1 && p_149673_5_ != 0) { - int i1 = this.getState(aAccess, p_149673_2_, p_149673_3_, p_149673_4_); - int j1 = i1 & 3; - boolean flag = (i1 & 4) != 0; - boolean flag1 = false; - boolean flag2 = (i1 & 8) != 0; - - if (flag) { - if (j1 == 0 && p_149673_5_ == 2) { - flag1 = !flag1; - } else if (j1 == 1 && p_149673_5_ == 5) { - flag1 = !flag1; - } else if (j1 == 2 && p_149673_5_ == 3) { - flag1 = !flag1; - } else if (j1 == 3 && p_149673_5_ == 4) { - flag1 = !flag1; - } - } else { - if (j1 == 0 && p_149673_5_ == 5) { - flag1 = !flag1; - } else if (j1 == 1 && p_149673_5_ == 3) { - flag1 = !flag1; - } else if (j1 == 2 && p_149673_5_ == 4) { - flag1 = !flag1; - } else if (j1 == 3 && p_149673_5_ == 2) { - flag1 = !flag1; - } - - if ((i1 & 16) != 0) { - flag1 = !flag1; - } - } - - return flag2 ? this.aTextureUpper[flag1 ? 1 : 0] : this.aTextureLower[flag1 ? 1 : 0]; - } else { - return this.aTextureLower[0]; - } - } - - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister p_149651_1_) { - this.aTextureUpper = new IIcon[2]; - this.aTextureLower = new IIcon[2]; - this.aTextureUpper[0] = p_149651_1_.registerIcon(this.getTextureName() + "_upper"); - this.aTextureLower[0] = p_149651_1_.registerIcon(this.getTextureName() + "_lower"); - this.aTextureUpper[1] = new IconFlipped(this.aTextureUpper[0], true, false); - this.aTextureLower[1] = new IconFlipped(this.aTextureLower[0], true, false); - } - - public boolean getBlocksMovement(IBlockAccess aAccess, int aX, int aY, int aZ) { - int l = this.getState(aAccess, aX, aY, aZ); - return (l & 4) != 0; - } - - /** - * If this block doesn't render as an ordinary block it will return False - * (examples: signs, buttons, stairs, etc) - */ - public boolean renderAsNormalBlock() { - return false; - } - - /** - * The type of render function that is called for this block - */ - public int getRenderType() { - return 7; - } - - /** - * Returns the bounding box of the wired rectangular prism to render. - */ - @SideOnly(Side.CLIENT) - public AxisAlignedBB getSelectedBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { - this.setBlockBoundsBasedOnState(aWorld, aX, aY, aZ); - return super.getSelectedBoundingBoxFromPool(aWorld, aX, aY, aZ); - } - - /** - * Returns a bounding box from the pool of bounding boxes (this means this box - * can change after the pool has been cleared to be reused) - */ - public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { - this.setBlockBoundsBasedOnState(aWorld, aX, aY, aZ); - return super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); - } - - /** - * Updates the blocks bounds based on its current state. Args: world, x, y, z - */ - public void setBlockBoundsBasedOnState(IBlockAccess aAccess, int aX, int aY, int aZ) { - this.setBounds(this.getState(aAccess, aX, aY, aZ)); - } - - public int func_150013_e(IBlockAccess p_150013_1_, int p_150013_2_, int p_150013_3_, int p_150013_4_) { - return this.getState(p_150013_1_, p_150013_2_, p_150013_3_, p_150013_4_) & 3; - } - - public boolean func_150015_f(IBlockAccess p_150015_1_, int p_150015_2_, int p_150015_3_, int p_150015_4_) { - return (this.getState(p_150015_1_, p_150015_2_, p_150015_3_, p_150015_4_) & 4) != 0; - } - - private void setBounds(int aState) { - float f = 0.1875F; - this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F); - int j = aState & 3; - boolean flag = (aState & 4) != 0; - boolean flag1 = (aState & 16) != 0; - - if (j == 0) { - if (flag) { - if (!flag1) { - this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); - } else { - this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); - } - } else { - this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F); - } - } else if (j == 1) { - if (flag) { - if (!flag1) { - this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - } else { - this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F); - } - } else { - this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); - } - } else if (j == 2) { - if (flag) { - if (!flag1) { - this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); - } else { - this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); - } - } else { - this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - } - } else if (j == 3) { - if (flag) { - if (!flag1) { - this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F); - } else { - this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - } - } else { - this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); - } - } - } - - /** - * Called upon block activation (right click on the block.) - */ - public boolean onBlockActivated(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer, int p_149727_6_, - float p_149727_7_, float p_149727_8_, float p_149727_9_) { - if (this.blockMaterial == Material.iron) { - return false; // Allow items to interact with the door - } else { - int i1 = this.getState(aWorld, aX, aY, aZ); - int j1 = i1 & 7; - j1 ^= 4; - - if ((i1 & 8) == 0) { - aWorld.setBlockMetadataWithNotify(aX, aY, aZ, j1, 2); - aWorld.markBlockRangeForRenderUpdate(aX, aY, aZ, aX, aY, aZ); - } else { - aWorld.setBlockMetadataWithNotify(aX, aY - 1, aZ, j1, 2); - aWorld.markBlockRangeForRenderUpdate(aX, aY - 1, aZ, aX, aY, aZ); - } - - aWorld.playAuxSFXAtEntity(aPlayer, 1003, aX, aY, aZ, 0); - return true; - } - } - - public void func_150014_a(World aWorld, int aX, int aY, int aZ, boolean aFlag) { - int l = this.getState(aWorld, aX, aY, aZ); - boolean flag1 = (l & 4) != 0; - - if (flag1 != aFlag) { - int i1 = l & 7; - i1 ^= 4; - - if ((l & 8) == 0) { - aWorld.setBlockMetadataWithNotify(aX, aY, aZ, i1, 2); - aWorld.markBlockRangeForRenderUpdate(aX, aY, aZ, aX, aY, aZ); - } else { - aWorld.setBlockMetadataWithNotify(aX, aY - 1, aZ, i1, 2); - aWorld.markBlockRangeForRenderUpdate(aX, aY - 1, aZ, aX, aY, aZ); - } - - aWorld.playAuxSFXAtEntity((EntityPlayer) null, 1003, aX, aY, aZ, 0); - } - } - - /** - * Lets the block know when one of its neighbor changes. Doesn't know which - * neighbor changed (coordinates passed are their own) Args: x, y, z, neighbor - * Block - */ - public void onNeighborBlockChange(World aWorld, int aX, int aY, int aZ, Block aNeighbour) { - int l = aWorld.getBlockMetadata(aX, aY, aZ); - - if ((l & 8) == 0) { - boolean flag = false; - - if (aWorld.getBlock(aX, aY + 1, aZ) != this) { - aWorld.setBlockToAir(aX, aY, aZ); - flag = true; - } - - if (!World.doesBlockHaveSolidTopSurface(aWorld, aX, aY - 1, aZ)) { - aWorld.setBlockToAir(aX, aY, aZ); - flag = true; - - if (aWorld.getBlock(aX, aY + 1, aZ) == this) { - aWorld.setBlockToAir(aX, aY + 1, aZ); - } - } - - if (flag) { - if (!aWorld.isRemote) { - this.dropBlockAsItem(aWorld, aX, aY, aZ, l, 0); - } - } else { - boolean flag1 = aWorld.isBlockIndirectlyGettingPowered(aX, aY, aZ) - || aWorld.isBlockIndirectlyGettingPowered(aX, aY + 1, aZ); - - if ((flag1 || aNeighbour.canProvidePower()) && aNeighbour != this) { - this.func_150014_a(aWorld, aX, aY, aZ, flag1); - } - } - } else { - if (aWorld.getBlock(aX, aY - 1, aZ) != this) { - aWorld.setBlockToAir(aX, aY, aZ); - } - - if (aNeighbour != this) { - this.onNeighborBlockChange(aWorld, aX, aY - 1, aZ, aNeighbour); - } - } - } - - public Item getItemDropped(int p_149650_1_, Random aRand, int p_149650_3_) { - if ((p_149650_1_ & 8) != 0) { - return null; - } else { - Block b = mDoorMap.get(this.blockMaterial); - if (b != null) { - return Item.getItemFromBlock(b); - } - } - return null; - } - - /** - * Ray traces through the blocks collision from start vector to end vector - * returning a ray trace hit. Args: world, x, y, z, startVec, endVec - */ - public MovingObjectPosition collisionRayTrace(World p_149731_1_, int p_149731_2_, int p_149731_3_, int p_149731_4_, - Vec3 p_149731_5_, Vec3 p_149731_6_) { - this.setBlockBoundsBasedOnState(p_149731_1_, p_149731_2_, p_149731_3_, p_149731_4_); - return super.collisionRayTrace(p_149731_1_, p_149731_2_, p_149731_3_, p_149731_4_, p_149731_5_, p_149731_6_); - } - - /** - * Checks to see if its valid to put this block at the specified coordinates. - * Args: world, x, y, z - */ - public boolean canPlaceBlockAt(World aWorld, int aX, int aY, int aZ) { - boolean aHeight = (aY < aWorld.getHeight() - 1); - boolean aSolidTopSurface = World.doesBlockHaveSolidTopSurface(aWorld, aX, aY - 1, aZ); - - boolean aCanPlace = aWorld.getBlock(aX, aY, aZ).isReplaceable(aWorld, aX, aY, aZ); - boolean aCanPlace2 = aWorld.getBlock(aX, aY, aZ).isReplaceable(aWorld, aX, aY + 1, aZ); - - // Logger.INFO(""+aY+"/"+aWorld.getHeight()+" | Trying to place door. Good - // height? "+aHeight+" | Solid top surface? "+aSolidTopSurface+" | Can Place? - // "+aCanPlace+"|"+aCanPlace2); - - return aHeight && aSolidTopSurface && aCanPlace && aCanPlace2; - } - - /** - * Returns the mobility information of the block, 0 = free, 1 = can't push but - * can move over, 2 = total immobility and stop pistons - */ - public int getMobilityFlag() { - return 1; - } - - public int getState(IBlockAccess aAccess, int aX, int aY, int aZ) { - int l = aAccess.getBlockMetadata(aX, aY, aZ); - boolean flag = (l & 8) != 0; - int i1; - int j1; - - if (flag) { - i1 = aAccess.getBlockMetadata(aX, aY - 1, aZ); - j1 = l; - } else { - i1 = l; - j1 = aAccess.getBlockMetadata(aX, aY + 1, aZ); - } - - boolean flag1 = (j1 & 1) != 0; - return i1 & 7 | (flag ? 8 : 0) | (flag1 ? 16 : 0); - } - - /** - * Gets an item for the block being called on. Args: world, x, y, z - */ - @SideOnly(Side.CLIENT) - public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) { - Block b = mDoorMap.get(this.blockMaterial); - if (b != null) { - return Item.getItemFromBlock(b); - } - // return this.blockMaterial == Material.iron ? Items.iron_door : - // Items.wooden_door; - return null; - } - - /** - * Called when the block is attempted to be harvested - */ - public void onBlockHarvested(World p_149681_1_, int p_149681_2_, int p_149681_3_, int p_149681_4_, int p_149681_5_, - EntityPlayer p_149681_6_) { - if (p_149681_6_.capabilities.isCreativeMode && (p_149681_5_ & 8) != 0 - && p_149681_1_.getBlock(p_149681_2_, p_149681_3_ - 1, p_149681_4_) == this) { - p_149681_1_.setBlockToAir(p_149681_2_, p_149681_3_ - 1, p_149681_4_); - } - } - - /** - * Called whenever the block is added into the world. Args: world, x, y, z - */ - @Override - public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) { - super.onBlockAdded(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); - } - - @Override - public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, - int p_149749_6_) { - super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); - p_149749_1_.removeTileEntity(p_149749_2_, p_149749_3_, p_149749_4_); - } - - @Override - public boolean onBlockEventReceived(World p_149696_1_, int p_149696_2_, int p_149696_3_, int p_149696_4_, - int p_149696_5_, int p_149696_6_) { - super.onBlockEventReceived(p_149696_1_, p_149696_2_, p_149696_3_, p_149696_4_, p_149696_5_, p_149696_6_); - TileEntity tileentity = p_149696_1_.getTileEntity(p_149696_2_, p_149696_3_, p_149696_4_); - return tileentity != null ? tileentity.receiveClientEvent(p_149696_5_, p_149696_6_) : false; - } - - @Override - public TileEntity createNewTileEntity(World world, int metadata) { - return new TileEntityPlayerDoorBase(this, metadata); - } - - @Override - public TileEntity createTileEntity(World world, int metadata) { - return new TileEntityPlayerDoorBase(this, metadata); - } + @SideOnly(Side.CLIENT) + private IIcon[] aTextureUpper; + + @SideOnly(Side.CLIENT) + private IIcon[] aTextureLower; + + private static final HashMap mDoorMap = new HashMap(); + + public PlayerDoors(Material aMaterial, String aTextureName, boolean vanillaType) { + this(aMaterial, aTextureName, vanillaType, 0f, null, null); + } + + public PlayerDoors( + Material aMaterial, + String aTextureName, + boolean vanillaType, + float aHardness, + SoundType aStepSound, + String aBlockExtensionName) { + super(aMaterial); + this.disableStats(); + this.isBlockContainer = true; + if (mDoorMap.get(aMaterial) == null) { + mDoorMap.put(aMaterial, this); + } + float f = 0.5F; + float f1 = 1.0F; + this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f); + + this.setBlockName("playerDoor_" + aTextureName); + if (aMaterial == Material.wood) { + setHardness(3.0F); + setStepSound(soundTypeWood); + setBlockName("playerDoor" + "Wood"); + this.setHarvestLevel("axe", 1); + } else if (aMaterial == Material.iron) { + setHardness(5.0F); + setStepSound(Block.soundTypeMetal); + setBlockName("playerDoor" + "Iron"); + this.setHarvestLevel("pickaxe", 1); + + } else if (aMaterial == Material.glass) { + setHardness(0.1F); + setStepSound(Block.soundTypeGlass); + setBlockName("playerDoor" + "Glass"); + this.setHarvestLevel("pickaxe", 1); + + } else if (aMaterial == Material.ice) { + setHardness(0.5F); + setStepSound(Block.soundTypeSnow); + setBlockName("playerDoor" + "Ice"); + this.setHarvestLevel("pickaxe", 1); + } else { + setHardness(aHardness); + setStepSound(aStepSound); + setBlockName("playerDoor" + aBlockExtensionName); + this.setHarvestLevel("axe", 1); + } + this.setBlockTextureName(vanillaType ? aTextureName : CORE.MODID + ":" + aTextureName); + GameRegistry.registerBlock(this, ItemBlockDoor.class, Utils.sanitizeString(this.getUnlocalizedName())); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) { + return this.aTextureLower[0]; + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess aAccess, int p_149673_2_, int p_149673_3_, int p_149673_4_, int p_149673_5_) { + if (p_149673_5_ != 1 && p_149673_5_ != 0) { + int i1 = this.getState(aAccess, p_149673_2_, p_149673_3_, p_149673_4_); + int j1 = i1 & 3; + boolean flag = (i1 & 4) != 0; + boolean flag1 = false; + boolean flag2 = (i1 & 8) != 0; + + if (flag) { + if (j1 == 0 && p_149673_5_ == 2) { + flag1 = !flag1; + } else if (j1 == 1 && p_149673_5_ == 5) { + flag1 = !flag1; + } else if (j1 == 2 && p_149673_5_ == 3) { + flag1 = !flag1; + } else if (j1 == 3 && p_149673_5_ == 4) { + flag1 = !flag1; + } + } else { + if (j1 == 0 && p_149673_5_ == 5) { + flag1 = !flag1; + } else if (j1 == 1 && p_149673_5_ == 3) { + flag1 = !flag1; + } else if (j1 == 2 && p_149673_5_ == 4) { + flag1 = !flag1; + } else if (j1 == 3 && p_149673_5_ == 2) { + flag1 = !flag1; + } + + if ((i1 & 16) != 0) { + flag1 = !flag1; + } + } + + return flag2 ? this.aTextureUpper[flag1 ? 1 : 0] : this.aTextureLower[flag1 ? 1 : 0]; + } else { + return this.aTextureLower[0]; + } + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) { + this.aTextureUpper = new IIcon[2]; + this.aTextureLower = new IIcon[2]; + this.aTextureUpper[0] = p_149651_1_.registerIcon(this.getTextureName() + "_upper"); + this.aTextureLower[0] = p_149651_1_.registerIcon(this.getTextureName() + "_lower"); + this.aTextureUpper[1] = new IconFlipped(this.aTextureUpper[0], true, false); + this.aTextureLower[1] = new IconFlipped(this.aTextureLower[0], true, false); + } + + public boolean getBlocksMovement(IBlockAccess aAccess, int aX, int aY, int aZ) { + int l = this.getState(aAccess, aX, aY, aZ); + return (l & 4) != 0; + } + + /** + * If this block doesn't render as an ordinary block it will return False + * (examples: signs, buttons, stairs, etc) + */ + public boolean renderAsNormalBlock() { + return false; + } + + /** + * The type of render function that is called for this block + */ + public int getRenderType() { + return 7; + } + + /** + * Returns the bounding box of the wired rectangular prism to render. + */ + @SideOnly(Side.CLIENT) + public AxisAlignedBB getSelectedBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { + this.setBlockBoundsBasedOnState(aWorld, aX, aY, aZ); + return super.getSelectedBoundingBoxFromPool(aWorld, aX, aY, aZ); + } + + /** + * Returns a bounding box from the pool of bounding boxes (this means this box + * can change after the pool has been cleared to be reused) + */ + public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { + this.setBlockBoundsBasedOnState(aWorld, aX, aY, aZ); + return super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); + } + + /** + * Updates the blocks bounds based on its current state. Args: world, x, y, z + */ + public void setBlockBoundsBasedOnState(IBlockAccess aAccess, int aX, int aY, int aZ) { + this.setBounds(this.getState(aAccess, aX, aY, aZ)); + } + + public int func_150013_e(IBlockAccess p_150013_1_, int p_150013_2_, int p_150013_3_, int p_150013_4_) { + return this.getState(p_150013_1_, p_150013_2_, p_150013_3_, p_150013_4_) & 3; + } + + public boolean func_150015_f(IBlockAccess p_150015_1_, int p_150015_2_, int p_150015_3_, int p_150015_4_) { + return (this.getState(p_150015_1_, p_150015_2_, p_150015_3_, p_150015_4_) & 4) != 0; + } + + private void setBounds(int aState) { + float f = 0.1875F; + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F); + int j = aState & 3; + boolean flag = (aState & 4) != 0; + boolean flag1 = (aState & 16) != 0; + + if (j == 0) { + if (flag) { + if (!flag1) { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); + } else { + this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); + } + } else { + this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F); + } + } else if (j == 1) { + if (flag) { + if (!flag1) { + this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } else { + this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F); + } + } else { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); + } + } else if (j == 2) { + if (flag) { + if (!flag1) { + this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); + } else { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); + } + } else { + this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + } else if (j == 3) { + if (flag) { + if (!flag1) { + this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F); + } else { + this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + } else { + this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); + } + } + } + + /** + * Called upon block activation (right click on the block.) + */ + public boolean onBlockActivated( + World aWorld, + int aX, + int aY, + int aZ, + EntityPlayer aPlayer, + int p_149727_6_, + float p_149727_7_, + float p_149727_8_, + float p_149727_9_) { + if (this.blockMaterial == Material.iron) { + return false; // Allow items to interact with the door + } else { + int i1 = this.getState(aWorld, aX, aY, aZ); + int j1 = i1 & 7; + j1 ^= 4; + + if ((i1 & 8) == 0) { + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, j1, 2); + aWorld.markBlockRangeForRenderUpdate(aX, aY, aZ, aX, aY, aZ); + } else { + aWorld.setBlockMetadataWithNotify(aX, aY - 1, aZ, j1, 2); + aWorld.markBlockRangeForRenderUpdate(aX, aY - 1, aZ, aX, aY, aZ); + } + + aWorld.playAuxSFXAtEntity(aPlayer, 1003, aX, aY, aZ, 0); + return true; + } + } + + public void func_150014_a(World aWorld, int aX, int aY, int aZ, boolean aFlag) { + int l = this.getState(aWorld, aX, aY, aZ); + boolean flag1 = (l & 4) != 0; + + if (flag1 != aFlag) { + int i1 = l & 7; + i1 ^= 4; + + if ((l & 8) == 0) { + aWorld.setBlockMetadataWithNotify(aX, aY, aZ, i1, 2); + aWorld.markBlockRangeForRenderUpdate(aX, aY, aZ, aX, aY, aZ); + } else { + aWorld.setBlockMetadataWithNotify(aX, aY - 1, aZ, i1, 2); + aWorld.markBlockRangeForRenderUpdate(aX, aY - 1, aZ, aX, aY, aZ); + } + + aWorld.playAuxSFXAtEntity((EntityPlayer) null, 1003, aX, aY, aZ, 0); + } + } + + /** + * Lets the block know when one of its neighbor changes. Doesn't know which + * neighbor changed (coordinates passed are their own) Args: x, y, z, neighbor + * Block + */ + public void onNeighborBlockChange(World aWorld, int aX, int aY, int aZ, Block aNeighbour) { + int l = aWorld.getBlockMetadata(aX, aY, aZ); + + if ((l & 8) == 0) { + boolean flag = false; + + if (aWorld.getBlock(aX, aY + 1, aZ) != this) { + aWorld.setBlockToAir(aX, aY, aZ); + flag = true; + } + + if (!World.doesBlockHaveSolidTopSurface(aWorld, aX, aY - 1, aZ)) { + aWorld.setBlockToAir(aX, aY, aZ); + flag = true; + + if (aWorld.getBlock(aX, aY + 1, aZ) == this) { + aWorld.setBlockToAir(aX, aY + 1, aZ); + } + } + + if (flag) { + if (!aWorld.isRemote) { + this.dropBlockAsItem(aWorld, aX, aY, aZ, l, 0); + } + } else { + boolean flag1 = aWorld.isBlockIndirectlyGettingPowered(aX, aY, aZ) + || aWorld.isBlockIndirectlyGettingPowered(aX, aY + 1, aZ); + + if ((flag1 || aNeighbour.canProvidePower()) && aNeighbour != this) { + this.func_150014_a(aWorld, aX, aY, aZ, flag1); + } + } + } else { + if (aWorld.getBlock(aX, aY - 1, aZ) != this) { + aWorld.setBlockToAir(aX, aY, aZ); + } + + if (aNeighbour != this) { + this.onNeighborBlockChange(aWorld, aX, aY - 1, aZ, aNeighbour); + } + } + } + + public Item getItemDropped(int p_149650_1_, Random aRand, int p_149650_3_) { + if ((p_149650_1_ & 8) != 0) { + return null; + } else { + Block b = mDoorMap.get(this.blockMaterial); + if (b != null) { + return Item.getItemFromBlock(b); + } + } + return null; + } + + /** + * Ray traces through the blocks collision from start vector to end vector + * returning a ray trace hit. Args: world, x, y, z, startVec, endVec + */ + public MovingObjectPosition collisionRayTrace( + World p_149731_1_, int p_149731_2_, int p_149731_3_, int p_149731_4_, Vec3 p_149731_5_, Vec3 p_149731_6_) { + this.setBlockBoundsBasedOnState(p_149731_1_, p_149731_2_, p_149731_3_, p_149731_4_); + return super.collisionRayTrace(p_149731_1_, p_149731_2_, p_149731_3_, p_149731_4_, p_149731_5_, p_149731_6_); + } + + /** + * Checks to see if its valid to put this block at the specified coordinates. + * Args: world, x, y, z + */ + public boolean canPlaceBlockAt(World aWorld, int aX, int aY, int aZ) { + boolean aHeight = (aY < aWorld.getHeight() - 1); + boolean aSolidTopSurface = World.doesBlockHaveSolidTopSurface(aWorld, aX, aY - 1, aZ); + + boolean aCanPlace = aWorld.getBlock(aX, aY, aZ).isReplaceable(aWorld, aX, aY, aZ); + boolean aCanPlace2 = aWorld.getBlock(aX, aY, aZ).isReplaceable(aWorld, aX, aY + 1, aZ); + + // Logger.INFO(""+aY+"/"+aWorld.getHeight()+" | Trying to place door. Good + // height? "+aHeight+" | Solid top surface? "+aSolidTopSurface+" | Can Place? + // "+aCanPlace+"|"+aCanPlace2); + + return aHeight && aSolidTopSurface && aCanPlace && aCanPlace2; + } + + /** + * Returns the mobility information of the block, 0 = free, 1 = can't push but + * can move over, 2 = total immobility and stop pistons + */ + public int getMobilityFlag() { + return 1; + } + + public int getState(IBlockAccess aAccess, int aX, int aY, int aZ) { + int l = aAccess.getBlockMetadata(aX, aY, aZ); + boolean flag = (l & 8) != 0; + int i1; + int j1; + + if (flag) { + i1 = aAccess.getBlockMetadata(aX, aY - 1, aZ); + j1 = l; + } else { + i1 = l; + j1 = aAccess.getBlockMetadata(aX, aY + 1, aZ); + } + + boolean flag1 = (j1 & 1) != 0; + return i1 & 7 | (flag ? 8 : 0) | (flag1 ? 16 : 0); + } + + /** + * Gets an item for the block being called on. Args: world, x, y, z + */ + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) { + Block b = mDoorMap.get(this.blockMaterial); + if (b != null) { + return Item.getItemFromBlock(b); + } + // return this.blockMaterial == Material.iron ? Items.iron_door : + // Items.wooden_door; + return null; + } + + /** + * Called when the block is attempted to be harvested + */ + public void onBlockHarvested( + World p_149681_1_, + int p_149681_2_, + int p_149681_3_, + int p_149681_4_, + int p_149681_5_, + EntityPlayer p_149681_6_) { + if (p_149681_6_.capabilities.isCreativeMode + && (p_149681_5_ & 8) != 0 + && p_149681_1_.getBlock(p_149681_2_, p_149681_3_ - 1, p_149681_4_) == this) { + p_149681_1_.setBlockToAir(p_149681_2_, p_149681_3_ - 1, p_149681_4_); + } + } + + /** + * Called whenever the block is added into the world. Args: world, x, y, z + */ + @Override + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) { + super.onBlockAdded(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); + } + + @Override + public void breakBlock( + World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) { + super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + p_149749_1_.removeTileEntity(p_149749_2_, p_149749_3_, p_149749_4_); + } + + @Override + public boolean onBlockEventReceived( + World p_149696_1_, int p_149696_2_, int p_149696_3_, int p_149696_4_, int p_149696_5_, int p_149696_6_) { + super.onBlockEventReceived(p_149696_1_, p_149696_2_, p_149696_3_, p_149696_4_, p_149696_5_, p_149696_6_); + TileEntity tileentity = p_149696_1_.getTileEntity(p_149696_2_, p_149696_3_, p_149696_4_); + return tileentity != null ? tileentity.receiveClientEvent(p_149696_5_, p_149696_6_) : false; + } + + @Override + public TileEntity createNewTileEntity(World world, int metadata) { + return new TileEntityPlayerDoorBase(this, metadata); + } + + @Override + public TileEntity createTileEntity(World world, int metadata) { + return new TileEntityPlayerDoorBase(this, metadata); + } } diff --git a/src/main/java/gtPlusPlus/core/block/general/antigrief/BlockWitherProof.java b/src/main/java/gtPlusPlus/core/block/general/antigrief/BlockWitherProof.java index 2210e68e8a..4d11a8ac66 100644 --- a/src/main/java/gtPlusPlus/core/block/general/antigrief/BlockWitherProof.java +++ b/src/main/java/gtPlusPlus/core/block/general/antigrief/BlockWitherProof.java @@ -3,7 +3,9 @@ package gtPlusPlus.core.block.general.antigrief; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -18,149 +20,163 @@ import net.minecraft.world.Explosion; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; - -public class BlockWitherProof extends Block{ - - public BlockWitherProof(){ - super(Material.redstoneLight); - this.setBlockName(Utils.sanitizeString("blockBlackGate")); - this.setBlockTextureName(CORE.MODID + ":" + "blockFrameGt"); - this.setCreativeTab(AddToCreativeTab.tabBlock); - this.setHardness(-1F); - this.setResistance(5000.0F); - this.setHarvestLevel("pickaxe", 3); - this.setStepSound(soundTypeMetal); - //LanguageRegistry.addName(this, "Wither Cage"); - GameRegistry.registerBlock(this, Utils.sanitizeString("blockBlackGate")); - } - - public String GetProperName(){ - return "Wither Cage"; - } - - @Override - @SideOnly(Side.CLIENT) - public int getRenderBlockPass(){ - return 1; - } - - @Override - public boolean isOpaqueCube(){ - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister iIcon){ - this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + "blockFrameGt"); - } - - @Override - public void onBlockExploded(final World world, final int x, final int y, final int z, final Explosion explosion){ - //prevent from being destroyed by wither and nukes. - } - - @Override - public void onBlockDestroyedByExplosion(final World p_149723_1_, final int p_149723_2_, - final int p_149723_3_, final int p_149723_4_, final Explosion p_149723_5_) { - - } - - @Override - public boolean canDropFromExplosion(final Explosion p_149659_1_) { - return false; - } - - @Override - public boolean canEntityDestroy(final IBlockAccess world, final int x, final int y, final int z, - final Entity entity) { - if ((entity == null) || !entity.isEntityAlive()){ - return false; - } - if ((entity instanceof EntityWither) || (entity instanceof EntityDragon) || (entity instanceof IBossDisplayData)){ - return false; - } - else { - return super.canEntityDestroy(world, x, y, z, entity); - } - } - - - //Colour Handling - private static final int mWitherColour = Utils.rgbtoHexValue(32, 32, 32); - - @Override - public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4){ - return mWitherColour; - } - - @Override - public int getRenderColor(final int aMeta) { - return mWitherColour; - } - - @Override - public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { - return false; - } - - @Override - public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) { - super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); - } - - @Override - public float getPlayerRelativeBlockHardness(EntityPlayer aPlayer, World p_149737_2_, int p_149737_3_, int p_149737_4_, int p_149737_5_) { - if (aPlayer != null && aPlayer instanceof EntityPlayerMP) { - return 1f; - } - return -1f; - } - - @Override - public float getExplosionResistance(Entity p_149638_1_) { - return Float.MAX_VALUE; - } - - @Override - public void onBlockClicked(World p_149699_1_, int p_149699_2_, int p_149699_3_, int p_149699_4_, EntityPlayer p_149699_5_) { - super.onBlockClicked(p_149699_1_, p_149699_2_, p_149699_3_, p_149699_4_, p_149699_5_); - } - - @Override - public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { - if ((entity == null) || !entity.isEntityAlive()){ - return; - } - if ((entity instanceof EntityWither) || (entity instanceof EntityDragon) || (entity instanceof IBossDisplayData)){ - return; - } - else { - super.onEntityCollidedWithBlock(world, x, y, z, entity); - } - } - - @Override - public void harvestBlock(World p_149636_1_, EntityPlayer p_149636_2_, int p_149636_3_, int p_149636_4_, int p_149636_5_, int p_149636_6_) { - super.harvestBlock( p_149636_1_, p_149636_2_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_); - } - - @Override - public boolean canHarvestBlock(EntityPlayer player, int meta) { - if (player != null && player instanceof EntityPlayerMP) { - return true; - } - return super.canHarvestBlock(player, meta); - } - - @Override - public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ) { - return Float.MAX_VALUE; - } - - - +public class BlockWitherProof extends Block { + + public BlockWitherProof() { + super(Material.redstoneLight); + this.setBlockName(Utils.sanitizeString("blockBlackGate")); + this.setBlockTextureName(CORE.MODID + ":" + "blockFrameGt"); + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setHardness(-1F); + this.setResistance(5000.0F); + this.setHarvestLevel("pickaxe", 3); + this.setStepSound(soundTypeMetal); + // LanguageRegistry.addName(this, "Wither Cage"); + GameRegistry.registerBlock(this, Utils.sanitizeString("blockBlackGate")); + } + + public String GetProperName() { + return "Wither Cage"; + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() { + return 1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iIcon) { + this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + "blockFrameGt"); + } + + @Override + public void onBlockExploded(final World world, final int x, final int y, final int z, final Explosion explosion) { + // prevent from being destroyed by wither and nukes. + } + + @Override + public void onBlockDestroyedByExplosion( + final World p_149723_1_, + final int p_149723_2_, + final int p_149723_3_, + final int p_149723_4_, + final Explosion p_149723_5_) {} + + @Override + public boolean canDropFromExplosion(final Explosion p_149659_1_) { + return false; + } + + @Override + public boolean canEntityDestroy( + final IBlockAccess world, final int x, final int y, final int z, final Entity entity) { + if ((entity == null) || !entity.isEntityAlive()) { + return false; + } + if ((entity instanceof EntityWither) + || (entity instanceof EntityDragon) + || (entity instanceof IBossDisplayData)) { + return false; + } else { + return super.canEntityDestroy(world, x, y, z, entity); + } + } + + // Colour Handling + private static final int mWitherColour = Utils.rgbtoHexValue(32, 32, 32); + + @Override + public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4) { + return mWitherColour; + } + + @Override + public int getRenderColor(final int aMeta) { + return mWitherColour; + } + + @Override + public boolean canCreatureSpawn( + final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + @Override + public void breakBlock( + World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) { + super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + } + + @Override + public float getPlayerRelativeBlockHardness( + EntityPlayer aPlayer, World p_149737_2_, int p_149737_3_, int p_149737_4_, int p_149737_5_) { + if (aPlayer != null && aPlayer instanceof EntityPlayerMP) { + return 1f; + } + return -1f; + } + + @Override + public float getExplosionResistance(Entity p_149638_1_) { + return Float.MAX_VALUE; + } + + @Override + public void onBlockClicked( + World p_149699_1_, int p_149699_2_, int p_149699_3_, int p_149699_4_, EntityPlayer p_149699_5_) { + super.onBlockClicked(p_149699_1_, p_149699_2_, p_149699_3_, p_149699_4_, p_149699_5_); + } + + @Override + public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { + if ((entity == null) || !entity.isEntityAlive()) { + return; + } + if ((entity instanceof EntityWither) + || (entity instanceof EntityDragon) + || (entity instanceof IBossDisplayData)) { + return; + } else { + super.onEntityCollidedWithBlock(world, x, y, z, entity); + } + } + + @Override + public void harvestBlock( + World p_149636_1_, + EntityPlayer p_149636_2_, + int p_149636_3_, + int p_149636_4_, + int p_149636_5_, + int p_149636_6_) { + super.harvestBlock(p_149636_1_, p_149636_2_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_); + } + + @Override + public boolean canHarvestBlock(EntityPlayer player, int meta) { + if (player != null && player instanceof EntityPlayerMP) { + return true; + } + return super.canHarvestBlock(player, meta); + } + + @Override + public float getExplosionResistance( + Entity par1Entity, + World world, + int x, + int y, + int z, + double explosionX, + double explosionY, + double explosionZ) { + return Float.MAX_VALUE; + } } diff --git a/src/main/java/gtPlusPlus/core/block/general/antigrief/TowerDevice.java b/src/main/java/gtPlusPlus/core/block/general/antigrief/TowerDevice.java index 01a2116a0b..b3bf56e3f5 100644 --- a/src/main/java/gtPlusPlus/core/block/general/antigrief/TowerDevice.java +++ b/src/main/java/gtPlusPlus/core/block/general/antigrief/TowerDevice.java @@ -2,12 +2,14 @@ package gtPlusPlus.core.block.general.antigrief; import static gtPlusPlus.core.block.ModBlocks.blockGriefSaver; -import java.util.List; -import java.util.Random; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.general.TileEntityReverter; +import java.util.List; +import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -23,271 +25,248 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.tileentities.general.TileEntityReverter; - public class TowerDevice extends Block { - private static IIcon TEX_ANTIBUILDER; - public static final int META_ANTIBUILDER = 9; - private boolean bUnbreakable; - - public TowerDevice() - { - super(Material.wood); - this.setHardness(10.0F); - this.setResistance(35.0F); - this.setStepSound(Block.soundTypeWood); - this.setCreativeTab(AddToCreativeTab.tabMachines); - } - - public int tickRate() - { - return 15; - } - - public void saveNBTData(final NBTTagCompound aNBT) { - aNBT.setBoolean("bUnbreakable", this.bUnbreakable); - } - - public void loadNBTData(final NBTTagCompound aNBT) { - this.bUnbreakable = aNBT.getBoolean("bUnbreakable"); - } - - @Override - public IIcon getIcon(final int side, final int meta) - { - return TEX_ANTIBUILDER; - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister par1IconRegister) - { - TEX_ANTIBUILDER = par1IconRegister.registerIcon(CORE.MODID + ":" + "blockAntiGrief"); - } - - @Override - public void getSubBlocks(final Item par1, final CreativeTabs par2CreativeTabs, final List par3List) - { - par3List.add(new ItemStack(par1, 1, 9)); - } - - @Override - public boolean onBlockActivated(final World par1World, final int x, final int y, final int z, final EntityPlayer par5EntityPlayer, final int par6, final float par7, final float par8, final float par9) - { - final int meta = par1World.getBlockMetadata(x, y, z); - return false; - } - - @Override - public float getExplosionResistance(final Entity par1Entity, final World world, final int x, final int y, final int z, final double explosionX, final double explosionY, final double explosionZ) - { - final int meta = world.getBlockMetadata(x, y, z); - return super.getExplosionResistance(par1Entity, world, x, y, z, explosionX, explosionY, explosionZ); - } - - @Override - public float getBlockHardness(final World world, final int x, final int y, final int z) - { - final int meta = world.getBlockMetadata(x, y, z); - return super.getBlockHardness(world, x, y, z); - } - - public static boolean areNearbyLockBlocks(final World world, final int x, final int y, final int z) - { - boolean locked = false; - for (int dx = x - 2; dx <= (x + 2); dx++) { - for (int dy = y - 2; dy <= (y + 2); dy++) { - for (int dz = z - 2; dz <= (z + 2); dz++) { - if ((world.getBlock(dx, dy, dz) == blockGriefSaver) && (world.getBlockMetadata(dx, dy, dz) == 4)) { - locked = true; - } - } - } - } - return locked; - } - - public static void unlockBlock(final World par1World, final int x, final int y, final int z) - { - final Block thereBlockID = par1World.getBlock(x, y, z); - final int thereBlockMeta = par1World.getBlockMetadata(x, y, z); - if ((thereBlockID == blockGriefSaver) || (thereBlockMeta == 4)) - { - changeToBlockMeta(par1World, x, y, z, 5); - par1World.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, "random.click", 0.3F, 0.6F); - } - } - - private static void changeToBlockMeta(final World par1World, final int x, final int y, final int z, final int meta) - { - final Block thereBlockID = par1World.getBlock(x, y, z); - if ((thereBlockID == blockGriefSaver)) - { - par1World.setBlock(x, y, z, thereBlockID, meta, 3); - par1World.markBlockRangeForRenderUpdate(x, y, z, x, y, z); - par1World.notifyBlocksOfNeighborChange(x, y, z, thereBlockID); - } - } - - @Override - public void onBlockAdded(final World par1World, final int x, final int y, final int z) - { - final int meta = par1World.getBlockMetadata(x, y, z); - if (!par1World.isRemote) { - - } - } - - @Override - public void onNeighborBlockChange(final World par1World, final int x, final int y, final int z, final Block myBlockID) - { - final int meta = par1World.getBlockMetadata(x, y, z); - if (!par1World.isRemote) - { - - } - } - - @Override - public void updateTick(final World par1World, final int x, final int y, final int z, final Random par5Random) - { - if (!par1World.isRemote) - { - final int meta = par1World.getBlockMetadata(x, y, z); - } - } - - private void letsBuild(final World par1World, final int x, final int y, final int z) - { - - } - - private boolean isInactiveTrapCharged(final World par1World, final int x, final int y, final int z) - { - return false; - } - - private boolean isReactorReady(final World world, final int x, final int y, final int z) - { - if ((world.getBlock(x, y + 1, z) != Blocks.redstone_block) || - (world.getBlock(x, y - 1, z) != Blocks.redstone_block) || - (world.getBlock(x + 1, y, z) != Blocks.redstone_block) || - (world.getBlock(x - 1, y, z) != Blocks.redstone_block) || - (world.getBlock(x, y, z + 1) != Blocks.redstone_block) || - (world.getBlock(x, y, z - 1) != Blocks.redstone_block)) { - return false; - } - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public void randomDisplayTick(final World par1World, final int x, final int y, final int z, final Random par5Random) - { - final int meta = par1World.getBlockMetadata(x, y, z); - if ((meta == 3) || (meta == 1) || (meta == 9)) { - for (int i = 0; i < 1; i++) { - this.sparkle(par1World, x, y, z, par5Random); - } - } - } - - public void sparkle(final World world, final int x, final int y, final int z, final Random rand) - { - final double offset = 0.0625D; - for (int side = 0; side < 6; side++) - { - double rx = x + rand.nextFloat(); - double ry = y + rand.nextFloat(); - double rz = z + rand.nextFloat(); - if ((side == 0) && (!world.getBlock(x, y + 1, z).isOpaqueCube())) { - ry = y + 1 + offset; - } - if ((side == 1) && (!world.getBlock(x, y - 1, z).isOpaqueCube())) { - ry = (y + 0) - offset; - } - if ((side == 2) && (!world.getBlock(x, y, z + 1).isOpaqueCube())) { - rz = z + 1 + offset; - } - if ((side == 3) && (!world.getBlock(x, y, z - 1).isOpaqueCube())) { - rz = (z + 0) - offset; - } - if ((side == 4) && (!world.getBlock(x + 1, y, z).isOpaqueCube())) { - rx = x + 1 + offset; - } - if ((side == 5) && (!world.getBlock(x - 1, y, z).isOpaqueCube())) { - rx = (x + 0) - offset; - } - if ((rx < x) || (rx > (x + 1)) || (ry < 0.0D) || (ry > (y + 1)) || (rz < z) || (rz > (z + 1))) { - world.spawnParticle("reddust", rx, ry, rz, 0.0D, 0.0D, 0.0D); - } - } - } - - public static void checkAndActivateVanishBlock(final World world, final int x, final int y, final int z) - { - final Block thereID = world.getBlock(x, y, z); - final int thereMeta = world.getBlockMetadata(x, y, z); - } - - public static void changeToActiveVanishBlock(final World par1World, final int x, final int y, final int z, final int meta) - { - changeToBlockMeta(par1World, x, y, z, meta); - par1World.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, "random.pop", 0.3F, 0.6F); - - final Block thereBlockID = par1World.getBlock(x, y, z); - par1World.scheduleBlockUpdate(x, y, z, thereBlockID, getTickRateFor(thereBlockID, meta, par1World.rand)); - } - - private static int getTickRateFor(final Block thereBlockID, final int meta, final Random rand) - { - return 15; - } - - @Override - public int getLightValue(final IBlockAccess world, final int x, final int y, final int z) - { - final Block blockID = world.getBlock(x, y, z); - final int meta = world.getBlockMetadata(x, y, z); - if (blockID != this) { - return 0; - } - return 10; - } - - @Override - public boolean hasTileEntity(final int metadata) - { - return (metadata == 0); - } - - @Override - public TileEntity createTileEntity(final World world, final int metadata) - { - if (metadata == 0) { - Logger.INFO("I have been created. [Antigriefer]"+this.getLocalizedName()); - return new TileEntityReverter(); - } - return null; - } - - @Override - public Item getItemDropped(final int meta, final Random par2Random, final int par3) - { - switch (meta) - { - case 0: - return null; - } - return Item.getItemFromBlock(this); - } - - @Override - public int damageDropped(final int meta) - { - return meta; - } + private static IIcon TEX_ANTIBUILDER; + public static final int META_ANTIBUILDER = 9; + private boolean bUnbreakable; + + public TowerDevice() { + super(Material.wood); + this.setHardness(10.0F); + this.setResistance(35.0F); + this.setStepSound(Block.soundTypeWood); + this.setCreativeTab(AddToCreativeTab.tabMachines); + } + + public int tickRate() { + return 15; + } + + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setBoolean("bUnbreakable", this.bUnbreakable); + } + + public void loadNBTData(final NBTTagCompound aNBT) { + this.bUnbreakable = aNBT.getBoolean("bUnbreakable"); + } + + @Override + public IIcon getIcon(final int side, final int meta) { + return TEX_ANTIBUILDER; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister par1IconRegister) { + TEX_ANTIBUILDER = par1IconRegister.registerIcon(CORE.MODID + ":" + "blockAntiGrief"); + } + + @Override + public void getSubBlocks(final Item par1, final CreativeTabs par2CreativeTabs, final List par3List) { + par3List.add(new ItemStack(par1, 1, 9)); + } + + @Override + public boolean onBlockActivated( + final World par1World, + final int x, + final int y, + final int z, + final EntityPlayer par5EntityPlayer, + final int par6, + final float par7, + final float par8, + final float par9) { + final int meta = par1World.getBlockMetadata(x, y, z); + return false; + } + + @Override + public float getExplosionResistance( + final Entity par1Entity, + final World world, + final int x, + final int y, + final int z, + final double explosionX, + final double explosionY, + final double explosionZ) { + final int meta = world.getBlockMetadata(x, y, z); + return super.getExplosionResistance(par1Entity, world, x, y, z, explosionX, explosionY, explosionZ); + } + + @Override + public float getBlockHardness(final World world, final int x, final int y, final int z) { + final int meta = world.getBlockMetadata(x, y, z); + return super.getBlockHardness(world, x, y, z); + } + + public static boolean areNearbyLockBlocks(final World world, final int x, final int y, final int z) { + boolean locked = false; + for (int dx = x - 2; dx <= (x + 2); dx++) { + for (int dy = y - 2; dy <= (y + 2); dy++) { + for (int dz = z - 2; dz <= (z + 2); dz++) { + if ((world.getBlock(dx, dy, dz) == blockGriefSaver) && (world.getBlockMetadata(dx, dy, dz) == 4)) { + locked = true; + } + } + } + } + return locked; + } + + public static void unlockBlock(final World par1World, final int x, final int y, final int z) { + final Block thereBlockID = par1World.getBlock(x, y, z); + final int thereBlockMeta = par1World.getBlockMetadata(x, y, z); + if ((thereBlockID == blockGriefSaver) || (thereBlockMeta == 4)) { + changeToBlockMeta(par1World, x, y, z, 5); + par1World.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, "random.click", 0.3F, 0.6F); + } + } + + private static void changeToBlockMeta( + final World par1World, final int x, final int y, final int z, final int meta) { + final Block thereBlockID = par1World.getBlock(x, y, z); + if ((thereBlockID == blockGriefSaver)) { + par1World.setBlock(x, y, z, thereBlockID, meta, 3); + par1World.markBlockRangeForRenderUpdate(x, y, z, x, y, z); + par1World.notifyBlocksOfNeighborChange(x, y, z, thereBlockID); + } + } + + @Override + public void onBlockAdded(final World par1World, final int x, final int y, final int z) { + final int meta = par1World.getBlockMetadata(x, y, z); + if (!par1World.isRemote) {} + } + + @Override + public void onNeighborBlockChange( + final World par1World, final int x, final int y, final int z, final Block myBlockID) { + final int meta = par1World.getBlockMetadata(x, y, z); + if (!par1World.isRemote) {} + } + + @Override + public void updateTick(final World par1World, final int x, final int y, final int z, final Random par5Random) { + if (!par1World.isRemote) { + final int meta = par1World.getBlockMetadata(x, y, z); + } + } + + private void letsBuild(final World par1World, final int x, final int y, final int z) {} + + private boolean isInactiveTrapCharged(final World par1World, final int x, final int y, final int z) { + return false; + } + + private boolean isReactorReady(final World world, final int x, final int y, final int z) { + if ((world.getBlock(x, y + 1, z) != Blocks.redstone_block) + || (world.getBlock(x, y - 1, z) != Blocks.redstone_block) + || (world.getBlock(x + 1, y, z) != Blocks.redstone_block) + || (world.getBlock(x - 1, y, z) != Blocks.redstone_block) + || (world.getBlock(x, y, z + 1) != Blocks.redstone_block) + || (world.getBlock(x, y, z - 1) != Blocks.redstone_block)) { + return false; + } + return true; + } + + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick( + final World par1World, final int x, final int y, final int z, final Random par5Random) { + final int meta = par1World.getBlockMetadata(x, y, z); + if ((meta == 3) || (meta == 1) || (meta == 9)) { + for (int i = 0; i < 1; i++) { + this.sparkle(par1World, x, y, z, par5Random); + } + } + } + + public void sparkle(final World world, final int x, final int y, final int z, final Random rand) { + final double offset = 0.0625D; + for (int side = 0; side < 6; side++) { + double rx = x + rand.nextFloat(); + double ry = y + rand.nextFloat(); + double rz = z + rand.nextFloat(); + if ((side == 0) && (!world.getBlock(x, y + 1, z).isOpaqueCube())) { + ry = y + 1 + offset; + } + if ((side == 1) && (!world.getBlock(x, y - 1, z).isOpaqueCube())) { + ry = (y + 0) - offset; + } + if ((side == 2) && (!world.getBlock(x, y, z + 1).isOpaqueCube())) { + rz = z + 1 + offset; + } + if ((side == 3) && (!world.getBlock(x, y, z - 1).isOpaqueCube())) { + rz = (z + 0) - offset; + } + if ((side == 4) && (!world.getBlock(x + 1, y, z).isOpaqueCube())) { + rx = x + 1 + offset; + } + if ((side == 5) && (!world.getBlock(x - 1, y, z).isOpaqueCube())) { + rx = (x + 0) - offset; + } + if ((rx < x) || (rx > (x + 1)) || (ry < 0.0D) || (ry > (y + 1)) || (rz < z) || (rz > (z + 1))) { + world.spawnParticle("reddust", rx, ry, rz, 0.0D, 0.0D, 0.0D); + } + } + } + + public static void checkAndActivateVanishBlock(final World world, final int x, final int y, final int z) { + final Block thereID = world.getBlock(x, y, z); + final int thereMeta = world.getBlockMetadata(x, y, z); + } + + public static void changeToActiveVanishBlock( + final World par1World, final int x, final int y, final int z, final int meta) { + changeToBlockMeta(par1World, x, y, z, meta); + par1World.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, "random.pop", 0.3F, 0.6F); + + final Block thereBlockID = par1World.getBlock(x, y, z); + par1World.scheduleBlockUpdate(x, y, z, thereBlockID, getTickRateFor(thereBlockID, meta, par1World.rand)); + } + + private static int getTickRateFor(final Block thereBlockID, final int meta, final Random rand) { + return 15; + } + + @Override + public int getLightValue(final IBlockAccess world, final int x, final int y, final int z) { + final Block blockID = world.getBlock(x, y, z); + final int meta = world.getBlockMetadata(x, y, z); + if (blockID != this) { + return 0; + } + return 10; + } + + @Override + public boolean hasTileEntity(final int metadata) { + return (metadata == 0); + } + + @Override + public TileEntity createTileEntity(final World world, final int metadata) { + if (metadata == 0) { + Logger.INFO("I have been created. [Antigriefer]" + this.getLocalizedName()); + return new TileEntityReverter(); + } + return null; + } + + @Override + public Item getItemDropped(final int meta, final Random par2Random, final int par3) { + switch (meta) { + case 0: + return null; + } + return Item.getItemFromBlock(this); + } + + @Override + public int damageDropped(final int meta) { + return meta; + } } diff --git a/src/main/java/gtPlusPlus/core/block/general/fluids/BlockFluidSludge.java b/src/main/java/gtPlusPlus/core/block/general/fluids/BlockFluidSludge.java index 6af27639ae..fcce29d164 100644 --- a/src/main/java/gtPlusPlus/core/block/general/fluids/BlockFluidSludge.java +++ b/src/main/java/gtPlusPlus/core/block/general/fluids/BlockFluidSludge.java @@ -2,62 +2,61 @@ package gtPlusPlus.core.block.general.fluids; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EnumCreatureType; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; - -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; import net.minecraftforge.fluids.BlockFluidClassic; import net.minecraftforge.fluids.Fluid; public class BlockFluidSludge extends BlockFluidClassic { - @SideOnly(Side.CLIENT) - protected IIcon stillIcon; - @SideOnly(Side.CLIENT) - protected IIcon flowingIcon; - - public BlockFluidSludge(final Fluid fluid, final Material material) { - super(fluid, material); - this.setCreativeTab(AddToCreativeTab.tabMisc); - } - - @Override - public IIcon getIcon(final int side, final int meta) { - return ((side == 0) || (side == 1))? this.stillIcon : this.flowingIcon; - } - - @SideOnly(Side.CLIENT) - @Override - public void registerBlockIcons(final IIconRegister register) { - this.stillIcon = register.registerIcon(CORE.MODID+":fluids/fluid.jackdaniels"); - this.flowingIcon = register.registerIcon(CORE.MODID+":fluids/fluid.jackdaniels"); - } - - @Override - public boolean canDisplace(final IBlockAccess world, final int x, final int y, final int z) { - if (world.getBlock(x, y, z).getMaterial().isLiquid()) { - return false; - } - return super.canDisplace(world, x, y, z); - } - - @Override - public boolean displaceIfPossible(final World world, final int x, final int y, final int z) { - if (world.getBlock(x, y, z).getMaterial().isLiquid()) { - return false; - } - return super.displaceIfPossible(world, x, y, z); - } - - @Override - public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { - return false; - } - + @SideOnly(Side.CLIENT) + protected IIcon stillIcon; + + @SideOnly(Side.CLIENT) + protected IIcon flowingIcon; + + public BlockFluidSludge(final Fluid fluid, final Material material) { + super(fluid, material); + this.setCreativeTab(AddToCreativeTab.tabMisc); + } + + @Override + public IIcon getIcon(final int side, final int meta) { + return ((side == 0) || (side == 1)) ? this.stillIcon : this.flowingIcon; + } + + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(final IIconRegister register) { + this.stillIcon = register.registerIcon(CORE.MODID + ":fluids/fluid.jackdaniels"); + this.flowingIcon = register.registerIcon(CORE.MODID + ":fluids/fluid.jackdaniels"); + } + + @Override + public boolean canDisplace(final IBlockAccess world, final int x, final int y, final int z) { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) { + return false; + } + return super.canDisplace(world, x, y, z); + } + + @Override + public boolean displaceIfPossible(final World world, final int x, final int y, final int z) { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) { + return false; + } + return super.displaceIfPossible(world, x, y, z); + } + + @Override + public boolean canCreatureSpawn( + final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } } diff --git a/src/main/java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstone.java b/src/main/java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstone.java index b84c96be99..1c1434b741 100644 --- a/src/main/java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstone.java +++ b/src/main/java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstone.java @@ -1,10 +1,5 @@ package gtPlusPlus.core.block.general.redstone; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Random; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; @@ -17,6 +12,10 @@ import gtPlusPlus.core.tileentities.general.redstone.TileEntityRedstoneHandler; import gtPlusPlus.core.util.minecraft.InventoryUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -36,335 +35,353 @@ import net.minecraftforge.common.util.ForgeDirection; public abstract class BlockGenericRedstone extends BlockContainer { - - @SuppressWarnings("deprecation") - public BlockGenericRedstone(String aUnlocalizedSuffix, String aDisplayName) { - super(Material.redstoneLight); - this.setBlockName("blockGenericRedstone." + aUnlocalizedSuffix); - this.setHardness(3f); - this.setCreativeTab(AddToCreativeTab.tabMachines); - GameRegistry.registerBlock(this, ItemBlockMeta.class, "blockGenericRedstone." + aUnlocalizedSuffix); - LanguageRegistry.addName(this, aDisplayName); - - } - - - private final HashMap> mTextures = new HashMap>(); - - /** - * A map of the textures used for this blocks. The key is the meta, then each internal map holds textures tied to each forge direction. Do not use unknown direction. - * @return - */ - public HashMap> getTextureArray() { - return mTextures; - } - - public abstract void generateTextureArray(final IIconRegister iicon); - - - @Override - @SideOnly(Side.CLIENT) - public final void registerBlockIcons(final IIconRegister iicon) { - generateTextureArray(iicon); - this.blockIcon = iicon.registerIcon("redstone_block"); - } - - - /** - * Called upon block activation (right click on the block.) - */ - @Override - public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, - final int side, final float lx, final float ly, final float lz) { - - if (world.isRemote) { - return true; - } - - boolean mDidTool = false; - // Check For Tools - try { - final ItemStack mHandStack = PlayerUtils.getItemStackInPlayersHand(world, player.getDisplayName()); - final Item mHandItem = mHandStack.getItem(); - if (ItemUtils.isItemGregtechTool(mHandStack)) { - - Logger.INFO("Found Tool in players hand!"); - - final TileEntityRedstoneHandler tile = (TileEntityRedstoneHandler) world.getTileEntity(x, y, z); - if (tile != null) { - if (tile.isScrewdriverable()) { - if (ItemUtils.isToolScrewdriver(mHandStack)){ - mDidTool = tile.onScrewdriverRMB(); - PlayerUtils.messagePlayer(player, "Adjusted Light level by 0.0625f. "+tile.getLightBrightness()); - } - } - if (tile.isMalletable()) { - if (ItemUtils.isToolMallet(mHandStack)){ - mDidTool = tile.onMalletRMB(); - PlayerUtils.messagePlayer(player, "Light Mode active: "+mDidTool); - } - } - if (tile.isWrenchable()) { - if (ItemUtils.isToolWrench(mHandStack)){ - mDidTool = tile.onWrenchRMB(); - } - } - } - } - } - catch (final Throwable t) {} - if (mDidTool) { - return true; - } - - return false; - } - - - - @Override - public void onBlockClicked(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer) { - - boolean mDidTool = false; - // Check For Tools - try { - final ItemStack mHandStack = PlayerUtils.getItemStackInPlayersHand(aWorld, aPlayer.getDisplayName()); - final Item mHandItem = mHandStack.getItem(); - if (mHandItem instanceof GT_MetaGenerated_Tool_01) { - - final TileEntityRedstoneHandler tile = (TileEntityRedstoneHandler) aWorld.getTileEntity(aX, aY, aZ); - if (tile != null) { - if (tile.isScrewdriverable()) { - if (ItemUtils.isToolScrewdriver(mHandStack)){ - mDidTool = tile.onScrewdriverLMB(); - } - } - if (tile.isMalletable()) { - if (ItemUtils.isToolMallet(mHandStack)){ - mDidTool = tile.onMalletLMB(); - } - } - if (tile.isWrenchable()) { - if (ItemUtils.isToolWrench(mHandStack)){ - mDidTool = tile.onWrenchLMB(); - } - } - } - } - } - catch (Throwable t) {} - - if (!mDidTool && !aPlayer.capabilities.isCreativeMode) { - super.onBlockClicked(aWorld, aX, aY, aZ, aPlayer); - } - else { - return; - } - } - - @Override - public abstract TileEntity createNewTileEntity(final World world, final int p_149915_2_); - - @Override - public void breakBlock(final World world, final int x, final int y, final int z, final Block block, - final int number) { - InventoryUtils.dropInventoryItems(world, x, y, z, block); - super.breakBlock(world, x, y, z, block, number); - } - - @Override - public void onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase entity, - final ItemStack stack) { - if (stack.hasDisplayName()) { - ((TileEntityRedstoneHandler) world.getTileEntity(x, y, z)).setCustomName(stack.getDisplayName()); - } - } - - @Override - public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, - final int z) { - return false; - } - - @Override - public int getLightValue() { - return super.getLightValue(); - } - - @Override - public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, - float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_) { - // TODO Auto-generated method stub - return super.onBlockPlaced(p_149660_1_, p_149660_2_, p_149660_3_, p_149660_4_, p_149660_5_, p_149660_6_, - p_149660_7_, p_149660_8_, p_149660_9_); - } - - @Override - public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { - TileEntityRedstoneHandler aThis = getTileEntity(world, x, y, z); - if (aThis != null) { - return aThis.isProvidingWeakPower(world, x, y, z, side); - } - return 0; - } - - @Override - public boolean canProvidePower() { - return false; - } - - @Override - public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side) { - TileEntityRedstoneHandler aThis = getTileEntity(world, x, y, z); - if (aThis != null) { - return aThis.isProvidingStrongPower(world, x, y, z, side); - } - return 0; - } - - @Override - public boolean hasComparatorInputOverride() { - // TODO Auto-generated method stub - return super.hasComparatorInputOverride(); - } - - @Override - public int getComparatorInputOverride(World p_149736_1_, int p_149736_2_, int p_149736_3_, int p_149736_4_, - int p_149736_5_) { - // TODO Auto-generated method stub - return super.getComparatorInputOverride(p_149736_1_, p_149736_2_, p_149736_3_, p_149736_4_, p_149736_5_); - } - - @Override - public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) { - TileEntityRedstoneHandler aThis = getTileEntity(world, x, y, z); - if (aThis != null) { - return aThis.canConnectRedstone(world, x, y, z, side); - } - return false; - } - - @Override - public boolean shouldCheckWeakPower(IBlockAccess world, int x, int y, int z, int side) { - TileEntityRedstoneHandler aThis = getTileEntity(world, x, y, z); - if (aThis != null) { - return aThis.shouldCheckWeakPower(world, x, y, z, side); - } + @SuppressWarnings("deprecation") + public BlockGenericRedstone(String aUnlocalizedSuffix, String aDisplayName) { + super(Material.redstoneLight); + this.setBlockName("blockGenericRedstone." + aUnlocalizedSuffix); + this.setHardness(3f); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockMeta.class, "blockGenericRedstone." + aUnlocalizedSuffix); + LanguageRegistry.addName(this, aDisplayName); + } + + private final HashMap> mTextures = + new HashMap>(); + + /** + * A map of the textures used for this blocks. The key is the meta, then each internal map holds textures tied to each forge direction. Do not use unknown direction. + * @return + */ + public HashMap> getTextureArray() { + return mTextures; + } + + public abstract void generateTextureArray(final IIconRegister iicon); + + @Override + @SideOnly(Side.CLIENT) + public final void registerBlockIcons(final IIconRegister iicon) { + generateTextureArray(iicon); + this.blockIcon = iicon.registerIcon("redstone_block"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated( + final World world, + final int x, + final int y, + final int z, + final EntityPlayer player, + final int side, + final float lx, + final float ly, + final float lz) { + + if (world.isRemote) { + return true; + } + + boolean mDidTool = false; + // Check For Tools + try { + final ItemStack mHandStack = PlayerUtils.getItemStackInPlayersHand(world, player.getDisplayName()); + final Item mHandItem = mHandStack.getItem(); + if (ItemUtils.isItemGregtechTool(mHandStack)) { + + Logger.INFO("Found Tool in players hand!"); + + final TileEntityRedstoneHandler tile = (TileEntityRedstoneHandler) world.getTileEntity(x, y, z); + if (tile != null) { + if (tile.isScrewdriverable()) { + if (ItemUtils.isToolScrewdriver(mHandStack)) { + mDidTool = tile.onScrewdriverRMB(); + PlayerUtils.messagePlayer( + player, "Adjusted Light level by 0.0625f. " + tile.getLightBrightness()); + } + } + if (tile.isMalletable()) { + if (ItemUtils.isToolMallet(mHandStack)) { + mDidTool = tile.onMalletRMB(); + PlayerUtils.messagePlayer(player, "Light Mode active: " + mDidTool); + } + } + if (tile.isWrenchable()) { + if (ItemUtils.isToolWrench(mHandStack)) { + mDidTool = tile.onWrenchRMB(); + } + } + } + } + } catch (final Throwable t) { + } + if (mDidTool) { + return true; + } + + return false; + } + + @Override + public void onBlockClicked(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer) { + + boolean mDidTool = false; + // Check For Tools + try { + final ItemStack mHandStack = PlayerUtils.getItemStackInPlayersHand(aWorld, aPlayer.getDisplayName()); + final Item mHandItem = mHandStack.getItem(); + if (mHandItem instanceof GT_MetaGenerated_Tool_01) { + + final TileEntityRedstoneHandler tile = (TileEntityRedstoneHandler) aWorld.getTileEntity(aX, aY, aZ); + if (tile != null) { + if (tile.isScrewdriverable()) { + if (ItemUtils.isToolScrewdriver(mHandStack)) { + mDidTool = tile.onScrewdriverLMB(); + } + } + if (tile.isMalletable()) { + if (ItemUtils.isToolMallet(mHandStack)) { + mDidTool = tile.onMalletLMB(); + } + } + if (tile.isWrenchable()) { + if (ItemUtils.isToolWrench(mHandStack)) { + mDidTool = tile.onWrenchLMB(); + } + } + } + } + } catch (Throwable t) { + } + + if (!mDidTool && !aPlayer.capabilities.isCreativeMode) { + super.onBlockClicked(aWorld, aX, aY, aZ, aPlayer); + } else { + return; + } + } + + @Override + public abstract TileEntity createNewTileEntity(final World world, final int p_149915_2_); + + @Override + public void breakBlock( + final World world, final int x, final int y, final int z, final Block block, final int number) { + InventoryUtils.dropInventoryItems(world, x, y, z, block); + super.breakBlock(world, x, y, z, block, number); + } + + @Override + public void onBlockPlacedBy( + final World world, + final int x, + final int y, + final int z, + final EntityLivingBase entity, + final ItemStack stack) { + if (stack.hasDisplayName()) { + ((TileEntityRedstoneHandler) world.getTileEntity(x, y, z)).setCustomName(stack.getDisplayName()); + } + } + + @Override + public boolean canCreatureSpawn( + final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + @Override + public int getLightValue() { + return super.getLightValue(); + } + + @Override + public int onBlockPlaced( + World p_149660_1_, + int p_149660_2_, + int p_149660_3_, + int p_149660_4_, + int p_149660_5_, + float p_149660_6_, + float p_149660_7_, + float p_149660_8_, + int p_149660_9_) { + // TODO Auto-generated method stub + return super.onBlockPlaced( + p_149660_1_, + p_149660_2_, + p_149660_3_, + p_149660_4_, + p_149660_5_, + p_149660_6_, + p_149660_7_, + p_149660_8_, + p_149660_9_); + } + + @Override + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { + TileEntityRedstoneHandler aThis = getTileEntity(world, x, y, z); + if (aThis != null) { + return aThis.isProvidingWeakPower(world, x, y, z, side); + } + return 0; + } + + @Override + public boolean canProvidePower() { + return false; + } + + @Override + public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side) { + TileEntityRedstoneHandler aThis = getTileEntity(world, x, y, z); + if (aThis != null) { + return aThis.isProvidingStrongPower(world, x, y, z, side); + } + return 0; + } + + @Override + public boolean hasComparatorInputOverride() { + // TODO Auto-generated method stub + return super.hasComparatorInputOverride(); + } + + @Override + public int getComparatorInputOverride( + World p_149736_1_, int p_149736_2_, int p_149736_3_, int p_149736_4_, int p_149736_5_) { + // TODO Auto-generated method stub + return super.getComparatorInputOverride(p_149736_1_, p_149736_2_, p_149736_3_, p_149736_4_, p_149736_5_); + } + + @Override + public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) { + TileEntityRedstoneHandler aThis = getTileEntity(world, x, y, z); + if (aThis != null) { + return aThis.canConnectRedstone(world, x, y, z, side); + } + return false; + } + + @Override + public boolean shouldCheckWeakPower(IBlockAccess world, int x, int y, int z, int side) { + TileEntityRedstoneHandler aThis = getTileEntity(world, x, y, z); + if (aThis != null) { + return aThis.shouldCheckWeakPower(world, x, y, z, side); + } return isNormalCube(); - } - - @Override - public boolean getWeakChanges(IBlockAccess world, int x, int y, int z) { - TileEntityRedstoneHandler aThis = getTileEntity(world, x, y, z); - if (aThis != null) { - return aThis.getWeakChanges(world, x, y, z); - } - return false; - } - - - /** - * Gets the block's texture. Args: side, meta - */ - @Override - @SideOnly(Side.CLIENT) - public abstract IIcon getIcon(final int side, final int meta); - - @Override - public int damageDropped(final int damage) { - return damage; - } - - @Override - public abstract void getSubBlocks(final Item item, final CreativeTabs tab, final List list); - - - /** - * Called whenever the block is added into the world. Args: world, x, y, z - */ - public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { - TileEntityRedstoneHandler aThis = getTileEntity(aWorld, aX, aY, aZ); - - if (!aWorld.isRemote) { - if (aThis.hasUpdatedRecently() && !aWorld.isBlockIndirectlyGettingPowered(aX, aY, aZ)) { - aWorld.scheduleBlockUpdate(aX, aY, aZ, this, 4); - } else if (!aThis.hasUpdatedRecently() && aWorld.isBlockIndirectlyGettingPowered(aX, aY, aZ)) { - aWorld.setBlock(aX, aY, aZ, Blocks.lit_redstone_lamp, 0, 2); - } - } - } - - /** - * Lets the block know when one of its neighbor changes. Doesn't know which - * neighbor changed (coordinates passed are their own) Args: x, y, z, neighbor - * Block - */ - public void onNeighborBlockChange(World aWorld, int aX, int aY, int aZ, Block p_149695_5_) { - - TileEntityRedstoneHandler aThis = getTileEntity(aWorld, aX, aY, aZ); - - if (!aWorld.isRemote) { - if (aThis.hasUpdatedRecently() && !aWorld.isBlockIndirectlyGettingPowered(aX, aY, aZ)) { - aWorld.scheduleBlockUpdate(aX, aY, aZ, this, 4); - } else if (!aThis.hasUpdatedRecently() && aWorld.isBlockIndirectlyGettingPowered(aX, aY, aZ)) { - aWorld.setBlock(aX, aY, aZ, Blocks.lit_redstone_lamp, 0, 2); - } - } - } - - /** - * Ticks the block if it's been scheduled - */ - public void updateTick(World aWorld, int aX, int aY, int aZ, Random p_149674_5_) { - TileEntityRedstoneHandler aTile = getTileEntity(aWorld, aX, aY, aZ); - // Client side handling - if (aTile != null) { - this.setLightLevel(aTile.getLightBrightness()); - } - // Only continue on server - if (aWorld.isRemote) { - return; - } - if (aTile != null) { - if (aTile.isGettingIndirectlyPowered()) { - } - } - } - - public TileEntityRedstoneHandler getTileEntity(IBlockAccess world, int aX, int aY, int aZ) { - TileEntity aTemp = world.getTileEntity(aX, aY, aZ); - if (aTemp != null) { - if (aTemp instanceof TileEntityRedstoneHandler) { - TileEntityRedstoneHandler g = (TileEntityRedstoneHandler) aTemp; - if (g != null) { - return g; - } - } - } - return null; - } - - - /** - * Gets an item for the block being called on. Args: world, x, y, z - */ - @SideOnly(Side.CLIENT) - @Override - public abstract Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_); - - /** - * Returns an item stack containing a single instance of the current block type. - * 'i' is the block's subtype/damage and is ignored for blocks which do not - * support subtypes. Blocks which cannot be harvested should return null. - */ - @Override - protected abstract ItemStack createStackedBlock(int p_149644_1_); - - @Override - public abstract ArrayList getDrops(final World world, final int x, final int y, final int z, final int metadata, final int fortune); - - @Override - public abstract Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_); - - -} \ No newline at end of file + } + + @Override + public boolean getWeakChanges(IBlockAccess world, int x, int y, int z) { + TileEntityRedstoneHandler aThis = getTileEntity(world, x, y, z); + if (aThis != null) { + return aThis.getWeakChanges(world, x, y, z); + } + return false; + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public abstract IIcon getIcon(final int side, final int meta); + + @Override + public int damageDropped(final int damage) { + return damage; + } + + @Override + public abstract void getSubBlocks(final Item item, final CreativeTabs tab, final List list); + + /** + * Called whenever the block is added into the world. Args: world, x, y, z + */ + public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { + TileEntityRedstoneHandler aThis = getTileEntity(aWorld, aX, aY, aZ); + + if (!aWorld.isRemote) { + if (aThis.hasUpdatedRecently() && !aWorld.isBlockIndirectlyGettingPowered(aX, aY, aZ)) { + aWorld.scheduleBlockUpdate(aX, aY, aZ, this, 4); + } else if (!aThis.hasUpdatedRecently() && aWorld.isBlockIndirectlyGettingPowered(aX, aY, aZ)) { + aWorld.setBlock(aX, aY, aZ, Blocks.lit_redstone_lamp, 0, 2); + } + } + } + + /** + * Lets the block know when one of its neighbor changes. Doesn't know which + * neighbor changed (coordinates passed are their own) Args: x, y, z, neighbor + * Block + */ + public void onNeighborBlockChange(World aWorld, int aX, int aY, int aZ, Block p_149695_5_) { + + TileEntityRedstoneHandler aThis = getTileEntity(aWorld, aX, aY, aZ); + + if (!aWorld.isRemote) { + if (aThis.hasUpdatedRecently() && !aWorld.isBlockIndirectlyGettingPowered(aX, aY, aZ)) { + aWorld.scheduleBlockUpdate(aX, aY, aZ, this, 4); + } else if (!aThis.hasUpdatedRecently() && aWorld.isBlockIndirectlyGettingPowered(aX, aY, aZ)) { + aWorld.setBlock(aX, aY, aZ, Blocks.lit_redstone_lamp, 0, 2); + } + } + } + + /** + * Ticks the block if it's been scheduled + */ + public void updateTick(World aWorld, int aX, int aY, int aZ, Random p_149674_5_) { + TileEntityRedstoneHandler aTile = getTileEntity(aWorld, aX, aY, aZ); + // Client side handling + if (aTile != null) { + this.setLightLevel(aTile.getLightBrightness()); + } + // Only continue on server + if (aWorld.isRemote) { + return; + } + if (aTile != null) { + if (aTile.isGettingIndirectlyPowered()) {} + } + } + + public TileEntityRedstoneHandler getTileEntity(IBlockAccess world, int aX, int aY, int aZ) { + TileEntity aTemp = world.getTileEntity(aX, aY, aZ); + if (aTemp != null) { + if (aTemp instanceof TileEntityRedstoneHandler) { + TileEntityRedstoneHandler g = (TileEntityRedstoneHandler) aTemp; + if (g != null) { + return g; + } + } + } + return null; + } + + /** + * Gets an item for the block being called on. Args: world, x, y, z + */ + @SideOnly(Side.CLIENT) + @Override + public abstract Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_); + + /** + * Returns an item stack containing a single instance of the current block type. + * 'i' is the block's subtype/damage and is ignored for blocks which do not + * support subtypes. Blocks which cannot be harvested should return null. + */ + @Override + protected abstract ItemStack createStackedBlock(int p_149644_1_); + + @Override + public abstract ArrayList getDrops( + final World world, final int x, final int y, final int z, final int metadata, final int fortune); + + @Override + public abstract Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_); +} diff --git a/src/main/java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneDetector.java b/src/main/java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneDetector.java index 43247110f1..406b53fb59 100644 --- a/src/main/java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneDetector.java +++ b/src/main/java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneDetector.java @@ -1,13 +1,12 @@ package gtPlusPlus.core.block.general.redstone; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.general.redstone.TileEntityRedstoneHandler; +import gtPlusPlus.core.util.minecraft.ItemUtils; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Random; - -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.tileentities.general.redstone.TileEntityRedstoneHandler; -import gtPlusPlus.core.util.minecraft.ItemUtils; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; @@ -19,113 +18,114 @@ import net.minecraftforge.common.util.ForgeDirection; public class BlockGenericRedstoneDetector extends BlockGenericRedstone { - public BlockGenericRedstoneDetector() { - super("detector", "Redstone Detector"); - setTickRandomly(true); - } - - @Override - public TileEntity createNewTileEntity(World world, int p_149915_2_) { - return new TileEntityRedstoneDetector(); - } - - public class TileEntityRedstoneDetector extends TileEntityRedstoneHandler { - public TileEntityRedstoneDetector() { - super(0); - } - - @Override - protected Class getTileEntityClass() { - return this.getClass(); - } - - @Override - protected String getTileEntityNameForRegistration() { - return "TileEntityRedstoneDetector"; - } - } - - @Override - public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List aList) { - aList.add(ItemUtils.getSimpleStack(this)); - } - - - @Override - public void updateTick(World aWorld, int aX, int aY, int aZ, Random aRand) { - super.updateTick(aWorld, aX, aY, aZ, aRand); - } - - @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { - // TODO Auto-generated method stub - return ItemUtils.getSimpleStack(this).getItem(); - } - - @Override - public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) { - // TODO Auto-generated method stub - return ItemUtils.getSimpleStack(this).getItem(); - } - - @Override - protected ItemStack createStackedBlock(int p_149644_1_) { - return ItemUtils.simpleMetaStack(this, p_149644_1_, 1); - } - - public void generateTextureArray(final IIconRegister iicon) { - HashMap> aTextures = new HashMap>(); - - - //New Block for Each Meta - int aMeta = 0; - { - HashMap aTempMap = new HashMap(); - aTempMap.put(ForgeDirection.UP, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); - aTempMap.put(ForgeDirection.DOWN, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); - aTempMap.put(ForgeDirection.NORTH, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); - aTempMap.put(ForgeDirection.SOUTH, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); - aTempMap.put(ForgeDirection.EAST, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); - aTempMap.put(ForgeDirection.WEST, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); - aTextures.put(aMeta++, aTempMap); - } - - } - - @Override - public IIcon getIcon(int side, int meta) { - HashMap aTemp = getTextureArray().get(meta); - if (aTemp != null) { - IIcon aSide = aTemp.get(ForgeDirection.getOrientation(side)); - if (aSide != null) { - return aSide; - } - else { - //Smart calculate missing sides - if (side <= 1) { - for (int ss = 0; ss < 2; ss++) { - aSide = aTemp.get(ForgeDirection.getOrientation(side)); - if (aSide != null) { - return aSide; - } - } - } - for (int ss = 2; ss < 6; ss++) { - aSide = aTemp.get(ForgeDirection.getOrientation(side)); - if (aSide != null) { - return aSide; - } - } - } - } - return blockIcon; - } - - @Override - public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { - ArrayList aDrops = new ArrayList(); - aDrops.add(ItemUtils.getSimpleStack(this)); - return aDrops; - } - + public BlockGenericRedstoneDetector() { + super("detector", "Redstone Detector"); + setTickRandomly(true); + } + + @Override + public TileEntity createNewTileEntity(World world, int p_149915_2_) { + return new TileEntityRedstoneDetector(); + } + + public class TileEntityRedstoneDetector extends TileEntityRedstoneHandler { + public TileEntityRedstoneDetector() { + super(0); + } + + @Override + protected Class getTileEntityClass() { + return this.getClass(); + } + + @Override + protected String getTileEntityNameForRegistration() { + return "TileEntityRedstoneDetector"; + } + } + + @Override + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List aList) { + aList.add(ItemUtils.getSimpleStack(this)); + } + + @Override + public void updateTick(World aWorld, int aX, int aY, int aZ, Random aRand) { + super.updateTick(aWorld, aX, aY, aZ, aRand); + } + + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + // TODO Auto-generated method stub + return ItemUtils.getSimpleStack(this).getItem(); + } + + @Override + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) { + // TODO Auto-generated method stub + return ItemUtils.getSimpleStack(this).getItem(); + } + + @Override + protected ItemStack createStackedBlock(int p_149644_1_) { + return ItemUtils.simpleMetaStack(this, p_149644_1_, 1); + } + + public void generateTextureArray(final IIconRegister iicon) { + HashMap> aTextures = + new HashMap>(); + + // New Block for Each Meta + int aMeta = 0; + { + HashMap aTempMap = new HashMap(); + aTempMap.put(ForgeDirection.UP, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); + aTempMap.put( + ForgeDirection.DOWN, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); + aTempMap.put( + ForgeDirection.NORTH, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); + aTempMap.put( + ForgeDirection.SOUTH, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); + aTempMap.put( + ForgeDirection.EAST, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); + aTempMap.put( + ForgeDirection.WEST, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); + aTextures.put(aMeta++, aTempMap); + } + } + + @Override + public IIcon getIcon(int side, int meta) { + HashMap aTemp = getTextureArray().get(meta); + if (aTemp != null) { + IIcon aSide = aTemp.get(ForgeDirection.getOrientation(side)); + if (aSide != null) { + return aSide; + } else { + // Smart calculate missing sides + if (side <= 1) { + for (int ss = 0; ss < 2; ss++) { + aSide = aTemp.get(ForgeDirection.getOrientation(side)); + if (aSide != null) { + return aSide; + } + } + } + for (int ss = 2; ss < 6; ss++) { + aSide = aTemp.get(ForgeDirection.getOrientation(side)); + if (aSide != null) { + return aSide; + } + } + } + } + return blockIcon; + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + ArrayList aDrops = new ArrayList(); + aDrops.add(ItemUtils.getSimpleStack(this)); + return aDrops; + } } diff --git a/src/main/java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneEmitter.java b/src/main/java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneEmitter.java index df8a929302..c732ed216b 100644 --- a/src/main/java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneEmitter.java +++ b/src/main/java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneEmitter.java @@ -1,5 +1,3 @@ package gtPlusPlus.core.block.general.redstone; -public class BlockGenericRedstoneEmitter { - -} +public class BlockGenericRedstoneEmitter {} diff --git a/src/main/java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneTest.java b/src/main/java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneTest.java index 0f1f983cd0..85c2506359 100644 --- a/src/main/java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneTest.java +++ b/src/main/java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneTest.java @@ -1,16 +1,15 @@ package gtPlusPlus.core.block.general.redstone; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Random; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.tileentities.general.redstone.TileEntityRedstoneHandler; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.world.explosions.ExplosionHandler; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Random; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; @@ -23,179 +22,179 @@ import net.minecraftforge.common.util.ForgeDirection; public class BlockGenericRedstoneTest extends BlockGenericRedstone { - public BlockGenericRedstoneTest() { - super("test", "Redstone Test"); - setTickRandomly(true); - } - - @Override - public TileEntity createNewTileEntity(World world, int p_149915_2_) { - return new TileEntityRedstoneTest(); - } - - public class TileEntityRedstoneTest extends TileEntityRedstoneHandler { - public TileEntityRedstoneTest() { - super(2); - } - - @Override - public boolean isScrewdriverable() { - return true; - } - - @Override - public boolean onScrewdriverLMB() { - return super.onScrewdriverLMB(); - } - - @Override - public boolean onScrewdriverRMB() { - if (this.mLightValue + 0.0625f <= 1) { - this.mLightValue += 0.0625f; - } - else { - this.mLightValue = 0; - } - this.markForUpdate(); - return true; - } - - @Override - public boolean isMalletable() { - return true; - } - - @Override - public boolean onMalletLMB() { - return super.onMalletLMB(); - } - - @Override - public boolean onMalletRMB() { - this.mLightMode = Utils.invertBoolean(mLightMode); - this.markForUpdate(); - return mLightMode; - } - - @Override - public boolean isWrenchable() { - return true; - } - - @Override - public boolean onWrenchLMB() { - return super.onWrenchLMB(); - } - - @Override - public boolean onWrenchRMB() { - Logger.INFO("Found Wrench"); - ExplosionHandler explode = new ExplosionHandler(); - explode.createExplosion(this.worldObj, null, this.xCoord, this.yCoord, this.zCoord, 1f, false, true); - return true; - } - - @Override - protected Class getTileEntityClass() { - return this.getClass(); - } - - @Override - protected String getTileEntityNameForRegistration() { - return "TileEntityRedstoneTest"; - } - - @Override - public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { - return super.isProvidingWeakPower(world, x, y, z, side); - } - - @Override - public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side) { - return super.isProvidingStrongPower(world, x, y, z, side); - } - } - - @SuppressWarnings("unchecked") - @Override - public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List aList) { - aList.add(ItemUtils.getSimpleStack(this)); - } - - - @Override - public void updateTick(World aWorld, int aX, int aY, int aZ, Random aRand) { - super.updateTick(aWorld, aX, aY, aZ, aRand); - } - - @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { - return ItemUtils.getSimpleStack(this).getItem(); - } - - @Override - public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) { - return ItemUtils.getSimpleStack(this).getItem(); - } - - @Override - protected ItemStack createStackedBlock(int p_149644_1_) { - return ItemUtils.simpleMetaStack(this, p_149644_1_, 1); - } - - public void generateTextureArray(final IIconRegister iicon) { - HashMap> aTextures = new HashMap>(); - - - //New Block for Each Meta - int aMeta = 0; - { - HashMap aTempMap = new HashMap(); - aTempMap.put(ForgeDirection.UP, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); - aTempMap.put(ForgeDirection.DOWN, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); - aTempMap.put(ForgeDirection.NORTH, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); - aTempMap.put(ForgeDirection.SOUTH, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); - aTempMap.put(ForgeDirection.EAST, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); - aTempMap.put(ForgeDirection.WEST, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); - aTextures.put(aMeta++, aTempMap); - } - - } - - @Override - public IIcon getIcon(int side, int meta) { - HashMap aTemp = getTextureArray().get(meta); - if (aTemp != null) { - IIcon aSide = aTemp.get(ForgeDirection.getOrientation(side)); - if (aSide != null) { - return aSide; - } - else { - //Smart calculate missing sides - if (side <= 1) { - for (int ss = 0; ss < 2; ss++) { - aSide = aTemp.get(ForgeDirection.getOrientation(side)); - if (aSide != null) { - return aSide; - } - } - } - for (int ss = 2; ss < 6; ss++) { - aSide = aTemp.get(ForgeDirection.getOrientation(side)); - if (aSide != null) { - return aSide; - } - } - } - } - return blockIcon; - } - - @Override - public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { - ArrayList aDrops = new ArrayList(); - aDrops.add(ItemUtils.getSimpleStack(this)); - return aDrops; - } - + public BlockGenericRedstoneTest() { + super("test", "Redstone Test"); + setTickRandomly(true); + } + + @Override + public TileEntity createNewTileEntity(World world, int p_149915_2_) { + return new TileEntityRedstoneTest(); + } + + public class TileEntityRedstoneTest extends TileEntityRedstoneHandler { + public TileEntityRedstoneTest() { + super(2); + } + + @Override + public boolean isScrewdriverable() { + return true; + } + + @Override + public boolean onScrewdriverLMB() { + return super.onScrewdriverLMB(); + } + + @Override + public boolean onScrewdriverRMB() { + if (this.mLightValue + 0.0625f <= 1) { + this.mLightValue += 0.0625f; + } else { + this.mLightValue = 0; + } + this.markForUpdate(); + return true; + } + + @Override + public boolean isMalletable() { + return true; + } + + @Override + public boolean onMalletLMB() { + return super.onMalletLMB(); + } + + @Override + public boolean onMalletRMB() { + this.mLightMode = Utils.invertBoolean(mLightMode); + this.markForUpdate(); + return mLightMode; + } + + @Override + public boolean isWrenchable() { + return true; + } + + @Override + public boolean onWrenchLMB() { + return super.onWrenchLMB(); + } + + @Override + public boolean onWrenchRMB() { + Logger.INFO("Found Wrench"); + ExplosionHandler explode = new ExplosionHandler(); + explode.createExplosion(this.worldObj, null, this.xCoord, this.yCoord, this.zCoord, 1f, false, true); + return true; + } + + @Override + protected Class getTileEntityClass() { + return this.getClass(); + } + + @Override + protected String getTileEntityNameForRegistration() { + return "TileEntityRedstoneTest"; + } + + @Override + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { + return super.isProvidingWeakPower(world, x, y, z, side); + } + + @Override + public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side) { + return super.isProvidingStrongPower(world, x, y, z, side); + } + } + + @SuppressWarnings("unchecked") + @Override + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List aList) { + aList.add(ItemUtils.getSimpleStack(this)); + } + + @Override + public void updateTick(World aWorld, int aX, int aY, int aZ, Random aRand) { + super.updateTick(aWorld, aX, aY, aZ, aRand); + } + + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + return ItemUtils.getSimpleStack(this).getItem(); + } + + @Override + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) { + return ItemUtils.getSimpleStack(this).getItem(); + } + + @Override + protected ItemStack createStackedBlock(int p_149644_1_) { + return ItemUtils.simpleMetaStack(this, p_149644_1_, 1); + } + + public void generateTextureArray(final IIconRegister iicon) { + HashMap> aTextures = + new HashMap>(); + + // New Block for Each Meta + int aMeta = 0; + { + HashMap aTempMap = new HashMap(); + aTempMap.put(ForgeDirection.UP, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); + aTempMap.put( + ForgeDirection.DOWN, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); + aTempMap.put( + ForgeDirection.NORTH, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); + aTempMap.put( + ForgeDirection.SOUTH, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); + aTempMap.put( + ForgeDirection.EAST, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); + aTempMap.put( + ForgeDirection.WEST, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top")); + aTextures.put(aMeta++, aTempMap); + } + } + + @Override + public IIcon getIcon(int side, int meta) { + HashMap aTemp = getTextureArray().get(meta); + if (aTemp != null) { + IIcon aSide = aTemp.get(ForgeDirection.getOrientation(side)); + if (aSide != null) { + return aSide; + } else { + // Smart calculate missing sides + if (side <= 1) { + for (int ss = 0; ss < 2; ss++) { + aSide = aTemp.get(ForgeDirection.getOrientation(side)); + if (aSide != null) { + return aSide; + } + } + } + for (int ss = 2; ss < 6; ss++) { + aSide = aTemp.get(ForgeDirection.getOrientation(side)); + if (aSide != null) { + return aSide; + } + } + } + } + return blockIcon; + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + ArrayList aDrops = new ArrayList(); + aDrops.add(ItemUtils.getSimpleStack(this)); + return aDrops; + } } diff --git a/src/main/java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java b/src/main/java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java index a4ed895b13..289b5e5c1c 100644 --- a/src/main/java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java +++ b/src/main/java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java @@ -1,42 +1,43 @@ package gtPlusPlus.core.block.machine; -import net.minecraft.block.material.Material; -import net.minecraft.entity.EnumCreatureType; -import net.minecraft.world.IBlockAccess; - import gtPlusPlus.core.block.base.BasicBlock.BlockTypes; import gtPlusPlus.core.block.base.MetaBlock; import gtPlusPlus.core.lib.CORE; +import net.minecraft.block.material.Material; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.world.IBlockAccess; public class BlockGtFrameBox extends MetaBlock { - private int[] colours; - private int totalColours; - - public BlockGtFrameBox( - final String unlocalizedName, final Material material, - final BlockTypes blockTypeENUM, final boolean recolour, final int... colour) { - super(unlocalizedName, material, blockTypeENUM.getBlockSoundType()); - this.setBlockTextureName(CORE.MODID + ":" + "blockGtFrame"); - this.setHarvestLevel(blockTypeENUM.getHarvestTool(), 2); - if (recolour && ((colour != null) && (colour.length > 0))){ - this.colours = colour; - this.totalColours = this.colours.length; - } - } - - @Override - public int colorMultiplier(final IBlockAccess p_149720_1_, final int p_149720_2_, - final int p_149720_3_, final int p_149720_4_) { - for (final int i : this.colours){ - - } - return super.colorMultiplier(p_149720_1_, p_149720_2_, p_149720_3_, p_149720_4_); - } - - @Override - public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { - return false; - } - + private int[] colours; + private int totalColours; + + public BlockGtFrameBox( + final String unlocalizedName, + final Material material, + final BlockTypes blockTypeENUM, + final boolean recolour, + final int... colour) { + super(unlocalizedName, material, blockTypeENUM.getBlockSoundType()); + this.setBlockTextureName(CORE.MODID + ":" + "blockGtFrame"); + this.setHarvestLevel(blockTypeENUM.getHarvestTool(), 2); + if (recolour && ((colour != null) && (colour.length > 0))) { + this.colours = colour; + this.totalColours = this.colours.length; + } + } + + @Override + public int colorMultiplier( + final IBlockAccess p_149720_1_, final int p_149720_2_, final int p_149720_3_, final int p_149720_4_) { + for (final int i : this.colours) {} + + return super.colorMultiplier(p_149720_1_, p_149720_2_, p_149720_3_, p_149720_4_); + } + + @Override + public boolean canCreatureSpawn( + final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } } diff --git a/src/main/java/gtPlusPlus/core/block/machine/CircuitProgrammer.java b/src/main/java/gtPlusPlus/core/block/machine/CircuitProgrammer.java index 7d8b3eb708..4cc3afec22 100644 --- a/src/main/java/gtPlusPlus/core/block/machine/CircuitProgrammer.java +++ b/src/main/java/gtPlusPlus/core/block/machine/CircuitProgrammer.java @@ -23,137 +23,148 @@ import net.minecraft.world.World; public class CircuitProgrammer extends BasicTileBlockWithTooltip { - /** - * Determines which tooltip is displayed within the itemblock. - */ - private final int mTooltipID = 4; - - @Override - public int getTooltipID() { - return this.mTooltipID; - } - - @SuppressWarnings("deprecation") - public CircuitProgrammer(){ - super(Material.iron); - LanguageRegistry.addName(this, "Circuit Programmer"); - } - - /** - * Called upon block activation (right click on the block.) - */ - @Override - public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz) - { - if (world.isRemote) { - return true; - } - else { - - boolean mDidScrewDriver = false; - // Check For Screwdriver - try { - final ItemStack mHandStack = PlayerUtils.getItemStackInPlayersHand(world, player.getDisplayName()); - final Item mHandItem = mHandStack.getItem(); - if (((mHandItem instanceof GT_MetaGenerated_Tool_01) - && ((mHandItem.getDamage(mHandStack) == 22) || (mHandItem.getDamage(mHandStack) == 150)))) { - final TileEntityCircuitProgrammer tile = (TileEntityCircuitProgrammer) world.getTileEntity(x, y, z); - if (tile != null) { - mDidScrewDriver = tile.onScrewdriverRightClick((byte) side, player, x, y, z); - } - } - } - catch (final Throwable t) {} - - if (!mDidScrewDriver) { - final TileEntity te = world.getTileEntity(x, y, z); - if ((te != null) && (te instanceof TileEntityCircuitProgrammer)){ - player.openGui(GTplusplus.instance, GuiHandler.GUI8, world, x, y, z); - return true; - } - } - else { - return true; - } - - } - return false; - } - - @Override - public int getRenderBlockPass() { - return 1; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { - return new TileEntityCircuitProgrammer(); - } - - @Override - public void onBlockAdded(final World world, final int x, final int y, final int z) { - super.onBlockAdded(world, x, y, z); - } - - @Override - public void onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase entity, final ItemStack stack) { - if (stack.hasDisplayName()) { - ((TileEntityCircuitProgrammer) world.getTileEntity(x,y,z)).setCustomName(stack.getDisplayName()); - } - } - - @Override - public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { - return false; - } - - @Override - public int getMetaCount() { - return 0; - } - - @Override - public String getUnlocalBlockName() { - return "blockCircuitProgrammer"; - } - - @Override - protected float initBlockHardness() { - return 5f; - } - - @Override - protected float initBlockResistance() { - return 1f; - } - - @Override - protected CreativeTabs initCreativeTab() { - return AddToCreativeTab.tabMachines; - } - - @Override - protected String getTileEntityName() { - return "Circuit Programmer"; - } - - @Override - public CubicObject[] getCustomTextureDirectoryObject() { - String[] aTexData = new String[] { - CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_G", - CORE.MODID + ":" + "metro/" + "TEXTURE_TECH_PANEL_B", - CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_I", - CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_I", - CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_I", - CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_I" - }; - CubicObject[] aTextureData = new CubicObject[] {new CubicObject(aTexData)}; - return aTextureData; - } - -} \ No newline at end of file + /** + * Determines which tooltip is displayed within the itemblock. + */ + private final int mTooltipID = 4; + + @Override + public int getTooltipID() { + return this.mTooltipID; + } + + @SuppressWarnings("deprecation") + public CircuitProgrammer() { + super(Material.iron); + LanguageRegistry.addName(this, "Circuit Programmer"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated( + final World world, + final int x, + final int y, + final int z, + final EntityPlayer player, + final int side, + final float lx, + final float ly, + final float lz) { + if (world.isRemote) { + return true; + } else { + + boolean mDidScrewDriver = false; + // Check For Screwdriver + try { + final ItemStack mHandStack = PlayerUtils.getItemStackInPlayersHand(world, player.getDisplayName()); + final Item mHandItem = mHandStack.getItem(); + if (((mHandItem instanceof GT_MetaGenerated_Tool_01) + && ((mHandItem.getDamage(mHandStack) == 22) || (mHandItem.getDamage(mHandStack) == 150)))) { + final TileEntityCircuitProgrammer tile = (TileEntityCircuitProgrammer) world.getTileEntity(x, y, z); + if (tile != null) { + mDidScrewDriver = tile.onScrewdriverRightClick((byte) side, player, x, y, z); + } + } + } catch (final Throwable t) { + } + + if (!mDidScrewDriver) { + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityCircuitProgrammer)) { + player.openGui(GTplusplus.instance, GuiHandler.GUI8, world, x, y, z); + return true; + } + } else { + return true; + } + } + return false; + } + + @Override + public int getRenderBlockPass() { + return 1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityCircuitProgrammer(); + } + + @Override + public void onBlockAdded(final World world, final int x, final int y, final int z) { + super.onBlockAdded(world, x, y, z); + } + + @Override + public void onBlockPlacedBy( + final World world, + final int x, + final int y, + final int z, + final EntityLivingBase entity, + final ItemStack stack) { + if (stack.hasDisplayName()) { + ((TileEntityCircuitProgrammer) world.getTileEntity(x, y, z)).setCustomName(stack.getDisplayName()); + } + } + + @Override + public boolean canCreatureSpawn( + final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + @Override + public int getMetaCount() { + return 0; + } + + @Override + public String getUnlocalBlockName() { + return "blockCircuitProgrammer"; + } + + @Override + protected float initBlockHardness() { + return 5f; + } + + @Override + protected float initBlockResistance() { + return 1f; + } + + @Override + protected CreativeTabs initCreativeTab() { + return AddToCreativeTab.tabMachines; + } + + @Override + protected String getTileEntityName() { + return "Circuit Programmer"; + } + + @Override + public CubicObject[] getCustomTextureDirectoryObject() { + String[] aTexData = new String[] { + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_G", + CORE.MODID + ":" + "metro/" + "TEXTURE_TECH_PANEL_B", + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_I", + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_I", + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_I", + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_I" + }; + CubicObject[] aTextureData = new CubicObject[] {new CubicObject(aTexData)}; + return aTextureData; + } +} diff --git a/src/main/java/gtPlusPlus/core/block/machine/DecayablesChest.java b/src/main/java/gtPlusPlus/core/block/machine/DecayablesChest.java index 15d330defc..c3c49ff03f 100644 --- a/src/main/java/gtPlusPlus/core/block/machine/DecayablesChest.java +++ b/src/main/java/gtPlusPlus/core/block/machine/DecayablesChest.java @@ -26,198 +26,195 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -public class DecayablesChest extends BlockContainer implements ITileTooltip -{ - @SideOnly(Side.CLIENT) - private IIcon textureTop; - @SideOnly(Side.CLIENT) - private IIcon textureBottom; - @SideOnly(Side.CLIENT) - private IIcon textureFront; - - /** - * Determines which tooltip is displayed within the itemblock. - */ - private final int mTooltipID = 5; - public final int field_149956_a = 0; - - @Override - public int getTooltipID() { - return this.mTooltipID; - } - - @SuppressWarnings("deprecation") - public DecayablesChest() - { - super(Material.iron); - this.setBlockName("blockDecayablesChest"); - this.setCreativeTab(AddToCreativeTab.tabMachines); - this.setHardness(5f); - this.setResistance(1f); - GameRegistry.registerBlock(this, ItemBlockBasicTile.class, "blockDecayablesChest"); - LanguageRegistry.addName(this, "Lead Lined Box"); - this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F); - - } - - /** - * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two - * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block. - */ - public boolean isOpaqueCube() - { - return false; - } - - /** - * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) - */ - public boolean renderAsNormalBlock() - { - return false; - } - - /** - * The type of render function that is called for this block - */ - @SideOnly(Side.CLIENT) - public int getRenderType(){ - try { - if (RenderDecayChest.INSTANCE != null){ - return RenderDecayChest.INSTANCE.mRenderID; - } - return super.getRenderType(); - } - catch (NullPointerException n) { - return 0; - } - } - - /** - * Updates the blocks bounds based on its current state. Args: world, x, y, z - */ - public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) - { - if (p_149719_1_.getBlock(p_149719_2_, p_149719_3_, p_149719_4_ - 1) == this) - { - this.setBlockBounds(0.0625F, 0.0F, 0.0F, 0.9375F, 0.875F, 0.9375F); - } - else if (p_149719_1_.getBlock(p_149719_2_, p_149719_3_, p_149719_4_ + 1) == this) - { - this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 1.0F); - } - else if (p_149719_1_.getBlock(p_149719_2_ - 1, p_149719_3_, p_149719_4_) == this) - { - this.setBlockBounds(0.0F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F); - } - else if (p_149719_1_.getBlock(p_149719_2_ + 1, p_149719_3_, p_149719_4_) == this) - { - this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 1.0F, 0.875F, 0.9375F); - } - else - { - this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F); - } - } - - - /** - * Gets the block's texture. Args: side, meta - */ - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) - { - return p_149691_1_ == 1 ? this.textureTop : (p_149691_1_ == 0 ? this.textureBottom : this.textureFront); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister p_149651_1_) - { - this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "DecayablesChest_top"); - this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "DecayablesChest_top"); - this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "DecayablesChest_side"); - this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "DecayablesChest_bottom"); - } - - /** - * Called upon block activation (right click on the block.) - */ - @Override - public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz) - { - if (world.isRemote) { - return true; - } - - final TileEntity te = world.getTileEntity(x, y, z); - if ((te != null) && (te instanceof TileEntityDecayablesChest)){ - player.openGui(GTplusplus.instance, GuiHandler.GUI13, world, x, y, z); - return true; - } - return false; - } - - @Override - public int getRenderBlockPass() { - return 1; - } - - @Override - public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { - return new TileEntityDecayablesChest(); - } - - @Override - public void onBlockAdded(final World world, final int x, final int y, final int z) { - super.onBlockAdded(world, x, y, z); - } - - @Override - public void breakBlock(final World world, final int x, final int y, final int z, final Block block, final int number) { - InventoryUtils.dropInventoryItems(world, x, y, z, block); - super.breakBlock(world, x, y, z, block, number); - } - - @Override - public void onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase entity, final ItemStack stack) { - if (stack.hasDisplayName()) { - ((TileEntityDecayablesChest) world.getTileEntity(x,y,z)).setCustomName(stack.getDisplayName()); - } - } - - @Override - public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { - return false; - } - - /*@Override - public void breakBlock(World world, BlockPos pos, IBlockState blockstate) { - TileEntityFishTrap te = (TileEntityFishTrap) world.getTileEntity(pos); - InventoryHelper.dropInventoryItems(world, pos, te); - super.breakBlock(world, pos, blockstate); - } - - - @Override - public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { - if (stack.hasDisplayName()) { - ((TileEntityFishTrap) worldIn.getTileEntity(pos)).setCustomName(stack.getDisplayName()); - } - }*/ - - /** - * Update Chest Meta - Stub - * @param aWorld - * @param xPos - * @param yPos - * @param zPos - */ - @Deprecated - public void func_149954_e(World aWorld, int xPos, int yPos, int zPos) - { - - } - -} \ No newline at end of file +public class DecayablesChest extends BlockContainer implements ITileTooltip { + @SideOnly(Side.CLIENT) + private IIcon textureTop; + + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + /** + * Determines which tooltip is displayed within the itemblock. + */ + private final int mTooltipID = 5; + + public final int field_149956_a = 0; + + @Override + public int getTooltipID() { + return this.mTooltipID; + } + + @SuppressWarnings("deprecation") + public DecayablesChest() { + super(Material.iron); + this.setBlockName("blockDecayablesChest"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setHardness(5f); + this.setResistance(1f); + GameRegistry.registerBlock(this, ItemBlockBasicTile.class, "blockDecayablesChest"); + LanguageRegistry.addName(this, "Lead Lined Box"); + this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F); + } + + /** + * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two + * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block. + */ + public boolean isOpaqueCube() { + return false; + } + + /** + * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) + */ + public boolean renderAsNormalBlock() { + return false; + } + + /** + * The type of render function that is called for this block + */ + @SideOnly(Side.CLIENT) + public int getRenderType() { + try { + if (RenderDecayChest.INSTANCE != null) { + return RenderDecayChest.INSTANCE.mRenderID; + } + return super.getRenderType(); + } catch (NullPointerException n) { + return 0; + } + } + + /** + * Updates the blocks bounds based on its current state. Args: world, x, y, z + */ + public void setBlockBoundsBasedOnState( + IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) { + if (p_149719_1_.getBlock(p_149719_2_, p_149719_3_, p_149719_4_ - 1) == this) { + this.setBlockBounds(0.0625F, 0.0F, 0.0F, 0.9375F, 0.875F, 0.9375F); + } else if (p_149719_1_.getBlock(p_149719_2_, p_149719_3_, p_149719_4_ + 1) == this) { + this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 1.0F); + } else if (p_149719_1_.getBlock(p_149719_2_ - 1, p_149719_3_, p_149719_4_) == this) { + this.setBlockBounds(0.0F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F); + } else if (p_149719_1_.getBlock(p_149719_2_ + 1, p_149719_3_, p_149719_4_) == this) { + this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 1.0F, 0.875F, 0.9375F); + } else { + this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F); + } + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) { + return p_149691_1_ == 1 ? this.textureTop : (p_149691_1_ == 0 ? this.textureBottom : this.textureFront); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "DecayablesChest_top"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "DecayablesChest_top"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "DecayablesChest_side"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "DecayablesChest_bottom"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated( + final World world, + final int x, + final int y, + final int z, + final EntityPlayer player, + final int side, + final float lx, + final float ly, + final float lz) { + if (world.isRemote) { + return true; + } + + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityDecayablesChest)) { + player.openGui(GTplusplus.instance, GuiHandler.GUI13, world, x, y, z); + return true; + } + return false; + } + + @Override + public int getRenderBlockPass() { + return 1; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityDecayablesChest(); + } + + @Override + public void onBlockAdded(final World world, final int x, final int y, final int z) { + super.onBlockAdded(world, x, y, z); + } + + @Override + public void breakBlock( + final World world, final int x, final int y, final int z, final Block block, final int number) { + InventoryUtils.dropInventoryItems(world, x, y, z, block); + super.breakBlock(world, x, y, z, block, number); + } + + @Override + public void onBlockPlacedBy( + final World world, + final int x, + final int y, + final int z, + final EntityLivingBase entity, + final ItemStack stack) { + if (stack.hasDisplayName()) { + ((TileEntityDecayablesChest) world.getTileEntity(x, y, z)).setCustomName(stack.getDisplayName()); + } + } + + @Override + public boolean canCreatureSpawn( + final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + /*@Override + public void breakBlock(World world, BlockPos pos, IBlockState blockstate) { + TileEntityFishTrap te = (TileEntityFishTrap) world.getTileEntity(pos); + InventoryHelper.dropInventoryItems(world, pos, te); + super.breakBlock(world, pos, blockstate); + } + + + @Override + public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { + if (stack.hasDisplayName()) { + ((TileEntityFishTrap) worldIn.getTileEntity(pos)).setCustomName(stack.getDisplayName()); + } + }*/ + + /** + * Update Chest Meta - Stub + * @param aWorld + * @param xPos + * @param yPos + * @param zPos + */ + @Deprecated + public void func_149954_e(World aWorld, int xPos, int yPos, int zPos) {} +} diff --git a/src/main/java/gtPlusPlus/core/block/machine/EggBox.java b/src/main/java/gtPlusPlus/core/block/machine/EggBox.java index 630c4b5bc2..2950eeae98 100644 --- a/src/main/java/gtPlusPlus/core/block/machine/EggBox.java +++ b/src/main/java/gtPlusPlus/core/block/machine/EggBox.java @@ -25,151 +25,161 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -public class EggBox extends BlockContainer implements ITileTooltip -{ - @SideOnly(Side.CLIENT) - private IIcon textureTop; - @SideOnly(Side.CLIENT) - private IIcon textureBottom; - @SideOnly(Side.CLIENT) - private IIcon textureFront; - - /** - * Determines which tooltip is displayed within the itemblock. - */ - private final int mTooltipID = 7; - public final int field_149956_a = 0; - - @Override - public int getTooltipID() { - return this.mTooltipID; - } - - @SuppressWarnings("deprecation") - public EggBox(){ - super(Material.wood); - this.setBlockName("blockEggBox"); - this.setCreativeTab(AddToCreativeTab.tabMachines); - this.setHardness(5f); - this.setResistance(1f); - GameRegistry.registerBlock(this, ItemBlockBasicTile.class, "blockEggBox"); - LanguageRegistry.addName(this, "Egg Box"); - - } - - /** - * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) - */ - public boolean renderAsNormalBlock() - { - return true; - } - - /** - * The type of render function that is called for this block - */ - @SideOnly(Side.CLIENT) - public int getRenderType(){ - return super.getRenderType(); - } - - /** - * Gets the block's texture. Args: side, meta - */ - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) - { - return p_149691_1_ == 1 ? this.textureTop : this.textureFront; - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister p_149651_1_) - { - this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "EggBox_top"); - this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "EggBox_top"); - this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "EggBox_side"); - this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "EggBox_side"); - } - - /** - * Called upon block activation (right click on the block.) - */ - @Override - public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz) - { - if (world.isRemote) { - return true; - } - - final TileEntity te = world.getTileEntity(x, y, z); - if ((te != null) && (te instanceof TileEntityEggBox)){ - player.openGui(GTplusplus.instance, GuiHandler.GUI17, world, x, y, z); - return true; - } - return false; - } - - @Override - public int getRenderBlockPass() { - return 0; - } - - @Override - public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { - return new TileEntityEggBox(); - } - - @Override - public void onBlockAdded(final World world, final int x, final int y, final int z) { - super.onBlockAdded(world, x, y, z); - } - - @Override - public void breakBlock(final World world, final int x, final int y, final int z, final Block block, final int number) { - InventoryUtils.dropInventoryItems(world, x, y, z, block); - super.breakBlock(world, x, y, z, block, number); - } - - @Override - public void onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase entity, final ItemStack stack) { - if (stack.hasDisplayName()) { - ((TileEntityEggBox) world.getTileEntity(x,y,z)).setCustomName(stack.getDisplayName()); - } - } - - @Override - public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { - return false; - } - - /*@Override - public void breakBlock(World world, BlockPos pos, IBlockState blockstate) { - TileEntityFishTrap te = (TileEntityFishTrap) world.getTileEntity(pos); - InventoryHelper.dropInventoryItems(world, pos, te); - super.breakBlock(world, pos, blockstate); - } - - - @Override - public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { - if (stack.hasDisplayName()) { - ((TileEntityFishTrap) worldIn.getTileEntity(pos)).setCustomName(stack.getDisplayName()); - } - }*/ - - /** - * Update Chest Meta - Stub - * @param aWorld - * @param xPos - * @param yPos - * @param zPos - */ - @Deprecated - public void func_149954_e(World aWorld, int xPos, int yPos, int zPos) - { - - } - -} \ No newline at end of file +public class EggBox extends BlockContainer implements ITileTooltip { + @SideOnly(Side.CLIENT) + private IIcon textureTop; + + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + /** + * Determines which tooltip is displayed within the itemblock. + */ + private final int mTooltipID = 7; + + public final int field_149956_a = 0; + + @Override + public int getTooltipID() { + return this.mTooltipID; + } + + @SuppressWarnings("deprecation") + public EggBox() { + super(Material.wood); + this.setBlockName("blockEggBox"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setHardness(5f); + this.setResistance(1f); + GameRegistry.registerBlock(this, ItemBlockBasicTile.class, "blockEggBox"); + LanguageRegistry.addName(this, "Egg Box"); + } + + /** + * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) + */ + public boolean renderAsNormalBlock() { + return true; + } + + /** + * The type of render function that is called for this block + */ + @SideOnly(Side.CLIENT) + public int getRenderType() { + return super.getRenderType(); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) { + return p_149691_1_ == 1 ? this.textureTop : this.textureFront; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "EggBox_top"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "EggBox_top"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "EggBox_side"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "EggBox_side"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated( + final World world, + final int x, + final int y, + final int z, + final EntityPlayer player, + final int side, + final float lx, + final float ly, + final float lz) { + if (world.isRemote) { + return true; + } + + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityEggBox)) { + player.openGui(GTplusplus.instance, GuiHandler.GUI17, world, x, y, z); + return true; + } + return false; + } + + @Override + public int getRenderBlockPass() { + return 0; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityEggBox(); + } + + @Override + public void onBlockAdded(final World world, final int x, final int y, final int z) { + super.onBlockAdded(world, x, y, z); + } + + @Override + public void breakBlock( + final World world, final int x, final int y, final int z, final Block block, final int number) { + InventoryUtils.dropInventoryItems(world, x, y, z, block); + super.breakBlock(world, x, y, z, block, number); + } + + @Override + public void onBlockPlacedBy( + final World world, + final int x, + final int y, + final int z, + final EntityLivingBase entity, + final ItemStack stack) { + if (stack.hasDisplayName()) { + ((TileEntityEggBox) world.getTileEntity(x, y, z)).setCustomName(stack.getDisplayName()); + } + } + + @Override + public boolean canCreatureSpawn( + final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + /*@Override + public void breakBlock(World world, BlockPos pos, IBlockState blockstate) { + TileEntityFishTrap te = (TileEntityFishTrap) world.getTileEntity(pos); + InventoryHelper.dropInventoryItems(world, pos, te); + super.breakBlock(world, pos, blockstate); + } + + + @Override + public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { + if (stack.hasDisplayName()) { + ((TileEntityFishTrap) worldIn.getTileEntity(pos)).setCustomName(stack.getDisplayName()); + } + }*/ + + /** + * Update Chest Meta - Stub + * @param aWorld + * @param xPos + * @param yPos + * @param zPos + */ + @Deprecated + public void func_149954_e(World aWorld, int xPos, int yPos, int zPos) {} +} diff --git a/src/main/java/gtPlusPlus/core/block/machine/FishTrap.java b/src/main/java/gtPlusPlus/core/block/machine/FishTrap.java index 037ec61ced..0975b71ace 100644 --- a/src/main/java/gtPlusPlus/core/block/machine/FishTrap.java +++ b/src/main/java/gtPlusPlus/core/block/machine/FishTrap.java @@ -4,7 +4,13 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.interfaces.ITileTooltip; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.itemblock.ItemBlockBasicTile; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.general.TileEntityFishTrap; +import gtPlusPlus.core.util.minecraft.InventoryUtils; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -18,135 +24,144 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import gtPlusPlus.GTplusplus; -import gtPlusPlus.api.interfaces.ITileTooltip; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.item.base.itemblock.ItemBlockBasicTile; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.tileentities.general.TileEntityFishTrap; -import gtPlusPlus.core.util.minecraft.InventoryUtils; - -public class FishTrap extends BlockContainer implements ITileTooltip -{ - @SideOnly(Side.CLIENT) - private IIcon textureTop; - @SideOnly(Side.CLIENT) - private IIcon textureBottom; - @SideOnly(Side.CLIENT) - private IIcon textureFront; - - /** - * Determines which tooltip is displayed within the itemblock. - */ - private final int mTooltipID = 0; - - @Override - public int getTooltipID() { - return this.mTooltipID; - } - - @SuppressWarnings("deprecation") - public FishTrap() - { - super(Material.iron); - this.setBlockName("blockFishTrap"); - this.setHardness(5f); - this.setResistance(1f); - this.setCreativeTab(AddToCreativeTab.tabMachines); - GameRegistry.registerBlock(this, ItemBlockBasicTile.class, "blockFishTrap"); - LanguageRegistry.addName(this, "Fish Catcher"); - - } - - /** - * Gets the block's texture. Args: side, meta - */ - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) - { - return p_149691_1_ == 1 ? this.textureTop : (p_149691_1_ == 0 ? this.textureBottom : ((p_149691_1_ != 2) && (p_149691_1_ != 4) ? this.blockIcon : this.textureFront)); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister p_149651_1_) - { - this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "fishtrap"); - this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "fishtrap"); - this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "fishtrap"); - this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "fishtrap"); - } - - /** - * Called upon block activation (right click on the block.) - */ - @Override - public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz) - { - if (world.isRemote) { - return true; - } - - final TileEntity te = world.getTileEntity(x, y, z); - if ((te != null) && (te instanceof TileEntityFishTrap)){ - player.openGui(GTplusplus.instance, 5, world, x, y, z); - return true; - } - return false; - } - - @Override - public int getRenderBlockPass() { - return 1; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { - return new TileEntityFishTrap(); - } - - @Override - public void onBlockAdded(final World world, final int x, final int y, final int z) { - super.onBlockAdded(world, x, y, z); - } - - @Override - public void breakBlock(final World world, final int x, final int y, final int z, final Block block, final int number) { - InventoryUtils.dropInventoryItems(world, x, y, z, block); - super.breakBlock(world, x, y, z, block, number); - } - - @Override - public void onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase entity, final ItemStack stack) { - if (stack.hasDisplayName()) { - ((TileEntityFishTrap) world.getTileEntity(x,y,z)).setCustomName(stack.getDisplayName()); - } - } - - @Override - public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { - return false; - } - - /*@Override - public void breakBlock(World world, BlockPos pos, IBlockState blockstate) { - TileEntityFishTrap te = (TileEntityFishTrap) world.getTileEntity(pos); - InventoryHelper.dropInventoryItems(world, pos, te); - super.breakBlock(world, pos, blockstate); - } - - - @Override - public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { - if (stack.hasDisplayName()) { - ((TileEntityFishTrap) worldIn.getTileEntity(pos)).setCustomName(stack.getDisplayName()); - } - }*/ - -} \ No newline at end of file +public class FishTrap extends BlockContainer implements ITileTooltip { + @SideOnly(Side.CLIENT) + private IIcon textureTop; + + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + /** + * Determines which tooltip is displayed within the itemblock. + */ + private final int mTooltipID = 0; + + @Override + public int getTooltipID() { + return this.mTooltipID; + } + + @SuppressWarnings("deprecation") + public FishTrap() { + super(Material.iron); + this.setBlockName("blockFishTrap"); + this.setHardness(5f); + this.setResistance(1f); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockBasicTile.class, "blockFishTrap"); + LanguageRegistry.addName(this, "Fish Catcher"); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) { + return p_149691_1_ == 1 + ? this.textureTop + : (p_149691_1_ == 0 + ? this.textureBottom + : ((p_149691_1_ != 2) && (p_149691_1_ != 4) ? this.blockIcon : this.textureFront)); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "fishtrap"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "fishtrap"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "fishtrap"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "fishtrap"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated( + final World world, + final int x, + final int y, + final int z, + final EntityPlayer player, + final int side, + final float lx, + final float ly, + final float lz) { + if (world.isRemote) { + return true; + } + + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityFishTrap)) { + player.openGui(GTplusplus.instance, 5, world, x, y, z); + return true; + } + return false; + } + + @Override + public int getRenderBlockPass() { + return 1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityFishTrap(); + } + + @Override + public void onBlockAdded(final World world, final int x, final int y, final int z) { + super.onBlockAdded(world, x, y, z); + } + + @Override + public void breakBlock( + final World world, final int x, final int y, final int z, final Block block, final int number) { + InventoryUtils.dropInventoryItems(world, x, y, z, block); + super.breakBlock(world, x, y, z, block, number); + } + + @Override + public void onBlockPlacedBy( + final World world, + final int x, + final int y, + final int z, + final EntityLivingBase entity, + final ItemStack stack) { + if (stack.hasDisplayName()) { + ((TileEntityFishTrap) world.getTileEntity(x, y, z)).setCustomName(stack.getDisplayName()); + } + } + + @Override + public boolean canCreatureSpawn( + final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + /*@Override + public void breakBlock(World world, BlockPos pos, IBlockState blockstate) { + TileEntityFishTrap te = (TileEntityFishTrap) world.getTileEntity(pos); + InventoryHelper.dropInventoryItems(world, pos, te); + super.breakBlock(world, pos, blockstate); + } + + + @Override + public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { + if (stack.hasDisplayName()) { + ((TileEntityFishTrap) worldIn.getTileEntity(pos)).setCustomName(stack.getDisplayName()); + } + }*/ + +} diff --git a/src/main/java/gtPlusPlus/core/block/machine/HeliumGenerator.java b/src/main/java/gtPlusPlus/core/block/machine/HeliumGenerator.java index 5dc8604a93..4c7668b9e0 100644 --- a/src/main/java/gtPlusPlus/core/block/machine/HeliumGenerator.java +++ b/src/main/java/gtPlusPlus/core/block/machine/HeliumGenerator.java @@ -4,7 +4,10 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.GTplusplus; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.general.TileEntityHeliumGenerator; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -13,83 +16,85 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; -import gtPlusPlus.GTplusplus; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.tileentities.general.TileEntityHeliumGenerator; - -public class HeliumGenerator extends BlockContainer -{ - @SideOnly(Side.CLIENT) - private IIcon textureTop; - @SideOnly(Side.CLIENT) - private IIcon textureBottom; - @SideOnly(Side.CLIENT) - private IIcon textureFront; - +public class HeliumGenerator extends BlockContainer { + @SideOnly(Side.CLIENT) + private IIcon textureTop; - @SuppressWarnings("deprecation") - public HeliumGenerator() - { - super(Material.wood); - this.setBlockName("blockHeliumGenerator"); - this.setCreativeTab(AddToCreativeTab.tabMachines); - GameRegistry.registerBlock(this, "blockHeliumGenerator"); - LanguageRegistry.addName(this, "Helium Generator"); + @SideOnly(Side.CLIENT) + private IIcon textureBottom; - } + @SideOnly(Side.CLIENT) + private IIcon textureFront; - /** - * Gets the block's texture. Args: side, meta - */ - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) - { - return p_149691_1_ == 1 ? this.textureTop : (p_149691_1_ == 0 ? this.textureBottom : ((p_149691_1_ != 2) && (p_149691_1_ != 4) ? this.blockIcon : this.textureFront)); - } + @SuppressWarnings("deprecation") + public HeliumGenerator() { + super(Material.wood); + this.setBlockName("blockHeliumGenerator"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, "blockHeliumGenerator"); + LanguageRegistry.addName(this, "Helium Generator"); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister p_149651_1_) - { - this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "Chrono/" + "CyberPanel"); - this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "Chrono/" + "CyberPanel"); - this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "Chrono/" + "CyberPanel"); - this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "Chrono/" + "CyberPanel"); - } + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) { + return p_149691_1_ == 1 + ? this.textureTop + : (p_149691_1_ == 0 + ? this.textureBottom + : ((p_149691_1_ != 2) && (p_149691_1_ != 4) ? this.blockIcon : this.textureFront)); + } - /** - * Called upon block activation (right click on the block.) - */ - @Override - public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz) - { - if (world.isRemote) { - return true; - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "Chrono/" + "CyberPanel"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "Chrono/" + "CyberPanel"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "Chrono/" + "CyberPanel"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "Chrono/" + "CyberPanel"); + } - final TileEntity te = world.getTileEntity(x, y, z); - if ((te != null) && (te instanceof TileEntityHeliumGenerator)){ //TODO - player.openGui(GTplusplus.instance, 1, world, x, y, z); //TODO - return true; - } - return false; - } + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated( + final World world, + final int x, + final int y, + final int z, + final EntityPlayer player, + final int side, + final float lx, + final float ly, + final float lz) { + if (world.isRemote) { + return true; + } - @Override - public int getRenderBlockPass() { - return 1; - } + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityHeliumGenerator)) { // TODO + player.openGui(GTplusplus.instance, 1, world, x, y, z); // TODO + return true; + } + return false; + } - @Override - public boolean isOpaqueCube() { - return false; - } + @Override + public int getRenderBlockPass() { + return 1; + } - @Override - public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { - return new TileEntityHeliumGenerator(); - } + @Override + public boolean isOpaqueCube() { + return false; + } -} \ No newline at end of file + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityHeliumGenerator(); + } +} diff --git a/src/main/java/gtPlusPlus/core/block/machine/Machine_ModularityTable.java b/src/main/java/gtPlusPlus/core/block/machine/Machine_ModularityTable.java index 6f60d39ce7..124860cb27 100644 --- a/src/main/java/gtPlusPlus/core/block/machine/Machine_ModularityTable.java +++ b/src/main/java/gtPlusPlus/core/block/machine/Machine_ModularityTable.java @@ -4,7 +4,13 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.interfaces.ITileTooltip; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.itemblock.ItemBlockBasicTile; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.machines.TileEntityModularityTable; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -15,89 +21,91 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import gtPlusPlus.GTplusplus; -import gtPlusPlus.api.interfaces.ITileTooltip; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.item.base.itemblock.ItemBlockBasicTile; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.tileentities.machines.TileEntityModularityTable; - -public class Machine_ModularityTable extends BlockContainer implements ITileTooltip -{ - @SideOnly(Side.CLIENT) - private IIcon textureTop; - @SideOnly(Side.CLIENT) - private IIcon textureBottom; - @SideOnly(Side.CLIENT) - private IIcon textureFront; +public class Machine_ModularityTable extends BlockContainer implements ITileTooltip { + @SideOnly(Side.CLIENT) + private IIcon textureTop; - /** - * Determines which tooltip is displayed within the itemblock. - */ - private final int mTooltipID = 1; + @SideOnly(Side.CLIENT) + private IIcon textureBottom; - @Override - public int getTooltipID() { - return this.mTooltipID; - } + @SideOnly(Side.CLIENT) + private IIcon textureFront; - @SuppressWarnings("deprecation") - public Machine_ModularityTable() - { - super(Material.iron); - this.setBlockName("blockModularity"); - this.setCreativeTab(AddToCreativeTab.tabMachines); - GameRegistry.registerBlock(this, ItemBlockBasicTile.class, "blockModularity"); - LanguageRegistry.addName(this, "Modularity Configurator"); + /** + * Determines which tooltip is displayed within the itemblock. + */ + private final int mTooltipID = 1; - } + @Override + public int getTooltipID() { + return this.mTooltipID; + } - /** - * Gets the block's texture. Args: side, meta - */ - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) - { - return p_149691_1_ == 1 ? this.textureTop : (p_149691_1_ == 0 ? this.textureBottom : ((p_149691_1_ != 2) && (p_149691_1_ != 4) ? this.blockIcon : this.textureFront)); - } + @SuppressWarnings("deprecation") + public Machine_ModularityTable() { + super(Material.iron); + this.setBlockName("blockModularity"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockBasicTile.class, "blockModularity"); + LanguageRegistry.addName(this, "Modularity Configurator"); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister p_149651_1_) - { - this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "ModularTable_side"); - this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "ModularTable_top"); - this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "ModularTable_output"); - this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "ModularTable_side"); - } + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) { + return p_149691_1_ == 1 + ? this.textureTop + : (p_149691_1_ == 0 + ? this.textureBottom + : ((p_149691_1_ != 2) && (p_149691_1_ != 4) ? this.blockIcon : this.textureFront)); + } - /** - * Called upon block activation (right click on the block.) - */ - @Override - public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz){ - if (world.isRemote) { - return true; - } - final TileEntity te = world.getTileEntity(x, y, z); - if ((te != null) && (te instanceof TileEntityModularityTable)){ - player.openGui(GTplusplus.instance, 1, world, x, y, z); - Logger.INFO("Player opened GUI"); - return true; - } - return false; - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "ModularTable_side"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "ModularTable_top"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "ModularTable_output"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "ModularTable_side"); + } - @Override - public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { - return new TileEntityModularityTable(); - } + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated( + final World world, + final int x, + final int y, + final int z, + final EntityPlayer player, + final int side, + final float lx, + final float ly, + final float lz) { + if (world.isRemote) { + return true; + } + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityModularityTable)) { + player.openGui(GTplusplus.instance, 1, world, x, y, z); + Logger.INFO("Player opened GUI"); + return true; + } + return false; + } - @Override - public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { - return false; - } + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityModularityTable(); + } -} \ No newline at end of file + @Override + public boolean canCreatureSpawn( + final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/core/block/machine/Machine_PestKiller.java b/src/main/java/gtPlusPlus/core/block/machine/Machine_PestKiller.java index 11fa80f439..96fe4e20b1 100644 --- a/src/main/java/gtPlusPlus/core/block/machine/Machine_PestKiller.java +++ b/src/main/java/gtPlusPlus/core/block/machine/Machine_PestKiller.java @@ -6,7 +6,6 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.GTplusplus; import gtPlusPlus.api.interfaces.ITileTooltip; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.handler.GuiHandler; import gtPlusPlus.core.item.base.itemblock.ItemBlockBasicTile; @@ -26,112 +25,126 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -public class Machine_PestKiller extends BlockContainer implements ITileTooltip -{ - @SideOnly(Side.CLIENT) - private IIcon textureTop; - @SideOnly(Side.CLIENT) - private IIcon textureBottom; - @SideOnly(Side.CLIENT) - private IIcon textureFront; - - /** - * Determines which tooltip is displayed within the itemblock. - */ - private final int mTooltipID = 6; - - @Override - public int getTooltipID() { - return this.mTooltipID; - } - - @SuppressWarnings("deprecation") - public Machine_PestKiller() - { - super(Material.wood); - this.setBlockName("blockPestKiller"); - this.setHardness(5f); - this.setResistance(1f); - this.setCreativeTab(AddToCreativeTab.tabMachines); - GameRegistry.registerBlock(this, ItemBlockBasicTile.class, "blockPestKiller"); - LanguageRegistry.addName(this, "Pest Killer"); - - } - - /** - * Gets the block's texture. Args: side, meta - */ - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(final int aSide, final int p_149691_2_) - { - return aSide == 1 ? this.textureTop : (aSide == 0 ? this.textureBottom : this.textureFront); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister p_149651_1_) - { - this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "MACHINE_CASING_FARM_MANAGER_STRUCTURAL"); - this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "MACHINE_PESTKILLER_TOP"); - this.textureBottom = p_149651_1_.registerIcon("planks_acacia"); - this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "MACHINE_CASING_FARM_MANAGER_STRUCTURAL"); - } - - /** - * Called upon block activation (right click on the block.) - */ - @Override - public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz) - { - if (world.isRemote) { - return true; - } - - final TileEntity te = world.getTileEntity(x, y, z); - if ((te != null) && (te instanceof TileEntityPestKiller)){ - player.openGui(GTplusplus.instance, GuiHandler.GUI15, world, x, y, z); - return true; - } - return false; - } - - @Override - public int getRenderBlockPass() { - return 0; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { - return new TileEntityPestKiller(); - } - - @Override - public void onBlockAdded(final World world, final int x, final int y, final int z) { - super.onBlockAdded(world, x, y, z); - } - - @Override - public void breakBlock(final World world, final int x, final int y, final int z, final Block block, final int number) { - InventoryUtils.dropInventoryItems(world, x, y, z, block); - super.breakBlock(world, x, y, z, block, number); - } - - @Override - public void onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase entity, final ItemStack stack) { - if (stack.hasDisplayName()) { - ((TileEntityPestKiller) world.getTileEntity(x,y,z)).setCustomName(stack.getDisplayName()); - } - } - - @Override - public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { - return false; - } - -} \ No newline at end of file +public class Machine_PestKiller extends BlockContainer implements ITileTooltip { + @SideOnly(Side.CLIENT) + private IIcon textureTop; + + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + /** + * Determines which tooltip is displayed within the itemblock. + */ + private final int mTooltipID = 6; + + @Override + public int getTooltipID() { + return this.mTooltipID; + } + + @SuppressWarnings("deprecation") + public Machine_PestKiller() { + super(Material.wood); + this.setBlockName("blockPestKiller"); + this.setHardness(5f); + this.setResistance(1f); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockBasicTile.class, "blockPestKiller"); + LanguageRegistry.addName(this, "Pest Killer"); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int aSide, final int p_149691_2_) { + return aSide == 1 ? this.textureTop : (aSide == 0 ? this.textureBottom : this.textureFront); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.blockIcon = + p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "MACHINE_CASING_FARM_MANAGER_STRUCTURAL"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "MACHINE_PESTKILLER_TOP"); + this.textureBottom = p_149651_1_.registerIcon("planks_acacia"); + this.textureFront = + p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "MACHINE_CASING_FARM_MANAGER_STRUCTURAL"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated( + final World world, + final int x, + final int y, + final int z, + final EntityPlayer player, + final int side, + final float lx, + final float ly, + final float lz) { + if (world.isRemote) { + return true; + } + + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityPestKiller)) { + player.openGui(GTplusplus.instance, GuiHandler.GUI15, world, x, y, z); + return true; + } + return false; + } + + @Override + public int getRenderBlockPass() { + return 0; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityPestKiller(); + } + + @Override + public void onBlockAdded(final World world, final int x, final int y, final int z) { + super.onBlockAdded(world, x, y, z); + } + + @Override + public void breakBlock( + final World world, final int x, final int y, final int z, final Block block, final int number) { + InventoryUtils.dropInventoryItems(world, x, y, z, block); + super.breakBlock(world, x, y, z, block, number); + } + + @Override + public void onBlockPlacedBy( + final World world, + final int x, + final int y, + final int z, + final EntityLivingBase entity, + final ItemStack stack) { + if (stack.hasDisplayName()) { + ((TileEntityPestKiller) world.getTileEntity(x, y, z)).setCustomName(stack.getDisplayName()); + } + } + + @Override + public boolean canCreatureSpawn( + final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/core/block/machine/Machine_PooCollector.java b/src/main/java/gtPlusPlus/core/block/machine/Machine_PooCollector.java index 945cf7b581..374694ff48 100644 --- a/src/main/java/gtPlusPlus/core/block/machine/Machine_PooCollector.java +++ b/src/main/java/gtPlusPlus/core/block/machine/Machine_PooCollector.java @@ -1,8 +1,5 @@ package gtPlusPlus.core.block.machine; -import java.util.List; -import java.util.Random; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -14,6 +11,8 @@ import gtPlusPlus.core.tileentities.machines.TileEntityBaseFluidCollector; import gtPlusPlus.core.tileentities.machines.TileEntityPooCollector; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; +import java.util.List; +import java.util.Random; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -27,156 +26,166 @@ import net.minecraft.world.World; public class Machine_PooCollector extends BlockContainer { - @SideOnly(Side.CLIENT) - private IIcon textureTop; - @SideOnly(Side.CLIENT) - private IIcon textureTop2; - @SideOnly(Side.CLIENT) - private IIcon textureSide; - @SideOnly(Side.CLIENT) - private IIcon textureSide2; - - public Machine_PooCollector() { - super(Material.iron); - this.setHardness(5f); - this.setResistance(1f); - this.setBlockName("blockPooCollector"); - this.setCreativeTab(AddToCreativeTab.tabMachines); - GameRegistry.registerBlock(this, ItemBlockMeta.class,"blockPooCollector"); - } - - /** - * Gets the block's texture. Args: side, meta - */ - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(final int aSide, final int aMeta) { - if (aMeta <= 7) { - blockIcon = textureSide; - return aSide <= 1 ? this.textureTop : this.textureSide; - } - else { - blockIcon = textureSide2; - return aSide <= 1 ? this.textureTop2 : this.textureSide2; - } - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister p_149651_1_) { - this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "sewer_top"); - this.textureTop2 = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "sewer_adv_top"); - this.textureSide = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "sewer_sides"); - this.textureSide2 = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "sewer_adv_sides"); - } - - /** - * Called upon block activation (right click on the block.) - */ - @Override - public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, - final int side, final float lx, final float ly, final float lz) { - if (world.isRemote) { - return true; - } else { - TileEntityBaseFluidCollector tank = (TileEntityBaseFluidCollector) world.getTileEntity(x, y, z); - if (tank != null) { - Item handItem; - try { - handItem = player.getHeldItem().getItem(); - } catch (Throwable t) { - handItem = null; - } - - //Fluid container code - /*if (handItem != null - && (handItem instanceof IFluidContainerItem || handItem instanceof ItemFluidContainer - || FluidContainerRegistry.isFilledContainer(player.getHeldItem()))) { - if (tank.tank.getFluid() == null) { - try { - if (!FluidContainerRegistry.isFilledContainer(player.getHeldItem())) { - ItemStack handItemStack = player.getHeldItem(); - IFluidContainerItem container = (IFluidContainerItem) handItem; - FluidStack containerFluid = container.getFluid(handItemStack); - container.drain(handItemStack, container.getFluid(handItemStack).amount, true); - tank.tank.setFluid(containerFluid); - } else { - ItemStack handItemStack = player.getHeldItem(); - FluidContainerRegistry.drainFluidContainer(handItemStack); - FluidStack containerFluid = FluidContainerRegistry.getFluidForFilledItem(handItemStack); - ItemStack emptyContainer = FluidContainerRegistry.drainFluidContainer(handItemStack); - player.setItemInUse(emptyContainer, 0); - - tank.tank.setFluid(containerFluid); - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - - }*/ - - if (!tank.mInventory.isEmpty()) { - PlayerUtils.messagePlayer(player, "Inventory contains:"); - PlayerUtils.messagePlayer(player, ItemUtils.getArrayStackNames(tank.mInventory.getRealInventory())); - } - else { - PlayerUtils.messagePlayer(player, "No solids collected yet."); - } - if (tank.tank.getFluid() != null) { - PlayerUtils.messagePlayer(player, "Tank contains " + tank.tank.getFluidAmount() + "L of " - + tank.tank.getFluid().getLocalizedName()); - } - } - } - return true; - } - - @Override - public int getRenderBlockPass() { - return 0; - } - - @Override - public boolean isOpaqueCube() { - return super.isOpaqueCube(); - } - - @Override - public TileEntity createNewTileEntity(final World world, final int aMeta) { - return aMeta <= 7 ? new TileEntityPooCollector() : new TileEntityAdvPooCollector(); - } - - @Override - public void onBlockAdded(World world, int x, int y, int z) { - super.onBlockAdded(world, x, y, z); - } - - @Override - public int getBlockColor() { - // TODO Auto-generated method stub - return 0; - } - - @Override - public int damageDropped(final int damage) { - return damage; - } - - @Override - public Item getItemDropped(final int meta, final Random rand, final int fortune) { - return Item.getItemFromBlock(this); - } - - @Override - public int getRenderColor(int aMeta) { - return super.getRenderColor(aMeta); - } - - @Override - public void getSubBlocks(Item aItem, CreativeTabs aTab, List aList) { - aList.add(new ItemStack(aItem, 1, 0)); - aList.add(new ItemStack(aItem, 1, 8)); - } - + @SideOnly(Side.CLIENT) + private IIcon textureTop; + + @SideOnly(Side.CLIENT) + private IIcon textureTop2; + + @SideOnly(Side.CLIENT) + private IIcon textureSide; + + @SideOnly(Side.CLIENT) + private IIcon textureSide2; + + public Machine_PooCollector() { + super(Material.iron); + this.setHardness(5f); + this.setResistance(1f); + this.setBlockName("blockPooCollector"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockMeta.class, "blockPooCollector"); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int aSide, final int aMeta) { + if (aMeta <= 7) { + blockIcon = textureSide; + return aSide <= 1 ? this.textureTop : this.textureSide; + } else { + blockIcon = textureSide2; + return aSide <= 1 ? this.textureTop2 : this.textureSide2; + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "sewer_top"); + this.textureTop2 = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "sewer_adv_top"); + this.textureSide = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "sewer_sides"); + this.textureSide2 = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "sewer_adv_sides"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated( + final World world, + final int x, + final int y, + final int z, + final EntityPlayer player, + final int side, + final float lx, + final float ly, + final float lz) { + if (world.isRemote) { + return true; + } else { + TileEntityBaseFluidCollector tank = (TileEntityBaseFluidCollector) world.getTileEntity(x, y, z); + if (tank != null) { + Item handItem; + try { + handItem = player.getHeldItem().getItem(); + } catch (Throwable t) { + handItem = null; + } + + // Fluid container code + /*if (handItem != null + && (handItem instanceof IFluidContainerItem || handItem instanceof ItemFluidContainer + || FluidContainerRegistry.isFilledContainer(player.getHeldItem()))) { + if (tank.tank.getFluid() == null) { + try { + if (!FluidContainerRegistry.isFilledContainer(player.getHeldItem())) { + ItemStack handItemStack = player.getHeldItem(); + IFluidContainerItem container = (IFluidContainerItem) handItem; + FluidStack containerFluid = container.getFluid(handItemStack); + container.drain(handItemStack, container.getFluid(handItemStack).amount, true); + tank.tank.setFluid(containerFluid); + } else { + ItemStack handItemStack = player.getHeldItem(); + FluidContainerRegistry.drainFluidContainer(handItemStack); + FluidStack containerFluid = FluidContainerRegistry.getFluidForFilledItem(handItemStack); + ItemStack emptyContainer = FluidContainerRegistry.drainFluidContainer(handItemStack); + player.setItemInUse(emptyContainer, 0); + + tank.tank.setFluid(containerFluid); + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + + }*/ + + if (!tank.mInventory.isEmpty()) { + PlayerUtils.messagePlayer(player, "Inventory contains:"); + PlayerUtils.messagePlayer(player, ItemUtils.getArrayStackNames(tank.mInventory.getRealInventory())); + } else { + PlayerUtils.messagePlayer(player, "No solids collected yet."); + } + if (tank.tank.getFluid() != null) { + PlayerUtils.messagePlayer( + player, + "Tank contains " + tank.tank.getFluidAmount() + "L of " + + tank.tank.getFluid().getLocalizedName()); + } + } + } + return true; + } + + @Override + public int getRenderBlockPass() { + return 0; + } + + @Override + public boolean isOpaqueCube() { + return super.isOpaqueCube(); + } + + @Override + public TileEntity createNewTileEntity(final World world, final int aMeta) { + return aMeta <= 7 ? new TileEntityPooCollector() : new TileEntityAdvPooCollector(); + } + + @Override + public void onBlockAdded(World world, int x, int y, int z) { + super.onBlockAdded(world, x, y, z); + } + + @Override + public int getBlockColor() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int damageDropped(final int damage) { + return damage; + } + + @Override + public Item getItemDropped(final int meta, final Random rand, final int fortune) { + return Item.getItemFromBlock(this); + } + + @Override + public int getRenderColor(int aMeta) { + return super.getRenderColor(aMeta); + } + + @Override + public void getSubBlocks(Item aItem, CreativeTabs aTab, List aList) { + aList.add(new ItemStack(aItem, 1, 0)); + aList.add(new ItemStack(aItem, 1, 8)); + } } diff --git a/src/main/java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java b/src/main/java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java index fdb6b1a0a8..1959c20f70 100644 --- a/src/main/java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java +++ b/src/main/java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java @@ -5,18 +5,6 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.block.BlockContainer; -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.EnumCreatureType; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - import gtPlusPlus.GTplusplus; import gtPlusPlus.api.interfaces.ITileTooltip; import gtPlusPlus.api.objects.Logger; @@ -28,137 +16,155 @@ import gtPlusPlus.core.tileentities.machines.TileEntityProjectTable; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import ic2.core.item.tool.ItemToolWrench; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; @Optional.Interface(iface = "crazypants.enderio.api.tool.ITool", modid = "EnderIO") -public class Machine_ProjectTable extends BlockContainer implements ITileTooltip -{ - @SideOnly(Side.CLIENT) - private IIcon textureTop; - @SideOnly(Side.CLIENT) - private IIcon textureBottom; - @SideOnly(Side.CLIENT) - private IIcon textureFront; - - /** - * Determines which tooltip is displayed within the itemblock. - */ - private final int mTooltipID = 3; - - @Override - public int getTooltipID() { - return this.mTooltipID; - } - - @SuppressWarnings("deprecation") - public Machine_ProjectTable() - { - super(Material.iron); - this.setBlockName("blockProjectBench"); - this.setCreativeTab(AddToCreativeTab.tabMachines); - GameRegistry.registerBlock(this, ItemBlockBasicTile.class, "blockProjectBench"); - LanguageRegistry.addName(this, "Project Workbench"); - - } - - /** - * Gets the block's texture. Args: side, meta - */ - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) - { - return p_149691_1_ == 1 ? this.textureTop : (p_149691_1_ == 0 ? this.textureBottom : ((p_149691_1_ != 2) && (p_149691_1_ != 4) ? this.blockIcon : this.textureFront)); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister p_149651_1_) - { - this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "machine_top"); - this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "cover_crafting"); - this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "machine_top"); - this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "machine_top"); - } - - /** - * Called upon block activation (right click on the block.) - */ - @Override - public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz) - { - - ItemStack heldItem = null; - if (world.isRemote){ - heldItem = PlayerUtils.getItemStackInPlayersHand(); - } - - boolean holdingWrench = false; - - if (heldItem != null){ - holdingWrench = isWrench(heldItem); - } - - if (world.isRemote) { - return true; - } - - final TileEntity te = world.getTileEntity(x, y, z); - if ((te != null) && (te instanceof TileEntityProjectTable)) - { - if (!holdingWrench){ - player.openGui(GTplusplus.instance, 0, world, x, y, z); - return true; - } - Logger.INFO("Holding a Wrench, doing wrench things instead."); - } - return false; - } - - @Override - public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { - return new TileEntityProjectTable(); - } - - public static boolean isWrench(final ItemStack item){ - if (item.getItem() instanceof ItemToolWrench){ - return true; - } - if (LoadedMods.BuildCraft){ - return checkBuildcraftWrench(item); - } - if (LoadedMods.EnderIO){ - return checkEnderIOWrench(item); - } - return false; - } - - @Optional.Method(modid = "EnderIO") - private static boolean checkEnderIOWrench(final ItemStack item) { - if (ReflectionUtils.doesClassExist("crazypants.enderio.api.tool.ITool")) { - Class wrenchClass; - wrenchClass = ReflectionUtils.getClass("crazypants.enderio.api.tool.ITool"); - if (wrenchClass.isInstance(item.getItem())) { - return true; - } - } - return false; - } - - @Optional.Method(modid = "Buildcraft") - private static boolean checkBuildcraftWrench(final ItemStack item) { - if (ReflectionUtils.doesClassExist("buildcraft.api.tools.IToolWrench")) { - Class wrenchClass; - wrenchClass = ReflectionUtils.getClass("buildcraft.api.tools.IToolWrench"); - if (wrenchClass.isInstance(item.getItem())) { - return true; - } - } - return false; - } - - @Override - public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { - return false; - } - -} \ No newline at end of file +public class Machine_ProjectTable extends BlockContainer implements ITileTooltip { + @SideOnly(Side.CLIENT) + private IIcon textureTop; + + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + /** + * Determines which tooltip is displayed within the itemblock. + */ + private final int mTooltipID = 3; + + @Override + public int getTooltipID() { + return this.mTooltipID; + } + + @SuppressWarnings("deprecation") + public Machine_ProjectTable() { + super(Material.iron); + this.setBlockName("blockProjectBench"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockBasicTile.class, "blockProjectBench"); + LanguageRegistry.addName(this, "Project Workbench"); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) { + return p_149691_1_ == 1 + ? this.textureTop + : (p_149691_1_ == 0 + ? this.textureBottom + : ((p_149691_1_ != 2) && (p_149691_1_ != 4) ? this.blockIcon : this.textureFront)); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "machine_top"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "cover_crafting"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "machine_top"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "machine_top"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated( + final World world, + final int x, + final int y, + final int z, + final EntityPlayer player, + final int side, + final float lx, + final float ly, + final float lz) { + + ItemStack heldItem = null; + if (world.isRemote) { + heldItem = PlayerUtils.getItemStackInPlayersHand(); + } + + boolean holdingWrench = false; + + if (heldItem != null) { + holdingWrench = isWrench(heldItem); + } + + if (world.isRemote) { + return true; + } + + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityProjectTable)) { + if (!holdingWrench) { + player.openGui(GTplusplus.instance, 0, world, x, y, z); + return true; + } + Logger.INFO("Holding a Wrench, doing wrench things instead."); + } + return false; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityProjectTable(); + } + + public static boolean isWrench(final ItemStack item) { + if (item.getItem() instanceof ItemToolWrench) { + return true; + } + if (LoadedMods.BuildCraft) { + return checkBuildcraftWrench(item); + } + if (LoadedMods.EnderIO) { + return checkEnderIOWrench(item); + } + return false; + } + + @Optional.Method(modid = "EnderIO") + private static boolean checkEnderIOWrench(final ItemStack item) { + if (ReflectionUtils.doesClassExist("crazypants.enderio.api.tool.ITool")) { + Class wrenchClass; + wrenchClass = ReflectionUtils.getClass("crazypants.enderio.api.tool.ITool"); + if (wrenchClass.isInstance(item.getItem())) { + return true; + } + } + return false; + } + + @Optional.Method(modid = "Buildcraft") + private static boolean checkBuildcraftWrench(final ItemStack item) { + if (ReflectionUtils.doesClassExist("buildcraft.api.tools.IToolWrench")) { + Class wrenchClass; + wrenchClass = ReflectionUtils.getClass("buildcraft.api.tools.IToolWrench"); + if (wrenchClass.isInstance(item.getItem())) { + return true; + } + } + return false; + } + + @Override + public boolean canCreatureSpawn( + final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/core/block/machine/Machine_RoundRobinator.java b/src/main/java/gtPlusPlus/core/block/machine/Machine_RoundRobinator.java index dc87b885b9..caf961f91f 100644 --- a/src/main/java/gtPlusPlus/core/block/machine/Machine_RoundRobinator.java +++ b/src/main/java/gtPlusPlus/core/block/machine/Machine_RoundRobinator.java @@ -18,114 +18,119 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class Machine_RoundRobinator extends BasicTileBlockWithTooltip { - - - public Machine_RoundRobinator(){ - super(Material.iron); - } - - /** - * Called upon block activation (right click on the block.) - */ - @Override - public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz) - { - if (world.isRemote) { - return true; - } - else { - - boolean mDidScrewDriver = false; - // Check For Screwdriver - try { - final ItemStack mHandStack = PlayerUtils.getItemStackInPlayersHand(world, player.getDisplayName()); - if (ItemUtils.isToolScrewdriver(mHandStack)) { - final TileEntityRoundRobinator tile = (TileEntityRoundRobinator) world.getTileEntity(x, y, z); - if (tile != null) { - mDidScrewDriver = tile.onScrewdriverRightClick((byte) side, player, x, y, z); - } - } - } - catch (final Throwable t) {} - - if (!mDidScrewDriver) { - final TileEntity te = world.getTileEntity(x, y, z); - if ((te != null) && (te instanceof TileEntityRoundRobinator)){ - return ((TileEntityRoundRobinator) te).onRightClick((byte) side, player, x, y, z); - } - return false; - } - else { - return true; - } - } - } - - @Override - public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { - return new TileEntityRoundRobinator(); - } - - @Override - public int getMetaCount() { - return 5; - } - - @Override - public String getUnlocalBlockName() { - return "blockRoundRobinator"; - } - - @Override - protected float initBlockHardness() { - return 1; - } - - @Override - protected float initBlockResistance() { - return 1; - } - - @Override - protected CreativeTabs initCreativeTab() { - return AddToCreativeTab.tabMachines; - } - - @Override - public int getTooltipID() { - return -1; - } - - @Override - protected String getTileEntityName() { - return "Round Robinator"; - } - - @Override - public Class getItemBlockClass() { - return ItemBlockRoundRobinator.class; - } - - @Override - public CubicObject[] getCustomTextureDirectoryObject() { - AutoMap aTemp = new AutoMap(); - for (int i=0;i<5;i++) { - String[] aTexData = new String[] { - CORE.MODID + ":" + "TileEntities/RoundRobinator/Top_"+i, - CORE.MODID + ":" + "TileEntities/RoundRobinator/Top_"+i, - CORE.MODID + ":" + "TileEntities/RoundRobinator/Side_"+i, - CORE.MODID + ":" + "TileEntities/RoundRobinator/Side_"+i, - CORE.MODID + ":" + "TileEntities/RoundRobinator/Side_"+i, - CORE.MODID + ":" + "TileEntities/RoundRobinator/Side_"+i, - }; - aTemp.put(aTexData); - } - AutoMap> aTemp2 = new AutoMap>(); - for (String[] y : aTemp) { - aTemp2.put(new CubicObject(y)); - } - CubicObject[] aTextureData = new CubicObject[] {aTemp2.get(0), aTemp2.get(1), aTemp2.get(2), aTemp2.get(3), aTemp2.get(4)}; - return aTextureData; - } - -} \ No newline at end of file + + public Machine_RoundRobinator() { + super(Material.iron); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated( + final World world, + final int x, + final int y, + final int z, + final EntityPlayer player, + final int side, + final float lx, + final float ly, + final float lz) { + if (world.isRemote) { + return true; + } else { + + boolean mDidScrewDriver = false; + // Check For Screwdriver + try { + final ItemStack mHandStack = PlayerUtils.getItemStackInPlayersHand(world, player.getDisplayName()); + if (ItemUtils.isToolScrewdriver(mHandStack)) { + final TileEntityRoundRobinator tile = (TileEntityRoundRobinator) world.getTileEntity(x, y, z); + if (tile != null) { + mDidScrewDriver = tile.onScrewdriverRightClick((byte) side, player, x, y, z); + } + } + } catch (final Throwable t) { + } + + if (!mDidScrewDriver) { + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityRoundRobinator)) { + return ((TileEntityRoundRobinator) te).onRightClick((byte) side, player, x, y, z); + } + return false; + } else { + return true; + } + } + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityRoundRobinator(); + } + + @Override + public int getMetaCount() { + return 5; + } + + @Override + public String getUnlocalBlockName() { + return "blockRoundRobinator"; + } + + @Override + protected float initBlockHardness() { + return 1; + } + + @Override + protected float initBlockResistance() { + return 1; + } + + @Override + protected CreativeTabs initCreativeTab() { + return AddToCreativeTab.tabMachines; + } + + @Override + public int getTooltipID() { + return -1; + } + + @Override + protected String getTileEntityName() { + return "Round Robinator"; + } + + @Override + public Class getItemBlockClass() { + return ItemBlockRoundRobinator.class; + } + + @Override + public CubicObject[] getCustomTextureDirectoryObject() { + AutoMap aTemp = new AutoMap(); + for (int i = 0; i < 5; i++) { + String[] aTexData = new String[] { + CORE.MODID + ":" + "TileEntities/RoundRobinator/Top_" + i, + CORE.MODID + ":" + "TileEntities/RoundRobinator/Top_" + i, + CORE.MODID + ":" + "TileEntities/RoundRobinator/Side_" + i, + CORE.MODID + ":" + "TileEntities/RoundRobinator/Side_" + i, + CORE.MODID + ":" + "TileEntities/RoundRobinator/Side_" + i, + CORE.MODID + ":" + "TileEntities/RoundRobinator/Side_" + i, + }; + aTemp.put(aTexData); + } + AutoMap> aTemp2 = new AutoMap>(); + for (String[] y : aTemp) { + aTemp2.put(new CubicObject(y)); + } + CubicObject[] aTextureData = + new CubicObject[] {aTemp2.get(0), aTemp2.get(1), aTemp2.get(2), aTemp2.get(3), aTemp2.get(4)}; + return aTextureData; + } +} diff --git a/src/main/java/gtPlusPlus/core/block/machine/Machine_SuperJukebox.java b/src/main/java/gtPlusPlus/core/block/machine/Machine_SuperJukebox.java index 021279f820..cbf8323c07 100644 --- a/src/main/java/gtPlusPlus/core/block/machine/Machine_SuperJukebox.java +++ b/src/main/java/gtPlusPlus/core/block/machine/Machine_SuperJukebox.java @@ -26,50 +26,55 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; -public class Machine_SuperJukebox extends BlockJukebox -{ - @SideOnly(Side.CLIENT) - private IIcon mIcon; - - public Machine_SuperJukebox(){ - this.setBlockName("blockSuperJukebox"); - this.setCreativeTab(CreativeTabs.tabRedstone); - setHardness(2.0F); - setResistance(10.0F); - setStepSound(soundTypePiston); - setBlockTextureName("jukebox"); - GameRegistry.registerBlock(this, "blockSuperJukebox"); - LanguageRegistry.addName(this, "Sir Mixalot [Jukebox]"); - } - - /** - * Gets the block's texture. Args: side, meta - */ - @SideOnly(Side.CLIENT) - public IIcon getIcon(int aSide, int aMeta) - { - return aSide == 1 ? this.mIcon : this.blockIcon; - } - - /** - * Called upon block activation (right click on the block.) - */ - @Override - public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz) - { - if (world.isRemote) { - return true; - } - - final TileEntity te = world.getTileEntity(x, y, z); - if ((te != null) && (te instanceof TileEntitySuperJukebox)){ - player.openGui(GTplusplus.instance, GuiHandler.GUI14, world, x, y, z); - return true; - } - return false; - - - /* if (aWorld.getBlockMetadata(aX, aY, aZ) == 0) +public class Machine_SuperJukebox extends BlockJukebox { + @SideOnly(Side.CLIENT) + private IIcon mIcon; + + public Machine_SuperJukebox() { + this.setBlockName("blockSuperJukebox"); + this.setCreativeTab(CreativeTabs.tabRedstone); + setHardness(2.0F); + setResistance(10.0F); + setStepSound(soundTypePiston); + setBlockTextureName("jukebox"); + GameRegistry.registerBlock(this, "blockSuperJukebox"); + LanguageRegistry.addName(this, "Sir Mixalot [Jukebox]"); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @SideOnly(Side.CLIENT) + public IIcon getIcon(int aSide, int aMeta) { + return aSide == 1 ? this.mIcon : this.blockIcon; + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated( + final World world, + final int x, + final int y, + final int z, + final EntityPlayer player, + final int side, + final float lx, + final float ly, + final float lz) { + if (world.isRemote) { + return true; + } + + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntitySuperJukebox)) { + player.openGui(GTplusplus.instance, GuiHandler.GUI14, world, x, y, z); + return true; + } + return false; + + /* if (aWorld.getBlockMetadata(aX, aY, aZ) == 0) { return false; } @@ -78,502 +83,472 @@ public class Machine_SuperJukebox extends BlockJukebox this.func_149925_e(aWorld, aX, aY, aZ); return true; }*/ - } - - /** - * Set the record in the {@link SuperJukebox} {@link TileEntity}. - */ - @Override - public final void func_149926_b(World aWorld, int aX, int aY, int aZ, ItemStack aStackToSet) { - setRecordInJukeBox(aWorld, aX, aY, aZ, aStackToSet); - } - - public void setRecordInJukeBox(World aWorld, int aX, int aY, int aZ, ItemStack aStackToSet) { - if (!aWorld.isRemote) { - TileEntitySuperJukebox tileentityjukebox = (TileEntitySuperJukebox) aWorld.getTileEntity(aX, aY, aZ); - if (tileentityjukebox != null && aStackToSet.getItem() instanceof ItemRecord) { - tileentityjukebox.setCurrentRecord(aStackToSet.copy()); - //aWorld.setBlockMetadataWithNotify(aX, aY, aZ, 1, 2); - } - } - } - - /** - * Function to handle playing of records. - */ - @Override - public final void func_149925_e(World aWorld, int aX, int aY, int aZ) { - playJukeboxRecord(aWorld, aX, aY, aZ); - } - - public void playJukeboxRecord(World aWorld, int aX, int aY, int aZ) { - if (!aWorld.isRemote) { - TileEntitySuperJukebox tileentityjukebox = (TileEntitySuperJukebox) aWorld.getTileEntity(aX, - aY, aZ); - - if (tileentityjukebox != null) { - ItemStack itemstack = tileentityjukebox.func_145856_a(); - - if (itemstack != null) { - - - - aWorld.playAuxSFX(1005, aX, aY, aZ, Item.getIdFromItem(itemstack.getItem())); - //aWorld.playRecord((String) null, aX, aY, aZ); - //tileentityjukebox.func_145857_a((ItemStack) null); - //aWorld.setBlockMetadataWithNotify(aX, aY, aZ, 0, 2); - /*float f = 0.7F; - double d0 = (double) (aWorld.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D; - double d1 = (double) (aWorld.rand.nextFloat() * f) + (double) (1.0F - f) * 0.2D + 0.6D; - double d2 = (double) (aWorld.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D; - ItemStack itemstack1 = itemstack.copy(); - EntityItem entityitem = new EntityItem(aWorld, (double) aX + d0, - (double) aY + d1, (double) aZ + d2, itemstack1); - entityitem.delayBeforeCanPickup = 10; - aWorld.spawnEntityInWorld(entityitem);*/ - } - } - } - } - - @Override - public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) - { - this.func_149925_e(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_); - super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); - } - - /** - * Drops the block items with a specified chance of dropping the specified items - */ - @Override - public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_) - { - if (!p_149690_1_.isRemote) - { - super.dropBlockAsItemWithChance(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, p_149690_6_, 0); - } - } - - /** - * Returns a new instance of a block's tile entity class. Called on placing the block. - */ - @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) - { - return new TileEntitySuperJukebox(); - } - - @SideOnly(Side.CLIENT) - @Override - public void registerBlockIcons(IIconRegister p_149651_1_) - { - this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side"); - this.mIcon = p_149651_1_.registerIcon(this.getTextureName() + "_top"); - } - - public static class TileEntitySuperJukebox extends TileEntityJukebox implements ISidedInventory { - - /** The number of players currently using this chest */ - public int numPlayersUsing; - private ItemStack mCurrentlyPlayingStack; - private final Inventory_SuperJukebox inventoryContents; - private String customName; - - - /* - * Important Data - */ - - public int a_TEST_INT_VAR_1; - public int a_TEST_INT_VAR_2; - public int a_TEST_INT_VAR_3; - public int a_TEST_INT_VAR_4; - - public boolean mIsPlaying = false; - public boolean mIsLooping = false; - public boolean a_TEST_BOOL_VAR_3; - public boolean a_TEST_BOOL_VAR_4; - - - - public TileEntitySuperJukebox() { - this.inventoryContents = new Inventory_SuperJukebox(); - } - - @Override - public void readFromNBT(NBTTagCompound aNBT) { - super.readFromNBT(aNBT); - - if (aNBT.hasKey("RecordItem", 10)) { - this.func_145857_a(ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("RecordItem"))); - } else if (aNBT.getInteger("Record") > 0) { - this.func_145857_a(new ItemStack(Item.getItemById(aNBT.getInteger("Record")), 1, 0)); - } - - this.inventoryContents.readFromNBT(aNBT.getCompoundTag("ContentsChest")); - if (aNBT.hasKey("CustomName", 8)) { - this.setCustomName(aNBT.getString("CustomName")); - } - - mIsPlaying = aNBT.getBoolean("mIsPlaying"); - mIsLooping = aNBT.getBoolean("mIsLooping"); - - - } - - @Override - public void writeToNBT(NBTTagCompound aNBT) { - super.writeToNBT(aNBT); - - if (this.getCurrentRecord() != null) { - aNBT.setTag("RecordItem", this.func_145856_a().writeToNBT(new NBTTagCompound())); - aNBT.setInteger("Record", Item.getIdFromItem(this.func_145856_a().getItem())); - } - - final NBTTagCompound chestData = new NBTTagCompound(); - this.inventoryContents.writeToNBT(chestData); - aNBT.setTag("ContentsChest", chestData); - if (this.hasCustomInventoryName()) { - aNBT.setString("CustomName", this.getCustomName()); - } - - aNBT.setBoolean("mIsPlaying", mIsPlaying); - aNBT.setBoolean("mIsLooping", mIsLooping); - - } - - /** - * Called to get the internal stack - */ - @Override - public ItemStack func_145856_a() { - return this.mCurrentlyPlayingStack; - } - - /** - * Called to get the internal stack, wraps vanilla function - * {@link func_145856_a}. - */ - public ItemStack getCurrentRecord() { - return func_145856_a(); - } - - /** - * Called to set the internal stack - */ - @Override - public void func_145857_a(ItemStack p_145857_1_) { - this.mCurrentlyPlayingStack = p_145857_1_; - this.markDirty(); - } - - /** - * Called to set the internal stack, wraps vanilla function - * {@link func_145857_a}. - */ - public void setCurrentRecord(ItemStack aStack) { - func_145857_a(aStack); - this.markDirty(); - } - - public Inventory_SuperJukebox getInventory() { - return this.inventoryContents; - } - - - - - - public boolean playRecord(ItemStack aRecord) { - - - - return false; - } - - public boolean stopRecord() { - return openDiscDrive(); - } - - public void setLoopState(boolean isShufflingForever) { - - - - } - - - //Play button pressed - public boolean jukeboxLogicUpdate() { - - if (this.worldObj.isRemote) { - return true; - } - - Logger.INFO("a"); - if (this.mIsPlaying || this.mIsLooping) { - return selectRecordToPlayFromInventoryAndSetViaVanillaHandler(); - } - else { - return stopRecord(); - } - } - - - //Determine which record to play - public boolean selectRecordToPlayFromInventoryAndSetViaVanillaHandler() { - AutoMap mValidRecords = new AutoMap(); - for (ItemStack g : this.getInventory().getInventory()) { - if (g != null) { - if (g.getItem() instanceof ItemRecord) { - mValidRecords.put(g); - } - } - } - - Logger.INFO("b1"); - //Select First Record - ItemStack aRecordToPlay; - if (mValidRecords.size() == 0) { - Logger.INFO("bX"); - return false; - } - else { - aRecordToPlay = mValidRecords.get(!mIsLooping ? 0 : MathUtils.randInt(0, (mValidRecords.size()-1))); - } - Logger.INFO("b2 - "+aRecordToPlay.getDisplayName()); - - int aSlotCounter = 0; - for (ItemStack g : this.getInventory().getInventory()) { - if (g != null && aSlotCounter <= 17) { - Logger.INFO("b3 - "+g.getDisplayName()); - if (GT_Utility.areStacksEqual(g, aRecordToPlay, true)) { - IInventory aThisInv = this.getInventory(); - if (aThisInv.getStackInSlot(20) != null) { - openDiscDrive(); - } - - GT_Utility.moveStackFromSlotAToSlotB(aThisInv, aThisInv, aSlotCounter, 20, (byte) 1, (byte) 1, (byte) 1, (byte) 1); - setCurrentRecord(aThisInv.getStackInSlot(20)); - - World aWorld = this.worldObj; - int aX = this.xCoord; - int aY = this.yCoord; - int aZ = this.zCoord; - if (!aWorld.isRemote) { - aRecordToPlay = this.func_145856_a(); - if (aRecordToPlay != null) { - aWorld.playAuxSFX(1005, aX, aY, aZ, Item.getIdFromItem(aRecordToPlay.getItem())); - this.markDirty(); - return true; - } - } - - Logger.INFO("b++"); - this.markDirty(); - return false; - } - } - aSlotCounter++; - } - - - Logger.INFO("b4"); - this.markDirty(); - return false; - } - - - public boolean genericMethodThree(Object a1, Object a2, Object a3, Object a4) { - return false; - } - - - public void vanillaStopJukebox() { - World aWorld = this.worldObj; - int aX = this.xCoord; - int aY = this.yCoord; - int aZ = this.zCoord; - if (!aWorld.isRemote) { - TileEntitySuperJukebox tileentityjukebox = (TileEntitySuperJukebox) aWorld.getTileEntity(aX, aY, aZ); - if (tileentityjukebox != null) { - ItemStack aRecordToPlay = tileentityjukebox.func_145856_a(); - if (aRecordToPlay != null) { - aWorld.playAuxSFX(1005, aX, aY, aZ, 0); - aWorld.playRecord((String) null, aX, aY, aZ); - tileentityjukebox.func_145857_a((ItemStack) null); - this.markDirty(); - } - } - } - } - - public boolean openDiscDrive() { - int aSlotCounter = 17; - - ItemStack g; - - for (int i = 17; i >= 0; i--) { - g = this.getInventory().getInventory()[i]; - if (g == null && aSlotCounter >= 0) { - IInventory aThisInv = this.getInventory(); - GT_Utility.moveStackFromSlotAToSlotB(aThisInv, aThisInv, 20, i, (byte) 1, (byte) 1, (byte) 1, (byte) 1); - vanillaStopJukebox(); - Logger.INFO("b++"); - this.markDirty(); - return true; - - } - } - - - /*for (ItemStack g : this.getInventory().getInventory()) { - if (g == null && aSlotCounter >= 0) { - IInventory aThisInv = this.getInventory(); - GT_Utility.moveStackFromSlotAToSlotB(aThisInv, aThisInv, 20, aSlotCounter, (byte) 1, (byte) 1, (byte) 1, (byte) 1); - vanillaStopJukebox(); - Logger.INFO("b++"); - return true; - - } - aSlotCounter--; - } */ - this.markDirty(); - return false; - } - - - - - - - - - - - public boolean anyPlayerInRange() { - return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, - 32) != null; - } - - public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) { - if (!nbt.hasKey(tag)) { - nbt.setTag(tag, new NBTTagCompound()); - } - return nbt.getCompoundTag(tag); - } - - @Override - public int getSizeInventory() { - return this.getInventory().getSizeInventory()-3; - } - - @Override - public ItemStack getStackInSlot(final int slot) { - return this.getInventory().getStackInSlot(slot); - } - - @Override - public ItemStack decrStackSize(final int slot, final int count) { - return this.getInventory().decrStackSize(slot, count); - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) { - return this.getInventory().getStackInSlotOnClosing(slot); - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) { - this.getInventory().setInventorySlotContents(slot, stack); - } - - @Override - public int getInventoryStackLimit() { - return 1; - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) { - return this.getInventory().isUseableByPlayer(entityplayer); - } - - @Override - public void openInventory() { - if (this.numPlayersUsing < 0) { - this.numPlayersUsing = 0; - } - if (!this.worldObj.isRemote) { - this.numPlayersUsing++; - } - this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, - this.numPlayersUsing); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); - this.getInventory().openInventory(); - } - - @Override - public void closeInventory() { - if (!this.worldObj.isRemote) { - this.numPlayersUsing--; - } - this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, - this.numPlayersUsing); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); - this.getInventory().closeInventory(); - } - - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { - if (slot >= 18) { - return false; - } - return this.getInventory().isItemValidForSlot(slot, itemstack); - } - - private final static int[] SIDED_SLOTS = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; - - @Override - public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { - return SIDED_SLOTS; - - } - - @Override - public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { - if (p_102007_1_ >= 18) { - return false; - } - return this.getInventory().isItemValidForSlot(p_102007_1_, p_102007_2_); - } - - @Override - public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { - if (p_102008_1_ >= 18) { - return false; - } - return this.getInventory().isItemValidForSlot(p_102008_1_, p_102008_2_); - } - - public String getCustomName() { - return this.customName; - } - - public void setCustomName(final String customName) { - this.customName = customName; - } - - @Override - public String getInventoryName() { - return this.hasCustomInventoryName() ? this.customName : "container.SuperJukebox"; - } - - @Override - public boolean hasCustomInventoryName() { - return (this.customName != null) && !this.customName.equals(""); - } - - } -} \ No newline at end of file + } + + /** + * Set the record in the {@link SuperJukebox} {@link TileEntity}. + */ + @Override + public final void func_149926_b(World aWorld, int aX, int aY, int aZ, ItemStack aStackToSet) { + setRecordInJukeBox(aWorld, aX, aY, aZ, aStackToSet); + } + + public void setRecordInJukeBox(World aWorld, int aX, int aY, int aZ, ItemStack aStackToSet) { + if (!aWorld.isRemote) { + TileEntitySuperJukebox tileentityjukebox = (TileEntitySuperJukebox) aWorld.getTileEntity(aX, aY, aZ); + if (tileentityjukebox != null && aStackToSet.getItem() instanceof ItemRecord) { + tileentityjukebox.setCurrentRecord(aStackToSet.copy()); + // aWorld.setBlockMetadataWithNotify(aX, aY, aZ, 1, 2); + } + } + } + + /** + * Function to handle playing of records. + */ + @Override + public final void func_149925_e(World aWorld, int aX, int aY, int aZ) { + playJukeboxRecord(aWorld, aX, aY, aZ); + } + + public void playJukeboxRecord(World aWorld, int aX, int aY, int aZ) { + if (!aWorld.isRemote) { + TileEntitySuperJukebox tileentityjukebox = (TileEntitySuperJukebox) aWorld.getTileEntity(aX, aY, aZ); + + if (tileentityjukebox != null) { + ItemStack itemstack = tileentityjukebox.func_145856_a(); + + if (itemstack != null) { + + aWorld.playAuxSFX(1005, aX, aY, aZ, Item.getIdFromItem(itemstack.getItem())); + // aWorld.playRecord((String) null, aX, aY, aZ); + // tileentityjukebox.func_145857_a((ItemStack) null); + // aWorld.setBlockMetadataWithNotify(aX, aY, aZ, 0, 2); + /*float f = 0.7F; + double d0 = (double) (aWorld.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D; + double d1 = (double) (aWorld.rand.nextFloat() * f) + (double) (1.0F - f) * 0.2D + 0.6D; + double d2 = (double) (aWorld.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D; + ItemStack itemstack1 = itemstack.copy(); + EntityItem entityitem = new EntityItem(aWorld, (double) aX + d0, + (double) aY + d1, (double) aZ + d2, itemstack1); + entityitem.delayBeforeCanPickup = 10; + aWorld.spawnEntityInWorld(entityitem);*/ + } + } + } + } + + @Override + public void breakBlock( + World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) { + this.func_149925_e(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_); + super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + } + + /** + * Drops the block items with a specified chance of dropping the specified items + */ + @Override + public void dropBlockAsItemWithChance( + World p_149690_1_, + int p_149690_2_, + int p_149690_3_, + int p_149690_4_, + int p_149690_5_, + float p_149690_6_, + int p_149690_7_) { + if (!p_149690_1_.isRemote) { + super.dropBlockAsItemWithChance( + p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, p_149690_6_, 0); + } + } + + /** + * Returns a new instance of a block's tile entity class. Called on placing the block. + */ + @Override + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + return new TileEntitySuperJukebox(); + } + + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(IIconRegister p_149651_1_) { + this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side"); + this.mIcon = p_149651_1_.registerIcon(this.getTextureName() + "_top"); + } + + public static class TileEntitySuperJukebox extends TileEntityJukebox implements ISidedInventory { + + /** The number of players currently using this chest */ + public int numPlayersUsing; + + private ItemStack mCurrentlyPlayingStack; + private final Inventory_SuperJukebox inventoryContents; + private String customName; + + /* + * Important Data + */ + + public int a_TEST_INT_VAR_1; + public int a_TEST_INT_VAR_2; + public int a_TEST_INT_VAR_3; + public int a_TEST_INT_VAR_4; + + public boolean mIsPlaying = false; + public boolean mIsLooping = false; + public boolean a_TEST_BOOL_VAR_3; + public boolean a_TEST_BOOL_VAR_4; + + public TileEntitySuperJukebox() { + this.inventoryContents = new Inventory_SuperJukebox(); + } + + @Override + public void readFromNBT(NBTTagCompound aNBT) { + super.readFromNBT(aNBT); + + if (aNBT.hasKey("RecordItem", 10)) { + this.func_145857_a(ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("RecordItem"))); + } else if (aNBT.getInteger("Record") > 0) { + this.func_145857_a(new ItemStack(Item.getItemById(aNBT.getInteger("Record")), 1, 0)); + } + + this.inventoryContents.readFromNBT(aNBT.getCompoundTag("ContentsChest")); + if (aNBT.hasKey("CustomName", 8)) { + this.setCustomName(aNBT.getString("CustomName")); + } + + mIsPlaying = aNBT.getBoolean("mIsPlaying"); + mIsLooping = aNBT.getBoolean("mIsLooping"); + } + + @Override + public void writeToNBT(NBTTagCompound aNBT) { + super.writeToNBT(aNBT); + + if (this.getCurrentRecord() != null) { + aNBT.setTag("RecordItem", this.func_145856_a().writeToNBT(new NBTTagCompound())); + aNBT.setInteger( + "Record", Item.getIdFromItem(this.func_145856_a().getItem())); + } + + final NBTTagCompound chestData = new NBTTagCompound(); + this.inventoryContents.writeToNBT(chestData); + aNBT.setTag("ContentsChest", chestData); + if (this.hasCustomInventoryName()) { + aNBT.setString("CustomName", this.getCustomName()); + } + + aNBT.setBoolean("mIsPlaying", mIsPlaying); + aNBT.setBoolean("mIsLooping", mIsLooping); + } + + /** + * Called to get the internal stack + */ + @Override + public ItemStack func_145856_a() { + return this.mCurrentlyPlayingStack; + } + + /** + * Called to get the internal stack, wraps vanilla function + * {@link func_145856_a}. + */ + public ItemStack getCurrentRecord() { + return func_145856_a(); + } + + /** + * Called to set the internal stack + */ + @Override + public void func_145857_a(ItemStack p_145857_1_) { + this.mCurrentlyPlayingStack = p_145857_1_; + this.markDirty(); + } + + /** + * Called to set the internal stack, wraps vanilla function + * {@link func_145857_a}. + */ + public void setCurrentRecord(ItemStack aStack) { + func_145857_a(aStack); + this.markDirty(); + } + + public Inventory_SuperJukebox getInventory() { + return this.inventoryContents; + } + + public boolean playRecord(ItemStack aRecord) { + + return false; + } + + public boolean stopRecord() { + return openDiscDrive(); + } + + public void setLoopState(boolean isShufflingForever) {} + + // Play button pressed + public boolean jukeboxLogicUpdate() { + + if (this.worldObj.isRemote) { + return true; + } + + Logger.INFO("a"); + if (this.mIsPlaying || this.mIsLooping) { + return selectRecordToPlayFromInventoryAndSetViaVanillaHandler(); + } else { + return stopRecord(); + } + } + + // Determine which record to play + public boolean selectRecordToPlayFromInventoryAndSetViaVanillaHandler() { + AutoMap mValidRecords = new AutoMap(); + for (ItemStack g : this.getInventory().getInventory()) { + if (g != null) { + if (g.getItem() instanceof ItemRecord) { + mValidRecords.put(g); + } + } + } + + Logger.INFO("b1"); + // Select First Record + ItemStack aRecordToPlay; + if (mValidRecords.size() == 0) { + Logger.INFO("bX"); + return false; + } else { + aRecordToPlay = mValidRecords.get(!mIsLooping ? 0 : MathUtils.randInt(0, (mValidRecords.size() - 1))); + } + Logger.INFO("b2 - " + aRecordToPlay.getDisplayName()); + + int aSlotCounter = 0; + for (ItemStack g : this.getInventory().getInventory()) { + if (g != null && aSlotCounter <= 17) { + Logger.INFO("b3 - " + g.getDisplayName()); + if (GT_Utility.areStacksEqual(g, aRecordToPlay, true)) { + IInventory aThisInv = this.getInventory(); + if (aThisInv.getStackInSlot(20) != null) { + openDiscDrive(); + } + + GT_Utility.moveStackFromSlotAToSlotB( + aThisInv, aThisInv, aSlotCounter, 20, (byte) 1, (byte) 1, (byte) 1, (byte) 1); + setCurrentRecord(aThisInv.getStackInSlot(20)); + + World aWorld = this.worldObj; + int aX = this.xCoord; + int aY = this.yCoord; + int aZ = this.zCoord; + if (!aWorld.isRemote) { + aRecordToPlay = this.func_145856_a(); + if (aRecordToPlay != null) { + aWorld.playAuxSFX(1005, aX, aY, aZ, Item.getIdFromItem(aRecordToPlay.getItem())); + this.markDirty(); + return true; + } + } + + Logger.INFO("b++"); + this.markDirty(); + return false; + } + } + aSlotCounter++; + } + + Logger.INFO("b4"); + this.markDirty(); + return false; + } + + public boolean genericMethodThree(Object a1, Object a2, Object a3, Object a4) { + return false; + } + + public void vanillaStopJukebox() { + World aWorld = this.worldObj; + int aX = this.xCoord; + int aY = this.yCoord; + int aZ = this.zCoord; + if (!aWorld.isRemote) { + TileEntitySuperJukebox tileentityjukebox = (TileEntitySuperJukebox) aWorld.getTileEntity(aX, aY, aZ); + if (tileentityjukebox != null) { + ItemStack aRecordToPlay = tileentityjukebox.func_145856_a(); + if (aRecordToPlay != null) { + aWorld.playAuxSFX(1005, aX, aY, aZ, 0); + aWorld.playRecord((String) null, aX, aY, aZ); + tileentityjukebox.func_145857_a((ItemStack) null); + this.markDirty(); + } + } + } + } + + public boolean openDiscDrive() { + int aSlotCounter = 17; + + ItemStack g; + + for (int i = 17; i >= 0; i--) { + g = this.getInventory().getInventory()[i]; + if (g == null && aSlotCounter >= 0) { + IInventory aThisInv = this.getInventory(); + GT_Utility.moveStackFromSlotAToSlotB( + aThisInv, aThisInv, 20, i, (byte) 1, (byte) 1, (byte) 1, (byte) 1); + vanillaStopJukebox(); + Logger.INFO("b++"); + this.markDirty(); + return true; + } + } + + /*for (ItemStack g : this.getInventory().getInventory()) { + if (g == null && aSlotCounter >= 0) { + IInventory aThisInv = this.getInventory(); + GT_Utility.moveStackFromSlotAToSlotB(aThisInv, aThisInv, 20, aSlotCounter, (byte) 1, (byte) 1, (byte) 1, (byte) 1); + vanillaStopJukebox(); + Logger.INFO("b++"); + return true; + + } + aSlotCounter--; + } */ + this.markDirty(); + return false; + } + + public boolean anyPlayerInRange() { + return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) + != null; + } + + public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) { + if (!nbt.hasKey(tag)) { + nbt.setTag(tag, new NBTTagCompound()); + } + return nbt.getCompoundTag(tag); + } + + @Override + public int getSizeInventory() { + return this.getInventory().getSizeInventory() - 3; + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.getInventory().getStackInSlot(slot); + } + + @Override + public ItemStack decrStackSize(final int slot, final int count) { + return this.getInventory().decrStackSize(slot, count); + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + return this.getInventory().getStackInSlotOnClosing(slot); + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.getInventory().setInventorySlotContents(slot, stack); + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return this.getInventory().isUseableByPlayer(entityplayer); + } + + @Override + public void openInventory() { + if (this.numPlayersUsing < 0) { + this.numPlayersUsing = 0; + } + if (!this.worldObj.isRemote) { + this.numPlayersUsing++; + } + this.worldObj.addBlockEvent( + this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.numPlayersUsing); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + this.getInventory().openInventory(); + } + + @Override + public void closeInventory() { + if (!this.worldObj.isRemote) { + this.numPlayersUsing--; + } + this.worldObj.addBlockEvent( + this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.numPlayersUsing); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + this.getInventory().closeInventory(); + } + + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + if (slot >= 18) { + return false; + } + return this.getInventory().isItemValidForSlot(slot, itemstack); + } + + private static final int[] SIDED_SLOTS = + new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + return SIDED_SLOTS; + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + if (p_102007_1_ >= 18) { + return false; + } + return this.getInventory().isItemValidForSlot(p_102007_1_, p_102007_2_); + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + if (p_102008_1_ >= 18) { + return false; + } + return this.getInventory().isItemValidForSlot(p_102008_1_, p_102008_2_); + } + + public String getCustomName() { + return this.customName; + } + + public void setCustomName(final String customName) { + this.customName = customName; + } + + @Override + public String getInventoryName() { + return this.hasCustomInventoryName() ? this.customName : "container.SuperJukebox"; + } + + @Override + public boolean hasCustomInventoryName() { + return (this.customName != null) && !this.customName.equals(""); + } + } +} diff --git a/src/main/java/gtPlusPlus/core/block/machine/Machine_TradeTable.java b/src/main/java/gtPlusPlus/core/block/machine/Machine_TradeTable.java index 5195e0f18c..96102017a3 100644 --- a/src/main/java/gtPlusPlus/core/block/machine/Machine_TradeTable.java +++ b/src/main/java/gtPlusPlus/core/block/machine/Machine_TradeTable.java @@ -2,7 +2,12 @@ package gtPlusPlus.core.block.machine; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.interfaces.ITileTooltip; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.base.BlockBaseNBT; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.machines.TileEntityTradeTable; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EnumCreatureType; @@ -12,75 +17,76 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import gtPlusPlus.GTplusplus; -import gtPlusPlus.api.interfaces.ITileTooltip; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.block.base.BlockBaseNBT; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.tileentities.machines.TileEntityTradeTable; +public class Machine_TradeTable extends BlockBaseNBT implements ITileTooltip { + @SideOnly(Side.CLIENT) + private IIcon textureTop; -public class Machine_TradeTable extends BlockBaseNBT implements ITileTooltip -{ - @SideOnly(Side.CLIENT) - private IIcon textureTop; - @SideOnly(Side.CLIENT) - private IIcon textureBottom; - @SideOnly(Side.CLIENT) - private IIcon textureFront; + @SideOnly(Side.CLIENT) + private IIcon textureBottom; - /** - * Determines which tooltip is displayed within the itemblock. - */ - private final int mTooltipID = 2; + @SideOnly(Side.CLIENT) + private IIcon textureFront; - @Override - public int getTooltipID() { - return this.mTooltipID; - } + /** + * Determines which tooltip is displayed within the itemblock. + */ + private final int mTooltipID = 2; - public Machine_TradeTable(){ - super(Material.leaves, "blockTradeBench", "Trade-o-Mat"); - } + @Override + public int getTooltipID() { + return this.mTooltipID; + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister p_149651_1_){ - this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlYellow"); - this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "workbench_top"); - this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlYellow"); - this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlYellow"); - } + public Machine_TradeTable() { + super(Material.leaves, "blockTradeBench", "Trade-o-Mat"); + } - /** - * Called upon block activation (right click on the block.) - */ - @Override - public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz){ - if (world.isRemote) { - return true; - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlYellow"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "workbench_top"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlYellow"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlYellow"); + } - final TileEntity te = world.getTileEntity(x, y, z); - if ((te != null) && (te instanceof TileEntityTradeTable)) - { - //Utils.LOG_INFO("Clicked on TE - ok"); - player.openGui(GTplusplus.instance, 6, world, x, y, z); - return true; - } - else { - Logger.INFO("Bad TE"); - } - return false; - } + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated( + final World world, + final int x, + final int y, + final int z, + final EntityPlayer player, + final int side, + final float lx, + final float ly, + final float lz) { + if (world.isRemote) { + return true; + } - @Override - public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { - return new TileEntityTradeTable(); - } + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityTradeTable)) { + // Utils.LOG_INFO("Clicked on TE - ok"); + player.openGui(GTplusplus.instance, 6, world, x, y, z); + return true; + } else { + Logger.INFO("Bad TE"); + } + return false; + } - @Override - public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { - return false; - } + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityTradeTable(); + } -} \ No newline at end of file + @Override + public boolean canCreatureSpawn( + final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/core/block/machine/Machine_WireiusDeletus.java b/src/main/java/gtPlusPlus/core/block/machine/Machine_WireiusDeletus.java index e964a9da01..688dfbb742 100644 --- a/src/main/java/gtPlusPlus/core/block/machine/Machine_WireiusDeletus.java +++ b/src/main/java/gtPlusPlus/core/block/machine/Machine_WireiusDeletus.java @@ -1,5 +1,4 @@ package gtPlusPlus.core.block.machine; -public class Machine_WireiusDeletus { //A Block that removes GT Cable and Wire from it's inventory. - +public class Machine_WireiusDeletus { // A Block that removes GT Cable and Wire from it's inventory. } diff --git a/src/main/java/gtPlusPlus/core/block/machine/VolumetricFlaskSetter.java b/src/main/java/gtPlusPlus/core/block/machine/VolumetricFlaskSetter.java index 90f9c1056a..f4c4d4e17f 100644 --- a/src/main/java/gtPlusPlus/core/block/machine/VolumetricFlaskSetter.java +++ b/src/main/java/gtPlusPlus/core/block/machine/VolumetricFlaskSetter.java @@ -9,7 +9,6 @@ import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.handler.GuiHandler; import gtPlusPlus.core.item.base.itemblock.ItemBlockBasicTile; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.network.packet.Packet_VolumetricFlaskGui2; import gtPlusPlus.core.tileentities.general.TileEntityVolumetricFlaskSetter; import gtPlusPlus.core.util.minecraft.PlayerUtils; import net.minecraft.block.material.Material; @@ -26,139 +25,151 @@ import net.minecraft.world.World; public class VolumetricFlaskSetter extends BasicTileBlockWithTooltip { - /** - * Determines which tooltip is displayed within the itemblock. - */ - private final int mTooltipID = 8; - - @Override - public int getTooltipID() { - return this.mTooltipID; - } - - @Override - public Class getItemBlockClass() { - return ItemBlockBasicTile.class; - } - - @SuppressWarnings("deprecation") - public VolumetricFlaskSetter(){ - super(Material.iron); - LanguageRegistry.addName(this, "Volumetric Flask Configurator"); - } - - /** - * Called upon block activation (right click on the block.) - */ - @Override - public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz) - { - if (world.isRemote) { - return true; - } - else { - - boolean mDidScrewDriver = false; - // Check For Screwdriver - try { - final ItemStack mHandStack = PlayerUtils.getItemStackInPlayersHand(world, player.getDisplayName()); - final Item mHandItem = mHandStack.getItem(); - if (((mHandItem instanceof GT_MetaGenerated_Tool_01) - && ((mHandItem.getDamage(mHandStack) == 22) || (mHandItem.getDamage(mHandStack) == 150)))) { - final TileEntityVolumetricFlaskSetter tile = (TileEntityVolumetricFlaskSetter) world.getTileEntity(x, y, z); - if (tile != null) { - mDidScrewDriver = tile.onScrewdriverRightClick((byte) side, player, x, y, z); - } - } - } - catch (final Throwable t) {} - - if (!mDidScrewDriver) { - final TileEntity te = world.getTileEntity(x, y, z); - if ((te != null) && (te instanceof TileEntityVolumetricFlaskSetter)){ - player.openGui(GTplusplus.instance, GuiHandler.GUI18, world, x, y, z); - TileEntityVolumetricFlaskSetter aTile = (TileEntityVolumetricFlaskSetter) te; - //new Packet_VolumetricFlaskGui2(aTile, aTile.getCustomValue()); - return true; - } - } - else { - return true; - } - - } - return false; - } - - @Override - public int getRenderBlockPass() { - return 0; - } - - @Override - public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { - return new TileEntityVolumetricFlaskSetter(); - } - - @Override - public void onBlockAdded(final World world, final int x, final int y, final int z) { - super.onBlockAdded(world, x, y, z); - } - - @Override - public void onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase entity, final ItemStack stack) { - if (stack.hasDisplayName()) { - ((TileEntityVolumetricFlaskSetter) world.getTileEntity(x,y,z)).setCustomName(stack.getDisplayName()); - } - } - - @Override - public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { - return false; - } - - @Override - public int getMetaCount() { - return 0; - } - - @Override - public String getUnlocalBlockName() { - return "blockVolumetricFlaskSetter"; - } - - @Override - protected float initBlockHardness() { - return 5f; - } - - @Override - protected float initBlockResistance() { - return 1f; - } - - @Override - protected CreativeTabs initCreativeTab() { - return AddToCreativeTab.tabMachines; - } - - @Override - protected String getTileEntityName() { - return "Volumetric Flask Configurator"; - } - - @Override - public CubicObject[] getCustomTextureDirectoryObject() { - String[] aTexData = new String[] { - CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_A", - CORE.MODID + ":" + "metro/" + "TEXTURE_TECH_PANEL_C", - CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_H", - CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_H", - CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_H", - CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_H" - }; - CubicObject[] aTextureData = new CubicObject[] {new CubicObject(aTexData)}; - return aTextureData; - } - -} \ No newline at end of file + /** + * Determines which tooltip is displayed within the itemblock. + */ + private final int mTooltipID = 8; + + @Override + public int getTooltipID() { + return this.mTooltipID; + } + + @Override + public Class getItemBlockClass() { + return ItemBlockBasicTile.class; + } + + @SuppressWarnings("deprecation") + public VolumetricFlaskSetter() { + super(Material.iron); + LanguageRegistry.addName(this, "Volumetric Flask Configurator"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated( + final World world, + final int x, + final int y, + final int z, + final EntityPlayer player, + final int side, + final float lx, + final float ly, + final float lz) { + if (world.isRemote) { + return true; + } else { + + boolean mDidScrewDriver = false; + // Check For Screwdriver + try { + final ItemStack mHandStack = PlayerUtils.getItemStackInPlayersHand(world, player.getDisplayName()); + final Item mHandItem = mHandStack.getItem(); + if (((mHandItem instanceof GT_MetaGenerated_Tool_01) + && ((mHandItem.getDamage(mHandStack) == 22) || (mHandItem.getDamage(mHandStack) == 150)))) { + final TileEntityVolumetricFlaskSetter tile = + (TileEntityVolumetricFlaskSetter) world.getTileEntity(x, y, z); + if (tile != null) { + mDidScrewDriver = tile.onScrewdriverRightClick((byte) side, player, x, y, z); + } + } + } catch (final Throwable t) { + } + + if (!mDidScrewDriver) { + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityVolumetricFlaskSetter)) { + player.openGui(GTplusplus.instance, GuiHandler.GUI18, world, x, y, z); + TileEntityVolumetricFlaskSetter aTile = (TileEntityVolumetricFlaskSetter) te; + // new Packet_VolumetricFlaskGui2(aTile, aTile.getCustomValue()); + return true; + } + } else { + return true; + } + } + return false; + } + + @Override + public int getRenderBlockPass() { + return 0; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityVolumetricFlaskSetter(); + } + + @Override + public void onBlockAdded(final World world, final int x, final int y, final int z) { + super.onBlockAdded(world, x, y, z); + } + + @Override + public void onBlockPlacedBy( + final World world, + final int x, + final int y, + final int z, + final EntityLivingBase entity, + final ItemStack stack) { + if (stack.hasDisplayName()) { + ((TileEntityVolumetricFlaskSetter) world.getTileEntity(x, y, z)).setCustomName(stack.getDisplayName()); + } + } + + @Override + public boolean canCreatureSpawn( + final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + @Override + public int getMetaCount() { + return 0; + } + + @Override + public String getUnlocalBlockName() { + return "blockVolumetricFlaskSetter"; + } + + @Override + protected float initBlockHardness() { + return 5f; + } + + @Override + protected float initBlockResistance() { + return 1f; + } + + @Override + protected CreativeTabs initCreativeTab() { + return AddToCreativeTab.tabMachines; + } + + @Override + protected String getTileEntityName() { + return "Volumetric Flask Configurator"; + } + + @Override + public CubicObject[] getCustomTextureDirectoryObject() { + String[] aTexData = new String[] { + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_A", + CORE.MODID + ":" + "metro/" + "TEXTURE_TECH_PANEL_C", + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_H", + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_H", + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_H", + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_H" + }; + CubicObject[] aTextureData = new CubicObject[] {new CubicObject(aTexData)}; + return aTextureData; + } +} diff --git a/src/main/java/gtPlusPlus/core/block/machine/bedrock/Mining_Head_Fake.java b/src/main/java/gtPlusPlus/core/block/machine/bedrock/Mining_Head_Fake.java index b8f9662ac7..00a5b97e2c 100644 --- a/src/main/java/gtPlusPlus/core/block/machine/bedrock/Mining_Head_Fake.java +++ b/src/main/java/gtPlusPlus/core/block/machine/bedrock/Mining_Head_Fake.java @@ -1,11 +1,15 @@ package gtPlusPlus.core.block.machine.bedrock; -import java.util.Random; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.EntityUtils; +import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -17,143 +21,153 @@ import net.minecraft.world.Explosion; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import gtPlusPlus.api.objects.minecraft.BlockPos; -import gtPlusPlus.api.objects.random.XSTR; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.EntityUtils; - -public class Mining_Head_Fake extends Block{ - - public Mining_Head_Fake(){ - super(Material.lava); - this.setBlockName(Utils.sanitizeString("blockMiningHeadFake")); - this.setBlockTextureName(CORE.MODID + ":" + "blockFrameGt"); - this.setCreativeTab(AddToCreativeTab.tabBlock); - this.setHardness(-1F); - this.setResistance(50000.0F); - this.setHarvestLevel("pickaxe", 10); - this.setStepSound(soundTypeMetal); - //LanguageRegistry.addName(this, "Wither Cage"); - GameRegistry.registerBlock(this, Utils.sanitizeString("blockMiningHeadFake")); - } - - public String GetProperName(){ - return "Hardened Mining Head"; - } - - @Override - @SideOnly(Side.CLIENT) - public int getRenderBlockPass(){ - return 1; - } - - @Override - public boolean isOpaqueCube(){ - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister iIcon){ - this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + "blockFrameGt"); - } - - @Override - public void onBlockExploded(final World world, final int x, final int y, final int z, final Explosion explosion){ - //prevent from being destroyed by wither and nukes. - } - - @Override - public void onBlockDestroyedByExplosion(final World p_149723_1_, final int p_149723_2_, - final int p_149723_3_, final int p_149723_4_, final Explosion p_149723_5_) { - - } - - @Override - public boolean canDropFromExplosion(final Explosion p_149659_1_) { - return false; - } - - @Override - public boolean canEntityDestroy(final IBlockAccess world, final int x, final int y, final int z, - final Entity entity) { - return false; - } - - - //Colour Handling - private static final int mWitherColour = Utils.rgbtoHexValue(175, 64, 32); - - @Override - public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4){ - return mWitherColour; - } - - @Override - public int getRenderColor(final int aMeta) { - return mWitherColour; - } - - @Override - public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { - return false; - } - - @Override - public boolean isCollidable() { - return true; - } - - @Override - public void randomDisplayTick(World world, int posX, int posY, int posZ, - Random rand) { - generateVoidParticlesAroundBlockPos(new BlockPos(posX, posY, posZ, world), 2); - super.randomDisplayTick(world, posX, posY, posZ, rand); - } - - @Override - public void onEntityCollidedWithBlock(World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, - Entity ent) { - EntityUtils.doDamage(ent, DamageSource.outOfWorld, 20); - EntityUtils.setEntityOnFire(ent, 100); - super.onEntityCollidedWithBlock(p_149670_1_, p_149670_2_, p_149670_3_, p_149670_4_, ent); - } - - @Override - protected boolean canSilkHarvest() { - return false; - } - - @Override - public boolean canHarvestBlock(EntityPlayer player, int meta) { - return false; - } - - public static void generateVoidParticlesAroundBlockPos(BlockPos Pos, int range){ - for (BlockPos G : Pos.getSurroundingBlocks()) { - int i1 = G.xPos + MathUtils.randInt(0, range) - MathUtils.randInt(0, range); - int j1 = G.yPos + MathUtils.randInt(0, range) - MathUtils.randInt(0, range); - int k1 = G.zPos + MathUtils.randInt(0, range) - MathUtils.randInt(0, range); - - Block block = Pos.world.getBlock(i1, j1, k1); - - if (block.getMaterial() == Material.air){ - - //lava - if (Pos.yPos <= 7) { - Pos.world.spawnParticle("portal", (double)((float)i1 + CORE.RANDOM.nextFloat()), (double)((float)j1 + CORE.RANDOM.nextFloat()), (double)((float)k1 + CORE.RANDOM.nextFloat()), 0.0D, 0.0D, 0.0D); - Pos.world.spawnParticle("lava", (double)((float)i1 + CORE.RANDOM.nextFloat()), (double)((float)j1 + CORE.RANDOM.nextFloat()), (double)((float)k1 + CORE.RANDOM.nextFloat()), 0.0D, 0.0D, 0.0D); - } - else { - Pos.world.spawnParticle("portal", (double)((float)i1 + CORE.RANDOM.nextFloat()), (double)((float)j1 + CORE.RANDOM.nextFloat()), (double)((float)k1 + CORE.RANDOM.nextFloat()), 0.0D, 0.0D, 0.0D); - } - - } - } - } - - +public class Mining_Head_Fake extends Block { + + public Mining_Head_Fake() { + super(Material.lava); + this.setBlockName(Utils.sanitizeString("blockMiningHeadFake")); + this.setBlockTextureName(CORE.MODID + ":" + "blockFrameGt"); + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setHardness(-1F); + this.setResistance(50000.0F); + this.setHarvestLevel("pickaxe", 10); + this.setStepSound(soundTypeMetal); + // LanguageRegistry.addName(this, "Wither Cage"); + GameRegistry.registerBlock(this, Utils.sanitizeString("blockMiningHeadFake")); + } + + public String GetProperName() { + return "Hardened Mining Head"; + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() { + return 1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iIcon) { + this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + "blockFrameGt"); + } + + @Override + public void onBlockExploded(final World world, final int x, final int y, final int z, final Explosion explosion) { + // prevent from being destroyed by wither and nukes. + } + + @Override + public void onBlockDestroyedByExplosion( + final World p_149723_1_, + final int p_149723_2_, + final int p_149723_3_, + final int p_149723_4_, + final Explosion p_149723_5_) {} + + @Override + public boolean canDropFromExplosion(final Explosion p_149659_1_) { + return false; + } + + @Override + public boolean canEntityDestroy( + final IBlockAccess world, final int x, final int y, final int z, final Entity entity) { + return false; + } + + // Colour Handling + private static final int mWitherColour = Utils.rgbtoHexValue(175, 64, 32); + + @Override + public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4) { + return mWitherColour; + } + + @Override + public int getRenderColor(final int aMeta) { + return mWitherColour; + } + + @Override + public boolean canCreatureSpawn( + final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + @Override + public boolean isCollidable() { + return true; + } + + @Override + public void randomDisplayTick(World world, int posX, int posY, int posZ, Random rand) { + generateVoidParticlesAroundBlockPos(new BlockPos(posX, posY, posZ, world), 2); + super.randomDisplayTick(world, posX, posY, posZ, rand); + } + + @Override + public void onEntityCollidedWithBlock( + World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, Entity ent) { + EntityUtils.doDamage(ent, DamageSource.outOfWorld, 20); + EntityUtils.setEntityOnFire(ent, 100); + super.onEntityCollidedWithBlock(p_149670_1_, p_149670_2_, p_149670_3_, p_149670_4_, ent); + } + + @Override + protected boolean canSilkHarvest() { + return false; + } + + @Override + public boolean canHarvestBlock(EntityPlayer player, int meta) { + return false; + } + + public static void generateVoidParticlesAroundBlockPos(BlockPos Pos, int range) { + for (BlockPos G : Pos.getSurroundingBlocks()) { + int i1 = G.xPos + MathUtils.randInt(0, range) - MathUtils.randInt(0, range); + int j1 = G.yPos + MathUtils.randInt(0, range) - MathUtils.randInt(0, range); + int k1 = G.zPos + MathUtils.randInt(0, range) - MathUtils.randInt(0, range); + + Block block = Pos.world.getBlock(i1, j1, k1); + + if (block.getMaterial() == Material.air) { + + // lava + if (Pos.yPos <= 7) { + Pos.world.spawnParticle( + "portal", + (double) ((float) i1 + CORE.RANDOM.nextFloat()), + (double) ((float) j1 + CORE.RANDOM.nextFloat()), + (double) ((float) k1 + CORE.RANDOM.nextFloat()), + 0.0D, + 0.0D, + 0.0D); + Pos.world.spawnParticle( + "lava", + (double) ((float) i1 + CORE.RANDOM.nextFloat()), + (double) ((float) j1 + CORE.RANDOM.nextFloat()), + (double) ((float) k1 + CORE.RANDOM.nextFloat()), + 0.0D, + 0.0D, + 0.0D); + } else { + Pos.world.spawnParticle( + "portal", + (double) ((float) i1 + CORE.RANDOM.nextFloat()), + (double) ((float) j1 + CORE.RANDOM.nextFloat()), + (double) ((float) k1 + CORE.RANDOM.nextFloat()), + 0.0D, + 0.0D, + 0.0D); + } + } + } + } } diff --git a/src/main/java/gtPlusPlus/core/block/machine/bedrock/Mining_Pipe_Fake.java b/src/main/java/gtPlusPlus/core/block/machine/bedrock/Mining_Pipe_Fake.java index bba185a0c1..0da1650edf 100644 --- a/src/main/java/gtPlusPlus/core/block/machine/bedrock/Mining_Pipe_Fake.java +++ b/src/main/java/gtPlusPlus/core/block/machine/bedrock/Mining_Pipe_Fake.java @@ -1,11 +1,15 @@ package gtPlusPlus.core.block.machine.bedrock; -import java.util.Random; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.EntityUtils; +import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -17,120 +21,112 @@ import net.minecraft.world.Explosion; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import gtPlusPlus.api.objects.minecraft.BlockPos; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.EntityUtils; - -public class Mining_Pipe_Fake extends Block{ - - public Mining_Pipe_Fake(){ - super(Material.cactus); - this.setBlockName(Utils.sanitizeString("blockMiningPipeFake")); - this.setBlockTextureName(CORE.MODID + ":" + "blockFrameGt"); - this.setCreativeTab(AddToCreativeTab.tabBlock); - this.setHardness(-1F); - this.setResistance(50000.0F); - this.setHarvestLevel("pickaxe", 8); - this.setStepSound(soundTypeMetal); - //LanguageRegistry.addName(this, "Wither Cage"); - GameRegistry.registerBlock(this, Utils.sanitizeString("blockMiningPipeFake")); - } - - public String GetProperName(){ - return "Hardened Mining Pipe"; - } - - @Override - @SideOnly(Side.CLIENT) - public int getRenderBlockPass(){ - return 1; - } - - @Override - public boolean isOpaqueCube(){ - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister iIcon){ - this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + "blockFrameGt"); - } - - @Override - public void onBlockExploded(final World world, final int x, final int y, final int z, final Explosion explosion){ - //prevent from being destroyed by wither and nukes. - } - - @Override - public void onBlockDestroyedByExplosion(final World p_149723_1_, final int p_149723_2_, - final int p_149723_3_, final int p_149723_4_, final Explosion p_149723_5_) { - - } - - @Override - public boolean canDropFromExplosion(final Explosion p_149659_1_) { - return false; - } - - @Override - public boolean canEntityDestroy(final IBlockAccess world, final int x, final int y, final int z, - final Entity entity) { - return false; - } - - - //Colour Handling - private static final int mWitherColour = Utils.rgbtoHexValue(32, 32, 32); - - @Override - public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4){ - return mWitherColour; - } - - @Override - public int getRenderColor(final int aMeta) { - return mWitherColour; - } - - @Override - public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { - return false; - } - - @Override - public boolean isCollidable() { - return true; - } - - @Override - public void randomDisplayTick(World world, int posX, int posY, int posZ, - Random rand) { - Mining_Head_Fake.generateVoidParticlesAroundBlockPos(new BlockPos(posX, posY, posZ, world), 2); - super.randomDisplayTick(world, posX, posY, posZ, rand); - } - - @Override - public void onEntityCollidedWithBlock(World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, Entity ent) { - if (MathUtils.randInt(0, 100) < 5) { - EntityUtils.doDamage(ent, DamageSource.outOfWorld, 1); - } - super.onEntityCollidedWithBlock(p_149670_1_, p_149670_2_, p_149670_3_, p_149670_4_, ent); - } - - @Override - protected boolean canSilkHarvest() { - return false; - } - - @Override - public boolean canHarvestBlock(EntityPlayer player, int meta) { - return false; - } - - - +public class Mining_Pipe_Fake extends Block { + + public Mining_Pipe_Fake() { + super(Material.cactus); + this.setBlockName(Utils.sanitizeString("blockMiningPipeFake")); + this.setBlockTextureName(CORE.MODID + ":" + "blockFrameGt"); + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setHardness(-1F); + this.setResistance(50000.0F); + this.setHarvestLevel("pickaxe", 8); + this.setStepSound(soundTypeMetal); + // LanguageRegistry.addName(this, "Wither Cage"); + GameRegistry.registerBlock(this, Utils.sanitizeString("blockMiningPipeFake")); + } + + public String GetProperName() { + return "Hardened Mining Pipe"; + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() { + return 1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iIcon) { + this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + "blockFrameGt"); + } + + @Override + public void onBlockExploded(final World world, final int x, final int y, final int z, final Explosion explosion) { + // prevent from being destroyed by wither and nukes. + } + + @Override + public void onBlockDestroyedByExplosion( + final World p_149723_1_, + final int p_149723_2_, + final int p_149723_3_, + final int p_149723_4_, + final Explosion p_149723_5_) {} + + @Override + public boolean canDropFromExplosion(final Explosion p_149659_1_) { + return false; + } + + @Override + public boolean canEntityDestroy( + final IBlockAccess world, final int x, final int y, final int z, final Entity entity) { + return false; + } + + // Colour Handling + private static final int mWitherColour = Utils.rgbtoHexValue(32, 32, 32); + + @Override + public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4) { + return mWitherColour; + } + + @Override + public int getRenderColor(final int aMeta) { + return mWitherColour; + } + + @Override + public boolean canCreatureSpawn( + final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + @Override + public boolean isCollidable() { + return true; + } + + @Override + public void randomDisplayTick(World world, int posX, int posY, int posZ, Random rand) { + Mining_Head_Fake.generateVoidParticlesAroundBlockPos(new BlockPos(posX, posY, posZ, world), 2); + super.randomDisplayTick(world, posX, posY, posZ, rand); + } + + @Override + public void onEntityCollidedWithBlock( + World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, Entity ent) { + if (MathUtils.randInt(0, 100) < 5) { + EntityUtils.doDamage(ent, DamageSource.outOfWorld, 1); + } + super.onEntityCollidedWithBlock(p_149670_1_, p_149670_2_, p_149670_3_, p_149670_4_, ent); + } + + @Override + protected boolean canSilkHarvest() { + return false; + } + + @Override + public boolean canHarvestBlock(EntityPlayer player, int meta) { + return false; + } } diff --git a/src/main/java/gtPlusPlus/core/chunkloading/GTPP_ChunkManager.java b/src/main/java/gtPlusPlus/core/chunkloading/GTPP_ChunkManager.java index b403646a2a..3322f3924c 100644 --- a/src/main/java/gtPlusPlus/core/chunkloading/GTPP_ChunkManager.java +++ b/src/main/java/gtPlusPlus/core/chunkloading/GTPP_ChunkManager.java @@ -1,11 +1,11 @@ package gtPlusPlus.core.chunkloading; import com.google.common.collect.LinkedListMultimap; +import com.google.common.collect.ListMultimap; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gtPlusPlus.GTplusplus; - -import com.google.common.collect.ListMultimap; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaTileEntityChunkLoader; +import java.util.*; import net.minecraft.entity.Entity; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.ChunkCoordIntPair; @@ -14,91 +14,92 @@ import net.minecraftforge.common.ForgeChunkManager; import net.minecraftforge.common.ForgeChunkManager.Ticket; import net.minecraftforge.common.MinecraftForge; -import java.util.*; - /** - * + * * This class handles re-initializing chunks after a server restart * Credits to Repo-Alt for the original implementation. * @author Repo-Alt, Alkalus * */ -public class GTPP_ChunkManager implements ForgeChunkManager.LoadingCallback, ForgeChunkManager.OrderedLoadingCallback, ForgeChunkManager.PlayerOrderedLoadingCallback { - private static GTPP_ChunkManager instance; +public class GTPP_ChunkManager + implements ForgeChunkManager.LoadingCallback, + ForgeChunkManager.OrderedLoadingCallback, + ForgeChunkManager.PlayerOrderedLoadingCallback { + private static GTPP_ChunkManager instance; - public static boolean enableChunkloaders = true; - public static boolean alwaysReloadChunkloaders = false; - public static boolean debugChunkloaders = false; + public static boolean enableChunkloaders = true; + public static boolean alwaysReloadChunkloaders = false; + public static boolean debugChunkloaders = false; - public static GTPP_ChunkManager getInstance() { - if (instance == null) { - instance = new GTPP_ChunkManager(); - } - return instance; - } + public static GTPP_ChunkManager getInstance() { + if (instance == null) { + instance = new GTPP_ChunkManager(); + } + return instance; + } - public static void init() { - if (enableChunkloaders) { - ForgeChunkManager.setForcedChunkLoadingCallback(GTplusplus.instance, getInstance()); - MinecraftForge.EVENT_BUS.register(getInstance()); - } - } + public static void init() { + if (enableChunkloaders) { + ForgeChunkManager.setForcedChunkLoadingCallback(GTplusplus.instance, getInstance()); + MinecraftForge.EVENT_BUS.register(getInstance()); + } + } - @Override - public void ticketsLoaded(List tickets, World world) { - for (Ticket ticket : tickets) { - if (ticket.isPlayerTicket()) - continue; - Entity entity = ticket.getEntity(); - if (entity == null) { - int x = ticket.getModData().getInteger("xCoord"); - int y = ticket.getModData().getInteger("yCoord"); - int z = ticket.getModData().getInteger("zCoord"); + @Override + public void ticketsLoaded(List tickets, World world) { + for (Ticket ticket : tickets) { + if (ticket.isPlayerTicket()) continue; + Entity entity = ticket.getEntity(); + if (entity == null) { + int x = ticket.getModData().getInteger("xCoord"); + int y = ticket.getModData().getInteger("yCoord"); + int z = ticket.getModData().getInteger("zCoord"); - if (y >= 0) { - TileEntity tile = world.getTileEntity(x, y, z); - if (((IGregTechTileEntity)tile).getMetaTileEntity() instanceof GregtechMetaTileEntityChunkLoader) { - ((GregtechMetaTileEntityChunkLoader)((IGregTechTileEntity)tile).getMetaTileEntity()).forceChunkLoading(ticket); - } - } - } - } - } + if (y >= 0) { + TileEntity tile = world.getTileEntity(x, y, z); + if (((IGregTechTileEntity) tile).getMetaTileEntity() instanceof GregtechMetaTileEntityChunkLoader) { + ((GregtechMetaTileEntityChunkLoader) ((IGregTechTileEntity) tile).getMetaTileEntity()) + .forceChunkLoading(ticket); + } + } + } + } + } - @Override - public List ticketsLoaded(List tickets, World world, int maxTicketCount) { - Set validTickets = new HashSet<>(); - for (Ticket ticket : tickets) { - Entity entity = ticket.getEntity(); - if (entity == null) { - int x = ticket.getModData().getInteger("xCoord"); - int y = ticket.getModData().getInteger("yCoord"); - int z = ticket.getModData().getInteger("zCoord"); + @Override + public List ticketsLoaded(List tickets, World world, int maxTicketCount) { + Set validTickets = new HashSet<>(); + for (Ticket ticket : tickets) { + Entity entity = ticket.getEntity(); + if (entity == null) { + int x = ticket.getModData().getInteger("xCoord"); + int y = ticket.getModData().getInteger("yCoord"); + int z = ticket.getModData().getInteger("zCoord"); - if (y >= 0) { - TileEntity tile = world.getTileEntity(x, y, z); - if (((IGregTechTileEntity)tile).getMetaTileEntity() instanceof GregtechMetaTileEntityChunkLoader) { - validTickets.add(ticket); - } - } - } - } + if (y >= 0) { + TileEntity tile = world.getTileEntity(x, y, z); + if (((IGregTechTileEntity) tile).getMetaTileEntity() instanceof GregtechMetaTileEntityChunkLoader) { + validTickets.add(ticket); + } + } + } + } - return new LinkedList<>(validTickets); - } + return new LinkedList<>(validTickets); + } - @Override - public ListMultimap playerTicketsLoaded(ListMultimap tickets, World world) { - return LinkedListMultimap.create(); - } + @Override + public ListMultimap playerTicketsLoaded(ListMultimap tickets, World world) { + return LinkedListMultimap.create(); + } - public static Set getChunksAround(int xChunk, int zChunk, int radius) { - Set chunkList = new HashSet<>(); - for (int xx = xChunk - radius; xx <= xChunk + radius; xx++) { - for (int zz = zChunk - radius; zz <= zChunk + radius; zz++) { - chunkList.add(new ChunkCoordIntPair(xx, zz)); - } - } - return chunkList; - } + public static Set getChunksAround(int xChunk, int zChunk, int radius) { + Set chunkList = new HashSet<>(); + for (int xx = xChunk - radius; xx <= xChunk + radius; xx++) { + for (int zz = zChunk - radius; zz <= zChunk + radius; zz++) { + chunkList.add(new ChunkCoordIntPair(xx, zz)); + } + } + return chunkList; + } } diff --git a/src/main/java/gtPlusPlus/core/client/CustomTextureSet.java b/src/main/java/gtPlusPlus/core/client/CustomTextureSet.java index 400503b2fa..687dc65fb1 100644 --- a/src/main/java/gtPlusPlus/core/client/CustomTextureSet.java +++ b/src/main/java/gtPlusPlus/core/client/CustomTextureSet.java @@ -4,25 +4,24 @@ import gregtech.api.enums.TextureSet; public class CustomTextureSet extends TextureSet { - public static enum TextureSets { - - REFINED(), - GEM_A(), - ENRICHED(), - NUCLEAR; + public static enum TextureSets { + REFINED(), + GEM_A(), + ENRICHED(), + NUCLEAR; - private final CustomTextureSet A; - - private TextureSets (){ - A = new CustomTextureSet(this.name().toUpperCase()); - } - public CustomTextureSet get() { - return A; - } - } - - public CustomTextureSet(String aSetName) { - super(aSetName); - } + private final CustomTextureSet A; + private TextureSets() { + A = new CustomTextureSet(this.name().toUpperCase()); + } + + public CustomTextureSet get() { + return A; + } + } + + public CustomTextureSet(String aSetName) { + super(aSetName); + } } diff --git a/src/main/java/gtPlusPlus/core/client/model/ModelBatKing.java b/src/main/java/gtPlusPlus/core/client/model/ModelBatKing.java index ac64dee26a..590345e8e6 100644 --- a/src/main/java/gtPlusPlus/core/client/model/ModelBatKing.java +++ b/src/main/java/gtPlusPlus/core/client/model/ModelBatKing.java @@ -1,19 +1,16 @@ package gtPlusPlus.core.client.model; -import org.lwjgl.opengl.GL11; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.core.entity.monster.EntityBatKing; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; -import net.minecraft.entity.passive.EntityBat; import net.minecraft.util.MathHelper; +import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class ModelBatKing extends ModelBase -{ +public class ModelBatKing extends ModelBase { private ModelRenderer batHead; /** The body box of the bat model. */ private ModelRenderer batBody; @@ -26,11 +23,10 @@ public class ModelBatKing extends ModelBase /** The outer left wing box of the bat model. */ private ModelRenderer batOuterLeftWing; - public ModelBatKing() - { + public ModelBatKing() { this.textureWidth = 64; this.textureHeight = 64; - + this.batHead = new ModelRenderer(this, 0, 0); this.batHead.addBox(-3.0F, -3.0F, -3.0F, 6, 6, 6); ModelRenderer modelrenderer = new ModelRenderer(this, 24, 0); @@ -65,56 +61,57 @@ public class ModelBatKing extends ModelBase * not actually sure this is size, is not used as of now, but the model would be recreated if the value changed and * it seems a good match for a bats size */ - public int getBatSize() - { + public int getBatSize() { return 72; } /** * Sets the models various rotation angles then renders the model. */ - public void render(Entity p_78088_1_, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float p_78088_7_) - { - EntityBatKing entitybat = (EntityBatKing)p_78088_1_; + public void render( + Entity p_78088_1_, + float p_78088_2_, + float p_78088_3_, + float p_78088_4_, + float p_78088_5_, + float p_78088_6_, + float p_78088_7_) { + EntityBatKing entitybat = (EntityBatKing) p_78088_1_; float f6; - if (entitybat.getIsBatHanging()) - { - f6 = (180F / (float)Math.PI); - this.batHead.rotateAngleX = p_78088_6_ / (180F / (float)Math.PI); - this.batHead.rotateAngleY = (float)Math.PI - p_78088_5_ / (180F / (float)Math.PI); - this.batHead.rotateAngleZ = (float)Math.PI; + if (entitybat.getIsBatHanging()) { + f6 = (180F / (float) Math.PI); + this.batHead.rotateAngleX = p_78088_6_ / (180F / (float) Math.PI); + this.batHead.rotateAngleY = (float) Math.PI - p_78088_5_ / (180F / (float) Math.PI); + this.batHead.rotateAngleZ = (float) Math.PI; this.batHead.setRotationPoint(0.0F, -2.0F, 0.0F); this.batRightWing.setRotationPoint(-3.0F, 0.0F, 3.0F); this.batLeftWing.setRotationPoint(3.0F, 0.0F, 3.0F); - this.batBody.rotateAngleX = (float)Math.PI; + this.batBody.rotateAngleX = (float) Math.PI; this.batRightWing.rotateAngleX = -0.15707964F; - this.batRightWing.rotateAngleY = -((float)Math.PI * 2F / 5F); + this.batRightWing.rotateAngleY = -((float) Math.PI * 2F / 5F); this.batOuterRightWing.rotateAngleY = -1.7278761F; this.batLeftWing.rotateAngleX = this.batRightWing.rotateAngleX; this.batLeftWing.rotateAngleY = -this.batRightWing.rotateAngleY; this.batOuterLeftWing.rotateAngleY = -this.batOuterRightWing.rotateAngleY; - } - else - { - f6 = (180F / (float)Math.PI); - this.batHead.rotateAngleX = p_78088_6_ / (180F / (float)Math.PI); - this.batHead.rotateAngleY = p_78088_5_ / (180F / (float)Math.PI); + } else { + f6 = (180F / (float) Math.PI); + this.batHead.rotateAngleX = p_78088_6_ / (180F / (float) Math.PI); + this.batHead.rotateAngleY = p_78088_5_ / (180F / (float) Math.PI); this.batHead.rotateAngleZ = 0.0F; this.batHead.setRotationPoint(0.0F, 0.0F, 0.0F); this.batRightWing.setRotationPoint(0.0F, 0.0F, 0.0F); this.batLeftWing.setRotationPoint(0.0F, 0.0F, 0.0F); - this.batBody.rotateAngleX = ((float)Math.PI / 4F) + MathHelper.cos(p_78088_4_ * 0.1F) * 0.15F; + this.batBody.rotateAngleX = ((float) Math.PI / 4F) + MathHelper.cos(p_78088_4_ * 0.1F) * 0.15F; this.batBody.rotateAngleY = 0.0F; - this.batRightWing.rotateAngleY = MathHelper.cos(p_78088_4_ * 1.3F) * (float)Math.PI * 0.25F; + this.batRightWing.rotateAngleY = MathHelper.cos(p_78088_4_ * 1.3F) * (float) Math.PI * 0.25F; this.batLeftWing.rotateAngleY = -this.batRightWing.rotateAngleY; this.batOuterRightWing.rotateAngleY = this.batRightWing.rotateAngleY * 0.5F; this.batOuterLeftWing.rotateAngleY = -this.batRightWing.rotateAngleY * 0.5F; } - GL11.glScalef(4, 4, 4); this.batHead.render(p_78088_7_); this.batBody.render(p_78088_7_); } -} \ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/core/client/model/ModelDecayChest.java b/src/main/java/gtPlusPlus/core/client/model/ModelDecayChest.java index c116dcf115..98c474a160 100644 --- a/src/main/java/gtPlusPlus/core/client/model/ModelDecayChest.java +++ b/src/main/java/gtPlusPlus/core/client/model/ModelDecayChest.java @@ -6,8 +6,7 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; @SideOnly(Side.CLIENT) -public class ModelDecayChest extends ModelBase -{ +public class ModelDecayChest extends ModelBase { /** The chest lid in the chest's model. */ public ModelRenderer chestLid = (new ModelRenderer(this, 0, 0)).setTextureSize(64, 64); /** The model of the bottom of the chest. */ @@ -15,8 +14,7 @@ public class ModelDecayChest extends ModelBase /** The chest's knob in the chest model. */ public ModelRenderer chestKnob; - public ModelDecayChest() - { + public ModelDecayChest() { this.chestLid.addBox(0.0F, -5.0F, -14.0F, 14, 5, 14, 0.0F); this.chestLid.rotationPointX = 1.0F; this.chestLid.rotationPointY = 7.0F; @@ -36,11 +34,10 @@ public class ModelDecayChest extends ModelBase /** * This method renders out all parts of the chest model. */ - public void renderAll() - { + public void renderAll() { this.chestKnob.rotateAngleX = this.chestLid.rotateAngleX; this.chestLid.render(0.0625F); this.chestKnob.render(0.0625F); this.chestBelow.render(0.0625F); } -} \ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/core/client/model/ModelEggBox.java b/src/main/java/gtPlusPlus/core/client/model/ModelEggBox.java index 0aef4eb7b0..a12b48c7d2 100644 --- a/src/main/java/gtPlusPlus/core/client/model/ModelEggBox.java +++ b/src/main/java/gtPlusPlus/core/client/model/ModelEggBox.java @@ -1,6 +1,5 @@ package gtPlusPlus.core.client.model; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.client.model.tabula.ModelTabulaBase; @@ -14,19 +13,19 @@ import net.minecraft.entity.Entity; * Created using Tabula 4.1.1 */ public class ModelEggBox extends ModelTabulaBase { - - private final AutoMap> mParts = new AutoMap>(); - - private static RenderTabulaBase mRendererInstance; - + + private final AutoMap> mParts = new AutoMap>(); + + private static RenderTabulaBase mRendererInstance; + public ModelRenderer bottom; - //EggBox_full.png + // EggBox_full.png public ModelEggBox() { - super(64, 64); + super(64, 64); this.textureWidth = 64; this.textureHeight = 64; - + this.bottom = new ModelRenderer(this, 0, 19); this.bottom.setRotationPoint(1.0F, 6.0F, 1.0F); this.bottom.addBox(0.0F, 0.0F, 0.0F, 14, 10, 14, 0.0F); @@ -34,8 +33,8 @@ public class ModelEggBox extends ModelTabulaBase { } @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - //Logger.INFO("Rendering EggBox"); + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + // Logger.INFO("Rendering EggBox"); this.bottom.render(f5); } @@ -48,18 +47,19 @@ public class ModelEggBox extends ModelTabulaBase { modelRenderer.rotateAngleZ = z; } - @Override - protected AutoMap> getModelParts() { - AutoMap> aParts = new AutoMap>(); - aParts.add(new Pair(bottom, 0.0625F)); - return aParts; - //return mParts; - } - - public static RenderTabulaBase getRenderer() { - if (mRendererInstance == null) { - mRendererInstance = new RenderTabulaBase(new ModelEggBox(), "textures/blocks/TileEntities/EggBox_full.png", TileEntityEggBox.class); - } - return mRendererInstance; - } + @Override + protected AutoMap> getModelParts() { + AutoMap> aParts = new AutoMap>(); + aParts.add(new Pair(bottom, 0.0625F)); + return aParts; + // return mParts; + } + + public static RenderTabulaBase getRenderer() { + if (mRendererInstance == null) { + mRendererInstance = new RenderTabulaBase( + new ModelEggBox(), "textures/blocks/TileEntities/EggBox_full.png", TileEntityEggBox.class); + } + return mRendererInstance; + } } diff --git a/src/main/java/gtPlusPlus/core/client/model/ModelGiantChicken.java b/src/main/java/gtPlusPlus/core/client/model/ModelGiantChicken.java index f7fb92f550..586dfec2db 100644 --- a/src/main/java/gtPlusPlus/core/client/model/ModelGiantChicken.java +++ b/src/main/java/gtPlusPlus/core/client/model/ModelGiantChicken.java @@ -2,7 +2,6 @@ package gtPlusPlus.core.client.model; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - import net.minecraft.client.model.ModelChicken; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; @@ -10,46 +9,50 @@ import net.minecraft.util.MathHelper; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class ModelGiantChicken extends ModelChicken{ +public class ModelGiantChicken extends ModelChicken { - public ModelGiantChicken() - { + public ModelGiantChicken() { byte b0 = 16; this.head = new ModelRenderer(this, 0, 0); this.head.addBox(-2.0F, -6.0F, -2.0F, 4, 6, 3, 0.0F); - this.head.setRotationPoint(0.0F, (float)(-1 + b0), -4.0F); + this.head.setRotationPoint(0.0F, (float) (-1 + b0), -4.0F); this.bill = new ModelRenderer(this, 14, 0); this.bill.addBox(-2.0F, -4.0F, -4.0F, 4, 2, 2, 0.0F); - this.bill.setRotationPoint(0.0F, (float)(-1 + b0), -4.0F); + this.bill.setRotationPoint(0.0F, (float) (-1 + b0), -4.0F); this.chin = new ModelRenderer(this, 14, 4); this.chin.addBox(-1.0F, -2.0F, -3.0F, 2, 2, 2, 0.0F); - this.chin.setRotationPoint(0.0F, (float)(-1 + b0), -4.0F); + this.chin.setRotationPoint(0.0F, (float) (-1 + b0), -4.0F); this.body = new ModelRenderer(this, 0, 9); this.body.addBox(-3.0F, -4.0F, -3.0F, 6, 8, 6, 0.0F); - this.body.setRotationPoint(0.0F, (float)b0, 0.0F); + this.body.setRotationPoint(0.0F, (float) b0, 0.0F); this.rightLeg = new ModelRenderer(this, 26, 0); this.rightLeg.addBox(-1.0F, 0.0F, -3.0F, 3, 5, 3); - this.rightLeg.setRotationPoint(-2.0F, (float)(3 + b0), 1.0F); + this.rightLeg.setRotationPoint(-2.0F, (float) (3 + b0), 1.0F); this.leftLeg = new ModelRenderer(this, 26, 0); this.leftLeg.addBox(-1.0F, 0.0F, -3.0F, 3, 5, 3); - this.leftLeg.setRotationPoint(1.0F, (float)(3 + b0), 1.0F); + this.leftLeg.setRotationPoint(1.0F, (float) (3 + b0), 1.0F); this.rightWing = new ModelRenderer(this, 24, 13); this.rightWing.addBox(0.0F, 0.0F, -3.0F, 1, 4, 6); - this.rightWing.setRotationPoint(-4.0F, (float)(-3 + b0), 0.0F); + this.rightWing.setRotationPoint(-4.0F, (float) (-3 + b0), 0.0F); this.leftWing = new ModelRenderer(this, 24, 13); this.leftWing.addBox(-1.0F, 0.0F, -3.0F, 1, 4, 6); - this.leftWing.setRotationPoint(4.0F, (float)(-3 + b0), 0.0F); + this.leftWing.setRotationPoint(4.0F, (float) (-3 + b0), 0.0F); } /** * Sets the models various rotation angles then renders the model. */ - public void render(Entity p_78088_1_, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float p_78088_7_) - { + public void render( + Entity p_78088_1_, + float p_78088_2_, + float p_78088_3_, + float p_78088_4_, + float p_78088_5_, + float p_78088_6_, + float p_78088_7_) { this.setRotationAngles(p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, p_78088_7_, p_78088_1_); - if (this.isChild) - { + if (this.isChild) { float f6 = 1.0F; GL11.glPushMatrix(); GL11.glTranslatef(0.0F, 0F, 0F); @@ -66,10 +69,8 @@ public class ModelGiantChicken extends ModelChicken{ this.rightWing.render(p_78088_7_); this.leftWing.render(p_78088_7_); GL11.glPopMatrix(); - //super.render(p_78088_1_, p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, p_78088_7_); - } - else - { + // super.render(p_78088_1_, p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, p_78088_7_); + } else { float f6 = 2.0F; GL11.glPushMatrix(); GL11.glScalef(1.0F * f6, 1.0F * f6, 1.0F * f6); @@ -95,18 +96,24 @@ public class ModelGiantChicken extends ModelChicken{ * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how * "far" arms and legs can swing at most. */ - public void setRotationAngles(float p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, float p_78087_5_, float p_78087_6_, Entity p_78087_7_) - { - this.head.rotateAngleX = p_78087_5_ / (180F / (float)Math.PI); - this.head.rotateAngleY = p_78087_4_ / (180F / (float)Math.PI); + public void setRotationAngles( + float p_78087_1_, + float p_78087_2_, + float p_78087_3_, + float p_78087_4_, + float p_78087_5_, + float p_78087_6_, + Entity p_78087_7_) { + this.head.rotateAngleX = p_78087_5_ / (180F / (float) Math.PI); + this.head.rotateAngleY = p_78087_4_ / (180F / (float) Math.PI); this.bill.rotateAngleX = this.head.rotateAngleX; this.bill.rotateAngleY = this.head.rotateAngleY; this.chin.rotateAngleX = this.head.rotateAngleX; this.chin.rotateAngleY = this.head.rotateAngleY; - this.body.rotateAngleX = ((float)Math.PI / 2F); + this.body.rotateAngleX = ((float) Math.PI / 2F); this.rightLeg.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F) * 1.4F * p_78087_2_; - this.leftLeg.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F + (float)Math.PI) * 1.4F * p_78087_2_; + this.leftLeg.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F + (float) Math.PI) * 1.4F * p_78087_2_; this.rightWing.rotateAngleZ = p_78087_3_; this.leftWing.rotateAngleZ = -p_78087_3_; } -} \ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/core/client/model/ModelSickBlaze.java b/src/main/java/gtPlusPlus/core/client/model/ModelSickBlaze.java index 455df761cb..7cfb7ec2ea 100644 --- a/src/main/java/gtPlusPlus/core/client/model/ModelSickBlaze.java +++ b/src/main/java/gtPlusPlus/core/client/model/ModelSickBlaze.java @@ -2,23 +2,20 @@ package gtPlusPlus.core.client.model; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - import net.minecraft.client.model.ModelBlaze; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraft.util.MathHelper; @SideOnly(Side.CLIENT) -public class ModelSickBlaze extends ModelBlaze -{ +public class ModelSickBlaze extends ModelBlaze { /** The sticks that fly around the Blaze. */ private ModelRenderer[] blazeSticks = new ModelRenderer[24]; + private ModelRenderer blazeHead; - public ModelSickBlaze() - { - for (int i = 0; i < this.blazeSticks.length; ++i) - { + public ModelSickBlaze() { + for (int i = 0; i < this.blazeSticks.length; ++i) { this.blazeSticks[i] = new ModelRenderer(this, 0, 16); this.blazeSticks[i].addBox(0.0F, 0.0F, 0.0F, 2, 8, 2); } @@ -28,8 +25,7 @@ public class ModelSickBlaze extends ModelBlaze } @Override - public int func_78104_a() - { + public int func_78104_a() { return 8; } @@ -37,13 +33,18 @@ public class ModelSickBlaze extends ModelBlaze * Sets the models various rotation angles then renders the model. */ @Override - public void render(Entity p_78088_1_, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float p_78088_7_) - { + public void render( + Entity p_78088_1_, + float p_78088_2_, + float p_78088_3_, + float p_78088_4_, + float p_78088_5_, + float p_78088_6_, + float p_78088_7_) { this.setRotationAngles(p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, p_78088_7_, p_78088_1_); this.blazeHead.render(p_78088_7_); - for (int i = 0; i < this.blazeSticks.length; ++i) - { + for (int i = 0; i < this.blazeSticks.length; ++i) { this.blazeSticks[i].render(p_78088_7_); } } @@ -54,40 +55,43 @@ public class ModelSickBlaze extends ModelBlaze * "far" arms and legs can swing at most. */ @Override - public void setRotationAngles(float p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, float p_78087_5_, float p_78087_6_, Entity p_78087_7_) - { - float f6 = p_78087_3_ * (float)Math.PI * -0.1F; + public void setRotationAngles( + float p_78087_1_, + float p_78087_2_, + float p_78087_3_, + float p_78087_4_, + float p_78087_5_, + float p_78087_6_, + Entity p_78087_7_) { + float f6 = p_78087_3_ * (float) Math.PI * -0.1F; int i; - for (i = 0; i < 4; ++i) - { + for (i = 0; i < 4; ++i) { this.blazeSticks[i].rotationPointY = -2.0F + MathHelper.cos((i * 2 + p_78087_3_) * 0.25F); this.blazeSticks[i].rotationPointX = MathHelper.cos(f6) * 9.0F; this.blazeSticks[i].rotationPointZ = MathHelper.sin(f6) * 9.0F; ++f6; } - f6 = ((float)Math.PI / 4F) + p_78087_3_ * (float)Math.PI * 0.03F; + f6 = ((float) Math.PI / 4F) + p_78087_3_ * (float) Math.PI * 0.03F; - for (i = 4; i < 8; ++i) - { + for (i = 4; i < 8; ++i) { this.blazeSticks[i].rotationPointY = 2.0F + MathHelper.cos((i * 2 + p_78087_3_) * 0.25F); this.blazeSticks[i].rotationPointX = MathHelper.cos(f6) * 7.0F; this.blazeSticks[i].rotationPointZ = MathHelper.sin(f6) * 7.0F; ++f6; } - f6 = 0.47123894F + p_78087_3_ * (float)Math.PI * -0.05F; + f6 = 0.47123894F + p_78087_3_ * (float) Math.PI * -0.05F; - for (i = 8; i < 12; ++i) - { + for (i = 8; i < 12; ++i) { this.blazeSticks[i].rotationPointY = 11.0F + MathHelper.cos((i * 1.5F + p_78087_3_) * 0.5F); this.blazeSticks[i].rotationPointX = MathHelper.cos(f6) * 5.0F; this.blazeSticks[i].rotationPointZ = MathHelper.sin(f6) * 5.0F; ++f6; } - this.blazeHead.rotateAngleY = p_78087_4_ / (180F / (float)Math.PI); - this.blazeHead.rotateAngleX = p_78087_5_ / (180F / (float)Math.PI); + this.blazeHead.rotateAngleY = p_78087_4_ / (180F / (float) Math.PI); + this.blazeHead.rotateAngleX = p_78087_5_ / (180F / (float) Math.PI); } -} \ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/core/client/model/ModelStaballoyConstruct.java b/src/main/java/gtPlusPlus/core/client/model/ModelStaballoyConstruct.java index aa23635b4d..879e06516a 100644 --- a/src/main/java/gtPlusPlus/core/client/model/ModelStaballoyConstruct.java +++ b/src/main/java/gtPlusPlus/core/client/model/ModelStaballoyConstruct.java @@ -2,7 +2,6 @@ package gtPlusPlus.core.client.model; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - import net.minecraft.client.model.ModelIronGolem; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; @@ -10,21 +9,17 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.EntityIronGolem; @SideOnly(Side.CLIENT) -public class ModelStaballoyConstruct extends ModelIronGolem -{ - - public ModelStaballoyConstruct() - { +public class ModelStaballoyConstruct extends ModelIronGolem { + + public ModelStaballoyConstruct() { this(0.0F); } - public ModelStaballoyConstruct(float p_i1161_1_) - { + public ModelStaballoyConstruct(float p_i1161_1_) { this(p_i1161_1_, -7.0F); } - public ModelStaballoyConstruct(float p_i1162_1_, float p_i1162_2_) - { + public ModelStaballoyConstruct(float p_i1162_1_, float p_i1162_2_) { short short1 = 128; short short2 = 128; this.ironGolemHead = (new ModelRenderer(this)).setTextureSize(short1, short2); @@ -54,8 +49,14 @@ public class ModelStaballoyConstruct extends ModelIronGolem * Sets the models various rotation angles then renders the model. */ @Override - public void render(Entity p_78088_1_, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float p_78088_7_) - { + public void render( + Entity p_78088_1_, + float p_78088_2_, + float p_78088_3_, + float p_78088_4_, + float p_78088_5_, + float p_78088_6_, + float p_78088_7_) { this.setRotationAngles(p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, p_78088_7_, p_78088_1_); this.ironGolemHead.render(p_78088_7_); this.ironGolemBody.render(p_78088_7_); @@ -71,10 +72,16 @@ public class ModelStaballoyConstruct extends ModelIronGolem * "far" arms and legs can swing at most. */ @Override - public void setRotationAngles(float p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, float p_78087_5_, float p_78087_6_, Entity p_78087_7_) - { - this.ironGolemHead.rotateAngleY = p_78087_4_ / (180F / (float)Math.PI); - this.ironGolemHead.rotateAngleX = p_78087_5_ / (180F / (float)Math.PI); + public void setRotationAngles( + float p_78087_1_, + float p_78087_2_, + float p_78087_3_, + float p_78087_4_, + float p_78087_5_, + float p_78087_6_, + Entity p_78087_7_) { + this.ironGolemHead.rotateAngleY = p_78087_4_ / (180F / (float) Math.PI); + this.ironGolemHead.rotateAngleX = p_78087_5_ / (180F / (float) Math.PI); this.ironGolemLeftLeg.rotateAngleX = -1.5F * this.func_78172_a(p_78087_1_, 13.0F) * p_78087_2_; this.ironGolemRightLeg.rotateAngleX = 1.5F * this.func_78172_a(p_78087_1_, 13.0F) * p_78087_2_; this.ironGolemLeftLeg.rotateAngleY = 0.0F; @@ -86,35 +93,28 @@ public class ModelStaballoyConstruct extends ModelIronGolem * and third as in the setRotationAngles method. */ @Override - public void setLivingAnimations(EntityLivingBase p_78086_1_, float p_78086_2_, float p_78086_3_, float p_78086_4_) - { - EntityIronGolem entityirongolem = (EntityIronGolem)p_78086_1_; + public void setLivingAnimations(EntityLivingBase p_78086_1_, float p_78086_2_, float p_78086_3_, float p_78086_4_) { + EntityIronGolem entityirongolem = (EntityIronGolem) p_78086_1_; int i = entityirongolem.getAttackTimer(); - if (i > 0) - { + if (i > 0) { this.ironGolemRightArm.rotateAngleX = -2.0F + 1.5F * this.func_78172_a(i - p_78086_4_, 10.0F); this.ironGolemLeftArm.rotateAngleX = -2.0F + 1.5F * this.func_78172_a(i - p_78086_4_, 10.0F); - } - else - { + } else { int j = entityirongolem.getHoldRoseTick(); - if (j > 0) - { + if (j > 0) { this.ironGolemRightArm.rotateAngleX = -0.8F + 0.025F * this.func_78172_a(j, 70.0F); this.ironGolemLeftArm.rotateAngleX = 0.0F; - } - else - { - this.ironGolemRightArm.rotateAngleX = (-0.2F + 1.5F * this.func_78172_a(p_78086_2_, 13.0F)) * p_78086_3_; + } else { + this.ironGolemRightArm.rotateAngleX = + (-0.2F + 1.5F * this.func_78172_a(p_78086_2_, 13.0F)) * p_78086_3_; this.ironGolemLeftArm.rotateAngleX = (-0.2F - 1.5F * this.func_78172_a(p_78086_2_, 13.0F)) * p_78086_3_; } } } - private float func_78172_a(float p_78172_1_, float p_78172_2_) - { + private float func_78172_a(float p_78172_1_, float p_78172_2_) { return (Math.abs(p_78172_1_ % p_78172_2_ - p_78172_2_ * 0.5F) - p_78172_2_ * 0.25F) / (p_78172_2_ * 0.25F); } -} \ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/core/client/model/tabula/ModelTabulaBase.java b/src/main/java/gtPlusPlus/core/client/model/tabula/ModelTabulaBase.java index 3a0cbb636b..2ec6e4f06d 100644 --- a/src/main/java/gtPlusPlus/core/client/model/tabula/ModelTabulaBase.java +++ b/src/main/java/gtPlusPlus/core/client/model/tabula/ModelTabulaBase.java @@ -1,6 +1,5 @@ package gtPlusPlus.core.client.model.tabula; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.data.Pair; import net.minecraft.client.model.ModelBase; @@ -11,20 +10,19 @@ import net.minecraft.client.model.ModelRenderer; * Created using Tabula 4.1.1 */ public abstract class ModelTabulaBase extends ModelBase { - - + public ModelTabulaBase(int aTexWidth, int aTexHeight) { this.textureWidth = aTexWidth; this.textureHeight = aTexHeight; } - + protected abstract AutoMap> getModelParts(); - + public void renderAll() { - for (Pair part : getModelParts()) { - //Logger.INFO("Rendering EggBox"); - part.getKey().render(part.getValue()); - } + for (Pair part : getModelParts()) { + // Logger.INFO("Rendering EggBox"); + part.getKey().render(part.getValue()); + } } /** diff --git a/src/main/java/gtPlusPlus/core/client/renderer/CustomItemBlockRenderer.java b/src/main/java/gtPlusPlus/core/client/renderer/CustomItemBlockRenderer.java index f40357495a..b24bc48dbd 100644 --- a/src/main/java/gtPlusPlus/core/client/renderer/CustomItemBlockRenderer.java +++ b/src/main/java/gtPlusPlus/core/client/renderer/CustomItemBlockRenderer.java @@ -7,79 +7,78 @@ import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraftforge.client.IItemRenderer; - import org.lwjgl.opengl.GL11; - /** * Easy way of rendering an item which should look like a block. * Borrowed. - * + * * @author King Lemming - * + * */ public class CustomItemBlockRenderer implements IItemRenderer { - public static CustomItemBlockRenderer instance = new CustomItemBlockRenderer(); + public static CustomItemBlockRenderer instance = new CustomItemBlockRenderer(); - @Override - public boolean handleRenderType(ItemStack item, ItemRenderType type) { - return true; - } + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + return true; + } - @Override - public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { - return true; - } + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return true; + } - @Override - public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { - double offset = -0.5; - if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { - offset = 0; - } else if (type == ItemRenderType.ENTITY) { - GL11.glScalef(0.5F, 0.5F, 0.5F); - } - renderItemAsBlock((RenderBlocks) data[0], item, offset, offset, offset); - } - - public static void renderItemAsBlock(RenderBlocks renderer, ItemStack item, double translateX, double translateY, double translateZ) { + double offset = -0.5; + if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { + offset = 0; + } else if (type == ItemRenderType.ENTITY) { + GL11.glScalef(0.5F, 0.5F, 0.5F); + } + renderItemAsBlock((RenderBlocks) data[0], item, offset, offset, offset); + } - renderTextureAsBlock(renderer, item.getIconIndex(), translateX, translateY, translateZ); - } + public static void renderItemAsBlock( + RenderBlocks renderer, ItemStack item, double translateX, double translateY, double translateZ) { - public static void renderTextureAsBlock(RenderBlocks renderer, IIcon texture, double translateX, double translateY, double translateZ) { + renderTextureAsBlock(renderer, item.getIconIndex(), translateX, translateY, translateZ); + } - Tessellator tessellator = Tessellator.instance; - Block block = Blocks.stone; + public static void renderTextureAsBlock( + RenderBlocks renderer, IIcon texture, double translateX, double translateY, double translateZ) { - if (texture == null) { - return; - } - renderer.setRenderBoundsFromBlock(block); - GL11.glTranslated(translateX, translateY, translateZ); - tessellator.startDrawingQuads(); + Tessellator tessellator = Tessellator.instance; + Block block = Blocks.stone; - tessellator.setNormal(0.0F, -1.0F, 0.0F); - renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, texture); + if (texture == null) { + return; + } + renderer.setRenderBoundsFromBlock(block); + GL11.glTranslated(translateX, translateY, translateZ); + tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 1.0F, 0.0F); - renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, texture); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, texture); - tessellator.setNormal(0.0F, 0.0F, -1.0F); - renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, texture); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, texture); - tessellator.setNormal(0.0F, 0.0F, 1.0F); - renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, texture); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, texture); - tessellator.setNormal(-1.0F, 0.0F, 0.0F); - renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, texture); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, texture); - tessellator.setNormal(1.0F, 0.0F, 0.0F); - renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, texture); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, texture); - tessellator.draw(); - } + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, texture); + tessellator.draw(); + } } diff --git a/src/main/java/gtPlusPlus/core/client/renderer/CustomOreBlockRenderer.java b/src/main/java/gtPlusPlus/core/client/renderer/CustomOreBlockRenderer.java index a0b34d3b0b..793e7093cb 100644 --- a/src/main/java/gtPlusPlus/core/client/renderer/CustomOreBlockRenderer.java +++ b/src/main/java/gtPlusPlus/core/client/renderer/CustomOreBlockRenderer.java @@ -1,7 +1,5 @@ package gtPlusPlus.core.client.renderer; -import org.lwjgl.opengl.GL11; - import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.client.registry.RenderingRegistry; import gregtech.api.interfaces.ITexture; @@ -14,443 +12,537 @@ import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; +import org.lwjgl.opengl.GL11; public class CustomOreBlockRenderer implements ISimpleBlockRenderingHandler { - public static CustomOreBlockRenderer INSTANCE; - public final int mRenderID; - - public CustomOreBlockRenderer() { - INSTANCE = this; - this.mRenderID = RenderingRegistry.getNextAvailableRenderId(); - RenderingRegistry.registerBlockHandler(this); - Logger.INFO("Registered Custom Ore Block Renderer."); - } - - public boolean renderStandardBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, RenderBlocks aRenderer) { - Block tTileEntity = aBlock; - if ((tTileEntity instanceof ITexturedBlock)) { - return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer, new ITexture[][]{((ITexturedBlock) tTileEntity).getTexture((byte) 0), ((ITexturedBlock) tTileEntity).getTexture((byte) 1), ((ITexturedBlock) tTileEntity).getTexture((byte) 2), ((ITexturedBlock) tTileEntity).getTexture((byte) 3), ((ITexturedBlock) tTileEntity).getTexture((byte) 4), ((ITexturedBlock) tTileEntity).getTexture((byte) 5)}); - } - return 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); - int l = aBlock.colorMultiplier(aWorld, aX, aY, aZ); - float RED = (float)(l >> 16 & 255) / 255.0F; - float GREEN = (float)(l >> 8 & 255) / 255.0F; - float BLUE = (float)(l & 255) / 255.0F; - - if (Minecraft.isAmbientOcclusionEnabled() && aBlock.getLightValue() == 0){ - if (RenderBlocks.getInstance().partialRenderBounds){ - return INSTANCE.renderStandardBlockWithAmbientOcclusionPartial(aWorld, aRenderer, aTextures, aBlock, aX, aY, aZ, RED, GREEN, BLUE); - } - else { - return INSTANCE.renderStandardBlockWithAmbientOcclusion(aWorld, aRenderer, aTextures, aBlock, aX, aY, aZ, RED, GREEN, BLUE); - } - } - else { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[0], true); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[1], true); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[2], true); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[3], true); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[4], true); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[5], true); - } - return true; - } - - public static void renderFaceYNeg(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, ITexture[][] aIcon) { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aIcon[0], true); - } - public static void renderFaceYPos(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, ITexture[][] aIcon) { - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aIcon[1], true); - } - public static void renderFaceZNeg(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, ITexture[][] aIcon) { - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aIcon[2], true); - } - public static void renderFaceZPos(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, ITexture[][] aIcon) { - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aIcon[3], true); - } - public static void renderFaceXNeg(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, ITexture[][] aIcon) { - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aIcon[4], true); - } - public static void renderFaceXPos(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, ITexture[][] aIcon) { - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aIcon[5], true); - } - - public static void renderNegativeYFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, ITexture[] aIcon, boolean aFullBlock) { - if (aWorld != null) { - if ((aFullBlock) && (!aBlock.shouldSideBeRendered(aWorld, aX, aY - 1, aZ, 0))) { - return; - } - Tessellator.instance.setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aFullBlock ? aY - 1 : aY, aZ)); - } - if (aIcon != null) { - for (int i = 0; i < aIcon.length; i++) { - if (aIcon[i] != null) { - aIcon[i].renderYNeg(aRenderer, aBlock, aX, aY, aZ); - } - } - } - aRenderer.flipTexture = false; - } - - public static void renderPositiveYFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, ITexture[] aIcon, boolean aFullBlock) { - if (aWorld != null) { - if ((aFullBlock) && (!aBlock.shouldSideBeRendered(aWorld, aX, aY + 1, aZ, 1))) { - return; - } - Tessellator.instance.setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aFullBlock ? aY + 1 : aY, aZ)); - } - if (aIcon != null) { - for (int i = 0; i < aIcon.length; i++) { - if (aIcon[i] != null) { - aIcon[i].renderYPos(aRenderer, aBlock, aX, aY, aZ); - } - } - } - aRenderer.flipTexture = false; - } - - public static void renderNegativeZFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, ITexture[] aIcon, boolean aFullBlock) { - if (aWorld != null) { - if ((aFullBlock) && (!aBlock.shouldSideBeRendered(aWorld, aX, aY, aZ - 1, 2))) { - return; - } - Tessellator.instance.setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aY, aFullBlock ? aZ - 1 : aZ)); - } - aRenderer.flipTexture = (!aFullBlock); - if (aIcon != null) { - for (int i = 0; i < aIcon.length; i++) { - if (aIcon[i] != null) { - aIcon[i].renderZNeg(aRenderer, aBlock, aX, aY, aZ); - } - } - } - aRenderer.flipTexture = false; - } - - public static void renderPositiveZFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, ITexture[] aIcon, boolean aFullBlock) { - if (aWorld != null) { - if ((aFullBlock) && (!aBlock.shouldSideBeRendered(aWorld, aX, aY, aZ + 1, 3))) { - return; - } - Tessellator.instance.setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aY, aFullBlock ? aZ + 1 : aZ)); - } - if (aIcon != null) { - for (int i = 0; i < aIcon.length; i++) { - if (aIcon[i] != null) { - aIcon[i].renderZPos(aRenderer, aBlock, aX, aY, aZ); - } - } - } - aRenderer.flipTexture = false; - } - - public static void renderNegativeXFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, ITexture[] aIcon, boolean aFullBlock) { - if (aWorld != null) { - if ((aFullBlock) && (!aBlock.shouldSideBeRendered(aWorld, aX - 1, aY, aZ, 4))) { - return; - } - Tessellator.instance.setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aFullBlock ? aX - 1 : aX, aY, aZ)); - } - if (aIcon != null) { - for (int i = 0; i < aIcon.length; i++) { - if (aIcon[i] != null) { - aIcon[i].renderXNeg(aRenderer, aBlock, aX, aY, aZ); - } - } - } - aRenderer.flipTexture = false; - } - - public static void renderPositiveXFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, ITexture[] aIcon, boolean aFullBlock) { - if (aWorld != null) { - if ((aFullBlock) && (!aBlock.shouldSideBeRendered(aWorld, aX + 1, aY, aZ, 5))) { - return; - } - Tessellator.instance.setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aFullBlock ? aX + 1 : aX, aY, aZ)); - } - aRenderer.flipTexture = (!aFullBlock); - if (aIcon != null) { - for (int i = 0; i < aIcon.length; i++) { - if (aIcon[i] != null) { - aIcon[i].renderXPos(aRenderer, aBlock, aX, aY, aZ); - } - } - } - aRenderer.flipTexture = false; - } - - public void renderInventoryBlock(Block aBlock, int aMeta, int aModelID, RenderBlocks aRenderer) { - aBlock.setBlockBoundsForItemRender(); - aRenderer.setRenderBoundsFromBlock(aBlock); - GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, -1.0F, 0.0F); - renderNegativeYFacing(null, aRenderer, aBlock, 0, 0, 0, ((ITexturedBlock) aBlock).getTexture((byte) 0), true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, 1.0F, 0.0F); - renderPositiveYFacing(null, aRenderer, aBlock, 0, 0, 0, ((ITexturedBlock) aBlock).getTexture((byte) 1), true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, 0.0F, -1.0F); - renderNegativeZFacing(null, aRenderer, aBlock, 0, 0, 0, ((ITexturedBlock) aBlock).getTexture((byte) 2), true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, 0.0F, 1.0F); - renderPositiveZFacing(null, aRenderer, aBlock, 0, 0, 0, ((ITexturedBlock) aBlock).getTexture((byte) 3), true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(-1.0F, 0.0F, 0.0F); - renderNegativeXFacing(null, aRenderer, aBlock, 0, 0, 0, ((ITexturedBlock) aBlock).getTexture((byte) 4), true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(1.0F, 0.0F, 0.0F); - renderPositiveXFacing(null, aRenderer, aBlock, 0, 0, 0, ((ITexturedBlock) aBlock).getTexture((byte) 5), 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 renderWorldBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, int aModelID, RenderBlocks aRenderer) { - blockAccess = aWorld; - return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); - } - - public boolean shouldRender3DInInventory(int aModel) { - return true; - } - - public int getRenderId() { - return this.mRenderID; - } - - public void setRenderBounds(double p_147782_1_, double p_147782_3_, double p_147782_5_, double p_147782_7_, double p_147782_9_, double p_147782_11_) - { - if (!this.lockBlockBounds) - { - this.renderMinX = p_147782_1_; - this.renderMaxX = p_147782_7_; - this.renderMinY = p_147782_3_; - this.renderMaxY = p_147782_9_; - this.renderMinZ = p_147782_5_; - this.renderMaxZ = p_147782_11_; - this.partialRenderBounds = this.minecraftRB.gameSettings.ambientOcclusion >= 2 && (this.renderMinX > 0.0D || this.renderMaxX < 1.0D || this.renderMinY > 0.0D || this.renderMaxY < 1.0D || this.renderMinZ > 0.0D || this.renderMaxZ < 1.0D); - } - } - - /** - * Like setRenderBounds, but automatically pulling the bounds from the given Block. - */ - public void setRenderBoundsFromBlock(Block block) - { - if (!this.lockBlockBounds) - { - this.renderMinX = block.getBlockBoundsMinX(); - this.renderMaxX = block.getBlockBoundsMaxX(); - this.renderMinY = block.getBlockBoundsMinY(); - this.renderMaxY = block.getBlockBoundsMaxY(); - this.renderMinZ = block.getBlockBoundsMinZ(); - this.renderMaxZ = block.getBlockBoundsMaxZ(); - this.partialRenderBounds = this.minecraftRB.gameSettings.ambientOcclusion >= 2 && (this.renderMinX > 0.0D || this.renderMaxX < 1.0D || this.renderMinY > 0.0D || this.renderMaxY < 1.0D || this.renderMinZ > 0.0D || this.renderMaxZ < 1.0D); - } - } - - /** - * Vanilla Variables - */ - - /** The minimum X value for rendering (default 0.0). */ - public double renderMinX; - /** The maximum X value for rendering (default 1.0). */ - public double renderMaxX; - /** The minimum Y value for rendering (default 0.0). */ - public double renderMinY; - /** The maximum Y value for rendering (default 1.0). */ - public double renderMaxY; - /** The minimum Z value for rendering (default 0.0). */ - public double renderMinZ; - /** The maximum Z value for rendering (default 1.0). */ - public double renderMaxZ; - public boolean lockBlockBounds; - public boolean partialRenderBounds; - public final Minecraft minecraftRB = RenderBlocks.getInstance().minecraftRB; - public int uvRotateEast; - public int uvRotateWest; - public int uvRotateSouth; - public int uvRotateNorth; - public int uvRotateTop; - public int uvRotateBottom; - /** Whether ambient occlusion is enabled or not */ - public boolean enableAO; - /** Used as a scratch variable for ambient occlusion on the north/bottom/east corner. */ - public float aoLightValueScratchXYZNNN; - /** Used as a scratch variable for ambient occlusion between the bottom face and the north face. */ - public float aoLightValueScratchXYNN; - /** Used as a scratch variable for ambient occlusion on the north/bottom/west corner. */ - public float aoLightValueScratchXYZNNP; - /** Used as a scratch variable for ambient occlusion between the bottom face and the east face. */ - public float aoLightValueScratchYZNN; - /** Used as a scratch variable for ambient occlusion between the bottom face and the west face. */ - public float aoLightValueScratchYZNP; - /** Used as a scratch variable for ambient occlusion on the south/bottom/east corner. */ - public float aoLightValueScratchXYZPNN; - /** Used as a scratch variable for ambient occlusion between the bottom face and the south face. */ - public float aoLightValueScratchXYPN; - /** Used as a scratch variable for ambient occlusion on the south/bottom/west corner. */ - public float aoLightValueScratchXYZPNP; - /** Used as a scratch variable for ambient occlusion on the north/top/east corner. */ - public float aoLightValueScratchXYZNPN; - /** Used as a scratch variable for ambient occlusion between the top face and the north face. */ - public float aoLightValueScratchXYNP; - /** Used as a scratch variable for ambient occlusion on the north/top/west corner. */ - public float aoLightValueScratchXYZNPP; - /** Used as a scratch variable for ambient occlusion between the top face and the east face. */ - public float aoLightValueScratchYZPN; - /** Used as a scratch variable for ambient occlusion on the south/top/east corner. */ - public float aoLightValueScratchXYZPPN; - /** Used as a scratch variable for ambient occlusion between the top face and the south face. */ - public float aoLightValueScratchXYPP; - /** Used as a scratch variable for ambient occlusion between the top face and the west face. */ - public float aoLightValueScratchYZPP; - /** Used as a scratch variable for ambient occlusion on the south/top/west corner. */ - public float aoLightValueScratchXYZPPP; - /** Used as a scratch variable for ambient occlusion between the north face and the east face. */ - public float aoLightValueScratchXZNN; - /** Used as a scratch variable for ambient occlusion between the south face and the east face. */ - public float aoLightValueScratchXZPN; - /** Used as a scratch variable for ambient occlusion between the north face and the west face. */ - public float aoLightValueScratchXZNP; - /** Used as a scratch variable for ambient occlusion between the south face and the west face. */ - public float aoLightValueScratchXZPP; - /** Ambient occlusion brightness XYZNNN */ - public int aoBrightnessXYZNNN; - /** Ambient occlusion brightness XYNN */ - public int aoBrightnessXYNN; - /** Ambient occlusion brightness XYZNNP */ - public int aoBrightnessXYZNNP; - /** Ambient occlusion brightness YZNN */ - public int aoBrightnessYZNN; - /** Ambient occlusion brightness YZNP */ - public int aoBrightnessYZNP; - /** Ambient occlusion brightness XYZPNN */ - public int aoBrightnessXYZPNN; - /** Ambient occlusion brightness XYPN */ - public int aoBrightnessXYPN; - /** Ambient occlusion brightness XYZPNP */ - public int aoBrightnessXYZPNP; - /** Ambient occlusion brightness XYZNPN */ - public int aoBrightnessXYZNPN; - /** Ambient occlusion brightness XYNP */ - public int aoBrightnessXYNP; - /** Ambient occlusion brightness XYZNPP */ - public int aoBrightnessXYZNPP; - /** Ambient occlusion brightness YZPN */ - public int aoBrightnessYZPN; - /** Ambient occlusion brightness XYZPPN */ - public int aoBrightnessXYZPPN; - /** Ambient occlusion brightness XYPP */ - public int aoBrightnessXYPP; - /** Ambient occlusion brightness YZPP */ - public int aoBrightnessYZPP; - /** Ambient occlusion brightness XYZPPP */ - public int aoBrightnessXYZPPP; - /** Ambient occlusion brightness XZNN */ - public int aoBrightnessXZNN; - /** Ambient occlusion brightness XZPN */ - public int aoBrightnessXZPN; - /** Ambient occlusion brightness XZNP */ - public int aoBrightnessXZNP; - /** Ambient occlusion brightness XZPP */ - public int aoBrightnessXZPP; - /** Brightness top left */ - public int brightnessTopLeft; - /** Brightness bottom left */ - public int brightnessBottomLeft; - /** Brightness bottom right */ - public int brightnessBottomRight; - /** Brightness top right */ - public int brightnessTopRight; - /** Red color value for the top left corner */ - public float colorRedTopLeft; - /** Red color value for the bottom left corner */ - public float colorRedBottomLeft; - /** Red color value for the bottom right corner */ - public float colorRedBottomRight; - /** Red color value for the top right corner */ - public float colorRedTopRight; - /** Green color value for the top left corner */ - public float colorGreenTopLeft; - /** Green color value for the bottom left corner */ - public float colorGreenBottomLeft; - /** Green color value for the bottom right corner */ - public float colorGreenBottomRight; - /** Green color value for the top right corner */ - public float colorGreenTopRight; - /** Blue color value for the top left corner */ - public float colorBlueTopLeft; - /** Blue color value for the bottom left corner */ - public float colorBlueBottomLeft; - /** Blue color value for the bottom right corner */ - public float colorBlueBottomRight; - /** Blue color value for the top right corner */ - public float colorBlueTopRight; - /** If set to >=0, all block faces will be rendered using this texture index */ - public IIcon overrideBlockTexture; - /** - * Clear override block texture - */ - public void clearOverrideBlockTexture() - { - this.overrideBlockTexture = null; - } - - public boolean hasOverrideBlockTexture() - { - return this.overrideBlockTexture != null; - } - - public IIcon getBlockIcon(Block block, IBlockAccess access, int x, int y, int z, int side) - { - return this.getIconSafe(block.getIcon(access, x, y, z, side)); - } - - public IIcon getBlockIconFromSideAndMetadata(Block block, int side, int meta) - { - return this.getIconSafe(block.getIcon(side, meta)); - } - - public IIcon getBlockIconFromSide(Block block, int side) - { - return this.getIconSafe(block.getBlockTextureFromSide(side)); - } - - public IIcon getBlockIcon(Block block) - { - return this.getIconSafe(block.getBlockTextureFromSide(1)); - } - - public IIcon getIconSafe(IIcon iicon) - { - if (iicon == null) - { - iicon = ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno"); - } - - return (IIcon)iicon; - } - - IBlockAccess blockAccess = RenderBlocks.getInstance().blockAccess; - - public boolean renderStandardBlockWithAmbientOcclusion(IBlockAccess aWorld, RenderBlocks aRenderer, ITexture[][] aTextures, Block block, int xPos, int yPos, int zPos, float R, float G, float B) - { + public static CustomOreBlockRenderer INSTANCE; + public final int mRenderID; + + public CustomOreBlockRenderer() { + INSTANCE = this; + this.mRenderID = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(this); + Logger.INFO("Registered Custom Ore Block Renderer."); + } + + public boolean renderStandardBlock( + IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, RenderBlocks aRenderer) { + Block tTileEntity = aBlock; + if ((tTileEntity instanceof ITexturedBlock)) { + return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer, new ITexture[][] { + ((ITexturedBlock) tTileEntity).getTexture((byte) 0), + ((ITexturedBlock) tTileEntity).getTexture((byte) 1), + ((ITexturedBlock) tTileEntity).getTexture((byte) 2), + ((ITexturedBlock) tTileEntity).getTexture((byte) 3), + ((ITexturedBlock) tTileEntity).getTexture((byte) 4), + ((ITexturedBlock) tTileEntity).getTexture((byte) 5) + }); + } + return 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); + int l = aBlock.colorMultiplier(aWorld, aX, aY, aZ); + float RED = (float) (l >> 16 & 255) / 255.0F; + float GREEN = (float) (l >> 8 & 255) / 255.0F; + float BLUE = (float) (l & 255) / 255.0F; + + if (Minecraft.isAmbientOcclusionEnabled() && aBlock.getLightValue() == 0) { + if (RenderBlocks.getInstance().partialRenderBounds) { + return INSTANCE.renderStandardBlockWithAmbientOcclusionPartial( + aWorld, aRenderer, aTextures, aBlock, aX, aY, aZ, RED, GREEN, BLUE); + } else { + return INSTANCE.renderStandardBlockWithAmbientOcclusion( + aWorld, aRenderer, aTextures, aBlock, aX, aY, aZ, RED, GREEN, BLUE); + } + } else { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[0], true); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[1], true); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[2], true); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[3], true); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[4], true); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[5], true); + } + return true; + } + + public static void renderFaceYNeg( + IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, ITexture[][] aIcon) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aIcon[0], true); + } + + public static void renderFaceYPos( + IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, ITexture[][] aIcon) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aIcon[1], true); + } + + public static void renderFaceZNeg( + IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, ITexture[][] aIcon) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aIcon[2], true); + } + + public static void renderFaceZPos( + IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, ITexture[][] aIcon) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aIcon[3], true); + } + + public static void renderFaceXNeg( + IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, ITexture[][] aIcon) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aIcon[4], true); + } + + public static void renderFaceXPos( + IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, ITexture[][] aIcon) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aIcon[5], true); + } + + public static void renderNegativeYFacing( + IBlockAccess aWorld, + RenderBlocks aRenderer, + Block aBlock, + int aX, + int aY, + int aZ, + ITexture[] aIcon, + boolean aFullBlock) { + if (aWorld != null) { + if ((aFullBlock) && (!aBlock.shouldSideBeRendered(aWorld, aX, aY - 1, aZ, 0))) { + return; + } + Tessellator.instance.setBrightness( + aBlock.getMixedBrightnessForBlock(aWorld, aX, aFullBlock ? aY - 1 : aY, aZ)); + } + if (aIcon != null) { + for (int i = 0; i < aIcon.length; i++) { + if (aIcon[i] != null) { + aIcon[i].renderYNeg(aRenderer, aBlock, aX, aY, aZ); + } + } + } + aRenderer.flipTexture = false; + } + + public static void renderPositiveYFacing( + IBlockAccess aWorld, + RenderBlocks aRenderer, + Block aBlock, + int aX, + int aY, + int aZ, + ITexture[] aIcon, + boolean aFullBlock) { + if (aWorld != null) { + if ((aFullBlock) && (!aBlock.shouldSideBeRendered(aWorld, aX, aY + 1, aZ, 1))) { + return; + } + Tessellator.instance.setBrightness( + aBlock.getMixedBrightnessForBlock(aWorld, aX, aFullBlock ? aY + 1 : aY, aZ)); + } + if (aIcon != null) { + for (int i = 0; i < aIcon.length; i++) { + if (aIcon[i] != null) { + aIcon[i].renderYPos(aRenderer, aBlock, aX, aY, aZ); + } + } + } + aRenderer.flipTexture = false; + } + + public static void renderNegativeZFacing( + IBlockAccess aWorld, + RenderBlocks aRenderer, + Block aBlock, + int aX, + int aY, + int aZ, + ITexture[] aIcon, + boolean aFullBlock) { + if (aWorld != null) { + if ((aFullBlock) && (!aBlock.shouldSideBeRendered(aWorld, aX, aY, aZ - 1, 2))) { + return; + } + Tessellator.instance.setBrightness( + aBlock.getMixedBrightnessForBlock(aWorld, aX, aY, aFullBlock ? aZ - 1 : aZ)); + } + aRenderer.flipTexture = (!aFullBlock); + if (aIcon != null) { + for (int i = 0; i < aIcon.length; i++) { + if (aIcon[i] != null) { + aIcon[i].renderZNeg(aRenderer, aBlock, aX, aY, aZ); + } + } + } + aRenderer.flipTexture = false; + } + + public static void renderPositiveZFacing( + IBlockAccess aWorld, + RenderBlocks aRenderer, + Block aBlock, + int aX, + int aY, + int aZ, + ITexture[] aIcon, + boolean aFullBlock) { + if (aWorld != null) { + if ((aFullBlock) && (!aBlock.shouldSideBeRendered(aWorld, aX, aY, aZ + 1, 3))) { + return; + } + Tessellator.instance.setBrightness( + aBlock.getMixedBrightnessForBlock(aWorld, aX, aY, aFullBlock ? aZ + 1 : aZ)); + } + if (aIcon != null) { + for (int i = 0; i < aIcon.length; i++) { + if (aIcon[i] != null) { + aIcon[i].renderZPos(aRenderer, aBlock, aX, aY, aZ); + } + } + } + aRenderer.flipTexture = false; + } + + public static void renderNegativeXFacing( + IBlockAccess aWorld, + RenderBlocks aRenderer, + Block aBlock, + int aX, + int aY, + int aZ, + ITexture[] aIcon, + boolean aFullBlock) { + if (aWorld != null) { + if ((aFullBlock) && (!aBlock.shouldSideBeRendered(aWorld, aX - 1, aY, aZ, 4))) { + return; + } + Tessellator.instance.setBrightness( + aBlock.getMixedBrightnessForBlock(aWorld, aFullBlock ? aX - 1 : aX, aY, aZ)); + } + if (aIcon != null) { + for (int i = 0; i < aIcon.length; i++) { + if (aIcon[i] != null) { + aIcon[i].renderXNeg(aRenderer, aBlock, aX, aY, aZ); + } + } + } + aRenderer.flipTexture = false; + } + + public static void renderPositiveXFacing( + IBlockAccess aWorld, + RenderBlocks aRenderer, + Block aBlock, + int aX, + int aY, + int aZ, + ITexture[] aIcon, + boolean aFullBlock) { + if (aWorld != null) { + if ((aFullBlock) && (!aBlock.shouldSideBeRendered(aWorld, aX + 1, aY, aZ, 5))) { + return; + } + Tessellator.instance.setBrightness( + aBlock.getMixedBrightnessForBlock(aWorld, aFullBlock ? aX + 1 : aX, aY, aZ)); + } + aRenderer.flipTexture = (!aFullBlock); + if (aIcon != null) { + for (int i = 0; i < aIcon.length; i++) { + if (aIcon[i] != null) { + aIcon[i].renderXPos(aRenderer, aBlock, aX, aY, aZ); + } + } + } + aRenderer.flipTexture = false; + } + + public void renderInventoryBlock(Block aBlock, int aMeta, int aModelID, RenderBlocks aRenderer) { + aBlock.setBlockBoundsForItemRender(); + aRenderer.setRenderBoundsFromBlock(aBlock); + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, -1.0F, 0.0F); + renderNegativeYFacing(null, aRenderer, aBlock, 0, 0, 0, ((ITexturedBlock) aBlock).getTexture((byte) 0), true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 1.0F, 0.0F); + renderPositiveYFacing(null, aRenderer, aBlock, 0, 0, 0, ((ITexturedBlock) aBlock).getTexture((byte) 1), true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 0.0F, -1.0F); + renderNegativeZFacing(null, aRenderer, aBlock, 0, 0, 0, ((ITexturedBlock) aBlock).getTexture((byte) 2), true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 0.0F, 1.0F); + renderPositiveZFacing(null, aRenderer, aBlock, 0, 0, 0, ((ITexturedBlock) aBlock).getTexture((byte) 3), true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(-1.0F, 0.0F, 0.0F); + renderNegativeXFacing(null, aRenderer, aBlock, 0, 0, 0, ((ITexturedBlock) aBlock).getTexture((byte) 4), true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(1.0F, 0.0F, 0.0F); + renderPositiveXFacing(null, aRenderer, aBlock, 0, 0, 0, ((ITexturedBlock) aBlock).getTexture((byte) 5), 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 renderWorldBlock( + IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, int aModelID, RenderBlocks aRenderer) { + blockAccess = aWorld; + return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); + } + + public boolean shouldRender3DInInventory(int aModel) { + return true; + } + + public int getRenderId() { + return this.mRenderID; + } + + public void setRenderBounds( + double p_147782_1_, + double p_147782_3_, + double p_147782_5_, + double p_147782_7_, + double p_147782_9_, + double p_147782_11_) { + if (!this.lockBlockBounds) { + this.renderMinX = p_147782_1_; + this.renderMaxX = p_147782_7_; + this.renderMinY = p_147782_3_; + this.renderMaxY = p_147782_9_; + this.renderMinZ = p_147782_5_; + this.renderMaxZ = p_147782_11_; + this.partialRenderBounds = this.minecraftRB.gameSettings.ambientOcclusion >= 2 + && (this.renderMinX > 0.0D + || this.renderMaxX < 1.0D + || this.renderMinY > 0.0D + || this.renderMaxY < 1.0D + || this.renderMinZ > 0.0D + || this.renderMaxZ < 1.0D); + } + } + + /** + * Like setRenderBounds, but automatically pulling the bounds from the given Block. + */ + public void setRenderBoundsFromBlock(Block block) { + if (!this.lockBlockBounds) { + this.renderMinX = block.getBlockBoundsMinX(); + this.renderMaxX = block.getBlockBoundsMaxX(); + this.renderMinY = block.getBlockBoundsMinY(); + this.renderMaxY = block.getBlockBoundsMaxY(); + this.renderMinZ = block.getBlockBoundsMinZ(); + this.renderMaxZ = block.getBlockBoundsMaxZ(); + this.partialRenderBounds = this.minecraftRB.gameSettings.ambientOcclusion >= 2 + && (this.renderMinX > 0.0D + || this.renderMaxX < 1.0D + || this.renderMinY > 0.0D + || this.renderMaxY < 1.0D + || this.renderMinZ > 0.0D + || this.renderMaxZ < 1.0D); + } + } + + /** + * Vanilla Variables + */ + + /** The minimum X value for rendering (default 0.0). */ + public double renderMinX; + /** The maximum X value for rendering (default 1.0). */ + public double renderMaxX; + /** The minimum Y value for rendering (default 0.0). */ + public double renderMinY; + /** The maximum Y value for rendering (default 1.0). */ + public double renderMaxY; + /** The minimum Z value for rendering (default 0.0). */ + public double renderMinZ; + /** The maximum Z value for rendering (default 1.0). */ + public double renderMaxZ; + + public boolean lockBlockBounds; + public boolean partialRenderBounds; + public final Minecraft minecraftRB = RenderBlocks.getInstance().minecraftRB; + public int uvRotateEast; + public int uvRotateWest; + public int uvRotateSouth; + public int uvRotateNorth; + public int uvRotateTop; + public int uvRotateBottom; + /** Whether ambient occlusion is enabled or not */ + public boolean enableAO; + /** Used as a scratch variable for ambient occlusion on the north/bottom/east corner. */ + public float aoLightValueScratchXYZNNN; + /** Used as a scratch variable for ambient occlusion between the bottom face and the north face. */ + public float aoLightValueScratchXYNN; + /** Used as a scratch variable for ambient occlusion on the north/bottom/west corner. */ + public float aoLightValueScratchXYZNNP; + /** Used as a scratch variable for ambient occlusion between the bottom face and the east face. */ + public float aoLightValueScratchYZNN; + /** Used as a scratch variable for ambient occlusion between the bottom face and the west face. */ + public float aoLightValueScratchYZNP; + /** Used as a scratch variable for ambient occlusion on the south/bottom/east corner. */ + public float aoLightValueScratchXYZPNN; + /** Used as a scratch variable for ambient occlusion between the bottom face and the south face. */ + public float aoLightValueScratchXYPN; + /** Used as a scratch variable for ambient occlusion on the south/bottom/west corner. */ + public float aoLightValueScratchXYZPNP; + /** Used as a scratch variable for ambient occlusion on the north/top/east corner. */ + public float aoLightValueScratchXYZNPN; + /** Used as a scratch variable for ambient occlusion between the top face and the north face. */ + public float aoLightValueScratchXYNP; + /** Used as a scratch variable for ambient occlusion on the north/top/west corner. */ + public float aoLightValueScratchXYZNPP; + /** Used as a scratch variable for ambient occlusion between the top face and the east face. */ + public float aoLightValueScratchYZPN; + /** Used as a scratch variable for ambient occlusion on the south/top/east corner. */ + public float aoLightValueScratchXYZPPN; + /** Used as a scratch variable for ambient occlusion between the top face and the south face. */ + public float aoLightValueScratchXYPP; + /** Used as a scratch variable for ambient occlusion between the top face and the west face. */ + public float aoLightValueScratchYZPP; + /** Used as a scratch variable for ambient occlusion on the south/top/west corner. */ + public float aoLightValueScratchXYZPPP; + /** Used as a scratch variable for ambient occlusion between the north face and the east face. */ + public float aoLightValueScratchXZNN; + /** Used as a scratch variable for ambient occlusion between the south face and the east face. */ + public float aoLightValueScratchXZPN; + /** Used as a scratch variable for ambient occlusion between the north face and the west face. */ + public float aoLightValueScratchXZNP; + /** Used as a scratch variable for ambient occlusion between the south face and the west face. */ + public float aoLightValueScratchXZPP; + /** Ambient occlusion brightness XYZNNN */ + public int aoBrightnessXYZNNN; + /** Ambient occlusion brightness XYNN */ + public int aoBrightnessXYNN; + /** Ambient occlusion brightness XYZNNP */ + public int aoBrightnessXYZNNP; + /** Ambient occlusion brightness YZNN */ + public int aoBrightnessYZNN; + /** Ambient occlusion brightness YZNP */ + public int aoBrightnessYZNP; + /** Ambient occlusion brightness XYZPNN */ + public int aoBrightnessXYZPNN; + /** Ambient occlusion brightness XYPN */ + public int aoBrightnessXYPN; + /** Ambient occlusion brightness XYZPNP */ + public int aoBrightnessXYZPNP; + /** Ambient occlusion brightness XYZNPN */ + public int aoBrightnessXYZNPN; + /** Ambient occlusion brightness XYNP */ + public int aoBrightnessXYNP; + /** Ambient occlusion brightness XYZNPP */ + public int aoBrightnessXYZNPP; + /** Ambient occlusion brightness YZPN */ + public int aoBrightnessYZPN; + /** Ambient occlusion brightness XYZPPN */ + public int aoBrightnessXYZPPN; + /** Ambient occlusion brightness XYPP */ + public int aoBrightnessXYPP; + /** Ambient occlusion brightness YZPP */ + public int aoBrightnessYZPP; + /** Ambient occlusion brightness XYZPPP */ + public int aoBrightnessXYZPPP; + /** Ambient occlusion brightness XZNN */ + public int aoBrightnessXZNN; + /** Ambient occlusion brightness XZPN */ + public int aoBrightnessXZPN; + /** Ambient occlusion brightness XZNP */ + public int aoBrightnessXZNP; + /** Ambient occlusion brightness XZPP */ + public int aoBrightnessXZPP; + /** Brightness top left */ + public int brightnessTopLeft; + /** Brightness bottom left */ + public int brightnessBottomLeft; + /** Brightness bottom right */ + public int brightnessBottomRight; + /** Brightness top right */ + public int brightnessTopRight; + /** Red color value for the top left corner */ + public float colorRedTopLeft; + /** Red color value for the bottom left corner */ + public float colorRedBottomLeft; + /** Red color value for the bottom right corner */ + public float colorRedBottomRight; + /** Red color value for the top right corner */ + public float colorRedTopRight; + /** Green color value for the top left corner */ + public float colorGreenTopLeft; + /** Green color value for the bottom left corner */ + public float colorGreenBottomLeft; + /** Green color value for the bottom right corner */ + public float colorGreenBottomRight; + /** Green color value for the top right corner */ + public float colorGreenTopRight; + /** Blue color value for the top left corner */ + public float colorBlueTopLeft; + /** Blue color value for the bottom left corner */ + public float colorBlueBottomLeft; + /** Blue color value for the bottom right corner */ + public float colorBlueBottomRight; + /** Blue color value for the top right corner */ + public float colorBlueTopRight; + /** If set to >=0, all block faces will be rendered using this texture index */ + public IIcon overrideBlockTexture; + /** + * Clear override block texture + */ + public void clearOverrideBlockTexture() { + this.overrideBlockTexture = null; + } + + public boolean hasOverrideBlockTexture() { + return this.overrideBlockTexture != null; + } + + public IIcon getBlockIcon(Block block, IBlockAccess access, int x, int y, int z, int side) { + return this.getIconSafe(block.getIcon(access, x, y, z, side)); + } + + public IIcon getBlockIconFromSideAndMetadata(Block block, int side, int meta) { + return this.getIconSafe(block.getIcon(side, meta)); + } + + public IIcon getBlockIconFromSide(Block block, int side) { + return this.getIconSafe(block.getBlockTextureFromSide(side)); + } + + public IIcon getBlockIcon(Block block) { + return this.getIconSafe(block.getBlockTextureFromSide(1)); + } + + public IIcon getIconSafe(IIcon iicon) { + if (iicon == null) { + iicon = ((TextureMap) + Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)) + .getAtlasSprite("missingno"); + } + + return (IIcon) iicon; + } + + IBlockAccess blockAccess = RenderBlocks.getInstance().blockAccess; + + public boolean renderStandardBlockWithAmbientOcclusion( + IBlockAccess aWorld, + RenderBlocks aRenderer, + ITexture[][] aTextures, + Block block, + int xPos, + int yPos, + int zPos, + float R, + float G, + float B) { this.enableAO = true; boolean flag = false; float f3 = 0.0F; @@ -462,12 +554,9 @@ public class CustomOreBlockRenderer implements ISimpleBlockRenderingHandler { Tessellator tessellator = Tessellator.instance; tessellator.setBrightness(983055); - if (this.getBlockIcon(block).getIconName().equals("grass_top")) - { + if (this.getBlockIcon(block).getIconName().equals("grass_top")) { flag1 = false; - } - else if (this.hasOverrideBlockTexture()) - { + } else if (this.hasOverrideBlockTexture()) { flag1 = false; } @@ -478,10 +567,9 @@ public class CustomOreBlockRenderer implements ISimpleBlockRenderingHandler { int i1; float f7; - if (RenderBlocks.getInstance().renderAllFaces || block.shouldSideBeRendered(blockAccess, xPos, yPos - 1, zPos, 0)) - { - if (this.renderMinY <= 0.0D) - { + if (RenderBlocks.getInstance().renderAllFaces + || block.shouldSideBeRendered(blockAccess, xPos, yPos - 1, zPos, 0)) { + if (this.renderMinY <= 0.0D) { --yPos; } @@ -489,92 +577,98 @@ public class CustomOreBlockRenderer implements ISimpleBlockRenderingHandler { this.aoBrightnessYZNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos - 1); this.aoBrightnessYZNP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos + 1); this.aoBrightnessXYPN = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos); - this.aoLightValueScratchXYNN = blockAccess.getBlock(xPos - 1, yPos, zPos).getAmbientOcclusionLightValue(); - this.aoLightValueScratchYZNN = blockAccess.getBlock(xPos, yPos, zPos - 1).getAmbientOcclusionLightValue(); - this.aoLightValueScratchYZNP = blockAccess.getBlock(xPos, yPos, zPos + 1).getAmbientOcclusionLightValue(); - this.aoLightValueScratchXYPN = blockAccess.getBlock(xPos + 1, yPos, zPos).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXYNN = + blockAccess.getBlock(xPos - 1, yPos, zPos).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZNN = + blockAccess.getBlock(xPos, yPos, zPos - 1).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZNP = + blockAccess.getBlock(xPos, yPos, zPos + 1).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXYPN = + blockAccess.getBlock(xPos + 1, yPos, zPos).getAmbientOcclusionLightValue(); flag2 = blockAccess.getBlock(xPos + 1, yPos - 1, zPos).getCanBlockGrass(); flag3 = blockAccess.getBlock(xPos - 1, yPos - 1, zPos).getCanBlockGrass(); flag4 = blockAccess.getBlock(xPos, yPos - 1, zPos + 1).getCanBlockGrass(); flag5 = blockAccess.getBlock(xPos, yPos - 1, zPos - 1).getCanBlockGrass(); - if (!flag5 && !flag3) - { + if (!flag5 && !flag3) { this.aoLightValueScratchXYZNNN = this.aoLightValueScratchXYNN; this.aoBrightnessXYZNNN = this.aoBrightnessXYNN; - } - else - { - this.aoLightValueScratchXYZNNN = blockAccess.getBlock(xPos - 1, yPos, zPos - 1).getAmbientOcclusionLightValue(); + } else { + this.aoLightValueScratchXYZNNN = + blockAccess.getBlock(xPos - 1, yPos, zPos - 1).getAmbientOcclusionLightValue(); this.aoBrightnessXYZNNN = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos - 1); } - if (!flag4 && !flag3) - { + if (!flag4 && !flag3) { this.aoLightValueScratchXYZNNP = this.aoLightValueScratchXYNN; this.aoBrightnessXYZNNP = this.aoBrightnessXYNN; - } - else - { - this.aoLightValueScratchXYZNNP = blockAccess.getBlock(xPos - 1, yPos, zPos + 1).getAmbientOcclusionLightValue(); + } else { + this.aoLightValueScratchXYZNNP = + blockAccess.getBlock(xPos - 1, yPos, zPos + 1).getAmbientOcclusionLightValue(); this.aoBrightnessXYZNNP = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos + 1); } - if (!flag5 && !flag2) - { + if (!flag5 && !flag2) { this.aoLightValueScratchXYZPNN = this.aoLightValueScratchXYPN; this.aoBrightnessXYZPNN = this.aoBrightnessXYPN; - } - else - { - this.aoLightValueScratchXYZPNN = blockAccess.getBlock(xPos + 1, yPos, zPos - 1).getAmbientOcclusionLightValue(); + } else { + this.aoLightValueScratchXYZPNN = + blockAccess.getBlock(xPos + 1, yPos, zPos - 1).getAmbientOcclusionLightValue(); this.aoBrightnessXYZPNN = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos - 1); } - if (!flag4 && !flag2) - { + if (!flag4 && !flag2) { this.aoLightValueScratchXYZPNP = this.aoLightValueScratchXYPN; this.aoBrightnessXYZPNP = this.aoBrightnessXYPN; - } - else - { - this.aoLightValueScratchXYZPNP = blockAccess.getBlock(xPos + 1, yPos, zPos + 1).getAmbientOcclusionLightValue(); + } else { + this.aoLightValueScratchXYZPNP = + blockAccess.getBlock(xPos + 1, yPos, zPos + 1).getAmbientOcclusionLightValue(); this.aoBrightnessXYZPNP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos + 1); } - if (this.renderMinY <= 0.0D) - { + if (this.renderMinY <= 0.0D) { ++yPos; } i1 = l; - if (this.renderMinY <= 0.0D || !blockAccess.getBlock(xPos, yPos - 1, zPos).isOpaqueCube()) - { + if (this.renderMinY <= 0.0D + || !blockAccess.getBlock(xPos, yPos - 1, zPos).isOpaqueCube()) { i1 = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos); } f7 = blockAccess.getBlock(xPos, yPos - 1, zPos).getAmbientOcclusionLightValue(); - f3 = (this.aoLightValueScratchXYZNNP + this.aoLightValueScratchXYNN + this.aoLightValueScratchYZNP + f7) / 4.0F; - f6 = (this.aoLightValueScratchYZNP + f7 + this.aoLightValueScratchXYZPNP + this.aoLightValueScratchXYPN) / 4.0F; - f5 = (f7 + this.aoLightValueScratchYZNN + this.aoLightValueScratchXYPN + this.aoLightValueScratchXYZPNN) / 4.0F; - f4 = (this.aoLightValueScratchXYNN + this.aoLightValueScratchXYZNNN + f7 + this.aoLightValueScratchYZNN) / 4.0F; - this.brightnessTopLeft = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXYZNNP, this.aoBrightnessXYNN, this.aoBrightnessYZNP, i1); - this.brightnessTopRight = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessYZNP, this.aoBrightnessXYZPNP, this.aoBrightnessXYPN, i1); - this.brightnessBottomRight = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessYZNN, this.aoBrightnessXYPN, this.aoBrightnessXYZPNN, i1); - this.brightnessBottomLeft = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXYNN, this.aoBrightnessXYZNNN, this.aoBrightnessYZNN, i1); - - if (flag1) - { - this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R * 0.5F; - this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G * 0.5F; - this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B * 0.5F; - } - else - { - this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.5F; - this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.5F; - this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.5F; + f3 = (this.aoLightValueScratchXYZNNP + this.aoLightValueScratchXYNN + this.aoLightValueScratchYZNP + f7) + / 4.0F; + f6 = (this.aoLightValueScratchYZNP + f7 + this.aoLightValueScratchXYZPNP + this.aoLightValueScratchXYPN) + / 4.0F; + f5 = (f7 + this.aoLightValueScratchYZNN + this.aoLightValueScratchXYPN + this.aoLightValueScratchXYZPNN) + / 4.0F; + f4 = (this.aoLightValueScratchXYNN + this.aoLightValueScratchXYZNNN + f7 + this.aoLightValueScratchYZNN) + / 4.0F; + this.brightnessTopLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYZNNP, this.aoBrightnessXYNN, this.aoBrightnessYZNP, i1); + this.brightnessTopRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZNP, this.aoBrightnessXYZPNP, this.aoBrightnessXYPN, i1); + this.brightnessBottomRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZNN, this.aoBrightnessXYPN, this.aoBrightnessXYZPNN, i1); + this.brightnessBottomLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYNN, this.aoBrightnessXYZNNN, this.aoBrightnessYZNN, i1); + + if (flag1) { + this.colorRedTopLeft = + this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R * 0.5F; + this.colorGreenTopLeft = + this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G * 0.5F; + this.colorBlueTopLeft = + this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B * 0.5F; + } else { + this.colorRedTopLeft = + this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.5F; + this.colorGreenTopLeft = + this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.5F; + this.colorBlueTopLeft = + this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.5F; } this.colorRedTopLeft *= f3; @@ -593,10 +687,9 @@ public class CustomOreBlockRenderer implements ISimpleBlockRenderingHandler { flag = true; } - if (RenderBlocks.getInstance().renderAllFaces || block.shouldSideBeRendered(blockAccess, xPos, yPos + 1, zPos, 1)) - { - if (this.renderMaxY >= 1.0D) - { + if (RenderBlocks.getInstance().renderAllFaces + || block.shouldSideBeRendered(blockAccess, xPos, yPos + 1, zPos, 1)) { + if (this.renderMaxY >= 1.0D) { ++yPos; } @@ -604,82 +697,86 @@ public class CustomOreBlockRenderer implements ISimpleBlockRenderingHandler { this.aoBrightnessXYPP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos); this.aoBrightnessYZPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos - 1); this.aoBrightnessYZPP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos + 1); - this.aoLightValueScratchXYNP = blockAccess.getBlock(xPos - 1, yPos, zPos).getAmbientOcclusionLightValue(); - this.aoLightValueScratchXYPP = blockAccess.getBlock(xPos + 1, yPos, zPos).getAmbientOcclusionLightValue(); - this.aoLightValueScratchYZPN = blockAccess.getBlock(xPos, yPos, zPos - 1).getAmbientOcclusionLightValue(); - this.aoLightValueScratchYZPP = blockAccess.getBlock(xPos, yPos, zPos + 1).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXYNP = + blockAccess.getBlock(xPos - 1, yPos, zPos).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXYPP = + blockAccess.getBlock(xPos + 1, yPos, zPos).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZPN = + blockAccess.getBlock(xPos, yPos, zPos - 1).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZPP = + blockAccess.getBlock(xPos, yPos, zPos + 1).getAmbientOcclusionLightValue(); flag2 = blockAccess.getBlock(xPos + 1, yPos + 1, zPos).getCanBlockGrass(); flag3 = blockAccess.getBlock(xPos - 1, yPos + 1, zPos).getCanBlockGrass(); flag4 = blockAccess.getBlock(xPos, yPos + 1, zPos + 1).getCanBlockGrass(); flag5 = blockAccess.getBlock(xPos, yPos + 1, zPos - 1).getCanBlockGrass(); - if (!flag5 && !flag3) - { + if (!flag5 && !flag3) { this.aoLightValueScratchXYZNPN = this.aoLightValueScratchXYNP; this.aoBrightnessXYZNPN = this.aoBrightnessXYNP; - } - else - { - this.aoLightValueScratchXYZNPN = blockAccess.getBlock(xPos - 1, yPos, zPos - 1).getAmbientOcclusionLightValue(); + } else { + this.aoLightValueScratchXYZNPN = + blockAccess.getBlock(xPos - 1, yPos, zPos - 1).getAmbientOcclusionLightValue(); this.aoBrightnessXYZNPN = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos - 1); } - if (!flag5 && !flag2) - { + if (!flag5 && !flag2) { this.aoLightValueScratchXYZPPN = this.aoLightValueScratchXYPP; this.aoBrightnessXYZPPN = this.aoBrightnessXYPP; - } - else - { - this.aoLightValueScratchXYZPPN = blockAccess.getBlock(xPos + 1, yPos, zPos - 1).getAmbientOcclusionLightValue(); + } else { + this.aoLightValueScratchXYZPPN = + blockAccess.getBlock(xPos + 1, yPos, zPos - 1).getAmbientOcclusionLightValue(); this.aoBrightnessXYZPPN = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos - 1); } - if (!flag4 && !flag3) - { + if (!flag4 && !flag3) { this.aoLightValueScratchXYZNPP = this.aoLightValueScratchXYNP; this.aoBrightnessXYZNPP = this.aoBrightnessXYNP; - } - else - { - this.aoLightValueScratchXYZNPP = blockAccess.getBlock(xPos - 1, yPos, zPos + 1).getAmbientOcclusionLightValue(); + } else { + this.aoLightValueScratchXYZNPP = + blockAccess.getBlock(xPos - 1, yPos, zPos + 1).getAmbientOcclusionLightValue(); this.aoBrightnessXYZNPP = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos + 1); } - if (!flag4 && !flag2) - { + if (!flag4 && !flag2) { this.aoLightValueScratchXYZPPP = this.aoLightValueScratchXYPP; this.aoBrightnessXYZPPP = this.aoBrightnessXYPP; - } - else - { - this.aoLightValueScratchXYZPPP = blockAccess.getBlock(xPos + 1, yPos, zPos + 1).getAmbientOcclusionLightValue(); + } else { + this.aoLightValueScratchXYZPPP = + blockAccess.getBlock(xPos + 1, yPos, zPos + 1).getAmbientOcclusionLightValue(); this.aoBrightnessXYZPPP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos + 1); } - if (this.renderMaxY >= 1.0D) - { + if (this.renderMaxY >= 1.0D) { --yPos; } i1 = l; - if (this.renderMaxY >= 1.0D || !blockAccess.getBlock(xPos, yPos + 1, zPos).isOpaqueCube()) - { + if (this.renderMaxY >= 1.0D + || !blockAccess.getBlock(xPos, yPos + 1, zPos).isOpaqueCube()) { i1 = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos); } f7 = blockAccess.getBlock(xPos, yPos + 1, zPos).getAmbientOcclusionLightValue(); - f6 = (this.aoLightValueScratchXYZNPP + this.aoLightValueScratchXYNP + this.aoLightValueScratchYZPP + f7) / 4.0F; - f3 = (this.aoLightValueScratchYZPP + f7 + this.aoLightValueScratchXYZPPP + this.aoLightValueScratchXYPP) / 4.0F; - f4 = (f7 + this.aoLightValueScratchYZPN + this.aoLightValueScratchXYPP + this.aoLightValueScratchXYZPPN) / 4.0F; - f5 = (this.aoLightValueScratchXYNP + this.aoLightValueScratchXYZNPN + f7 + this.aoLightValueScratchYZPN) / 4.0F; - this.brightnessTopRight = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXYZNPP, this.aoBrightnessXYNP, this.aoBrightnessYZPP, i1); - this.brightnessTopLeft = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessYZPP, this.aoBrightnessXYZPPP, this.aoBrightnessXYPP, i1); - this.brightnessBottomLeft = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessYZPN, this.aoBrightnessXYPP, this.aoBrightnessXYZPPN, i1); - this.brightnessBottomRight = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXYNP, this.aoBrightnessXYZNPN, this.aoBrightnessYZPN, i1); + f6 = (this.aoLightValueScratchXYZNPP + this.aoLightValueScratchXYNP + this.aoLightValueScratchYZPP + f7) + / 4.0F; + f3 = (this.aoLightValueScratchYZPP + f7 + this.aoLightValueScratchXYZPPP + this.aoLightValueScratchXYPP) + / 4.0F; + f4 = (f7 + this.aoLightValueScratchYZPN + this.aoLightValueScratchXYPP + this.aoLightValueScratchXYZPPN) + / 4.0F; + f5 = (this.aoLightValueScratchXYNP + this.aoLightValueScratchXYZNPN + f7 + this.aoLightValueScratchYZPN) + / 4.0F; + this.brightnessTopRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYZNPP, this.aoBrightnessXYNP, this.aoBrightnessYZPP, i1); + this.brightnessTopLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZPP, this.aoBrightnessXYZPPP, this.aoBrightnessXYPP, i1); + this.brightnessBottomLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZPN, this.aoBrightnessXYPP, this.aoBrightnessXYZPPN, i1); + this.brightnessBottomRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYNP, this.aoBrightnessXYZNPN, this.aoBrightnessYZPN, i1); this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R; - this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G; + this.colorGreenTopLeft = + this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G; this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B; this.colorRedTopLeft *= f3; this.colorGreenTopLeft *= f3; @@ -699,17 +796,20 @@ public class CustomOreBlockRenderer implements ISimpleBlockRenderingHandler { IIcon iicon; - if (RenderBlocks.getInstance().renderAllFaces || block.shouldSideBeRendered(blockAccess, xPos, yPos, zPos - 1, 2)) - { - if (this.renderMinZ <= 0.0D) - { + if (RenderBlocks.getInstance().renderAllFaces + || block.shouldSideBeRendered(blockAccess, xPos, yPos, zPos - 1, 2)) { + if (this.renderMinZ <= 0.0D) { --zPos; } - this.aoLightValueScratchXZNN = blockAccess.getBlock(xPos - 1, yPos, zPos).getAmbientOcclusionLightValue(); - this.aoLightValueScratchYZNN = blockAccess.getBlock(xPos, yPos - 1, zPos).getAmbientOcclusionLightValue(); - this.aoLightValueScratchYZPN = blockAccess.getBlock(xPos, yPos + 1, zPos).getAmbientOcclusionLightValue(); - this.aoLightValueScratchXZPN = blockAccess.getBlock(xPos + 1, yPos, zPos).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZNN = + blockAccess.getBlock(xPos - 1, yPos, zPos).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZNN = + blockAccess.getBlock(xPos, yPos - 1, zPos).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZPN = + blockAccess.getBlock(xPos, yPos + 1, zPos).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZPN = + blockAccess.getBlock(xPos + 1, yPos, zPos).getAmbientOcclusionLightValue(); this.aoBrightnessXZNN = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos); this.aoBrightnessYZNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos); this.aoBrightnessYZPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos); @@ -719,83 +819,85 @@ public class CustomOreBlockRenderer implements ISimpleBlockRenderingHandler { flag4 = blockAccess.getBlock(xPos, yPos + 1, zPos - 1).getCanBlockGrass(); flag5 = blockAccess.getBlock(xPos, yPos - 1, zPos - 1).getCanBlockGrass(); - if (!flag3 && !flag5) - { + if (!flag3 && !flag5) { this.aoLightValueScratchXYZNNN = this.aoLightValueScratchXZNN; this.aoBrightnessXYZNNN = this.aoBrightnessXZNN; - } - else - { - this.aoLightValueScratchXYZNNN = blockAccess.getBlock(xPos - 1, yPos - 1, zPos).getAmbientOcclusionLightValue(); + } else { + this.aoLightValueScratchXYZNNN = + blockAccess.getBlock(xPos - 1, yPos - 1, zPos).getAmbientOcclusionLightValue(); this.aoBrightnessXYZNNN = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos - 1, zPos); } - if (!flag3 && !flag4) - { + if (!flag3 && !flag4) { this.aoLightValueScratchXYZNPN = this.aoLightValueScratchXZNN; this.aoBrightnessXYZNPN = this.aoBrightnessXZNN; - } - else - { - this.aoLightValueScratchXYZNPN = blockAccess.getBlock(xPos - 1, yPos + 1, zPos).getAmbientOcclusionLightValue(); + } else { + this.aoLightValueScratchXYZNPN = + blockAccess.getBlock(xPos - 1, yPos + 1, zPos).getAmbientOcclusionLightValue(); this.aoBrightnessXYZNPN = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos + 1, zPos); } - if (!flag2 && !flag5) - { + if (!flag2 && !flag5) { this.aoLightValueScratchXYZPNN = this.aoLightValueScratchXZPN; this.aoBrightnessXYZPNN = this.aoBrightnessXZPN; - } - else - { - this.aoLightValueScratchXYZPNN = blockAccess.getBlock(xPos + 1, yPos - 1, zPos).getAmbientOcclusionLightValue(); + } else { + this.aoLightValueScratchXYZPNN = + blockAccess.getBlock(xPos + 1, yPos - 1, zPos).getAmbientOcclusionLightValue(); this.aoBrightnessXYZPNN = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos - 1, zPos); } - if (!flag2 && !flag4) - { + if (!flag2 && !flag4) { this.aoLightValueScratchXYZPPN = this.aoLightValueScratchXZPN; this.aoBrightnessXYZPPN = this.aoBrightnessXZPN; - } - else - { - this.aoLightValueScratchXYZPPN = blockAccess.getBlock(xPos + 1, yPos + 1, zPos).getAmbientOcclusionLightValue(); + } else { + this.aoLightValueScratchXYZPPN = + blockAccess.getBlock(xPos + 1, yPos + 1, zPos).getAmbientOcclusionLightValue(); this.aoBrightnessXYZPPN = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos + 1, zPos); } - if (this.renderMinZ <= 0.0D) - { + if (this.renderMinZ <= 0.0D) { ++zPos; } i1 = l; - if (this.renderMinZ <= 0.0D || !blockAccess.getBlock(xPos, yPos, zPos - 1).isOpaqueCube()) - { + if (this.renderMinZ <= 0.0D + || !blockAccess.getBlock(xPos, yPos, zPos - 1).isOpaqueCube()) { i1 = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos - 1); } f7 = blockAccess.getBlock(xPos, yPos, zPos - 1).getAmbientOcclusionLightValue(); - f3 = (this.aoLightValueScratchXZNN + this.aoLightValueScratchXYZNPN + f7 + this.aoLightValueScratchYZPN) / 4.0F; - f4 = (f7 + this.aoLightValueScratchYZPN + this.aoLightValueScratchXZPN + this.aoLightValueScratchXYZPPN) / 4.0F; - f5 = (this.aoLightValueScratchYZNN + f7 + this.aoLightValueScratchXYZPNN + this.aoLightValueScratchXZPN) / 4.0F; - f6 = (this.aoLightValueScratchXYZNNN + this.aoLightValueScratchXZNN + this.aoLightValueScratchYZNN + f7) / 4.0F; - this.brightnessTopLeft = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXZNN, this.aoBrightnessXYZNPN, this.aoBrightnessYZPN, i1); - this.brightnessBottomLeft = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessYZPN, this.aoBrightnessXZPN, this.aoBrightnessXYZPPN, i1); - this.brightnessBottomRight = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessYZNN, this.aoBrightnessXYZPNN, this.aoBrightnessXZPN, i1); - this.brightnessTopRight = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXYZNNN, this.aoBrightnessXZNN, this.aoBrightnessYZNN, i1); - - if (flag1) - { - this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R * 0.8F; - this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G * 0.8F; - this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B * 0.8F; - } - else - { - this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.8F; - this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.8F; - this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.8F; + f3 = (this.aoLightValueScratchXZNN + this.aoLightValueScratchXYZNPN + f7 + this.aoLightValueScratchYZPN) + / 4.0F; + f4 = (f7 + this.aoLightValueScratchYZPN + this.aoLightValueScratchXZPN + this.aoLightValueScratchXYZPPN) + / 4.0F; + f5 = (this.aoLightValueScratchYZNN + f7 + this.aoLightValueScratchXYZPNN + this.aoLightValueScratchXZPN) + / 4.0F; + f6 = (this.aoLightValueScratchXYZNNN + this.aoLightValueScratchXZNN + this.aoLightValueScratchYZNN + f7) + / 4.0F; + this.brightnessTopLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXZNN, this.aoBrightnessXYZNPN, this.aoBrightnessYZPN, i1); + this.brightnessBottomLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZPN, this.aoBrightnessXZPN, this.aoBrightnessXYZPPN, i1); + this.brightnessBottomRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZNN, this.aoBrightnessXYZPNN, this.aoBrightnessXZPN, i1); + this.brightnessTopRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYZNNN, this.aoBrightnessXZNN, this.aoBrightnessYZNN, i1); + + if (flag1) { + this.colorRedTopLeft = + this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R * 0.8F; + this.colorGreenTopLeft = + this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G * 0.8F; + this.colorBlueTopLeft = + this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B * 0.8F; + } else { + this.colorRedTopLeft = + this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.8F; + this.colorGreenTopLeft = + this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.8F; + this.colorBlueTopLeft = + this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.8F; } this.colorRedTopLeft *= f3; @@ -814,8 +916,9 @@ public class CustomOreBlockRenderer implements ISimpleBlockRenderingHandler { CustomOreBlockRenderer.renderFaceZNeg(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); RenderBlocks.getInstance(); - if (RenderBlocks.fancyGrass && iicon.getIconName().equals("grass_side") && !this.hasOverrideBlockTexture()) - { + if (RenderBlocks.fancyGrass + && iicon.getIconName().equals("grass_side") + && !this.hasOverrideBlockTexture()) { this.colorRedTopLeft *= R; this.colorRedBottomLeft *= R; this.colorRedBottomRight *= R; @@ -834,17 +937,20 @@ public class CustomOreBlockRenderer implements ISimpleBlockRenderingHandler { flag = true; } - if (RenderBlocks.getInstance().renderAllFaces || block.shouldSideBeRendered(blockAccess, xPos, yPos, zPos + 1, 3)) - { - if (this.renderMaxZ >= 1.0D) - { + if (RenderBlocks.getInstance().renderAllFaces + || block.shouldSideBeRendered(blockAccess, xPos, yPos, zPos + 1, 3)) { + if (this.renderMaxZ >= 1.0D) { ++zPos; } - this.aoLightValueScratchXZNP = blockAccess.getBlock(xPos - 1, yPos, zPos).getAmbientOcclusionLightValue(); - this.aoLightValueScratchXZPP = blockAccess.getBlock(xPos + 1, yPos, zPos).getAmbientOcclusionLightValue(); - this.aoLightValueScratchYZNP = blockAccess.getBlock(xPos, yPos - 1, zPos).getAmbientOcclusionLightValue(); - this.aoLightValueScratchYZPP = blockAccess.getBlock(xPos, yPos + 1, zPos).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZNP = + blockAccess.getBlock(xPos - 1, yPos, zPos).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZPP = + blockAccess.getBlock(xPos + 1, yPos, zPos).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZNP = + blockAccess.getBlock(xPos, yPos - 1, zPos).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZPP = + blockAccess.getBlock(xPos, yPos + 1, zPos).getAmbientOcclusionLightValue(); this.aoBrightnessXZNP = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos); this.aoBrightnessXZPP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos); this.aoBrightnessYZNP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos); @@ -854,83 +960,85 @@ public class CustomOreBlockRenderer implements ISimpleBlockRenderingHandler { flag4 = blockAccess.getBlock(xPos, yPos + 1, zPos + 1).getCanBlockGrass(); flag5 = blockAccess.getBlock(xPos, yPos - 1, zPos + 1).getCanBlockGrass(); - if (!flag3 && !flag5) - { + if (!flag3 && !flag5) { this.aoLightValueScratchXYZNNP = this.aoLightValueScratchXZNP; this.aoBrightnessXYZNNP = this.aoBrightnessXZNP; - } - else - { - this.aoLightValueScratchXYZNNP = blockAccess.getBlock(xPos - 1, yPos - 1, zPos).getAmbientOcclusionLightValue(); + } else { + this.aoLightValueScratchXYZNNP = + blockAccess.getBlock(xPos - 1, yPos - 1, zPos).getAmbientOcclusionLightValue(); this.aoBrightnessXYZNNP = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos - 1, zPos); } - if (!flag3 && !flag4) - { + if (!flag3 && !flag4) { this.aoLightValueScratchXYZNPP = this.aoLightValueScratchXZNP; this.aoBrightnessXYZNPP = this.aoBrightnessXZNP; - } - else - { - this.aoLightValueScratchXYZNPP = blockAccess.getBlock(xPos - 1, yPos + 1, zPos).getAmbientOcclusionLightValue(); + } else { + this.aoLightValueScratchXYZNPP = + blockAccess.getBlock(xPos - 1, yPos + 1, zPos).getAmbientOcclusionLightValue(); this.aoBrightnessXYZNPP = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos + 1, zPos); } - if (!flag2 && !flag5) - { + if (!flag2 && !flag5) { this.aoLightValueScratchXYZPNP = this.aoLightValueScratchXZPP; this.aoBrightnessXYZPNP = this.aoBrightnessXZPP; - } - else - { - this.aoLightValueScratchXYZPNP = blockAccess.getBlock(xPos + 1, yPos - 1, zPos).getAmbientOcclusionLightValue(); + } else { + this.aoLightValueScratchXYZPNP = + blockAccess.getBlock(xPos + 1, yPos - 1, zPos).getAmbientOcclusionLightValue(); this.aoBrightnessXYZPNP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos - 1, zPos); } - if (!flag2 && !flag4) - { + if (!flag2 && !flag4) { this.aoLightValueScratchXYZPPP = this.aoLightValueScratchXZPP; this.aoBrightnessXYZPPP = this.aoBrightnessXZPP; - } - else - { - this.aoLightValueScratchXYZPPP = blockAccess.getBlock(xPos + 1, yPos + 1, zPos).getAmbientOcclusionLightValue(); + } else { + this.aoLightValueScratchXYZPPP = + blockAccess.getBlock(xPos + 1, yPos + 1, zPos).getAmbientOcclusionLightValue(); this.aoBrightnessXYZPPP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos + 1, zPos); } - if (this.renderMaxZ >= 1.0D) - { + if (this.renderMaxZ >= 1.0D) { --zPos; } i1 = l; - if (this.renderMaxZ >= 1.0D || !blockAccess.getBlock(xPos, yPos, zPos + 1).isOpaqueCube()) - { + if (this.renderMaxZ >= 1.0D + || !blockAccess.getBlock(xPos, yPos, zPos + 1).isOpaqueCube()) { i1 = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos + 1); } f7 = blockAccess.getBlock(xPos, yPos, zPos + 1).getAmbientOcclusionLightValue(); - f3 = (this.aoLightValueScratchXZNP + this.aoLightValueScratchXYZNPP + f7 + this.aoLightValueScratchYZPP) / 4.0F; - f6 = (f7 + this.aoLightValueScratchYZPP + this.aoLightValueScratchXZPP + this.aoLightValueScratchXYZPPP) / 4.0F; - f5 = (this.aoLightValueScratchYZNP + f7 + this.aoLightValueScratchXYZPNP + this.aoLightValueScratchXZPP) / 4.0F; - f4 = (this.aoLightValueScratchXYZNNP + this.aoLightValueScratchXZNP + this.aoLightValueScratchYZNP + f7) / 4.0F; - this.brightnessTopLeft = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXZNP, this.aoBrightnessXYZNPP, this.aoBrightnessYZPP, i1); - this.brightnessTopRight = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessYZPP, this.aoBrightnessXZPP, this.aoBrightnessXYZPPP, i1); - this.brightnessBottomRight = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessYZNP, this.aoBrightnessXYZPNP, this.aoBrightnessXZPP, i1); - this.brightnessBottomLeft = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXYZNNP, this.aoBrightnessXZNP, this.aoBrightnessYZNP, i1); - - if (flag1) - { - this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R * 0.8F; - this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G * 0.8F; - this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B * 0.8F; - } - else - { - this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.8F; - this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.8F; - this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.8F; + f3 = (this.aoLightValueScratchXZNP + this.aoLightValueScratchXYZNPP + f7 + this.aoLightValueScratchYZPP) + / 4.0F; + f6 = (f7 + this.aoLightValueScratchYZPP + this.aoLightValueScratchXZPP + this.aoLightValueScratchXYZPPP) + / 4.0F; + f5 = (this.aoLightValueScratchYZNP + f7 + this.aoLightValueScratchXYZPNP + this.aoLightValueScratchXZPP) + / 4.0F; + f4 = (this.aoLightValueScratchXYZNNP + this.aoLightValueScratchXZNP + this.aoLightValueScratchYZNP + f7) + / 4.0F; + this.brightnessTopLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXZNP, this.aoBrightnessXYZNPP, this.aoBrightnessYZPP, i1); + this.brightnessTopRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZPP, this.aoBrightnessXZPP, this.aoBrightnessXYZPPP, i1); + this.brightnessBottomRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZNP, this.aoBrightnessXYZPNP, this.aoBrightnessXZPP, i1); + this.brightnessBottomLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYZNNP, this.aoBrightnessXZNP, this.aoBrightnessYZNP, i1); + + if (flag1) { + this.colorRedTopLeft = + this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R * 0.8F; + this.colorGreenTopLeft = + this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G * 0.8F; + this.colorBlueTopLeft = + this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B * 0.8F; + } else { + this.colorRedTopLeft = + this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.8F; + this.colorGreenTopLeft = + this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.8F; + this.colorBlueTopLeft = + this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.8F; } this.colorRedTopLeft *= f3; @@ -949,8 +1057,9 @@ public class CustomOreBlockRenderer implements ISimpleBlockRenderingHandler { CustomOreBlockRenderer.renderFaceZPos(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); RenderBlocks.getInstance(); - if (RenderBlocks.fancyGrass && iicon.getIconName().equals("grass_side") && !this.hasOverrideBlockTexture()) - { + if (RenderBlocks.fancyGrass + && iicon.getIconName().equals("grass_side") + && !this.hasOverrideBlockTexture()) { this.colorRedTopLeft *= R; this.colorRedBottomLeft *= R; this.colorRedBottomRight *= R; @@ -969,17 +1078,20 @@ public class CustomOreBlockRenderer implements ISimpleBlockRenderingHandler { flag = true; } - if (RenderBlocks.getInstance().renderAllFaces || block.shouldSideBeRendered(blockAccess, xPos - 1, yPos, zPos, 4)) - { - if (this.renderMinX <= 0.0D) - { + if (RenderBlocks.getInstance().renderAllFaces + || block.shouldSideBeRendered(blockAccess, xPos - 1, yPos, zPos, 4)) { + if (this.renderMinX <= 0.0D) { --xPos; } - this.aoLightValueScratchXYNN = blockAccess.getBlock(xPos, yPos - 1, zPos).getAmbientOcclusionLightValue(); - this.aoLightValueScratchXZNN = blockAccess.getBlock(xPos, yPos, zPos - 1).getAmbientOcclusionLightValue(); - this.aoLightValueScratchXZNP = blockAccess.getBlock(xPos, yPos, zPos + 1).getAmbientOcclusionLightValue(); - this.aoLightValueScratchXYNP = blockAccess.getBlock(xPos, yPos + 1, zPos).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXYNN = + blockAccess.getBlock(xPos, yPos - 1, zPos).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZNN = + blockAccess.getBlock(xPos, yPos, zPos - 1).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZNP = + blockAccess.getBlock(xPos, yPos, zPos + 1).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXYNP = + blockAccess.getBlock(xPos, yPos + 1, zPos).getAmbientOcclusionLightValue(); this.aoBrightnessXYNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos); this.aoBrightnessXZNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos - 1); this.aoBrightnessXZNP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos + 1); @@ -989,83 +1101,85 @@ public class CustomOreBlockRenderer implements ISimpleBlockRenderingHandler { flag4 = blockAccess.getBlock(xPos - 1, yPos, zPos - 1).getCanBlockGrass(); flag5 = blockAccess.getBlock(xPos - 1, yPos, zPos + 1).getCanBlockGrass(); - if (!flag4 && !flag3) - { + if (!flag4 && !flag3) { this.aoLightValueScratchXYZNNN = this.aoLightValueScratchXZNN; this.aoBrightnessXYZNNN = this.aoBrightnessXZNN; - } - else - { - this.aoLightValueScratchXYZNNN = blockAccess.getBlock(xPos, yPos - 1, zPos - 1).getAmbientOcclusionLightValue(); + } else { + this.aoLightValueScratchXYZNNN = + blockAccess.getBlock(xPos, yPos - 1, zPos - 1).getAmbientOcclusionLightValue(); this.aoBrightnessXYZNNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos - 1); } - if (!flag5 && !flag3) - { + if (!flag5 && !flag3) { this.aoLightValueScratchXYZNNP = this.aoLightValueScratchXZNP; this.aoBrightnessXYZNNP = this.aoBrightnessXZNP; - } - else - { - this.aoLightValueScratchXYZNNP = blockAccess.getBlock(xPos, yPos - 1, zPos + 1).getAmbientOcclusionLightValue(); + } else { + this.aoLightValueScratchXYZNNP = + blockAccess.getBlock(xPos, yPos - 1, zPos + 1).getAmbientOcclusionLightValue(); this.aoBrightnessXYZNNP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos + 1); } - if (!flag4 && !flag2) - { + if (!flag4 && !flag2) { this.aoLightValueScratchXYZNPN = this.aoLightValueScratchXZNN; this.aoBrightnessXYZNPN = this.aoBrightnessXZNN; - } - else - { - this.aoLightValueScratchXYZNPN = blockAccess.getBlock(xPos, yPos + 1, zPos - 1).getAmbientOcclusionLightValue(); + } else { + this.aoLightValueScratchXYZNPN = + blockAccess.getBlock(xPos, yPos + 1, zPos - 1).getAmbientOcclusionLightValue(); this.aoBrightnessXYZNPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos - 1); } - if (!flag5 && !flag2) - { + if (!flag5 && !flag2) { this.aoLightValueScratchXYZNPP = this.aoLightValueScratchXZNP; this.aoBrightnessXYZNPP = this.aoBrightnessXZNP; - } - else - { - this.aoLightValueScratchXYZNPP = blockAccess.getBlock(xPos, yPos + 1, zPos + 1).getAmbientOcclusionLightValue(); + } else { + this.aoLightValueScratchXYZNPP = + blockAccess.getBlock(xPos, yPos + 1, zPos + 1).getAmbientOcclusionLightValue(); this.aoBrightnessXYZNPP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos + 1); } - if (this.renderMinX <= 0.0D) - { + if (this.renderMinX <= 0.0D) { ++xPos; } i1 = l; - if (this.renderMinX <= 0.0D || !blockAccess.getBlock(xPos - 1, yPos, zPos).isOpaqueCube()) - { + if (this.renderMinX <= 0.0D + || !blockAccess.getBlock(xPos - 1, yPos, zPos).isOpaqueCube()) { i1 = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos); } f7 = blockAccess.getBlock(xPos - 1, yPos, zPos).getAmbientOcclusionLightValue(); - f6 = (this.aoLightValueScratchXYNN + this.aoLightValueScratchXYZNNP + f7 + this.aoLightValueScratchXZNP) / 4.0F; - f3 = (f7 + this.aoLightValueScratchXZNP + this.aoLightValueScratchXYNP + this.aoLightValueScratchXYZNPP) / 4.0F; - f4 = (this.aoLightValueScratchXZNN + f7 + this.aoLightValueScratchXYZNPN + this.aoLightValueScratchXYNP) / 4.0F; - f5 = (this.aoLightValueScratchXYZNNN + this.aoLightValueScratchXYNN + this.aoLightValueScratchXZNN + f7) / 4.0F; - this.brightnessTopRight = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXYNN, this.aoBrightnessXYZNNP, this.aoBrightnessXZNP, i1); - this.brightnessTopLeft = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXZNP, this.aoBrightnessXYNP, this.aoBrightnessXYZNPP, i1); - this.brightnessBottomLeft = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXZNN, this.aoBrightnessXYZNPN, this.aoBrightnessXYNP, i1); - this.brightnessBottomRight = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXYZNNN, this.aoBrightnessXYNN, this.aoBrightnessXZNN, i1); - - if (flag1) - { - this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R * 0.6F; - this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G * 0.6F; - this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B * 0.6F; - } - else - { - this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.6F; - this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.6F; - this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.6F; + f6 = (this.aoLightValueScratchXYNN + this.aoLightValueScratchXYZNNP + f7 + this.aoLightValueScratchXZNP) + / 4.0F; + f3 = (f7 + this.aoLightValueScratchXZNP + this.aoLightValueScratchXYNP + this.aoLightValueScratchXYZNPP) + / 4.0F; + f4 = (this.aoLightValueScratchXZNN + f7 + this.aoLightValueScratchXYZNPN + this.aoLightValueScratchXYNP) + / 4.0F; + f5 = (this.aoLightValueScratchXYZNNN + this.aoLightValueScratchXYNN + this.aoLightValueScratchXZNN + f7) + / 4.0F; + this.brightnessTopRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYNN, this.aoBrightnessXYZNNP, this.aoBrightnessXZNP, i1); + this.brightnessTopLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXZNP, this.aoBrightnessXYNP, this.aoBrightnessXYZNPP, i1); + this.brightnessBottomLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXZNN, this.aoBrightnessXYZNPN, this.aoBrightnessXYNP, i1); + this.brightnessBottomRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYZNNN, this.aoBrightnessXYNN, this.aoBrightnessXZNN, i1); + + if (flag1) { + this.colorRedTopLeft = + this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R * 0.6F; + this.colorGreenTopLeft = + this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G * 0.6F; + this.colorBlueTopLeft = + this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B * 0.6F; + } else { + this.colorRedTopLeft = + this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.6F; + this.colorGreenTopLeft = + this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.6F; + this.colorBlueTopLeft = + this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.6F; } this.colorRedTopLeft *= f3; @@ -1084,8 +1198,9 @@ public class CustomOreBlockRenderer implements ISimpleBlockRenderingHandler { CustomOreBlockRenderer.renderFaceXNeg(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); RenderBlocks.getInstance(); - if (RenderBlocks.fancyGrass && iicon.getIconName().equals("grass_side") && !this.hasOverrideBlockTexture()) - { + if (RenderBlocks.fancyGrass + && iicon.getIconName().equals("grass_side") + && !this.hasOverrideBlockTexture()) { this.colorRedTopLeft *= R; this.colorRedBottomLeft *= R; this.colorRedBottomRight *= R; @@ -1104,17 +1219,20 @@ public class CustomOreBlockRenderer implements ISimpleBlockRenderingHandler { flag = true; } - if (RenderBlocks.getInstance().renderAllFaces || block.shouldSideBeRendered(blockAccess, xPos + 1, yPos, zPos, 5)) - { - if (this.renderMaxX >= 1.0D) - { + if (RenderBlocks.getInstance().renderAllFaces + || block.shouldSideBeRendered(blockAccess, xPos + 1, yPos, zPos, 5)) { + if (this.renderMaxX >= 1.0D) { ++xPos; } - this.aoLightValueScratchXYPN = blockAccess.getBlock(xPos, yPos - 1, zPos).getAmbientOcclusionLightValue(); - this.aoLightValueScratchXZPN = blockAccess.getBlock(xPos, yPos, zPos - 1).getAmbientOcclusionLightValue(); - this.aoLightValueScratchXZPP = blockAccess.getBlock(xPos, yPos, zPos + 1).getAmbientOcclusionLightValue(); - this.aoLightValueScratchXYPP = blockAccess.getBlock(xPos, yPos + 1, zPos).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXYPN = + blockAccess.getBlock(xPos, yPos - 1, zPos).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZPN = + blockAccess.getBlock(xPos, yPos, zPos - 1).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZPP = + blockAccess.getBlock(xPos, yPos, zPos + 1).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXYPP = + blockAccess.getBlock(xPos, yPos + 1, zPos).getAmbientOcclusionLightValue(); this.aoBrightnessXYPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos); this.aoBrightnessXZPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos - 1); this.aoBrightnessXZPP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos + 1); @@ -1124,83 +1242,85 @@ public class CustomOreBlockRenderer implements ISimpleBlockRenderingHandler { flag4 = blockAccess.getBlock(xPos + 1, yPos, zPos + 1).getCanBlockGrass(); flag5 = blockAccess.getBlock(xPos + 1, yPos, zPos - 1).getCanBlockGrass(); - if (!flag3 && !flag5) - { + if (!flag3 && !flag5) { this.aoLightValueScratchXYZPNN = this.aoLightValueScratchXZPN; this.aoBrightnessXYZPNN = this.aoBrightnessXZPN; - } - else - { - this.aoLightValueScratchXYZPNN = blockAccess.getBlock(xPos, yPos - 1, zPos - 1).getAmbientOcclusionLightValue(); + } else { + this.aoLightValueScratchXYZPNN = + blockAccess.getBlock(xPos, yPos - 1, zPos - 1).getAmbientOcclusionLightValue(); this.aoBrightnessXYZPNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos - 1); } - if (!flag3 && !flag4) - { + if (!flag3 && !flag4) { this.aoLightValueScratchXYZPNP = this.aoLightValueScratchXZPP; this.aoBrightnessXYZPNP = this.aoBrightnessXZPP; - } - else - { - this.aoLightValueScratchXYZPNP = blockAccess.getBlock(xPos, yPos - 1, zPos + 1).getAmbientOcclusionLightValue(); + } else { + this.aoLightValueScratchXYZPNP = + blockAccess.getBlock(xPos, yPos - 1, zPos + 1).getAmbientOcclusionLightValue(); this.aoBrightnessXYZPNP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos + 1); } - if (!flag2 && !flag5) - { + if (!flag2 && !flag5) { this.aoLightValueScratchXYZPPN = this.aoLightValueScratchXZPN; this.aoBrightnessXYZPPN = this.aoBrightnessXZPN; - } - else - { - this.aoLightValueScratchXYZPPN = blockAccess.getBlock(xPos, yPos + 1, zPos - 1).getAmbientOcclusionLightValue(); + } else { + this.aoLightValueScratchXYZPPN = + blockAccess.getBlock(xPos, yPos + 1, zPos - 1).getAmbientOcclusionLightValue(); this.aoBrightnessXYZPPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos - 1); } - if (!flag2 && !flag4) - { + if (!flag2 && !flag4) { this.aoLightValueScratchXYZPPP = this.aoLightValueScratchXZPP; this.aoBrightnessXYZPPP = this.aoBrightnessXZPP; - } - else - { - this.aoLightValueScratchXYZPPP = blockAccess.getBlock(xPos, yPos + 1, zPos + 1).getAmbientOcclusionLightValue(); + } else { + this.aoLightValueScratchXYZPPP = + blockAccess.getBlock(xPos, yPos + 1, zPos + 1).getAmbientOcclusionLightValue(); this.aoBrightnessXYZPPP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos + 1); } - if (this.renderMaxX >= 1.0D) - { + if (this.renderMaxX >= 1.0D) { --xPos; } i1 = l; - if (this.renderMaxX >= 1.0D || !blockAccess.getBlock(xPos + 1, yPos, zPos).isOpaqueCube()) - { + if (this.renderMaxX >= 1.0D + || !blockAccess.getBlock(xPos + 1, yPos, zPos).isOpaqueCube()) { i1 = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos); } f7 = blockAccess.getBlock(xPos + 1, yPos, zPos).getAmbientOcclusionLightValue(); - f3 = (this.aoLightValueScratchXYPN + this.aoLightValueScratchXYZPNP + f7 + this.aoLightValueScratchXZPP) / 4.0F; - f4 = (this.aoLightValueScratchXYZPNN + this.aoLightValueScratchXYPN + this.aoLightValueScratchXZPN + f7) / 4.0F; - f5 = (this.aoLightValueScratchXZPN + f7 + this.aoLightValueScratchXYZPPN + this.aoLightValueScratchXYPP) / 4.0F; - f6 = (f7 + this.aoLightValueScratchXZPP + this.aoLightValueScratchXYPP + this.aoLightValueScratchXYZPPP) / 4.0F; - this.brightnessTopLeft = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXYPN, this.aoBrightnessXYZPNP, this.aoBrightnessXZPP, i1); - this.brightnessTopRight = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXZPP, this.aoBrightnessXYPP, this.aoBrightnessXYZPPP, i1); - this.brightnessBottomRight = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXZPN, this.aoBrightnessXYZPPN, this.aoBrightnessXYPP, i1); - this.brightnessBottomLeft = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXYZPNN, this.aoBrightnessXYPN, this.aoBrightnessXZPN, i1); - - if (flag1) - { - this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R * 0.6F; - this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G * 0.6F; - this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B * 0.6F; - } - else - { - this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.6F; - this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.6F; - this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.6F; + f3 = (this.aoLightValueScratchXYPN + this.aoLightValueScratchXYZPNP + f7 + this.aoLightValueScratchXZPP) + / 4.0F; + f4 = (this.aoLightValueScratchXYZPNN + this.aoLightValueScratchXYPN + this.aoLightValueScratchXZPN + f7) + / 4.0F; + f5 = (this.aoLightValueScratchXZPN + f7 + this.aoLightValueScratchXYZPPN + this.aoLightValueScratchXYPP) + / 4.0F; + f6 = (f7 + this.aoLightValueScratchXZPP + this.aoLightValueScratchXYPP + this.aoLightValueScratchXYZPPP) + / 4.0F; + this.brightnessTopLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYPN, this.aoBrightnessXYZPNP, this.aoBrightnessXZPP, i1); + this.brightnessTopRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXZPP, this.aoBrightnessXYPP, this.aoBrightnessXYZPPP, i1); + this.brightnessBottomRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXZPN, this.aoBrightnessXYZPPN, this.aoBrightnessXYPP, i1); + this.brightnessBottomLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYZPNN, this.aoBrightnessXYPN, this.aoBrightnessXZPN, i1); + + if (flag1) { + this.colorRedTopLeft = + this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R * 0.6F; + this.colorGreenTopLeft = + this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G * 0.6F; + this.colorBlueTopLeft = + this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B * 0.6F; + } else { + this.colorRedTopLeft = + this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.6F; + this.colorGreenTopLeft = + this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.6F; + this.colorBlueTopLeft = + this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.6F; } this.colorRedTopLeft *= f3; @@ -1219,8 +1339,9 @@ public class CustomOreBlockRenderer implements ISimpleBlockRenderingHandler { CustomOreBlockRenderer.renderFaceXPos(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); RenderBlocks.getInstance(); - if (RenderBlocks.fancyGrass && iicon.getIconName().equals("grass_side") && !this.hasOverrideBlockTexture()) - { + if (RenderBlocks.fancyGrass + && iicon.getIconName().equals("grass_side") + && !this.hasOverrideBlockTexture()) { this.colorRedTopLeft *= R; this.colorRedBottomLeft *= R; this.colorRedBottomRight *= R; @@ -1242,842 +1363,1071 @@ public class CustomOreBlockRenderer implements ISimpleBlockRenderingHandler { this.enableAO = false; return flag; } - - /** - * Renders non-full-cube block with ambient occusion. Args: block, x, y, z, red, green, blue (lighting) - */ - public boolean renderStandardBlockWithAmbientOcclusionPartial(IBlockAccess aWorld, RenderBlocks aRenderer, ITexture[][] aTextures, Block block, int xPos, int yPos, int zPos, float R, float G, float B) - { - this.enableAO = true; - boolean flag = false; - float f3 = 0.0F; - float f4 = 0.0F; - float f5 = 0.0F; - float f6 = 0.0F; - boolean flag1 = true; - int l = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos); - Tessellator tessellator = Tessellator.instance; - tessellator.setBrightness(983055); - - if (this.getBlockIcon(block).getIconName().equals("grass_top")) - { - flag1 = false; - } - else if (this.hasOverrideBlockTexture()) - { - flag1 = false; - } - - boolean flag2; - boolean flag3; - boolean flag4; - boolean flag5; - int i1; - float f7; - - if (RenderBlocks.getInstance().renderAllFaces || block.shouldSideBeRendered(blockAccess, xPos, yPos - 1, zPos, 0)) - { - if (this.renderMinY <= 0.0D) - { - --yPos; - } - - this.aoBrightnessXYNN = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos); - this.aoBrightnessYZNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos - 1); - this.aoBrightnessYZNP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos + 1); - this.aoBrightnessXYPN = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos); - this.aoLightValueScratchXYNN = blockAccess.getBlock(xPos - 1, yPos, zPos).getAmbientOcclusionLightValue(); - this.aoLightValueScratchYZNN = blockAccess.getBlock(xPos, yPos, zPos - 1).getAmbientOcclusionLightValue(); - this.aoLightValueScratchYZNP = blockAccess.getBlock(xPos, yPos, zPos + 1).getAmbientOcclusionLightValue(); - this.aoLightValueScratchXYPN = blockAccess.getBlock(xPos + 1, yPos, zPos).getAmbientOcclusionLightValue(); - flag2 = blockAccess.getBlock(xPos + 1, yPos - 1, zPos).getCanBlockGrass(); - flag3 = blockAccess.getBlock(xPos - 1, yPos - 1, zPos).getCanBlockGrass(); - flag4 = blockAccess.getBlock(xPos, yPos - 1, zPos + 1).getCanBlockGrass(); - flag5 = blockAccess.getBlock(xPos, yPos - 1, zPos - 1).getCanBlockGrass(); - - if (!flag5 && !flag3) - { - this.aoLightValueScratchXYZNNN = this.aoLightValueScratchXYNN; - this.aoBrightnessXYZNNN = this.aoBrightnessXYNN; - } - else - { - this.aoLightValueScratchXYZNNN = blockAccess.getBlock(xPos - 1, yPos, zPos - 1).getAmbientOcclusionLightValue(); - this.aoBrightnessXYZNNN = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos - 1); - } - - if (!flag4 && !flag3) - { - this.aoLightValueScratchXYZNNP = this.aoLightValueScratchXYNN; - this.aoBrightnessXYZNNP = this.aoBrightnessXYNN; - } - else - { - this.aoLightValueScratchXYZNNP = blockAccess.getBlock(xPos - 1, yPos, zPos + 1).getAmbientOcclusionLightValue(); - this.aoBrightnessXYZNNP = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos + 1); - } - - if (!flag5 && !flag2) - { - this.aoLightValueScratchXYZPNN = this.aoLightValueScratchXYPN; - this.aoBrightnessXYZPNN = this.aoBrightnessXYPN; - } - else - { - this.aoLightValueScratchXYZPNN = blockAccess.getBlock(xPos + 1, yPos, zPos - 1).getAmbientOcclusionLightValue(); - this.aoBrightnessXYZPNN = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos - 1); - } - - if (!flag4 && !flag2) - { - this.aoLightValueScratchXYZPNP = this.aoLightValueScratchXYPN; - this.aoBrightnessXYZPNP = this.aoBrightnessXYPN; - } - else - { - this.aoLightValueScratchXYZPNP = blockAccess.getBlock(xPos + 1, yPos, zPos + 1).getAmbientOcclusionLightValue(); - this.aoBrightnessXYZPNP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos + 1); - } - - if (this.renderMinY <= 0.0D) - { - ++yPos; - } - - i1 = l; - - if (this.renderMinY <= 0.0D || !blockAccess.getBlock(xPos, yPos - 1, zPos).isOpaqueCube()) - { - i1 = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos); - } - - f7 = blockAccess.getBlock(xPos, yPos - 1, zPos).getAmbientOcclusionLightValue(); - f3 = (this.aoLightValueScratchXYZNNP + this.aoLightValueScratchXYNN + this.aoLightValueScratchYZNP + f7) / 4.0F; - f6 = (this.aoLightValueScratchYZNP + f7 + this.aoLightValueScratchXYZPNP + this.aoLightValueScratchXYPN) / 4.0F; - f5 = (f7 + this.aoLightValueScratchYZNN + this.aoLightValueScratchXYPN + this.aoLightValueScratchXYZPNN) / 4.0F; - f4 = (this.aoLightValueScratchXYNN + this.aoLightValueScratchXYZNNN + f7 + this.aoLightValueScratchYZNN) / 4.0F; - this.brightnessTopLeft = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXYZNNP, this.aoBrightnessXYNN, this.aoBrightnessYZNP, i1); - this.brightnessTopRight = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessYZNP, this.aoBrightnessXYZPNP, this.aoBrightnessXYPN, i1); - this.brightnessBottomRight = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessYZNN, this.aoBrightnessXYPN, this.aoBrightnessXYZPNN, i1); - this.brightnessBottomLeft = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXYNN, this.aoBrightnessXYZNNN, this.aoBrightnessYZNN, i1); - - if (flag1) - { - this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R * 0.5F; - this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G * 0.5F; - this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B * 0.5F; - } - else - { - this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.5F; - this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.5F; - this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.5F; - } - - this.colorRedTopLeft *= f3; - this.colorGreenTopLeft *= f3; - this.colorBlueTopLeft *= f3; - this.colorRedBottomLeft *= f4; - this.colorGreenBottomLeft *= f4; - this.colorBlueBottomLeft *= f4; - this.colorRedBottomRight *= f5; - this.colorGreenBottomRight *= f5; - this.colorBlueBottomRight *= f5; - this.colorRedTopRight *= f6; - this.colorGreenTopRight *= f6; - this.colorBlueTopRight *= f6; - CustomOreBlockRenderer.renderFaceYNeg(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); - flag = true; - } - - if (RenderBlocks.getInstance().renderAllFaces || block.shouldSideBeRendered(blockAccess, xPos, yPos + 1, zPos, 1)) - { - if (this.renderMaxY >= 1.0D) - { - ++yPos; - } - - this.aoBrightnessXYNP = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos); - this.aoBrightnessXYPP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos); - this.aoBrightnessYZPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos - 1); - this.aoBrightnessYZPP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos + 1); - this.aoLightValueScratchXYNP = blockAccess.getBlock(xPos - 1, yPos, zPos).getAmbientOcclusionLightValue(); - this.aoLightValueScratchXYPP = blockAccess.getBlock(xPos + 1, yPos, zPos).getAmbientOcclusionLightValue(); - this.aoLightValueScratchYZPN = blockAccess.getBlock(xPos, yPos, zPos - 1).getAmbientOcclusionLightValue(); - this.aoLightValueScratchYZPP = blockAccess.getBlock(xPos, yPos, zPos + 1).getAmbientOcclusionLightValue(); - flag2 = blockAccess.getBlock(xPos + 1, yPos + 1, zPos).getCanBlockGrass(); - flag3 = blockAccess.getBlock(xPos - 1, yPos + 1, zPos).getCanBlockGrass(); - flag4 = blockAccess.getBlock(xPos, yPos + 1, zPos + 1).getCanBlockGrass(); - flag5 = blockAccess.getBlock(xPos, yPos + 1, zPos - 1).getCanBlockGrass(); - - if (!flag5 && !flag3) - { - this.aoLightValueScratchXYZNPN = this.aoLightValueScratchXYNP; - this.aoBrightnessXYZNPN = this.aoBrightnessXYNP; - } - else - { - this.aoLightValueScratchXYZNPN = blockAccess.getBlock(xPos - 1, yPos, zPos - 1).getAmbientOcclusionLightValue(); - this.aoBrightnessXYZNPN = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos - 1); - } - - if (!flag5 && !flag2) - { - this.aoLightValueScratchXYZPPN = this.aoLightValueScratchXYPP; - this.aoBrightnessXYZPPN = this.aoBrightnessXYPP; - } - else - { - this.aoLightValueScratchXYZPPN = blockAccess.getBlock(xPos + 1, yPos, zPos - 1).getAmbientOcclusionLightValue(); - this.aoBrightnessXYZPPN = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos - 1); - } - - if (!flag4 && !flag3) - { - this.aoLightValueScratchXYZNPP = this.aoLightValueScratchXYNP; - this.aoBrightnessXYZNPP = this.aoBrightnessXYNP; - } - else - { - this.aoLightValueScratchXYZNPP = blockAccess.getBlock(xPos - 1, yPos, zPos + 1).getAmbientOcclusionLightValue(); - this.aoBrightnessXYZNPP = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos + 1); - } - - if (!flag4 && !flag2) - { - this.aoLightValueScratchXYZPPP = this.aoLightValueScratchXYPP; - this.aoBrightnessXYZPPP = this.aoBrightnessXYPP; - } - else - { - this.aoLightValueScratchXYZPPP = blockAccess.getBlock(xPos + 1, yPos, zPos + 1).getAmbientOcclusionLightValue(); - this.aoBrightnessXYZPPP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos + 1); - } - - if (this.renderMaxY >= 1.0D) - { - --yPos; - } - - i1 = l; - - if (this.renderMaxY >= 1.0D || !blockAccess.getBlock(xPos, yPos + 1, zPos).isOpaqueCube()) - { - i1 = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos); - } - - f7 = blockAccess.getBlock(xPos, yPos + 1, zPos).getAmbientOcclusionLightValue(); - f6 = (this.aoLightValueScratchXYZNPP + this.aoLightValueScratchXYNP + this.aoLightValueScratchYZPP + f7) / 4.0F; - f3 = (this.aoLightValueScratchYZPP + f7 + this.aoLightValueScratchXYZPPP + this.aoLightValueScratchXYPP) / 4.0F; - f4 = (f7 + this.aoLightValueScratchYZPN + this.aoLightValueScratchXYPP + this.aoLightValueScratchXYZPPN) / 4.0F; - f5 = (this.aoLightValueScratchXYNP + this.aoLightValueScratchXYZNPN + f7 + this.aoLightValueScratchYZPN) / 4.0F; - this.brightnessTopRight = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXYZNPP, this.aoBrightnessXYNP, this.aoBrightnessYZPP, i1); - this.brightnessTopLeft = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessYZPP, this.aoBrightnessXYZPPP, this.aoBrightnessXYPP, i1); - this.brightnessBottomLeft = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessYZPN, this.aoBrightnessXYPP, this.aoBrightnessXYZPPN, i1); - this.brightnessBottomRight = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXYNP, this.aoBrightnessXYZNPN, this.aoBrightnessYZPN, i1); - this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R; - this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G; - this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B; - this.colorRedTopLeft *= f3; - this.colorGreenTopLeft *= f3; - this.colorBlueTopLeft *= f3; - this.colorRedBottomLeft *= f4; - this.colorGreenBottomLeft *= f4; - this.colorBlueBottomLeft *= f4; - this.colorRedBottomRight *= f5; - this.colorGreenBottomRight *= f5; - this.colorBlueBottomRight *= f5; - this.colorRedTopRight *= f6; - this.colorGreenTopRight *= f6; - this.colorBlueTopRight *= f6; - CustomOreBlockRenderer.renderFaceYPos(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); - flag = true; - } - - float f8; - float f9; - float f10; - float f11; - int j1; - int k1; - int l1; - int i2; - IIcon iicon; - - if (RenderBlocks.getInstance().renderAllFaces || block.shouldSideBeRendered(blockAccess, xPos, yPos, zPos - 1, 2)) - { - if (this.renderMinZ <= 0.0D) - { - --zPos; - } - - this.aoLightValueScratchXZNN = blockAccess.getBlock(xPos - 1, yPos, zPos).getAmbientOcclusionLightValue(); - this.aoLightValueScratchYZNN = blockAccess.getBlock(xPos, yPos - 1, zPos).getAmbientOcclusionLightValue(); - this.aoLightValueScratchYZPN = blockAccess.getBlock(xPos, yPos + 1, zPos).getAmbientOcclusionLightValue(); - this.aoLightValueScratchXZPN = blockAccess.getBlock(xPos + 1, yPos, zPos).getAmbientOcclusionLightValue(); - this.aoBrightnessXZNN = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos); - this.aoBrightnessYZNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos); - this.aoBrightnessYZPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos); - this.aoBrightnessXZPN = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos); - flag2 = blockAccess.getBlock(xPos + 1, yPos, zPos - 1).getCanBlockGrass(); - flag3 = blockAccess.getBlock(xPos - 1, yPos, zPos - 1).getCanBlockGrass(); - flag4 = blockAccess.getBlock(xPos, yPos + 1, zPos - 1).getCanBlockGrass(); - flag5 = blockAccess.getBlock(xPos, yPos - 1, zPos - 1).getCanBlockGrass(); - - if (!flag3 && !flag5) - { - this.aoLightValueScratchXYZNNN = this.aoLightValueScratchXZNN; - this.aoBrightnessXYZNNN = this.aoBrightnessXZNN; - } - else - { - this.aoLightValueScratchXYZNNN = blockAccess.getBlock(xPos - 1, yPos - 1, zPos).getAmbientOcclusionLightValue(); - this.aoBrightnessXYZNNN = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos - 1, zPos); - } - - if (!flag3 && !flag4) - { - this.aoLightValueScratchXYZNPN = this.aoLightValueScratchXZNN; - this.aoBrightnessXYZNPN = this.aoBrightnessXZNN; - } - else - { - this.aoLightValueScratchXYZNPN = blockAccess.getBlock(xPos - 1, yPos + 1, zPos).getAmbientOcclusionLightValue(); - this.aoBrightnessXYZNPN = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos + 1, zPos); - } - - if (!flag2 && !flag5) - { - this.aoLightValueScratchXYZPNN = this.aoLightValueScratchXZPN; - this.aoBrightnessXYZPNN = this.aoBrightnessXZPN; - } - else - { - this.aoLightValueScratchXYZPNN = blockAccess.getBlock(xPos + 1, yPos - 1, zPos).getAmbientOcclusionLightValue(); - this.aoBrightnessXYZPNN = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos - 1, zPos); - } - - if (!flag2 && !flag4) - { - this.aoLightValueScratchXYZPPN = this.aoLightValueScratchXZPN; - this.aoBrightnessXYZPPN = this.aoBrightnessXZPN; - } - else - { - this.aoLightValueScratchXYZPPN = blockAccess.getBlock(xPos + 1, yPos + 1, zPos).getAmbientOcclusionLightValue(); - this.aoBrightnessXYZPPN = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos + 1, zPos); - } - - if (this.renderMinZ <= 0.0D) - { - ++zPos; - } - - i1 = l; - - if (this.renderMinZ <= 0.0D || !blockAccess.getBlock(xPos, yPos, zPos - 1).isOpaqueCube()) - { - i1 = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos - 1); - } - - f7 = blockAccess.getBlock(xPos, yPos, zPos - 1).getAmbientOcclusionLightValue(); - f8 = (this.aoLightValueScratchXZNN + this.aoLightValueScratchXYZNPN + f7 + this.aoLightValueScratchYZPN) / 4.0F; - f9 = (f7 + this.aoLightValueScratchYZPN + this.aoLightValueScratchXZPN + this.aoLightValueScratchXYZPPN) / 4.0F; - f10 = (this.aoLightValueScratchYZNN + f7 + this.aoLightValueScratchXYZPNN + this.aoLightValueScratchXZPN) / 4.0F; - f11 = (this.aoLightValueScratchXYZNNN + this.aoLightValueScratchXZNN + this.aoLightValueScratchYZNN + f7) / 4.0F; - f3 = (float)((double)f8 * this.renderMaxY * (1.0D - this.renderMinX) + (double)f9 * this.renderMaxY * this.renderMinX + (double)f10 * (1.0D - this.renderMaxY) * this.renderMinX + (double)f11 * (1.0D - this.renderMaxY) * (1.0D - this.renderMinX)); - f4 = (float)((double)f8 * this.renderMaxY * (1.0D - this.renderMaxX) + (double)f9 * this.renderMaxY * this.renderMaxX + (double)f10 * (1.0D - this.renderMaxY) * this.renderMaxX + (double)f11 * (1.0D - this.renderMaxY) * (1.0D - this.renderMaxX)); - f5 = (float)((double)f8 * this.renderMinY * (1.0D - this.renderMaxX) + (double)f9 * this.renderMinY * this.renderMaxX + (double)f10 * (1.0D - this.renderMinY) * this.renderMaxX + (double)f11 * (1.0D - this.renderMinY) * (1.0D - this.renderMaxX)); - f6 = (float)((double)f8 * this.renderMinY * (1.0D - this.renderMinX) + (double)f9 * this.renderMinY * this.renderMinX + (double)f10 * (1.0D - this.renderMinY) * this.renderMinX + (double)f11 * (1.0D - this.renderMinY) * (1.0D - this.renderMinX)); - j1 = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXZNN, this.aoBrightnessXYZNPN, this.aoBrightnessYZPN, i1); - k1 = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessYZPN, this.aoBrightnessXZPN, this.aoBrightnessXYZPPN, i1); - l1 = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessYZNN, this.aoBrightnessXYZPNN, this.aoBrightnessXZPN, i1); - i2 = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXYZNNN, this.aoBrightnessXZNN, this.aoBrightnessYZNN, i1); - this.brightnessTopLeft = RenderBlocks.getInstance().mixAoBrightness(j1, k1, l1, i2, this.renderMaxY * (1.0D - this.renderMinX), this.renderMaxY * this.renderMinX, (1.0D - this.renderMaxY) * this.renderMinX, (1.0D - this.renderMaxY) * (1.0D - this.renderMinX)); - this.brightnessBottomLeft = RenderBlocks.getInstance().mixAoBrightness(j1, k1, l1, i2, this.renderMaxY * (1.0D - this.renderMaxX), this.renderMaxY * this.renderMaxX, (1.0D - this.renderMaxY) * this.renderMaxX, (1.0D - this.renderMaxY) * (1.0D - this.renderMaxX)); - this.brightnessBottomRight = RenderBlocks.getInstance().mixAoBrightness(j1, k1, l1, i2, this.renderMinY * (1.0D - this.renderMaxX), this.renderMinY * this.renderMaxX, (1.0D - this.renderMinY) * this.renderMaxX, (1.0D - this.renderMinY) * (1.0D - this.renderMaxX)); - this.brightnessTopRight = RenderBlocks.getInstance().mixAoBrightness(j1, k1, l1, i2, this.renderMinY * (1.0D - this.renderMinX), this.renderMinY * this.renderMinX, (1.0D - this.renderMinY) * this.renderMinX, (1.0D - this.renderMinY) * (1.0D - this.renderMinX)); - - if (flag1) - { - this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R * 0.8F; - this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G * 0.8F; - this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B * 0.8F; - } - else - { - this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.8F; - this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.8F; - this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.8F; - } - - this.colorRedTopLeft *= f3; - this.colorGreenTopLeft *= f3; - this.colorBlueTopLeft *= f3; - this.colorRedBottomLeft *= f4; - this.colorGreenBottomLeft *= f4; - this.colorBlueBottomLeft *= f4; - this.colorRedBottomRight *= f5; - this.colorGreenBottomRight *= f5; - this.colorBlueBottomRight *= f5; - this.colorRedTopRight *= f6; - this.colorGreenTopRight *= f6; - this.colorBlueTopRight *= f6; - iicon = this.getBlockIcon(block, blockAccess, xPos, yPos, zPos, 2); - CustomOreBlockRenderer.renderFaceZNeg(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); - - RenderBlocks.getInstance(); - if (RenderBlocks.fancyGrass && iicon.getIconName().equals("grass_side") && !this.hasOverrideBlockTexture()) - { - this.colorRedTopLeft *= R; - this.colorRedBottomLeft *= R; - this.colorRedBottomRight *= R; - this.colorRedTopRight *= R; - this.colorGreenTopLeft *= G; - this.colorGreenBottomLeft *= G; - this.colorGreenBottomRight *= G; - this.colorGreenTopRight *= G; - this.colorBlueTopLeft *= B; - this.colorBlueBottomLeft *= B; - this.colorBlueBottomRight *= B; - this.colorBlueTopRight *= B; - CustomOreBlockRenderer.renderFaceZNeg(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); - } - - flag = true; - } - - if (RenderBlocks.getInstance().renderAllFaces || block.shouldSideBeRendered(blockAccess, xPos, yPos, zPos + 1, 3)) - { - if (this.renderMaxZ >= 1.0D) - { - ++zPos; - } - - this.aoLightValueScratchXZNP = blockAccess.getBlock(xPos - 1, yPos, zPos).getAmbientOcclusionLightValue(); - this.aoLightValueScratchXZPP = blockAccess.getBlock(xPos + 1, yPos, zPos).getAmbientOcclusionLightValue(); - this.aoLightValueScratchYZNP = blockAccess.getBlock(xPos, yPos - 1, zPos).getAmbientOcclusionLightValue(); - this.aoLightValueScratchYZPP = blockAccess.getBlock(xPos, yPos + 1, zPos).getAmbientOcclusionLightValue(); - this.aoBrightnessXZNP = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos); - this.aoBrightnessXZPP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos); - this.aoBrightnessYZNP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos); - this.aoBrightnessYZPP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos); - flag2 = blockAccess.getBlock(xPos + 1, yPos, zPos + 1).getCanBlockGrass(); - flag3 = blockAccess.getBlock(xPos - 1, yPos, zPos + 1).getCanBlockGrass(); - flag4 = blockAccess.getBlock(xPos, yPos + 1, zPos + 1).getCanBlockGrass(); - flag5 = blockAccess.getBlock(xPos, yPos - 1, zPos + 1).getCanBlockGrass(); - - if (!flag3 && !flag5) - { - this.aoLightValueScratchXYZNNP = this.aoLightValueScratchXZNP; - this.aoBrightnessXYZNNP = this.aoBrightnessXZNP; - } - else - { - this.aoLightValueScratchXYZNNP = blockAccess.getBlock(xPos - 1, yPos - 1, zPos).getAmbientOcclusionLightValue(); - this.aoBrightnessXYZNNP = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos - 1, zPos); - } - - if (!flag3 && !flag4) - { - this.aoLightValueScratchXYZNPP = this.aoLightValueScratchXZNP; - this.aoBrightnessXYZNPP = this.aoBrightnessXZNP; - } - else - { - this.aoLightValueScratchXYZNPP = blockAccess.getBlock(xPos - 1, yPos + 1, zPos).getAmbientOcclusionLightValue(); - this.aoBrightnessXYZNPP = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos + 1, zPos); - } - - if (!flag2 && !flag5) - { - this.aoLightValueScratchXYZPNP = this.aoLightValueScratchXZPP; - this.aoBrightnessXYZPNP = this.aoBrightnessXZPP; - } - else - { - this.aoLightValueScratchXYZPNP = blockAccess.getBlock(xPos + 1, yPos - 1, zPos).getAmbientOcclusionLightValue(); - this.aoBrightnessXYZPNP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos - 1, zPos); - } - - if (!flag2 && !flag4) - { - this.aoLightValueScratchXYZPPP = this.aoLightValueScratchXZPP; - this.aoBrightnessXYZPPP = this.aoBrightnessXZPP; - } - else - { - this.aoLightValueScratchXYZPPP = blockAccess.getBlock(xPos + 1, yPos + 1, zPos).getAmbientOcclusionLightValue(); - this.aoBrightnessXYZPPP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos + 1, zPos); - } - - if (this.renderMaxZ >= 1.0D) - { - --zPos; - } - - i1 = l; - - if (this.renderMaxZ >= 1.0D || !blockAccess.getBlock(xPos, yPos, zPos + 1).isOpaqueCube()) - { - i1 = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos + 1); - } - - f7 = blockAccess.getBlock(xPos, yPos, zPos + 1).getAmbientOcclusionLightValue(); - f8 = (this.aoLightValueScratchXZNP + this.aoLightValueScratchXYZNPP + f7 + this.aoLightValueScratchYZPP) / 4.0F; - f9 = (f7 + this.aoLightValueScratchYZPP + this.aoLightValueScratchXZPP + this.aoLightValueScratchXYZPPP) / 4.0F; - f10 = (this.aoLightValueScratchYZNP + f7 + this.aoLightValueScratchXYZPNP + this.aoLightValueScratchXZPP) / 4.0F; - f11 = (this.aoLightValueScratchXYZNNP + this.aoLightValueScratchXZNP + this.aoLightValueScratchYZNP + f7) / 4.0F; - f3 = (float)((double)f8 * this.renderMaxY * (1.0D - this.renderMinX) + (double)f9 * this.renderMaxY * this.renderMinX + (double)f10 * (1.0D - this.renderMaxY) * this.renderMinX + (double)f11 * (1.0D - this.renderMaxY) * (1.0D - this.renderMinX)); - f4 = (float)((double)f8 * this.renderMinY * (1.0D - this.renderMinX) + (double)f9 * this.renderMinY * this.renderMinX + (double)f10 * (1.0D - this.renderMinY) * this.renderMinX + (double)f11 * (1.0D - this.renderMinY) * (1.0D - this.renderMinX)); - f5 = (float)((double)f8 * this.renderMinY * (1.0D - this.renderMaxX) + (double)f9 * this.renderMinY * this.renderMaxX + (double)f10 * (1.0D - this.renderMinY) * this.renderMaxX + (double)f11 * (1.0D - this.renderMinY) * (1.0D - this.renderMaxX)); - f6 = (float)((double)f8 * this.renderMaxY * (1.0D - this.renderMaxX) + (double)f9 * this.renderMaxY * this.renderMaxX + (double)f10 * (1.0D - this.renderMaxY) * this.renderMaxX + (double)f11 * (1.0D - this.renderMaxY) * (1.0D - this.renderMaxX)); - j1 = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXZNP, this.aoBrightnessXYZNPP, this.aoBrightnessYZPP, i1); - k1 = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessYZPP, this.aoBrightnessXZPP, this.aoBrightnessXYZPPP, i1); - l1 = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessYZNP, this.aoBrightnessXYZPNP, this.aoBrightnessXZPP, i1); - i2 = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXYZNNP, this.aoBrightnessXZNP, this.aoBrightnessYZNP, i1); - this.brightnessTopLeft = RenderBlocks.getInstance().mixAoBrightness(j1, i2, l1, k1, this.renderMaxY * (1.0D - this.renderMinX), (1.0D - this.renderMaxY) * (1.0D - this.renderMinX), (1.0D - this.renderMaxY) * this.renderMinX, this.renderMaxY * this.renderMinX); - this.brightnessBottomLeft = RenderBlocks.getInstance().mixAoBrightness(j1, i2, l1, k1, this.renderMinY * (1.0D - this.renderMinX), (1.0D - this.renderMinY) * (1.0D - this.renderMinX), (1.0D - this.renderMinY) * this.renderMinX, this.renderMinY * this.renderMinX); - this.brightnessBottomRight = RenderBlocks.getInstance().mixAoBrightness(j1, i2, l1, k1, this.renderMinY * (1.0D - this.renderMaxX), (1.0D - this.renderMinY) * (1.0D - this.renderMaxX), (1.0D - this.renderMinY) * this.renderMaxX, this.renderMinY * this.renderMaxX); - this.brightnessTopRight = RenderBlocks.getInstance().mixAoBrightness(j1, i2, l1, k1, this.renderMaxY * (1.0D - this.renderMaxX), (1.0D - this.renderMaxY) * (1.0D - this.renderMaxX), (1.0D - this.renderMaxY) * this.renderMaxX, this.renderMaxY * this.renderMaxX); - - if (flag1) - { - this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R * 0.8F; - this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G * 0.8F; - this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B * 0.8F; - } - else - { - this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.8F; - this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.8F; - this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.8F; - } - - this.colorRedTopLeft *= f3; - this.colorGreenTopLeft *= f3; - this.colorBlueTopLeft *= f3; - this.colorRedBottomLeft *= f4; - this.colorGreenBottomLeft *= f4; - this.colorBlueBottomLeft *= f4; - this.colorRedBottomRight *= f5; - this.colorGreenBottomRight *= f5; - this.colorBlueBottomRight *= f5; - this.colorRedTopRight *= f6; - this.colorGreenTopRight *= f6; - this.colorBlueTopRight *= f6; - iicon = this.getBlockIcon(block, blockAccess, xPos, yPos, zPos, 3); - CustomOreBlockRenderer.renderFaceZPos(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); - - RenderBlocks.getInstance(); - if (RenderBlocks.fancyGrass && iicon.getIconName().equals("grass_side") && !this.hasOverrideBlockTexture()) - { - this.colorRedTopLeft *= R; - this.colorRedBottomLeft *= R; - this.colorRedBottomRight *= R; - this.colorRedTopRight *= R; - this.colorGreenTopLeft *= G; - this.colorGreenBottomLeft *= G; - this.colorGreenBottomRight *= G; - this.colorGreenTopRight *= G; - this.colorBlueTopLeft *= B; - this.colorBlueBottomLeft *= B; - this.colorBlueBottomRight *= B; - this.colorBlueTopRight *= B; - CustomOreBlockRenderer.renderFaceZPos(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); - } - - flag = true; - } - - if (RenderBlocks.getInstance().renderAllFaces || block.shouldSideBeRendered(blockAccess, xPos - 1, yPos, zPos, 4)) - { - if (this.renderMinX <= 0.0D) - { - --xPos; - } - - this.aoLightValueScratchXYNN = blockAccess.getBlock(xPos, yPos - 1, zPos).getAmbientOcclusionLightValue(); - this.aoLightValueScratchXZNN = blockAccess.getBlock(xPos, yPos, zPos - 1).getAmbientOcclusionLightValue(); - this.aoLightValueScratchXZNP = blockAccess.getBlock(xPos, yPos, zPos + 1).getAmbientOcclusionLightValue(); - this.aoLightValueScratchXYNP = blockAccess.getBlock(xPos, yPos + 1, zPos).getAmbientOcclusionLightValue(); - this.aoBrightnessXYNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos); - this.aoBrightnessXZNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos - 1); - this.aoBrightnessXZNP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos + 1); - this.aoBrightnessXYNP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos); - flag2 = blockAccess.getBlock(xPos - 1, yPos + 1, zPos).getCanBlockGrass(); - flag3 = blockAccess.getBlock(xPos - 1, yPos - 1, zPos).getCanBlockGrass(); - flag4 = blockAccess.getBlock(xPos - 1, yPos, zPos - 1).getCanBlockGrass(); - flag5 = blockAccess.getBlock(xPos - 1, yPos, zPos + 1).getCanBlockGrass(); - - if (!flag4 && !flag3) - { - this.aoLightValueScratchXYZNNN = this.aoLightValueScratchXZNN; - this.aoBrightnessXYZNNN = this.aoBrightnessXZNN; - } - else - { - this.aoLightValueScratchXYZNNN = blockAccess.getBlock(xPos, yPos - 1, zPos - 1).getAmbientOcclusionLightValue(); - this.aoBrightnessXYZNNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos - 1); - } - - if (!flag5 && !flag3) - { - this.aoLightValueScratchXYZNNP = this.aoLightValueScratchXZNP; - this.aoBrightnessXYZNNP = this.aoBrightnessXZNP; - } - else - { - this.aoLightValueScratchXYZNNP = blockAccess.getBlock(xPos, yPos - 1, zPos + 1).getAmbientOcclusionLightValue(); - this.aoBrightnessXYZNNP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos + 1); - } - - if (!flag4 && !flag2) - { - this.aoLightValueScratchXYZNPN = this.aoLightValueScratchXZNN; - this.aoBrightnessXYZNPN = this.aoBrightnessXZNN; - } - else - { - this.aoLightValueScratchXYZNPN = blockAccess.getBlock(xPos, yPos + 1, zPos - 1).getAmbientOcclusionLightValue(); - this.aoBrightnessXYZNPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos - 1); - } - - if (!flag5 && !flag2) - { - this.aoLightValueScratchXYZNPP = this.aoLightValueScratchXZNP; - this.aoBrightnessXYZNPP = this.aoBrightnessXZNP; - } - else - { - this.aoLightValueScratchXYZNPP = blockAccess.getBlock(xPos, yPos + 1, zPos + 1).getAmbientOcclusionLightValue(); - this.aoBrightnessXYZNPP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos + 1); - } - - if (this.renderMinX <= 0.0D) - { - ++xPos; - } - - i1 = l; - - if (this.renderMinX <= 0.0D || !blockAccess.getBlock(xPos - 1, yPos, zPos).isOpaqueCube()) - { - i1 = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos); - } - - f7 = blockAccess.getBlock(xPos - 1, yPos, zPos).getAmbientOcclusionLightValue(); - f8 = (this.aoLightValueScratchXYNN + this.aoLightValueScratchXYZNNP + f7 + this.aoLightValueScratchXZNP) / 4.0F; - f9 = (f7 + this.aoLightValueScratchXZNP + this.aoLightValueScratchXYNP + this.aoLightValueScratchXYZNPP) / 4.0F; - f10 = (this.aoLightValueScratchXZNN + f7 + this.aoLightValueScratchXYZNPN + this.aoLightValueScratchXYNP) / 4.0F; - f11 = (this.aoLightValueScratchXYZNNN + this.aoLightValueScratchXYNN + this.aoLightValueScratchXZNN + f7) / 4.0F; - f3 = (float)((double)f9 * this.renderMaxY * this.renderMaxZ + (double)f10 * this.renderMaxY * (1.0D - this.renderMaxZ) + (double)f11 * (1.0D - this.renderMaxY) * (1.0D - this.renderMaxZ) + (double)f8 * (1.0D - this.renderMaxY) * this.renderMaxZ); - f4 = (float)((double)f9 * this.renderMaxY * this.renderMinZ + (double)f10 * this.renderMaxY * (1.0D - this.renderMinZ) + (double)f11 * (1.0D - this.renderMaxY) * (1.0D - this.renderMinZ) + (double)f8 * (1.0D - this.renderMaxY) * this.renderMinZ); - f5 = (float)((double)f9 * this.renderMinY * this.renderMinZ + (double)f10 * this.renderMinY * (1.0D - this.renderMinZ) + (double)f11 * (1.0D - this.renderMinY) * (1.0D - this.renderMinZ) + (double)f8 * (1.0D - this.renderMinY) * this.renderMinZ); - f6 = (float)((double)f9 * this.renderMinY * this.renderMaxZ + (double)f10 * this.renderMinY * (1.0D - this.renderMaxZ) + (double)f11 * (1.0D - this.renderMinY) * (1.0D - this.renderMaxZ) + (double)f8 * (1.0D - this.renderMinY) * this.renderMaxZ); - j1 = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXYNN, this.aoBrightnessXYZNNP, this.aoBrightnessXZNP, i1); - k1 = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXZNP, this.aoBrightnessXYNP, this.aoBrightnessXYZNPP, i1); - l1 = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXZNN, this.aoBrightnessXYZNPN, this.aoBrightnessXYNP, i1); - i2 = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXYZNNN, this.aoBrightnessXYNN, this.aoBrightnessXZNN, i1); - this.brightnessTopLeft = RenderBlocks.getInstance().mixAoBrightness(k1, l1, i2, j1, this.renderMaxY * this.renderMaxZ, this.renderMaxY * (1.0D - this.renderMaxZ), (1.0D - this.renderMaxY) * (1.0D - this.renderMaxZ), (1.0D - this.renderMaxY) * this.renderMaxZ); - this.brightnessBottomLeft = RenderBlocks.getInstance().mixAoBrightness(k1, l1, i2, j1, this.renderMaxY * this.renderMinZ, this.renderMaxY * (1.0D - this.renderMinZ), (1.0D - this.renderMaxY) * (1.0D - this.renderMinZ), (1.0D - this.renderMaxY) * this.renderMinZ); - this.brightnessBottomRight = RenderBlocks.getInstance().mixAoBrightness(k1, l1, i2, j1, this.renderMinY * this.renderMinZ, this.renderMinY * (1.0D - this.renderMinZ), (1.0D - this.renderMinY) * (1.0D - this.renderMinZ), (1.0D - this.renderMinY) * this.renderMinZ); - this.brightnessTopRight = RenderBlocks.getInstance().mixAoBrightness(k1, l1, i2, j1, this.renderMinY * this.renderMaxZ, this.renderMinY * (1.0D - this.renderMaxZ), (1.0D - this.renderMinY) * (1.0D - this.renderMaxZ), (1.0D - this.renderMinY) * this.renderMaxZ); - - if (flag1) - { - this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R * 0.6F; - this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G * 0.6F; - this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B * 0.6F; - } - else - { - this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.6F; - this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.6F; - this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.6F; - } - - this.colorRedTopLeft *= f3; - this.colorGreenTopLeft *= f3; - this.colorBlueTopLeft *= f3; - this.colorRedBottomLeft *= f4; - this.colorGreenBottomLeft *= f4; - this.colorBlueBottomLeft *= f4; - this.colorRedBottomRight *= f5; - this.colorGreenBottomRight *= f5; - this.colorBlueBottomRight *= f5; - this.colorRedTopRight *= f6; - this.colorGreenTopRight *= f6; - this.colorBlueTopRight *= f6; - iicon = this.getBlockIcon(block, blockAccess, xPos, yPos, zPos, 4); - CustomOreBlockRenderer.renderFaceXNeg(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); - - RenderBlocks.getInstance(); - if (RenderBlocks.fancyGrass && iicon.getIconName().equals("grass_side") && !this.hasOverrideBlockTexture()) - { - this.colorRedTopLeft *= R; - this.colorRedBottomLeft *= R; - this.colorRedBottomRight *= R; - this.colorRedTopRight *= R; - this.colorGreenTopLeft *= G; - this.colorGreenBottomLeft *= G; - this.colorGreenBottomRight *= G; - this.colorGreenTopRight *= G; - this.colorBlueTopLeft *= B; - this.colorBlueBottomLeft *= B; - this.colorBlueBottomRight *= B; - this.colorBlueTopRight *= B; - CustomOreBlockRenderer.renderFaceXNeg(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); - } - - flag = true; - } - - if (RenderBlocks.getInstance().renderAllFaces || block.shouldSideBeRendered(blockAccess, xPos + 1, yPos, zPos, 5)) - { - if (this.renderMaxX >= 1.0D) - { - ++xPos; - } - - this.aoLightValueScratchXYPN = blockAccess.getBlock(xPos, yPos - 1, zPos).getAmbientOcclusionLightValue(); - this.aoLightValueScratchXZPN = blockAccess.getBlock(xPos, yPos, zPos - 1).getAmbientOcclusionLightValue(); - this.aoLightValueScratchXZPP = blockAccess.getBlock(xPos, yPos, zPos + 1).getAmbientOcclusionLightValue(); - this.aoLightValueScratchXYPP = blockAccess.getBlock(xPos, yPos + 1, zPos).getAmbientOcclusionLightValue(); - this.aoBrightnessXYPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos); - this.aoBrightnessXZPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos - 1); - this.aoBrightnessXZPP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos + 1); - this.aoBrightnessXYPP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos); - flag2 = blockAccess.getBlock(xPos + 1, yPos + 1, zPos).getCanBlockGrass(); - flag3 = blockAccess.getBlock(xPos + 1, yPos - 1, zPos).getCanBlockGrass(); - flag4 = blockAccess.getBlock(xPos + 1, yPos, zPos + 1).getCanBlockGrass(); - flag5 = blockAccess.getBlock(xPos + 1, yPos, zPos - 1).getCanBlockGrass(); - - if (!flag3 && !flag5) - { - this.aoLightValueScratchXYZPNN = this.aoLightValueScratchXZPN; - this.aoBrightnessXYZPNN = this.aoBrightnessXZPN; - } - else - { - this.aoLightValueScratchXYZPNN = blockAccess.getBlock(xPos, yPos - 1, zPos - 1).getAmbientOcclusionLightValue(); - this.aoBrightnessXYZPNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos - 1); - } - - if (!flag3 && !flag4) - { - this.aoLightValueScratchXYZPNP = this.aoLightValueScratchXZPP; - this.aoBrightnessXYZPNP = this.aoBrightnessXZPP; - } - else - { - this.aoLightValueScratchXYZPNP = blockAccess.getBlock(xPos, yPos - 1, zPos + 1).getAmbientOcclusionLightValue(); - this.aoBrightnessXYZPNP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos + 1); - } - - if (!flag2 && !flag5) - { - this.aoLightValueScratchXYZPPN = this.aoLightValueScratchXZPN; - this.aoBrightnessXYZPPN = this.aoBrightnessXZPN; - } - else - { - this.aoLightValueScratchXYZPPN = blockAccess.getBlock(xPos, yPos + 1, zPos - 1).getAmbientOcclusionLightValue(); - this.aoBrightnessXYZPPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos - 1); - } - - if (!flag2 && !flag4) - { - this.aoLightValueScratchXYZPPP = this.aoLightValueScratchXZPP; - this.aoBrightnessXYZPPP = this.aoBrightnessXZPP; - } - else - { - this.aoLightValueScratchXYZPPP = blockAccess.getBlock(xPos, yPos + 1, zPos + 1).getAmbientOcclusionLightValue(); - this.aoBrightnessXYZPPP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos + 1); - } - - if (this.renderMaxX >= 1.0D) - { - --xPos; - } - - i1 = l; - - if (this.renderMaxX >= 1.0D || !blockAccess.getBlock(xPos + 1, yPos, zPos).isOpaqueCube()) - { - i1 = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos); - } - - f7 = blockAccess.getBlock(xPos + 1, yPos, zPos).getAmbientOcclusionLightValue(); - f8 = (this.aoLightValueScratchXYPN + this.aoLightValueScratchXYZPNP + f7 + this.aoLightValueScratchXZPP) / 4.0F; - f9 = (this.aoLightValueScratchXYZPNN + this.aoLightValueScratchXYPN + this.aoLightValueScratchXZPN + f7) / 4.0F; - f10 = (this.aoLightValueScratchXZPN + f7 + this.aoLightValueScratchXYZPPN + this.aoLightValueScratchXYPP) / 4.0F; - f11 = (f7 + this.aoLightValueScratchXZPP + this.aoLightValueScratchXYPP + this.aoLightValueScratchXYZPPP) / 4.0F; - f3 = (float)((double)f8 * (1.0D - this.renderMinY) * this.renderMaxZ + (double)f9 * (1.0D - this.renderMinY) * (1.0D - this.renderMaxZ) + (double)f10 * this.renderMinY * (1.0D - this.renderMaxZ) + (double)f11 * this.renderMinY * this.renderMaxZ); - f4 = (float)((double)f8 * (1.0D - this.renderMinY) * this.renderMinZ + (double)f9 * (1.0D - this.renderMinY) * (1.0D - this.renderMinZ) + (double)f10 * this.renderMinY * (1.0D - this.renderMinZ) + (double)f11 * this.renderMinY * this.renderMinZ); - f5 = (float)((double)f8 * (1.0D - this.renderMaxY) * this.renderMinZ + (double)f9 * (1.0D - this.renderMaxY) * (1.0D - this.renderMinZ) + (double)f10 * this.renderMaxY * (1.0D - this.renderMinZ) + (double)f11 * this.renderMaxY * this.renderMinZ); - f6 = (float)((double)f8 * (1.0D - this.renderMaxY) * this.renderMaxZ + (double)f9 * (1.0D - this.renderMaxY) * (1.0D - this.renderMaxZ) + (double)f10 * this.renderMaxY * (1.0D - this.renderMaxZ) + (double)f11 * this.renderMaxY * this.renderMaxZ); - j1 = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXYPN, this.aoBrightnessXYZPNP, this.aoBrightnessXZPP, i1); - k1 = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXZPP, this.aoBrightnessXYPP, this.aoBrightnessXYZPPP, i1); - l1 = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXZPN, this.aoBrightnessXYZPPN, this.aoBrightnessXYPP, i1); - i2 = RenderBlocks.getInstance().getAoBrightness(this.aoBrightnessXYZPNN, this.aoBrightnessXYPN, this.aoBrightnessXZPN, i1); - this.brightnessTopLeft = RenderBlocks.getInstance().mixAoBrightness(j1, i2, l1, k1, (1.0D - this.renderMinY) * this.renderMaxZ, (1.0D - this.renderMinY) * (1.0D - this.renderMaxZ), this.renderMinY * (1.0D - this.renderMaxZ), this.renderMinY * this.renderMaxZ); - this.brightnessBottomLeft = RenderBlocks.getInstance().mixAoBrightness(j1, i2, l1, k1, (1.0D - this.renderMinY) * this.renderMinZ, (1.0D - this.renderMinY) * (1.0D - this.renderMinZ), this.renderMinY * (1.0D - this.renderMinZ), this.renderMinY * this.renderMinZ); - this.brightnessBottomRight = RenderBlocks.getInstance().mixAoBrightness(j1, i2, l1, k1, (1.0D - this.renderMaxY) * this.renderMinZ, (1.0D - this.renderMaxY) * (1.0D - this.renderMinZ), this.renderMaxY * (1.0D - this.renderMinZ), this.renderMaxY * this.renderMinZ); - this.brightnessTopRight = RenderBlocks.getInstance().mixAoBrightness(j1, i2, l1, k1, (1.0D - this.renderMaxY) * this.renderMaxZ, (1.0D - this.renderMaxY) * (1.0D - this.renderMaxZ), this.renderMaxY * (1.0D - this.renderMaxZ), this.renderMaxY * this.renderMaxZ); - - if (flag1) - { - this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R * 0.6F; - this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G * 0.6F; - this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B * 0.6F; - } - else - { - this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.6F; - this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.6F; - this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.6F; - } - - this.colorRedTopLeft *= f3; - this.colorGreenTopLeft *= f3; - this.colorBlueTopLeft *= f3; - this.colorRedBottomLeft *= f4; - this.colorGreenBottomLeft *= f4; - this.colorBlueBottomLeft *= f4; - this.colorRedBottomRight *= f5; - this.colorGreenBottomRight *= f5; - this.colorBlueBottomRight *= f5; - this.colorRedTopRight *= f6; - this.colorGreenTopRight *= f6; - this.colorBlueTopRight *= f6; - iicon = this.getBlockIcon(block, blockAccess, xPos, yPos, zPos, 5); - CustomOreBlockRenderer.renderFaceXPos(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); - - RenderBlocks.getInstance(); - if (RenderBlocks.fancyGrass && iicon.getIconName().equals("grass_side") && !this.hasOverrideBlockTexture()) - { - this.colorRedTopLeft *= R; - this.colorRedBottomLeft *= R; - this.colorRedBottomRight *= R; - this.colorRedTopRight *= R; - this.colorGreenTopLeft *= G; - this.colorGreenBottomLeft *= G; - this.colorGreenBottomRight *= G; - this.colorGreenTopRight *= G; - this.colorBlueTopLeft *= B; - this.colorBlueBottomLeft *= B; - this.colorBlueBottomRight *= B; - this.colorBlueTopRight *= B; - CustomOreBlockRenderer.renderFaceXPos(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); - } - - flag = true; - } - - this.enableAO = false; - return flag; - } + /** + * Renders non-full-cube block with ambient occusion. Args: block, x, y, z, red, green, blue (lighting) + */ + public boolean renderStandardBlockWithAmbientOcclusionPartial( + IBlockAccess aWorld, + RenderBlocks aRenderer, + ITexture[][] aTextures, + Block block, + int xPos, + int yPos, + int zPos, + float R, + float G, + float B) { + this.enableAO = true; + boolean flag = false; + float f3 = 0.0F; + float f4 = 0.0F; + float f5 = 0.0F; + float f6 = 0.0F; + boolean flag1 = true; + int l = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos); + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(983055); + + if (this.getBlockIcon(block).getIconName().equals("grass_top")) { + flag1 = false; + } else if (this.hasOverrideBlockTexture()) { + flag1 = false; + } + + boolean flag2; + boolean flag3; + boolean flag4; + boolean flag5; + int i1; + float f7; + + if (RenderBlocks.getInstance().renderAllFaces + || block.shouldSideBeRendered(blockAccess, xPos, yPos - 1, zPos, 0)) { + if (this.renderMinY <= 0.0D) { + --yPos; + } + + this.aoBrightnessXYNN = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos); + this.aoBrightnessYZNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos - 1); + this.aoBrightnessYZNP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos + 1); + this.aoBrightnessXYPN = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos); + this.aoLightValueScratchXYNN = + blockAccess.getBlock(xPos - 1, yPos, zPos).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZNN = + blockAccess.getBlock(xPos, yPos, zPos - 1).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZNP = + blockAccess.getBlock(xPos, yPos, zPos + 1).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXYPN = + blockAccess.getBlock(xPos + 1, yPos, zPos).getAmbientOcclusionLightValue(); + flag2 = blockAccess.getBlock(xPos + 1, yPos - 1, zPos).getCanBlockGrass(); + flag3 = blockAccess.getBlock(xPos - 1, yPos - 1, zPos).getCanBlockGrass(); + flag4 = blockAccess.getBlock(xPos, yPos - 1, zPos + 1).getCanBlockGrass(); + flag5 = blockAccess.getBlock(xPos, yPos - 1, zPos - 1).getCanBlockGrass(); + + if (!flag5 && !flag3) { + this.aoLightValueScratchXYZNNN = this.aoLightValueScratchXYNN; + this.aoBrightnessXYZNNN = this.aoBrightnessXYNN; + } else { + this.aoLightValueScratchXYZNNN = + blockAccess.getBlock(xPos - 1, yPos, zPos - 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNN = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos - 1); + } + + if (!flag4 && !flag3) { + this.aoLightValueScratchXYZNNP = this.aoLightValueScratchXYNN; + this.aoBrightnessXYZNNP = this.aoBrightnessXYNN; + } else { + this.aoLightValueScratchXYZNNP = + blockAccess.getBlock(xPos - 1, yPos, zPos + 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNP = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos + 1); + } + + if (!flag5 && !flag2) { + this.aoLightValueScratchXYZPNN = this.aoLightValueScratchXYPN; + this.aoBrightnessXYZPNN = this.aoBrightnessXYPN; + } else { + this.aoLightValueScratchXYZPNN = + blockAccess.getBlock(xPos + 1, yPos, zPos - 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNN = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos - 1); + } + + if (!flag4 && !flag2) { + this.aoLightValueScratchXYZPNP = this.aoLightValueScratchXYPN; + this.aoBrightnessXYZPNP = this.aoBrightnessXYPN; + } else { + this.aoLightValueScratchXYZPNP = + blockAccess.getBlock(xPos + 1, yPos, zPos + 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos + 1); + } + + if (this.renderMinY <= 0.0D) { + ++yPos; + } + + i1 = l; + + if (this.renderMinY <= 0.0D + || !blockAccess.getBlock(xPos, yPos - 1, zPos).isOpaqueCube()) { + i1 = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos); + } + + f7 = blockAccess.getBlock(xPos, yPos - 1, zPos).getAmbientOcclusionLightValue(); + f3 = (this.aoLightValueScratchXYZNNP + this.aoLightValueScratchXYNN + this.aoLightValueScratchYZNP + f7) + / 4.0F; + f6 = (this.aoLightValueScratchYZNP + f7 + this.aoLightValueScratchXYZPNP + this.aoLightValueScratchXYPN) + / 4.0F; + f5 = (f7 + this.aoLightValueScratchYZNN + this.aoLightValueScratchXYPN + this.aoLightValueScratchXYZPNN) + / 4.0F; + f4 = (this.aoLightValueScratchXYNN + this.aoLightValueScratchXYZNNN + f7 + this.aoLightValueScratchYZNN) + / 4.0F; + this.brightnessTopLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYZNNP, this.aoBrightnessXYNN, this.aoBrightnessYZNP, i1); + this.brightnessTopRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZNP, this.aoBrightnessXYZPNP, this.aoBrightnessXYPN, i1); + this.brightnessBottomRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZNN, this.aoBrightnessXYPN, this.aoBrightnessXYZPNN, i1); + this.brightnessBottomLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYNN, this.aoBrightnessXYZNNN, this.aoBrightnessYZNN, i1); + + if (flag1) { + this.colorRedTopLeft = + this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R * 0.5F; + this.colorGreenTopLeft = + this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G * 0.5F; + this.colorBlueTopLeft = + this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B * 0.5F; + } else { + this.colorRedTopLeft = + this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.5F; + this.colorGreenTopLeft = + this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.5F; + this.colorBlueTopLeft = + this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.5F; + } + + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + CustomOreBlockRenderer.renderFaceYNeg(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + flag = true; + } + + if (RenderBlocks.getInstance().renderAllFaces + || block.shouldSideBeRendered(blockAccess, xPos, yPos + 1, zPos, 1)) { + if (this.renderMaxY >= 1.0D) { + ++yPos; + } + + this.aoBrightnessXYNP = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos); + this.aoBrightnessXYPP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos); + this.aoBrightnessYZPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos - 1); + this.aoBrightnessYZPP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos + 1); + this.aoLightValueScratchXYNP = + blockAccess.getBlock(xPos - 1, yPos, zPos).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXYPP = + blockAccess.getBlock(xPos + 1, yPos, zPos).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZPN = + blockAccess.getBlock(xPos, yPos, zPos - 1).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZPP = + blockAccess.getBlock(xPos, yPos, zPos + 1).getAmbientOcclusionLightValue(); + flag2 = blockAccess.getBlock(xPos + 1, yPos + 1, zPos).getCanBlockGrass(); + flag3 = blockAccess.getBlock(xPos - 1, yPos + 1, zPos).getCanBlockGrass(); + flag4 = blockAccess.getBlock(xPos, yPos + 1, zPos + 1).getCanBlockGrass(); + flag5 = blockAccess.getBlock(xPos, yPos + 1, zPos - 1).getCanBlockGrass(); + + if (!flag5 && !flag3) { + this.aoLightValueScratchXYZNPN = this.aoLightValueScratchXYNP; + this.aoBrightnessXYZNPN = this.aoBrightnessXYNP; + } else { + this.aoLightValueScratchXYZNPN = + blockAccess.getBlock(xPos - 1, yPos, zPos - 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPN = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos - 1); + } + + if (!flag5 && !flag2) { + this.aoLightValueScratchXYZPPN = this.aoLightValueScratchXYPP; + this.aoBrightnessXYZPPN = this.aoBrightnessXYPP; + } else { + this.aoLightValueScratchXYZPPN = + blockAccess.getBlock(xPos + 1, yPos, zPos - 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPN = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos - 1); + } + + if (!flag4 && !flag3) { + this.aoLightValueScratchXYZNPP = this.aoLightValueScratchXYNP; + this.aoBrightnessXYZNPP = this.aoBrightnessXYNP; + } else { + this.aoLightValueScratchXYZNPP = + blockAccess.getBlock(xPos - 1, yPos, zPos + 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPP = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos + 1); + } + + if (!flag4 && !flag2) { + this.aoLightValueScratchXYZPPP = this.aoLightValueScratchXYPP; + this.aoBrightnessXYZPPP = this.aoBrightnessXYPP; + } else { + this.aoLightValueScratchXYZPPP = + blockAccess.getBlock(xPos + 1, yPos, zPos + 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos + 1); + } + + if (this.renderMaxY >= 1.0D) { + --yPos; + } + + i1 = l; + + if (this.renderMaxY >= 1.0D + || !blockAccess.getBlock(xPos, yPos + 1, zPos).isOpaqueCube()) { + i1 = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos); + } + + f7 = blockAccess.getBlock(xPos, yPos + 1, zPos).getAmbientOcclusionLightValue(); + f6 = (this.aoLightValueScratchXYZNPP + this.aoLightValueScratchXYNP + this.aoLightValueScratchYZPP + f7) + / 4.0F; + f3 = (this.aoLightValueScratchYZPP + f7 + this.aoLightValueScratchXYZPPP + this.aoLightValueScratchXYPP) + / 4.0F; + f4 = (f7 + this.aoLightValueScratchYZPN + this.aoLightValueScratchXYPP + this.aoLightValueScratchXYZPPN) + / 4.0F; + f5 = (this.aoLightValueScratchXYNP + this.aoLightValueScratchXYZNPN + f7 + this.aoLightValueScratchYZPN) + / 4.0F; + this.brightnessTopRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYZNPP, this.aoBrightnessXYNP, this.aoBrightnessYZPP, i1); + this.brightnessTopLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZPP, this.aoBrightnessXYZPPP, this.aoBrightnessXYPP, i1); + this.brightnessBottomLeft = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZPN, this.aoBrightnessXYPP, this.aoBrightnessXYZPPN, i1); + this.brightnessBottomRight = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYNP, this.aoBrightnessXYZNPN, this.aoBrightnessYZPN, i1); + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R; + this.colorGreenTopLeft = + this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B; + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + CustomOreBlockRenderer.renderFaceYPos(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + flag = true; + } + + float f8; + float f9; + float f10; + float f11; + int j1; + int k1; + int l1; + int i2; + IIcon iicon; + + if (RenderBlocks.getInstance().renderAllFaces + || block.shouldSideBeRendered(blockAccess, xPos, yPos, zPos - 1, 2)) { + if (this.renderMinZ <= 0.0D) { + --zPos; + } + + this.aoLightValueScratchXZNN = + blockAccess.getBlock(xPos - 1, yPos, zPos).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZNN = + blockAccess.getBlock(xPos, yPos - 1, zPos).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZPN = + blockAccess.getBlock(xPos, yPos + 1, zPos).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZPN = + blockAccess.getBlock(xPos + 1, yPos, zPos).getAmbientOcclusionLightValue(); + this.aoBrightnessXZNN = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos); + this.aoBrightnessYZNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos); + this.aoBrightnessYZPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos); + this.aoBrightnessXZPN = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos); + flag2 = blockAccess.getBlock(xPos + 1, yPos, zPos - 1).getCanBlockGrass(); + flag3 = blockAccess.getBlock(xPos - 1, yPos, zPos - 1).getCanBlockGrass(); + flag4 = blockAccess.getBlock(xPos, yPos + 1, zPos - 1).getCanBlockGrass(); + flag5 = blockAccess.getBlock(xPos, yPos - 1, zPos - 1).getCanBlockGrass(); + + if (!flag3 && !flag5) { + this.aoLightValueScratchXYZNNN = this.aoLightValueScratchXZNN; + this.aoBrightnessXYZNNN = this.aoBrightnessXZNN; + } else { + this.aoLightValueScratchXYZNNN = + blockAccess.getBlock(xPos - 1, yPos - 1, zPos).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNN = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos - 1, zPos); + } + + if (!flag3 && !flag4) { + this.aoLightValueScratchXYZNPN = this.aoLightValueScratchXZNN; + this.aoBrightnessXYZNPN = this.aoBrightnessXZNN; + } else { + this.aoLightValueScratchXYZNPN = + blockAccess.getBlock(xPos - 1, yPos + 1, zPos).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPN = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos + 1, zPos); + } + + if (!flag2 && !flag5) { + this.aoLightValueScratchXYZPNN = this.aoLightValueScratchXZPN; + this.aoBrightnessXYZPNN = this.aoBrightnessXZPN; + } else { + this.aoLightValueScratchXYZPNN = + blockAccess.getBlock(xPos + 1, yPos - 1, zPos).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNN = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos - 1, zPos); + } + + if (!flag2 && !flag4) { + this.aoLightValueScratchXYZPPN = this.aoLightValueScratchXZPN; + this.aoBrightnessXYZPPN = this.aoBrightnessXZPN; + } else { + this.aoLightValueScratchXYZPPN = + blockAccess.getBlock(xPos + 1, yPos + 1, zPos).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPN = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos + 1, zPos); + } + + if (this.renderMinZ <= 0.0D) { + ++zPos; + } + + i1 = l; + + if (this.renderMinZ <= 0.0D + || !blockAccess.getBlock(xPos, yPos, zPos - 1).isOpaqueCube()) { + i1 = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos - 1); + } + + f7 = blockAccess.getBlock(xPos, yPos, zPos - 1).getAmbientOcclusionLightValue(); + f8 = (this.aoLightValueScratchXZNN + this.aoLightValueScratchXYZNPN + f7 + this.aoLightValueScratchYZPN) + / 4.0F; + f9 = (f7 + this.aoLightValueScratchYZPN + this.aoLightValueScratchXZPN + this.aoLightValueScratchXYZPPN) + / 4.0F; + f10 = (this.aoLightValueScratchYZNN + f7 + this.aoLightValueScratchXYZPNN + this.aoLightValueScratchXZPN) + / 4.0F; + f11 = (this.aoLightValueScratchXYZNNN + this.aoLightValueScratchXZNN + this.aoLightValueScratchYZNN + f7) + / 4.0F; + f3 = (float) ((double) f8 * this.renderMaxY * (1.0D - this.renderMinX) + + (double) f9 * this.renderMaxY * this.renderMinX + + (double) f10 * (1.0D - this.renderMaxY) * this.renderMinX + + (double) f11 * (1.0D - this.renderMaxY) * (1.0D - this.renderMinX)); + f4 = (float) ((double) f8 * this.renderMaxY * (1.0D - this.renderMaxX) + + (double) f9 * this.renderMaxY * this.renderMaxX + + (double) f10 * (1.0D - this.renderMaxY) * this.renderMaxX + + (double) f11 * (1.0D - this.renderMaxY) * (1.0D - this.renderMaxX)); + f5 = (float) ((double) f8 * this.renderMinY * (1.0D - this.renderMaxX) + + (double) f9 * this.renderMinY * this.renderMaxX + + (double) f10 * (1.0D - this.renderMinY) * this.renderMaxX + + (double) f11 * (1.0D - this.renderMinY) * (1.0D - this.renderMaxX)); + f6 = (float) ((double) f8 * this.renderMinY * (1.0D - this.renderMinX) + + (double) f9 * this.renderMinY * this.renderMinX + + (double) f10 * (1.0D - this.renderMinY) * this.renderMinX + + (double) f11 * (1.0D - this.renderMinY) * (1.0D - this.renderMinX)); + j1 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXZNN, this.aoBrightnessXYZNPN, this.aoBrightnessYZPN, i1); + k1 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZPN, this.aoBrightnessXZPN, this.aoBrightnessXYZPPN, i1); + l1 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZNN, this.aoBrightnessXYZPNN, this.aoBrightnessXZPN, i1); + i2 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYZNNN, this.aoBrightnessXZNN, this.aoBrightnessYZNN, i1); + this.brightnessTopLeft = RenderBlocks.getInstance() + .mixAoBrightness( + j1, + k1, + l1, + i2, + this.renderMaxY * (1.0D - this.renderMinX), + this.renderMaxY * this.renderMinX, + (1.0D - this.renderMaxY) * this.renderMinX, + (1.0D - this.renderMaxY) * (1.0D - this.renderMinX)); + this.brightnessBottomLeft = RenderBlocks.getInstance() + .mixAoBrightness( + j1, + k1, + l1, + i2, + this.renderMaxY * (1.0D - this.renderMaxX), + this.renderMaxY * this.renderMaxX, + (1.0D - this.renderMaxY) * this.renderMaxX, + (1.0D - this.renderMaxY) * (1.0D - this.renderMaxX)); + this.brightnessBottomRight = RenderBlocks.getInstance() + .mixAoBrightness( + j1, + k1, + l1, + i2, + this.renderMinY * (1.0D - this.renderMaxX), + this.renderMinY * this.renderMaxX, + (1.0D - this.renderMinY) * this.renderMaxX, + (1.0D - this.renderMinY) * (1.0D - this.renderMaxX)); + this.brightnessTopRight = RenderBlocks.getInstance() + .mixAoBrightness( + j1, + k1, + l1, + i2, + this.renderMinY * (1.0D - this.renderMinX), + this.renderMinY * this.renderMinX, + (1.0D - this.renderMinY) * this.renderMinX, + (1.0D - this.renderMinY) * (1.0D - this.renderMinX)); + + if (flag1) { + this.colorRedTopLeft = + this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R * 0.8F; + this.colorGreenTopLeft = + this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G * 0.8F; + this.colorBlueTopLeft = + this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B * 0.8F; + } else { + this.colorRedTopLeft = + this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.8F; + this.colorGreenTopLeft = + this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.8F; + this.colorBlueTopLeft = + this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.8F; + } + + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + iicon = this.getBlockIcon(block, blockAccess, xPos, yPos, zPos, 2); + CustomOreBlockRenderer.renderFaceZNeg(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + + RenderBlocks.getInstance(); + if (RenderBlocks.fancyGrass + && iicon.getIconName().equals("grass_side") + && !this.hasOverrideBlockTexture()) { + this.colorRedTopLeft *= R; + this.colorRedBottomLeft *= R; + this.colorRedBottomRight *= R; + this.colorRedTopRight *= R; + this.colorGreenTopLeft *= G; + this.colorGreenBottomLeft *= G; + this.colorGreenBottomRight *= G; + this.colorGreenTopRight *= G; + this.colorBlueTopLeft *= B; + this.colorBlueBottomLeft *= B; + this.colorBlueBottomRight *= B; + this.colorBlueTopRight *= B; + CustomOreBlockRenderer.renderFaceZNeg(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + } + + flag = true; + } + + if (RenderBlocks.getInstance().renderAllFaces + || block.shouldSideBeRendered(blockAccess, xPos, yPos, zPos + 1, 3)) { + if (this.renderMaxZ >= 1.0D) { + ++zPos; + } + + this.aoLightValueScratchXZNP = + blockAccess.getBlock(xPos - 1, yPos, zPos).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZPP = + blockAccess.getBlock(xPos + 1, yPos, zPos).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZNP = + blockAccess.getBlock(xPos, yPos - 1, zPos).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZPP = + blockAccess.getBlock(xPos, yPos + 1, zPos).getAmbientOcclusionLightValue(); + this.aoBrightnessXZNP = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos); + this.aoBrightnessXZPP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos); + this.aoBrightnessYZNP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos); + this.aoBrightnessYZPP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos); + flag2 = blockAccess.getBlock(xPos + 1, yPos, zPos + 1).getCanBlockGrass(); + flag3 = blockAccess.getBlock(xPos - 1, yPos, zPos + 1).getCanBlockGrass(); + flag4 = blockAccess.getBlock(xPos, yPos + 1, zPos + 1).getCanBlockGrass(); + flag5 = blockAccess.getBlock(xPos, yPos - 1, zPos + 1).getCanBlockGrass(); + + if (!flag3 && !flag5) { + this.aoLightValueScratchXYZNNP = this.aoLightValueScratchXZNP; + this.aoBrightnessXYZNNP = this.aoBrightnessXZNP; + } else { + this.aoLightValueScratchXYZNNP = + blockAccess.getBlock(xPos - 1, yPos - 1, zPos).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNP = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos - 1, zPos); + } + + if (!flag3 && !flag4) { + this.aoLightValueScratchXYZNPP = this.aoLightValueScratchXZNP; + this.aoBrightnessXYZNPP = this.aoBrightnessXZNP; + } else { + this.aoLightValueScratchXYZNPP = + blockAccess.getBlock(xPos - 1, yPos + 1, zPos).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPP = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos + 1, zPos); + } + + if (!flag2 && !flag5) { + this.aoLightValueScratchXYZPNP = this.aoLightValueScratchXZPP; + this.aoBrightnessXYZPNP = this.aoBrightnessXZPP; + } else { + this.aoLightValueScratchXYZPNP = + blockAccess.getBlock(xPos + 1, yPos - 1, zPos).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos - 1, zPos); + } + + if (!flag2 && !flag4) { + this.aoLightValueScratchXYZPPP = this.aoLightValueScratchXZPP; + this.aoBrightnessXYZPPP = this.aoBrightnessXZPP; + } else { + this.aoLightValueScratchXYZPPP = + blockAccess.getBlock(xPos + 1, yPos + 1, zPos).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPP = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos + 1, zPos); + } + + if (this.renderMaxZ >= 1.0D) { + --zPos; + } + + i1 = l; + + if (this.renderMaxZ >= 1.0D + || !blockAccess.getBlock(xPos, yPos, zPos + 1).isOpaqueCube()) { + i1 = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos + 1); + } + + f7 = blockAccess.getBlock(xPos, yPos, zPos + 1).getAmbientOcclusionLightValue(); + f8 = (this.aoLightValueScratchXZNP + this.aoLightValueScratchXYZNPP + f7 + this.aoLightValueScratchYZPP) + / 4.0F; + f9 = (f7 + this.aoLightValueScratchYZPP + this.aoLightValueScratchXZPP + this.aoLightValueScratchXYZPPP) + / 4.0F; + f10 = (this.aoLightValueScratchYZNP + f7 + this.aoLightValueScratchXYZPNP + this.aoLightValueScratchXZPP) + / 4.0F; + f11 = (this.aoLightValueScratchXYZNNP + this.aoLightValueScratchXZNP + this.aoLightValueScratchYZNP + f7) + / 4.0F; + f3 = (float) ((double) f8 * this.renderMaxY * (1.0D - this.renderMinX) + + (double) f9 * this.renderMaxY * this.renderMinX + + (double) f10 * (1.0D - this.renderMaxY) * this.renderMinX + + (double) f11 * (1.0D - this.renderMaxY) * (1.0D - this.renderMinX)); + f4 = (float) ((double) f8 * this.renderMinY * (1.0D - this.renderMinX) + + (double) f9 * this.renderMinY * this.renderMinX + + (double) f10 * (1.0D - this.renderMinY) * this.renderMinX + + (double) f11 * (1.0D - this.renderMinY) * (1.0D - this.renderMinX)); + f5 = (float) ((double) f8 * this.renderMinY * (1.0D - this.renderMaxX) + + (double) f9 * this.renderMinY * this.renderMaxX + + (double) f10 * (1.0D - this.renderMinY) * this.renderMaxX + + (double) f11 * (1.0D - this.renderMinY) * (1.0D - this.renderMaxX)); + f6 = (float) ((double) f8 * this.renderMaxY * (1.0D - this.renderMaxX) + + (double) f9 * this.renderMaxY * this.renderMaxX + + (double) f10 * (1.0D - this.renderMaxY) * this.renderMaxX + + (double) f11 * (1.0D - this.renderMaxY) * (1.0D - this.renderMaxX)); + j1 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXZNP, this.aoBrightnessXYZNPP, this.aoBrightnessYZPP, i1); + k1 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZPP, this.aoBrightnessXZPP, this.aoBrightnessXYZPPP, i1); + l1 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessYZNP, this.aoBrightnessXYZPNP, this.aoBrightnessXZPP, i1); + i2 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYZNNP, this.aoBrightnessXZNP, this.aoBrightnessYZNP, i1); + this.brightnessTopLeft = RenderBlocks.getInstance() + .mixAoBrightness( + j1, + i2, + l1, + k1, + this.renderMaxY * (1.0D - this.renderMinX), + (1.0D - this.renderMaxY) * (1.0D - this.renderMinX), + (1.0D - this.renderMaxY) * this.renderMinX, + this.renderMaxY * this.renderMinX); + this.brightnessBottomLeft = RenderBlocks.getInstance() + .mixAoBrightness( + j1, + i2, + l1, + k1, + this.renderMinY * (1.0D - this.renderMinX), + (1.0D - this.renderMinY) * (1.0D - this.renderMinX), + (1.0D - this.renderMinY) * this.renderMinX, + this.renderMinY * this.renderMinX); + this.brightnessBottomRight = RenderBlocks.getInstance() + .mixAoBrightness( + j1, + i2, + l1, + k1, + this.renderMinY * (1.0D - this.renderMaxX), + (1.0D - this.renderMinY) * (1.0D - this.renderMaxX), + (1.0D - this.renderMinY) * this.renderMaxX, + this.renderMinY * this.renderMaxX); + this.brightnessTopRight = RenderBlocks.getInstance() + .mixAoBrightness( + j1, + i2, + l1, + k1, + this.renderMaxY * (1.0D - this.renderMaxX), + (1.0D - this.renderMaxY) * (1.0D - this.renderMaxX), + (1.0D - this.renderMaxY) * this.renderMaxX, + this.renderMaxY * this.renderMaxX); + + if (flag1) { + this.colorRedTopLeft = + this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R * 0.8F; + this.colorGreenTopLeft = + this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G * 0.8F; + this.colorBlueTopLeft = + this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B * 0.8F; + } else { + this.colorRedTopLeft = + this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.8F; + this.colorGreenTopLeft = + this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.8F; + this.colorBlueTopLeft = + this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.8F; + } + + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + iicon = this.getBlockIcon(block, blockAccess, xPos, yPos, zPos, 3); + CustomOreBlockRenderer.renderFaceZPos(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + + RenderBlocks.getInstance(); + if (RenderBlocks.fancyGrass + && iicon.getIconName().equals("grass_side") + && !this.hasOverrideBlockTexture()) { + this.colorRedTopLeft *= R; + this.colorRedBottomLeft *= R; + this.colorRedBottomRight *= R; + this.colorRedTopRight *= R; + this.colorGreenTopLeft *= G; + this.colorGreenBottomLeft *= G; + this.colorGreenBottomRight *= G; + this.colorGreenTopRight *= G; + this.colorBlueTopLeft *= B; + this.colorBlueBottomLeft *= B; + this.colorBlueBottomRight *= B; + this.colorBlueTopRight *= B; + CustomOreBlockRenderer.renderFaceZPos(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + } + + flag = true; + } + + if (RenderBlocks.getInstance().renderAllFaces + || block.shouldSideBeRendered(blockAccess, xPos - 1, yPos, zPos, 4)) { + if (this.renderMinX <= 0.0D) { + --xPos; + } + + this.aoLightValueScratchXYNN = + blockAccess.getBlock(xPos, yPos - 1, zPos).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZNN = + blockAccess.getBlock(xPos, yPos, zPos - 1).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZNP = + blockAccess.getBlock(xPos, yPos, zPos + 1).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXYNP = + blockAccess.getBlock(xPos, yPos + 1, zPos).getAmbientOcclusionLightValue(); + this.aoBrightnessXYNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos); + this.aoBrightnessXZNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos - 1); + this.aoBrightnessXZNP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos + 1); + this.aoBrightnessXYNP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos); + flag2 = blockAccess.getBlock(xPos - 1, yPos + 1, zPos).getCanBlockGrass(); + flag3 = blockAccess.getBlock(xPos - 1, yPos - 1, zPos).getCanBlockGrass(); + flag4 = blockAccess.getBlock(xPos - 1, yPos, zPos - 1).getCanBlockGrass(); + flag5 = blockAccess.getBlock(xPos - 1, yPos, zPos + 1).getCanBlockGrass(); + + if (!flag4 && !flag3) { + this.aoLightValueScratchXYZNNN = this.aoLightValueScratchXZNN; + this.aoBrightnessXYZNNN = this.aoBrightnessXZNN; + } else { + this.aoLightValueScratchXYZNNN = + blockAccess.getBlock(xPos, yPos - 1, zPos - 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos - 1); + } + + if (!flag5 && !flag3) { + this.aoLightValueScratchXYZNNP = this.aoLightValueScratchXZNP; + this.aoBrightnessXYZNNP = this.aoBrightnessXZNP; + } else { + this.aoLightValueScratchXYZNNP = + blockAccess.getBlock(xPos, yPos - 1, zPos + 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos + 1); + } + + if (!flag4 && !flag2) { + this.aoLightValueScratchXYZNPN = this.aoLightValueScratchXZNN; + this.aoBrightnessXYZNPN = this.aoBrightnessXZNN; + } else { + this.aoLightValueScratchXYZNPN = + blockAccess.getBlock(xPos, yPos + 1, zPos - 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos - 1); + } + + if (!flag5 && !flag2) { + this.aoLightValueScratchXYZNPP = this.aoLightValueScratchXZNP; + this.aoBrightnessXYZNPP = this.aoBrightnessXZNP; + } else { + this.aoLightValueScratchXYZNPP = + blockAccess.getBlock(xPos, yPos + 1, zPos + 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos + 1); + } + + if (this.renderMinX <= 0.0D) { + ++xPos; + } + + i1 = l; + + if (this.renderMinX <= 0.0D + || !blockAccess.getBlock(xPos - 1, yPos, zPos).isOpaqueCube()) { + i1 = block.getMixedBrightnessForBlock(blockAccess, xPos - 1, yPos, zPos); + } + + f7 = blockAccess.getBlock(xPos - 1, yPos, zPos).getAmbientOcclusionLightValue(); + f8 = (this.aoLightValueScratchXYNN + this.aoLightValueScratchXYZNNP + f7 + this.aoLightValueScratchXZNP) + / 4.0F; + f9 = (f7 + this.aoLightValueScratchXZNP + this.aoLightValueScratchXYNP + this.aoLightValueScratchXYZNPP) + / 4.0F; + f10 = (this.aoLightValueScratchXZNN + f7 + this.aoLightValueScratchXYZNPN + this.aoLightValueScratchXYNP) + / 4.0F; + f11 = (this.aoLightValueScratchXYZNNN + this.aoLightValueScratchXYNN + this.aoLightValueScratchXZNN + f7) + / 4.0F; + f3 = (float) ((double) f9 * this.renderMaxY * this.renderMaxZ + + (double) f10 * this.renderMaxY * (1.0D - this.renderMaxZ) + + (double) f11 * (1.0D - this.renderMaxY) * (1.0D - this.renderMaxZ) + + (double) f8 * (1.0D - this.renderMaxY) * this.renderMaxZ); + f4 = (float) ((double) f9 * this.renderMaxY * this.renderMinZ + + (double) f10 * this.renderMaxY * (1.0D - this.renderMinZ) + + (double) f11 * (1.0D - this.renderMaxY) * (1.0D - this.renderMinZ) + + (double) f8 * (1.0D - this.renderMaxY) * this.renderMinZ); + f5 = (float) ((double) f9 * this.renderMinY * this.renderMinZ + + (double) f10 * this.renderMinY * (1.0D - this.renderMinZ) + + (double) f11 * (1.0D - this.renderMinY) * (1.0D - this.renderMinZ) + + (double) f8 * (1.0D - this.renderMinY) * this.renderMinZ); + f6 = (float) ((double) f9 * this.renderMinY * this.renderMaxZ + + (double) f10 * this.renderMinY * (1.0D - this.renderMaxZ) + + (double) f11 * (1.0D - this.renderMinY) * (1.0D - this.renderMaxZ) + + (double) f8 * (1.0D - this.renderMinY) * this.renderMaxZ); + j1 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYNN, this.aoBrightnessXYZNNP, this.aoBrightnessXZNP, i1); + k1 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXZNP, this.aoBrightnessXYNP, this.aoBrightnessXYZNPP, i1); + l1 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXZNN, this.aoBrightnessXYZNPN, this.aoBrightnessXYNP, i1); + i2 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYZNNN, this.aoBrightnessXYNN, this.aoBrightnessXZNN, i1); + this.brightnessTopLeft = RenderBlocks.getInstance() + .mixAoBrightness( + k1, + l1, + i2, + j1, + this.renderMaxY * this.renderMaxZ, + this.renderMaxY * (1.0D - this.renderMaxZ), + (1.0D - this.renderMaxY) * (1.0D - this.renderMaxZ), + (1.0D - this.renderMaxY) * this.renderMaxZ); + this.brightnessBottomLeft = RenderBlocks.getInstance() + .mixAoBrightness( + k1, + l1, + i2, + j1, + this.renderMaxY * this.renderMinZ, + this.renderMaxY * (1.0D - this.renderMinZ), + (1.0D - this.renderMaxY) * (1.0D - this.renderMinZ), + (1.0D - this.renderMaxY) * this.renderMinZ); + this.brightnessBottomRight = RenderBlocks.getInstance() + .mixAoBrightness( + k1, + l1, + i2, + j1, + this.renderMinY * this.renderMinZ, + this.renderMinY * (1.0D - this.renderMinZ), + (1.0D - this.renderMinY) * (1.0D - this.renderMinZ), + (1.0D - this.renderMinY) * this.renderMinZ); + this.brightnessTopRight = RenderBlocks.getInstance() + .mixAoBrightness( + k1, + l1, + i2, + j1, + this.renderMinY * this.renderMaxZ, + this.renderMinY * (1.0D - this.renderMaxZ), + (1.0D - this.renderMinY) * (1.0D - this.renderMaxZ), + (1.0D - this.renderMinY) * this.renderMaxZ); + + if (flag1) { + this.colorRedTopLeft = + this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R * 0.6F; + this.colorGreenTopLeft = + this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G * 0.6F; + this.colorBlueTopLeft = + this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B * 0.6F; + } else { + this.colorRedTopLeft = + this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.6F; + this.colorGreenTopLeft = + this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.6F; + this.colorBlueTopLeft = + this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.6F; + } + + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + iicon = this.getBlockIcon(block, blockAccess, xPos, yPos, zPos, 4); + CustomOreBlockRenderer.renderFaceXNeg(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + + RenderBlocks.getInstance(); + if (RenderBlocks.fancyGrass + && iicon.getIconName().equals("grass_side") + && !this.hasOverrideBlockTexture()) { + this.colorRedTopLeft *= R; + this.colorRedBottomLeft *= R; + this.colorRedBottomRight *= R; + this.colorRedTopRight *= R; + this.colorGreenTopLeft *= G; + this.colorGreenBottomLeft *= G; + this.colorGreenBottomRight *= G; + this.colorGreenTopRight *= G; + this.colorBlueTopLeft *= B; + this.colorBlueBottomLeft *= B; + this.colorBlueBottomRight *= B; + this.colorBlueTopRight *= B; + CustomOreBlockRenderer.renderFaceXNeg(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + } + + flag = true; + } + + if (RenderBlocks.getInstance().renderAllFaces + || block.shouldSideBeRendered(blockAccess, xPos + 1, yPos, zPos, 5)) { + if (this.renderMaxX >= 1.0D) { + ++xPos; + } + + this.aoLightValueScratchXYPN = + blockAccess.getBlock(xPos, yPos - 1, zPos).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZPN = + blockAccess.getBlock(xPos, yPos, zPos - 1).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZPP = + blockAccess.getBlock(xPos, yPos, zPos + 1).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXYPP = + blockAccess.getBlock(xPos, yPos + 1, zPos).getAmbientOcclusionLightValue(); + this.aoBrightnessXYPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos); + this.aoBrightnessXZPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos - 1); + this.aoBrightnessXZPP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos, zPos + 1); + this.aoBrightnessXYPP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos); + flag2 = blockAccess.getBlock(xPos + 1, yPos + 1, zPos).getCanBlockGrass(); + flag3 = blockAccess.getBlock(xPos + 1, yPos - 1, zPos).getCanBlockGrass(); + flag4 = blockAccess.getBlock(xPos + 1, yPos, zPos + 1).getCanBlockGrass(); + flag5 = blockAccess.getBlock(xPos + 1, yPos, zPos - 1).getCanBlockGrass(); + + if (!flag3 && !flag5) { + this.aoLightValueScratchXYZPNN = this.aoLightValueScratchXZPN; + this.aoBrightnessXYZPNN = this.aoBrightnessXZPN; + } else { + this.aoLightValueScratchXYZPNN = + blockAccess.getBlock(xPos, yPos - 1, zPos - 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos - 1); + } + + if (!flag3 && !flag4) { + this.aoLightValueScratchXYZPNP = this.aoLightValueScratchXZPP; + this.aoBrightnessXYZPNP = this.aoBrightnessXZPP; + } else { + this.aoLightValueScratchXYZPNP = + blockAccess.getBlock(xPos, yPos - 1, zPos + 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos - 1, zPos + 1); + } + + if (!flag2 && !flag5) { + this.aoLightValueScratchXYZPPN = this.aoLightValueScratchXZPN; + this.aoBrightnessXYZPPN = this.aoBrightnessXZPN; + } else { + this.aoLightValueScratchXYZPPN = + blockAccess.getBlock(xPos, yPos + 1, zPos - 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPN = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos - 1); + } + + if (!flag2 && !flag4) { + this.aoLightValueScratchXYZPPP = this.aoLightValueScratchXZPP; + this.aoBrightnessXYZPPP = this.aoBrightnessXZPP; + } else { + this.aoLightValueScratchXYZPPP = + blockAccess.getBlock(xPos, yPos + 1, zPos + 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPP = block.getMixedBrightnessForBlock(blockAccess, xPos, yPos + 1, zPos + 1); + } + + if (this.renderMaxX >= 1.0D) { + --xPos; + } + + i1 = l; + + if (this.renderMaxX >= 1.0D + || !blockAccess.getBlock(xPos + 1, yPos, zPos).isOpaqueCube()) { + i1 = block.getMixedBrightnessForBlock(blockAccess, xPos + 1, yPos, zPos); + } + + f7 = blockAccess.getBlock(xPos + 1, yPos, zPos).getAmbientOcclusionLightValue(); + f8 = (this.aoLightValueScratchXYPN + this.aoLightValueScratchXYZPNP + f7 + this.aoLightValueScratchXZPP) + / 4.0F; + f9 = (this.aoLightValueScratchXYZPNN + this.aoLightValueScratchXYPN + this.aoLightValueScratchXZPN + f7) + / 4.0F; + f10 = (this.aoLightValueScratchXZPN + f7 + this.aoLightValueScratchXYZPPN + this.aoLightValueScratchXYPP) + / 4.0F; + f11 = (f7 + this.aoLightValueScratchXZPP + this.aoLightValueScratchXYPP + this.aoLightValueScratchXYZPPP) + / 4.0F; + f3 = (float) ((double) f8 * (1.0D - this.renderMinY) * this.renderMaxZ + + (double) f9 * (1.0D - this.renderMinY) * (1.0D - this.renderMaxZ) + + (double) f10 * this.renderMinY * (1.0D - this.renderMaxZ) + + (double) f11 * this.renderMinY * this.renderMaxZ); + f4 = (float) ((double) f8 * (1.0D - this.renderMinY) * this.renderMinZ + + (double) f9 * (1.0D - this.renderMinY) * (1.0D - this.renderMinZ) + + (double) f10 * this.renderMinY * (1.0D - this.renderMinZ) + + (double) f11 * this.renderMinY * this.renderMinZ); + f5 = (float) ((double) f8 * (1.0D - this.renderMaxY) * this.renderMinZ + + (double) f9 * (1.0D - this.renderMaxY) * (1.0D - this.renderMinZ) + + (double) f10 * this.renderMaxY * (1.0D - this.renderMinZ) + + (double) f11 * this.renderMaxY * this.renderMinZ); + f6 = (float) ((double) f8 * (1.0D - this.renderMaxY) * this.renderMaxZ + + (double) f9 * (1.0D - this.renderMaxY) * (1.0D - this.renderMaxZ) + + (double) f10 * this.renderMaxY * (1.0D - this.renderMaxZ) + + (double) f11 * this.renderMaxY * this.renderMaxZ); + j1 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYPN, this.aoBrightnessXYZPNP, this.aoBrightnessXZPP, i1); + k1 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXZPP, this.aoBrightnessXYPP, this.aoBrightnessXYZPPP, i1); + l1 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXZPN, this.aoBrightnessXYZPPN, this.aoBrightnessXYPP, i1); + i2 = RenderBlocks.getInstance() + .getAoBrightness(this.aoBrightnessXYZPNN, this.aoBrightnessXYPN, this.aoBrightnessXZPN, i1); + this.brightnessTopLeft = RenderBlocks.getInstance() + .mixAoBrightness( + j1, + i2, + l1, + k1, + (1.0D - this.renderMinY) * this.renderMaxZ, + (1.0D - this.renderMinY) * (1.0D - this.renderMaxZ), + this.renderMinY * (1.0D - this.renderMaxZ), + this.renderMinY * this.renderMaxZ); + this.brightnessBottomLeft = RenderBlocks.getInstance() + .mixAoBrightness( + j1, + i2, + l1, + k1, + (1.0D - this.renderMinY) * this.renderMinZ, + (1.0D - this.renderMinY) * (1.0D - this.renderMinZ), + this.renderMinY * (1.0D - this.renderMinZ), + this.renderMinY * this.renderMinZ); + this.brightnessBottomRight = RenderBlocks.getInstance() + .mixAoBrightness( + j1, + i2, + l1, + k1, + (1.0D - this.renderMaxY) * this.renderMinZ, + (1.0D - this.renderMaxY) * (1.0D - this.renderMinZ), + this.renderMaxY * (1.0D - this.renderMinZ), + this.renderMaxY * this.renderMinZ); + this.brightnessTopRight = RenderBlocks.getInstance() + .mixAoBrightness( + j1, + i2, + l1, + k1, + (1.0D - this.renderMaxY) * this.renderMaxZ, + (1.0D - this.renderMaxY) * (1.0D - this.renderMaxZ), + this.renderMaxY * (1.0D - this.renderMaxZ), + this.renderMaxY * this.renderMaxZ); + + if (flag1) { + this.colorRedTopLeft = + this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = R * 0.6F; + this.colorGreenTopLeft = + this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = G * 0.6F; + this.colorBlueTopLeft = + this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = B * 0.6F; + } else { + this.colorRedTopLeft = + this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.6F; + this.colorGreenTopLeft = + this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.6F; + this.colorBlueTopLeft = + this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.6F; + } + + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + iicon = this.getBlockIcon(block, blockAccess, xPos, yPos, zPos, 5); + CustomOreBlockRenderer.renderFaceXPos(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + + RenderBlocks.getInstance(); + if (RenderBlocks.fancyGrass + && iicon.getIconName().equals("grass_side") + && !this.hasOverrideBlockTexture()) { + this.colorRedTopLeft *= R; + this.colorRedBottomLeft *= R; + this.colorRedBottomRight *= R; + this.colorRedTopRight *= R; + this.colorGreenTopLeft *= G; + this.colorGreenBottomLeft *= G; + this.colorGreenBottomRight *= G; + this.colorGreenTopRight *= G; + this.colorBlueTopLeft *= B; + this.colorBlueBottomLeft *= B; + this.colorBlueBottomRight *= B; + this.colorBlueTopRight *= B; + CustomOreBlockRenderer.renderFaceXPos(aWorld, aRenderer, block, xPos, yPos, zPos, aTextures); + } + + flag = true; + } + + this.enableAO = false; + return flag; + } } diff --git a/src/main/java/gtPlusPlus/core/client/renderer/RenderBatKing.java b/src/main/java/gtPlusPlus/core/client/renderer/RenderBatKing.java index 000badb80f..6654ff5c8d 100644 --- a/src/main/java/gtPlusPlus/core/client/renderer/RenderBatKing.java +++ b/src/main/java/gtPlusPlus/core/client/renderer/RenderBatKing.java @@ -1,7 +1,5 @@ package gtPlusPlus.core.client.renderer; -import org.lwjgl.opengl.GL11; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.core.client.model.ModelBatKing; @@ -13,140 +11,162 @@ import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class RenderBatKing extends RenderLiving { - - private static final ResourceLocation batTextures = new ResourceLocation(CORE.MODID+":"+"textures/entity/batKing.png"); - - /** - * not actually sure this is size, is not used as of now, but the model would be - * recreated if the value changed and it seems a good match for a bats size - */ - private int renderedBatSize; - - public RenderBatKing() { - super(new ModelBatKing(), 0.7F); - this.renderedBatSize = (((ModelBatKing) this.mainModel).getBatSize()); - } - - /** - * Actually renders the given argument. This is a synthetic bridge method, - * always casting down its argument and then handing it off to a worker function - * which does the actual work. In all probabilty, the class Render is generic - * (Render 1.0F) - { - f2 = 1.0F; - } - - f2 *= f2; - f2 *= f2; - final float f3 = 1.0F + (f2 * 0.3F); - GL11.glScalef(f3, f3, f3); - } - - f2 = (1.0F - (((entity.fuse - p_76986_9_) + 1.0F) / 100.0F)) * 0.8F; - this.bindEntityTexture(entity); - this.blockRenderer.renderBlockAsItem(ModBlocks.blockMiningExplosive, 0, entity.getBrightness(p_76986_9_)); - - if (((entity.fuse / 5) % 2) == 0) - { - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA); - GL11.glColor4f(1.0F, 1.0F, 1.0F, f2); - this.blockRenderer.renderBlockAsItem(ModBlocks.blockMiningExplosive, 0, 1.0F); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_TEXTURE_2D); - } - - GL11.glPopMatrix(); - } - - /** - * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. - */ - protected ResourceLocation getEntityTexture(final EntityPrimedMiningExplosive p_110775_1_){ - return TextureMap.locationBlocksTexture; - } - - /** - * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. - */ - @Override - protected ResourceLocation getEntityTexture(final Entity p_110775_1_){ - Logger.WARNING("Rendering Mining Explosion. 4"); - return this.getEntityTexture((EntityPrimedMiningExplosive)p_110775_1_); - } - - /** - * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then - * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic - * (Render 1.0F) { + f2 = 1.0F; + } + + f2 *= f2; + f2 *= f2; + final float f3 = 1.0F + (f2 * 0.3F); + GL11.glScalef(f3, f3, f3); + } + + f2 = (1.0F - (((entity.fuse - p_76986_9_) + 1.0F) / 100.0F)) * 0.8F; + this.bindEntityTexture(entity); + this.blockRenderer.renderBlockAsItem(ModBlocks.blockMiningExplosive, 0, entity.getBrightness(p_76986_9_)); + + if (((entity.fuse / 5) % 2) == 0) { + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA); + GL11.glColor4f(1.0F, 1.0F, 1.0F, f2); + this.blockRenderer.renderBlockAsItem(ModBlocks.blockMiningExplosive, 0, 1.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + GL11.glPopMatrix(); + } + + /** + * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. + */ + protected ResourceLocation getEntityTexture(final EntityPrimedMiningExplosive p_110775_1_) { + return TextureMap.locationBlocksTexture; + } + + /** + * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. + */ + @Override + protected ResourceLocation getEntityTexture(final Entity p_110775_1_) { + Logger.WARNING("Rendering Mining Explosion. 4"); + return this.getEntityTexture((EntityPrimedMiningExplosive) p_110775_1_); + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then + * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic + * (Render= 0; --i) { - adouble[i] = d3; - adouble1[i] = d4; - d3 += (double) (random.nextInt(11) - 5); - d4 += (double) (random.nextInt(11) - 5); - } - - for (int k1 = 0; k1 < 4; ++k1) { - Random random1 = new XSTR(p_76986_1_.boltVertex); - - for (int j = 0; j < 3; ++j) { - int k = 7; - int l = 0; - - if (j > 0) { - k = 7 - j; - } - - if (j > 0) { - l = k - 2; - } - - double d5 = adouble[k] - d3; - double d6 = adouble1[k] - d4; - - for (int i1 = k; i1 >= l; --i1) { - double d7 = d5; - double d8 = d6; - - if (j == 0) { - d5 += (double) (random1.nextInt(11) - 5); - d6 += (double) (random1.nextInt(11) - 5); - } - else { - d5 += (double) (random1.nextInt(31) - 15); - d6 += (double) (random1.nextInt(31) - 15); - } - - tessellator.startDrawing(5); - float f2 = 0.5F; - tessellator.setColorRGBA_F(0.9F * f2, 0.9F * f2, 1.0F * f2, 0.3F); - double d9 = 0.1D + (double) k1 * 0.2D; - - if (j == 0) { - d9 *= (double) i1 * 0.1D + 1.0D; - } - - double d10 = 0.1D + (double) k1 * 0.2D; - - if (j == 0) { - d10 *= (double) (i1 - 1) * 0.1D + 1.0D; - } - - for (int j1 = 0; j1 < 5; ++j1) { - double d11 = p_76986_2_ + 0.5D - d9; - double d12 = p_76986_6_ + 0.5D - d9; - - if (j1 == 1 || j1 == 2) { - d11 += d9 * 2.0D; - } - - if (j1 == 2 || j1 == 3) { - d12 += d9 * 2.0D; - } - - double d13 = p_76986_2_ + 0.5D - d10; - double d14 = p_76986_6_ + 0.5D - d10; - - if (j1 == 1 || j1 == 2) { - d13 += d10 * 2.0D; - } - - if (j1 == 2 || j1 == 3) { - d14 += d10 * 2.0D; - } - - tessellator.addVertex(d13 + d5, p_76986_4_ + (double) (i1 * 16), d14 + d6); - tessellator.addVertex(d11 + d7, p_76986_4_ + (double) ((i1 + 1) * 16), d12 + d8); - } - - tessellator.draw(); - } - } - } - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_TEXTURE_2D); - } - - /** - * Returns the location of an entity's texture. Doesn't seem to be called - * unless you call Render.bindEntityTexture. - */ - protected ResourceLocation getEntityTexture(EntityTeslaTowerLightning p_110775_1_) { - return null; - } - - /** - * Returns the location of an entity's texture. Doesn't seem to be called - * unless you call Render.bindEntityTexture. - */ - protected ResourceLocation getEntityTexture(Entity p_110775_1_) { - Logger.INFO("Render Plasma. 5"); - return this.getEntityTexture((EntityTeslaTowerLightning) p_110775_1_); - } - - /** - * Actually renders the given argument. This is a synthetic bridge method, - * always casting down its argument and then handing it off to a worker - * function which does the actual work. In all probabilty, the class Render - * is generic (Render= 0; --i) { + adouble[i] = d3; + adouble1[i] = d4; + d3 += (double) (random.nextInt(11) - 5); + d4 += (double) (random.nextInt(11) - 5); + } + + for (int k1 = 0; k1 < 4; ++k1) { + Random random1 = new XSTR(p_76986_1_.boltVertex); + + for (int j = 0; j < 3; ++j) { + int k = 7; + int l = 0; + + if (j > 0) { + k = 7 - j; + } + + if (j > 0) { + l = k - 2; + } + + double d5 = adouble[k] - d3; + double d6 = adouble1[k] - d4; + + for (int i1 = k; i1 >= l; --i1) { + double d7 = d5; + double d8 = d6; + + if (j == 0) { + d5 += (double) (random1.nextInt(11) - 5); + d6 += (double) (random1.nextInt(11) - 5); + } else { + d5 += (double) (random1.nextInt(31) - 15); + d6 += (double) (random1.nextInt(31) - 15); + } + + tessellator.startDrawing(5); + float f2 = 0.5F; + tessellator.setColorRGBA_F(0.9F * f2, 0.9F * f2, 1.0F * f2, 0.3F); + double d9 = 0.1D + (double) k1 * 0.2D; + + if (j == 0) { + d9 *= (double) i1 * 0.1D + 1.0D; + } + + double d10 = 0.1D + (double) k1 * 0.2D; + + if (j == 0) { + d10 *= (double) (i1 - 1) * 0.1D + 1.0D; + } + + for (int j1 = 0; j1 < 5; ++j1) { + double d11 = p_76986_2_ + 0.5D - d9; + double d12 = p_76986_6_ + 0.5D - d9; + + if (j1 == 1 || j1 == 2) { + d11 += d9 * 2.0D; + } + + if (j1 == 2 || j1 == 3) { + d12 += d9 * 2.0D; + } + + double d13 = p_76986_2_ + 0.5D - d10; + double d14 = p_76986_6_ + 0.5D - d10; + + if (j1 == 1 || j1 == 2) { + d13 += d10 * 2.0D; + } + + if (j1 == 2 || j1 == 3) { + d14 += d10 * 2.0D; + } + + tessellator.addVertex(d13 + d5, p_76986_4_ + (double) (i1 * 16), d14 + d6); + tessellator.addVertex(d11 + d7, p_76986_4_ + (double) ((i1 + 1) * 16), d12 + d8); + } + + tessellator.draw(); + } + } + } + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + /** + * Returns the location of an entity's texture. Doesn't seem to be called + * unless you call Render.bindEntityTexture. + */ + protected ResourceLocation getEntityTexture(EntityTeslaTowerLightning p_110775_1_) { + return null; + } + + /** + * Returns the location of an entity's texture. Doesn't seem to be called + * unless you call Render.bindEntityTexture. + */ + protected ResourceLocation getEntityTexture(Entity p_110775_1_) { + Logger.INFO("Render Plasma. 5"); + return this.getEntityTexture((EntityTeslaTowerLightning) p_110775_1_); + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, + * always casting down its argument and then handing it off to a worker + * function which does the actual work. In all probabilty, the class Render + * is generic (Render> 16 & 255) / 255.0F; float f3 = (i >> 8 & 255) / 255.0F; float f4 = (i & 255) / 255.0F; @@ -77,13 +75,11 @@ public class RenderPotionthrow extends Render * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ @Override - protected ResourceLocation getEntityTexture(Entity p_110775_1_) - { + protected ResourceLocation getEntityTexture(Entity p_110775_1_) { return TextureMap.locationItemsTexture; } - private void func_77026_a(Tessellator p_77026_1_, IIcon p_77026_2_) - { + private void func_77026_a(Tessellator p_77026_1_, IIcon p_77026_2_) { float f = p_77026_2_.getMinU(); float f1 = p_77026_2_.getMaxU(); float f2 = p_77026_2_.getMinV(); @@ -101,4 +97,4 @@ public class RenderPotionthrow extends Render p_77026_1_.addVertexWithUV(0.0F - f5, f4 - f6, 0.0D, f, f2); p_77026_1_.draw(); } -} \ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/core/client/renderer/RenderSickBlaze.java b/src/main/java/gtPlusPlus/core/client/renderer/RenderSickBlaze.java index e1e8360840..960451514d 100644 --- a/src/main/java/gtPlusPlus/core/client/renderer/RenderSickBlaze.java +++ b/src/main/java/gtPlusPlus/core/client/renderer/RenderSickBlaze.java @@ -2,27 +2,24 @@ package gtPlusPlus.core.client.renderer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.core.client.model.ModelSickBlaze; +import gtPlusPlus.core.entity.monster.EntitySickBlaze; +import gtPlusPlus.core.lib.CORE; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.ResourceLocation; -import gtPlusPlus.core.client.model.ModelSickBlaze; -import gtPlusPlus.core.entity.monster.EntitySickBlaze; -import gtPlusPlus.core.lib.CORE; - @SideOnly(Side.CLIENT) -public class RenderSickBlaze extends RenderLiving -{ - private static final ResourceLocation blazeTextures = new ResourceLocation(CORE.MODID+":"+"textures/entity/sickBlaze.png"); +public class RenderSickBlaze extends RenderLiving { + private static final ResourceLocation blazeTextures = + new ResourceLocation(CORE.MODID + ":" + "textures/entity/sickBlaze.png"); private int field_77068_a; - public RenderSickBlaze() - { + public RenderSickBlaze() { super(new ModelSickBlaze(), 0.5F); - this.field_77068_a = ((ModelSickBlaze)this.mainModel).func_78104_a(); + this.field_77068_a = ((ModelSickBlaze) this.mainModel).func_78104_a(); } /** @@ -31,12 +28,16 @@ public class RenderSickBlaze extends RenderLiving * (Render= 0.01D) { - float f3 = 13.0F; - float f4 = p_77043_1_.limbSwing - p_77043_1_.limbSwingAmount * (1.0F - p_77043_4_) + 6.0F; - float f5 = (Math.abs(f4 % f3 - f3 * 0.5F) - f3 * 0.25F) / (f3 * 0.25F); - GL11.glRotatef(6.5F * f5, 0.0F, 0.0F, 1.0F); - } - } - - protected void renderEquippedItems(EntityStaballoyConstruct p_77029_1_, float p_77029_2_) { - super.renderEquippedItems(p_77029_1_, p_77029_2_); - - if (p_77029_1_.getHoldRoseTick() != 0) { - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glPushMatrix(); - GL11.glRotatef(5.0F + 180.0F * this.staballoyGolemModel.ironGolemRightArm.rotateAngleX / (float) Math.PI, 1.0F, - 0.0F, 0.0F); - GL11.glTranslatef(-0.6875F, 1.25F, -0.9375F); - GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); - float f1 = 0.8F; - GL11.glScalef(f1, -f1, f1); - int i = p_77029_1_.getBrightnessForRender(p_77029_2_); - int j = i % 65536; - int k = i / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j / 1.0F, k / 1.0F); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.bindTexture(TextureMap.locationBlocksTexture); - this.field_147909_c.renderBlockAsItem(Blocks.red_flower, 0, 1.0F); - GL11.glPopMatrix(); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - } - } - - /** - * Actually renders the given argument. This is a synthetic bridge method, - * always casting down its argument and then handing it off to a worker - * function which does the actual work. In all probabilty, the class Render - * is generic (Render= 0.01D) { + float f3 = 13.0F; + float f4 = p_77043_1_.limbSwing - p_77043_1_.limbSwingAmount * (1.0F - p_77043_4_) + 6.0F; + float f5 = (Math.abs(f4 % f3 - f3 * 0.5F) - f3 * 0.25F) / (f3 * 0.25F); + GL11.glRotatef(6.5F * f5, 0.0F, 0.0F, 1.0F); + } + } + + protected void renderEquippedItems(EntityStaballoyConstruct p_77029_1_, float p_77029_2_) { + super.renderEquippedItems(p_77029_1_, p_77029_2_); + + if (p_77029_1_.getHoldRoseTick() != 0) { + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glPushMatrix(); + GL11.glRotatef( + 5.0F + 180.0F * this.staballoyGolemModel.ironGolemRightArm.rotateAngleX / (float) Math.PI, + 1.0F, + 0.0F, + 0.0F); + GL11.glTranslatef(-0.6875F, 1.25F, -0.9375F); + GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); + float f1 = 0.8F; + GL11.glScalef(f1, -f1, f1); + int i = p_77029_1_.getBrightnessForRender(p_77029_2_); + int j = i % 65536; + int k = i / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j / 1.0F, k / 1.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.bindTexture(TextureMap.locationBlocksTexture); + this.field_147909_c.renderBlockAsItem(Blocks.red_flower, 0, 1.0F); + GL11.glPopMatrix(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + } + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, + * always casting down its argument and then handing it off to a worker + * function which does the actual work. In all probabilty, the class Render + * is generic (Render 0) { - this.motionX *= 0.02D; - this.motionY *= 0.02D; - this.motionZ *= 0.02D; - this.setParticleTextureIndex(113); - } else { - this.setParticleTextureIndex(112); - } - this.moveEntity(this.motionX, this.motionY, this.motionZ); - this.motionX *= 0.9800000190734863D; - this.motionY *= 0.9800000190734863D; - this.motionZ *= 0.9800000190734863D; - - if (this.particleMaxAge-- <= 0) { - this.setDead(); - } - if (this.onGround) { - this.setParticleTextureIndex(114); - this.motionX *= 0.699999988079071D; - this.motionZ *= 0.699999988079071D; - } - if (this.particleGravity > 0) { - Material material = this.worldObj.getBlock(MathHelper.floor(this.posX), MathHelper.floor(this.posY), MathHelper.floor(this.posZ)).getMaterial(); - - if (material.isLiquid() || material.isSolid()) { - double d0 = MathHelper.floor(this.posY) - + 1 - - BlockLiquid.getLiquidHeightPercent(this.worldObj.getBlockMetadata(MathHelper.floor(this.posX), MathHelper.floor(this.posY), - MathHelper.floor(this.posZ))); - if (this.posY < d0) { - this.setDead(); - } - } - } else { - Material material = this.worldObj.getBlock(MathHelper.ceil(this.posX), MathHelper.ceil(this.posY), MathHelper.ceil(this.posZ)).getMaterial(); - - if (material.isLiquid() || material.isSolid()) { - double d0 = MathHelper.ceil(this.posY) - + 1 - - BlockLiquid.getLiquidHeightPercent(this.worldObj.getBlockMetadata(MathHelper.ceil(this.posX), MathHelper.ceil(this.posY), - MathHelper.ceil(this.posZ))); - if (this.posY > d0) { - this.setDead(); - } - } - } - } - + private int bobTimer; + + public EntityDropParticleFX( + World world, double x, double y, double z, float particleRed, float particleGreen, float particleBlue) { + + this(world, x, y, z, particleRed, particleGreen, particleBlue, -1); + } + + public EntityDropParticleFX( + World world, + double x, + double y, + double z, + float particleRed, + float particleGreen, + float particleBlue, + int gravityMod) { + + super(world, x, y, z, 0.0D, 0.0D, 0.0D); + this.motionX = this.motionY = this.motionZ = 0.0D; + + this.particleRed = particleRed; + this.particleGreen = particleGreen; + this.particleBlue = particleBlue; + + this.setParticleTextureIndex(113); + this.setSize(0.01F, 0.01F); + this.particleGravity = -0.06F * gravityMod; + this.bobTimer = 40; + this.particleMaxAge = (int) (48.0D / (Math.random() * 0.8D + 0.2D)); + this.motionX = this.motionY = this.motionZ = 0.0D; + } + + @Override + public void onUpdate() { + + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + this.motionY -= this.particleGravity; + + if (this.bobTimer-- > 0) { + this.motionX *= 0.02D; + this.motionY *= 0.02D; + this.motionZ *= 0.02D; + this.setParticleTextureIndex(113); + } else { + this.setParticleTextureIndex(112); + } + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.9800000190734863D; + this.motionY *= 0.9800000190734863D; + this.motionZ *= 0.9800000190734863D; + + if (this.particleMaxAge-- <= 0) { + this.setDead(); + } + if (this.onGround) { + this.setParticleTextureIndex(114); + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + } + if (this.particleGravity > 0) { + Material material = this.worldObj + .getBlock(MathHelper.floor(this.posX), MathHelper.floor(this.posY), MathHelper.floor(this.posZ)) + .getMaterial(); + + if (material.isLiquid() || material.isSolid()) { + double d0 = MathHelper.floor(this.posY) + + 1 + - BlockLiquid.getLiquidHeightPercent(this.worldObj.getBlockMetadata( + MathHelper.floor(this.posX), MathHelper.floor(this.posY), MathHelper.floor(this.posZ))); + if (this.posY < d0) { + this.setDead(); + } + } + } else { + Material material = this.worldObj + .getBlock(MathHelper.ceil(this.posX), MathHelper.ceil(this.posY), MathHelper.ceil(this.posZ)) + .getMaterial(); + + if (material.isLiquid() || material.isSolid()) { + double d0 = MathHelper.ceil(this.posY) + + 1 + - BlockLiquid.getLiquidHeightPercent(this.worldObj.getBlockMetadata( + MathHelper.ceil(this.posX), MathHelper.ceil(this.posY), MathHelper.ceil(this.posZ))); + if (this.posY > d0) { + this.setDead(); + } + } + } + } } diff --git a/src/main/java/gtPlusPlus/core/client/renderer/tabula/RenderTabulaBase.java b/src/main/java/gtPlusPlus/core/client/renderer/tabula/RenderTabulaBase.java index b4f64f9b35..ad2d90f482 100644 --- a/src/main/java/gtPlusPlus/core/client/renderer/tabula/RenderTabulaBase.java +++ b/src/main/java/gtPlusPlus/core/client/renderer/tabula/RenderTabulaBase.java @@ -3,7 +3,6 @@ package gtPlusPlus.core.client.renderer.tabula; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.client.model.tabula.ModelTabulaBase; import gtPlusPlus.core.lib.CORE; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; @@ -13,34 +12,36 @@ import net.minecraft.util.ResourceLocation; @SideOnly(Side.CLIENT) public class RenderTabulaBase extends TileEntitySpecialRenderer { - private final ModelTabulaBase mModel; - private final ResourceLocation mTexture; - private final Class mTileClass; - - public final int mRenderID; - public final RenderTabulaBase mInstance; + private final ModelTabulaBase mModel; + private final ResourceLocation mTexture; + private final Class mTileClass; - public RenderTabulaBase(ModelTabulaBase aModel, String aTexturePath, Class aTileClass) { - mModel = aModel; - mTexture = new ResourceLocation(CORE.MODID, aTexturePath); - mTileClass = aTileClass; - this.mRenderID = RenderingRegistry.getNextAvailableRenderId(); - mInstance = this; - } + public final int mRenderID; + public final RenderTabulaBase mInstance; - public void renderTileEntityAt(Object aTile, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) { - if (mTileClass.isInstance(aTile)) { - //Logger.INFO("Rendering EggBox"); - this.bindTexture(mTexture); - mModel.renderAll(); - } - } + public RenderTabulaBase(ModelTabulaBase aModel, String aTexturePath, Class aTileClass) { + mModel = aModel; + mTexture = new ResourceLocation(CORE.MODID, aTexturePath); + mTileClass = aTileClass; + this.mRenderID = RenderingRegistry.getNextAvailableRenderId(); + mInstance = this; + } - public void renderTileEntityAt(TileEntity aTile, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) { - if (mTileClass != null && aTile != null) { - if (mTileClass.isInstance(aTile)) { - this.renderTileEntityAt((Object) aTile, p_147500_2_, p_147500_4_, p_147500_6_, p_147500_8_); - } - } - } -} \ No newline at end of file + public void renderTileEntityAt( + Object aTile, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) { + if (mTileClass.isInstance(aTile)) { + // Logger.INFO("Rendering EggBox"); + this.bindTexture(mTexture); + mModel.renderAll(); + } + } + + public void renderTileEntityAt( + TileEntity aTile, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) { + if (mTileClass != null && aTile != null) { + if (mTileClass.isInstance(aTile)) { + this.renderTileEntityAt((Object) aTile, p_147500_2_, p_147500_4_, p_147500_6_, p_147500_8_); + } + } + } +} diff --git a/src/main/java/gtPlusPlus/core/commands/CommandDebugChunks.java b/src/main/java/gtPlusPlus/core/commands/CommandDebugChunks.java index 8e86bcdcd6..f86476b91a 100644 --- a/src/main/java/gtPlusPlus/core/commands/CommandDebugChunks.java +++ b/src/main/java/gtPlusPlus/core/commands/CommandDebugChunks.java @@ -1,152 +1,138 @@ package gtPlusPlus.core.commands; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.preloader.ChunkDebugger; +import gtPlusPlus.preloader.asm.AsmConfig; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; - import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.data.Pair; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.preloader.ChunkDebugger; -import gtPlusPlus.preloader.asm.AsmConfig; - - -public class CommandDebugChunks implements ICommand -{ - private final List aliases; - - protected String fullEntityName; - protected Entity conjuredEntity; - - public CommandDebugChunks(){ - this.aliases = new ArrayList<>(); - aliases.add("debugchunks"); - aliases.add("DC"); - } - - @Override - public int compareTo(final Object o){ - return 0; - - } - - @Override - public String getCommandName(){ - return "DebugChunks"; - - } - - @Override - public String getCommandUsage(final ICommandSender var1){ - return "/DebugChunks"; - - } - - @Override - public List getCommandAliases(){ - return this.aliases; - - } - - @Override - public void processCommand(final ICommandSender S, final String[] argString){ - Logger.INFO("Debug Command"); - - final World W = S.getEntityWorld(); - final EntityPlayer P = CommandUtils.getPlayer(S); - - if (!AsmConfig.enableChunkDebugging) { - PlayerUtils.messagePlayer(P, "Chunk Debugging is disabled."); - return; - } - - - Map aTicketCounter = new LinkedHashMap(); - for (Pair f : ChunkDebugger.mChunkTicketsMap.values()) { - String aMod = f.getKey(); - String aDim = f.getValue(); - if (aMod != null) { - if (aTicketCounter.containsKey(aMod)) { - int aModTicketCount = aTicketCounter.get(aMod); - aModTicketCount++; - aTicketCounter.put(aMod, aModTicketCount); - } - else { - aTicketCounter.put(aMod, 1); - } - } - } - if (aTicketCounter.isEmpty()) { - PlayerUtils.messagePlayer(P, "No forced chunk tickets active."); - } - for (String x : aTicketCounter.keySet()) { - PlayerUtils.messagePlayer(P, x+" has "+aTicketCounter.get(x)+" tickets active."); - } - - - Map aChunkCounter = new LinkedHashMap(); - for (Pair f : ChunkDebugger.mChunksLoadedByModsMap.values()) { - String aMod = f.getKey(); - String aDim = f.getValue(); - if (aMod == null) { - aMod = "Bad ModId"; - } - - if (aMod != null) { - //PlayerUtils.messagePlayer(P, aMod+" has "+aDim+" active."); - if (aChunkCounter.containsKey(aMod)) { - int aModTicketCount = aChunkCounter.get(aMod); - aModTicketCount = aModTicketCount + 1; - aChunkCounter.put(aMod, aModTicketCount); - Logger.INFO("Counting +1 for "+aMod+", total of "+aModTicketCount); - } - else { - aChunkCounter.put(aMod, 1); - Logger.INFO("Counting +1 for "+aMod); - } - } - } - if (aChunkCounter.isEmpty()) { - PlayerUtils.messagePlayer(P, "No chunks force loaded."); - } - for (String x : aChunkCounter.keySet()) { - PlayerUtils.messagePlayer(P, x+" has "+aChunkCounter.get(x)+" chunks active."); - } - - } - - @Override - public boolean canCommandSenderUseCommand(final ICommandSender var1){ - final EntityPlayer P = CommandUtils.getPlayer(var1); - if (P == null){ - return false; - } - if (PlayerUtils.isPlayerOP(P)) { - return true; - } - return false; - } - - @Override - public List addTabCompletionOptions(final ICommandSender var1, final String[] var2){ - return new ArrayList<>(); - } - - @Override - public boolean isUsernameIndex(final String[] var1, final int var2){ - // TODO Auto-generated method stub - return false; - } - - public boolean playerUsesCommand(final World W, final EntityPlayer P, final int cost){ - return true; - } - -} \ No newline at end of file +public class CommandDebugChunks implements ICommand { + private final List aliases; + + protected String fullEntityName; + protected Entity conjuredEntity; + + public CommandDebugChunks() { + this.aliases = new ArrayList<>(); + aliases.add("debugchunks"); + aliases.add("DC"); + } + + @Override + public int compareTo(final Object o) { + return 0; + } + + @Override + public String getCommandName() { + return "DebugChunks"; + } + + @Override + public String getCommandUsage(final ICommandSender var1) { + return "/DebugChunks"; + } + + @Override + public List getCommandAliases() { + return this.aliases; + } + + @Override + public void processCommand(final ICommandSender S, final String[] argString) { + Logger.INFO("Debug Command"); + + final World W = S.getEntityWorld(); + final EntityPlayer P = CommandUtils.getPlayer(S); + + if (!AsmConfig.enableChunkDebugging) { + PlayerUtils.messagePlayer(P, "Chunk Debugging is disabled."); + return; + } + + Map aTicketCounter = new LinkedHashMap(); + for (Pair f : ChunkDebugger.mChunkTicketsMap.values()) { + String aMod = f.getKey(); + String aDim = f.getValue(); + if (aMod != null) { + if (aTicketCounter.containsKey(aMod)) { + int aModTicketCount = aTicketCounter.get(aMod); + aModTicketCount++; + aTicketCounter.put(aMod, aModTicketCount); + } else { + aTicketCounter.put(aMod, 1); + } + } + } + if (aTicketCounter.isEmpty()) { + PlayerUtils.messagePlayer(P, "No forced chunk tickets active."); + } + for (String x : aTicketCounter.keySet()) { + PlayerUtils.messagePlayer(P, x + " has " + aTicketCounter.get(x) + " tickets active."); + } + + Map aChunkCounter = new LinkedHashMap(); + for (Pair f : ChunkDebugger.mChunksLoadedByModsMap.values()) { + String aMod = f.getKey(); + String aDim = f.getValue(); + if (aMod == null) { + aMod = "Bad ModId"; + } + + if (aMod != null) { + // PlayerUtils.messagePlayer(P, aMod+" has "+aDim+" active."); + if (aChunkCounter.containsKey(aMod)) { + int aModTicketCount = aChunkCounter.get(aMod); + aModTicketCount = aModTicketCount + 1; + aChunkCounter.put(aMod, aModTicketCount); + Logger.INFO("Counting +1 for " + aMod + ", total of " + aModTicketCount); + } else { + aChunkCounter.put(aMod, 1); + Logger.INFO("Counting +1 for " + aMod); + } + } + } + if (aChunkCounter.isEmpty()) { + PlayerUtils.messagePlayer(P, "No chunks force loaded."); + } + for (String x : aChunkCounter.keySet()) { + PlayerUtils.messagePlayer(P, x + " has " + aChunkCounter.get(x) + " chunks active."); + } + } + + @Override + public boolean canCommandSenderUseCommand(final ICommandSender var1) { + final EntityPlayer P = CommandUtils.getPlayer(var1); + if (P == null) { + return false; + } + if (PlayerUtils.isPlayerOP(P)) { + return true; + } + return false; + } + + @Override + public List addTabCompletionOptions(final ICommandSender var1, final String[] var2) { + return new ArrayList<>(); + } + + @Override + public boolean isUsernameIndex(final String[] var1, final int var2) { + // TODO Auto-generated method stub + return false; + } + + public boolean playerUsesCommand(final World W, final EntityPlayer P, final int cost) { + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/commands/CommandEnableDebugWhileRunning.java b/src/main/java/gtPlusPlus/core/commands/CommandEnableDebugWhileRunning.java index 4f5615b60a..43b9de8c58 100644 --- a/src/main/java/gtPlusPlus/core/commands/CommandEnableDebugWhileRunning.java +++ b/src/main/java/gtPlusPlus/core/commands/CommandEnableDebugWhileRunning.java @@ -1,13 +1,8 @@ package gtPlusPlus.core.commands; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - import cpw.mods.fml.common.registry.GameRegistry; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; -import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; @@ -16,6 +11,9 @@ import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.preloader.CORE_Preloader; import gtPlusPlus.preloader.asm.AsmConfig; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; @@ -27,245 +25,238 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; +public class CommandEnableDebugWhileRunning implements ICommand { + private final List aliases; -public class CommandEnableDebugWhileRunning implements ICommand -{ - private final List aliases; - - public CommandEnableDebugWhileRunning(){ - this.aliases = new ArrayList<>(); - this.aliases.add("gtplusplus"); - } - - @Override - public int compareTo(final Object o){ - if (o instanceof Comparable) { - @SuppressWarnings("unchecked") - Comparable a = (Comparable) o; - if (a.equals(this)) { - return 0; - } - else { - return -1; - } - } - return -1; - } - - @Override - public String getCommandName(){ - return "gtpp"; - - } + public CommandEnableDebugWhileRunning() { + this.aliases = new ArrayList<>(); + this.aliases.add("gtplusplus"); + } + @Override + public int compareTo(final Object o) { + if (o instanceof Comparable) { + @SuppressWarnings("unchecked") + Comparable a = (Comparable) o; + if (a.equals(this)) { + return 0; + } else { + return -1; + } + } + return -1; + } - // Use '/gtpp' along with 'logging' or 'debug' to toggle Debug mode and Logging. - // Using nothing after the command toggles both to their opposite states respectively. - @Override - public String getCommandUsage(final ICommandSender var1){ - return "/gtpp ?"; - } + @Override + public String getCommandName() { + return "gtpp"; + } - @Override - public List getCommandAliases(){ - return this.aliases; - } + // Use '/gtpp' along with 'logging' or 'debug' to toggle Debug mode and Logging. + // Using nothing after the command toggles both to their opposite states respectively. + @Override + public String getCommandUsage(final ICommandSender var1) { + return "/gtpp ?"; + } - @Override - public void processCommand(final ICommandSender S, final String[] argString){ - int aMaxArgumentsAllowed = 2; + @Override + public List getCommandAliases() { + return this.aliases; + } - if ((argString == null || argString.length == 0 || argString.length > aMaxArgumentsAllowed) || argString[0].toLowerCase().equals("?")) { - Logger.INFO("Listing commands and their uses."); - final EntityPlayer P = CommandUtils.getPlayer(S); - AsmConfig.disableAllLogging = Utils.invertBoolean(AsmConfig.disableAllLogging); - PlayerUtils.messagePlayer(P, "The following are valid args for the '/gtpp' command:"); - PlayerUtils.messagePlayer(P, "? - This help command."); - PlayerUtils.messagePlayer(P, "logging - Toggles ALL GT++ logging for current session."); - PlayerUtils.messagePlayer(P, "hand - Lists information about held item."); - PlayerUtils.messagePlayer(P, "fuid xxx - Tries to find the fluid in the FluidRegistry."); - PlayerUtils.messagePlayer(P, "debug - Toggles GT++ Debug Mode. Only use when advised, may break everything. (OP)"); - } - else if (argString[0].toLowerCase().equals("debug")) { - Logger.INFO("Toggling Debug Mode."); - final EntityPlayer P = CommandUtils.getPlayer(S); - if (PlayerUtils.isPlayerOP(P)) { - CORE_Preloader.DEBUG_MODE = Utils.invertBoolean(CORE_Preloader.DEBUG_MODE); - PlayerUtils.messagePlayer(P, "Toggled GT++ Debug Mode - Enabled: "+CORE_Preloader.DEBUG_MODE); - } - } - else if (argString[0].toLowerCase().equals("logging")) { - Logger.INFO("Toggling Logging."); - final EntityPlayer P = CommandUtils.getPlayer(S); - AsmConfig.disableAllLogging = Utils.invertBoolean(AsmConfig.disableAllLogging); - PlayerUtils.messagePlayer(P, "Toggled GT++ Logging - Enabled: "+(!AsmConfig.disableAllLogging)); - } - /* else if (argString[0].toLowerCase().equals("test")) { - ItemStack mSemiFluidgen = ItemUtils.simpleMetaStack("IC2:blockGenerator", 7, 1); - final EntityPlayer P = CommandUtils.getPlayer(S); - if(mSemiFluidgen != null) { - PlayerUtils.messagePlayer(P, ItemUtils.getItemName(mSemiFluidgen)); - } - }*/ + @Override + public void processCommand(final ICommandSender S, final String[] argString) { + int aMaxArgumentsAllowed = 2; - else if (argString[0].toLowerCase().equals("inv")) { - final EntityPlayer P = CommandUtils.getPlayer(S); - if (P != null && !P.worldObj.isRemote) { - ItemStack[] aInv = P.inventory.mainInventory; - for (ItemStack aItem : aInv) { - if (aItem != null) { - String aModID = GameRegistry.findUniqueIdentifierFor(aItem.getItem()).modId; - String aRegistryName = GameRegistry.findUniqueIdentifierFor(aItem.getItem()).name; - Logger.INFO(aModID+":"+aRegistryName+":"+aItem.getItemDamage()+" | "+aItem.getDisplayName()); - } - } - PlayerUtils.messagePlayer(P, "Dumped Inventory."); - } - } - else if (argString[0].toLowerCase().equals("hand")) { - final EntityPlayer P = CommandUtils.getPlayer(S); - if (P != null) { - ItemStack aHeldItem = PlayerUtils.getItemStackInPlayersHand(P); - if (aHeldItem != null) { - String aItemDisplayName = ItemUtils.getItemName(aHeldItem); - String aItemUnlocalName = ItemUtils.getUnlocalizedItemName(aHeldItem); - String aNbtString = tryIterateNBTData(aHeldItem); - AutoMap aOreDictNames = new AutoMap(); + if ((argString == null || argString.length == 0 || argString.length > aMaxArgumentsAllowed) + || argString[0].toLowerCase().equals("?")) { + Logger.INFO("Listing commands and their uses."); + final EntityPlayer P = CommandUtils.getPlayer(S); + AsmConfig.disableAllLogging = Utils.invertBoolean(AsmConfig.disableAllLogging); + PlayerUtils.messagePlayer(P, "The following are valid args for the '/gtpp' command:"); + PlayerUtils.messagePlayer(P, "? - This help command."); + PlayerUtils.messagePlayer(P, "logging - Toggles ALL GT++ logging for current session."); + PlayerUtils.messagePlayer(P, "hand - Lists information about held item."); + PlayerUtils.messagePlayer(P, "fuid xxx - Tries to find the fluid in the FluidRegistry."); + PlayerUtils.messagePlayer( + P, "debug - Toggles GT++ Debug Mode. Only use when advised, may break everything. (OP)"); + } else if (argString[0].toLowerCase().equals("debug")) { + Logger.INFO("Toggling Debug Mode."); + final EntityPlayer P = CommandUtils.getPlayer(S); + if (PlayerUtils.isPlayerOP(P)) { + CORE_Preloader.DEBUG_MODE = Utils.invertBoolean(CORE_Preloader.DEBUG_MODE); + PlayerUtils.messagePlayer(P, "Toggled GT++ Debug Mode - Enabled: " + CORE_Preloader.DEBUG_MODE); + } + } else if (argString[0].toLowerCase().equals("logging")) { + Logger.INFO("Toggling Logging."); + final EntityPlayer P = CommandUtils.getPlayer(S); + AsmConfig.disableAllLogging = Utils.invertBoolean(AsmConfig.disableAllLogging); + PlayerUtils.messagePlayer(P, "Toggled GT++ Logging - Enabled: " + (!AsmConfig.disableAllLogging)); + } + /* else if (argString[0].toLowerCase().equals("test")) { + ItemStack mSemiFluidgen = ItemUtils.simpleMetaStack("IC2:blockGenerator", 7, 1); + final EntityPlayer P = CommandUtils.getPlayer(S); + if(mSemiFluidgen != null) { + PlayerUtils.messagePlayer(P, ItemUtils.getItemName(mSemiFluidgen)); + } + }*/ - int[] aOreIDs = OreDictionary.getOreIDs(aHeldItem); - for (int id : aOreIDs) { - String aOreNameFromID = OreDictionary.getOreName(id); - if (aOreNameFromID != null && aOreNameFromID.length() > 0 && !aOreNameFromID.equals("Unknown")) { - aOreDictNames.add(aOreNameFromID); - } - } + else if (argString[0].toLowerCase().equals("inv")) { + final EntityPlayer P = CommandUtils.getPlayer(S); + if (P != null && !P.worldObj.isRemote) { + ItemStack[] aInv = P.inventory.mainInventory; + for (ItemStack aItem : aInv) { + if (aItem != null) { + String aModID = GameRegistry.findUniqueIdentifierFor(aItem.getItem()).modId; + String aRegistryName = GameRegistry.findUniqueIdentifierFor(aItem.getItem()).name; + Logger.INFO(aModID + ":" + aRegistryName + ":" + aItem.getItemDamage() + " | " + + aItem.getDisplayName()); + } + } + PlayerUtils.messagePlayer(P, "Dumped Inventory."); + } + } else if (argString[0].toLowerCase().equals("hand")) { + final EntityPlayer P = CommandUtils.getPlayer(S); + if (P != null) { + ItemStack aHeldItem = PlayerUtils.getItemStackInPlayersHand(P); + if (aHeldItem != null) { + String aItemDisplayName = ItemUtils.getItemName(aHeldItem); + String aItemUnlocalName = ItemUtils.getUnlocalizedItemName(aHeldItem); + String aNbtString = tryIterateNBTData(aHeldItem); + AutoMap aOreDictNames = new AutoMap(); - String aOreDictData = ""; - if (!aOreDictNames.isEmpty()) { - for (String tag : aOreDictNames) { - aOreDictData += (tag+", "); - } - if (aOreDictData.endsWith(", ")) { - aOreDictData = aOreDictData.substring(0, aOreDictData.length()-2); - } - } - - AutoMap aFluidContainerData = new AutoMap(); - FluidStack aHeldItemFluid = FluidContainerRegistry.getFluidForFilledItem(aHeldItem); - if (aHeldItemFluid != null) { - aFluidContainerData.put("FluidStack Unlocal Name: "+aHeldItemFluid.getUnlocalizedName()); - aFluidContainerData.put("FluidStack Local Name: "+aHeldItemFluid.getLocalizedName()); - aFluidContainerData.put("Fluid Unlocal Name: "+aHeldItemFluid.getFluid().getUnlocalizedName()); - aFluidContainerData.put("Fluid Local Name: "+aHeldItemFluid.getFluid().getLocalizedName()); - aFluidContainerData.put("Fluid Name: "+aHeldItemFluid.getFluid().getName()); - } + int[] aOreIDs = OreDictionary.getOreIDs(aHeldItem); + for (int id : aOreIDs) { + String aOreNameFromID = OreDictionary.getOreName(id); + if (aOreNameFromID != null + && aOreNameFromID.length() > 0 + && !aOreNameFromID.equals("Unknown")) { + aOreDictNames.add(aOreNameFromID); + } + } - PlayerUtils.messagePlayer(P, "["+aItemUnlocalName+"]"+"["+aItemDisplayName+"] "); - if (aFluidContainerData.size() > 0) { - for (String s : aFluidContainerData) { - PlayerUtils.messagePlayer(P, ""+s); - } - } - if (!aOreDictNames.isEmpty()) { - PlayerUtils.messagePlayer(P, ""+aOreDictData); - } - if (aNbtString.length() > 0) { - PlayerUtils.messagePlayer(P, ""+aNbtString); - } - } - else { - PlayerUtils.messagePlayer(P, "No item held."); - } - } - } - else if (argString[0].toLowerCase().equals("fluid")) { - if (argString.length > 1 && argString[1] != null && argString[1].length() > 0) { - final EntityPlayer P = CommandUtils.getPlayer(S); - FluidStack aFluid = FluidUtils.getWildcardFluidStack(argString[1], 1); - if (P != null && aFluid != null) { - PlayerUtils.messagePlayer(P, "Found fluid stack: "+FluidRegistry.getFluidName(aFluid)); - } - else if (P != null && aFluid == null) { - PlayerUtils.messagePlayer(P, "Could not find any fluids."); - } - } - } - else if (argString[0].toLowerCase().equals("item")) { - if (argString.length > 1 && argString[1] != null && argString[1].length() > 0) { - final EntityPlayer P = CommandUtils.getPlayer(S); - ItemStack aTest = ItemUtils.getItemStackFromFQRN(argString[1], 1); - if (P != null && aTest != null) { - PlayerUtils.messagePlayer(P, "Found fluid stack: "+ItemUtils.getItemName(aTest)); - } - else if (P != null && aTest == null) { - PlayerUtils.messagePlayer(P, "Could not find valid item."); - } - } - } - else { - final EntityPlayer P = CommandUtils.getPlayer(S); - PlayerUtils.messagePlayer(P, "Invalid command, use '?' as an argument for help.'"); - } + String aOreDictData = ""; + if (!aOreDictNames.isEmpty()) { + for (String tag : aOreDictNames) { + aOreDictData += (tag + ", "); + } + if (aOreDictData.endsWith(", ")) { + aOreDictData = aOreDictData.substring(0, aOreDictData.length() - 2); + } + } - } + AutoMap aFluidContainerData = new AutoMap(); + FluidStack aHeldItemFluid = FluidContainerRegistry.getFluidForFilledItem(aHeldItem); + if (aHeldItemFluid != null) { + aFluidContainerData.put("FluidStack Unlocal Name: " + aHeldItemFluid.getUnlocalizedName()); + aFluidContainerData.put("FluidStack Local Name: " + aHeldItemFluid.getLocalizedName()); + aFluidContainerData.put("Fluid Unlocal Name: " + + aHeldItemFluid.getFluid().getUnlocalizedName()); + aFluidContainerData.put( + "Fluid Local Name: " + aHeldItemFluid.getFluid().getLocalizedName()); + aFluidContainerData.put( + "Fluid Name: " + aHeldItemFluid.getFluid().getName()); + } - @Override - public boolean canCommandSenderUseCommand(final ICommandSender var1){ - if (var1 == null || CommandUtils.getPlayer(var1) == null) { - return false; - } - return true; - } + PlayerUtils.messagePlayer(P, "[" + aItemUnlocalName + "]" + "[" + aItemDisplayName + "] "); + if (aFluidContainerData.size() > 0) { + for (String s : aFluidContainerData) { + PlayerUtils.messagePlayer(P, "" + s); + } + } + if (!aOreDictNames.isEmpty()) { + PlayerUtils.messagePlayer(P, "" + aOreDictData); + } + if (aNbtString.length() > 0) { + PlayerUtils.messagePlayer(P, "" + aNbtString); + } + } else { + PlayerUtils.messagePlayer(P, "No item held."); + } + } + } else if (argString[0].toLowerCase().equals("fluid")) { + if (argString.length > 1 && argString[1] != null && argString[1].length() > 0) { + final EntityPlayer P = CommandUtils.getPlayer(S); + FluidStack aFluid = FluidUtils.getWildcardFluidStack(argString[1], 1); + if (P != null && aFluid != null) { + PlayerUtils.messagePlayer(P, "Found fluid stack: " + FluidRegistry.getFluidName(aFluid)); + } else if (P != null && aFluid == null) { + PlayerUtils.messagePlayer(P, "Could not find any fluids."); + } + } + } else if (argString[0].toLowerCase().equals("item")) { + if (argString.length > 1 && argString[1] != null && argString[1].length() > 0) { + final EntityPlayer P = CommandUtils.getPlayer(S); + ItemStack aTest = ItemUtils.getItemStackFromFQRN(argString[1], 1); + if (P != null && aTest != null) { + PlayerUtils.messagePlayer(P, "Found fluid stack: " + ItemUtils.getItemName(aTest)); + } else if (P != null && aTest == null) { + PlayerUtils.messagePlayer(P, "Could not find valid item."); + } + } + } else { + final EntityPlayer P = CommandUtils.getPlayer(S); + PlayerUtils.messagePlayer(P, "Invalid command, use '?' as an argument for help.'"); + } + } - @Override - public List addTabCompletionOptions(final ICommandSender var1, final String[] var2){ - ArrayList aTabCompletes = new ArrayList(); - aTabCompletes.add("?"); - aTabCompletes.add("logging"); - aTabCompletes.add("debug"); - aTabCompletes.add("hand"); - aTabCompletes.add("fluid"); - return aTabCompletes; - } + @Override + public boolean canCommandSenderUseCommand(final ICommandSender var1) { + if (var1 == null || CommandUtils.getPlayer(var1) == null) { + return false; + } + return true; + } - @Override - public boolean isUsernameIndex(final String[] var1, final int var2){ - // TODO Auto-generated method stub - return false; - } + @Override + public List addTabCompletionOptions(final ICommandSender var1, final String[] var2) { + ArrayList aTabCompletes = new ArrayList(); + aTabCompletes.add("?"); + aTabCompletes.add("logging"); + aTabCompletes.add("debug"); + aTabCompletes.add("hand"); + aTabCompletes.add("fluid"); + return aTabCompletes; + } - public boolean playerUsesCommand(final World W, final EntityPlayer P, final int cost){ - return true; - } + @Override + public boolean isUsernameIndex(final String[] var1, final int var2) { + // TODO Auto-generated method stub + return false; + } - public static String tryIterateNBTData(ItemStack aStack) { - try { - AutoMap aItemDataTags = new AutoMap(); - NBTTagCompound aNBT = NBTUtils.getNBT(aStack); - if (aNBT != null) { - if (!aNBT.hasNoTags()) { - Map mInternalMap = ReflectionUtils.getField(aNBT, "tagMap"); - if (mInternalMap != null) { - for (Map.Entry e : mInternalMap.entrySet()) { - aItemDataTags.add(e.getKey().toString()+":"+e.getValue()); - } - int a = 0; - String data = ""; - for (String tag : aItemDataTags) { - data += (tag+", "); - } - if (data.endsWith(", ")) { - data = data.substring(0, data.length()-2); - } - return data; - } else { - Logger.INFO("Data map reflected from NBTTagCompound was not valid."); - return "Bad NBT"; - } - } - } - } catch (Throwable t) {} - return ""; - } + public boolean playerUsesCommand(final World W, final EntityPlayer P, final int cost) { + return true; + } -} \ No newline at end of file + public static String tryIterateNBTData(ItemStack aStack) { + try { + AutoMap aItemDataTags = new AutoMap(); + NBTTagCompound aNBT = NBTUtils.getNBT(aStack); + if (aNBT != null) { + if (!aNBT.hasNoTags()) { + Map mInternalMap = ReflectionUtils.getField(aNBT, "tagMap"); + if (mInternalMap != null) { + for (Map.Entry e : mInternalMap.entrySet()) { + aItemDataTags.add(e.getKey().toString() + ":" + e.getValue()); + } + int a = 0; + String data = ""; + for (String tag : aItemDataTags) { + data += (tag + ", "); + } + if (data.endsWith(", ")) { + data = data.substring(0, data.length() - 2); + } + return data; + } else { + Logger.INFO("Data map reflected from NBTTagCompound was not valid."); + return "Bad NBT"; + } + } + } + } catch (Throwable t) { + } + return ""; + } +} diff --git a/src/main/java/gtPlusPlus/core/commands/CommandMath.java b/src/main/java/gtPlusPlus/core/commands/CommandMath.java index 5ccfb3397f..b26f93c56a 100644 --- a/src/main/java/gtPlusPlus/core/commands/CommandMath.java +++ b/src/main/java/gtPlusPlus/core/commands/CommandMath.java @@ -1,100 +1,86 @@ package gtPlusPlus.core.commands; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.MiningUtils; import java.util.ArrayList; -import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; - import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.data.Pair; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.MiningUtils; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.preloader.ChunkDebugger; - - -public class CommandMath implements ICommand -{ - private final List aliases; - - protected String fullEntityName; - protected Entity conjuredEntity; - - public CommandMath(){ - this.aliases = new ArrayList<>(); - //this.aliases.add("hometele"); - //this.aliases.add("warphome"); - } - - @Override - public int compareTo(final Object o){ - return 0; - - } - - @Override - public String getCommandName(){ - return "alkalus"; - - } - - @Override - public String getCommandUsage(final ICommandSender var1){ - return "/alkalus [Dev Command]"; - - } - - @Override - public List getCommandAliases(){ - return this.aliases; - - } - - @Override - public void processCommand(final ICommandSender S, final String[] argString){ - Logger.INFO("Debug Command"); - final World W = S.getEntityWorld(); - final EntityPlayer P = CommandUtils.getPlayer(S); - if (P.getDisplayName().equalsIgnoreCase("draknyte1")) { - Logger.INFO("[Bedrock Miner] OreType Scan"); - MiningUtils.iterateAllOreTypes(); - } - - } - - @Override - public boolean canCommandSenderUseCommand(final ICommandSender var1){ - final EntityPlayer P = CommandUtils.getPlayer(var1); - if (P == null){ - return false; - } - if (P.getDisplayName().toLowerCase().equals("draknyte1") || P.getCommandSenderName().toLowerCase().equals("draknyte1") || CORE.DEVENV) { - return true; - } - return false; - } - - @Override - public List addTabCompletionOptions(final ICommandSender var1, final String[] var2){ - return null; - } - - @Override - public boolean isUsernameIndex(final String[] var1, final int var2){ - // TODO Auto-generated method stub - return false; - } - - public boolean playerUsesCommand(final World W, final EntityPlayer P, final int cost){ - - - return true; - } - -} \ No newline at end of file +public class CommandMath implements ICommand { + private final List aliases; + + protected String fullEntityName; + protected Entity conjuredEntity; + + public CommandMath() { + this.aliases = new ArrayList<>(); + // this.aliases.add("hometele"); + // this.aliases.add("warphome"); + } + + @Override + public int compareTo(final Object o) { + return 0; + } + + @Override + public String getCommandName() { + return "alkalus"; + } + + @Override + public String getCommandUsage(final ICommandSender var1) { + return "/alkalus [Dev Command]"; + } + + @Override + public List getCommandAliases() { + return this.aliases; + } + + @Override + public void processCommand(final ICommandSender S, final String[] argString) { + Logger.INFO("Debug Command"); + final World W = S.getEntityWorld(); + final EntityPlayer P = CommandUtils.getPlayer(S); + if (P.getDisplayName().equalsIgnoreCase("draknyte1")) { + Logger.INFO("[Bedrock Miner] OreType Scan"); + MiningUtils.iterateAllOreTypes(); + } + } + + @Override + public boolean canCommandSenderUseCommand(final ICommandSender var1) { + final EntityPlayer P = CommandUtils.getPlayer(var1); + if (P == null) { + return false; + } + if (P.getDisplayName().toLowerCase().equals("draknyte1") + || P.getCommandSenderName().toLowerCase().equals("draknyte1") + || CORE.DEVENV) { + return true; + } + return false; + } + + @Override + public List addTabCompletionOptions(final ICommandSender var1, final String[] var2) { + return null; + } + + @Override + public boolean isUsernameIndex(final String[] var1, final int var2) { + // TODO Auto-generated method stub + return false; + } + + public boolean playerUsesCommand(final World W, final EntityPlayer P, final int cost) { + + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/commands/CommandUtils.java b/src/main/java/gtPlusPlus/core/commands/CommandUtils.java index 175925d40c..931ac5239f 100644 --- a/src/main/java/gtPlusPlus/core/commands/CommandUtils.java +++ b/src/main/java/gtPlusPlus/core/commands/CommandUtils.java @@ -5,16 +5,14 @@ import net.minecraft.entity.player.EntityPlayer; public class CommandUtils { - public static EntityPlayer getPlayer(final ICommandSender icommandsender){ - EntityPlayer player; - - if(icommandsender instanceof EntityPlayer){ - player = (EntityPlayer)icommandsender; - return player; - } - else { - return null; - } - } + public static EntityPlayer getPlayer(final ICommandSender icommandsender) { + EntityPlayer player; + if (icommandsender instanceof EntityPlayer) { + player = (EntityPlayer) icommandsender; + return player; + } else { + return null; + } + } } diff --git a/src/main/java/gtPlusPlus/core/common/BasePlayer.java b/src/main/java/gtPlusPlus/core/common/BasePlayer.java index 4686f34207..69cd46178a 100644 --- a/src/main/java/gtPlusPlus/core/common/BasePlayer.java +++ b/src/main/java/gtPlusPlus/core/common/BasePlayer.java @@ -10,203 +10,205 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.potion.Potion; import net.minecraft.util.MovementInputFromOptions; -public class BasePlayer extends ClientPlayerBase -{ - private final Minecraft mc = Minecraft.getMinecraft(); - private final CustomMovementHandler customMovementInput = new CustomMovementHandler(); - private final GameSettings settings = this.mc.gameSettings; - - public BasePlayer(final ClientPlayerAPI api) - { - super(api); - } - - /* - * EntityPlayerSP.onLivingUpdate() - Adapted to PlayerAPI - */ - @Override - public void onLivingUpdate() { - - super.onLivingUpdate(); - EntityPlayer aPlayer = this.player; - if (aPlayer != null) { - SneakManager aSneak = SneakManager.get(aPlayer); - if (!aSneak.isWearingRing()) { - return; - } - } - - if(this.player.sprintingTicksLeft > 0) - { - --this.player.sprintingTicksLeft; - if(this.player.sprintingTicksLeft == 0) - { - this.player.setSprinting(false); - } - } - - if(this.playerAPI.getSprintToggleTimerField() > 0) - { - this.playerAPI.setSprintToggleTimerField(this.playerAPI.getSprintToggleTimerField() - 1); - } - - if(this.mc.playerController.enableEverythingIsScrewedUpMode()) - { - this.player.posX = this.player.posZ = 0.5D; - this.player.posX = 0.0D; - this.player.posZ = 0.0D; - this.player.rotationYaw = this.player.ticksExisted / 12.0F; - this.player.rotationPitch = 10.0F; - this.player.posY = 68.5D; - } - else - { - - - - - final boolean isJumping = this.player.movementInput.jump; - - final float minSpeed = 0.8F; - final boolean isMovingForward = this.player.movementInput.moveForward >= minSpeed; - this.customMovementInput.update(this.mc, (MovementInputFromOptions)this.player.movementInput, this.player); - - - /* - * Begin ToggleSneak Changes - ToggleSprint - */ - SneakManager aSneak = SneakManager.get(this.player); - - final boolean isSprintDisabled = false; - final boolean canDoubleTap = aSneak.optionDoubleTap; - - - // Detect when ToggleSprint was disabled in the in-game options menu - if(aSneak.wasSprintDisabled) - { - this.player.setSprinting(false); - this.customMovementInput.UpdateSprint(false, false, aSneak); - aSneak.wasSprintDisabled = false; - } - - // Default Sprint routine converted to PlayerAPI, use if ToggleSprint is disabled - TODO - Disable sprinting as a whole - if(isSprintDisabled) - { - //Utils.LOG_INFO("Sprint pressed"); - if(aSneak.optionDoubleTap && this.player.onGround && !isMovingForward && (this.player.movementInput.moveForward >= minSpeed) && !this.player.isSprinting() && !this.player.isUsingItem() && !this.player.isPotionActive(Potion.blindness)) - { - if((this.playerAPI.getSprintToggleTimerField() <= 0) && !this.settings.keyBindSprint.getIsKeyPressed()) - { - this.playerAPI.setSprintToggleTimerField(7); - } - else - { - if (aSneak.Sprinting()){ - this.player.setSprinting(true); - this.customMovementInput.UpdateSprint(true, false, aSneak); - } - else { - this.player.setSprinting(false); - this.customMovementInput.UpdateSprint(false, false, aSneak); - } - } - } - - if(!this.player.isSprinting() && (this.player.movementInput.moveForward >= minSpeed) && !this.player.isUsingItem() && !this.player.isPotionActive(Potion.blindness) && this.settings.keyBindSprint.getIsKeyPressed()) - { - if (aSneak.Sprinting()){ - this.player.setSprinting(true); - this.customMovementInput.UpdateSprint(true, false, aSneak); - } - else { - this.player.setSprinting(false); - this.customMovementInput.UpdateSprint(false, false, aSneak); - } - } - } - else - { - final boolean state = this.customMovementInput.sprint; - - // Only handle changes in state under the following conditions: - // On ground, not hungry, not eating/using item, not blind, and not Vanilla - // - // 5/6/14 - onGround check removed to match vanilla's 'start sprint while jumping' behavior. - //if(this.player.onGround && enoughHunger && !this.player.isUsingItem() && !this.player.isPotionActive(Potion.blindness) && !this.customMovementInput.sprintHeldAndReleased) - - if(!this.player.isUsingItem() && !this.player.isPotionActive(Potion.blindness) && !this.customMovementInput.sprintHeldAndReleased) - { - if((canDoubleTap && !this.player.isSprinting()) || !canDoubleTap) - { - if (aSneak.Sprinting()){ - this.player.setSprinting(state); - } else { - this.player.setSprinting(false); - } - } - } - - if(canDoubleTap && !state && this.player.onGround && !isMovingForward && (this.player.movementInput.moveForward >= minSpeed) && !this.player.isSprinting() && !this.player.isUsingItem() && !this.player.isPotionActive(Potion.blindness)) - { - if(this.playerAPI.getSprintToggleTimerField() == 0) - { - this.playerAPI.setSprintToggleTimerField(7); - } - else - { - if (aSneak.Sprinting()){ - this.player.setSprinting(true); - this.customMovementInput.UpdateSprint(true, true, aSneak); - this.playerAPI.setSprintToggleTimerField(0); - } - } - } - } - - // If sprinting, break the sprint in appropriate circumstances: - // Player stops moving forward, runs into something, or gets too hungry - if(this.player.isSprinting() && ((this.player.movementInput.moveForward < minSpeed) || this.player.isCollidedHorizontally)) - { - this.player.setSprinting(false); - - // Undo toggle if we resumed vanilla operation due to Hold&Release, DoubleTap, Fly, Ride - if ((this.customMovementInput.sprintHeldAndReleased == true) || isSprintDisabled || this.customMovementInput.sprintDoubleTapped || this.player.capabilities.isFlying || this.player.isRiding()) - { - this.customMovementInput.UpdateSprint(false, false, aSneak); - } - } - - /* - * End ToggleSneak Changes - ToggleSprint - */ - - // // - // // Debug Framework - Added 5/7/2014 - // // - // if (this.showDebug && this.settings.keyBindPickBlock.getIsKeyPressed() && !this.handledDebugPress) - // { - // this.player.addChatMessage(new ChatComponentText("+--------------------------------------+")); - // this.player.addChatMessage(new ChatComponentText("| ToggleSneak Debug Info |")); - // this.player.addChatMessage(new ChatComponentText("+--------------------------------------+")); - // this.player.addChatMessage(new ChatComponentText(" ")); - // this.player.addChatMessage(new ChatComponentText("isFlying - " + (this.player.capabilities.isFlying == true ? "True" : "False"))); - // this.player.addChatMessage(new ChatComponentText("isCreative - " + (this.player.capabilities.isCreativeMode == true ? "True" : "False"))); - // this.player.addChatMessage(new ChatComponentText("enableFlyBoost - " + (SneakManager.optionEnableFlyBoost == true ? "True" : "False"))); - // this.player.addChatMessage(new ChatComponentText("flyBoostAmount - " + SneakManager.optionFlyBoostAmount)); - // this.player.addChatMessage(new ChatComponentText(" ")); - // this.player.addChatMessage(new ChatComponentText("keybindSprint - " + (this.settings.keyBindSprint.getIsKeyPressed() == true ? "True" : "False"))); - // this.player.addChatMessage(new ChatComponentText("keybindSneak - " + (this.settings.keyBindSneak.getIsKeyPressed() == true ? "True" : "False"))); - // this.player.addChatMessage(new ChatComponentText("keybindJump - " + (this.settings.keyBindJump.getIsKeyPressed() == true ? "True" : "False"))); - // this.player.addChatMessage(new ChatComponentText(" ")); - // this.player.addChatMessage(new ChatComponentText(" ")); - // - // this.handledDebugPress = true; - // } - // else if (this.showDebug && !this.settings.keyBindPickBlock.getIsKeyPressed() && this.handledDebugPress) - // { - // this.handledDebugPress = false; - // } - - } - } -} \ No newline at end of file +public class BasePlayer extends ClientPlayerBase { + private final Minecraft mc = Minecraft.getMinecraft(); + private final CustomMovementHandler customMovementInput = new CustomMovementHandler(); + private final GameSettings settings = this.mc.gameSettings; + + public BasePlayer(final ClientPlayerAPI api) { + super(api); + } + + /* + * EntityPlayerSP.onLivingUpdate() - Adapted to PlayerAPI + */ + @Override + public void onLivingUpdate() { + + super.onLivingUpdate(); + EntityPlayer aPlayer = this.player; + if (aPlayer != null) { + SneakManager aSneak = SneakManager.get(aPlayer); + if (!aSneak.isWearingRing()) { + return; + } + } + + if (this.player.sprintingTicksLeft > 0) { + --this.player.sprintingTicksLeft; + if (this.player.sprintingTicksLeft == 0) { + this.player.setSprinting(false); + } + } + + if (this.playerAPI.getSprintToggleTimerField() > 0) { + this.playerAPI.setSprintToggleTimerField(this.playerAPI.getSprintToggleTimerField() - 1); + } + + if (this.mc.playerController.enableEverythingIsScrewedUpMode()) { + this.player.posX = this.player.posZ = 0.5D; + this.player.posX = 0.0D; + this.player.posZ = 0.0D; + this.player.rotationYaw = this.player.ticksExisted / 12.0F; + this.player.rotationPitch = 10.0F; + this.player.posY = 68.5D; + } else { + + final boolean isJumping = this.player.movementInput.jump; + + final float minSpeed = 0.8F; + final boolean isMovingForward = this.player.movementInput.moveForward >= minSpeed; + this.customMovementInput.update(this.mc, (MovementInputFromOptions) this.player.movementInput, this.player); + + /* + * Begin ToggleSneak Changes - ToggleSprint + */ + SneakManager aSneak = SneakManager.get(this.player); + + final boolean isSprintDisabled = false; + final boolean canDoubleTap = aSneak.optionDoubleTap; + + // Detect when ToggleSprint was disabled in the in-game options menu + if (aSneak.wasSprintDisabled) { + this.player.setSprinting(false); + this.customMovementInput.UpdateSprint(false, false, aSneak); + aSneak.wasSprintDisabled = false; + } + + // Default Sprint routine converted to PlayerAPI, use if ToggleSprint is disabled - TODO - Disable sprinting + // as a whole + if (isSprintDisabled) { + // Utils.LOG_INFO("Sprint pressed"); + if (aSneak.optionDoubleTap + && this.player.onGround + && !isMovingForward + && (this.player.movementInput.moveForward >= minSpeed) + && !this.player.isSprinting() + && !this.player.isUsingItem() + && !this.player.isPotionActive(Potion.blindness)) { + if ((this.playerAPI.getSprintToggleTimerField() <= 0) + && !this.settings.keyBindSprint.getIsKeyPressed()) { + this.playerAPI.setSprintToggleTimerField(7); + } else { + if (aSneak.Sprinting()) { + this.player.setSprinting(true); + this.customMovementInput.UpdateSprint(true, false, aSneak); + } else { + this.player.setSprinting(false); + this.customMovementInput.UpdateSprint(false, false, aSneak); + } + } + } + + if (!this.player.isSprinting() + && (this.player.movementInput.moveForward >= minSpeed) + && !this.player.isUsingItem() + && !this.player.isPotionActive(Potion.blindness) + && this.settings.keyBindSprint.getIsKeyPressed()) { + if (aSneak.Sprinting()) { + this.player.setSprinting(true); + this.customMovementInput.UpdateSprint(true, false, aSneak); + } else { + this.player.setSprinting(false); + this.customMovementInput.UpdateSprint(false, false, aSneak); + } + } + } else { + final boolean state = this.customMovementInput.sprint; + + // Only handle changes in state under the following conditions: + // On ground, not hungry, not eating/using item, not blind, and not Vanilla + // + // 5/6/14 - onGround check removed to match vanilla's 'start sprint while jumping' behavior. + // if(this.player.onGround && enoughHunger && !this.player.isUsingItem() && + // !this.player.isPotionActive(Potion.blindness) && !this.customMovementInput.sprintHeldAndReleased) + + if (!this.player.isUsingItem() + && !this.player.isPotionActive(Potion.blindness) + && !this.customMovementInput.sprintHeldAndReleased) { + if ((canDoubleTap && !this.player.isSprinting()) || !canDoubleTap) { + if (aSneak.Sprinting()) { + this.player.setSprinting(state); + } else { + this.player.setSprinting(false); + } + } + } + + if (canDoubleTap + && !state + && this.player.onGround + && !isMovingForward + && (this.player.movementInput.moveForward >= minSpeed) + && !this.player.isSprinting() + && !this.player.isUsingItem() + && !this.player.isPotionActive(Potion.blindness)) { + if (this.playerAPI.getSprintToggleTimerField() == 0) { + this.playerAPI.setSprintToggleTimerField(7); + } else { + if (aSneak.Sprinting()) { + this.player.setSprinting(true); + this.customMovementInput.UpdateSprint(true, true, aSneak); + this.playerAPI.setSprintToggleTimerField(0); + } + } + } + } + + // If sprinting, break the sprint in appropriate circumstances: + // Player stops moving forward, runs into something, or gets too hungry + if (this.player.isSprinting() + && ((this.player.movementInput.moveForward < minSpeed) || this.player.isCollidedHorizontally)) { + this.player.setSprinting(false); + + // Undo toggle if we resumed vanilla operation due to Hold&Release, DoubleTap, Fly, Ride + if ((this.customMovementInput.sprintHeldAndReleased == true) + || isSprintDisabled + || this.customMovementInput.sprintDoubleTapped + || this.player.capabilities.isFlying + || this.player.isRiding()) { + this.customMovementInput.UpdateSprint(false, false, aSneak); + } + } + + /* + * End ToggleSneak Changes - ToggleSprint + */ + + // // + // // Debug Framework - Added 5/7/2014 + // // + // if (this.showDebug && this.settings.keyBindPickBlock.getIsKeyPressed() && !this.handledDebugPress) + // { + // this.player.addChatMessage(new ChatComponentText("+--------------------------------------+")); + // this.player.addChatMessage(new ChatComponentText("| ToggleSneak Debug Info |")); + // this.player.addChatMessage(new ChatComponentText("+--------------------------------------+")); + // this.player.addChatMessage(new ChatComponentText(" ")); + // this.player.addChatMessage(new ChatComponentText("isFlying - " + + // (this.player.capabilities.isFlying == true ? "True" : "False"))); + // this.player.addChatMessage(new ChatComponentText("isCreative - " + + // (this.player.capabilities.isCreativeMode == true ? "True" : "False"))); + // this.player.addChatMessage(new ChatComponentText("enableFlyBoost - " + + // (SneakManager.optionEnableFlyBoost == true ? "True" : "False"))); + // this.player.addChatMessage(new ChatComponentText("flyBoostAmount - " + + // SneakManager.optionFlyBoostAmount)); + // this.player.addChatMessage(new ChatComponentText(" ")); + // this.player.addChatMessage(new ChatComponentText("keybindSprint - " + + // (this.settings.keyBindSprint.getIsKeyPressed() == true ? "True" : "False"))); + // this.player.addChatMessage(new ChatComponentText("keybindSneak - " + + // (this.settings.keyBindSneak.getIsKeyPressed() == true ? "True" : "False"))); + // this.player.addChatMessage(new ChatComponentText("keybindJump - " + + // (this.settings.keyBindJump.getIsKeyPressed() == true ? "True" : "False"))); + // this.player.addChatMessage(new ChatComponentText(" ")); + // this.player.addChatMessage(new ChatComponentText(" ")); + // + // this.handledDebugPress = true; + // } + // else if (this.showDebug && !this.settings.keyBindPickBlock.getIsKeyPressed() && this.handledDebugPress) + // { + // this.handledDebugPress = false; + // } + + } + } +} diff --git a/src/main/java/gtPlusPlus/core/common/CommonProxy.java b/src/main/java/gtPlusPlus/core/common/CommonProxy.java index 2909ef3541..421dd05b8f 100644 --- a/src/main/java/gtPlusPlus/core/common/CommonProxy.java +++ b/src/main/java/gtPlusPlus/core/common/CommonProxy.java @@ -3,7 +3,6 @@ package gtPlusPlus.core.common; import cpw.mods.fml.common.event.*; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import cpw.mods.fml.common.registry.GameRegistry; -import gregtech.api.enums.OrePrefixes; import gtPlusPlus.GTplusplus; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; @@ -18,12 +17,10 @@ import gtPlusPlus.core.fluids.FluidFactory; import gtPlusPlus.core.handler.*; import gtPlusPlus.core.handler.events.*; import gtPlusPlus.core.item.ModItems; -import gtPlusPlus.core.item.chemistry.GenericChem; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.CORE.ConfigSwitches; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.ALLOY; -import gtPlusPlus.core.material.Material; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.tileentities.ModTileEntities; import gtPlusPlus.core.util.Utils; @@ -36,7 +33,6 @@ import gtPlusPlus.plugin.villagers.block.BlockGenericSpawner; import gtPlusPlus.preloader.CORE_Preloader; import gtPlusPlus.xmod.eio.handler.HandlerTooltip_EIO; import gtPlusPlus.xmod.galacticraft.handler.HandlerTooltip_GC; -import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.api.util.SpecialBehaviourTooltipHandler; import net.minecraft.enchantment.Enchantment; import net.minecraft.entity.Entity; @@ -50,261 +46,258 @@ import net.minecraftforge.client.IItemRenderer; public class CommonProxy { - public CommonProxy() { - // Should Register Gregtech Materials I've Made - Utils.registerEvent(this); - if (!CORE.GTNH) { - Logger.INFO("We're using Gregtech " + Utils.getGregtechVersionAsString()); - } else { - Logger.INFO("We're using GTNH's Gregtech " + Utils.getGregtechVersionAsString()); - } - } - - public void preInit(final FMLPreInitializationEvent e) { - Logger.INFO("Doing some house cleaning."); - LoadedMods.checkLoaded(); - Logger.INFO("Making sure we're ready to party!"); - - if (!CORE_Preloader.DEBUG_MODE) { - Logger.WARNING("Development mode not enabled."); - } else if (CORE_Preloader.DEBUG_MODE) { - Logger.INFO("Development mode enabled."); - } else { - Logger.WARNING("Development mode not set."); - } - - AddToCreativeTab.initialiseTabs(); - EnumHelperHandler.init(); - - // Moved from Init after Debug Loading. - // 29/01/18 - Alkalus - // Moved earlier into PreInit, so that Items exist before they're called upon in - // recipes. - // 20/03/18 - Alkalus - ModItems.init(); - ModBlocks.init(); - CI.preInit(); - FluidFactory.preInit(); - COMPAT_IntermodStaging.preInit(e); - BookHandler.run(); - // Registration of entities and renderers - Logger.INFO("[Proxy] Calling Entity registrator."); - registerEntities(); - Logger.INFO("[Proxy] Calling Tile Entity registrator."); - registerTileEntities(); - - Logger.INFO("[Proxy] Calling Render registrator."); - registerRenderThings(); - - } - - public void init(final FMLInitializationEvent e) { - // Debug Loading - if (CORE_Preloader.DEBUG_MODE) { - DEBUG_INIT.registerHandlers(); - } - - registerCustomItemsForMaterials(); - ModBlocks.blockCustomMobSpawner = new BlockGenericSpawner(); - CI.init(); - FluidFactory.init(); - - /** - * Register the Event Handlers. - */ - - // Prevents my Safes being destroyed. - Utils.registerEvent(new PickaxeBlockBreakEventHandler()); - // Block Handler for all events. - Utils.registerEvent(new BlockEventHandler()); - Utils.registerEvent(new GeneralTooltipEventHandler()); - // Handles Tooltips for items giving custom multiblock behaviour - Utils.registerEvent(new SpecialBehaviourTooltipHandler()); - // Handles Custom tooltips for EIO. - Utils.registerEvent(new HandlerTooltip_EIO()); - // Handles Custom Tooltips for GC - Utils.registerEvent(new HandlerTooltip_GC()); - // Handles Sleep Benefits - PlayerSleepEventHandler.init(); - // Handles Magic Feather - Utils.registerEvent(ModItems.itemMagicFeather); - - if (CORE.DEVENV) { - Utils.registerEvent(new StopAnnoyingFuckingAchievements()); - } - - Utils.registerEvent(new EnderDragonDeathHandler()); - Utils.registerEvent(new EntityDeathHandler()); - - if (ConfigSwitches.disableZombieReinforcement) { - // Make Zombie reinforcements fuck off. - Utils.registerEvent(new ZombieBackupSpawnEventHandler()); - } - - /** - * End of Subscribe Event registration. - */ - - // Compat Handling - COMPAT_HANDLER.registerMyModsOreDictEntries(); - COMPAT_HANDLER.intermodOreDictionarySupport(); - COMPAT_IntermodStaging.init(e); - } - - public void postInit(final FMLPostInitializationEvent e) { - Logger.INFO("Cleaning up, doing postInit."); - PlayerCache.initCache(); - FluidFactory.postInit(); - - // Make Burnables burnable - if (!CORE.burnables.isEmpty()) { - BurnableFuelHandler fuelHandler = new BurnableFuelHandler(); - GameRegistry.registerFuelHandler(fuelHandler); - Logger.INFO("[Fuel Handler] Registering " + fuelHandler.getClass().getName()); - } - - // Compat Handling - Logger.INFO("Removing recipes from other mods."); - COMPAT_HANDLER.RemoveRecipesFromOtherMods(); - Logger.INFO("Initialising Handler, Then Adding Recipes"); - COMPAT_HANDLER.InitialiseHandlerThenAddRecipes(); - Logger.INFO("Loading Intermod staging."); - COMPAT_IntermodStaging.postInit(e); - Logger.INFO("Loading queued recipes."); - COMPAT_HANDLER.runQueuedRecipes(); - Logger.INFO("Registering custom mob drops."); - registerCustomMobDrops(); - - // Moved last in postInit(). - // 12/12/19 - Alkalus - // Moved last, to prevent recipes being generated post initialisation. - Logger.INFO("Loading Gregtech API recipes."); - COMPAT_HANDLER.startLoadingGregAPIBasedRecipes(); - } - - public void serverStarting(final FMLServerStartingEvent e) { - COMPAT_HANDLER.InitialiseLateHandlerThenAddRecipes(); - } - - public void onLoadComplete(FMLLoadCompleteEvent event) { - COMPAT_IntermodStaging.onLoadComplete(event); - COMPAT_HANDLER.onLoadComplete(event); - } - - public void registerNetworkStuff() { - GuiHandler.init(); - } - - public void registerEntities() { - InternalEntityRegistry.registerEntities(); - } - - public void registerTileEntities() { - ModTileEntities.init(); - } - - public void registerRenderThings() { - - } - - public int addArmor(final String armor) { - return 0; - } - - public void generateMysteriousParticles(final Entity entity) { - - } - - public void generateMobSpawners() { - // Try register some test spawners - Utils.createNewMobSpawner(0, EntityGiantChickenBase.class); - Utils.createNewMobSpawner(1, EntitySickBlaze.class); - Utils.createNewMobSpawner(2, EntityStaballoyConstruct.class); - } - - public void registerCustomItemsForMaterials() { - //Material.registerComponentForMaterial(GenericChem.CARBYNE, OrePrefixes.plate, GregtechItemList.Carbyne_Sheet_Finished.get(1)); - } - - public void registerCustomMobDrops() { - - //Zombie - EntityUtils.registerDropsForMob(EntityZombie.class, ItemUtils.getSimpleStack(ModItems.itemRope), 3, 100); - EntityUtils.registerDropsForMob(EntityZombie.class, ItemUtils.getSimpleStack(ModItems.itemFiber), 5, 250); - EntityUtils.registerDropsForMob(EntityZombie.class, ItemUtils.getSimpleStack(ModItems.itemSandstoneHammer), 1, 10); - EntityUtils.registerDropsForMob(EntityZombie.class, ItemUtils.getSimpleStack(ModItems.itemBomb), 2, 10); - EntityUtils.registerDropsForMob(EntityZombie.class, ALLOY.TUMBAGA.getTinyDust(1), 1, 10); - EntityUtils.registerDropsForMob(EntityZombie.class, ALLOY.POTIN.getTinyDust(1), 1, 10); - - //Blazes - if (ItemUtils.doesOreDictHaveEntryFor("dustPyrotheum")) { - EntityUtils.registerDropsForMob(EntityBlaze.class, ItemUtils.getItemStackOfAmountFromOreDict("dustPyrotheum", 1), 1, 10); - EntityUtils.registerDropsForMob(EntityBlaze.class, ItemUtils.getItemStackOfAmountFromOreDict("dustPyrotheum", 1), 1, 10); - } - - - //Special mobs Support - if (ReflectionUtils.doesClassExist("toast.specialMobs.entity.zombie.EntityBrutishZombie")) { - Class aBrutishZombie = ReflectionUtils.getClass("toast.specialMobs.entity.zombie.EntityBrutishZombie"); - ItemStack aFortune1 = ItemUtils.getEnchantedBook(Enchantment.fortune, 1); - ItemStack aFortune2 = ItemUtils.getEnchantedBook(Enchantment.fortune, 1); - ItemStack aFortune3 = ItemUtils.getEnchantedBook(Enchantment.fortune, 1); - EntityUtils.registerDropsForMob(aBrutishZombie, aFortune1, 1, 100); - EntityUtils.registerDropsForMob(aBrutishZombie, aFortune2, 1, 50); - EntityUtils.registerDropsForMob(aBrutishZombie, aFortune3, 1, 1); - EntityUtils.registerDropsForMob(aBrutishZombie, ItemUtils.getItemStackOfAmountFromOreDict("ingotRedAlloy", 1), 3, 200); - } - - //GalaxySpace Support - if (ReflectionUtils.doesClassExist("galaxyspace.SolarSystem.moons.europa.entities.EntityEvolvedColdBlaze")) { - Class aColdBlaze = ReflectionUtils.getClass("galaxyspace.SolarSystem.moons.europa.entities.EntityEvolvedColdBlaze"); - ItemStack aSmallBlizz, aTinyBlizz, aSmallCryo, aTinyCryo; - aSmallBlizz = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallBlizz", 1); - aTinyBlizz = ItemUtils.getItemStackOfAmountFromOreDict("dustTinyBlizz", 1); - aSmallCryo = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallCryotheum", 1); - aTinyCryo = ItemUtils.getItemStackOfAmountFromOreDict("dustTinyCryotheum", 1); - EntityUtils.registerDropsForMob(aColdBlaze, ItemUtils.getItemStackOfAmountFromOreDict("stickBlizz", 1), 2, 500); - if (aSmallBlizz != null) { - EntityUtils.registerDropsForMob(aColdBlaze, aSmallBlizz, 2, 750); - } - if (aTinyBlizz != null) { - EntityUtils.registerDropsForMob(aColdBlaze, aTinyBlizz, 4, 1500); - } - if (aSmallCryo != null) { - EntityUtils.registerDropsForMob(aColdBlaze, aSmallCryo, 1, 50); - } - if (aTinyCryo != null) { - EntityUtils.registerDropsForMob(aColdBlaze, aTinyCryo, 2, 100); - } - } - - } - - protected final AutoMap> mItemRenderMappings = new AutoMap>(); - - - public static void registerItemRendererGlobal(Item aItem, IItemRenderer aRenderer) { - GTplusplus.proxy.registerItemRenderer(aItem, aRenderer); - } - - public void registerItemRenderer(Item aItem, IItemRenderer aRenderer) { - if (Utils.isServer()) { - return; - } - else { - mItemRenderMappings.add(new Pair(aItem, aRenderer)); - } - } - - public World getClientWorld() { - return null; - } - - /** - * Returns a side-appropriate EntityPlayer for use during message handling - */ - public EntityPlayer getPlayerEntity(MessageContext ctx) { - return ctx.getServerHandler().playerEntity; - } - + public CommonProxy() { + // Should Register Gregtech Materials I've Made + Utils.registerEvent(this); + if (!CORE.GTNH) { + Logger.INFO("We're using Gregtech " + Utils.getGregtechVersionAsString()); + } else { + Logger.INFO("We're using GTNH's Gregtech " + Utils.getGregtechVersionAsString()); + } + } + + public void preInit(final FMLPreInitializationEvent e) { + Logger.INFO("Doing some house cleaning."); + LoadedMods.checkLoaded(); + Logger.INFO("Making sure we're ready to party!"); + + if (!CORE_Preloader.DEBUG_MODE) { + Logger.WARNING("Development mode not enabled."); + } else if (CORE_Preloader.DEBUG_MODE) { + Logger.INFO("Development mode enabled."); + } else { + Logger.WARNING("Development mode not set."); + } + + AddToCreativeTab.initialiseTabs(); + EnumHelperHandler.init(); + + // Moved from Init after Debug Loading. + // 29/01/18 - Alkalus + // Moved earlier into PreInit, so that Items exist before they're called upon in + // recipes. + // 20/03/18 - Alkalus + ModItems.init(); + ModBlocks.init(); + CI.preInit(); + FluidFactory.preInit(); + COMPAT_IntermodStaging.preInit(e); + BookHandler.run(); + // Registration of entities and renderers + Logger.INFO("[Proxy] Calling Entity registrator."); + registerEntities(); + Logger.INFO("[Proxy] Calling Tile Entity registrator."); + registerTileEntities(); + + Logger.INFO("[Proxy] Calling Render registrator."); + registerRenderThings(); + } + + public void init(final FMLInitializationEvent e) { + // Debug Loading + if (CORE_Preloader.DEBUG_MODE) { + DEBUG_INIT.registerHandlers(); + } + + registerCustomItemsForMaterials(); + ModBlocks.blockCustomMobSpawner = new BlockGenericSpawner(); + CI.init(); + FluidFactory.init(); + + /** + * Register the Event Handlers. + */ + + // Prevents my Safes being destroyed. + Utils.registerEvent(new PickaxeBlockBreakEventHandler()); + // Block Handler for all events. + Utils.registerEvent(new BlockEventHandler()); + Utils.registerEvent(new GeneralTooltipEventHandler()); + // Handles Tooltips for items giving custom multiblock behaviour + Utils.registerEvent(new SpecialBehaviourTooltipHandler()); + // Handles Custom tooltips for EIO. + Utils.registerEvent(new HandlerTooltip_EIO()); + // Handles Custom Tooltips for GC + Utils.registerEvent(new HandlerTooltip_GC()); + // Handles Sleep Benefits + PlayerSleepEventHandler.init(); + // Handles Magic Feather + Utils.registerEvent(ModItems.itemMagicFeather); + + if (CORE.DEVENV) { + Utils.registerEvent(new StopAnnoyingFuckingAchievements()); + } + + Utils.registerEvent(new EnderDragonDeathHandler()); + Utils.registerEvent(new EntityDeathHandler()); + + if (ConfigSwitches.disableZombieReinforcement) { + // Make Zombie reinforcements fuck off. + Utils.registerEvent(new ZombieBackupSpawnEventHandler()); + } + + /** + * End of Subscribe Event registration. + */ + + // Compat Handling + COMPAT_HANDLER.registerMyModsOreDictEntries(); + COMPAT_HANDLER.intermodOreDictionarySupport(); + COMPAT_IntermodStaging.init(e); + } + + public void postInit(final FMLPostInitializationEvent e) { + Logger.INFO("Cleaning up, doing postInit."); + PlayerCache.initCache(); + FluidFactory.postInit(); + + // Make Burnables burnable + if (!CORE.burnables.isEmpty()) { + BurnableFuelHandler fuelHandler = new BurnableFuelHandler(); + GameRegistry.registerFuelHandler(fuelHandler); + Logger.INFO("[Fuel Handler] Registering " + fuelHandler.getClass().getName()); + } + + // Compat Handling + Logger.INFO("Removing recipes from other mods."); + COMPAT_HANDLER.RemoveRecipesFromOtherMods(); + Logger.INFO("Initialising Handler, Then Adding Recipes"); + COMPAT_HANDLER.InitialiseHandlerThenAddRecipes(); + Logger.INFO("Loading Intermod staging."); + COMPAT_IntermodStaging.postInit(e); + Logger.INFO("Loading queued recipes."); + COMPAT_HANDLER.runQueuedRecipes(); + Logger.INFO("Registering custom mob drops."); + registerCustomMobDrops(); + + // Moved last in postInit(). + // 12/12/19 - Alkalus + // Moved last, to prevent recipes being generated post initialisation. + Logger.INFO("Loading Gregtech API recipes."); + COMPAT_HANDLER.startLoadingGregAPIBasedRecipes(); + } + + public void serverStarting(final FMLServerStartingEvent e) { + COMPAT_HANDLER.InitialiseLateHandlerThenAddRecipes(); + } + + public void onLoadComplete(FMLLoadCompleteEvent event) { + COMPAT_IntermodStaging.onLoadComplete(event); + COMPAT_HANDLER.onLoadComplete(event); + } + + public void registerNetworkStuff() { + GuiHandler.init(); + } + + public void registerEntities() { + InternalEntityRegistry.registerEntities(); + } + + public void registerTileEntities() { + ModTileEntities.init(); + } + + public void registerRenderThings() {} + + public int addArmor(final String armor) { + return 0; + } + + public void generateMysteriousParticles(final Entity entity) {} + + public void generateMobSpawners() { + // Try register some test spawners + Utils.createNewMobSpawner(0, EntityGiantChickenBase.class); + Utils.createNewMobSpawner(1, EntitySickBlaze.class); + Utils.createNewMobSpawner(2, EntityStaballoyConstruct.class); + } + + public void registerCustomItemsForMaterials() { + // Material.registerComponentForMaterial(GenericChem.CARBYNE, OrePrefixes.plate, + // GregtechItemList.Carbyne_Sheet_Finished.get(1)); + } + + public void registerCustomMobDrops() { + + // Zombie + EntityUtils.registerDropsForMob(EntityZombie.class, ItemUtils.getSimpleStack(ModItems.itemRope), 3, 100); + EntityUtils.registerDropsForMob(EntityZombie.class, ItemUtils.getSimpleStack(ModItems.itemFiber), 5, 250); + EntityUtils.registerDropsForMob( + EntityZombie.class, ItemUtils.getSimpleStack(ModItems.itemSandstoneHammer), 1, 10); + EntityUtils.registerDropsForMob(EntityZombie.class, ItemUtils.getSimpleStack(ModItems.itemBomb), 2, 10); + EntityUtils.registerDropsForMob(EntityZombie.class, ALLOY.TUMBAGA.getTinyDust(1), 1, 10); + EntityUtils.registerDropsForMob(EntityZombie.class, ALLOY.POTIN.getTinyDust(1), 1, 10); + + // Blazes + if (ItemUtils.doesOreDictHaveEntryFor("dustPyrotheum")) { + EntityUtils.registerDropsForMob( + EntityBlaze.class, ItemUtils.getItemStackOfAmountFromOreDict("dustPyrotheum", 1), 1, 10); + EntityUtils.registerDropsForMob( + EntityBlaze.class, ItemUtils.getItemStackOfAmountFromOreDict("dustPyrotheum", 1), 1, 10); + } + + // Special mobs Support + if (ReflectionUtils.doesClassExist("toast.specialMobs.entity.zombie.EntityBrutishZombie")) { + Class aBrutishZombie = ReflectionUtils.getClass("toast.specialMobs.entity.zombie.EntityBrutishZombie"); + ItemStack aFortune1 = ItemUtils.getEnchantedBook(Enchantment.fortune, 1); + ItemStack aFortune2 = ItemUtils.getEnchantedBook(Enchantment.fortune, 1); + ItemStack aFortune3 = ItemUtils.getEnchantedBook(Enchantment.fortune, 1); + EntityUtils.registerDropsForMob(aBrutishZombie, aFortune1, 1, 100); + EntityUtils.registerDropsForMob(aBrutishZombie, aFortune2, 1, 50); + EntityUtils.registerDropsForMob(aBrutishZombie, aFortune3, 1, 1); + EntityUtils.registerDropsForMob( + aBrutishZombie, ItemUtils.getItemStackOfAmountFromOreDict("ingotRedAlloy", 1), 3, 200); + } + + // GalaxySpace Support + if (ReflectionUtils.doesClassExist("galaxyspace.SolarSystem.moons.europa.entities.EntityEvolvedColdBlaze")) { + Class aColdBlaze = + ReflectionUtils.getClass("galaxyspace.SolarSystem.moons.europa.entities.EntityEvolvedColdBlaze"); + ItemStack aSmallBlizz, aTinyBlizz, aSmallCryo, aTinyCryo; + aSmallBlizz = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallBlizz", 1); + aTinyBlizz = ItemUtils.getItemStackOfAmountFromOreDict("dustTinyBlizz", 1); + aSmallCryo = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallCryotheum", 1); + aTinyCryo = ItemUtils.getItemStackOfAmountFromOreDict("dustTinyCryotheum", 1); + EntityUtils.registerDropsForMob( + aColdBlaze, ItemUtils.getItemStackOfAmountFromOreDict("stickBlizz", 1), 2, 500); + if (aSmallBlizz != null) { + EntityUtils.registerDropsForMob(aColdBlaze, aSmallBlizz, 2, 750); + } + if (aTinyBlizz != null) { + EntityUtils.registerDropsForMob(aColdBlaze, aTinyBlizz, 4, 1500); + } + if (aSmallCryo != null) { + EntityUtils.registerDropsForMob(aColdBlaze, aSmallCryo, 1, 50); + } + if (aTinyCryo != null) { + EntityUtils.registerDropsForMob(aColdBlaze, aTinyCryo, 2, 100); + } + } + } + + protected final AutoMap> mItemRenderMappings = new AutoMap>(); + + public static void registerItemRendererGlobal(Item aItem, IItemRenderer aRenderer) { + GTplusplus.proxy.registerItemRenderer(aItem, aRenderer); + } + + public void registerItemRenderer(Item aItem, IItemRenderer aRenderer) { + if (Utils.isServer()) { + return; + } else { + mItemRenderMappings.add(new Pair(aItem, aRenderer)); + } + } + + public World getClientWorld() { + return null; + } + + /** + * Returns a side-appropriate EntityPlayer for use during message handling + */ + public EntityPlayer getPlayerEntity(MessageContext ctx) { + return ctx.getServerHandler().playerEntity; + } } diff --git a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_Baubles.java b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_Baubles.java index c9704603af..4af788a9df 100644 --- a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_Baubles.java +++ b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_Baubles.java @@ -21,51 +21,56 @@ import net.minecraft.entity.monster.EntityZombie; public class COMPAT_Baubles { - public static void run(){ - if (LoadedMods.Baubles){ - baublesLoaded(); - } - else { - baublesNotLoaded(); - } - } + public static void run() { + if (LoadedMods.Baubles) { + baublesLoaded(); + } else { + baublesNotLoaded(); + } + } - public static void baublesLoaded(){ - Logger.INFO("Baubles Found - Loading Wearables."); - ModItems.itemPersonalCloakingDevice = new ItemCloakingDevice(0); - //itemPersonalCloakingDeviceCharged = new ItemCloakingDevice(0).set; - ModItems.itemPersonalHealingDevice = new ItemHealingDevice(); - ModItems.itemPersonalFireProofDevice = new FireProtectionBauble(); + public static void baublesLoaded() { + Logger.INFO("Baubles Found - Loading Wearables."); + ModItems.itemPersonalCloakingDevice = new ItemCloakingDevice(0); + // itemPersonalCloakingDeviceCharged = new ItemCloakingDevice(0).set; + ModItems.itemPersonalHealingDevice = new ItemHealingDevice(); + ModItems.itemPersonalFireProofDevice = new FireProtectionBauble(); - try { - ModItems.itemChargePack_Low_1 = new BatteryPackBaseBauble(1); - ModItems.itemChargePack_Low_2 = new BatteryPackBaseBauble(2); - ModItems.itemChargePack_Low_3 = new BatteryPackBaseBauble(3); - ModItems.itemChargePack_Low_4 = new BatteryPackBaseBauble(4); - ModItems.itemChargePack_Low_5 = new BatteryPackBaseBauble(5); - ModItems.itemChargePack_High_1 = new BatteryPackBaseBauble(6); - ModItems.itemChargePack_High_2 = new BatteryPackBaseBauble(7); - ModItems.itemChargePack_High_3 = new BatteryPackBaseBauble(8); - ModItems.itemChargePack_High_4 = new BatteryPackBaseBauble(9); - } - catch (Throwable t) { - t.printStackTrace(); - } + try { + ModItems.itemChargePack_Low_1 = new BatteryPackBaseBauble(1); + ModItems.itemChargePack_Low_2 = new BatteryPackBaseBauble(2); + ModItems.itemChargePack_Low_3 = new BatteryPackBaseBauble(3); + ModItems.itemChargePack_Low_4 = new BatteryPackBaseBauble(4); + ModItems.itemChargePack_Low_5 = new BatteryPackBaseBauble(5); + ModItems.itemChargePack_High_1 = new BatteryPackBaseBauble(6); + ModItems.itemChargePack_High_2 = new BatteryPackBaseBauble(7); + ModItems.itemChargePack_High_3 = new BatteryPackBaseBauble(8); + ModItems.itemChargePack_High_4 = new BatteryPackBaseBauble(9); + } catch (Throwable t) { + t.printStackTrace(); + } - ModItems.itemAmuletMonsterKiller_Zombie = new MonsterKillerBaseBauble(new Class[] {EntityZombie.class}, "Zombie", 3); - ModItems.itemAmuletMonsterKiller_Skeleton = new MonsterKillerBaseBauble(new Class[] {EntitySkeleton.class}, "Skeleton", 3); - ModItems.itemAmuletMonsterKiller_Spider = new MonsterKillerBaseBauble(new Class[] {EntitySpider.class}, "Spider", 3); - ModItems.itemAmuletMonsterKiller_Creeper = new MonsterKillerBaseBauble(new Class[] {EntityCreeper.class}, "Creeper", 4); - ModItems.itemAmuletMonsterKiller_Enderman = new MonsterKillerBaseBauble(new Class[] {EntityEnderman.class}, "Enderman", 4); - ModItems.itemAmuletMonsterKiller_Nether = new MonsterKillerBaseBauble(new Class[] {EntityPigZombie.class, EntityGhast.class, EntityMagmaCube.class, EntityBlaze.class}, "Hellish", 6); - - if (LoadedMods.PlayerAPI){ - ModItems.itemSlowBuildingRing = new ItemSlowBuildingRing(); - } - } + ModItems.itemAmuletMonsterKiller_Zombie = + new MonsterKillerBaseBauble(new Class[] {EntityZombie.class}, "Zombie", 3); + ModItems.itemAmuletMonsterKiller_Skeleton = + new MonsterKillerBaseBauble(new Class[] {EntitySkeleton.class}, "Skeleton", 3); + ModItems.itemAmuletMonsterKiller_Spider = + new MonsterKillerBaseBauble(new Class[] {EntitySpider.class}, "Spider", 3); + ModItems.itemAmuletMonsterKiller_Creeper = + new MonsterKillerBaseBauble(new Class[] {EntityCreeper.class}, "Creeper", 4); + ModItems.itemAmuletMonsterKiller_Enderman = + new MonsterKillerBaseBauble(new Class[] {EntityEnderman.class}, "Enderman", 4); + ModItems.itemAmuletMonsterKiller_Nether = new MonsterKillerBaseBauble( + new Class[] {EntityPigZombie.class, EntityGhast.class, EntityMagmaCube.class, EntityBlaze.class}, + "Hellish", + 6); - public static void baublesNotLoaded(){ - Logger.INFO("Baubles Not Found - Skipping Resources."); - } + if (LoadedMods.PlayerAPI) { + ModItems.itemSlowBuildingRing = new ItemSlowBuildingRing(); + } + } + public static void baublesNotLoaded() { + Logger.INFO("Baubles Not Found - Skipping Resources."); + } } diff --git a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_BigReactors.java b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_BigReactors.java index 3854f6612f..fcaf76e81c 100644 --- a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_BigReactors.java +++ b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_BigReactors.java @@ -1,21 +1,18 @@ package gtPlusPlus.core.common.compat; -import net.minecraft.item.ItemStack; - import gregtech.api.util.GT_OreDictUnificator; - import gtPlusPlus.core.item.ModItems; +import net.minecraft.item.ItemStack; public class COMPAT_BigReactors { - public static void OreDict(){ - run(); - } - - private static final void run(){ - GT_OreDictUnificator.registerOre("plateBlutonium", new ItemStack(ModItems.itemPlateBlutonium)); - GT_OreDictUnificator.registerOre("plateCyanite", new ItemStack(ModItems.itemPlateCyanite)); - GT_OreDictUnificator.registerOre("plateLudicrite", new ItemStack(ModItems.itemPlateLudicrite)); - } + public static void OreDict() { + run(); + } + private static final void run() { + GT_OreDictUnificator.registerOre("plateBlutonium", new ItemStack(ModItems.itemPlateBlutonium)); + GT_OreDictUnificator.registerOre("plateCyanite", new ItemStack(ModItems.itemPlateCyanite)); + GT_OreDictUnificator.registerOre("plateLudicrite", new ItemStack(ModItems.itemPlateLudicrite)); + } } diff --git a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_CompactWindmills.java b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_CompactWindmills.java index cd5d36b653..3f097eed4a 100644 --- a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_CompactWindmills.java +++ b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_CompactWindmills.java @@ -2,171 +2,219 @@ package gtPlusPlus.core.common.compat; import static gtPlusPlus.core.handler.COMPAT_HANDLER.*; -import net.minecraft.item.ItemStack; - import gtPlusPlus.core.recipe.ShapedRecipeObject; import gtPlusPlus.core.util.minecraft.ItemUtils; - - +import net.minecraft.item.ItemStack; public class COMPAT_CompactWindmills { - //Change IC2 Upgrades - public static ItemStack kineticWind = ItemUtils.simpleMetaStack("IC2:blockKineticGenerator", 0, 1); - public static ItemStack shaftIron = ItemUtils.simpleMetaStack("IC2:itemRecipePart", 11, 1); - public static ItemStack cableCopper = ItemUtils.simpleMetaStack("gregtech:gt.blockmachines", 1367, 1); - public static String plateRubber = "ore:plateRubber"; - - //Machine Casings - public static ItemStack elvCasing = ItemUtils.simpleMetaStack("gregtech:gt.blockcasings", 0, 1); - public static ItemStack lvCasing = ItemUtils.simpleMetaStack("gregtech:gt.blockcasings", 1, 1); - public static ItemStack mvCasing = ItemUtils.simpleMetaStack("gregtech:gt.blockcasings", 2, 1); - public static ItemStack hvCasing = ItemUtils.simpleMetaStack("gregtech:gt.blockcasings", 3, 1); - public static ItemStack evCasing = ItemUtils.simpleMetaStack("gregtech:gt.blockcasings", 4, 1); - public static ItemStack ivCasing = ItemUtils.simpleMetaStack("gregtech:gt.blockcasings", 5, 1); - - //GT Transformers - public static ItemStack elvTransformer = ItemUtils.simpleMetaStack("gregtech:gt.blockmachines", 20, 1); - public static ItemStack lvTransformer = ItemUtils.simpleMetaStack("gregtech:gt.blockmachines", 21, 1); - public static ItemStack mvTransformer = ItemUtils.simpleMetaStack("gregtech:gt.blockmachines", 22, 1); - public static ItemStack hvTransformer = ItemUtils.simpleMetaStack("gregtech:gt.blockmachines", 23, 1); - public static ItemStack evTransformer = ItemUtils.simpleMetaStack("gregtech:gt.blockmachines", 24, 1); - - //Compact Windmills - public static ItemStack elvWindmill = ItemUtils.simpleMetaStack("CompactWindmills:blockCompactWindmill", 0, 1); - public static ItemStack lvWindmill = ItemUtils.simpleMetaStack("CompactWindmills:blockCompactWindmill", 1, 1); - public static ItemStack mvWindmill = ItemUtils.simpleMetaStack("CompactWindmills:blockCompactWindmill", 2, 1); - public static ItemStack hvWindmill = ItemUtils.simpleMetaStack("CompactWindmills:blockCompactWindmill", 3, 1); - public static ItemStack evWindmill = ItemUtils.simpleMetaStack("CompactWindmills:blockCompactWindmill", 4, 1); - - //Compact Rotors - public static ItemStack rotor2 = ItemUtils.getItemStackFromFQRN("CompactWindmills:WOOL", 1); - public static ItemStack rotor1 = ItemUtils.getItemStackFromFQRN("CompactWindmills:WOOD", 1); - public static ItemStack rotor3 = ItemUtils.getItemStackFromFQRN("CompactWindmills:ALLOY", 1); - public static ItemStack rotor4 = ItemUtils.getItemStackFromFQRN("CompactWindmills:CARBON", 1); - public static ItemStack rotor5 = ItemUtils.getItemStackFromFQRN("CompactWindmills:IRIDIUM", 1); - - //IC2 Rotors - public static ItemStack rotorIC1 = ItemUtils.getItemStackFromFQRN("IC2:itemwoodrotor", 1); - public static ItemStack rotorIC2 = ItemUtils.getItemStackFromFQRN("IC2:itemironrotor", 1); - public static ItemStack rotorIC3 = ItemUtils.getItemStackFromFQRN("IC2:itemsteelrotor", 1); - public static ItemStack rotorIC4 = ItemUtils.getItemStackFromFQRN("IC2:itemwcarbonrotor", 1); - public static ItemStack rotorBlade1 = ItemUtils.simpleMetaStack("IC2:itemRecipePart", 7, 1); - public static ItemStack rotorBlade2 = ItemUtils.simpleMetaStack("IC2:itemRecipePart", 8, 1); - public static ItemStack rotorBlade3 = ItemUtils.simpleMetaStack("IC2:itemRecipePart", 10, 1); - public static ItemStack rotorBlade4 = ItemUtils.simpleMetaStack("IC2:itemRecipePart", 9, 1); - - //Plates - public static String plateTier1 = "ore:plateMagnalium"; - public static String plateTier2 = "ore:plateStainlessSteel"; - public static String plateTier3 = "ore:plateTitanium"; - public static String plateTier4 = "ore:plateTungstenSteel"; - public static String plateTier5 = "ore:plateNichrome"; - public static String plateCarbon = "ore:plateAlloyCarbon"; - public static String plateAlloy = "ore:plateAlloyAdvanced"; - - //Circuits - public static String circuitTier1 = "ore:circuitGood"; - public static String circuitTier2 = "ore:circuitAdvanced"; - public static String circuitTier3 = "ore:circuitData"; - public static String circuitTier4 = "ore:circuitElite"; - public static String circuitTier5 = "ore:circuitMaster"; - - //Wooden Rotor - public static ShapedRecipeObject Wooden_Rotor = new ShapedRecipeObject( - rotorBlade1, "ore:plateAnyIron", "ore:plateAnyIron", - "ore:screwAluminium", rotorIC1, "ore:screwAluminium", - rotorBlade1, "plateAnyIron", rotorBlade1, - rotor1); - //Alloy Rotor - public static ShapedRecipeObject Alloy_Rotor = new ShapedRecipeObject( - plateAlloy, plateAlloy, plateAlloy, - plateAlloy, rotorIC3, plateAlloy, - plateAlloy,plateAlloy, plateAlloy, - rotor3); - //Carbon Rotor - public static ShapedRecipeObject Carbon_Rotor = new ShapedRecipeObject( - plateCarbon, rotorBlade4, plateCarbon, - rotorBlade4, rotor3, rotorBlade4, - plateCarbon, rotorBlade4, plateCarbon, - rotor4); - - //Kinetic Wind Turbine - public static ShapedRecipeObject KWT = new ShapedRecipeObject( - plateCarbon, shaftIron, plateCarbon, - cableCopper, mvCasing, cableCopper, - plateRubber, plateCarbon, plateRubber, - kineticWind); - - //ELV Windmill - public static ShapedRecipeObject WM_ELV = new ShapedRecipeObject( - - circuitTier1, elvTransformer, circuitTier1, - plateTier1, lvCasing, plateTier1, - plateTier1, rotor1, plateTier1, - elvWindmill); - - - //LV Windmill - public static ShapedRecipeObject WM_LV = new ShapedRecipeObject( - circuitTier2, lvTransformer, circuitTier2, - plateTier2, mvCasing, plateTier2, - plateTier2, rotor2, plateTier2, - lvWindmill); - - //MV Windmill - public static ShapedRecipeObject WM_MV = new ShapedRecipeObject( - circuitTier3, mvTransformer, circuitTier3, - plateTier3, hvCasing, plateTier3, - plateTier3, rotor3, plateTier3, - mvWindmill); - - //HV Windmill - public static ShapedRecipeObject WM_HV = new ShapedRecipeObject( - circuitTier4, hvTransformer, circuitTier4, - plateTier4, evCasing, plateTier4, - plateTier4, rotor4, plateTier4, - hvWindmill); - - //EV Windmill - public static ShapedRecipeObject WM_EV = new ShapedRecipeObject( - circuitTier5, evTransformer, circuitTier5, - plateTier5, ivCasing, plateTier5, - plateTier5, rotor5, plateTier5, - evWindmill); - - public static void OreDict(){ - run(); - } - - private static final void run(){ - //RemoveRecipeQueue.add("CompactWindmills:WOOL"); - //RemoveRecipeQueue.add("CompactWindmills:WOOD"); - //RemoveRecipeQueue.add("CompactWindmills:ALLOY"); - //RemoveRecipeQueue.add("CompactWindmills:CARBON"); - //RemoveRecipeQueue.add("CompactWindmills:IRIDIUM"); - - //Remove Recipes - RemoveRecipeQueue.add(kineticWind); - RemoveRecipeQueue.add(elvWindmill); - RemoveRecipeQueue.add(lvWindmill); - RemoveRecipeQueue.add(mvWindmill); - RemoveRecipeQueue.add(hvWindmill); - RemoveRecipeQueue.add(evWindmill); - RemoveRecipeQueue.add(rotor1); - RemoveRecipeQueue.add(rotor3); - RemoveRecipeQueue.add(rotor4); - - //Add Recipes - AddRecipeQueue.add(Wooden_Rotor); - AddRecipeQueue.add(Alloy_Rotor); - AddRecipeQueue.add(Carbon_Rotor); - AddRecipeQueue.add(KWT); - AddRecipeQueue.add(WM_ELV); - AddRecipeQueue.add(WM_LV); - AddRecipeQueue.add(WM_MV); - AddRecipeQueue.add(WM_HV); - AddRecipeQueue.add(WM_EV); - - } + // Change IC2 Upgrades + public static ItemStack kineticWind = ItemUtils.simpleMetaStack("IC2:blockKineticGenerator", 0, 1); + public static ItemStack shaftIron = ItemUtils.simpleMetaStack("IC2:itemRecipePart", 11, 1); + public static ItemStack cableCopper = ItemUtils.simpleMetaStack("gregtech:gt.blockmachines", 1367, 1); + public static String plateRubber = "ore:plateRubber"; + + // Machine Casings + public static ItemStack elvCasing = ItemUtils.simpleMetaStack("gregtech:gt.blockcasings", 0, 1); + public static ItemStack lvCasing = ItemUtils.simpleMetaStack("gregtech:gt.blockcasings", 1, 1); + public static ItemStack mvCasing = ItemUtils.simpleMetaStack("gregtech:gt.blockcasings", 2, 1); + public static ItemStack hvCasing = ItemUtils.simpleMetaStack("gregtech:gt.blockcasings", 3, 1); + public static ItemStack evCasing = ItemUtils.simpleMetaStack("gregtech:gt.blockcasings", 4, 1); + public static ItemStack ivCasing = ItemUtils.simpleMetaStack("gregtech:gt.blockcasings", 5, 1); + + // GT Transformers + public static ItemStack elvTransformer = ItemUtils.simpleMetaStack("gregtech:gt.blockmachines", 20, 1); + public static ItemStack lvTransformer = ItemUtils.simpleMetaStack("gregtech:gt.blockmachines", 21, 1); + public static ItemStack mvTransformer = ItemUtils.simpleMetaStack("gregtech:gt.blockmachines", 22, 1); + public static ItemStack hvTransformer = ItemUtils.simpleMetaStack("gregtech:gt.blockmachines", 23, 1); + public static ItemStack evTransformer = ItemUtils.simpleMetaStack("gregtech:gt.blockmachines", 24, 1); + + // Compact Windmills + public static ItemStack elvWindmill = ItemUtils.simpleMetaStack("CompactWindmills:blockCompactWindmill", 0, 1); + public static ItemStack lvWindmill = ItemUtils.simpleMetaStack("CompactWindmills:blockCompactWindmill", 1, 1); + public static ItemStack mvWindmill = ItemUtils.simpleMetaStack("CompactWindmills:blockCompactWindmill", 2, 1); + public static ItemStack hvWindmill = ItemUtils.simpleMetaStack("CompactWindmills:blockCompactWindmill", 3, 1); + public static ItemStack evWindmill = ItemUtils.simpleMetaStack("CompactWindmills:blockCompactWindmill", 4, 1); + + // Compact Rotors + public static ItemStack rotor2 = ItemUtils.getItemStackFromFQRN("CompactWindmills:WOOL", 1); + public static ItemStack rotor1 = ItemUtils.getItemStackFromFQRN("CompactWindmills:WOOD", 1); + public static ItemStack rotor3 = ItemUtils.getItemStackFromFQRN("CompactWindmills:ALLOY", 1); + public static ItemStack rotor4 = ItemUtils.getItemStackFromFQRN("CompactWindmills:CARBON", 1); + public static ItemStack rotor5 = ItemUtils.getItemStackFromFQRN("CompactWindmills:IRIDIUM", 1); + + // IC2 Rotors + public static ItemStack rotorIC1 = ItemUtils.getItemStackFromFQRN("IC2:itemwoodrotor", 1); + public static ItemStack rotorIC2 = ItemUtils.getItemStackFromFQRN("IC2:itemironrotor", 1); + public static ItemStack rotorIC3 = ItemUtils.getItemStackFromFQRN("IC2:itemsteelrotor", 1); + public static ItemStack rotorIC4 = ItemUtils.getItemStackFromFQRN("IC2:itemwcarbonrotor", 1); + public static ItemStack rotorBlade1 = ItemUtils.simpleMetaStack("IC2:itemRecipePart", 7, 1); + public static ItemStack rotorBlade2 = ItemUtils.simpleMetaStack("IC2:itemRecipePart", 8, 1); + public static ItemStack rotorBlade3 = ItemUtils.simpleMetaStack("IC2:itemRecipePart", 10, 1); + public static ItemStack rotorBlade4 = ItemUtils.simpleMetaStack("IC2:itemRecipePart", 9, 1); + + // Plates + public static String plateTier1 = "ore:plateMagnalium"; + public static String plateTier2 = "ore:plateStainlessSteel"; + public static String plateTier3 = "ore:plateTitanium"; + public static String plateTier4 = "ore:plateTungstenSteel"; + public static String plateTier5 = "ore:plateNichrome"; + public static String plateCarbon = "ore:plateAlloyCarbon"; + public static String plateAlloy = "ore:plateAlloyAdvanced"; + + // Circuits + public static String circuitTier1 = "ore:circuitGood"; + public static String circuitTier2 = "ore:circuitAdvanced"; + public static String circuitTier3 = "ore:circuitData"; + public static String circuitTier4 = "ore:circuitElite"; + public static String circuitTier5 = "ore:circuitMaster"; + + // Wooden Rotor + public static ShapedRecipeObject Wooden_Rotor = new ShapedRecipeObject( + rotorBlade1, + "ore:plateAnyIron", + "ore:plateAnyIron", + "ore:screwAluminium", + rotorIC1, + "ore:screwAluminium", + rotorBlade1, + "plateAnyIron", + rotorBlade1, + rotor1); + // Alloy Rotor + public static ShapedRecipeObject Alloy_Rotor = new ShapedRecipeObject( + plateAlloy, + plateAlloy, + plateAlloy, + plateAlloy, + rotorIC3, + plateAlloy, + plateAlloy, + plateAlloy, + plateAlloy, + rotor3); + // Carbon Rotor + public static ShapedRecipeObject Carbon_Rotor = new ShapedRecipeObject( + plateCarbon, + rotorBlade4, + plateCarbon, + rotorBlade4, + rotor3, + rotorBlade4, + plateCarbon, + rotorBlade4, + plateCarbon, + rotor4); + + // Kinetic Wind Turbine + public static ShapedRecipeObject KWT = new ShapedRecipeObject( + plateCarbon, + shaftIron, + plateCarbon, + cableCopper, + mvCasing, + cableCopper, + plateRubber, + plateCarbon, + plateRubber, + kineticWind); + + // ELV Windmill + public static ShapedRecipeObject WM_ELV = new ShapedRecipeObject( + circuitTier1, + elvTransformer, + circuitTier1, + plateTier1, + lvCasing, + plateTier1, + plateTier1, + rotor1, + plateTier1, + elvWindmill); + + // LV Windmill + public static ShapedRecipeObject WM_LV = new ShapedRecipeObject( + circuitTier2, + lvTransformer, + circuitTier2, + plateTier2, + mvCasing, + plateTier2, + plateTier2, + rotor2, + plateTier2, + lvWindmill); + + // MV Windmill + public static ShapedRecipeObject WM_MV = new ShapedRecipeObject( + circuitTier3, + mvTransformer, + circuitTier3, + plateTier3, + hvCasing, + plateTier3, + plateTier3, + rotor3, + plateTier3, + mvWindmill); + + // HV Windmill + public static ShapedRecipeObject WM_HV = new ShapedRecipeObject( + circuitTier4, + hvTransformer, + circuitTier4, + plateTier4, + evCasing, + plateTier4, + plateTier4, + rotor4, + plateTier4, + hvWindmill); + + // EV Windmill + public static ShapedRecipeObject WM_EV = new ShapedRecipeObject( + circuitTier5, + evTransformer, + circuitTier5, + plateTier5, + ivCasing, + plateTier5, + plateTier5, + rotor5, + plateTier5, + evWindmill); + + public static void OreDict() { + run(); + } + + private static final void run() { + // RemoveRecipeQueue.add("CompactWindmills:WOOL"); + // RemoveRecipeQueue.add("CompactWindmills:WOOD"); + // RemoveRecipeQueue.add("CompactWindmills:ALLOY"); + // RemoveRecipeQueue.add("CompactWindmills:CARBON"); + // RemoveRecipeQueue.add("CompactWindmills:IRIDIUM"); + + // Remove Recipes + RemoveRecipeQueue.add(kineticWind); + RemoveRecipeQueue.add(elvWindmill); + RemoveRecipeQueue.add(lvWindmill); + RemoveRecipeQueue.add(mvWindmill); + RemoveRecipeQueue.add(hvWindmill); + RemoveRecipeQueue.add(evWindmill); + RemoveRecipeQueue.add(rotor1); + RemoveRecipeQueue.add(rotor3); + RemoveRecipeQueue.add(rotor4); + + // Add Recipes + AddRecipeQueue.add(Wooden_Rotor); + AddRecipeQueue.add(Alloy_Rotor); + AddRecipeQueue.add(Carbon_Rotor); + AddRecipeQueue.add(KWT); + AddRecipeQueue.add(WM_ELV); + AddRecipeQueue.add(WM_LV); + AddRecipeQueue.add(WM_MV); + AddRecipeQueue.add(WM_HV); + AddRecipeQueue.add(WM_EV); + } } diff --git a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_EnderIO.java b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_EnderIO.java index 6598a7e21e..31c2943f24 100644 --- a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_EnderIO.java +++ b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_EnderIO.java @@ -1,28 +1,25 @@ package gtPlusPlus.core.common.compat; -import net.minecraft.item.ItemStack; - import gregtech.api.util.GT_OreDictUnificator; - import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.item.ItemStack; public class COMPAT_EnderIO { - public static void OreDict(){ - run(); - } - - private static final void run(){ - ItemUtils.getItemForOreDict("EnderIO:itemAlloy", "ingotVibrantAlloy", "Vibrant Alloy Ingot", 2); - GT_OreDictUnificator.registerOre("plateConductiveIron", new ItemStack(ModItems.itemPlateConductiveIron)); - GT_OreDictUnificator.registerOre("plateDarkSteel", new ItemStack(ModItems.itemPlateDarkSteel)); - GT_OreDictUnificator.registerOre("plateElectricalSteel", new ItemStack(ModItems.itemPlateElectricalSteel)); - GT_OreDictUnificator.registerOre("plateEnergeticAlloy", new ItemStack(ModItems.itemPlateEnergeticAlloy)); - GT_OreDictUnificator.registerOre("platePulsatingIron", new ItemStack(ModItems.itemPlatePulsatingIron)); - GT_OreDictUnificator.registerOre("plateRedstoneAlloy", new ItemStack(ModItems.itemPlateRedstoneAlloy)); - GT_OreDictUnificator.registerOre("plateSoularium", new ItemStack(ModItems.itemPlateSoularium)); - GT_OreDictUnificator.registerOre("plateVibrantAlloy", new ItemStack(ModItems.itemPlateVibrantAlloy)); - } + public static void OreDict() { + run(); + } + private static final void run() { + ItemUtils.getItemForOreDict("EnderIO:itemAlloy", "ingotVibrantAlloy", "Vibrant Alloy Ingot", 2); + GT_OreDictUnificator.registerOre("plateConductiveIron", new ItemStack(ModItems.itemPlateConductiveIron)); + GT_OreDictUnificator.registerOre("plateDarkSteel", new ItemStack(ModItems.itemPlateDarkSteel)); + GT_OreDictUnificator.registerOre("plateElectricalSteel", new ItemStack(ModItems.itemPlateElectricalSteel)); + GT_OreDictUnificator.registerOre("plateEnergeticAlloy", new ItemStack(ModItems.itemPlateEnergeticAlloy)); + GT_OreDictUnificator.registerOre("platePulsatingIron", new ItemStack(ModItems.itemPlatePulsatingIron)); + GT_OreDictUnificator.registerOre("plateRedstoneAlloy", new ItemStack(ModItems.itemPlateRedstoneAlloy)); + GT_OreDictUnificator.registerOre("plateSoularium", new ItemStack(ModItems.itemPlateSoularium)); + GT_OreDictUnificator.registerOre("plateVibrantAlloy", new ItemStack(ModItems.itemPlateVibrantAlloy)); + } } diff --git a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_ExtraUtils.java b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_ExtraUtils.java index d5ee51f61a..70c342453c 100644 --- a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_ExtraUtils.java +++ b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_ExtraUtils.java @@ -1,32 +1,35 @@ package gtPlusPlus.core.common.compat; -import net.minecraft.item.ItemStack; - import gtPlusPlus.core.lib.CORE.ConfigSwitches; import gtPlusPlus.core.recipe.RECIPES_Tools; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.RecipeUtils; +import net.minecraft.item.ItemStack; public class COMPAT_ExtraUtils { - public static void OreDict(){ - RECIPES_Tools.RECIPE_DivisionSigil = new ItemStack(ItemUtils.getItemFromFQRN("ExtraUtilities:divisionSigil")); - run(); - - } - - private static final void run(){ - ItemUtils.getItemForOreDict("ExtraUtilities:bedrockiumIngot", "ingotBedrockium", "Bedrockium Ingot", 0); - //GT_OreDictUnificator.registerOre("plateBedrockium", new ItemStack(ModItems.itemPlateBedrockium)); - - if (ConfigSwitches.enableAlternativeDivisionSigilRecipe){ - //Division Sigil - RecipeUtils.addShapedRecipe( - "plateNetherStar", "gemIridium", "plateNetherStar", - "plateIridium", RECIPES_Tools.craftingToolHardHammer, "plateIridium", - "plateNetherStar", "gemIridium", "plateNetherStar", - RECIPES_Tools.RECIPE_DivisionSigil); - } - } - + public static void OreDict() { + RECIPES_Tools.RECIPE_DivisionSigil = new ItemStack(ItemUtils.getItemFromFQRN("ExtraUtilities:divisionSigil")); + run(); + } + + private static final void run() { + ItemUtils.getItemForOreDict("ExtraUtilities:bedrockiumIngot", "ingotBedrockium", "Bedrockium Ingot", 0); + // GT_OreDictUnificator.registerOre("plateBedrockium", new ItemStack(ModItems.itemPlateBedrockium)); + + if (ConfigSwitches.enableAlternativeDivisionSigilRecipe) { + // Division Sigil + RecipeUtils.addShapedRecipe( + "plateNetherStar", + "gemIridium", + "plateNetherStar", + "plateIridium", + RECIPES_Tools.craftingToolHardHammer, + "plateIridium", + "plateNetherStar", + "gemIridium", + "plateNetherStar", + RECIPES_Tools.RECIPE_DivisionSigil); + } + } } diff --git a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_HarvestCraft.java b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_HarvestCraft.java index 9e148f0102..fa2beb54ad 100644 --- a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_HarvestCraft.java +++ b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_HarvestCraft.java @@ -4,12 +4,11 @@ import gtPlusPlus.xmod.growthcraft.fishtrap.FishTrapHandler; public class COMPAT_HarvestCraft { - public static void OreDict(){ - run(); - } - - private static final void run(){ - FishTrapHandler.pamsHarvestCraftCompat(); - } + public static void OreDict() { + run(); + } + private static final void run() { + FishTrapHandler.pamsHarvestCraftCompat(); + } } diff --git a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_IC2.java b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_IC2.java index e1ed2a666a..1169473d85 100644 --- a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_IC2.java +++ b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_IC2.java @@ -1,64 +1,68 @@ package gtPlusPlus.core.common.compat; - import static gtPlusPlus.core.handler.COMPAT_HANDLER.RemoveRecipeQueue; -import net.minecraft.item.ItemStack; - import gtPlusPlus.core.lib.CORE.ConfigSwitches; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.recipe.ShapedRecipeObject; import gtPlusPlus.core.util.minecraft.ItemUtils; - +import net.minecraft.item.ItemStack; public class COMPAT_IC2 { - private static ItemStack itemCropnalyzer = ItemUtils.simpleMetaStack("IC2:itemCropnalyzer", 0, 1); - private static ItemStack itemSolarHelmet = ItemUtils.simpleMetaStack("IC2:itemSolarHelmet", 0, 1); - - public static ShapedRecipeObject Cropnalyzer = new ShapedRecipeObject( - "ore:cableGt02Copper", "ore:cableGt02Copper", null, - "minecraft:redstone", "ore:blockGlass", "minecraft:redstone", - "minecraft:redstone", "ore:circuitBasic", "minecraft:redstone", - itemCropnalyzer); - public static ShapedRecipeObject SolarHelmet = new ShapedRecipeObject( - "ore:plateIron", "ore:plateIron", "ore:plateIron", - "ore:plateIron", "gregtech:gt.metaitem.01:32750", "ore:plateIron", - "ore:craftingWireCopper", "ore:craftingWireCopper", "ore:craftingWireCopper", - itemSolarHelmet); - - - - public static void OreDict(){ - //Get ItemStacks for results - /*itemCropnalyzer = UtilsItems.getItemStack("IC2:itemCropnalyzer", 1); - itemSolarHelmet = UtilsItems.getItemStack("IC2:itemSolarHelmet", 1); */ - run(); - } - - private static final void run(){ - - if (ConfigSwitches.disableIC2Recipes){ - - - - if (LoadedMods.Gregtech){ - //Fuck these right off. - RemoveRecipeQueue.add("IC2:itemCable"); - RemoveRecipeQueue.add("IC2:itemCable:1"); - RemoveRecipeQueue.add("IC2:itemCable:2"); - RemoveRecipeQueue.add("IC2:itemCable:3"); - RemoveRecipeQueue.add("IC2:itemCable:5"); - RemoveRecipeQueue.add("IC2:itemCable:6"); - RemoveRecipeQueue.add("IC2:itemCable:10"); - RemoveRecipeQueue.add("IC2:itemCable:13"); - //RemoveRecipeQueue.add(itemCropnalyzer); - //RemoveRecipeQueue.add(itemSolarHelmet); - - //AddRecipeQueue.add(Cropnalyzer); - //AddRecipeQueue.add(SolarHelmet); - } - } - } - + private static ItemStack itemCropnalyzer = ItemUtils.simpleMetaStack("IC2:itemCropnalyzer", 0, 1); + private static ItemStack itemSolarHelmet = ItemUtils.simpleMetaStack("IC2:itemSolarHelmet", 0, 1); + + public static ShapedRecipeObject Cropnalyzer = new ShapedRecipeObject( + "ore:cableGt02Copper", + "ore:cableGt02Copper", + null, + "minecraft:redstone", + "ore:blockGlass", + "minecraft:redstone", + "minecraft:redstone", + "ore:circuitBasic", + "minecraft:redstone", + itemCropnalyzer); + public static ShapedRecipeObject SolarHelmet = new ShapedRecipeObject( + "ore:plateIron", + "ore:plateIron", + "ore:plateIron", + "ore:plateIron", + "gregtech:gt.metaitem.01:32750", + "ore:plateIron", + "ore:craftingWireCopper", + "ore:craftingWireCopper", + "ore:craftingWireCopper", + itemSolarHelmet); + + public static void OreDict() { + // Get ItemStacks for results + /*itemCropnalyzer = UtilsItems.getItemStack("IC2:itemCropnalyzer", 1); + itemSolarHelmet = UtilsItems.getItemStack("IC2:itemSolarHelmet", 1); */ + run(); + } + + private static final void run() { + + if (ConfigSwitches.disableIC2Recipes) { + + if (LoadedMods.Gregtech) { + // Fuck these right off. + RemoveRecipeQueue.add("IC2:itemCable"); + RemoveRecipeQueue.add("IC2:itemCable:1"); + RemoveRecipeQueue.add("IC2:itemCable:2"); + RemoveRecipeQueue.add("IC2:itemCable:3"); + RemoveRecipeQueue.add("IC2:itemCable:5"); + RemoveRecipeQueue.add("IC2:itemCable:6"); + RemoveRecipeQueue.add("IC2:itemCable:10"); + RemoveRecipeQueue.add("IC2:itemCable:13"); + // RemoveRecipeQueue.add(itemCropnalyzer); + // RemoveRecipeQueue.add(itemSolarHelmet); + + // AddRecipeQueue.add(Cropnalyzer); + // AddRecipeQueue.add(SolarHelmet); + } + } + } } diff --git a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_MorePlanets.java b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_MorePlanets.java index b7da7c436e..3e9c6da4ec 100644 --- a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_MorePlanets.java +++ b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_MorePlanets.java @@ -4,34 +4,34 @@ import gtPlusPlus.core.util.minecraft.ItemUtils; public class COMPAT_MorePlanets { + public static void OreDict() { + run(); + } - public static void OreDict(){ - run(); - } - - private final static void run(){ - //Metals - ItemUtils.getItemForOreDict("MorePlanet:kapteyn-b_item", "ingotFrozenIron", "Frozen Iron Ingot", 0); - ItemUtils.getItemForOreDict("MorePlanet:kapteyn-b_item", "ingotAnyIron", "Frozen Iron Ingot", 0); - ItemUtils.getItemForOreDict("MorePlanet:polongnius_item", "ingotPalladium", "Palladium Ingot", 5); - ItemUtils.getItemForOreDict("MorePlanet:fronos_item", "ingotIridium", "Iridium Ingot", 3); - ItemUtils.getItemForOreDict("MorePlanet:nibiru_item", "ingotNorium", "Norium Ingot", 1); - ItemUtils.getItemForOreDict("MorePlanet:venus_item", "ingotLead", "Lead Ingot", 0); - ItemUtils.getItemForOreDict("MorePlanet:diona_item", "ingotQuontonium", "Quontonium Ingot", 0); - ItemUtils.getItemForOreDict("MorePlanet:diona_item", "ingotFronisium", "Fronisium Ingot", 1); - ItemUtils.getItemForOreDict("MorePlanet:sirius-b_item", "ingotSulfur", "Sulfur Ingot", 3); - ItemUtils.getItemForOreDict("MorePlanet:koentus_item", "ingotKoentusMeteoricIron", "Koentus Meteoric Iron Ingot", 4); - ItemUtils.getItemForOreDict("MorePlanet:mercury_item", "ingotMetallic", "Metallic Ingot", 2); - ItemUtils.getItemForOreDict("MorePlanet:polongnius_item", "ingotPolongiusMeteoricIron", "Polongius Meteoric Iron Ingot", 4); - ItemUtils.getItemForOreDict("MorePlanet:mercury_item", "ingotMeteoricSteel", "Meteoric Steel Ingot", 3); - ItemUtils.getItemForOreDict("MorePlanet:sirius-b_item", "dustSulfur", "Sulfur Dust", 2); - - //Gems - ItemUtils.getItemForOreDict("MorePlanet:fronos_item", "gemBlackDiamond", "Black Diamond Gem", 2); - ItemUtils.getItemForOreDict("MorePlanet:koentus_item", "gemWhiteCrystal", "White Crystal", 0); - ItemUtils.getItemForOreDict("MorePlanet:nibiru_item", "gemRedCrystal", "Red Crystal", 0); - ItemUtils.getItemForOreDict("MorePlanet:pluto_item", "gemXeonius", "Xeonius Gem", 0); - ItemUtils.getItemForOreDict("MorePlanet:kapteyn-b_item", "gemUranium", "Uranium Gem", 1); - } + private static final void run() { + // Metals + ItemUtils.getItemForOreDict("MorePlanet:kapteyn-b_item", "ingotFrozenIron", "Frozen Iron Ingot", 0); + ItemUtils.getItemForOreDict("MorePlanet:kapteyn-b_item", "ingotAnyIron", "Frozen Iron Ingot", 0); + ItemUtils.getItemForOreDict("MorePlanet:polongnius_item", "ingotPalladium", "Palladium Ingot", 5); + ItemUtils.getItemForOreDict("MorePlanet:fronos_item", "ingotIridium", "Iridium Ingot", 3); + ItemUtils.getItemForOreDict("MorePlanet:nibiru_item", "ingotNorium", "Norium Ingot", 1); + ItemUtils.getItemForOreDict("MorePlanet:venus_item", "ingotLead", "Lead Ingot", 0); + ItemUtils.getItemForOreDict("MorePlanet:diona_item", "ingotQuontonium", "Quontonium Ingot", 0); + ItemUtils.getItemForOreDict("MorePlanet:diona_item", "ingotFronisium", "Fronisium Ingot", 1); + ItemUtils.getItemForOreDict("MorePlanet:sirius-b_item", "ingotSulfur", "Sulfur Ingot", 3); + ItemUtils.getItemForOreDict( + "MorePlanet:koentus_item", "ingotKoentusMeteoricIron", "Koentus Meteoric Iron Ingot", 4); + ItemUtils.getItemForOreDict("MorePlanet:mercury_item", "ingotMetallic", "Metallic Ingot", 2); + ItemUtils.getItemForOreDict( + "MorePlanet:polongnius_item", "ingotPolongiusMeteoricIron", "Polongius Meteoric Iron Ingot", 4); + ItemUtils.getItemForOreDict("MorePlanet:mercury_item", "ingotMeteoricSteel", "Meteoric Steel Ingot", 3); + ItemUtils.getItemForOreDict("MorePlanet:sirius-b_item", "dustSulfur", "Sulfur Dust", 2); + // Gems + ItemUtils.getItemForOreDict("MorePlanet:fronos_item", "gemBlackDiamond", "Black Diamond Gem", 2); + ItemUtils.getItemForOreDict("MorePlanet:koentus_item", "gemWhiteCrystal", "White Crystal", 0); + ItemUtils.getItemForOreDict("MorePlanet:nibiru_item", "gemRedCrystal", "Red Crystal", 0); + ItemUtils.getItemForOreDict("MorePlanet:pluto_item", "gemXeonius", "Xeonius Gem", 0); + ItemUtils.getItemForOreDict("MorePlanet:kapteyn-b_item", "gemUranium", "Uranium Gem", 1); + } } diff --git a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_OpenBlocks.java b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_OpenBlocks.java index 6381a6705e..cade4c4418 100644 --- a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_OpenBlocks.java +++ b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_OpenBlocks.java @@ -1,29 +1,28 @@ package gtPlusPlus.core.common.compat; -import net.minecraft.block.Block; -import net.minecraft.item.Item; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.block.Block; +import net.minecraft.item.Item; public class COMPAT_OpenBlocks { - public static void OreDict(){ - run(); - } + public static void OreDict() { + run(); + } - private static final void run(){ + private static final void run() { - Item aGraveItem = ItemUtils.getItemFromFQRN("OpenBlocks:grave"); - if (aGraveItem == null) { - return; - } - Block aGraveBlock = Block.getBlockFromItem(aGraveItem); - if (aGraveBlock == null) { - return; - } - - Logger.INFO("[Hungry Node Blacklist] Setting the Hardness of the OpenBlocks Grave to 6."); - aGraveBlock.setHardness(6f); - } + Item aGraveItem = ItemUtils.getItemFromFQRN("OpenBlocks:grave"); + if (aGraveItem == null) { + return; + } + Block aGraveBlock = Block.getBlockFromItem(aGraveItem); + if (aGraveBlock == null) { + return; + } + Logger.INFO("[Hungry Node Blacklist] Setting the Hardness of the OpenBlocks Grave to 6."); + aGraveBlock.setHardness(6f); + } } diff --git a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_PlayerAPI.java b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_PlayerAPI.java index 12b3a94083..762ffe79a1 100644 --- a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_PlayerAPI.java +++ b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_PlayerAPI.java @@ -2,51 +2,34 @@ package gtPlusPlus.core.common.compat; import api.player.client.ClientPlayerAPI; import gtPlusPlus.core.common.BasePlayer; -import gtPlusPlus.core.handler.events.SneakManager; -import gtPlusPlus.core.util.Utils; public class COMPAT_PlayerAPI { - public static class commonProxy{ - public static void initPre(){ + public static class commonProxy { + public static void initPre() {} - } + public static void Init() {} - public static void Init(){ + public static void initPost() {} + } - } + public static class clientProxy { + public static void initPre() { + // Utils.registerEvent(SneakManager.instance); + } - public static void initPost(){ + public static void Init() { + ClientPlayerAPI.register("SneakManager", BasePlayer.class); + } - } - } + public static void initPost() {} + } - public static class clientProxy{ - public static void initPre(){ - //Utils.registerEvent(SneakManager.instance); - } + public static class serverProxy { + public static void initPre() {} - public static void Init(){ - ClientPlayerAPI.register("SneakManager", BasePlayer.class); - } - - public static void initPost(){ - - } - } - - public static class serverProxy{ - public static void initPre(){ - - } - - public static void Init(){ - - } - - public static void initPost(){ - - } - } + public static void Init() {} + public static void initPost() {} + } } diff --git a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_PneumaticCraft.java b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_PneumaticCraft.java index 0f80dc8be4..5b29345b9d 100644 --- a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_PneumaticCraft.java +++ b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_PneumaticCraft.java @@ -1,19 +1,16 @@ package gtPlusPlus.core.common.compat; -import net.minecraft.item.ItemStack; - import gregtech.api.util.GT_OreDictUnificator; - import gtPlusPlus.core.item.ModItems; +import net.minecraft.item.ItemStack; public class COMPAT_PneumaticCraft { - public static void OreDict(){ - run(); - } - - private static final void run(){ - GT_OreDictUnificator.registerOre("plateCompressedIron", new ItemStack(ModItems.itemPlateCompressedIron)); - } + public static void OreDict() { + run(); + } + private static final void run() { + GT_OreDictUnificator.registerOre("plateCompressedIron", new ItemStack(ModItems.itemPlateCompressedIron)); + } } diff --git a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_RFTools.java b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_RFTools.java index 37c87ad99d..05e32b21fd 100644 --- a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_RFTools.java +++ b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_RFTools.java @@ -1,20 +1,16 @@ package gtPlusPlus.core.common.compat; -import net.minecraft.item.ItemStack; - import gregtech.api.util.GT_OreDictUnificator; - import gtPlusPlus.core.item.ModItems; +import net.minecraft.item.ItemStack; public class COMPAT_RFTools { - public static void OreDict(){ - run(); - } - - private static final void run(){ - GT_OreDictUnificator.registerOre("plateDimensionShard", new ItemStack(ModItems.itemPlateDimensionShard)); - - } + public static void OreDict() { + run(); + } + private static final void run() { + GT_OreDictUnificator.registerOre("plateDimensionShard", new ItemStack(ModItems.itemPlateDimensionShard)); + } } diff --git a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_Railcraft.java b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_Railcraft.java index f6c8e86808..69fa7674c6 100644 --- a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_Railcraft.java +++ b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_Railcraft.java @@ -2,13 +2,9 @@ package gtPlusPlus.core.common.compat; public class COMPAT_Railcraft { - public static void OreDict(){ - run(); - } - - private static final void run(){ - - - } + public static void OreDict() { + run(); + } + private static final void run() {} } diff --git a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_SimplyJetpacks.java b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_SimplyJetpacks.java index 5f9976acb0..c93d522c40 100644 --- a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_SimplyJetpacks.java +++ b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_SimplyJetpacks.java @@ -1,20 +1,16 @@ package gtPlusPlus.core.common.compat; -import net.minecraft.item.ItemStack; - import gregtech.api.util.GT_OreDictUnificator; - import gtPlusPlus.core.item.ModItems; +import net.minecraft.item.ItemStack; public class COMPAT_SimplyJetpacks { - public static void OreDict(){ - run(); - } - - private static final void run(){ - GT_OreDictUnificator.registerOre("plateEnrichedSoularium", new ItemStack(ModItems.itemPlateEnrichedSoularium)); - - } + public static void OreDict() { + run(); + } + private static final void run() { + GT_OreDictUnificator.registerOre("plateEnrichedSoularium", new ItemStack(ModItems.itemPlateEnrichedSoularium)); + } } diff --git a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_Thaumcraft.java b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_Thaumcraft.java index b78c10c8ce..75e7707a01 100644 --- a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_Thaumcraft.java +++ b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_Thaumcraft.java @@ -1,45 +1,49 @@ package gtPlusPlus.core.common.compat; import gregtech.api.util.GT_OreDictUnificator; - import gtPlusPlus.core.lib.CORE.ConfigSwitches; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.minecraft.ItemUtils; public class COMPAT_Thaumcraft { - public static void OreDict(){ - - if (ConfigSwitches.enableThaumcraftShardUnification){ - run(); - } - } - - private static final void run(){ - - for(int i=0; i<=6; i++){ - //Utils.LOG_INFO(""+i); - ItemUtils.getItemForOreDict("Thaumcraft:ItemShard", "shardAny", "TC Shard "+i, i); - GT_OreDictUnificator.registerOre("shardAny", ItemUtils.getItemStackFromFQRN("Thaumcraft:ItemShard:"+i, 1)); - ItemUtils.getItemForOreDict("Thaumcraft:ItemShard", "gemInfusedAnything", "TC Shard "+i, i); - GT_OreDictUnificator.registerOre("gemInfusedAnything", ItemUtils.getItemStackFromFQRN("Thaumcraft:ItemShard:"+i, 1)); - //System.out.println("TC Shard registration count is: "+i); - } - - if (LoadedMods.ForbiddenMagic){ - for(int i=0; i<=6; i++){ - //Utils.LOG_INFO(""+i); - ItemUtils.getItemForOreDict("ForbiddenMagic:NetherShard", "shardAny", "FM Shard "+i, i); - GT_OreDictUnificator.registerOre("shardAny", ItemUtils.getItemStackFromFQRN("ForbiddenMagic:NetherShard:"+i, 1)); - ItemUtils.getItemForOreDict("ForbiddenMagic:NetherShard", "gemInfusedAnything", "FM Shard "+i, i); - GT_OreDictUnificator.registerOre("gemInfusedAnything", ItemUtils.getItemStackFromFQRN("ForbiddenMagic:NetherShard:"+i, 1)); - //System.out.println("TC Shard registration count is: "+i); - } - ItemUtils.getItemForOreDict("ForbiddenMagic:GluttonyShard", "shardAny", "FM Gluttony Shard", 0); - GT_OreDictUnificator.registerOre("shardAny", ItemUtils.getItemStackFromFQRN("ForbiddenMagic:GluttonyShard", 1)); - ItemUtils.getItemForOreDict("ForbiddenMagic:GluttonyShard", "gemInfusedAnything", "FM Gluttony Shard", 0); - GT_OreDictUnificator.registerOre("gemInfusedAnything", ItemUtils.getItemStackFromFQRN("ForbiddenMagic:GluttonyShard", 1)); - } - } - + public static void OreDict() { + + if (ConfigSwitches.enableThaumcraftShardUnification) { + run(); + } + } + + private static final void run() { + + for (int i = 0; i <= 6; i++) { + // Utils.LOG_INFO(""+i); + ItemUtils.getItemForOreDict("Thaumcraft:ItemShard", "shardAny", "TC Shard " + i, i); + GT_OreDictUnificator.registerOre( + "shardAny", ItemUtils.getItemStackFromFQRN("Thaumcraft:ItemShard:" + i, 1)); + ItemUtils.getItemForOreDict("Thaumcraft:ItemShard", "gemInfusedAnything", "TC Shard " + i, i); + GT_OreDictUnificator.registerOre( + "gemInfusedAnything", ItemUtils.getItemStackFromFQRN("Thaumcraft:ItemShard:" + i, 1)); + // System.out.println("TC Shard registration count is: "+i); + } + + if (LoadedMods.ForbiddenMagic) { + for (int i = 0; i <= 6; i++) { + // Utils.LOG_INFO(""+i); + ItemUtils.getItemForOreDict("ForbiddenMagic:NetherShard", "shardAny", "FM Shard " + i, i); + GT_OreDictUnificator.registerOre( + "shardAny", ItemUtils.getItemStackFromFQRN("ForbiddenMagic:NetherShard:" + i, 1)); + ItemUtils.getItemForOreDict("ForbiddenMagic:NetherShard", "gemInfusedAnything", "FM Shard " + i, i); + GT_OreDictUnificator.registerOre( + "gemInfusedAnything", ItemUtils.getItemStackFromFQRN("ForbiddenMagic:NetherShard:" + i, 1)); + // System.out.println("TC Shard registration count is: "+i); + } + ItemUtils.getItemForOreDict("ForbiddenMagic:GluttonyShard", "shardAny", "FM Gluttony Shard", 0); + GT_OreDictUnificator.registerOre( + "shardAny", ItemUtils.getItemStackFromFQRN("ForbiddenMagic:GluttonyShard", 1)); + ItemUtils.getItemForOreDict("ForbiddenMagic:GluttonyShard", "gemInfusedAnything", "FM Gluttony Shard", 0); + GT_OreDictUnificator.registerOre( + "gemInfusedAnything", ItemUtils.getItemStackFromFQRN("ForbiddenMagic:GluttonyShard", 1)); + } + } } diff --git a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_Witchery.java b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_Witchery.java index cde6e3ae98..9af582e0de 100644 --- a/src/main/java/gtPlusPlus/core/common/compat/COMPAT_Witchery.java +++ b/src/main/java/gtPlusPlus/core/common/compat/COMPAT_Witchery.java @@ -3,24 +3,25 @@ package gtPlusPlus.core.common.compat; import static gtPlusPlus.core.lib.LoadedMods.Witchery; import gregtech.api.util.GT_OreDictUnificator; - import gtPlusPlus.core.util.minecraft.ItemUtils; import net.minecraft.item.ItemStack; public class COMPAT_Witchery { - public static void OreDict(){ - run(); - } - - private static final void run(){ - //Koboldite - ItemStack aKobolditeDust = ItemUtils.getItemStackWithMeta(Witchery, "witchery:ingredient", "Koboldite Dust", 148, 1); - ItemStack aKobolditeNugget = ItemUtils.getItemStackWithMeta(Witchery, "witchery:ingredient", "Koboldite Nugget", 149, 1); - ItemStack aKobolditeIngot = ItemUtils.getItemStackWithMeta(Witchery, "witchery:ingredient", "Koboldite Ingot", 150, 1); - if (aKobolditeDust != null) GT_OreDictUnificator.registerOre("dust"+"Koboldite", aKobolditeDust); - if (aKobolditeNugget != null) GT_OreDictUnificator.registerOre("nugget"+"Koboldite", aKobolditeNugget); - if (aKobolditeIngot != null) GT_OreDictUnificator.registerOre("ingot"+"Koboldite", aKobolditeIngot); - } + public static void OreDict() { + run(); + } + private static final void run() { + // Koboldite + ItemStack aKobolditeDust = + ItemUtils.getItemStackWithMeta(Witchery, "witchery:ingredient", "Koboldite Dust", 148, 1); + ItemStack aKobolditeNugget = + ItemUtils.getItemStackWithMeta(Witchery, "witchery:ingredient", "Koboldite Nugget", 149, 1); + ItemStack aKobolditeIngot = + ItemUtils.getItemStackWithMeta(Witchery, "witchery:ingredient", "Koboldite Ingot", 150, 1); + if (aKobolditeDust != null) GT_OreDictUnificator.registerOre("dust" + "Koboldite", aKobolditeDust); + if (aKobolditeNugget != null) GT_OreDictUnificator.registerOre("nugget" + "Koboldite", aKobolditeNugget); + if (aKobolditeIngot != null) GT_OreDictUnificator.registerOre("ingot" + "Koboldite", aKobolditeIngot); + } } diff --git a/src/main/java/gtPlusPlus/core/config/ConfigHandler.java b/src/main/java/gtPlusPlus/core/config/ConfigHandler.java index 951b10b432..f2126417c7 100644 --- a/src/main/java/gtPlusPlus/core/config/ConfigHandler.java +++ b/src/main/java/gtPlusPlus/core/config/ConfigHandler.java @@ -5,173 +5,601 @@ import static gtPlusPlus.core.lib.CORE.*; import static gtPlusPlus.core.lib.CORE.ConfigSwitches.*; import static gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_WorldAccelerator.BlacklistedTileEntiyClassNames; -import java.io.File; - import cpw.mods.fml.common.event.FMLPreInitializationEvent; - +import java.io.File; import net.minecraftforge.common.config.Configuration; public class ConfigHandler { - public static void handleConfigFile(final FMLPreInitializationEvent event) { - final Configuration config = new Configuration(new File(event.getModConfigurationDirectory(), "GTplusplus/GTplusplus.cfg")); - config.load(); - - // Debug - /* DEBUG = config.getBoolean("debugMode", "debug", false, - "Enables all sorts of debug logging. (Don't use unless told to, breaks other things.)");*/ - disableEnderIOIntegration = config.getBoolean("disableEnderIO", "debug", false, "Disables EnderIO Integration."); - disableEnderIOIngotTooltips = config.getBoolean("disableEnderIOIngotTooltips", "debug", false, "Disables EnderIO Ingot Tooltips. These apparently may cause issues for a very small number of users."); - MACHINE_INFO = config.getBoolean("enableMachineInfoLogging", "debug", false, "Makes many machines display lots of debug logging."); - showHiddenNEIItems = config.getBoolean("showHiddenNEIItems", "debug", false, "Makes all items hidden from NEI display."); - dumpItemAndBlockData = config.getBoolean("dumpItemAndBlockData", "debug", false, "Dumps all GT++ and Toxic Everglade Data to en_US.lang in the config folder. This config option can be used by foreign players to generate blank .lang files, which they can populate with their language of choice."); - - // Machines - enableThaumcraftShardUnification = config.getBoolean("enableThaumcraftShardUnification", "machines", false, "Allows the use of TC shards across many recipes by oreDicting them into a common group."); - enableAlternativeBatteryAlloy = config.getBoolean("enableAlternativeBatteryAlloy", "machines", false, "Adds a non-Antimony using Battery Alloy. Not Balanced at all.."); - disableIC2Recipes = config.getBoolean("disableIC2Recipes", "machines", false, "Alkaluscraft Related - Removes IC2 Cables Except glass fibre. Few other Misc Tweaks."); - enableAlternativeDivisionSigilRecipe = config.getBoolean("enableAlternativeDivisionSigilRecipe", "machines", false, "Utilizes Neutronium instead."); - boilerSteamPerSecond = config.getInt("boilerSteamPerSecond", "machines", 750, 0, 10000, "Sets the steam per second value in LV,MV,HV boilers (respectively 1x,2x,3x this number for the tiers)"); - - // requireControlCores - boolean temp = config.getBoolean("requireControlCores", "machines", true, "Multiblocks Require Control Cores"); - - // Circuits - enableCustomCircuits = config.getBoolean("enableCustomCircuits", "gregtech", false, "Adds custom circuits to expand past the Master Tier. Only really recommended to enable if enableOldGTcircuits is enabled."); - enableOldGTcircuits = config.getBoolean("enableOldGTcircuits", "gregtech", false, "Restores circuits and their recipes from Pre-5.09.28 times."); - - // Tools - enableSkookumChoochers = config.getBoolean("enableSkookumChoochers", "gregtech", true, "Adds Custom GT Tools, called Skookum Choochers, functioning as a hard hammer and a wrench."); - enableMultiSizeTools = config.getBoolean("enableMultiSizeTools", "gregtech", true, "Adds Custom GT Shovels and Pickaxes which mine in a 3x3 style. One of each whill be generated for each Gregtech Material which has Dense Plates and Long Rods available."); - - // GT-Fixes - enableNitroFix = config.getBoolean("enableNitroFix", "gregtech", false, "Restores the old Nitro-Diesel recipes."); - enableSulfuricAcidFix = config.getBoolean("enableSulfuricAcidFix", "gregtech", false, "Adds GT6 recipes for Sulfuric Acid. Should remove all pre-existing recipes."); - enableAnimatedTurbines = config.getBoolean("enableAnimatedTurbines", "gregtech", true, "Gives GT Gas/Steam turbines animated textures while running."); - turbineCutoffBase = config.getInt("turbineCutoffBase", "gregtech", 75000, 0, Integer.MAX_VALUE, "Rotors below this durability will be removed, prevents NEI clutter. Minimum Durability is N * x, where N is the new value set and x is the turbine size, where 1 is Tiny and 4 is Huge. Set to 0 to disable."); - - enableHarderRecipesForHighTierCasings = config.getBoolean("enableHarderRecipesForHighTierCasings", "gregtech", false, "Makes LuV+ Casings and Hulls more difficult to craft."); - - // Pipes & Cables - enableCustom_Pipes = config.getBoolean("enableCustom_Pipes", "gregtech", true, "Adds Custom GT Fluid Pipes."); - enableCustom_Cables = config.getBoolean("enableCustom_Cables", "gregtech", true, "Adds Custom GT Cables."); - - // Block Drops - chanceToDropDrainedShard = config.getInt("chanceToDropDrainedShard", "blockdrops", 196, 0, 10000, "Drained shards have a 1 in X chance to drop."); - chanceToDropFluoriteOre = config.getInt("chanceToDropFluoriteOre", "blockdrops", 32, 0, 10000, "Fluorite Ore has a 1 in X chance to drop from Limestone and a 1 in X*20 from Sandstone.."); - - // Single machines - enableMachine_SolarGenerators = config.getBoolean("enableSolarGenerators", "gregtech", false, "These may be overpowered, Consult a local electrician."); - enableMachine_ComponentAssemblers = config.getBoolean("enableComponentAssemblers", "gregtech", true, "These construct machine components."); - enableMachine_Safes = config.getBoolean("enableMachineSafes", "gregtech", true, "These protect your goodies/rare stuff."); - enableMachine_Dehydrators = config.getBoolean("enableMachineDehydrators", "gregtech", true, "These dehydrate stuff."); - enableMachine_SteamConverter = config.getBoolean("enableMachineSteamConverter", "gregtech", true, "Converts IC2 steam -> Railcraft steam."); - enableMachine_FluidTanks = config.getBoolean("enableMachineFluidTanks", "gregtech", true, "Portable fluid tanks."); - enableMachine_RocketEngines = config.getBoolean("enableMachineRocketEngines", "gregtech", true, "Diesel egines with different internals, they consume less fuel overall."); - enableMachine_GeothermalEngines = config.getBoolean("enableMachineGeothermalEngines", "gregtech", true, "These may be overpowered, Consult a local geologist."); - enableMachine_WorldAccelerators = config.getBoolean("enableMachineWorldAccelerators", "gregtech", true, "These allow boosting Block/TileEntity Tick times [OP]."); - enableMachine_Tesseracts = config.getBoolean("enableMachineTesseracts", "gregtech", true, "Tesseracts for wireless item/fluid movement."); - enableMachine_SimpleWasher = config.getBoolean("enableMachineSimpleWasher", "gregtech", true, "Very basic automated cauldron for dust washing."); - enableMachine_Pollution = config.getBoolean("enableMachinePollution", "gregtech", true, "Pollution Detector & Scrubbers."); - enableMachine_RF_Convetor = config.getBoolean("enableMachineRFConvetor", "gregtech", true, "Converts RF to GTEU. Requires COFH-Core to be installed."); - - // Multi machines - enableMultiblock_AlloyBlastSmelter = config.getBoolean("enableMultiblockAlloyBlastSmelter", "gregtech", true, "Required to smelt most high tier materials from GT++. Also smelts everything else to molten metal."); - enableMultiblock_IndustrialCentrifuge = config.getBoolean("enableMultiblockIndustrialCentrifuge", "gregtech", true, "Spin, Spin, Spiiiin."); - enableMultiblock_IndustrialCokeOven = config.getBoolean("enableMultiblockIndustrialCokeOven", "gregtech", true, "Pyro Oven Alternative, older, more realistic, better."); - enableMultiblock_IndustrialElectrolyzer = config.getBoolean("enableMultiblockIndustrialElectrolyzer", "gregtech", true, "Electrolyzes things with extra bling factor."); - enableMultiblock_IndustrialMacerationStack = config.getBoolean("enableMultiblockIndustrialMacerationStack", "gregtech", true, "A hyper efficient maceration tower, nets more bonus outputs."); - enableMultiblock_IndustrialPlatePress = config.getBoolean("enableMultiblockIndustrialPlatePress", "gregtech", true, "Industrial bendering machine thingo."); - enableMultiblock_IndustrialWireMill = config.getBoolean("enableMultiblockIndustrialWireMill", "gregtech", true, "Produces fine wire and exotic cables."); - enableMultiblock_IronBlastFurnace = config.getBoolean("enableMultiblockIronBlastFurnace", "gregtech", true, "Skip the Bronze age, very slowly."); - enableMultiblock_MatterFabricator = config.getBoolean("enableMultiblockMatterFabricator", "gregtech", true, "?FAB?RIC?ATE MA?TT?ER."); - enableMultiblock_MultiTank = config.getBoolean("enableMultiblockMultiTank", "gregtech", true, "Tall tanks, each layer adds extra fluid storage."); - enableMultiblock_PowerSubstation = config.getBoolean("enableMultiblockPowerSubstation", "gregtech", true, "For managing large power grids."); - enableMultiblock_LiquidFluorideThoriumReactor = config.getBoolean("enableMultiblockLiquidFluorideThoriumReactor", "gregtech", true, "For supplying large power grids."); - enableMultiblock_NuclearFuelRefinery = config.getBoolean("enableMultiblock_NuclearFuelRefinery", "gregtech", true, "Refines molten chemicals into nuclear fuels."); - enableMultiblock_IndustrialSifter = config.getBoolean("enableMultiblock_IndustrialSifter", "gregtech", true, "Large scale sifting."); - enableMultiblock_LargeAutoCrafter = config.getBoolean("enableMultiblock_LargeAutoCrafter", "gregtech", true, "Can Assemble, Disassemble and Craft Project data from Data Sticks."); - enableMultiblock_IndustrialThermalCentrifuge = config.getBoolean("enableMultiblock_IndustrialThermalCentrifuge", "gregtech", true, "Your warm spin for the ore thing."); - enableMultiblock_IndustrialWashPlant = config.getBoolean("enableMultiblock_IndustrialWashPlant", "gregtech", true, "Used to wash the dirt, riiiiight offff.."); - enableMultiblock_ThermalBoiler = config.getBoolean("enableMachineThermalBoiler", "gregtech", true, "Thermal Boiler from GT4. Can Filter Lava for resources."); - enableMultiblock_IndustrialCuttingMachine = config.getBoolean("enableMultiblock_IndustrialCuttingMachine", "gregtech", true, "Very fast and efficient Cutting Machine."); - enableMultiblock_IndustrialFishingPort = config.getBoolean("enableMultiblock_IndustrialFishingPort", "gregtech", true, "Fish the seas, except on land."); - enableMultiblock_IndustrialExtrudingMachine = config.getBoolean("enableMultiblock_IndustrialExtrudingMachine", "gregtech", true, "Very fast and efficient Extruding Machine."); - enableMultiblock_IndustrialMultiMachine = config.getBoolean("enableMultiblock_IndustrialMultiMachine", "gregtech", true, "Can run recipes for 9 different types of machines."); - enableMultiblock_Cyclotron = config.getBoolean("enableMultiblock_Cyclotron", "gregtech", true, "COMET - Scientific Cyclotron."); - - // Options - rfPerEU = config.getInt("rfUsedPerEUForUniversalBatteries", "configurables", 4, 1, 1000, "How much RF is a single unit of EU worth? (Most mods use 4:1 ratio)"); - - // Features - enableCustomCapes = config.getBoolean("enableSupporterCape", "features", true, "Enables Custom GT++ Cape."); - disableZombieReinforcement = config.getBoolean("disableZombieReinforcement", "features", false, "Disables Zombie Reinforcement on hard difficutly."); - enableWatchdogBGM = config.getInt("enableWatchdogBGM", "features", 0, 0, Short.MAX_VALUE, "Set to a value greater than 0 to reduce the ticks taken to delay between BGM tracks. Acceptable Values are 1-32767, where 0 is disabled. Vanilla Uses 12,000 & 24,000. 200 is 10s."); - hideUniversalCells = config.getBoolean("hideUniversalCells", "features", true, "Hides every filled IC2 Universal Cell from NEI."); - - // Biomes - EVERGLADES_ID = config.getInt("darkworld_ID", "worldgen", 227, 1, 254, "The ID of the Dark Dimension."); - EVERGLADESBIOME_ID = config.getInt("darkbiome_ID", "worldgen", 238, 1, 254, "The biome within the Dark Dimension."); - - // Blacklisted Accelerator TileEntities - BlacklistedTileEntiyClassNames = new String[]{"com.rwtema.extrautils.tileentity.enderquarry.TileEntityEnderQuarry"}; - BlacklistedTileEntiyClassNames = config.getStringList("BlacklistedTileEntiyClassNames", "gregtech", BlacklistedTileEntiyClassNames, "The Canonical Class-Names of TileEntities that should be ignored by the WorldAccelerator"); - - // Pollution - pollutionPerSecondMultiPackager = config.get("pollution", "pollutionPerSecondMultiPackager", pollutionPerSecondMultiPackager, "pollution rate in gibbl/s for the Amazon warehousing depot").getInt(pollutionPerSecondMultiPackager); - pollutionPerSecondMultiIndustrialAlloySmelter = config.get("pollution", "pollutionPerSecondMultiIndustrialAlloySmelter", pollutionPerSecondMultiIndustrialAlloySmelter, "pollution rate in gibbl/s for the Alloy blast smelter").getInt(pollutionPerSecondMultiIndustrialAlloySmelter); - pollutionPerSecondMultiIndustrialArcFurnace = config.get("pollution", "pollutionPerSecondMultiIndustrialArcFurnace", pollutionPerSecondMultiIndustrialArcFurnace, "pollution rate in gibbl/s for the High current arc furnace").getInt(pollutionPerSecondMultiIndustrialArcFurnace); - pollutionPerSecondMultiIndustrialCentrifuge = config.get("pollution", "pollutionPerSecondMultiIndustrialCentrifuge", pollutionPerSecondMultiIndustrialCentrifuge, "pollution rate in gibbl/s for the Industrial centrifuge").getInt(pollutionPerSecondMultiIndustrialCentrifuge); - pollutionPerSecondMultiIndustrialCokeOven = config.get("pollution", "pollutionPerSecondMultiIndustrialCokeOven", pollutionPerSecondMultiIndustrialCokeOven, "pollution rate in gibbl/s for the Industrial coke oven").getInt(pollutionPerSecondMultiIndustrialCokeOven); - pollutionPerSecondMultiIndustrialCuttingMachine = config.get("pollution", "pollutionPerSecondMultiIndustrialCuttingMachine", pollutionPerSecondMultiIndustrialCuttingMachine, "pollution rate in gibbl/s for the Cutting factory").getInt(pollutionPerSecondMultiIndustrialCuttingMachine); - pollutionPerSecondMultiIndustrialDehydrator = config.get("pollution", "pollutionPerSecondMultiIndustrialDehydrator", pollutionPerSecondMultiIndustrialDehydrator, "pollution rate in gibbl/s for the Utupu-Tanuri").getInt(pollutionPerSecondMultiIndustrialDehydrator); - pollutionPerSecondMultiIndustrialElectrolyzer = config.get("pollution", "pollutionPerSecondMultiIndustrialElectrolyzer", pollutionPerSecondMultiIndustrialElectrolyzer, "pollution rate in gibbl/s for the Industrial electrolyzer").getInt(pollutionPerSecondMultiIndustrialElectrolyzer); - pollutionPerSecondMultiIndustrialExtruder = config.get("pollution", "pollutionPerSecondMultiIndustrialExtruder", pollutionPerSecondMultiIndustrialExtruder, "pollution rate in gibbl/s for the Industrial extrusion machine").getInt(pollutionPerSecondMultiIndustrialExtruder); - pollutionPerSecondMultiIndustrialMacerator = config.get("pollution", "pollutionPerSecondMultiIndustrialMacerator", pollutionPerSecondMultiIndustrialMacerator, "pollution rate in gibbl/s for the Maceration stack").getInt(pollutionPerSecondMultiIndustrialMacerator); - pollutionPerSecondMultiIndustrialMixer = config.get("pollution", "pollutionPerSecondMultiIndustrialMixer", pollutionPerSecondMultiIndustrialMixer, "pollution rate in gibbl/s for the Industrial mixing machine").getInt(pollutionPerSecondMultiIndustrialMixer); - pollutionPerSecondMultiIndustrialMultiMachine_ModeMetal = config.get("pollution", "pollutionPerSecondMultiIndustrialMultiMachine_ModeMetal", pollutionPerSecondMultiIndustrialMultiMachine_ModeMetal, "pollution rate in gibbl/s for the Large processing factory in metal mode").getInt(pollutionPerSecondMultiIndustrialMultiMachine_ModeMetal); - pollutionPerSecondMultiIndustrialMultiMachine_ModeFluid = config.get("pollution", "pollutionPerSecondMultiIndustrialMultiMachine_ModeFluid", pollutionPerSecondMultiIndustrialMultiMachine_ModeFluid, "pollution rate in gibbl/s for the Large processing factory in fluid mode").getInt(pollutionPerSecondMultiIndustrialMultiMachine_ModeFluid); - pollutionPerSecondMultiIndustrialMultiMachine_ModeMisc = config.get("pollution", "pollutionPerSecondMultiIndustrialMultiMachine_ModeMisc", pollutionPerSecondMultiIndustrialMultiMachine_ModeMisc, "pollution rate in gibbl/s for the Large processing factory in misc mode").getInt(pollutionPerSecondMultiIndustrialMultiMachine_ModeMisc); - pollutionPerSecondMultiIndustrialPlatePress_ModeForming = config.get("pollution", "pollutionPerSecondMultiIndustrialPlatePress_ModeForming", pollutionPerSecondMultiIndustrialPlatePress_ModeForming, "pollution rate in gibbl/s for the Industrial material press in forming mode").getInt(pollutionPerSecondMultiIndustrialPlatePress_ModeForming); - pollutionPerSecondMultiIndustrialPlatePress_ModeBending = config.get("pollution", "pollutionPerSecondMultiIndustrialPlatePress_ModeBending", pollutionPerSecondMultiIndustrialPlatePress_ModeBending, "pollution rate in gibbl/s for the Industrial material press in bending mode").getInt(pollutionPerSecondMultiIndustrialPlatePress_ModeBending); - pollutionPerSecondMultiIndustrialForgeHammer = config.get("pollution", "pollutionPerSecondMultiIndustrialForgeHammer", pollutionPerSecondMultiIndustrialForgeHammer, "pollution rate in gibbl/s for the Industrial Forge Hammer").getInt(pollutionPerSecondMultiIndustrialForgeHammer); - pollutionPerSecondMultiIndustrialSifter = config.get("pollution", "pollutionPerSecondMultiIndustrialSifter", pollutionPerSecondMultiIndustrialSifter, "pollution rate in gibbl/s for the Large Sifter").getInt(pollutionPerSecondMultiIndustrialSifter); - pollutionPerSecondMultiIndustrialThermalCentrifuge = config.get("pollution", "pollutionPerSecondMultiIndustrialThermalCentrifuge", pollutionPerSecondMultiIndustrialThermalCentrifuge, "pollution rate in gibbl/s for the Large thermal refinery").getInt(pollutionPerSecondMultiIndustrialThermalCentrifuge); - pollutionPerSecondMultiIndustrialVacuumFreezer = config.get("pollution", "pollutionPerSecondMultiIndustrialVacuumFreezer", pollutionPerSecondMultiIndustrialVacuumFreezer, "pollution rate in gibbl/s for the Cryogenic freezer").getInt(pollutionPerSecondMultiIndustrialVacuumFreezer); - pollutionPerSecondMultiIndustrialWashPlant_ModeChemBath = config.get("pollution", "pollutionPerSecondMultiIndustrialWashPlant_ModeChemBath", pollutionPerSecondMultiIndustrialWashPlant_ModeChemBath, "pollution rate in gibbl/s for the Ore washing plant in chemical bath mode").getInt(pollutionPerSecondMultiIndustrialWashPlant_ModeChemBath); - pollutionPerSecondMultiIndustrialWashPlant_ModeWasher = config.get("pollution", "pollutionPerSecondMultiIndustrialWashPlant_ModeWasher", pollutionPerSecondMultiIndustrialWashPlant_ModeWasher, "pollution rate in gibbl/s for the Ore washing plant in ore washer mode").getInt(pollutionPerSecondMultiIndustrialWashPlant_ModeWasher); - pollutionPerSecondMultiIndustrialWireMill = config.get("pollution", "pollutionPerSecondMultiIndustrialWireMill", pollutionPerSecondMultiIndustrialWireMill, "pollution rate in gibbl/s for the Wire factory").getInt(pollutionPerSecondMultiIndustrialWireMill); - pollutionPerSecondMultiIsaMill = config.get("pollution", "pollutionPerSecondMultiIsaMill", pollutionPerSecondMultiIsaMill, "pollution rate in gibbl/s for the IsaMill grinding machine").getInt(pollutionPerSecondMultiIsaMill); - pollutionPerSecondMultiAdvDistillationTower_ModeDistillery = config.get("pollution", "pollutionPerSecondMultiAdvDistillationTower_ModeDistillery", pollutionPerSecondMultiAdvDistillationTower_ModeDistillery, "pollution rate in gibbl/s for the Dangote distillus in distillery mode").getInt(pollutionPerSecondMultiAdvDistillationTower_ModeDistillery); - pollutionPerSecondMultiAdvDistillationTower_ModeDT = config.get("pollution", "pollutionPerSecondMultiAdvDistillationTower_ModeDT", pollutionPerSecondMultiAdvDistillationTower_ModeDT, "pollution rate in gibbl/s for the Dangote distillus in distillation tower mode").getInt(pollutionPerSecondMultiAdvDistillationTower_ModeDT); - pollutionPerSecondMultiAdvEBF = config.get("pollution", "pollutionPerSecondMultiAdvEBF", pollutionPerSecondMultiAdvEBF, "pollution rate in gibbl/s for the Volcanus").getInt(pollutionPerSecondMultiAdvEBF); - pollutionPerSecondMultiAdvImplosion = config.get("pollution", "pollutionPerSecondMultiAdvImplosion", pollutionPerSecondMultiAdvImplosion, "pollution rate in gibbl/s for the Density^2").getInt(pollutionPerSecondMultiAdvImplosion); - pollutionPerSecondMultiABS = config.get("pollution", "pollutionPerSecondMultiABS", pollutionPerSecondMultiABS, "pollution rate in gibbl/s for the Alloy blast furnace").getInt(pollutionPerSecondMultiABS); - pollutionPerSecondMultiCyclotron = config.get("pollution", "pollutionPerSecondMultiCyclotron", pollutionPerSecondMultiCyclotron, "pollution rate in gibbl/s for the Cyclotron").getInt(pollutionPerSecondMultiCyclotron); - pollutionPerSecondMultiIndustrialFishingPond = config.get("pollution", "pollutionPerSecondMultiIndustrialFishingPond", pollutionPerSecondMultiIndustrialFishingPond, "pollution rate in gibbl/s for the Zuhai - fishing port").getInt(pollutionPerSecondMultiIndustrialFishingPond); - // pollutionPerSecondMultiLargeRocketEngine; - pollutionPerSecondMultiLargeSemiFluidGenerator = config.get("pollution", "pollutionPerSecondMultiLargeSemiFluidGenerator", pollutionPerSecondMultiLargeSemiFluidGenerator, "pollution rate in gibbl/s for the Large semifluid burner").getInt(pollutionPerSecondMultiLargeSemiFluidGenerator); - pollutionPerSecondMultiMassFabricator = config.get("pollution", "pollutionPerSecondMultiMassFabricator", pollutionPerSecondMultiMassFabricator, "pollution rate in gibbl/s for the Matter fabrication CPU").getInt(pollutionPerSecondMultiMassFabricator); - pollutionPerSecondMultiRefinery = config.get("pollution", "pollutionPerSecondMultiRefinery", pollutionPerSecondMultiRefinery, "pollution rate in gibbl/s for the Reactor fuel processing plant").getInt(pollutionPerSecondMultiRefinery); - // pollutionPerSecondMultiGeneratorArray; - pollutionPerSecondMultiIndustrialRockBreaker = config.get("pollution", "pollutionPerSecondMultiIndustrialRockBreaker", pollutionPerSecondMultiIndustrialRockBreaker, "pollution rate in gibbl/s for the Industrial Rock Breaker").getInt(pollutionPerSecondMultiIndustrialRockBreaker); - pollutionPerSecondMultiIndustrialChisel = config.get("pollution", "pollutionPerSecondMultiIndustrialChisel", pollutionPerSecondMultiIndustrialChisel, "pollution rate in gibbl/s for the Industrial Chisel").getInt(pollutionPerSecondMultiIndustrialChisel); - pollutionPerSecondMultiTreeFarm = config.get("pollution", "pollutionPerSecondMultiTreeFarm", pollutionPerSecondMultiTreeFarm, "pollution rate in gibbl/s for the Tree growth simulator").getInt(pollutionPerSecondMultiTreeFarm); - pollutionPerSecondMultiFrothFlotationCell = config.get("pollution", "pollutionPerSecondMultiFrothFlotationCell", pollutionPerSecondMultiFrothFlotationCell, "pollution rate in gibbl/s for the Flotation cell regulator").getInt(pollutionPerSecondMultiFrothFlotationCell); - pollutionPerSecondMultiAutoCrafter = config.get("pollution", "pollutionPerSecondMultiAutoCrafter", pollutionPerSecondMultiAutoCrafter, "pollution rate in gibbl/s for the Large-Scale auto assembler v1.01").getInt(pollutionPerSecondMultiAutoCrafter); - pollutionPerSecondMultiMolecularTransformer = config.get("pollution", "pollutionPerSecondMultiMolecularTransformer", pollutionPerSecondMultiMolecularTransformer, "pollution rate in gibbl/s for the Multiblock Molecular Transformer").getInt(pollutionPerSecondMultiMolecularTransformer); - pollutionPerSecondMultiThermalBoiler = config.get("pollution", "pollutionPerSecondMultiThermalBoiler", pollutionPerSecondMultiThermalBoiler, "pollution rate in gibbl/s for the Thermal boiler").getInt(pollutionPerSecondMultiThermalBoiler); - pollutionPerSecondMultiAlgaePond = config.get("pollution", "pollutionPerSecondMultiAlgaePond", pollutionPerSecondMultiAlgaePond, "pollution rate in gibbl/s for the Algae farm").getInt(pollutionPerSecondMultiAlgaePond); - basePollutionPerSecondSemiFluidGenerator = config.get("pollution", "basePollutionPerSecondSemiFluidGenerator", basePollutionPerSecondSemiFluidGenerator, "base pollution rate in gibbl/s for the single block semi fluid generators").getInt(basePollutionPerSecondSemiFluidGenerator); - pollutionReleasedByTierSemiFluidGenerator = config.get("pollution", "pollutionReleasedByTierSemiFluidGenerator", pollutionReleasedByTierSemiFluidGenerator, "coefficient applied to the base rate of the single block semi fluid generators based on its tier (first is tier 0 aka ULV)").getDoubleList(); - basePollutionPerSecondBoiler = config.get("pollution", "basePollutionPerSecondBoiler", basePollutionPerSecondBoiler, "base pollution rate in gibbl/s for the single block boilers").getInt(basePollutionPerSecondBoiler); - pollutionReleasedByTierBoiler = config.get("pollution", "pollutionReleasedByTierBoiler", pollutionReleasedByTierBoiler, "coefficient applied to the base rate of the single block semi fluid generators based on its tier (first is tier 0 aka ULV)").getDoubleList(); - baseMinPollutionPerSecondRocketFuelGenerator = config.get("pollution", "baseMinPollutionPerSecondRocketFuelGenerator", baseMinPollutionPerSecondRocketFuelGenerator, "minimum base pollution rate in gibbl/s for the single block rocket engines").getInt(baseMinPollutionPerSecondRocketFuelGenerator); - baseMaxPollutionPerSecondRocketFuelGenerator = config.get("pollution", "baseMaxPollutionPerSecondRocketFuelGenerator", baseMaxPollutionPerSecondRocketFuelGenerator, "maximum base pollution rate in gibbl/s for the single block rocket engines").getInt(baseMaxPollutionPerSecondRocketFuelGenerator); - pollutionReleasedByTierRocketFuelGenerator = config.get("pollution", "pollutionReleasedByTierRocketFuelGenerator", pollutionReleasedByTierRocketFuelGenerator, "coefficient applied to the base rate of the single block rocket engines based on its tier (first is tier 0 aka ULV)").getDoubleList(); - basePollutionPerSecondGeothermalGenerator = config.get("pollution", "basePollutionPerSecondGeothermalGenerator", basePollutionPerSecondGeothermalGenerator, "base pollution rate in gibbl/s for the geothermal engines").getInt(basePollutionPerSecondGeothermalGenerator); - pollutionReleasedByTierGeothermalGenerator = config.get("pollution", "pollutionReleasedByTierGeothermalGenerator", pollutionReleasedByTierGeothermalGenerator, "coefficient applied to the base rate of the single block geothermal engines based on its tier (first is tier 0 aka ULV)").getDoubleList(); - config.save(); - } + public static void handleConfigFile(final FMLPreInitializationEvent event) { + final Configuration config = + new Configuration(new File(event.getModConfigurationDirectory(), "GTplusplus/GTplusplus.cfg")); + config.load(); + + // Debug + /* DEBUG = config.getBoolean("debugMode", "debug", false, + "Enables all sorts of debug logging. (Don't use unless told to, breaks other things.)");*/ + disableEnderIOIntegration = + config.getBoolean("disableEnderIO", "debug", false, "Disables EnderIO Integration."); + disableEnderIOIngotTooltips = config.getBoolean( + "disableEnderIOIngotTooltips", + "debug", + false, + "Disables EnderIO Ingot Tooltips. These apparently may cause issues for a very small number of users."); + MACHINE_INFO = config.getBoolean( + "enableMachineInfoLogging", "debug", false, "Makes many machines display lots of debug logging."); + showHiddenNEIItems = + config.getBoolean("showHiddenNEIItems", "debug", false, "Makes all items hidden from NEI display."); + dumpItemAndBlockData = config.getBoolean( + "dumpItemAndBlockData", + "debug", + false, + "Dumps all GT++ and Toxic Everglade Data to en_US.lang in the config folder. This config option can be used by foreign players to generate blank .lang files, which they can populate with their language of choice."); + + // Machines + enableThaumcraftShardUnification = config.getBoolean( + "enableThaumcraftShardUnification", + "machines", + false, + "Allows the use of TC shards across many recipes by oreDicting them into a common group."); + enableAlternativeBatteryAlloy = config.getBoolean( + "enableAlternativeBatteryAlloy", + "machines", + false, + "Adds a non-Antimony using Battery Alloy. Not Balanced at all.."); + disableIC2Recipes = config.getBoolean( + "disableIC2Recipes", + "machines", + false, + "Alkaluscraft Related - Removes IC2 Cables Except glass fibre. Few other Misc Tweaks."); + enableAlternativeDivisionSigilRecipe = config.getBoolean( + "enableAlternativeDivisionSigilRecipe", "machines", false, "Utilizes Neutronium instead."); + boilerSteamPerSecond = config.getInt( + "boilerSteamPerSecond", + "machines", + 750, + 0, + 10000, + "Sets the steam per second value in LV,MV,HV boilers (respectively 1x,2x,3x this number for the tiers)"); + + // requireControlCores + boolean temp = config.getBoolean("requireControlCores", "machines", true, "Multiblocks Require Control Cores"); + + // Circuits + enableCustomCircuits = config.getBoolean( + "enableCustomCircuits", + "gregtech", + false, + "Adds custom circuits to expand past the Master Tier. Only really recommended to enable if enableOldGTcircuits is enabled."); + enableOldGTcircuits = config.getBoolean( + "enableOldGTcircuits", + "gregtech", + false, + "Restores circuits and their recipes from Pre-5.09.28 times."); + + // Tools + enableSkookumChoochers = config.getBoolean( + "enableSkookumChoochers", + "gregtech", + true, + "Adds Custom GT Tools, called Skookum Choochers, functioning as a hard hammer and a wrench."); + enableMultiSizeTools = config.getBoolean( + "enableMultiSizeTools", + "gregtech", + true, + "Adds Custom GT Shovels and Pickaxes which mine in a 3x3 style. One of each whill be generated for each Gregtech Material which has Dense Plates and Long Rods available."); + + // GT-Fixes + enableNitroFix = + config.getBoolean("enableNitroFix", "gregtech", false, "Restores the old Nitro-Diesel recipes."); + enableSulfuricAcidFix = config.getBoolean( + "enableSulfuricAcidFix", + "gregtech", + false, + "Adds GT6 recipes for Sulfuric Acid. Should remove all pre-existing recipes."); + enableAnimatedTurbines = config.getBoolean( + "enableAnimatedTurbines", + "gregtech", + true, + "Gives GT Gas/Steam turbines animated textures while running."); + turbineCutoffBase = config.getInt( + "turbineCutoffBase", + "gregtech", + 75000, + 0, + Integer.MAX_VALUE, + "Rotors below this durability will be removed, prevents NEI clutter. Minimum Durability is N * x, where N is the new value set and x is the turbine size, where 1 is Tiny and 4 is Huge. Set to 0 to disable."); + + enableHarderRecipesForHighTierCasings = config.getBoolean( + "enableHarderRecipesForHighTierCasings", + "gregtech", + false, + "Makes LuV+ Casings and Hulls more difficult to craft."); + + // Pipes & Cables + enableCustom_Pipes = config.getBoolean("enableCustom_Pipes", "gregtech", true, "Adds Custom GT Fluid Pipes."); + enableCustom_Cables = config.getBoolean("enableCustom_Cables", "gregtech", true, "Adds Custom GT Cables."); + + // Block Drops + chanceToDropDrainedShard = config.getInt( + "chanceToDropDrainedShard", + "blockdrops", + 196, + 0, + 10000, + "Drained shards have a 1 in X chance to drop."); + chanceToDropFluoriteOre = config.getInt( + "chanceToDropFluoriteOre", + "blockdrops", + 32, + 0, + 10000, + "Fluorite Ore has a 1 in X chance to drop from Limestone and a 1 in X*20 from Sandstone.."); + + // Single machines + enableMachine_SolarGenerators = config.getBoolean( + "enableSolarGenerators", "gregtech", false, "These may be overpowered, Consult a local electrician."); + enableMachine_ComponentAssemblers = + config.getBoolean("enableComponentAssemblers", "gregtech", true, "These construct machine components."); + enableMachine_Safes = + config.getBoolean("enableMachineSafes", "gregtech", true, "These protect your goodies/rare stuff."); + enableMachine_Dehydrators = + config.getBoolean("enableMachineDehydrators", "gregtech", true, "These dehydrate stuff."); + enableMachine_SteamConverter = config.getBoolean( + "enableMachineSteamConverter", "gregtech", true, "Converts IC2 steam -> Railcraft steam."); + enableMachine_FluidTanks = + config.getBoolean("enableMachineFluidTanks", "gregtech", true, "Portable fluid tanks."); + enableMachine_RocketEngines = config.getBoolean( + "enableMachineRocketEngines", + "gregtech", + true, + "Diesel egines with different internals, they consume less fuel overall."); + enableMachine_GeothermalEngines = config.getBoolean( + "enableMachineGeothermalEngines", + "gregtech", + true, + "These may be overpowered, Consult a local geologist."); + enableMachine_WorldAccelerators = config.getBoolean( + "enableMachineWorldAccelerators", + "gregtech", + true, + "These allow boosting Block/TileEntity Tick times [OP]."); + enableMachine_Tesseracts = config.getBoolean( + "enableMachineTesseracts", "gregtech", true, "Tesseracts for wireless item/fluid movement."); + enableMachine_SimpleWasher = config.getBoolean( + "enableMachineSimpleWasher", "gregtech", true, "Very basic automated cauldron for dust washing."); + enableMachine_Pollution = + config.getBoolean("enableMachinePollution", "gregtech", true, "Pollution Detector & Scrubbers."); + enableMachine_RF_Convetor = config.getBoolean( + "enableMachineRFConvetor", + "gregtech", + true, + "Converts RF to GTEU. Requires COFH-Core to be installed."); + + // Multi machines + enableMultiblock_AlloyBlastSmelter = config.getBoolean( + "enableMultiblockAlloyBlastSmelter", + "gregtech", + true, + "Required to smelt most high tier materials from GT++. Also smelts everything else to molten metal."); + enableMultiblock_IndustrialCentrifuge = + config.getBoolean("enableMultiblockIndustrialCentrifuge", "gregtech", true, "Spin, Spin, Spiiiin."); + enableMultiblock_IndustrialCokeOven = config.getBoolean( + "enableMultiblockIndustrialCokeOven", + "gregtech", + true, + "Pyro Oven Alternative, older, more realistic, better."); + enableMultiblock_IndustrialElectrolyzer = config.getBoolean( + "enableMultiblockIndustrialElectrolyzer", + "gregtech", + true, + "Electrolyzes things with extra bling factor."); + enableMultiblock_IndustrialMacerationStack = config.getBoolean( + "enableMultiblockIndustrialMacerationStack", + "gregtech", + true, + "A hyper efficient maceration tower, nets more bonus outputs."); + enableMultiblock_IndustrialPlatePress = config.getBoolean( + "enableMultiblockIndustrialPlatePress", "gregtech", true, "Industrial bendering machine thingo."); + enableMultiblock_IndustrialWireMill = config.getBoolean( + "enableMultiblockIndustrialWireMill", "gregtech", true, "Produces fine wire and exotic cables."); + enableMultiblock_IronBlastFurnace = config.getBoolean( + "enableMultiblockIronBlastFurnace", "gregtech", true, "Skip the Bronze age, very slowly."); + enableMultiblock_MatterFabricator = + config.getBoolean("enableMultiblockMatterFabricator", "gregtech", true, "?FAB?RIC?ATE MA?TT?ER."); + enableMultiblock_MultiTank = config.getBoolean( + "enableMultiblockMultiTank", "gregtech", true, "Tall tanks, each layer adds extra fluid storage."); + enableMultiblock_PowerSubstation = config.getBoolean( + "enableMultiblockPowerSubstation", "gregtech", true, "For managing large power grids."); + enableMultiblock_LiquidFluorideThoriumReactor = config.getBoolean( + "enableMultiblockLiquidFluorideThoriumReactor", "gregtech", true, "For supplying large power grids."); + enableMultiblock_NuclearFuelRefinery = config.getBoolean( + "enableMultiblock_NuclearFuelRefinery", + "gregtech", + true, + "Refines molten chemicals into nuclear fuels."); + enableMultiblock_IndustrialSifter = + config.getBoolean("enableMultiblock_IndustrialSifter", "gregtech", true, "Large scale sifting."); + enableMultiblock_LargeAutoCrafter = config.getBoolean( + "enableMultiblock_LargeAutoCrafter", + "gregtech", + true, + "Can Assemble, Disassemble and Craft Project data from Data Sticks."); + enableMultiblock_IndustrialThermalCentrifuge = config.getBoolean( + "enableMultiblock_IndustrialThermalCentrifuge", "gregtech", true, "Your warm spin for the ore thing."); + enableMultiblock_IndustrialWashPlant = config.getBoolean( + "enableMultiblock_IndustrialWashPlant", "gregtech", true, "Used to wash the dirt, riiiiight offff.."); + enableMultiblock_ThermalBoiler = config.getBoolean( + "enableMachineThermalBoiler", + "gregtech", + true, + "Thermal Boiler from GT4. Can Filter Lava for resources."); + enableMultiblock_IndustrialCuttingMachine = config.getBoolean( + "enableMultiblock_IndustrialCuttingMachine", + "gregtech", + true, + "Very fast and efficient Cutting Machine."); + enableMultiblock_IndustrialFishingPort = config.getBoolean( + "enableMultiblock_IndustrialFishingPort", "gregtech", true, "Fish the seas, except on land."); + enableMultiblock_IndustrialExtrudingMachine = config.getBoolean( + "enableMultiblock_IndustrialExtrudingMachine", + "gregtech", + true, + "Very fast and efficient Extruding Machine."); + enableMultiblock_IndustrialMultiMachine = config.getBoolean( + "enableMultiblock_IndustrialMultiMachine", + "gregtech", + true, + "Can run recipes for 9 different types of machines."); + enableMultiblock_Cyclotron = + config.getBoolean("enableMultiblock_Cyclotron", "gregtech", true, "COMET - Scientific Cyclotron."); + + // Options + rfPerEU = config.getInt( + "rfUsedPerEUForUniversalBatteries", + "configurables", + 4, + 1, + 1000, + "How much RF is a single unit of EU worth? (Most mods use 4:1 ratio)"); + + // Features + enableCustomCapes = config.getBoolean("enableSupporterCape", "features", true, "Enables Custom GT++ Cape."); + disableZombieReinforcement = config.getBoolean( + "disableZombieReinforcement", "features", false, "Disables Zombie Reinforcement on hard difficutly."); + enableWatchdogBGM = config.getInt( + "enableWatchdogBGM", + "features", + 0, + 0, + Short.MAX_VALUE, + "Set to a value greater than 0 to reduce the ticks taken to delay between BGM tracks. Acceptable Values are 1-32767, where 0 is disabled. Vanilla Uses 12,000 & 24,000. 200 is 10s."); + hideUniversalCells = config.getBoolean( + "hideUniversalCells", "features", true, "Hides every filled IC2 Universal Cell from NEI."); + + // Biomes + EVERGLADES_ID = config.getInt("darkworld_ID", "worldgen", 227, 1, 254, "The ID of the Dark Dimension."); + EVERGLADESBIOME_ID = + config.getInt("darkbiome_ID", "worldgen", 238, 1, 254, "The biome within the Dark Dimension."); + + // Blacklisted Accelerator TileEntities + BlacklistedTileEntiyClassNames = + new String[] {"com.rwtema.extrautils.tileentity.enderquarry.TileEntityEnderQuarry"}; + BlacklistedTileEntiyClassNames = config.getStringList( + "BlacklistedTileEntiyClassNames", + "gregtech", + BlacklistedTileEntiyClassNames, + "The Canonical Class-Names of TileEntities that should be ignored by the WorldAccelerator"); + // Pollution + pollutionPerSecondMultiPackager = config.get( + "pollution", + "pollutionPerSecondMultiPackager", + pollutionPerSecondMultiPackager, + "pollution rate in gibbl/s for the Amazon warehousing depot") + .getInt(pollutionPerSecondMultiPackager); + pollutionPerSecondMultiIndustrialAlloySmelter = config.get( + "pollution", + "pollutionPerSecondMultiIndustrialAlloySmelter", + pollutionPerSecondMultiIndustrialAlloySmelter, + "pollution rate in gibbl/s for the Alloy blast smelter") + .getInt(pollutionPerSecondMultiIndustrialAlloySmelter); + pollutionPerSecondMultiIndustrialArcFurnace = config.get( + "pollution", + "pollutionPerSecondMultiIndustrialArcFurnace", + pollutionPerSecondMultiIndustrialArcFurnace, + "pollution rate in gibbl/s for the High current arc furnace") + .getInt(pollutionPerSecondMultiIndustrialArcFurnace); + pollutionPerSecondMultiIndustrialCentrifuge = config.get( + "pollution", + "pollutionPerSecondMultiIndustrialCentrifuge", + pollutionPerSecondMultiIndustrialCentrifuge, + "pollution rate in gibbl/s for the Industrial centrifuge") + .getInt(pollutionPerSecondMultiIndustrialCentrifuge); + pollutionPerSecondMultiIndustrialCokeOven = config.get( + "pollution", + "pollutionPerSecondMultiIndustrialCokeOven", + pollutionPerSecondMultiIndustrialCokeOven, + "pollution rate in gibbl/s for the Industrial coke oven") + .getInt(pollutionPerSecondMultiIndustrialCokeOven); + pollutionPerSecondMultiIndustrialCuttingMachine = config.get( + "pollution", + "pollutionPerSecondMultiIndustrialCuttingMachine", + pollutionPerSecondMultiIndustrialCuttingMachine, + "pollution rate in gibbl/s for the Cutting factory") + .getInt(pollutionPerSecondMultiIndustrialCuttingMachine); + pollutionPerSecondMultiIndustrialDehydrator = config.get( + "pollution", + "pollutionPerSecondMultiIndustrialDehydrator", + pollutionPerSecondMultiIndustrialDehydrator, + "pollution rate in gibbl/s for the Utupu-Tanuri") + .getInt(pollutionPerSecondMultiIndustrialDehydrator); + pollutionPerSecondMultiIndustrialElectrolyzer = config.get( + "pollution", + "pollutionPerSecondMultiIndustrialElectrolyzer", + pollutionPerSecondMultiIndustrialElectrolyzer, + "pollution rate in gibbl/s for the Industrial electrolyzer") + .getInt(pollutionPerSecondMultiIndustrialElectrolyzer); + pollutionPerSecondMultiIndustrialExtruder = config.get( + "pollution", + "pollutionPerSecondMultiIndustrialExtruder", + pollutionPerSecondMultiIndustrialExtruder, + "pollution rate in gibbl/s for the Industrial extrusion machine") + .getInt(pollutionPerSecondMultiIndustrialExtruder); + pollutionPerSecondMultiIndustrialMacerator = config.get( + "pollution", + "pollutionPerSecondMultiIndustrialMacerator", + pollutionPerSecondMultiIndustrialMacerator, + "pollution rate in gibbl/s for the Maceration stack") + .getInt(pollutionPerSecondMultiIndustrialMacerator); + pollutionPerSecondMultiIndustrialMixer = config.get( + "pollution", + "pollutionPerSecondMultiIndustrialMixer", + pollutionPerSecondMultiIndustrialMixer, + "pollution rate in gibbl/s for the Industrial mixing machine") + .getInt(pollutionPerSecondMultiIndustrialMixer); + pollutionPerSecondMultiIndustrialMultiMachine_ModeMetal = config.get( + "pollution", + "pollutionPerSecondMultiIndustrialMultiMachine_ModeMetal", + pollutionPerSecondMultiIndustrialMultiMachine_ModeMetal, + "pollution rate in gibbl/s for the Large processing factory in metal mode") + .getInt(pollutionPerSecondMultiIndustrialMultiMachine_ModeMetal); + pollutionPerSecondMultiIndustrialMultiMachine_ModeFluid = config.get( + "pollution", + "pollutionPerSecondMultiIndustrialMultiMachine_ModeFluid", + pollutionPerSecondMultiIndustrialMultiMachine_ModeFluid, + "pollution rate in gibbl/s for the Large processing factory in fluid mode") + .getInt(pollutionPerSecondMultiIndustrialMultiMachine_ModeFluid); + pollutionPerSecondMultiIndustrialMultiMachine_ModeMisc = config.get( + "pollution", + "pollutionPerSecondMultiIndustrialMultiMachine_ModeMisc", + pollutionPerSecondMultiIndustrialMultiMachine_ModeMisc, + "pollution rate in gibbl/s for the Large processing factory in misc mode") + .getInt(pollutionPerSecondMultiIndustrialMultiMachine_ModeMisc); + pollutionPerSecondMultiIndustrialPlatePress_ModeForming = config.get( + "pollution", + "pollutionPerSecondMultiIndustrialPlatePress_ModeForming", + pollutionPerSecondMultiIndustrialPlatePress_ModeForming, + "pollution rate in gibbl/s for the Industrial material press in forming mode") + .getInt(pollutionPerSecondMultiIndustrialPlatePress_ModeForming); + pollutionPerSecondMultiIndustrialPlatePress_ModeBending = config.get( + "pollution", + "pollutionPerSecondMultiIndustrialPlatePress_ModeBending", + pollutionPerSecondMultiIndustrialPlatePress_ModeBending, + "pollution rate in gibbl/s for the Industrial material press in bending mode") + .getInt(pollutionPerSecondMultiIndustrialPlatePress_ModeBending); + pollutionPerSecondMultiIndustrialForgeHammer = config.get( + "pollution", + "pollutionPerSecondMultiIndustrialForgeHammer", + pollutionPerSecondMultiIndustrialForgeHammer, + "pollution rate in gibbl/s for the Industrial Forge Hammer") + .getInt(pollutionPerSecondMultiIndustrialForgeHammer); + pollutionPerSecondMultiIndustrialSifter = config.get( + "pollution", + "pollutionPerSecondMultiIndustrialSifter", + pollutionPerSecondMultiIndustrialSifter, + "pollution rate in gibbl/s for the Large Sifter") + .getInt(pollutionPerSecondMultiIndustrialSifter); + pollutionPerSecondMultiIndustrialThermalCentrifuge = config.get( + "pollution", + "pollutionPerSecondMultiIndustrialThermalCentrifuge", + pollutionPerSecondMultiIndustrialThermalCentrifuge, + "pollution rate in gibbl/s for the Large thermal refinery") + .getInt(pollutionPerSecondMultiIndustrialThermalCentrifuge); + pollutionPerSecondMultiIndustrialVacuumFreezer = config.get( + "pollution", + "pollutionPerSecondMultiIndustrialVacuumFreezer", + pollutionPerSecondMultiIndustrialVacuumFreezer, + "pollution rate in gibbl/s for the Cryogenic freezer") + .getInt(pollutionPerSecondMultiIndustrialVacuumFreezer); + pollutionPerSecondMultiIndustrialWashPlant_ModeChemBath = config.get( + "pollution", + "pollutionPerSecondMultiIndustrialWashPlant_ModeChemBath", + pollutionPerSecondMultiIndustrialWashPlant_ModeChemBath, + "pollution rate in gibbl/s for the Ore washing plant in chemical bath mode") + .getInt(pollutionPerSecondMultiIndustrialWashPlant_ModeChemBath); + pollutionPerSecondMultiIndustrialWashPlant_ModeWasher = config.get( + "pollution", + "pollutionPerSecondMultiIndustrialWashPlant_ModeWasher", + pollutionPerSecondMultiIndustrialWashPlant_ModeWasher, + "pollution rate in gibbl/s for the Ore washing plant in ore washer mode") + .getInt(pollutionPerSecondMultiIndustrialWashPlant_ModeWasher); + pollutionPerSecondMultiIndustrialWireMill = config.get( + "pollution", + "pollutionPerSecondMultiIndustrialWireMill", + pollutionPerSecondMultiIndustrialWireMill, + "pollution rate in gibbl/s for the Wire factory") + .getInt(pollutionPerSecondMultiIndustrialWireMill); + pollutionPerSecondMultiIsaMill = config.get( + "pollution", + "pollutionPerSecondMultiIsaMill", + pollutionPerSecondMultiIsaMill, + "pollution rate in gibbl/s for the IsaMill grinding machine") + .getInt(pollutionPerSecondMultiIsaMill); + pollutionPerSecondMultiAdvDistillationTower_ModeDistillery = config.get( + "pollution", + "pollutionPerSecondMultiAdvDistillationTower_ModeDistillery", + pollutionPerSecondMultiAdvDistillationTower_ModeDistillery, + "pollution rate in gibbl/s for the Dangote distillus in distillery mode") + .getInt(pollutionPerSecondMultiAdvDistillationTower_ModeDistillery); + pollutionPerSecondMultiAdvDistillationTower_ModeDT = config.get( + "pollution", + "pollutionPerSecondMultiAdvDistillationTower_ModeDT", + pollutionPerSecondMultiAdvDistillationTower_ModeDT, + "pollution rate in gibbl/s for the Dangote distillus in distillation tower mode") + .getInt(pollutionPerSecondMultiAdvDistillationTower_ModeDT); + pollutionPerSecondMultiAdvEBF = config.get( + "pollution", + "pollutionPerSecondMultiAdvEBF", + pollutionPerSecondMultiAdvEBF, + "pollution rate in gibbl/s for the Volcanus") + .getInt(pollutionPerSecondMultiAdvEBF); + pollutionPerSecondMultiAdvImplosion = config.get( + "pollution", + "pollutionPerSecondMultiAdvImplosion", + pollutionPerSecondMultiAdvImplosion, + "pollution rate in gibbl/s for the Density^2") + .getInt(pollutionPerSecondMultiAdvImplosion); + pollutionPerSecondMultiABS = config.get( + "pollution", + "pollutionPerSecondMultiABS", + pollutionPerSecondMultiABS, + "pollution rate in gibbl/s for the Alloy blast furnace") + .getInt(pollutionPerSecondMultiABS); + pollutionPerSecondMultiCyclotron = config.get( + "pollution", + "pollutionPerSecondMultiCyclotron", + pollutionPerSecondMultiCyclotron, + "pollution rate in gibbl/s for the Cyclotron") + .getInt(pollutionPerSecondMultiCyclotron); + pollutionPerSecondMultiIndustrialFishingPond = config.get( + "pollution", + "pollutionPerSecondMultiIndustrialFishingPond", + pollutionPerSecondMultiIndustrialFishingPond, + "pollution rate in gibbl/s for the Zuhai - fishing port") + .getInt(pollutionPerSecondMultiIndustrialFishingPond); + // pollutionPerSecondMultiLargeRocketEngine; + pollutionPerSecondMultiLargeSemiFluidGenerator = config.get( + "pollution", + "pollutionPerSecondMultiLargeSemiFluidGenerator", + pollutionPerSecondMultiLargeSemiFluidGenerator, + "pollution rate in gibbl/s for the Large semifluid burner") + .getInt(pollutionPerSecondMultiLargeSemiFluidGenerator); + pollutionPerSecondMultiMassFabricator = config.get( + "pollution", + "pollutionPerSecondMultiMassFabricator", + pollutionPerSecondMultiMassFabricator, + "pollution rate in gibbl/s for the Matter fabrication CPU") + .getInt(pollutionPerSecondMultiMassFabricator); + pollutionPerSecondMultiRefinery = config.get( + "pollution", + "pollutionPerSecondMultiRefinery", + pollutionPerSecondMultiRefinery, + "pollution rate in gibbl/s for the Reactor fuel processing plant") + .getInt(pollutionPerSecondMultiRefinery); + // pollutionPerSecondMultiGeneratorArray; + pollutionPerSecondMultiIndustrialRockBreaker = config.get( + "pollution", + "pollutionPerSecondMultiIndustrialRockBreaker", + pollutionPerSecondMultiIndustrialRockBreaker, + "pollution rate in gibbl/s for the Industrial Rock Breaker") + .getInt(pollutionPerSecondMultiIndustrialRockBreaker); + pollutionPerSecondMultiIndustrialChisel = config.get( + "pollution", + "pollutionPerSecondMultiIndustrialChisel", + pollutionPerSecondMultiIndustrialChisel, + "pollution rate in gibbl/s for the Industrial Chisel") + .getInt(pollutionPerSecondMultiIndustrialChisel); + pollutionPerSecondMultiTreeFarm = config.get( + "pollution", + "pollutionPerSecondMultiTreeFarm", + pollutionPerSecondMultiTreeFarm, + "pollution rate in gibbl/s for the Tree growth simulator") + .getInt(pollutionPerSecondMultiTreeFarm); + pollutionPerSecondMultiFrothFlotationCell = config.get( + "pollution", + "pollutionPerSecondMultiFrothFlotationCell", + pollutionPerSecondMultiFrothFlotationCell, + "pollution rate in gibbl/s for the Flotation cell regulator") + .getInt(pollutionPerSecondMultiFrothFlotationCell); + pollutionPerSecondMultiAutoCrafter = config.get( + "pollution", + "pollutionPerSecondMultiAutoCrafter", + pollutionPerSecondMultiAutoCrafter, + "pollution rate in gibbl/s for the Large-Scale auto assembler v1.01") + .getInt(pollutionPerSecondMultiAutoCrafter); + pollutionPerSecondMultiMolecularTransformer = config.get( + "pollution", + "pollutionPerSecondMultiMolecularTransformer", + pollutionPerSecondMultiMolecularTransformer, + "pollution rate in gibbl/s for the Multiblock Molecular Transformer") + .getInt(pollutionPerSecondMultiMolecularTransformer); + pollutionPerSecondMultiThermalBoiler = config.get( + "pollution", + "pollutionPerSecondMultiThermalBoiler", + pollutionPerSecondMultiThermalBoiler, + "pollution rate in gibbl/s for the Thermal boiler") + .getInt(pollutionPerSecondMultiThermalBoiler); + pollutionPerSecondMultiAlgaePond = config.get( + "pollution", + "pollutionPerSecondMultiAlgaePond", + pollutionPerSecondMultiAlgaePond, + "pollution rate in gibbl/s for the Algae farm") + .getInt(pollutionPerSecondMultiAlgaePond); + basePollutionPerSecondSemiFluidGenerator = config.get( + "pollution", + "basePollutionPerSecondSemiFluidGenerator", + basePollutionPerSecondSemiFluidGenerator, + "base pollution rate in gibbl/s for the single block semi fluid generators") + .getInt(basePollutionPerSecondSemiFluidGenerator); + pollutionReleasedByTierSemiFluidGenerator = config.get( + "pollution", + "pollutionReleasedByTierSemiFluidGenerator", + pollutionReleasedByTierSemiFluidGenerator, + "coefficient applied to the base rate of the single block semi fluid generators based on its tier (first is tier 0 aka ULV)") + .getDoubleList(); + basePollutionPerSecondBoiler = config.get( + "pollution", + "basePollutionPerSecondBoiler", + basePollutionPerSecondBoiler, + "base pollution rate in gibbl/s for the single block boilers") + .getInt(basePollutionPerSecondBoiler); + pollutionReleasedByTierBoiler = config.get( + "pollution", + "pollutionReleasedByTierBoiler", + pollutionReleasedByTierBoiler, + "coefficient applied to the base rate of the single block semi fluid generators based on its tier (first is tier 0 aka ULV)") + .getDoubleList(); + baseMinPollutionPerSecondRocketFuelGenerator = config.get( + "pollution", + "baseMinPollutionPerSecondRocketFuelGenerator", + baseMinPollutionPerSecondRocketFuelGenerator, + "minimum base pollution rate in gibbl/s for the single block rocket engines") + .getInt(baseMinPollutionPerSecondRocketFuelGenerator); + baseMaxPollutionPerSecondRocketFuelGenerator = config.get( + "pollution", + "baseMaxPollutionPerSecondRocketFuelGenerator", + baseMaxPollutionPerSecondRocketFuelGenerator, + "maximum base pollution rate in gibbl/s for the single block rocket engines") + .getInt(baseMaxPollutionPerSecondRocketFuelGenerator); + pollutionReleasedByTierRocketFuelGenerator = config.get( + "pollution", + "pollutionReleasedByTierRocketFuelGenerator", + pollutionReleasedByTierRocketFuelGenerator, + "coefficient applied to the base rate of the single block rocket engines based on its tier (first is tier 0 aka ULV)") + .getDoubleList(); + basePollutionPerSecondGeothermalGenerator = config.get( + "pollution", + "basePollutionPerSecondGeothermalGenerator", + basePollutionPerSecondGeothermalGenerator, + "base pollution rate in gibbl/s for the geothermal engines") + .getInt(basePollutionPerSecondGeothermalGenerator); + pollutionReleasedByTierGeothermalGenerator = config.get( + "pollution", + "pollutionReleasedByTierGeothermalGenerator", + pollutionReleasedByTierGeothermalGenerator, + "coefficient applied to the base rate of the single block geothermal engines based on its tier (first is tier 0 aka ULV)") + .getDoubleList(); + config.save(); + } } diff --git a/src/main/java/gtPlusPlus/core/container/Container_BackpackBase.java b/src/main/java/gtPlusPlus/core/container/Container_BackpackBase.java index ad76bebe81..e3ed090b0c 100644 --- a/src/main/java/gtPlusPlus/core/container/Container_BackpackBase.java +++ b/src/main/java/gtPlusPlus/core/container/Container_BackpackBase.java @@ -1,208 +1,191 @@ package gtPlusPlus.core.container; +import gtPlusPlus.core.inventories.BaseInventoryBackpack; +import gtPlusPlus.core.slots.SlotItemBackpackInv; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import gtPlusPlus.core.inventories.BaseInventoryBackpack; -import gtPlusPlus.core.slots.SlotItemBackpackInv; - -public class Container_BackpackBase extends Container -{ - /** The Item Inventory for this Container, only needed if you want to reference isUseableByPlayer */ - public final BaseInventoryBackpack inventory; - - /** Using these will make transferStackInSlot easier to understand and implement - * INV_START is the index of the first slot in the Player's Inventory, so our - * BaseInventoryBackpack's number of slots (e.g. 5 slots is array indices 0-4, so start at 5) - * Notice how we don't have to remember how many slots we made? We can just use - * BaseInventoryBackpack.INV_SIZE and if we ever change it, the Container updates automatically. */ - private static final int INV_START = BaseInventoryBackpack.INV_SIZE, INV_END = INV_START+26, - HOTBAR_START = INV_END+1, HOTBAR_END = HOTBAR_START+8; - - // If you're planning to add armor slots, put those first like this: - // ARMOR_START = BaseInventoryBackpack.INV_SIZE, ARMOR_END = ARMOR_START+3, - // INV_START = ARMOR_END+1, and then carry on like above. - - public Container_BackpackBase(final EntityPlayer par1Player, final InventoryPlayer inventoryPlayer, final BaseInventoryBackpack inventoryItem) - { - this.inventory = inventoryItem; - - int i; - - // ITEM INVENTORY - you'll need to adjust the slot locations to match your texture file - // I have them set vertically in columns of 4 to the right of the player model - for (i = 0; i < BaseInventoryBackpack.INV_SIZE; ++i) - { - // You can make a custom Slot if you need different behavior, - // such as only certain item types can be put into this slot - // We made a custom slot to prevent our inventory-storing item - // from being stored within itself, but if you want to allow that and - // you followed my advice at the end of the above step, then you - // could get away with using the vanilla Slot class - this.addSlotToContainer(new SlotItemBackpackInv(this.inventory, i, 80 + (18 * (i/4)), 8 + (18*(i%4)))); - } - - // If you want, you can add ARMOR SLOTS here as well, but you need to - // make a public version of SlotArmor. I won't be doing that in this tutorial. - /* - for (i = 0; i < 4; ++i) - { - // These are the standard positions for survival inventory layout - this.addSlotToContainer(new SlotArmor(this.player, inventoryPlayer, inventoryPlayer.getSizeInventory() - 1 - i, 8, 8 + i * 18, i)); - } - */ - - // PLAYER INVENTORY - uses default locations for standard inventory texture file - for (i = 0; i < 3; ++i) - { - for (int j = 0; j < 9; ++j) - { - this.addSlotToContainer(new Slot(inventoryPlayer, j + (i * 9) + 9, 8 + (j * 18), 84 + (i * 18))); - } - } - - // PLAYER ACTION BAR - uses default locations for standard action bar texture file - for (i = 0; i < 9; ++i) - { - this.addSlotToContainer(new Slot(inventoryPlayer, i, 8 + (i * 18), 142)); - } - } - - @Override - public boolean canInteractWith(final EntityPlayer entityplayer) - { - // be sure to return the inventory's isUseableByPlayer method - // if you defined special behavior there: - return this.inventory.isUseableByPlayer(entityplayer); - } - - /** - * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that. - */ - @Override - public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int index) - { - ItemStack itemstack = null; - final Slot slot = (Slot) this.inventorySlots.get(index); - - if ((slot != null) && slot.getHasStack()) - { - final ItemStack itemstack1 = slot.getStack(); - itemstack = itemstack1.copy(); - - // If item is in our custom Inventory or armor slot - if (index < INV_START) - { - // try to place in player inventory / action bar - if (!this.mergeItemStack(itemstack1, INV_START, HOTBAR_END+1, true)) - { - return null; - } - - slot.onSlotChange(itemstack1, itemstack); - } - // Item is in inventory / hotbar, try to place in custom inventory or armor slots - else - { - /* - If your inventory only stores certain instances of Items, - you can implement shift-clicking to your inventory like this: - - // Check that the item is the right type - if (itemstack1.getItem() instanceof ItemCustom) - { - // Try to merge into your custom inventory slots - // We use 'BaseInventoryBackpack.INV_SIZE' instead of INV_START just in case - // you also add armor or other custom slots - if (!this.mergeItemStack(itemstack1, 0, BaseInventoryBackpack.INV_SIZE, false)) - { - return null; - } - } - // If you added armor slots, check them here as well: - // Item being shift-clicked is armor - try to put in armor slot - if (itemstack1.getItem() instanceof ItemArmor) - { - int type = ((ItemArmor) itemstack1.getItem()).armorType; - if (!this.mergeItemStack(itemstack1, ARMOR_START + type, ARMOR_START + type + 1, false)) - { - return null; - } - } - Otherwise, you have basically 2 choices: - 1. shift-clicking between player inventory and custom inventory - 2. shift-clicking between action bar and inventory - - Be sure to choose only ONE of the following implementations!!! - */ - /** - * Implementation number 1: Shift-click into your custom inventory - */ - if (index >= INV_START) - { - // place in custom inventory - if (!this.mergeItemStack(itemstack1, 0, INV_START, false)) - { - return null; - } - } - - /** - * Implementation number 2: Shift-click items between action bar and inventory - */ - // item is in player's inventory, but not in action bar - if ((index >= INV_START) && (index < HOTBAR_START)) - { - // place in action bar - if (!this.mergeItemStack(itemstack1, HOTBAR_START, HOTBAR_END+1, false)) - { - return null; - } - } - // item in action bar - place in player inventory - else if ((index >= HOTBAR_START) && (index < (HOTBAR_END+1))) - { - if (!this.mergeItemStack(itemstack1, INV_START, INV_END+1, false)) - { - return null; - } - } - } - - if (itemstack1.stackSize == 0) - { - slot.putStack((ItemStack) null); - } - else - { - slot.onSlotChanged(); - } - - if (itemstack1.stackSize == itemstack.stackSize) - { - return null; - } - - slot.onPickupFromSlot(par1EntityPlayer, itemstack1); - } - - return itemstack; - } - - /** - * You should override this method to prevent the player from moving the stack that - * opened the inventory, otherwise if the player moves it, the inventory will not - * be able to save properly - */ - @Override - public ItemStack slotClick(final int slot, final int button, final int flag, final EntityPlayer player) { - // this will prevent the player from interacting with the item that opened the inventory: - if ((slot >= 0) && (this.getSlot(slot) != null) && (this.getSlot(slot).getStack() == player.getHeldItem())) { - return null; - } - return super.slotClick(slot, button, flag, player); - } +public class Container_BackpackBase extends Container { + /** The Item Inventory for this Container, only needed if you want to reference isUseableByPlayer */ + public final BaseInventoryBackpack inventory; + + /** Using these will make transferStackInSlot easier to understand and implement + * INV_START is the index of the first slot in the Player's Inventory, so our + * BaseInventoryBackpack's number of slots (e.g. 5 slots is array indices 0-4, so start at 5) + * Notice how we don't have to remember how many slots we made? We can just use + * BaseInventoryBackpack.INV_SIZE and if we ever change it, the Container updates automatically. */ + private static final int INV_START = BaseInventoryBackpack.INV_SIZE, + INV_END = INV_START + 26, + HOTBAR_START = INV_END + 1, + HOTBAR_END = HOTBAR_START + 8; + + // If you're planning to add armor slots, put those first like this: + // ARMOR_START = BaseInventoryBackpack.INV_SIZE, ARMOR_END = ARMOR_START+3, + // INV_START = ARMOR_END+1, and then carry on like above. + + public Container_BackpackBase( + final EntityPlayer par1Player, + final InventoryPlayer inventoryPlayer, + final BaseInventoryBackpack inventoryItem) { + this.inventory = inventoryItem; + + int i; + + // ITEM INVENTORY - you'll need to adjust the slot locations to match your texture file + // I have them set vertically in columns of 4 to the right of the player model + for (i = 0; i < BaseInventoryBackpack.INV_SIZE; ++i) { + // You can make a custom Slot if you need different behavior, + // such as only certain item types can be put into this slot + // We made a custom slot to prevent our inventory-storing item + // from being stored within itself, but if you want to allow that and + // you followed my advice at the end of the above step, then you + // could get away with using the vanilla Slot class + this.addSlotToContainer( + new SlotItemBackpackInv(this.inventory, i, 80 + (18 * (i / 4)), 8 + (18 * (i % 4)))); + } + + // If you want, you can add ARMOR SLOTS here as well, but you need to + // make a public version of SlotArmor. I won't be doing that in this tutorial. + /* + for (i = 0; i < 4; ++i) + { + // These are the standard positions for survival inventory layout + this.addSlotToContainer(new SlotArmor(this.player, inventoryPlayer, inventoryPlayer.getSizeInventory() - 1 - i, 8, 8 + i * 18, i)); + } + */ + + // PLAYER INVENTORY - uses default locations for standard inventory texture file + for (i = 0; i < 3; ++i) { + for (int j = 0; j < 9; ++j) { + this.addSlotToContainer(new Slot(inventoryPlayer, j + (i * 9) + 9, 8 + (j * 18), 84 + (i * 18))); + } + } + + // PLAYER ACTION BAR - uses default locations for standard action bar texture file + for (i = 0; i < 9; ++i) { + this.addSlotToContainer(new Slot(inventoryPlayer, i, 8 + (i * 18), 142)); + } + } + + @Override + public boolean canInteractWith(final EntityPlayer entityplayer) { + // be sure to return the inventory's isUseableByPlayer method + // if you defined special behavior there: + return this.inventory.isUseableByPlayer(entityplayer); + } + + /** + * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that. + */ + @Override + public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int index) { + ItemStack itemstack = null; + final Slot slot = (Slot) this.inventorySlots.get(index); + + if ((slot != null) && slot.getHasStack()) { + final ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + // If item is in our custom Inventory or armor slot + if (index < INV_START) { + // try to place in player inventory / action bar + if (!this.mergeItemStack(itemstack1, INV_START, HOTBAR_END + 1, true)) { + return null; + } + + slot.onSlotChange(itemstack1, itemstack); + } + // Item is in inventory / hotbar, try to place in custom inventory or armor slots + else { + /* + If your inventory only stores certain instances of Items, + you can implement shift-clicking to your inventory like this: + + // Check that the item is the right type + if (itemstack1.getItem() instanceof ItemCustom) + { + // Try to merge into your custom inventory slots + // We use 'BaseInventoryBackpack.INV_SIZE' instead of INV_START just in case + // you also add armor or other custom slots + if (!this.mergeItemStack(itemstack1, 0, BaseInventoryBackpack.INV_SIZE, false)) + { + return null; + } + } + // If you added armor slots, check them here as well: + // Item being shift-clicked is armor - try to put in armor slot + if (itemstack1.getItem() instanceof ItemArmor) + { + int type = ((ItemArmor) itemstack1.getItem()).armorType; + if (!this.mergeItemStack(itemstack1, ARMOR_START + type, ARMOR_START + type + 1, false)) + { + return null; + } + } + Otherwise, you have basically 2 choices: + 1. shift-clicking between player inventory and custom inventory + 2. shift-clicking between action bar and inventory + + Be sure to choose only ONE of the following implementations!!! + */ + /** + * Implementation number 1: Shift-click into your custom inventory + */ + if (index >= INV_START) { + // place in custom inventory + if (!this.mergeItemStack(itemstack1, 0, INV_START, false)) { + return null; + } + } + + /** + * Implementation number 2: Shift-click items between action bar and inventory + */ + // item is in player's inventory, but not in action bar + if ((index >= INV_START) && (index < HOTBAR_START)) { + // place in action bar + if (!this.mergeItemStack(itemstack1, HOTBAR_START, HOTBAR_END + 1, false)) { + return null; + } + } + // item in action bar - place in player inventory + else if ((index >= HOTBAR_START) && (index < (HOTBAR_END + 1))) { + if (!this.mergeItemStack(itemstack1, INV_START, INV_END + 1, false)) { + return null; + } + } + } + + if (itemstack1.stackSize == 0) { + slot.putStack((ItemStack) null); + } else { + slot.onSlotChanged(); + } + + if (itemstack1.stackSize == itemstack.stackSize) { + return null; + } + + slot.onPickupFromSlot(par1EntityPlayer, itemstack1); + } + + return itemstack; + } + + /** + * You should override this method to prevent the player from moving the stack that + * opened the inventory, otherwise if the player moves it, the inventory will not + * be able to save properly + */ + @Override + public ItemStack slotClick(final int slot, final int button, final int flag, final EntityPlayer player) { + // this will prevent the player from interacting with the item that opened the inventory: + if ((slot >= 0) && (this.getSlot(slot) != null) && (this.getSlot(slot).getStack() == player.getHeldItem())) { + return null; + } + return super.slotClick(slot, button, flag, player); + } } diff --git a/src/main/java/gtPlusPlus/core/container/Container_CircuitProgrammer.java b/src/main/java/gtPlusPlus/core/container/Container_CircuitProgrammer.java index d8ce521fb5..73f7eefe8d 100644 --- a/src/main/java/gtPlusPlus/core/container/Container_CircuitProgrammer.java +++ b/src/main/java/gtPlusPlus/core/container/Container_CircuitProgrammer.java @@ -1,190 +1,184 @@ package gtPlusPlus.core.container; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.inventories.InventoryCircuitProgrammer; import gtPlusPlus.core.slots.SlotIntegratedCircuit; import gtPlusPlus.core.slots.SlotNoInput; import gtPlusPlus.core.tileentities.general.TileEntityCircuitProgrammer; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; public class Container_CircuitProgrammer extends Container { - protected TileEntityCircuitProgrammer tile_entity; - public final InventoryCircuitProgrammer inventoryChest; - - private final World worldObj; - private final int posX; - private final int posY; - private final int posZ; - - public static final int SLOT_OUTPUT = 25; - - public static int StorageSlotNumber = 26; // Number of slots in storage area - public static int InventorySlotNumber = 36; // Inventory Slots (Inventory - // and Hotbar) - public static int FullSlotNumber = InventorySlotNumber + StorageSlotNumber; // All - // slots - - public Container_CircuitProgrammer(final InventoryPlayer inventory, final TileEntityCircuitProgrammer te) { - this.tile_entity = te; - this.inventoryChest = te.getInventory(); - - int var6; - int var7; - this.worldObj = te.getWorldObj(); - this.posX = te.xCoord; - this.posY = te.yCoord; - this.posZ = te.zCoord; - Logger.INFO("1"); - - int o = 0; - - // Storage Side - /*for (var6 = 0; var6 < 3; var6++) { - for (var7 = 0; var7 < 5; var7++) { - this.addSlotToContainer(new SlotIntegratedCircuit(o, this.inventoryChest, o, 44 + (var7 * 18), 15 + (var6 * 18))); - o++; - } - }*/ - - - int xStart = 8; - int yStart = 5; - - try { - //0 - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart, yStart)); - //1-10 - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+18, yStart)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+36, yStart)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+54, yStart)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+72, yStart)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+90, yStart)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+108, yStart)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+18, yStart+18)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+36, yStart+18)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+54, yStart+18)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+72, yStart+18)); - //11-20 - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+90, yStart+18)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+108, yStart+18)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+18, yStart+36)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+36, yStart+36)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+54, yStart+36)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+72, yStart+36)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+90, yStart+36)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+108, yStart+36)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+18, yStart+54)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+36, yStart+54)); - //21-24 - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+54, yStart+54)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+72, yStart+54)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+90, yStart+54)); - this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart+108, yStart+54)); - Logger.INFO("2"); - - //Add Output - this.addSlotToContainer(new SlotNoInput(this.inventoryChest, SLOT_OUTPUT, xStart+(8*18), yStart+54)); - o++; - Logger.INFO("3"); - - - - // Player Inventory - for (var6 = 0; var6 < 3; ++var6) { - for (var7 = 0; var7 < 9; ++var7) { - this.addSlotToContainer(new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18))); - } - } - // Player Hotbar - for (var6 = 0; var6 < 9; ++var6) { - this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142)); - } - - - - Logger.INFO("4"); - } - catch (Throwable t) {} - - } - - @Override - public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold, - final EntityPlayer aPlayer) { - - if (!aPlayer.worldObj.isRemote) { - if ((aSlotIndex == 999) || (aSlotIndex == -999)) { - // Utils.LOG_WARNING("??? - "+aSlotIndex); - } - } - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - @Override - public void onContainerClosed(final EntityPlayer par1EntityPlayer) { - super.onContainerClosed(par1EntityPlayer); - } - - @Override - public boolean canInteractWith(final EntityPlayer par1EntityPlayer) { - if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockCircuitProgrammer) { - return false; - } - - return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; - } - - @Override - public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) { - ItemStack var3 = null; - final Slot var4 = (Slot) this.inventorySlots.get(par2); - - if ((var4 != null) && var4.getHasStack()) { - final ItemStack var5 = var4.getStack(); - var3 = var5.copy(); - - /* - * if (par2 == 0) { if (!this.mergeItemStack(var5, - * InOutputSlotNumber, FullSlotNumber, true)) { return null; } - * - * var4.onSlotChange(var5, var3); } else if (par2 >= - * InOutputSlotNumber && par2 < InventoryOutSlotNumber) { if - * (!this.mergeItemStack(var5, InventoryOutSlotNumber, - * FullSlotNumber, false)) { return null; } } else if (par2 >= - * InventoryOutSlotNumber && par2 < FullSlotNumber) { if - * (!this.mergeItemStack(var5, InOutputSlotNumber, - * InventoryOutSlotNumber, false)) { return null; } } else if - * (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, - * false)) { return null; } - */ - - if (var5.stackSize == 0) { - var4.putStack((ItemStack) null); - } else { - var4.onSlotChanged(); - } - - if (var5.stackSize == var3.stackSize) { - return null; - } - - var4.onPickupFromSlot(par1EntityPlayer, var5); - } - - return var3; - } - - // Can merge Slot - @Override - public boolean func_94530_a(final ItemStack p_94530_1_, final Slot p_94530_2_) { - return super.func_94530_a(p_94530_1_, p_94530_2_); - } - -} \ No newline at end of file + protected TileEntityCircuitProgrammer tile_entity; + public final InventoryCircuitProgrammer inventoryChest; + + private final World worldObj; + private final int posX; + private final int posY; + private final int posZ; + + public static final int SLOT_OUTPUT = 25; + + public static int StorageSlotNumber = 26; // Number of slots in storage area + public static int InventorySlotNumber = 36; // Inventory Slots (Inventory + // and Hotbar) + public static int FullSlotNumber = InventorySlotNumber + StorageSlotNumber; // All + // slots + + public Container_CircuitProgrammer(final InventoryPlayer inventory, final TileEntityCircuitProgrammer te) { + this.tile_entity = te; + this.inventoryChest = te.getInventory(); + + int var6; + int var7; + this.worldObj = te.getWorldObj(); + this.posX = te.xCoord; + this.posY = te.yCoord; + this.posZ = te.zCoord; + Logger.INFO("1"); + + int o = 0; + + // Storage Side + /*for (var6 = 0; var6 < 3; var6++) { + for (var7 = 0; var7 < 5; var7++) { + this.addSlotToContainer(new SlotIntegratedCircuit(o, this.inventoryChest, o, 44 + (var7 * 18), 15 + (var6 * 18))); + o++; + } + }*/ + + int xStart = 8; + int yStart = 5; + + try { + // 0 + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart, yStart)); + // 1-10 + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 18, yStart)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 36, yStart)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 54, yStart)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 72, yStart)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 90, yStart)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 108, yStart)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 18, yStart + 18)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 36, yStart + 18)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 54, yStart + 18)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 72, yStart + 18)); + // 11-20 + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 90, yStart + 18)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 108, yStart + 18)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 18, yStart + 36)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 36, yStart + 36)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 54, yStart + 36)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 72, yStart + 36)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 90, yStart + 36)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 108, yStart + 36)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 18, yStart + 54)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 36, yStart + 54)); + // 21-24 + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 54, yStart + 54)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 72, yStart + 54)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 90, yStart + 54)); + this.addSlotToContainer(new SlotIntegratedCircuit(this.inventoryChest, o++, xStart + 108, yStart + 54)); + Logger.INFO("2"); + + // Add Output + this.addSlotToContainer(new SlotNoInput(this.inventoryChest, SLOT_OUTPUT, xStart + (8 * 18), yStart + 54)); + o++; + Logger.INFO("3"); + + // Player Inventory + for (var6 = 0; var6 < 3; ++var6) { + for (var7 = 0; var7 < 9; ++var7) { + this.addSlotToContainer( + new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18))); + } + } + // Player Hotbar + for (var6 = 0; var6 < 9; ++var6) { + this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142)); + } + + Logger.INFO("4"); + } catch (Throwable t) { + } + } + + @Override + public ItemStack slotClick( + final int aSlotIndex, final int aMouseclick, final int aShifthold, final EntityPlayer aPlayer) { + + if (!aPlayer.worldObj.isRemote) { + if ((aSlotIndex == 999) || (aSlotIndex == -999)) { + // Utils.LOG_WARNING("??? - "+aSlotIndex); + } + } + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + @Override + public void onContainerClosed(final EntityPlayer par1EntityPlayer) { + super.onContainerClosed(par1EntityPlayer); + } + + @Override + public boolean canInteractWith(final EntityPlayer par1EntityPlayer) { + if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockCircuitProgrammer) { + return false; + } + + return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; + } + + @Override + public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) { + ItemStack var3 = null; + final Slot var4 = (Slot) this.inventorySlots.get(par2); + + if ((var4 != null) && var4.getHasStack()) { + final ItemStack var5 = var4.getStack(); + var3 = var5.copy(); + + /* + * if (par2 == 0) { if (!this.mergeItemStack(var5, + * InOutputSlotNumber, FullSlotNumber, true)) { return null; } + * + * var4.onSlotChange(var5, var3); } else if (par2 >= + * InOutputSlotNumber && par2 < InventoryOutSlotNumber) { if + * (!this.mergeItemStack(var5, InventoryOutSlotNumber, + * FullSlotNumber, false)) { return null; } } else if (par2 >= + * InventoryOutSlotNumber && par2 < FullSlotNumber) { if + * (!this.mergeItemStack(var5, InOutputSlotNumber, + * InventoryOutSlotNumber, false)) { return null; } } else if + * (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, + * false)) { return null; } + */ + + if (var5.stackSize == 0) { + var4.putStack((ItemStack) null); + } else { + var4.onSlotChanged(); + } + + if (var5.stackSize == var3.stackSize) { + return null; + } + + var4.onPickupFromSlot(par1EntityPlayer, var5); + } + + return var3; + } + + // Can merge Slot + @Override + public boolean func_94530_a(final ItemStack p_94530_1_, final Slot p_94530_2_) { + return super.func_94530_a(p_94530_1_, p_94530_2_); + } +} diff --git a/src/main/java/gtPlusPlus/core/container/Container_DecayablesChest.java b/src/main/java/gtPlusPlus/core/container/Container_DecayablesChest.java index 5bc384cd29..ac755d71aa 100644 --- a/src/main/java/gtPlusPlus/core/container/Container_DecayablesChest.java +++ b/src/main/java/gtPlusPlus/core/container/Container_DecayablesChest.java @@ -12,129 +12,127 @@ import net.minecraft.world.World; public class Container_DecayablesChest extends Container { - protected TileEntityDecayablesChest tile_entity; - public final Inventory_DecayablesChest inventoryChest; + protected TileEntityDecayablesChest tile_entity; + public final Inventory_DecayablesChest inventoryChest; - private final World worldObj; - private final int posX; - private final int posY; - private final int posZ; + private final World worldObj; + private final int posX; + private final int posY; + private final int posZ; - public static int StorageSlotNumber = 15; // Number of slots in storage area - public static int InventorySlotNumber = 36; // Inventory Slots (Inventory - // and Hotbar) - public static int FullSlotNumber = InventorySlotNumber + StorageSlotNumber; // All - // slots + public static int StorageSlotNumber = 15; // Number of slots in storage area + public static int InventorySlotNumber = 36; // Inventory Slots (Inventory + // and Hotbar) + public static int FullSlotNumber = InventorySlotNumber + StorageSlotNumber; // All + // slots - private final int[] slotStorage = new int[15]; + private final int[] slotStorage = new int[15]; - public Container_DecayablesChest(final InventoryPlayer inventory, final TileEntityDecayablesChest te) { - this.tile_entity = te; - this.inventoryChest = te.getInventory(); + public Container_DecayablesChest(final InventoryPlayer inventory, final TileEntityDecayablesChest te) { + this.tile_entity = te; + this.inventoryChest = te.getInventory(); te.openInventory(); - int var6; - int var7; - this.worldObj = te.getWorldObj(); - this.posX = te.xCoord; - this.posY = te.yCoord; - this.posZ = te.zCoord; - - int o = 0; - - // Storage Side - for (var6 = 0; var6 < 3; var6++) { - for (var7 = 0; var7 < 5; var7++) { - this.slotStorage[o] = o; - this.addSlotToContainer(new Slot(this.inventoryChest, o++, 44 + (var7 * 18), 15 + (var6 * 18))); - } - } - - // Player Inventory - for (var6 = 0; var6 < 3; ++var6) { - for (var7 = 0; var7 < 9; ++var7) { - this.addSlotToContainer(new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18))); - } - } - - // Player Hotbar - for (var6 = 0; var6 < 9; ++var6) { - this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142)); - } - - } - - @Override - public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold, - final EntityPlayer aPlayer) { - - if (!aPlayer.worldObj.isRemote) { - if ((aSlotIndex == 999) || (aSlotIndex == -999)) { - // Utils.LOG_WARNING("??? - "+aSlotIndex); - } - } - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - @Override - public void onContainerClosed(final EntityPlayer par1EntityPlayer) { - super.onContainerClosed(par1EntityPlayer); - tile_entity.closeInventory(); - } - - @Override - public boolean canInteractWith(final EntityPlayer par1EntityPlayer) { - if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockDecayablesChest) { - return false; - } - - return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; - } - - @Override - public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) { - ItemStack var3 = null; - final Slot var4 = (Slot) this.inventorySlots.get(par2); - - if ((var4 != null) && var4.getHasStack()) { - final ItemStack var5 = var4.getStack(); - var3 = var5.copy(); - - /* - * if (par2 == 0) { if (!this.mergeItemStack(var5, - * InOutputSlotNumber, FullSlotNumber, true)) { return null; } - * - * var4.onSlotChange(var5, var3); } else if (par2 >= - * InOutputSlotNumber && par2 < InventoryOutSlotNumber) { if - * (!this.mergeItemStack(var5, InventoryOutSlotNumber, - * FullSlotNumber, false)) { return null; } } else if (par2 >= - * InventoryOutSlotNumber && par2 < FullSlotNumber) { if - * (!this.mergeItemStack(var5, InOutputSlotNumber, - * InventoryOutSlotNumber, false)) { return null; } } else if - * (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, - * false)) { return null; } - */ - - if (var5.stackSize == 0) { - var4.putStack((ItemStack) null); - } else { - var4.onSlotChanged(); - } - - if (var5.stackSize == var3.stackSize) { - return null; - } - - var4.onPickupFromSlot(par1EntityPlayer, var5); - } - - return var3; - } - - // Can merge Slot - @Override - public boolean func_94530_a(final ItemStack p_94530_1_, final Slot p_94530_2_) { - return super.func_94530_a(p_94530_1_, p_94530_2_); - } - -} \ No newline at end of file + int var6; + int var7; + this.worldObj = te.getWorldObj(); + this.posX = te.xCoord; + this.posY = te.yCoord; + this.posZ = te.zCoord; + + int o = 0; + + // Storage Side + for (var6 = 0; var6 < 3; var6++) { + for (var7 = 0; var7 < 5; var7++) { + this.slotStorage[o] = o; + this.addSlotToContainer(new Slot(this.inventoryChest, o++, 44 + (var7 * 18), 15 + (var6 * 18))); + } + } + + // Player Inventory + for (var6 = 0; var6 < 3; ++var6) { + for (var7 = 0; var7 < 9; ++var7) { + this.addSlotToContainer(new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18))); + } + } + + // Player Hotbar + for (var6 = 0; var6 < 9; ++var6) { + this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142)); + } + } + + @Override + public ItemStack slotClick( + final int aSlotIndex, final int aMouseclick, final int aShifthold, final EntityPlayer aPlayer) { + + if (!aPlayer.worldObj.isRemote) { + if ((aSlotIndex == 999) || (aSlotIndex == -999)) { + // Utils.LOG_WARNING("??? - "+aSlotIndex); + } + } + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + @Override + public void onContainerClosed(final EntityPlayer par1EntityPlayer) { + super.onContainerClosed(par1EntityPlayer); + tile_entity.closeInventory(); + } + + @Override + public boolean canInteractWith(final EntityPlayer par1EntityPlayer) { + if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockDecayablesChest) { + return false; + } + + return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; + } + + @Override + public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) { + ItemStack var3 = null; + final Slot var4 = (Slot) this.inventorySlots.get(par2); + + if ((var4 != null) && var4.getHasStack()) { + final ItemStack var5 = var4.getStack(); + var3 = var5.copy(); + + /* + * if (par2 == 0) { if (!this.mergeItemStack(var5, + * InOutputSlotNumber, FullSlotNumber, true)) { return null; } + * + * var4.onSlotChange(var5, var3); } else if (par2 >= + * InOutputSlotNumber && par2 < InventoryOutSlotNumber) { if + * (!this.mergeItemStack(var5, InventoryOutSlotNumber, + * FullSlotNumber, false)) { return null; } } else if (par2 >= + * InventoryOutSlotNumber && par2 < FullSlotNumber) { if + * (!this.mergeItemStack(var5, InOutputSlotNumber, + * InventoryOutSlotNumber, false)) { return null; } } else if + * (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, + * false)) { return null; } + */ + + if (var5.stackSize == 0) { + var4.putStack((ItemStack) null); + } else { + var4.onSlotChanged(); + } + + if (var5.stackSize == var3.stackSize) { + return null; + } + + var4.onPickupFromSlot(par1EntityPlayer, var5); + } + + return var3; + } + + // Can merge Slot + @Override + public boolean func_94530_a(final ItemStack p_94530_1_, final Slot p_94530_2_) { + return super.func_94530_a(p_94530_1_, p_94530_2_); + } +} diff --git a/src/main/java/gtPlusPlus/core/container/Container_EggBox.java b/src/main/java/gtPlusPlus/core/container/Container_EggBox.java index c4396cca6f..26815d2b7b 100644 --- a/src/main/java/gtPlusPlus/core/container/Container_EggBox.java +++ b/src/main/java/gtPlusPlus/core/container/Container_EggBox.java @@ -12,129 +12,127 @@ import net.minecraft.world.World; public class Container_EggBox extends Container { - protected TileEntityEggBox tile_entity; - public final Inventory_EggBox inventoryChest; + protected TileEntityEggBox tile_entity; + public final Inventory_EggBox inventoryChest; - private final World worldObj; - private final int posX; - private final int posY; - private final int posZ; + private final World worldObj; + private final int posX; + private final int posY; + private final int posZ; - public static int StorageSlotNumber = 15; // Number of slots in storage area - public static int InventorySlotNumber = 36; // Inventory Slots (Inventory - // and Hotbar) - public static int FullSlotNumber = InventorySlotNumber + StorageSlotNumber; // All - // slots + public static int StorageSlotNumber = 15; // Number of slots in storage area + public static int InventorySlotNumber = 36; // Inventory Slots (Inventory + // and Hotbar) + public static int FullSlotNumber = InventorySlotNumber + StorageSlotNumber; // All + // slots - private final int[] slotStorage = new int[15]; + private final int[] slotStorage = new int[15]; - public Container_EggBox(final InventoryPlayer inventory, final TileEntityEggBox te) { - this.tile_entity = te; - this.inventoryChest = te.getInventory(); + public Container_EggBox(final InventoryPlayer inventory, final TileEntityEggBox te) { + this.tile_entity = te; + this.inventoryChest = te.getInventory(); te.openInventory(); - int var6; - int var7; - this.worldObj = te.getWorldObj(); - this.posX = te.xCoord; - this.posY = te.yCoord; - this.posZ = te.zCoord; - - int o = 0; - - // Storage Side - for (var6 = 0; var6 < 3; var6++) { - for (var7 = 0; var7 < 5; var7++) { - this.slotStorage[o] = o; - this.addSlotToContainer(new Slot(this.inventoryChest, o++, 44 + (var7 * 18), 15 + (var6 * 18))); - } - } - - // Player Inventory - for (var6 = 0; var6 < 3; ++var6) { - for (var7 = 0; var7 < 9; ++var7) { - this.addSlotToContainer(new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18))); - } - } - - // Player Hotbar - for (var6 = 0; var6 < 9; ++var6) { - this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142)); - } - - } - - @Override - public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold, - final EntityPlayer aPlayer) { - - if (!aPlayer.worldObj.isRemote) { - if ((aSlotIndex == 999) || (aSlotIndex == -999)) { - // Utils.LOG_WARNING("??? - "+aSlotIndex); - } - } - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - @Override - public void onContainerClosed(final EntityPlayer par1EntityPlayer) { - super.onContainerClosed(par1EntityPlayer); - tile_entity.closeInventory(); - } - - @Override - public boolean canInteractWith(final EntityPlayer par1EntityPlayer) { - if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockEggBox) { - return false; - } - - return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; - } - - @Override - public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) { - ItemStack var3 = null; - final Slot var4 = (Slot) this.inventorySlots.get(par2); - - if ((var4 != null) && var4.getHasStack()) { - final ItemStack var5 = var4.getStack(); - var3 = var5.copy(); - - /* - * if (par2 == 0) { if (!this.mergeItemStack(var5, - * InOutputSlotNumber, FullSlotNumber, true)) { return null; } - * - * var4.onSlotChange(var5, var3); } else if (par2 >= - * InOutputSlotNumber && par2 < InventoryOutSlotNumber) { if - * (!this.mergeItemStack(var5, InventoryOutSlotNumber, - * FullSlotNumber, false)) { return null; } } else if (par2 >= - * InventoryOutSlotNumber && par2 < FullSlotNumber) { if - * (!this.mergeItemStack(var5, InOutputSlotNumber, - * InventoryOutSlotNumber, false)) { return null; } } else if - * (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, - * false)) { return null; } - */ - - if (var5.stackSize == 0) { - var4.putStack((ItemStack) null); - } else { - var4.onSlotChanged(); - } - - if (var5.stackSize == var3.stackSize) { - return null; - } - - var4.onPickupFromSlot(par1EntityPlayer, var5); - } - - return var3; - } - - // Can merge Slot - @Override - public boolean func_94530_a(final ItemStack p_94530_1_, final Slot p_94530_2_) { - return super.func_94530_a(p_94530_1_, p_94530_2_); - } - -} \ No newline at end of file + int var6; + int var7; + this.worldObj = te.getWorldObj(); + this.posX = te.xCoord; + this.posY = te.yCoord; + this.posZ = te.zCoord; + + int o = 0; + + // Storage Side + for (var6 = 0; var6 < 3; var6++) { + for (var7 = 0; var7 < 5; var7++) { + this.slotStorage[o] = o; + this.addSlotToContainer(new Slot(this.inventoryChest, o++, 44 + (var7 * 18), 15 + (var6 * 18))); + } + } + + // Player Inventory + for (var6 = 0; var6 < 3; ++var6) { + for (var7 = 0; var7 < 9; ++var7) { + this.addSlotToContainer(new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18))); + } + } + + // Player Hotbar + for (var6 = 0; var6 < 9; ++var6) { + this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142)); + } + } + + @Override + public ItemStack slotClick( + final int aSlotIndex, final int aMouseclick, final int aShifthold, final EntityPlayer aPlayer) { + + if (!aPlayer.worldObj.isRemote) { + if ((aSlotIndex == 999) || (aSlotIndex == -999)) { + // Utils.LOG_WARNING("??? - "+aSlotIndex); + } + } + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + @Override + public void onContainerClosed(final EntityPlayer par1EntityPlayer) { + super.onContainerClosed(par1EntityPlayer); + tile_entity.closeInventory(); + } + + @Override + public boolean canInteractWith(final EntityPlayer par1EntityPlayer) { + if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockEggBox) { + return false; + } + + return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; + } + + @Override + public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) { + ItemStack var3 = null; + final Slot var4 = (Slot) this.inventorySlots.get(par2); + + if ((var4 != null) && var4.getHasStack()) { + final ItemStack var5 = var4.getStack(); + var3 = var5.copy(); + + /* + * if (par2 == 0) { if (!this.mergeItemStack(var5, + * InOutputSlotNumber, FullSlotNumber, true)) { return null; } + * + * var4.onSlotChange(var5, var3); } else if (par2 >= + * InOutputSlotNumber && par2 < InventoryOutSlotNumber) { if + * (!this.mergeItemStack(var5, InventoryOutSlotNumber, + * FullSlotNumber, false)) { return null; } } else if (par2 >= + * InventoryOutSlotNumber && par2 < FullSlotNumber) { if + * (!this.mergeItemStack(var5, InOutputSlotNumber, + * InventoryOutSlotNumber, false)) { return null; } } else if + * (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, + * false)) { return null; } + */ + + if (var5.stackSize == 0) { + var4.putStack((ItemStack) null); + } else { + var4.onSlotChanged(); + } + + if (var5.stackSize == var3.stackSize) { + return null; + } + + var4.onPickupFromSlot(par1EntityPlayer, var5); + } + + return var3; + } + + // Can merge Slot + @Override + public boolean func_94530_a(final ItemStack p_94530_1_, final Slot p_94530_2_) { + return super.func_94530_a(p_94530_1_, p_94530_2_); + } +} diff --git a/src/main/java/gtPlusPlus/core/container/Container_FishTrap.java b/src/main/java/gtPlusPlus/core/container/Container_FishTrap.java index a2f44441d9..44079d21e5 100644 --- a/src/main/java/gtPlusPlus/core/container/Container_FishTrap.java +++ b/src/main/java/gtPlusPlus/core/container/Container_FishTrap.java @@ -1,5 +1,9 @@ package gtPlusPlus.core.container; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.inventories.InventoryFishTrap; +import gtPlusPlus.core.slots.SlotNoInput; +import gtPlusPlus.core.tileentities.general.TileEntityFishTrap; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; @@ -7,136 +11,129 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.inventories.InventoryFishTrap; -import gtPlusPlus.core.slots.SlotNoInput; -import gtPlusPlus.core.tileentities.general.TileEntityFishTrap; - public class Container_FishTrap extends Container { - protected TileEntityFishTrap tile_entity; - public final InventoryFishTrap inventoryChest; + protected TileEntityFishTrap tile_entity; + public final InventoryFishTrap inventoryChest; - private final World worldObj; - private final int posX; - private final int posY; - private final int posZ; + private final World worldObj; + private final int posX; + private final int posY; + private final int posZ; - public static int StorageSlotNumber = 15; // Number of slots in storage area - public static int InventorySlotNumber = 36; // Inventory Slots (Inventory - // and Hotbar) - public static int FullSlotNumber = InventorySlotNumber + StorageSlotNumber; // All - // slots + public static int StorageSlotNumber = 15; // Number of slots in storage area + public static int InventorySlotNumber = 36; // Inventory Slots (Inventory + // and Hotbar) + public static int FullSlotNumber = InventorySlotNumber + StorageSlotNumber; // All + // slots - private final int[] slotStorage = new int[15]; + private final int[] slotStorage = new int[15]; - public Container_FishTrap(final InventoryPlayer inventory, final TileEntityFishTrap te) { - this.tile_entity = te; - this.inventoryChest = te.getInventory(); + public Container_FishTrap(final InventoryPlayer inventory, final TileEntityFishTrap te) { + this.tile_entity = te; + this.inventoryChest = te.getInventory(); te.openInventory(); - int var6; - int var7; - this.worldObj = te.getWorldObj(); - this.posX = te.xCoord; - this.posY = te.yCoord; - this.posZ = te.zCoord; - - int o = 0; - - // Storage Side - for (var6 = 0; var6 < 3; var6++) { - for (var7 = 0; var7 < 5; var7++) { - this.slotStorage[o] = o; - this.addSlotToContainer(new SlotNoInput(this.inventoryChest, o++, 44 + (var7 * 18), 15 + (var6 * 18))); - } - } - - // Player Inventory - for (var6 = 0; var6 < 3; ++var6) { - for (var7 = 0; var7 < 9; ++var7) { - this.addSlotToContainer(new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18))); - } - } - - // Player Hotbar - for (var6 = 0; var6 < 9; ++var6) { - this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142)); - } - - } - - @Override - public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold, - final EntityPlayer aPlayer) { - - if (!aPlayer.worldObj.isRemote) { - if ((aSlotIndex == 999) || (aSlotIndex == -999)) { - // Utils.LOG_WARNING("??? - "+aSlotIndex); - } - } - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - @Override - public void onContainerClosed(final EntityPlayer par1EntityPlayer) { - super.onContainerClosed(par1EntityPlayer); - tile_entity.closeInventory(); - } - - @Override - public boolean canInteractWith(final EntityPlayer par1EntityPlayer) { - if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockFishTrap) { - return false; - } - - return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; - } - - @Override - public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) { - ItemStack var3 = null; - final Slot var4 = (Slot) this.inventorySlots.get(par2); - - if ((var4 != null) && var4.getHasStack()) { - final ItemStack var5 = var4.getStack(); - var3 = var5.copy(); - - /* - * if (par2 == 0) { if (!this.mergeItemStack(var5, - * InOutputSlotNumber, FullSlotNumber, true)) { return null; } - * - * var4.onSlotChange(var5, var3); } else if (par2 >= - * InOutputSlotNumber && par2 < InventoryOutSlotNumber) { if - * (!this.mergeItemStack(var5, InventoryOutSlotNumber, - * FullSlotNumber, false)) { return null; } } else if (par2 >= - * InventoryOutSlotNumber && par2 < FullSlotNumber) { if - * (!this.mergeItemStack(var5, InOutputSlotNumber, - * InventoryOutSlotNumber, false)) { return null; } } else if - * (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, - * false)) { return null; } - */ - - if (var5.stackSize == 0) { - var4.putStack((ItemStack) null); - } else { - var4.onSlotChanged(); - } - - if (var5.stackSize == var3.stackSize) { - return null; - } - - var4.onPickupFromSlot(par1EntityPlayer, var5); - } - - return var3; - } - - // Can merge Slot - @Override - public boolean func_94530_a(final ItemStack p_94530_1_, final Slot p_94530_2_) { - return super.func_94530_a(p_94530_1_, p_94530_2_); - } - -} \ No newline at end of file + int var6; + int var7; + this.worldObj = te.getWorldObj(); + this.posX = te.xCoord; + this.posY = te.yCoord; + this.posZ = te.zCoord; + + int o = 0; + + // Storage Side + for (var6 = 0; var6 < 3; var6++) { + for (var7 = 0; var7 < 5; var7++) { + this.slotStorage[o] = o; + this.addSlotToContainer(new SlotNoInput(this.inventoryChest, o++, 44 + (var7 * 18), 15 + (var6 * 18))); + } + } + + // Player Inventory + for (var6 = 0; var6 < 3; ++var6) { + for (var7 = 0; var7 < 9; ++var7) { + this.addSlotToContainer(new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18))); + } + } + + // Player Hotbar + for (var6 = 0; var6 < 9; ++var6) { + this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142)); + } + } + + @Override + public ItemStack slotClick( + final int aSlotIndex, final int aMouseclick, final int aShifthold, final EntityPlayer aPlayer) { + + if (!aPlayer.worldObj.isRemote) { + if ((aSlotIndex == 999) || (aSlotIndex == -999)) { + // Utils.LOG_WARNING("??? - "+aSlotIndex); + } + } + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + @Override + public void onContainerClosed(final EntityPlayer par1EntityPlayer) { + super.onContainerClosed(par1EntityPlayer); + tile_entity.closeInventory(); + } + + @Override + public boolean canInteractWith(final EntityPlayer par1EntityPlayer) { + if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockFishTrap) { + return false; + } + + return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; + } + + @Override + public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) { + ItemStack var3 = null; + final Slot var4 = (Slot) this.inventorySlots.get(par2); + + if ((var4 != null) && var4.getHasStack()) { + final ItemStack var5 = var4.getStack(); + var3 = var5.copy(); + + /* + * if (par2 == 0) { if (!this.mergeItemStack(var5, + * InOutputSlotNumber, FullSlotNumber, true)) { return null; } + * + * var4.onSlotChange(var5, var3); } else if (par2 >= + * InOutputSlotNumber && par2 < InventoryOutSlotNumber) { if + * (!this.mergeItemStack(var5, InventoryOutSlotNumber, + * FullSlotNumber, false)) { return null; } } else if (par2 >= + * InventoryOutSlotNumber && par2 < FullSlotNumber) { if + * (!this.mergeItemStack(var5, InOutputSlotNumber, + * InventoryOutSlotNumber, false)) { return null; } } else if + * (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, + * false)) { return null; } + */ + + if (var5.stackSize == 0) { + var4.putStack((ItemStack) null); + } else { + var4.onSlotChanged(); + } + + if (var5.stackSize == var3.stackSize) { + return null; + } + + var4.onPickupFromSlot(par1EntityPlayer, var5); + } + + return var3; + } + + // Can merge Slot + @Override + public boolean func_94530_a(final ItemStack p_94530_1_, final Slot p_94530_2_) { + return super.func_94530_a(p_94530_1_, p_94530_2_); + } +} diff --git a/src/main/java/gtPlusPlus/core/container/Container_Grindle.java b/src/main/java/gtPlusPlus/core/container/Container_Grindle.java index 4ab79322c9..f0580abb24 100644 --- a/src/main/java/gtPlusPlus/core/container/Container_Grindle.java +++ b/src/main/java/gtPlusPlus/core/container/Container_Grindle.java @@ -1,160 +1,165 @@ package gtPlusPlus.core.container; +import gtPlusPlus.core.inventories.BaseInventoryGrindle; +import gtPlusPlus.core.slots.SlotDataStick; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import gtPlusPlus.core.inventories.BaseInventoryGrindle; -import gtPlusPlus.core.slots.SlotDataStick; - public class Container_Grindle extends Container { - /** - * The Item Inventory for this Container, only needed if you want to reference - * isUseableByPlayer - */ - public final BaseInventoryGrindle inventory; - - /** - * Using these will make transferStackInSlot easier to understand and implement - * INV_START is the index of the first slot in the Player's Inventory, so our - * BaseInventoryBackpack's number of slots (e.g. 5 slots is array indices 0-4, - * so start at 5) Notice how we don't have to remember how many slots we made? - * We can just use BaseInventoryBackpack.INV_SIZE and if we ever change it, the - * Container updates automatically. - */ - private static final int - INV_START = BaseInventoryGrindle.INV_SIZE, - INV_END = INV_START + 0, - HOTBAR_START = INV_END, - HOTBAR_END = HOTBAR_START + 8; - - public Container_Grindle(final EntityPlayer par1Player, final InventoryPlayer inventoryPlayer, - final BaseInventoryGrindle inventoryItem) { - this.inventory = inventoryItem; - - int i; - - // Actual Scan Slot - this.addSlotToContainer(new SlotDataStick(this.inventory, 0, 152, 5)); - - for (i = 1; i < BaseInventoryGrindle.INV_SIZE; ++i) { - this.addSlotToContainer(new SlotDataStick(this.inventory, i, 153, 30 + (18 * i))); - } - - // PLAYER ACTION BAR - uses default locations for standard action bar texture - // file - for (i = 0; i < 9; ++i) { - this.addSlotToContainer(new Slot(inventoryPlayer, i, 8 + (i * 18), 142)); - } - } - - @Override - public boolean canInteractWith(final EntityPlayer entityplayer) { - return this.inventory.isUseableByPlayer(entityplayer); - } - - /** - * Called when a player shift-clicks on a slot. You must override this or you - * will crash when someone does that. - */ - @Override - public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int index) { - ItemStack itemstack = null; - final Slot slot = (Slot) this.inventorySlots.get(index); - - if ((slot != null) && slot.getHasStack()) { - final ItemStack itemstack1 = slot.getStack(); - itemstack = itemstack1.copy(); - - // If item is in our custom Inventory or armor slot - if (index < INV_START) { - // try to place in player inventory / action bar - if (!this.mergeItemStack(itemstack1, INV_START, HOTBAR_END + 1, true)) { - return null; - } - - slot.onSlotChange(itemstack1, itemstack); - } - // Item is in inventory / hotbar, try to place in custom inventory or armor - // slots - else {/* - - * If your inventory only stores certain instances of Items, you can implement - * shift-clicking to your inventory like this: - * - * // Check that the item is the right type if (itemstack1.getItem() instanceof - * ItemCustom) { // Try to merge into your custom inventory slots // We use - * 'BaseInventoryBackpack.INV_SIZE' instead of INV_START just in case // you - * also add armor or other custom slots if (!this.mergeItemStack(itemstack1, 0, - * BaseInventoryBackpack.INV_SIZE, false)) { return null; } } // If you added - * armor slots, check them here as well: // Item being shift-clicked is armor - - * try to put in armor slot if (itemstack1.getItem() instanceof ItemArmor) { int - * type = ((ItemArmor) itemstack1.getItem()).armorType; if - * (!this.mergeItemStack(itemstack1, ARMOR_START + type, ARMOR_START + type + 1, - * false)) { return null; } } Otherwise, you have basically 2 choices: 1. - * shift-clicking between player inventory and custom inventory 2. - * shift-clicking between action bar and inventory - * - * Be sure to choose only ONE of the following implementations!!! - - *//** - * Implementation number 1: Shift-click into your custom inventory - *//* - if (index >= INV_START) { - // place in custom inventory - if (!this.mergeItemStack(itemstack1, 0, INV_START, false)) { - return null; - } - } - - *//** - * Implementation number 2: Shift-click items between action bar and inventory - *//* - // item is in player's inventory, but not in action bar - if ((index >= INV_START) && (index < HOTBAR_START)) { - // place in action bar - if (!this.mergeItemStack(itemstack1, HOTBAR_START, HOTBAR_END + 1, false)) { - return null; - } - } - // item in action bar - place in player inventory - else if ((index >= HOTBAR_START) && (index < (HOTBAR_END + 1))) { - if (!this.mergeItemStack(itemstack1, INV_START, INV_END + 1, false)) { - return null; - } - } - */} - - if (itemstack1.stackSize == 0) { - slot.putStack((ItemStack) null); - } else { - slot.onSlotChanged(); - } - - if (itemstack1.stackSize == itemstack.stackSize) { - return null; - } - - slot.onPickupFromSlot(par1EntityPlayer, itemstack1); - } - - return itemstack; - } - - /** - * You should override this method to prevent the player from moving the stack - * that opened the inventory, otherwise if the player moves it, the inventory - * will not be able to save properly - */ - @Override - public ItemStack slotClick(final int slot, final int button, final int flag, final EntityPlayer player) { - // this will prevent the player from interacting with the item that opened the - // inventory: - if ((slot >= 0) && (this.getSlot(slot) != null) && (this.getSlot(slot).getStack() == player.getHeldItem())) { - return null; - } - return super.slotClick(slot, button, flag, player); - } + /** + * The Item Inventory for this Container, only needed if you want to reference + * isUseableByPlayer + */ + public final BaseInventoryGrindle inventory; + + /** + * Using these will make transferStackInSlot easier to understand and implement + * INV_START is the index of the first slot in the Player's Inventory, so our + * BaseInventoryBackpack's number of slots (e.g. 5 slots is array indices 0-4, + * so start at 5) Notice how we don't have to remember how many slots we made? + * We can just use BaseInventoryBackpack.INV_SIZE and if we ever change it, the + * Container updates automatically. + */ + private static final int INV_START = BaseInventoryGrindle.INV_SIZE, + INV_END = INV_START + 0, + HOTBAR_START = INV_END, + HOTBAR_END = HOTBAR_START + 8; + + public Container_Grindle( + final EntityPlayer par1Player, + final InventoryPlayer inventoryPlayer, + final BaseInventoryGrindle inventoryItem) { + this.inventory = inventoryItem; + + int i; + + // Actual Scan Slot + this.addSlotToContainer(new SlotDataStick(this.inventory, 0, 152, 5)); + + for (i = 1; i < BaseInventoryGrindle.INV_SIZE; ++i) { + this.addSlotToContainer(new SlotDataStick(this.inventory, i, 153, 30 + (18 * i))); + } + + // PLAYER ACTION BAR - uses default locations for standard action bar texture + // file + for (i = 0; i < 9; ++i) { + this.addSlotToContainer(new Slot(inventoryPlayer, i, 8 + (i * 18), 142)); + } + } + + @Override + public boolean canInteractWith(final EntityPlayer entityplayer) { + return this.inventory.isUseableByPlayer(entityplayer); + } + + /** + * Called when a player shift-clicks on a slot. You must override this or you + * will crash when someone does that. + */ + @Override + public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int index) { + ItemStack itemstack = null; + final Slot slot = (Slot) this.inventorySlots.get(index); + + if ((slot != null) && slot.getHasStack()) { + final ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + // If item is in our custom Inventory or armor slot + if (index < INV_START) { + // try to place in player inventory / action bar + if (!this.mergeItemStack(itemstack1, INV_START, HOTBAR_END + 1, true)) { + return null; + } + + slot.onSlotChange(itemstack1, itemstack); + } + // Item is in inventory / hotbar, try to place in custom inventory or armor + // slots + else { + /* + + * If your inventory only stores certain instances of Items, you can implement + * shift-clicking to your inventory like this: + * + * // Check that the item is the right type if (itemstack1.getItem() instanceof + * ItemCustom) { // Try to merge into your custom inventory slots // We use + * 'BaseInventoryBackpack.INV_SIZE' instead of INV_START just in case // you + * also add armor or other custom slots if (!this.mergeItemStack(itemstack1, 0, + * BaseInventoryBackpack.INV_SIZE, false)) { return null; } } // If you added + * armor slots, check them here as well: // Item being shift-clicked is armor - + * try to put in armor slot if (itemstack1.getItem() instanceof ItemArmor) { int + * type = ((ItemArmor) itemstack1.getItem()).armorType; if + * (!this.mergeItemStack(itemstack1, ARMOR_START + type, ARMOR_START + type + 1, + * false)) { return null; } } Otherwise, you have basically 2 choices: 1. + * shift-clicking between player inventory and custom inventory 2. + * shift-clicking between action bar and inventory + * + * Be sure to choose only ONE of the following implementations!!! + + */ + /** + * Implementation number 1: Shift-click into your custom inventory + */ + /* + if (index >= INV_START) { + // place in custom inventory + if (!this.mergeItemStack(itemstack1, 0, INV_START, false)) { + return null; + } + } + + */ + /** + * Implementation number 2: Shift-click items between action bar and inventory + */ + /* + // item is in player's inventory, but not in action bar + if ((index >= INV_START) && (index < HOTBAR_START)) { + // place in action bar + if (!this.mergeItemStack(itemstack1, HOTBAR_START, HOTBAR_END + 1, false)) { + return null; + } + } + // item in action bar - place in player inventory + else if ((index >= HOTBAR_START) && (index < (HOTBAR_END + 1))) { + if (!this.mergeItemStack(itemstack1, INV_START, INV_END + 1, false)) { + return null; + } + } + */ } + + if (itemstack1.stackSize == 0) { + slot.putStack((ItemStack) null); + } else { + slot.onSlotChanged(); + } + + if (itemstack1.stackSize == itemstack.stackSize) { + return null; + } + + slot.onPickupFromSlot(par1EntityPlayer, itemstack1); + } + + return itemstack; + } + + /** + * You should override this method to prevent the player from moving the stack + * that opened the inventory, otherwise if the player moves it, the inventory + * will not be able to save properly + */ + @Override + public ItemStack slotClick(final int slot, final int button, final int flag, final EntityPlayer player) { + // this will prevent the player from interacting with the item that opened the + // inventory: + if ((slot >= 0) && (this.getSlot(slot) != null) && (this.getSlot(slot).getStack() == player.getHeldItem())) { + return null; + } + return super.slotClick(slot, button, flag, player); + } } diff --git a/src/main/java/gtPlusPlus/core/container/Container_HeliumGenerator.java b/src/main/java/gtPlusPlus/core/container/Container_HeliumGenerator.java index 39e07f2f0e..3bda62a403 100644 --- a/src/main/java/gtPlusPlus/core/container/Container_HeliumGenerator.java +++ b/src/main/java/gtPlusPlus/core/container/Container_HeliumGenerator.java @@ -1,193 +1,170 @@ package gtPlusPlus.core.container; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.inventories.InventoryHeliumGenerator; import gtPlusPlus.core.slots.SlotFuelRod; import gtPlusPlus.core.slots.SlotNoInput; import gtPlusPlus.core.tileentities.general.TileEntityHeliumGenerator; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; public class Container_HeliumGenerator extends Container { - protected TileEntityHeliumGenerator tile_entity; - public final InventoryHeliumGenerator inventoryChest; - - private final World worldObj; - private final int posX; - private final int posY; - private final int posZ; - - - public static int StorageSlotNumber = 19; //Number of slots in storage area - public static int InventorySlotNumber = 36; //Inventory Slots (Inventory and Hotbar) - public static int FullSlotNumber = InventorySlotNumber + StorageSlotNumber; //All slots - - //0 Is output, 1-18 are input. - private final int[] slotStorage = new int[19]; - - public Container_HeliumGenerator(final InventoryPlayer inventory, final TileEntityHeliumGenerator te){ - this.tile_entity = te; - this.inventoryChest = te.getInventory(); - - int var6; - int var7; - this.worldObj = te.getWorldObj(); - this.posX = te.xCoord; - this.posY = te.yCoord; - this.posZ = te.zCoord; - - int o=0; - - //Output - this.addSlotToContainer(new SlotNoInput(this.inventoryChest, 0, 80, 53)); - this.slotStorage[o] = o; - o++; - - //Side A - for (var6 = 0; var6 < 3; ++var6) - { - for (var7 = 0; var7 < 3; ++var7) - { - Logger.INFO("Adding slots at var:"+(o)+" x:"+(8 + var7 * 18)+" y:"+(9 + var6 * 18)); - this.addSlotToContainer(new SlotFuelRod(this.inventoryChest, o, 8 + (var7 * 18), 18 + (var6 * 18))); - this.slotStorage[o] = o; - o++; - } - } - - //Side B - for (var6 = 0; var6 < 3; ++var6) - { - for (var7 = 0; var7 < 3; ++var7) - { - Logger.INFO("Adding slots at var:"+(o)+" x:"+(90+8+(var7 * 18))+" y:"+(9 + var6 * 18)); - this.addSlotToContainer(new SlotFuelRod(this.inventoryChest, o, 116 + (var7 * 18), 18 + (var6 * 18))); - this.slotStorage[o] = o; - o++; - } - } - - o=0; - - //Player Inventory - for (var6 = 0; var6 < 3; ++var6) - { - for (var7 = 0; var7 < 9; ++var7) - { - this.addSlotToContainer(new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18))); - } - } - - //Player Hotbar - for (var6 = 0; var6 < 9; ++var6) - { - this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142)); - } - - } - - @Override - public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold, final EntityPlayer aPlayer){ - - if (!aPlayer.worldObj.isRemote){ - if ((aSlotIndex == 999) || (aSlotIndex == -999)){ - //Utils.LOG_WARNING("??? - "+aSlotIndex); - } - } - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - - - - - @Override - public void onContainerClosed(final EntityPlayer par1EntityPlayer){ - super.onContainerClosed(par1EntityPlayer); - } - - - @Override - public boolean canInteractWith(final EntityPlayer par1EntityPlayer){ - if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockHeliumGenerator){ - return false; - } - - return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; - } - - - @Override - public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) - { - ItemStack var3 = null; - final Slot var4 = (Slot)this.inventorySlots.get(par2); - - if ((var4 != null) && var4.getHasStack()) - { - final ItemStack var5 = var4.getStack(); - var3 = var5.copy(); - - /*if (par2 == 0) - { - if (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, true)) - { - return null; - } - - var4.onSlotChange(var5, var3); - } - else if (par2 >= InOutputSlotNumber && par2 < InventoryOutSlotNumber) - { - if (!this.mergeItemStack(var5, InventoryOutSlotNumber, FullSlotNumber, false)) - { - return null; - } - } - else if (par2 >= InventoryOutSlotNumber && par2 < FullSlotNumber) - { - if (!this.mergeItemStack(var5, InOutputSlotNumber, InventoryOutSlotNumber, false)) - { - return null; - } - } - else if (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, false)) - { - return null; - }*/ - - if (var5.stackSize == 0) - { - var4.putStack((ItemStack)null); - } - else - { - var4.onSlotChanged(); - } - - if (var5.stackSize == var3.stackSize) - { - return null; - } - - var4.onPickupFromSlot(par1EntityPlayer, var5); - } - - return var3; - } - - //Can merge Slot - @Override - public boolean func_94530_a(final ItemStack p_94530_1_, final Slot p_94530_2_) { - return super.func_94530_a(p_94530_1_, p_94530_2_); - } - - -} \ No newline at end of file + protected TileEntityHeliumGenerator tile_entity; + public final InventoryHeliumGenerator inventoryChest; + + private final World worldObj; + private final int posX; + private final int posY; + private final int posZ; + + public static int StorageSlotNumber = 19; // Number of slots in storage area + public static int InventorySlotNumber = 36; // Inventory Slots (Inventory and Hotbar) + public static int FullSlotNumber = InventorySlotNumber + StorageSlotNumber; // All slots + + // 0 Is output, 1-18 are input. + private final int[] slotStorage = new int[19]; + + public Container_HeliumGenerator(final InventoryPlayer inventory, final TileEntityHeliumGenerator te) { + this.tile_entity = te; + this.inventoryChest = te.getInventory(); + + int var6; + int var7; + this.worldObj = te.getWorldObj(); + this.posX = te.xCoord; + this.posY = te.yCoord; + this.posZ = te.zCoord; + + int o = 0; + + // Output + this.addSlotToContainer(new SlotNoInput(this.inventoryChest, 0, 80, 53)); + this.slotStorage[o] = o; + o++; + + // Side A + for (var6 = 0; var6 < 3; ++var6) { + for (var7 = 0; var7 < 3; ++var7) { + Logger.INFO("Adding slots at var:" + (o) + " x:" + (8 + var7 * 18) + " y:" + (9 + var6 * 18)); + this.addSlotToContainer(new SlotFuelRod(this.inventoryChest, o, 8 + (var7 * 18), 18 + (var6 * 18))); + this.slotStorage[o] = o; + o++; + } + } + + // Side B + for (var6 = 0; var6 < 3; ++var6) { + for (var7 = 0; var7 < 3; ++var7) { + Logger.INFO("Adding slots at var:" + (o) + " x:" + (90 + 8 + (var7 * 18)) + " y:" + (9 + var6 * 18)); + this.addSlotToContainer(new SlotFuelRod(this.inventoryChest, o, 116 + (var7 * 18), 18 + (var6 * 18))); + this.slotStorage[o] = o; + o++; + } + } + + o = 0; + + // Player Inventory + for (var6 = 0; var6 < 3; ++var6) { + for (var7 = 0; var7 < 9; ++var7) { + this.addSlotToContainer(new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18))); + } + } + + // Player Hotbar + for (var6 = 0; var6 < 9; ++var6) { + this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142)); + } + } + + @Override + public ItemStack slotClick( + final int aSlotIndex, final int aMouseclick, final int aShifthold, final EntityPlayer aPlayer) { + + if (!aPlayer.worldObj.isRemote) { + if ((aSlotIndex == 999) || (aSlotIndex == -999)) { + // Utils.LOG_WARNING("??? - "+aSlotIndex); + } + } + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + @Override + public void onContainerClosed(final EntityPlayer par1EntityPlayer) { + super.onContainerClosed(par1EntityPlayer); + } + + @Override + public boolean canInteractWith(final EntityPlayer par1EntityPlayer) { + if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockHeliumGenerator) { + return false; + } + + return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; + } + + @Override + public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) { + ItemStack var3 = null; + final Slot var4 = (Slot) this.inventorySlots.get(par2); + + if ((var4 != null) && var4.getHasStack()) { + final ItemStack var5 = var4.getStack(); + var3 = var5.copy(); + + /*if (par2 == 0) + { + if (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, true)) + { + return null; + } + + var4.onSlotChange(var5, var3); + } + else if (par2 >= InOutputSlotNumber && par2 < InventoryOutSlotNumber) + { + if (!this.mergeItemStack(var5, InventoryOutSlotNumber, FullSlotNumber, false)) + { + return null; + } + } + else if (par2 >= InventoryOutSlotNumber && par2 < FullSlotNumber) + { + if (!this.mergeItemStack(var5, InOutputSlotNumber, InventoryOutSlotNumber, false)) + { + return null; + } + } + else if (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, false)) + { + return null; + }*/ + + if (var5.stackSize == 0) { + var4.putStack((ItemStack) null); + } else { + var4.onSlotChanged(); + } + + if (var5.stackSize == var3.stackSize) { + return null; + } + + var4.onPickupFromSlot(par1EntityPlayer, var5); + } + + return var3; + } + + // Can merge Slot + @Override + public boolean func_94530_a(final ItemStack p_94530_1_, final Slot p_94530_2_) { + return super.func_94530_a(p_94530_1_, p_94530_2_); + } +} diff --git a/src/main/java/gtPlusPlus/core/container/Container_ModularityTable.java b/src/main/java/gtPlusPlus/core/container/Container_ModularityTable.java index e0fb51fe61..602de2447b 100644 --- a/src/main/java/gtPlusPlus/core/container/Container_ModularityTable.java +++ b/src/main/java/gtPlusPlus/core/container/Container_ModularityTable.java @@ -1,12 +1,5 @@ package gtPlusPlus.core.container; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.inventories.modulartable.InventoryModularMain; @@ -15,238 +8,234 @@ import gtPlusPlus.core.slots.SlotModularBauble; import gtPlusPlus.core.slots.SlotModularBaubleUpgrades; import gtPlusPlus.core.slots.SlotNoInput; import gtPlusPlus.core.tileentities.machines.TileEntityModularityTable; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; public class Container_ModularityTable extends Container { - /** The crafting matrix inventory (3x3). */ - - protected TileEntityModularityTable tile_entity; - public final InventoryModularMain inventoryGrid; - public final InventoryModularOutput inventoryOutputs; - public int mRecipeTime; - - private final World worldObj; - private final int posX; - private final int posY; - private final int posZ; - - private final int[] slotOutputs = new int[3]; - private final int[] slotGrid = new int[9]; - - - public Container_ModularityTable(final InventoryPlayer inventory, final TileEntityModularityTable tile){ - this.tile_entity = tile; - this.inventoryGrid = tile.inventoryGrid; - this.inventoryOutputs = tile.inventoryOutputs; - this.tile_entity.setContainer(this); - this.mRecipeTime = this.tile_entity.getRecipeTime(); - Logger.INFO("Container: "+this.mRecipeTime); - - int var6; - int var7; - this.worldObj = tile.getWorldObj(); - this.posX = tile.xCoord; - this.posY = tile.yCoord; - this.posZ = tile.zCoord; - - int nextFreeSlot = 0; - - - //Output slots - this.addSlotToContainer(new SlotModularBauble(this.inventoryOutputs, 0, 26+(18*6), 8)); - this.addSlotToContainer(new SlotModularBaubleUpgrades(this.inventoryOutputs, 1, 26+(18*5), 8)); - this.addSlotToContainer(new SlotNoInput(this.inventoryOutputs, 2, 26+(18*6), 44)); - - int o = 0; - - //Storage Side - for (var6 = 0; var6 < 3; ++var6) - { - for (var7 = 0; var7 < 3; ++var7) - { - //Utils.LOG_WARNING("Adding slots at var:"+(var7 + var6 * 4)+" x:"+(8 + var7 * 18)+" y:"+(7 + var6 * 18)); - this.addSlotToContainer(new SlotModularBaubleUpgrades(this.inventoryGrid, nextFreeSlot, 8+18 + (var7 * 18), 17 + (var6 * 18))); - this.slotGrid[o] = nextFreeSlot; - nextFreeSlot++; - o++; - } - } - - //Player Inventory - for (var6 = 0; var6 < 3; ++var6) - { - for (var7 = 0; var7 < 9; ++var7) - { - this.addSlotToContainer(new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18))); - } - } - - //Player Hotbar - for (var6 = 0; var6 < 9; ++var6) - { - this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142)); - } - - //this.onCraftMatrixChanged(this.craftMatrix); - - } - - /** - * Callback for when the crafting matrix is changed. - */ - /* public void onCraftMatrixChanged(IInventory p_75130_1_) + /** The crafting matrix inventory (3x3). */ + protected TileEntityModularityTable tile_entity; + + public final InventoryModularMain inventoryGrid; + public final InventoryModularOutput inventoryOutputs; + public int mRecipeTime; + + private final World worldObj; + private final int posX; + private final int posY; + private final int posZ; + + private final int[] slotOutputs = new int[3]; + private final int[] slotGrid = new int[9]; + + public Container_ModularityTable(final InventoryPlayer inventory, final TileEntityModularityTable tile) { + this.tile_entity = tile; + this.inventoryGrid = tile.inventoryGrid; + this.inventoryOutputs = tile.inventoryOutputs; + this.tile_entity.setContainer(this); + this.mRecipeTime = this.tile_entity.getRecipeTime(); + Logger.INFO("Container: " + this.mRecipeTime); + + int var6; + int var7; + this.worldObj = tile.getWorldObj(); + this.posX = tile.xCoord; + this.posY = tile.yCoord; + this.posZ = tile.zCoord; + + int nextFreeSlot = 0; + + // Output slots + this.addSlotToContainer(new SlotModularBauble(this.inventoryOutputs, 0, 26 + (18 * 6), 8)); + this.addSlotToContainer(new SlotModularBaubleUpgrades(this.inventoryOutputs, 1, 26 + (18 * 5), 8)); + this.addSlotToContainer(new SlotNoInput(this.inventoryOutputs, 2, 26 + (18 * 6), 44)); + + int o = 0; + + // Storage Side + for (var6 = 0; var6 < 3; ++var6) { + for (var7 = 0; var7 < 3; ++var7) { + // Utils.LOG_WARNING("Adding slots at var:"+(var7 + var6 * 4)+" x:"+(8 + var7 * 18)+" y:"+(7 + var6 * + // 18)); + this.addSlotToContainer(new SlotModularBaubleUpgrades( + this.inventoryGrid, nextFreeSlot, 8 + 18 + (var7 * 18), 17 + (var6 * 18))); + this.slotGrid[o] = nextFreeSlot; + nextFreeSlot++; + o++; + } + } + + // Player Inventory + for (var6 = 0; var6 < 3; ++var6) { + for (var7 = 0; var7 < 9; ++var7) { + this.addSlotToContainer(new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18))); + } + } + + // Player Hotbar + for (var6 = 0; var6 < 9; ++var6) { + this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142)); + } + + // this.onCraftMatrixChanged(this.craftMatrix); + + } + + /** + * Callback for when the crafting matrix is changed. + */ + /* public void onCraftMatrixChanged(IInventory p_75130_1_) { this.craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj)); }*/ - /** - * Called when the container is closed. - */ - @Override - public void onContainerClosed(EntityPlayer p_75134_1_){ - super.onContainerClosed(p_75134_1_); - if (!this.worldObj.isRemote){ - /* for (int i = 0; i < 9; ++i){ + /** + * Called when the container is closed. + */ + @Override + public void onContainerClosed(EntityPlayer p_75134_1_) { + super.onContainerClosed(p_75134_1_); + if (!this.worldObj.isRemote) { + /* for (int i = 0; i < 9; ++i){ ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i); if (itemstack != null){ p_75134_1_.dropPlayerItemWithRandomChoice(itemstack, false); } }*/ - } - } - - public TileEntityModularityTable getTileentityViaContainer(){ - if (this.tile_entity != null){ - return this.tile_entity; - } - return null; - } - - @Override - public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold, final EntityPlayer aPlayer){ - - if (!aPlayer.worldObj.isRemote){ - if ((aSlotIndex == 999) || (aSlotIndex == -999)){ - //Utils.LOG_WARNING("??? - "+aSlotIndex); - } - - if (aSlotIndex == 0){ - Logger.INFO("Player Clicked on the bauble slot"); - //TODO - } - else if (aSlotIndex == 1){ - Logger.INFO("Player Clicked on the upgrade slot"); - //TODO - } - else if (aSlotIndex == 2){ - Logger.INFO("Player Clicked on the output slot"); - //TODO - } - else { - for (final int x : this.slotGrid){ - if (aSlotIndex == x){ - Logger.INFO("Player Clicked slot "+aSlotIndex+" in the crafting Grid"); - } - } - } - } - //Utils.LOG_WARNING("Player Clicked slot "+aSlotIndex+" in the Grid"); - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - @Override - public boolean canInteractWith(final EntityPlayer par1EntityPlayer){ - if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockModularTable){ - return false; - } - - return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; - } - - - @Override - public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) - { - - return null; - - /*ItemStack var3 = null; - final Slot var4 = (Slot)this.inventorySlots.get(par2); - - if ((var4 != null) && var4.getHasStack()) - { - final ItemStack var5 = var4.getStack(); - var3 = var5.copy(); - - if (par2 == 0) - { - if (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, true)) - { - return null; - } - - var4.onSlotChange(var5, var3); - } - else if ((par2 >= InOutputSlotNumber) && (par2 < InventoryOutSlotNumber)) - { - if (!this.mergeItemStack(var5, InventoryOutSlotNumber, FullSlotNumber, false)) - { - return null; - } - } - else if ((par2 >= InventoryOutSlotNumber) && (par2 < FullSlotNumber)) - { - if (!this.mergeItemStack(var5, InOutputSlotNumber, InventoryOutSlotNumber, false)) - { - return null; - } - } - else if (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, false)) - { - return null; - } - - if (var5.stackSize == 0) - { - var4.putStack((ItemStack)null); - } - else - { - var4.onSlotChanged(); - } - - if (var5.stackSize == var3.stackSize) - { - return null; - } - - var4.onPickupFromSlot(par1EntityPlayer, var5); - } - - return var3;*/ - } - - //Can merge Slot - /*public boolean func_94530_a(ItemStack p_94530_1_, Slot p_94530_2_){ + } + } + + public TileEntityModularityTable getTileentityViaContainer() { + if (this.tile_entity != null) { + return this.tile_entity; + } + return null; + } + + @Override + public ItemStack slotClick( + final int aSlotIndex, final int aMouseclick, final int aShifthold, final EntityPlayer aPlayer) { + + if (!aPlayer.worldObj.isRemote) { + if ((aSlotIndex == 999) || (aSlotIndex == -999)) { + // Utils.LOG_WARNING("??? - "+aSlotIndex); + } + + if (aSlotIndex == 0) { + Logger.INFO("Player Clicked on the bauble slot"); + // TODO + } else if (aSlotIndex == 1) { + Logger.INFO("Player Clicked on the upgrade slot"); + // TODO + } else if (aSlotIndex == 2) { + Logger.INFO("Player Clicked on the output slot"); + // TODO + } else { + for (final int x : this.slotGrid) { + if (aSlotIndex == x) { + Logger.INFO("Player Clicked slot " + aSlotIndex + " in the crafting Grid"); + } + } + } + } + // Utils.LOG_WARNING("Player Clicked slot "+aSlotIndex+" in the Grid"); + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + @Override + public boolean canInteractWith(final EntityPlayer par1EntityPlayer) { + if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockModularTable) { + return false; + } + + return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; + } + + @Override + public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) { + + return null; + + /*ItemStack var3 = null; + final Slot var4 = (Slot)this.inventorySlots.get(par2); + + if ((var4 != null) && var4.getHasStack()) + { + final ItemStack var5 = var4.getStack(); + var3 = var5.copy(); + + if (par2 == 0) + { + if (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, true)) + { + return null; + } + + var4.onSlotChange(var5, var3); + } + else if ((par2 >= InOutputSlotNumber) && (par2 < InventoryOutSlotNumber)) + { + if (!this.mergeItemStack(var5, InventoryOutSlotNumber, FullSlotNumber, false)) + { + return null; + } + } + else if ((par2 >= InventoryOutSlotNumber) && (par2 < FullSlotNumber)) + { + if (!this.mergeItemStack(var5, InOutputSlotNumber, InventoryOutSlotNumber, false)) + { + return null; + } + } + else if (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, false)) + { + return null; + } + + if (var5.stackSize == 0) + { + var4.putStack((ItemStack)null); + } + else + { + var4.onSlotChanged(); + } + + if (var5.stackSize == var3.stackSize) + { + return null; + } + + var4.onPickupFromSlot(par1EntityPlayer, var5); + } + + return var3;*/ + } + + // Can merge Slot + /*public boolean func_94530_a(ItemStack p_94530_1_, Slot p_94530_2_){ return p_94530_2_.inventory != this.craftResult && super.func_94530_a(p_94530_1_, p_94530_2_); }*/ - /*public ItemStack getOutputContent(){ - ItemStack output = this.craftResult.getStackInSlot(0); - if (output != null){ - return output; - } - return null; - } - - public ItemStack[] getInputComponents(){ - ItemStack inputs[] = new ItemStack[9]; - for (int r=0;r= - * InOutputSlotNumber && par2 < InventoryOutSlotNumber) { if - * (!this.mergeItemStack(var5, InventoryOutSlotNumber, - * FullSlotNumber, false)) { return null; } } else if (par2 >= - * InventoryOutSlotNumber && par2 < FullSlotNumber) { if - * (!this.mergeItemStack(var5, InOutputSlotNumber, - * InventoryOutSlotNumber, false)) { return null; } } else if - * (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, - * false)) { return null; } - */ - - if (var5.stackSize == 0) { - var4.putStack((ItemStack) null); - } else { - var4.onSlotChanged(); - } - - if (var5.stackSize == var3.stackSize) { - return null; - } - - var4.onPickupFromSlot(par1EntityPlayer, var5); - } - - return var3; - } - - // Can merge Slot - @Override - public boolean func_94530_a(final ItemStack p_94530_1_, final Slot p_94530_2_) { - return super.func_94530_a(p_94530_1_, p_94530_2_); - } - -} \ No newline at end of file + // Player Inventory + for (var6 = 0; var6 < 3; ++var6) { + for (var7 = 0; var7 < 9; ++var7) { + this.addSlotToContainer(new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18))); + } + } + + // Player Hotbar + for (var6 = 0; var6 < 9; ++var6) { + this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142)); + } + } + + public FluidStack getFluidOfStoredTank() { + if (tile_entity != null) { + if (tile_entity.getTank() != null) { + return tile_entity.getTank().getFluid(); + } + } + return null; + } + + public int getFluidStoredAmount() { + FluidStack f = getFluidOfStoredTank(); + return f == null ? 0 : f.amount; + } + + @Override + public ItemStack slotClick( + final int aSlotIndex, final int aMouseclick, final int aShifthold, final EntityPlayer aPlayer) { + boolean fluid = false; + if (aSlotIndex == 2) { + fluid = true; + } + if (!fluid) { + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } else { + return null; + } + } + + @Override + public void onContainerClosed(final EntityPlayer par1EntityPlayer) { + super.onContainerClosed(par1EntityPlayer); + tile_entity.closeInventory(); + } + + @Override + public boolean canInteractWith(final EntityPlayer par1EntityPlayer) { + if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockPestKiller) { + return false; + } + return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; + } + + @Override + public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) { + ItemStack var3 = null; + final Slot var4 = (Slot) this.inventorySlots.get(par2); + + if ((var4 != null) && var4.getHasStack()) { + final ItemStack var5 = var4.getStack(); + var3 = var5.copy(); + + /* + * if (par2 == 0) { if (!this.mergeItemStack(var5, + * InOutputSlotNumber, FullSlotNumber, true)) { return null; } + * + * var4.onSlotChange(var5, var3); } else if (par2 >= + * InOutputSlotNumber && par2 < InventoryOutSlotNumber) { if + * (!this.mergeItemStack(var5, InventoryOutSlotNumber, + * FullSlotNumber, false)) { return null; } } else if (par2 >= + * InventoryOutSlotNumber && par2 < FullSlotNumber) { if + * (!this.mergeItemStack(var5, InOutputSlotNumber, + * InventoryOutSlotNumber, false)) { return null; } } else if + * (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, + * false)) { return null; } + */ + + if (var5.stackSize == 0) { + var4.putStack((ItemStack) null); + } else { + var4.onSlotChanged(); + } + + if (var5.stackSize == var3.stackSize) { + return null; + } + + var4.onPickupFromSlot(par1EntityPlayer, var5); + } + + return var3; + } + + // Can merge Slot + @Override + public boolean func_94530_a(final ItemStack p_94530_1_, final Slot p_94530_2_) { + return super.func_94530_a(p_94530_1_, p_94530_2_); + } +} diff --git a/src/main/java/gtPlusPlus/core/container/Container_ProjectTable.java b/src/main/java/gtPlusPlus/core/container/Container_ProjectTable.java index 2cdf7ee783..63eeb3fcae 100644 --- a/src/main/java/gtPlusPlus/core/container/Container_ProjectTable.java +++ b/src/main/java/gtPlusPlus/core/container/Container_ProjectTable.java @@ -1,12 +1,5 @@ package gtPlusPlus.core.container; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.*; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.CraftingManager; -import net.minecraft.world.World; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.inventories.projecttable.InventoryProjectMain; @@ -15,228 +8,226 @@ import gtPlusPlus.core.slots.SlotCraftingNoCollect; import gtPlusPlus.core.slots.SlotDataStick; import gtPlusPlus.core.slots.SlotNoInput; import gtPlusPlus.core.tileentities.machines.TileEntityProjectTable; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.*; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.world.World; public class Container_ProjectTable extends Container { - /** The crafting matrix inventory (3x3). */ + /** The crafting matrix inventory (3x3). */ public InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3); + public IInventory craftResult = new InventoryCraftResult(); - - protected TileEntityProjectTable tile_entity; - public final InventoryProjectMain inventoryGrid; - public final InventoryProjectOutput inventoryOutputs; - - private final World worldObj; - private final int posX; - private final int posY; - private final int posZ; - - private final int[] slotOutputs = new int[2]; - private final int[] slotGrid = new int[9]; - - - public Container_ProjectTable(final InventoryPlayer inventory, final TileEntityProjectTable tile){ - this.tile_entity = tile; - this.inventoryGrid = tile.inventoryGrid; - this.inventoryOutputs = tile.inventoryOutputs; - this.tile_entity.setContainer(this); - - int var6; - int var7; - this.worldObj = tile.getWorldObj(); - this.posX = tile.xCoord; - this.posY = tile.yCoord; - this.posZ = tile.zCoord; - - int nextFreeSlot = 0; - - - //Output slots - this.addSlotToContainer(new SlotDataStick(this.inventoryOutputs, 0, 26+(18*6), 8)); - this.addSlotToContainer(new SlotNoInput(this.inventoryOutputs, 1, 26+(18*6), 44)); - - this.addSlotToContainer(new SlotCraftingNoCollect(inventory.player, this.craftMatrix, this.craftResult, 0, 26+(18*4), 25)); - - - int o = 0; - //Storage Side - for (var6 = 0; var6 < 3; ++var6) - { - for (var7 = 0; var7 < 3; ++var7) - { - //Utils.LOG_WARNING("Adding slots at var:"+(var7 + var6 * 4)+" x:"+(8 + var7 * 18)+" y:"+(7 + var6 * 18)); - this.addSlotToContainer(new Slot(this.craftMatrix, nextFreeSlot, 8+18 + (var7 * 18), 8 + (var6 * 18))); - this.slotGrid[o] = nextFreeSlot; - nextFreeSlot++; - o++; - } - } - - - //Player Inventory - for (var6 = 0; var6 < 3; ++var6) - { - for (var7 = 0; var7 < 9; ++var7) - { - this.addSlotToContainer(new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18))); - } - } - - //Player Hotbar - for (var6 = 0; var6 < 9; ++var6) - { - this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142)); - } - + + protected TileEntityProjectTable tile_entity; + public final InventoryProjectMain inventoryGrid; + public final InventoryProjectOutput inventoryOutputs; + + private final World worldObj; + private final int posX; + private final int posY; + private final int posZ; + + private final int[] slotOutputs = new int[2]; + private final int[] slotGrid = new int[9]; + + public Container_ProjectTable(final InventoryPlayer inventory, final TileEntityProjectTable tile) { + this.tile_entity = tile; + this.inventoryGrid = tile.inventoryGrid; + this.inventoryOutputs = tile.inventoryOutputs; + this.tile_entity.setContainer(this); + + int var6; + int var7; + this.worldObj = tile.getWorldObj(); + this.posX = tile.xCoord; + this.posY = tile.yCoord; + this.posZ = tile.zCoord; + + int nextFreeSlot = 0; + + // Output slots + this.addSlotToContainer(new SlotDataStick(this.inventoryOutputs, 0, 26 + (18 * 6), 8)); + this.addSlotToContainer(new SlotNoInput(this.inventoryOutputs, 1, 26 + (18 * 6), 44)); + + this.addSlotToContainer( + new SlotCraftingNoCollect(inventory.player, this.craftMatrix, this.craftResult, 0, 26 + (18 * 4), 25)); + + int o = 0; + // Storage Side + for (var6 = 0; var6 < 3; ++var6) { + for (var7 = 0; var7 < 3; ++var7) { + // Utils.LOG_WARNING("Adding slots at var:"+(var7 + var6 * 4)+" x:"+(8 + var7 * 18)+" y:"+(7 + var6 * + // 18)); + this.addSlotToContainer( + new Slot(this.craftMatrix, nextFreeSlot, 8 + 18 + (var7 * 18), 8 + (var6 * 18))); + this.slotGrid[o] = nextFreeSlot; + nextFreeSlot++; + o++; + } + } + + // Player Inventory + for (var6 = 0; var6 < 3; ++var6) { + for (var7 = 0; var7 < 9; ++var7) { + this.addSlotToContainer(new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18))); + } + } + + // Player Hotbar + for (var6 = 0; var6 < 9; ++var6) { + this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142)); + } + this.onCraftMatrixChanged(this.craftMatrix); + } - } - - /** + /** * Callback for when the crafting matrix is changed. */ @Override - public void onCraftMatrixChanged(IInventory p_75130_1_) - { - this.craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj)); + public void onCraftMatrixChanged(IInventory p_75130_1_) { + this.craftResult.setInventorySlotContents( + 0, CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj)); } - + /** * Called when the container is closed. */ @Override - public void onContainerClosed(EntityPlayer p_75134_1_){ + public void onContainerClosed(EntityPlayer p_75134_1_) { super.onContainerClosed(p_75134_1_); - if (!this.worldObj.isRemote){ - for (int i = 0; i < 9; ++i){ + if (!this.worldObj.isRemote) { + for (int i = 0; i < 9; ++i) { ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i); - if (itemstack != null){ + if (itemstack != null) { p_75134_1_.dropPlayerItemWithRandomChoice(itemstack, false); } } } } - @Override - public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold, final EntityPlayer aPlayer){ - - if (!aPlayer.worldObj.isRemote){ - if ((aSlotIndex == 999) || (aSlotIndex == -999)){ - //Utils.LOG_WARNING("??? - "+aSlotIndex); - } - - if (aSlotIndex == 0){ - Logger.INFO("Player Clicked on the Data Stick slot"); - //TODO - }if (aSlotIndex == 1){ - Logger.INFO("Player Clicked on the output slot"); - //TODO - } - - for (final int x : this.slotGrid){ - if (aSlotIndex == x){ - Logger.INFO("Player Clicked slot "+aSlotIndex+" in the crafting Grid"); - } - } - } - //Utils.LOG_WARNING("Player Clicked slot "+aSlotIndex+" in the Grid"); - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - @Override - public boolean canInteractWith(final EntityPlayer par1EntityPlayer){ - if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockProjectTable){ - return false; - } - - return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; - } - - - @Override - public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) - { - - return null; - - /*ItemStack var3 = null; - final Slot var4 = (Slot)this.inventorySlots.get(par2); - - if ((var4 != null) && var4.getHasStack()) - { - final ItemStack var5 = var4.getStack(); - var3 = var5.copy(); - - if (par2 == 0) - { - if (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, true)) - { - return null; - } - - var4.onSlotChange(var5, var3); - } - else if ((par2 >= InOutputSlotNumber) && (par2 < InventoryOutSlotNumber)) - { - if (!this.mergeItemStack(var5, InventoryOutSlotNumber, FullSlotNumber, false)) - { - return null; - } - } - else if ((par2 >= InventoryOutSlotNumber) && (par2 < FullSlotNumber)) - { - if (!this.mergeItemStack(var5, InOutputSlotNumber, InventoryOutSlotNumber, false)) - { - return null; - } - } - else if (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, false)) - { - return null; - } - - if (var5.stackSize == 0) - { - var4.putStack((ItemStack)null); - } - else - { - var4.onSlotChanged(); - } - - if (var5.stackSize == var3.stackSize) - { - return null; - } - - var4.onPickupFromSlot(par1EntityPlayer, var5); - } - - return var3;*/ - } - - //Can merge Slot - @Override - public boolean func_94530_a(ItemStack p_94530_1_, Slot p_94530_2_){ + @Override + public ItemStack slotClick( + final int aSlotIndex, final int aMouseclick, final int aShifthold, final EntityPlayer aPlayer) { + + if (!aPlayer.worldObj.isRemote) { + if ((aSlotIndex == 999) || (aSlotIndex == -999)) { + // Utils.LOG_WARNING("??? - "+aSlotIndex); + } + + if (aSlotIndex == 0) { + Logger.INFO("Player Clicked on the Data Stick slot"); + // TODO + } + if (aSlotIndex == 1) { + Logger.INFO("Player Clicked on the output slot"); + // TODO + } + + for (final int x : this.slotGrid) { + if (aSlotIndex == x) { + Logger.INFO("Player Clicked slot " + aSlotIndex + " in the crafting Grid"); + } + } + } + // Utils.LOG_WARNING("Player Clicked slot "+aSlotIndex+" in the Grid"); + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + @Override + public boolean canInteractWith(final EntityPlayer par1EntityPlayer) { + if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockProjectTable) { + return false; + } + + return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; + } + + @Override + public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) { + + return null; + + /*ItemStack var3 = null; + final Slot var4 = (Slot)this.inventorySlots.get(par2); + + if ((var4 != null) && var4.getHasStack()) + { + final ItemStack var5 = var4.getStack(); + var3 = var5.copy(); + + if (par2 == 0) + { + if (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, true)) + { + return null; + } + + var4.onSlotChange(var5, var3); + } + else if ((par2 >= InOutputSlotNumber) && (par2 < InventoryOutSlotNumber)) + { + if (!this.mergeItemStack(var5, InventoryOutSlotNumber, FullSlotNumber, false)) + { + return null; + } + } + else if ((par2 >= InventoryOutSlotNumber) && (par2 < FullSlotNumber)) + { + if (!this.mergeItemStack(var5, InOutputSlotNumber, InventoryOutSlotNumber, false)) + { + return null; + } + } + else if (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, false)) + { + return null; + } + + if (var5.stackSize == 0) + { + var4.putStack((ItemStack)null); + } + else + { + var4.onSlotChanged(); + } + + if (var5.stackSize == var3.stackSize) + { + return null; + } + + var4.onPickupFromSlot(par1EntityPlayer, var5); + } + + return var3;*/ + } + + // Can merge Slot + @Override + public boolean func_94530_a(ItemStack p_94530_1_, Slot p_94530_2_) { return p_94530_2_.inventory != this.craftResult && super.func_94530_a(p_94530_1_, p_94530_2_); } - - public ItemStack getOutputContent(){ - ItemStack output = this.craftResult.getStackInSlot(0); - if (output != null){ - return output; - } - return null; - } - - public ItemStack[] getInputComponents(){ - ItemStack inputs[] = new ItemStack[9]; - for (int r=0;r= 3 && c < 6) { - continue; - } - this.addSlotToContainer(new SlotJukebox(this.inventoryChest, o++, xStart+(18*c), yStart)); - } - - //Row Two - for (int c = 0; c < 9; c++) { - if (c >= 3 && c < 6) { - continue; - } - this.addSlotToContainer(new SlotJukebox(this.inventoryChest, o++, xStart+(18*c), yStart+18)); - } - - //Row Two - for (int c = 0; c < 9; c++) { - if (c >= 3 && c < 6) { - continue; - } - this.addSlotToContainer(new SlotJukebox(this.inventoryChest, o++, xStart+(18*c), yStart+36)); - } - - - //Controls - int c = 4; - - //Two Control Buttons - this.addSlotToContainer(new SlotNoInput(this.inventoryChest, SLOT_HOLO_PLAY, xStart+(18*c), 12)); - this.addSlotToContainer(new SlotNoInput(this.inventoryChest, SLOT_HOLO_LOOP, xStart+(18*c), 12+(1*18))); - - //Active playing slot for visual - this.addSlotToContainer(new SlotJukebox(this.inventoryChest, SLOT_OUTPUT, xStart+(18*c), 18+(2*18), true)); - - - - - // Player Inventory - for (var6 = 0; var6 < 3; ++var6) { - for (var7 = 0; var7 < 9; ++var7) { - this.addSlotToContainer(new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18))); - } - } - // Player Hotbar - for (var6 = 0; var6 < 9; ++var6) { - this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142)); - } - - - Logger.INFO("3"); - - } - catch (Throwable t) { - t.printStackTrace(); - } - - } - - @Override - public void onContainerClosed(final EntityPlayer par1EntityPlayer) { - super.onContainerClosed(par1EntityPlayer); - } - - @Override - public boolean canInteractWith(final EntityPlayer par1EntityPlayer) { - if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockCustomJukebox) { - return false; - } - - return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; - } - - @Override - public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) { - ItemStack var3 = null; - final Slot var4 = (Slot) this.inventorySlots.get(par2); - - if ((var4 != null) && var4.getHasStack()) { - final ItemStack var5 = var4.getStack(); - var3 = var5.copy(); - - /* - * if (par2 == 0) { if (!this.mergeItemStack(var5, - * InOutputSlotNumber, FullSlotNumber, true)) { return null; } - * - * var4.onSlotChange(var5, var3); } else if (par2 >= - * InOutputSlotNumber && par2 < InventoryOutSlotNumber) { if - * (!this.mergeItemStack(var5, InventoryOutSlotNumber, - * FullSlotNumber, false)) { return null; } } else if (par2 >= - * InventoryOutSlotNumber && par2 < FullSlotNumber) { if - * (!this.mergeItemStack(var5, InOutputSlotNumber, - * InventoryOutSlotNumber, false)) { return null; } } else if - * (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, - * false)) { return null; } - */ - - if (var5.stackSize == 0) { - var4.putStack((ItemStack) null); - } else { - var4.onSlotChanged(); - } - - if (var5.stackSize == var3.stackSize) { - return null; - } - - var4.onPickupFromSlot(par1EntityPlayer, var5); - } - - return var3; - } - - // Can merge Slot - @Override - public boolean func_94530_a(final ItemStack p_94530_1_, final Slot p_94530_2_) { - return super.func_94530_a(p_94530_1_, p_94530_2_); - } - - - - @Override - public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (tile_entity == null || tile_entity.getWorldObj().isRemote) return null; - switch (aSlotIndex) { - case SLOT_HOLO_PLAY: - if (tile_entity == null) return null; - tile_entity.mIsPlaying = !tile_entity.mIsPlaying; - Logger.INFO("Jukebox | Playing: "+tile_entity.mIsPlaying); - tile_entity.jukeboxLogicUpdate(); - return null; - case SLOT_HOLO_LOOP: - if (tile_entity == null) return null; - tile_entity.mIsLooping = !tile_entity.mIsLooping; - Logger.INFO("Jukebox | Looping: "+tile_entity.mIsLooping); - return null; - case 20: - return null; - default: - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - } - - public boolean isPlaying; - public boolean isLooping; - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if (tile_entity == null || tile_entity.getWorldObj().isRemote) return; - - isPlaying = tile_entity.mIsPlaying; - isLooping = tile_entity.mIsLooping; - - Iterator var2 = this.crafters.iterator(); - while (var2.hasNext()) { - ICrafting var1 = (ICrafting) var2.next(); - var1.sendProgressBarUpdate(this, 102, isPlaying ? 1 : 0); - var1.sendProgressBarUpdate(this, 103, isLooping ? 1 : 0); - } - } - - @Override - public void addCraftingToCrafters(ICrafting par1ICrafting) { - super.addCraftingToCrafters(par1ICrafting); - } - - @Override - @SideOnly(Side.CLIENT) - public void updateProgressBar(int par1, int par2) { - super.updateProgressBar(par1, par2); - switch (par1) { - case 102: - isPlaying = (par2 != 0); - break; - case 103: - isLooping = (par2 != 0); - break; - } - } -} \ No newline at end of file + protected TileEntitySuperJukebox tile_entity; + public final Inventory_SuperJukebox inventoryChest; + + private final World worldObj; + private final int posX; + private final int posY; + private final int posZ; + + public static final int SLOT_HOLO_PLAY = 18; + public static final int SLOT_HOLO_LOOP = 19; + public static final int SLOT_OUTPUT = 20; + + public static int StorageSlotNumber = 26; // Number of slots in storage area + public static int InventorySlotNumber = 36; // Inventory Slots (Inventory + // and Hotbar) + public static int FullSlotNumber = InventorySlotNumber + StorageSlotNumber; // All + // slots + + public Container_SuperJukebox(final InventoryPlayer inventory, final TileEntitySuperJukebox te) { + this.tile_entity = te; + this.inventoryChest = te.getInventory(); + + int var6; + int var7; + this.worldObj = te.getWorldObj(); + this.posX = te.xCoord; + this.posY = te.yCoord; + this.posZ = te.zCoord; + Logger.INFO("1"); + + int o = 0; + + // Storage Side + /*for (var6 = 0; var6 < 3; var6++) { + for (var7 = 0; var7 < 5; var7++) { + this.addSlotToContainer(new SlotIntegratedCircuit(o, this.inventoryChest, o, 44 + (var7 * 18), 15 + (var6 * 18))); + o++; + } + }*/ + + int xStart = 9; + int yStart = 20; + + try { + + // Row One + for (int c = 0; c < 9; c++) { + if (c >= 3 && c < 6) { + continue; + } + this.addSlotToContainer(new SlotJukebox(this.inventoryChest, o++, xStart + (18 * c), yStart)); + } + + // Row Two + for (int c = 0; c < 9; c++) { + if (c >= 3 && c < 6) { + continue; + } + this.addSlotToContainer(new SlotJukebox(this.inventoryChest, o++, xStart + (18 * c), yStart + 18)); + } + + // Row Two + for (int c = 0; c < 9; c++) { + if (c >= 3 && c < 6) { + continue; + } + this.addSlotToContainer(new SlotJukebox(this.inventoryChest, o++, xStart + (18 * c), yStart + 36)); + } + + // Controls + int c = 4; + + // Two Control Buttons + this.addSlotToContainer(new SlotNoInput(this.inventoryChest, SLOT_HOLO_PLAY, xStart + (18 * c), 12)); + this.addSlotToContainer( + new SlotNoInput(this.inventoryChest, SLOT_HOLO_LOOP, xStart + (18 * c), 12 + (1 * 18))); + + // Active playing slot for visual + this.addSlotToContainer( + new SlotJukebox(this.inventoryChest, SLOT_OUTPUT, xStart + (18 * c), 18 + (2 * 18), true)); + + // Player Inventory + for (var6 = 0; var6 < 3; ++var6) { + for (var7 = 0; var7 < 9; ++var7) { + this.addSlotToContainer( + new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18))); + } + } + // Player Hotbar + for (var6 = 0; var6 < 9; ++var6) { + this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142)); + } + + Logger.INFO("3"); + + } catch (Throwable t) { + t.printStackTrace(); + } + } + + @Override + public void onContainerClosed(final EntityPlayer par1EntityPlayer) { + super.onContainerClosed(par1EntityPlayer); + } + + @Override + public boolean canInteractWith(final EntityPlayer par1EntityPlayer) { + if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockCustomJukebox) { + return false; + } + + return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; + } + + @Override + public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) { + ItemStack var3 = null; + final Slot var4 = (Slot) this.inventorySlots.get(par2); + + if ((var4 != null) && var4.getHasStack()) { + final ItemStack var5 = var4.getStack(); + var3 = var5.copy(); + + /* + * if (par2 == 0) { if (!this.mergeItemStack(var5, + * InOutputSlotNumber, FullSlotNumber, true)) { return null; } + * + * var4.onSlotChange(var5, var3); } else if (par2 >= + * InOutputSlotNumber && par2 < InventoryOutSlotNumber) { if + * (!this.mergeItemStack(var5, InventoryOutSlotNumber, + * FullSlotNumber, false)) { return null; } } else if (par2 >= + * InventoryOutSlotNumber && par2 < FullSlotNumber) { if + * (!this.mergeItemStack(var5, InOutputSlotNumber, + * InventoryOutSlotNumber, false)) { return null; } } else if + * (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, + * false)) { return null; } + */ + + if (var5.stackSize == 0) { + var4.putStack((ItemStack) null); + } else { + var4.onSlotChanged(); + } + + if (var5.stackSize == var3.stackSize) { + return null; + } + + var4.onPickupFromSlot(par1EntityPlayer, var5); + } + + return var3; + } + + // Can merge Slot + @Override + public boolean func_94530_a(final ItemStack p_94530_1_, final Slot p_94530_2_) { + return super.func_94530_a(p_94530_1_, p_94530_2_); + } + + @Override + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { + if (tile_entity == null || tile_entity.getWorldObj().isRemote) return null; + switch (aSlotIndex) { + case SLOT_HOLO_PLAY: + if (tile_entity == null) return null; + tile_entity.mIsPlaying = !tile_entity.mIsPlaying; + Logger.INFO("Jukebox | Playing: " + tile_entity.mIsPlaying); + tile_entity.jukeboxLogicUpdate(); + return null; + case SLOT_HOLO_LOOP: + if (tile_entity == null) return null; + tile_entity.mIsLooping = !tile_entity.mIsLooping; + Logger.INFO("Jukebox | Looping: " + tile_entity.mIsLooping); + return null; + case 20: + return null; + default: + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + } + + public boolean isPlaying; + public boolean isLooping; + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (tile_entity == null || tile_entity.getWorldObj().isRemote) return; + + isPlaying = tile_entity.mIsPlaying; + isLooping = tile_entity.mIsLooping; + + Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) { + ICrafting var1 = (ICrafting) var2.next(); + var1.sendProgressBarUpdate(this, 102, isPlaying ? 1 : 0); + var1.sendProgressBarUpdate(this, 103, isLooping ? 1 : 0); + } + } + + @Override + public void addCraftingToCrafters(ICrafting par1ICrafting) { + super.addCraftingToCrafters(par1ICrafting); + } + + @Override + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 102: + isPlaying = (par2 != 0); + break; + case 103: + isLooping = (par2 != 0); + break; + } + } +} diff --git a/src/main/java/gtPlusPlus/core/container/Container_TradeTable.java b/src/main/java/gtPlusPlus/core/container/Container_TradeTable.java index f812e384a7..14515c25f3 100644 --- a/src/main/java/gtPlusPlus/core/container/Container_TradeTable.java +++ b/src/main/java/gtPlusPlus/core/container/Container_TradeTable.java @@ -1,12 +1,5 @@ package gtPlusPlus.core.container; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.inventories.tradetable.InventoryTradeMain; @@ -14,210 +7,209 @@ import gtPlusPlus.core.inventories.tradetable.InventoryTradeOutput; import gtPlusPlus.core.slots.SlotGeneric; import gtPlusPlus.core.slots.SlotNoInput; import gtPlusPlus.core.tileentities.machines.TileEntityTradeTable; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; public class Container_TradeTable extends Container { - protected TileEntityTradeTable tile_entity; - public final InventoryTradeMain inventoryChest; - public final InventoryTradeOutput inventoryOutputs; - - private final World worldObj; - private final int posX; - private final int posY; - private final int posZ; - - private final int[] slotOutputs = new int[2]; - private final int[] slotGrid = new int[9]; - - - public Container_TradeTable(final InventoryPlayer inventory, final TileEntityTradeTable te){ - - this.tile_entity = te; - this.inventoryChest = te.inventoryGrid; - this.inventoryOutputs = te.inventoryOutputs; - this.tile_entity.setContainer(this); - - if (te.isServerSide()) - Logger.INFO("Container - "+te.mOwnerName); - - int var6; - int var7; - this.worldObj = te.getWorldObj(); - this.posX = te.xCoord; - this.posY = te.yCoord; - this.posZ = te.zCoord; - - int nextFreeSlot = 0; - - - //Output slots - this.addSlotToContainer(new SlotGeneric(this.inventoryOutputs, 0, 26+(18*6), 8)); - this.addSlotToContainer(new SlotNoInput(this.inventoryOutputs, 1, 26+(18*6), 44)); - - //this.addSlotToContainer(new SlotCraftingNoCollect(inventory.player, this.craftMatrix, this.craftResult, 0, 26+(18*4), 25)); - - int o = 0; - //Storage Side - for (var6 = 0; var6 < 3; ++var6) - { - for (var7 = 0; var7 < 3; ++var7) - { - //Utils.LOG_WARNING("Adding slots at var:"+(var7 + var6 * 4)+" x:"+(8 + var7 * 18)+" y:"+(7 + var6 * 18)); - this.addSlotToContainer(new Slot(this.inventoryChest, nextFreeSlot, 8+18 + (var7 * 18), 8 + (var6 * 18))); - this.slotGrid[o] = nextFreeSlot; - nextFreeSlot++; - o++; - } - } - - //Player Inventory - for (var6 = 0; var6 < 3; ++var6) - { - for (var7 = 0; var7 < 9; ++var7) - { - this.addSlotToContainer(new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18))); - } - } - - //Player Hotbar - for (var6 = 0; var6 < 9; ++var6) - { - this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142)); - } - - //this.onCraftMatrixChanged(this.craftMatrix); - } - - /** - * Called when the container is closed. - */ - @Override - public void onContainerClosed(EntityPlayer p_75134_1_){ - super.onContainerClosed(p_75134_1_); - if (!this.worldObj.isRemote){ - for (int i = 0; i < 9; ++i){ - ItemStack itemstack = this.inventoryChest.getStackInSlotOnClosing(i); - if (itemstack != null){ - p_75134_1_.dropPlayerItemWithRandomChoice(itemstack, false); - } - } - } - } - - @Override - public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold, final EntityPlayer aPlayer){ - - if (!aPlayer.worldObj.isRemote){ - if ((aSlotIndex == 999) || (aSlotIndex == -999)){ - //Utils.LOG_WARNING("??? - "+aSlotIndex); - } - - if (aSlotIndex == 0){ - Logger.INFO("Player Clicked on the Data Stick slot"); - //TODO - }if (aSlotIndex == 1){ - Logger.INFO("Player Clicked on the output slot"); - //TODO - } - - for (final int x : this.slotGrid){ - if (aSlotIndex == x){ - Logger.INFO("Player Clicked slot "+aSlotIndex+" in the crafting Grid"); - } - } - } - //Utils.LOG_WARNING("Player Clicked slot "+aSlotIndex+" in the Grid"); - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - @Override - public boolean canInteractWith(final EntityPlayer par1EntityPlayer){ - if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockTradeTable){ - return false; - } - - return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; - } - - - @Override - public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) - { - - return null; - - /*ItemStack var3 = null; - final Slot var4 = (Slot)this.inventorySlots.get(par2); - - if ((var4 != null) && var4.getHasStack()) - { - final ItemStack var5 = var4.getStack(); - var3 = var5.copy(); - - if (par2 == 0) - { - if (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, true)) - { - return null; - } - - var4.onSlotChange(var5, var3); - } - else if ((par2 >= InOutputSlotNumber) && (par2 < InventoryOutSlotNumber)) - { - if (!this.mergeItemStack(var5, InventoryOutSlotNumber, FullSlotNumber, false)) - { - return null; - } - } - else if ((par2 >= InventoryOutSlotNumber) && (par2 < FullSlotNumber)) - { - if (!this.mergeItemStack(var5, InOutputSlotNumber, InventoryOutSlotNumber, false)) - { - return null; - } - } - else if (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, false)) - { - return null; - } - - if (var5.stackSize == 0) - { - var4.putStack((ItemStack)null); - } - else - { - var4.onSlotChanged(); - } - - if (var5.stackSize == var3.stackSize) - { - return null; - } - - var4.onPickupFromSlot(par1EntityPlayer, var5); - } - - return var3;*/ - } - - public ItemStack getOutputContent(){ - ItemStack output = this.inventoryOutputs.getStackInSlot(0); - if (output != null){ - return output; - } - return null; - } - - public ItemStack[] getInputComponents(){ - ItemStack inputs[] = new ItemStack[9]; - for (int r=0;r= InOutputSlotNumber) && (par2 < InventoryOutSlotNumber)) + { + if (!this.mergeItemStack(var5, InventoryOutSlotNumber, FullSlotNumber, false)) + { + return null; + } + } + else if ((par2 >= InventoryOutSlotNumber) && (par2 < FullSlotNumber)) + { + if (!this.mergeItemStack(var5, InOutputSlotNumber, InventoryOutSlotNumber, false)) + { + return null; + } + } + else if (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, false)) + { + return null; + } + + if (var5.stackSize == 0) + { + var4.putStack((ItemStack)null); + } + else + { + var4.onSlotChanged(); + } + + if (var5.stackSize == var3.stackSize) + { + return null; + } + + var4.onPickupFromSlot(par1EntityPlayer, var5); + } + + return var3;*/ + } + + public ItemStack getOutputContent() { + ItemStack output = this.inventoryOutputs.getStackInSlot(0); + if (output != null) { + return output; + } + return null; + } + + public ItemStack[] getInputComponents() { + ItemStack inputs[] = new ItemStack[9]; + for (int r = 0; r < this.inventoryChest.getSizeInventory(); r++) { + ItemStack temp = this.inventoryChest.getStackInSlot(r); + inputs[r] = temp; + } + return inputs; + } +} diff --git a/src/main/java/gtPlusPlus/core/container/Container_VolumetricFlaskSetter.java b/src/main/java/gtPlusPlus/core/container/Container_VolumetricFlaskSetter.java index 65e84d7272..740048f88d 100644 --- a/src/main/java/gtPlusPlus/core/container/Container_VolumetricFlaskSetter.java +++ b/src/main/java/gtPlusPlus/core/container/Container_VolumetricFlaskSetter.java @@ -1,7 +1,5 @@ package gtPlusPlus.core.container; -import java.util.Iterator; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.api.objects.Logger; @@ -11,6 +9,7 @@ import gtPlusPlus.core.slots.SlotNoInput; import gtPlusPlus.core.slots.SlotVolumetricFlask; import gtPlusPlus.core.tileentities.general.TileEntityVolumetricFlaskSetter; import gtPlusPlus.core.util.Utils; +import java.util.Iterator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; @@ -21,170 +20,163 @@ import net.minecraft.world.World; public class Container_VolumetricFlaskSetter extends Container { - public TileEntityVolumetricFlaskSetter mTileEntity; - public final Inventory_VolumetricFlaskSetter inventoryChest; - - - public int mCustomValue; - private int oCustomValue; - private int mTimer; - - - private final World worldObj; - private final int posX; - private final int posY; - private final int posZ; - - public static final int SLOT_OUTPUT = 8; - - public static int StorageSlotNumber = 8; // Number of slots in storage area - public static int InventorySlotNumber = 36; // Inventory Slots (Inventory - // and Hotbar) - public static int FullSlotNumber = InventorySlotNumber + StorageSlotNumber; // All - // slots - - public Container_VolumetricFlaskSetter(final InventoryPlayer inventory, final TileEntityVolumetricFlaskSetter te) { - this.mTileEntity = te; - this.inventoryChest = te.getInventory(); - - int var6; - int var7; - this.worldObj = te.getWorldObj(); - this.posX = te.xCoord; - this.posY = te.yCoord; - this.posZ = te.zCoord; - //mCustomValue = te.getCustomValue(); - - int o = 0; - - // Storage Side - /*for (var6 = 0; var6 < 3; var6++) { - for (var7 = 0; var7 < 5; var7++) { - this.addSlotToContainer(new SlotIntegratedCircuit(o, this.inventoryChest, o, 44 + (var7 * 18), 15 + (var6 * 18))); - o++; - } - }*/ - - - int xStart = 26; - int yStart = 12; - - try { - //0 - this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart, yStart)); - this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart+=18, yStart)); - this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart+=18, yStart)); - this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart+=18, yStart)); - this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart+=18, yStart)); - this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart+=18, yStart)); - this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart+=18, yStart)); - this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart, yStart+18)); - - //Add Output - this.addSlotToContainer(new SlotNoInput(this.inventoryChest, o++, 8+(8*18), 59)); - o++; - - - - // Player Inventory - for (var6 = 0; var6 < 3; ++var6) { - for (var7 = 0; var7 < 9; ++var7) { - this.addSlotToContainer(new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18))); - } - } - // Player Hotbar - for (var6 = 0; var6 < 9; ++var6) { - this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142)); - } - detectAndSendChanges(); - } - catch (Throwable t) {} - - } - - - @Override - public boolean canInteractWith(final EntityPlayer par1EntityPlayer) { - if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockVolumetricFlaskSetter) { - return false; - } - return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; - } - - @Override - public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) { - ItemStack var3 = null; - final Slot var4 = (Slot) this.inventorySlots.get(par2); - - if ((var4 != null) && var4.getHasStack()) { - final ItemStack var5 = var4.getStack(); - var3 = var5.copy(); - - /* - * if (par2 == 0) { if (!this.mergeItemStack(var5, - * InOutputSlotNumber, FullSlotNumber, true)) { return null; } - * - * var4.onSlotChange(var5, var3); } else if (par2 >= - * InOutputSlotNumber && par2 < InventoryOutSlotNumber) { if - * (!this.mergeItemStack(var5, InventoryOutSlotNumber, - * FullSlotNumber, false)) { return null; } } else if (par2 >= - * InventoryOutSlotNumber && par2 < FullSlotNumber) { if - * (!this.mergeItemStack(var5, InOutputSlotNumber, - * InventoryOutSlotNumber, false)) { return null; } } else if - * (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, - * false)) { return null; } - */ - - if (var5.stackSize == 0) { - var4.putStack((ItemStack) null); - } else { - var4.onSlotChanged(); - } - - if (var5.stackSize == var3.stackSize) { - return null; - } - - var4.onPickupFromSlot(par1EntityPlayer, var5); - } - - return var3; - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if ((Utils.isClient()) || (this.mTileEntity == null)) { - return; - } - - mCustomValue = mTileEntity.getCustomValue(); + public TileEntityVolumetricFlaskSetter mTileEntity; + public final Inventory_VolumetricFlaskSetter inventoryChest; + + public int mCustomValue; + private int oCustomValue; + private int mTimer; + + private final World worldObj; + private final int posX; + private final int posY; + private final int posZ; + + public static final int SLOT_OUTPUT = 8; + + public static int StorageSlotNumber = 8; // Number of slots in storage area + public static int InventorySlotNumber = 36; // Inventory Slots (Inventory + // and Hotbar) + public static int FullSlotNumber = InventorySlotNumber + StorageSlotNumber; // All + // slots + + public Container_VolumetricFlaskSetter(final InventoryPlayer inventory, final TileEntityVolumetricFlaskSetter te) { + this.mTileEntity = te; + this.inventoryChest = te.getInventory(); + + int var6; + int var7; + this.worldObj = te.getWorldObj(); + this.posX = te.xCoord; + this.posY = te.yCoord; + this.posZ = te.zCoord; + // mCustomValue = te.getCustomValue(); + + int o = 0; + + // Storage Side + /*for (var6 = 0; var6 < 3; var6++) { + for (var7 = 0; var7 < 5; var7++) { + this.addSlotToContainer(new SlotIntegratedCircuit(o, this.inventoryChest, o, 44 + (var7 * 18), 15 + (var6 * 18))); + o++; + } + }*/ + + int xStart = 26; + int yStart = 12; + + try { + // 0 + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart, yStart)); + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart += 18, yStart)); + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart += 18, yStart)); + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart += 18, yStart)); + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart += 18, yStart)); + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart += 18, yStart)); + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart += 18, yStart)); + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart, yStart + 18)); + + // Add Output + this.addSlotToContainer(new SlotNoInput(this.inventoryChest, o++, 8 + (8 * 18), 59)); + o++; + + // Player Inventory + for (var6 = 0; var6 < 3; ++var6) { + for (var7 = 0; var7 < 9; ++var7) { + this.addSlotToContainer( + new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18))); + } + } + // Player Hotbar + for (var6 = 0; var6 < 9; ++var6) { + this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142)); + } + detectAndSendChanges(); + } catch (Throwable t) { + } + } + + @Override + public boolean canInteractWith(final EntityPlayer par1EntityPlayer) { + if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockVolumetricFlaskSetter) { + return false; + } + return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; + } + + @Override + public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) { + ItemStack var3 = null; + final Slot var4 = (Slot) this.inventorySlots.get(par2); + + if ((var4 != null) && var4.getHasStack()) { + final ItemStack var5 = var4.getStack(); + var3 = var5.copy(); + + /* + * if (par2 == 0) { if (!this.mergeItemStack(var5, + * InOutputSlotNumber, FullSlotNumber, true)) { return null; } + * + * var4.onSlotChange(var5, var3); } else if (par2 >= + * InOutputSlotNumber && par2 < InventoryOutSlotNumber) { if + * (!this.mergeItemStack(var5, InventoryOutSlotNumber, + * FullSlotNumber, false)) { return null; } } else if (par2 >= + * InventoryOutSlotNumber && par2 < FullSlotNumber) { if + * (!this.mergeItemStack(var5, InOutputSlotNumber, + * InventoryOutSlotNumber, false)) { return null; } } else if + * (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, + * false)) { return null; } + */ + + if (var5.stackSize == 0) { + var4.putStack((ItemStack) null); + } else { + var4.onSlotChanged(); + } + + if (var5.stackSize == var3.stackSize) { + return null; + } + + var4.onPickupFromSlot(par1EntityPlayer, var5); + } + + return var3; + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if ((Utils.isClient()) || (this.mTileEntity == null)) { + return; + } + + mCustomValue = mTileEntity.getCustomValue(); mTimer++; - Iterator var2 = this.crafters.iterator(); - while (var2.hasNext()) { - ICrafting var1 = (ICrafting) var2.next(); - if (mTimer % 20 == 10 || oCustomValue != mCustomValue) { - var1.sendProgressBarUpdate(this, 0, mCustomValue); - } - } - - oCustomValue = mCustomValue; - } - - @SideOnly(Side.CLIENT) - @Override - public void updateProgressBar(int par1, int par2) { - super.updateProgressBar(par1, par2); - switch (par1) { - case 0: - mCustomValue = (short) par2; - break; - } - } - - public void log(String aString) { - Logger.INFO("[Flask-Container] "+aString); - } - -} \ No newline at end of file + Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) { + ICrafting var1 = (ICrafting) var2.next(); + if (mTimer % 20 == 10 || oCustomValue != mCustomValue) { + var1.sendProgressBarUpdate(this, 0, mCustomValue); + } + } + + oCustomValue = mCustomValue; + } + + @SideOnly(Side.CLIENT) + @Override + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 0: + mCustomValue = (short) par2; + break; + } + } + + public void log(String aString) { + Logger.INFO("[Flask-Container] " + aString); + } +} diff --git a/src/main/java/gtPlusPlus/core/container/box/LunchBoxContainer.java b/src/main/java/gtPlusPlus/core/container/box/LunchBoxContainer.java index 8e56c661f2..51bc85a6ae 100644 --- a/src/main/java/gtPlusPlus/core/container/box/LunchBoxContainer.java +++ b/src/main/java/gtPlusPlus/core/container/box/LunchBoxContainer.java @@ -7,7 +7,13 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; public class LunchBoxContainer extends ContainerBoxBase { - public LunchBoxContainer(EntityPlayer par1Player, InventoryPlayer inventoryPlayer, CustomBoxInventory CustomBoxInventory) { - super(par1Player, inventoryPlayer, CustomBoxInventory, SlotLunchBox.class, gtPlusPlus.core.item.tool.misc.box.AutoLunchBox.SLOTS); - } + public LunchBoxContainer( + EntityPlayer par1Player, InventoryPlayer inventoryPlayer, CustomBoxInventory CustomBoxInventory) { + super( + par1Player, + inventoryPlayer, + CustomBoxInventory, + SlotLunchBox.class, + gtPlusPlus.core.item.tool.misc.box.AutoLunchBox.SLOTS); + } } diff --git a/src/main/java/gtPlusPlus/core/container/box/MagicBagContainer.java b/src/main/java/gtPlusPlus/core/container/box/MagicBagContainer.java index 7820d56814..294836ded4 100644 --- a/src/main/java/gtPlusPlus/core/container/box/MagicBagContainer.java +++ b/src/main/java/gtPlusPlus/core/container/box/MagicBagContainer.java @@ -7,7 +7,13 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; public class MagicBagContainer extends ContainerBoxBase { - public MagicBagContainer(EntityPlayer par1Player, InventoryPlayer inventoryPlayer, CustomBoxInventory CustomBoxInventory) { - super(par1Player, inventoryPlayer, CustomBoxInventory, SlotMagicToolBag.class, gtPlusPlus.core.item.tool.misc.box.MagicToolBag.SLOTS); - } + public MagicBagContainer( + EntityPlayer par1Player, InventoryPlayer inventoryPlayer, CustomBoxInventory CustomBoxInventory) { + super( + par1Player, + inventoryPlayer, + CustomBoxInventory, + SlotMagicToolBag.class, + gtPlusPlus.core.item.tool.misc.box.MagicToolBag.SLOTS); + } } diff --git a/src/main/java/gtPlusPlus/core/container/box/ToolBoxContainer.java b/src/main/java/gtPlusPlus/core/container/box/ToolBoxContainer.java index 49719aa9ba..e2c8841266 100644 --- a/src/main/java/gtPlusPlus/core/container/box/ToolBoxContainer.java +++ b/src/main/java/gtPlusPlus/core/container/box/ToolBoxContainer.java @@ -8,8 +8,8 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; public class ToolBoxContainer extends ContainerBoxBase { - public ToolBoxContainer(EntityPlayer par1Player, InventoryPlayer inventoryPlayer, - CustomBoxInventory CustomBoxInventory) { - super(par1Player, inventoryPlayer, CustomBoxInventory, SlotToolBox.class, UniversalToolBox.SLOTS); - } + public ToolBoxContainer( + EntityPlayer par1Player, InventoryPlayer inventoryPlayer, CustomBoxInventory CustomBoxInventory) { + super(par1Player, inventoryPlayer, CustomBoxInventory, SlotToolBox.class, UniversalToolBox.SLOTS); + } } diff --git a/src/main/java/gtPlusPlus/core/creative/AddToCreativeTab.java b/src/main/java/gtPlusPlus/core/creative/AddToCreativeTab.java index 218bef46bd..f0fb71112b 100644 --- a/src/main/java/gtPlusPlus/core/creative/AddToCreativeTab.java +++ b/src/main/java/gtPlusPlus/core/creative/AddToCreativeTab.java @@ -1,35 +1,33 @@ package gtPlusPlus.core.creative; -import net.minecraft.creativetab.CreativeTabs; import gregtech.api.util.GT_CreativeTab; import gtPlusPlus.core.creative.tabs.*; -import gtPlusPlus.xmod.bop.creative.MiscUtilsBOPTab; +import net.minecraft.creativetab.CreativeTabs; public class AddToCreativeTab { - public static CreativeTabs tabBlock; - public static CreativeTabs tabMisc; - public static CreativeTabs tabCombat; - public static CreativeTabs tabTools; - public static CreativeTabs tabMachines; - public static CreativeTabs tabOther; - public static CreativeTabs tabBOP; + public static CreativeTabs tabBlock; + public static CreativeTabs tabMisc; + public static CreativeTabs tabCombat; + public static CreativeTabs tabTools; + public static CreativeTabs tabMachines; + public static CreativeTabs tabOther; + public static CreativeTabs tabBOP; + + public static void initialiseTabs() { + // GT_CreativeTab + /*tabBlock = new MiscUtilCreativeTabBlock("MiscUtilBlockTab"); + tabMisc = new MiscUtilCreativeTabMisc("MiscUtilMiscTab"); + tabTools = new MiscUtilCreativeTabTools("MiscUtilToolsTab"); + tabMachines = new MiscUtilCreativeTabMachines("MiscUtilMachineTab"); + tabOther = new MiscUtilCreativeTabOther("MiscUtilOtherTab"); + tabBOP = new MiscUtilsBOPTab("MiscUtilBOP");*/ - public static void initialiseTabs() { - //GT_CreativeTab - /*tabBlock = new MiscUtilCreativeTabBlock("MiscUtilBlockTab"); - tabMisc = new MiscUtilCreativeTabMisc("MiscUtilMiscTab"); - tabTools = new MiscUtilCreativeTabTools("MiscUtilToolsTab"); - tabMachines = new MiscUtilCreativeTabMachines("MiscUtilMachineTab"); - tabOther = new MiscUtilCreativeTabOther("MiscUtilOtherTab"); - tabBOP = new MiscUtilsBOPTab("MiscUtilBOP");*/ - - tabBlock = new GT_CreativeTab("GTPP_BLOCKS", "GT++ Blocks"); - tabMisc = new GT_CreativeTab("GTPP_MISC", "GT++ Misc"); - tabTools = new GT_CreativeTab("GTPP_TOOLS", "GT++ Tools"); - tabMachines = new GT_CreativeTab("GTPP_MACHINES", "GT++ Machines"); - tabOther = new GT_CreativeTab("GTPP_OTHER", "GT++ Other"); - tabBOP = new GT_CreativeTab("GTPP_OTHER_2", "GT++ Other II"); - - } + tabBlock = new GT_CreativeTab("GTPP_BLOCKS", "GT++ Blocks"); + tabMisc = new GT_CreativeTab("GTPP_MISC", "GT++ Misc"); + tabTools = new GT_CreativeTab("GTPP_TOOLS", "GT++ Tools"); + tabMachines = new GT_CreativeTab("GTPP_MACHINES", "GT++ Machines"); + tabOther = new GT_CreativeTab("GTPP_OTHER", "GT++ Other"); + tabBOP = new GT_CreativeTab("GTPP_OTHER_2", "GT++ Other II"); + } } diff --git a/src/main/java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabBlock.java b/src/main/java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabBlock.java index 2851a514d0..7cb10f1092 100644 --- a/src/main/java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabBlock.java +++ b/src/main/java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabBlock.java @@ -1,27 +1,25 @@ package gtPlusPlus.core.creative.tabs; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.item.Item; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gtPlusPlus.core.block.ModBlocks; public class MiscUtilCreativeTabBlock extends CreativeTabs { - public MiscUtilCreativeTabBlock(final String lable) { - super(lable); - } + public MiscUtilCreativeTabBlock(final String lable) { + super(lable); + } + + @Override + public Item getTabIconItem() { + return Item.getItemFromBlock(Blocks.bedrock); + } - @Override - public Item getTabIconItem() { - return Item.getItemFromBlock(Blocks.bedrock); - } - @SideOnly(Side.CLIENT) - @Override - public int func_151243_f(){ + @Override + public int func_151243_f() { return 0; } - } diff --git a/src/main/java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabMachines.java b/src/main/java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabMachines.java index 96c809c4da..57fb663d40 100644 --- a/src/main/java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabMachines.java +++ b/src/main/java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabMachines.java @@ -4,18 +4,14 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Items; import net.minecraft.item.Item; -import gtPlusPlus.core.item.ModItems; - public class MiscUtilCreativeTabMachines extends CreativeTabs { + public MiscUtilCreativeTabMachines(final String lable) { + super(lable); + } - public MiscUtilCreativeTabMachines(final String lable) { - super(lable); - } - - @Override - public Item getTabIconItem() { - return Items.netherbrick; - } - + @Override + public Item getTabIconItem() { + return Items.netherbrick; + } } diff --git a/src/main/java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabMisc.java b/src/main/java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabMisc.java index a67668bbf0..397474065f 100644 --- a/src/main/java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabMisc.java +++ b/src/main/java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabMisc.java @@ -4,17 +4,14 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Items; import net.minecraft.item.Item; -import gtPlusPlus.core.item.ModItems; - public class MiscUtilCreativeTabMisc extends CreativeTabs { - public MiscUtilCreativeTabMisc(final String lable) { - super(lable); - } - - @Override - public Item getTabIconItem() { - return Items.painting; - } + public MiscUtilCreativeTabMisc(final String lable) { + super(lable); + } + @Override + public Item getTabIconItem() { + return Items.painting; + } } diff --git a/src/main/java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabOther.java b/src/main/java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabOther.java index afd89346c0..7fb99db6f0 100644 --- a/src/main/java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabOther.java +++ b/src/main/java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabOther.java @@ -4,17 +4,14 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Items; import net.minecraft.item.Item; -import gtPlusPlus.core.item.ModItems; - public class MiscUtilCreativeTabOther extends CreativeTabs { - public MiscUtilCreativeTabOther(final String lable) { - super(lable); - } - - @Override - public Item getTabIconItem() { - return Items.repeater; - } + public MiscUtilCreativeTabOther(final String lable) { + super(lable); + } + @Override + public Item getTabIconItem() { + return Items.repeater; + } } diff --git a/src/main/java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabTools.java b/src/main/java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabTools.java index ab1ab069de..1c81c6b952 100644 --- a/src/main/java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabTools.java +++ b/src/main/java/gtPlusPlus/core/creative/tabs/MiscUtilCreativeTabTools.java @@ -4,17 +4,14 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Items; import net.minecraft.item.Item; -import gtPlusPlus.core.item.ModItems; - public class MiscUtilCreativeTabTools extends CreativeTabs { - public MiscUtilCreativeTabTools(final String lable) { - super(lable); - } - - @Override - public Item getTabIconItem() { - return Items.diamond_pickaxe; - } + public MiscUtilCreativeTabTools(final String lable) { + super(lable); + } + @Override + public Item getTabIconItem() { + return Items.diamond_pickaxe; + } } diff --git a/src/main/java/gtPlusPlus/core/entity/EntityPrimedMiningExplosive.java b/src/main/java/gtPlusPlus/core/entity/EntityPrimedMiningExplosive.java index 9abd07392d..63d94fafee 100644 --- a/src/main/java/gtPlusPlus/core/entity/EntityPrimedMiningExplosive.java +++ b/src/main/java/gtPlusPlus/core/entity/EntityPrimedMiningExplosive.java @@ -1,216 +1,397 @@ package gtPlusPlus.core.entity; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.world.explosions.ExplosionHandler; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityTNTPrimed; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.world.explosions.ExplosionHandler; +public class EntityPrimedMiningExplosive extends EntityTNTPrimed { + /** How long the fuse is */ + private EntityLivingBase tntPlacedBy; + + public EntityPrimedMiningExplosive(final World world) { + super(world); + this.fuse = 160; + this.preventEntitySpawning = true; + this.setSize(0.98F, 0.98F); + this.yOffset = this.height / 2.0F; + } + + public EntityPrimedMiningExplosive( + final World world, final double x, final double y, final double z, final EntityLivingBase placingEntity) { + this(world); + this.setPosition(x, y, z); + final float f = (float) (Math.random() * Math.PI * 2.0D); + this.motionX = -((float) Math.sin(f)) * 0.02F; + this.motionY = 0.20000000298023224D; + this.motionZ = -((float) Math.cos(f)) * 0.02F; + this.fuse = 160; + this.prevPosX = x; + this.prevPosY = y; + this.prevPosZ = z; + this.tntPlacedBy = placingEntity; + } + + @Override + protected void entityInit() {} + + /** + * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to + * prevent them from trampling crops + */ + @Override + protected boolean canTriggerWalking() { + return false; + } + + /** + * Returns true if other Entities should be prevented from moving through this Entity. + */ + @Override + public boolean canBeCollidedWith() { + return !this.isDead; + } + + /** + * Called to update the entity's position/logic. + */ + @Override + public void onUpdate() { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + this.motionY -= 0.03999999910593033D; + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.9800000190734863D; + this.motionY *= 0.9800000190734863D; + this.motionZ *= 0.9800000190734863D; + + if (this.onGround) { + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + this.motionY *= -0.5D; + } + + if (this.fuse-- <= 0) { + this.setDead(); + + if (!this.worldObj.isRemote) { + this.explode(); + } + } else { + + int t = MathUtils.randInt(0, 15); + + if (t <= 2) { + int e = MathUtils.randInt(0, 3); + if (e <= 1) { + this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D); + this.worldObj.spawnParticle( + "largesmoke", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "cloud", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "flame", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + } else if (e == 2) { + this.worldObj.spawnParticle( + "explode", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largeexplode", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "hugeexplosion", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + } + } else if (t <= 4) { + int e = MathUtils.randInt(0, 5); + if (e <= 1) { + this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D); + this.worldObj.spawnParticle( + "largesmoke", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "cloud", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "flame", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + } else if (e == 2) { + this.worldObj.spawnParticle( + "explode", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largeexplode", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "hugeexplosion", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + } + } else if (t <= 6) { + int e = MathUtils.randInt(0, 4); + if (e <= 1) { + this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D); + this.worldObj.spawnParticle( + "largesmoke", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "cloud", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "flame", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + } else if (e == 2) { + this.worldObj.spawnParticle( + "explode", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largeexplode", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "hugeexplosion", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + } + } else if (t <= 8) { + int e = MathUtils.randInt(0, 1); + if (e <= 1) { + this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D); + this.worldObj.spawnParticle( + "largesmoke", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "cloud", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "flame", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + } else if (e == 2) { + this.worldObj.spawnParticle( + "explode", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largeexplode", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "hugeexplosion", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + } + } else if (t <= 10) { + int e = MathUtils.randInt(0, 6); + if (e <= 1) { + this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D); + this.worldObj.spawnParticle( + "largesmoke", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "cloud", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "flame", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + } else if (e >= 2) { + this.worldObj.spawnParticle( + "explode", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largeexplode", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "hugeexplosion", + this.posX + MathUtils.randDouble(0, 1), + this.posY + MathUtils.randDouble(0, 1), + this.posZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + } + } + } + } + + private void explode() { + final float f = 100.0F; + + ExplosionHandler explode = new ExplosionHandler(); + explode.createExplosion(this.worldObj, this, this.posX, this.posY, this.posZ, f, false, true); + + /*this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, f, true); + this.worldObj.createExplosion(this, this.posX+MathUtils.randDouble(-10, 10), this.posY, this.posZ+MathUtils.randDouble(-10, 10), f+MathUtils.randFloat(-5F, 5F), true); + this.worldObj.createExplosion(this, this.posX+MathUtils.randDouble(-10, 10), this.posY, this.posZ+MathUtils.randDouble(-10, 10), f+MathUtils.randFloat(-5F, 5F), true); + this.worldObj.createExplosion(this, this.posX+MathUtils.randDouble(-10, 10), this.posY, this.posZ+MathUtils.randDouble(-10, 10), f+MathUtils.randFloat(-5F, 5F), true); + this.worldObj.createExplosion(this, this.posX+MathUtils.randDouble(-10, 10), this.posY, this.posZ+MathUtils.randDouble(-10, 10), f+MathUtils.randFloat(-5F, 5F), true);*/ + } + + /** + * (abstract) Protected helper method to write subclass entity data to NBT. + */ + @Override + protected void writeEntityToNBT(final NBTTagCompound tag) { + tag.setByte("Fuse", (byte) this.fuse); + } + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + @Override + protected void readEntityFromNBT(final NBTTagCompound tag) { + this.fuse = tag.getByte("Fuse"); + } -public class EntityPrimedMiningExplosive extends EntityTNTPrimed -{ - /** How long the fuse is */ - private EntityLivingBase tntPlacedBy; - - public EntityPrimedMiningExplosive(final World world){ - super(world); - this.fuse = 160; - this.preventEntitySpawning = true; - this.setSize(0.98F, 0.98F); - this.yOffset = this.height / 2.0F; - } - - public EntityPrimedMiningExplosive(final World world, final double x, final double y, final double z, final EntityLivingBase placingEntity) - { - this(world); - this.setPosition(x, y, z); - final float f = (float)(Math.random() * Math.PI * 2.0D); - this.motionX = -((float)Math.sin(f)) * 0.02F; - this.motionY = 0.20000000298023224D; - this.motionZ = -((float)Math.cos(f)) * 0.02F; - this.fuse = 160; - this.prevPosX = x; - this.prevPosY = y; - this.prevPosZ = z; - this.tntPlacedBy = placingEntity; - } - - @Override - protected void entityInit() {} - - /** - * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to - * prevent them from trampling crops - */ - @Override - protected boolean canTriggerWalking() - { - return false; - } - - /** - * Returns true if other Entities should be prevented from moving through this Entity. - */ - @Override - public boolean canBeCollidedWith() - { - return !this.isDead; - } - - /** - * Called to update the entity's position/logic. - */ - @Override - public void onUpdate() - { - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; - this.motionY -= 0.03999999910593033D; - this.moveEntity(this.motionX, this.motionY, this.motionZ); - this.motionX *= 0.9800000190734863D; - this.motionY *= 0.9800000190734863D; - this.motionZ *= 0.9800000190734863D; - - if (this.onGround) - { - this.motionX *= 0.699999988079071D; - this.motionZ *= 0.699999988079071D; - this.motionY *= -0.5D; - } - - if (this.fuse-- <= 0) - { - this.setDead(); - - if (!this.worldObj.isRemote) - { - this.explode(); - } - } - else - { - - int t = MathUtils.randInt(0, 15); - - if (t <= 2){ - int e = MathUtils.randInt(0, 3); - if (e <= 1){ - this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("largesmoke", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("cloud", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("flame", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - } - else if (e == 2){ - this.worldObj.spawnParticle("explode", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("largeexplode", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("hugeexplosion", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - - } - } - else if (t <= 4){ - int e = MathUtils.randInt(0, 5); - if (e <= 1){ - this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("largesmoke", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("cloud", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("flame", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - } - else if (e == 2){ - this.worldObj.spawnParticle("explode", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("largeexplode", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("hugeexplosion", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - - } - } - else if (t <= 6){ - int e = MathUtils.randInt(0, 4); - if (e <= 1){ - this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("largesmoke", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("cloud", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("flame", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - } - else if (e == 2){ - this.worldObj.spawnParticle("explode", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("largeexplode", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("hugeexplosion", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - - } - } - else if (t <= 8){ - int e = MathUtils.randInt(0, 1); - if (e <= 1){ - this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("largesmoke", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("cloud", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("flame", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - } - else if (e == 2){ - this.worldObj.spawnParticle("explode", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("largeexplode", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("hugeexplosion", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - - } - } - else if (t <= 10){ - int e = MathUtils.randInt(0, 6); - if (e <= 1){ - this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("largesmoke", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("cloud", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("flame", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - } - else if (e >= 2){ - this.worldObj.spawnParticle("explode", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("largeexplode", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("hugeexplosion", this.posX+MathUtils.randDouble(0, 1), this.posY+MathUtils.randDouble(0, 1), this.posZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - - } - } - - } - } - - private void explode() - { - final float f = 100.0F; - - ExplosionHandler explode = new ExplosionHandler(); - explode.createExplosion(this.worldObj, this, this.posX, this.posY, this.posZ, f, false, true); - - /*this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, f, true); - this.worldObj.createExplosion(this, this.posX+MathUtils.randDouble(-10, 10), this.posY, this.posZ+MathUtils.randDouble(-10, 10), f+MathUtils.randFloat(-5F, 5F), true); - this.worldObj.createExplosion(this, this.posX+MathUtils.randDouble(-10, 10), this.posY, this.posZ+MathUtils.randDouble(-10, 10), f+MathUtils.randFloat(-5F, 5F), true); - this.worldObj.createExplosion(this, this.posX+MathUtils.randDouble(-10, 10), this.posY, this.posZ+MathUtils.randDouble(-10, 10), f+MathUtils.randFloat(-5F, 5F), true); - this.worldObj.createExplosion(this, this.posX+MathUtils.randDouble(-10, 10), this.posY, this.posZ+MathUtils.randDouble(-10, 10), f+MathUtils.randFloat(-5F, 5F), true);*/ - } - - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ - @Override - protected void writeEntityToNBT(final NBTTagCompound tag) - { - tag.setByte("Fuse", (byte)this.fuse); - } - - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - @Override - protected void readEntityFromNBT(final NBTTagCompound tag) - { - this.fuse = tag.getByte("Fuse"); - } - - /** - * returns null or the entityliving it was placed or ignited by - */ - @Override - public EntityLivingBase getTntPlacedBy() - { - return this.tntPlacedBy; - } -} \ No newline at end of file + /** + * returns null or the entityliving it was placed or ignited by + */ + @Override + public EntityLivingBase getTntPlacedBy() { + return this.tntPlacedBy; + } +} diff --git a/src/main/java/gtPlusPlus/core/entity/EntityTeleportFX.java b/src/main/java/gtPlusPlus/core/entity/EntityTeleportFX.java index ea667b8667..ca4229bec3 100644 --- a/src/main/java/gtPlusPlus/core/entity/EntityTeleportFX.java +++ b/src/main/java/gtPlusPlus/core/entity/EntityTeleportFX.java @@ -2,7 +2,6 @@ package gtPlusPlus.core.entity; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; import net.minecraft.init.Items; @@ -11,237 +10,228 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.MathHelper; import net.minecraft.world.World; -public class EntityTeleportFX extends Entity -{ - /** 'x' location the eye should float towards. */ - private double targetX; - /** 'y' location the eye should float towards. */ - private double targetY; - /** 'z' location the eye should float towards. */ - private double targetZ; - private int despawnTimer; - private boolean shatterOrDrop; - private static final String __OBFID = "CL_00001716"; - - public EntityTeleportFX(final World p_i1757_1_) - { - super(p_i1757_1_); - this.setSize(0.25F, 0.25F); - } - - @Override - protected void entityInit() {} - - /** - * Checks if the entity is in range to render by using the past in distance and comparing it to its average edge - * length * 64 * renderDistanceWeight Args: distance - */ - @Override - @SideOnly(Side.CLIENT) - public boolean isInRangeToRenderDist(final double p_70112_1_) - { - double d1 = this.boundingBox.getAverageEdgeLength() * 4.0D; - d1 *= 64.0D; - return p_70112_1_ < (d1 * d1); - } - - public EntityTeleportFX(final World p_i1758_1_, final double p_i1758_2_, final double p_i1758_4_, final double p_i1758_6_) - { - super(p_i1758_1_); - this.despawnTimer = 0; - this.setSize(0.25F, 0.25F); - this.setPosition(p_i1758_2_, p_i1758_4_, p_i1758_6_); - this.yOffset = 0.0F; - } - - /** - * The location the eye should float/move towards. Currently used for moving towards the nearest stronghold. Args: - * strongholdX, strongholdY, strongholdZ - */ - public void moveTowards(final double p_70220_1_, final int p_70220_3_, final double p_70220_4_) - { - final double d2 = p_70220_1_ - this.posX; - final double d3 = p_70220_4_ - this.posZ; - final float f = MathHelper.sqrt_double((d2 * d2) + (d3 * d3)); - - if (f > 12.0F) - { - this.targetX = this.posX + ((d2 / f) * 12.0D); - this.targetZ = this.posZ + ((d3 / f) * 12.0D); - this.targetY = this.posY + 8.0D; - } - else - { - this.targetX = p_70220_1_; - this.targetY = p_70220_3_; - this.targetZ = p_70220_4_; - } - - this.despawnTimer = 0; - this.shatterOrDrop = this.rand.nextInt(5) > 0; - } - - /** - * Sets the velocity to the args. Args: x, y, z - */ - @Override - @SideOnly(Side.CLIENT) - public void setVelocity(final double p_70016_1_, final double p_70016_3_, final double p_70016_5_) - { - this.motionX = p_70016_1_; - this.motionY = p_70016_3_; - this.motionZ = p_70016_5_; - - if ((this.prevRotationPitch == 0.0F) && (this.prevRotationYaw == 0.0F)) - { - final float f = MathHelper.sqrt_double((p_70016_1_ * p_70016_1_) + (p_70016_5_ * p_70016_5_)); - this.prevRotationYaw = this.rotationYaw = (float)((Math.atan2(p_70016_1_, p_70016_5_) * 180.0D) / Math.PI); - this.prevRotationPitch = this.rotationPitch = (float)((Math.atan2(p_70016_3_, f) * 180.0D) / Math.PI); - } - } - - /** - * Called to update the entity's position/logic. - */ - @Override - public void onUpdate() - { - this.lastTickPosX = this.posX; - this.lastTickPosY = this.posY; - this.lastTickPosZ = this.posZ; - super.onUpdate(); - this.posX += this.motionX; - this.posY += this.motionY; - this.posZ += this.motionZ; - final float f = MathHelper.sqrt_double((this.motionX * this.motionX) + (this.motionZ * this.motionZ)); - this.rotationYaw = (float)((Math.atan2(this.motionX, this.motionZ) * 180.0D) / Math.PI); - - for (this.rotationPitch = (float)((Math.atan2(this.motionY, f) * 180.0D) / Math.PI); (this.rotationPitch - this.prevRotationPitch) < -180.0F; this.prevRotationPitch -= 360.0F) - { - ; - } - - while ((this.rotationPitch - this.prevRotationPitch) >= 180.0F) - { - this.prevRotationPitch += 360.0F; - } - - while ((this.rotationYaw - this.prevRotationYaw) < -180.0F) - { - this.prevRotationYaw -= 360.0F; - } - - while ((this.rotationYaw - this.prevRotationYaw) >= 180.0F) - { - this.prevRotationYaw += 360.0F; - } - - this.rotationPitch = this.prevRotationPitch + ((this.rotationPitch - this.prevRotationPitch) * 0.2F); - this.rotationYaw = this.prevRotationYaw + ((this.rotationYaw - this.prevRotationYaw) * 0.2F); - - if (!this.worldObj.isRemote) - { - final double d0 = this.targetX - this.posX; - final double d1 = this.targetZ - this.posZ; - final float f1 = (float)Math.sqrt((d0 * d0) + (d1 * d1)); - final float f2 = (float)Math.atan2(d1, d0); - double d2 = f + ((f1 - f) * 0.0025D); - - if (f1 < 1.0F) - { - d2 *= 0.8D; - this.motionY *= 0.8D; - } - - this.motionX = Math.cos(f2) * d2; - this.motionZ = Math.sin(f2) * d2; - - if (this.posY < this.targetY) - { - this.motionY += (1.0D - this.motionY) * 0.014999999664723873D; - } - else - { - this.motionY += (-1.0D - this.motionY) * 0.014999999664723873D; - } - } - - final float f3 = 0.25F; - - if (this.isInWater()) - { - for (int i = 0; i < 4; ++i) - { - this.worldObj.spawnParticle("bubble", this.posX - (this.motionX * f3), this.posY - (this.motionY * f3), this.posZ - (this.motionZ * f3), this.motionX, this.motionY, this.motionZ); - } - } - else - { - this.worldObj.spawnParticle("portal", ((this.posX - (this.motionX * f3)) + (this.rand.nextDouble() * 0.6D)) - 0.3D, this.posY - (this.motionY * f3) - 0.5D, ((this.posZ - (this.motionZ * f3)) + (this.rand.nextDouble() * 0.6D)) - 0.3D, this.motionX, this.motionY, this.motionZ); - } - - if (!this.worldObj.isRemote) - { - this.setPosition(this.posX, this.posY, this.posZ); - ++this.despawnTimer; - - if ((this.despawnTimer > 80) && !this.worldObj.isRemote) - { - this.setDead(); - - if (this.shatterOrDrop) - { - this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, new ItemStack(Items.ender_eye))); - } - else - { - this.worldObj.playAuxSFX(2003, (int)Math.round(this.posX), (int)Math.round(this.posY), (int)Math.round(this.posZ), 0); - } - } - } - } - - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ - @Override - public void writeEntityToNBT(final NBTTagCompound p_70014_1_) {} - - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - @Override - public void readEntityFromNBT(final NBTTagCompound p_70037_1_) {} - - @Override - @SideOnly(Side.CLIENT) - public float getShadowSize() - { - return 0.0F; - } - - /** - * Gets how bright this entity is. - */ - @Override - public float getBrightness(final float p_70013_1_) - { - return 1.0F; - } - - @Override - @SideOnly(Side.CLIENT) - public int getBrightnessForRender(final float p_70070_1_) - { - return 15728880; - } - - /** - * If returns false, the item will not inflict any damage against entities. - */ - @Override - public boolean canAttackWithItem() - { - return false; - } -} \ No newline at end of file +public class EntityTeleportFX extends Entity { + /** 'x' location the eye should float towards. */ + private double targetX; + /** 'y' location the eye should float towards. */ + private double targetY; + /** 'z' location the eye should float towards. */ + private double targetZ; + + private int despawnTimer; + private boolean shatterOrDrop; + private static final String __OBFID = "CL_00001716"; + + public EntityTeleportFX(final World p_i1757_1_) { + super(p_i1757_1_); + this.setSize(0.25F, 0.25F); + } + + @Override + protected void entityInit() {} + + /** + * Checks if the entity is in range to render by using the past in distance and comparing it to its average edge + * length * 64 * renderDistanceWeight Args: distance + */ + @Override + @SideOnly(Side.CLIENT) + public boolean isInRangeToRenderDist(final double p_70112_1_) { + double d1 = this.boundingBox.getAverageEdgeLength() * 4.0D; + d1 *= 64.0D; + return p_70112_1_ < (d1 * d1); + } + + public EntityTeleportFX( + final World p_i1758_1_, final double p_i1758_2_, final double p_i1758_4_, final double p_i1758_6_) { + super(p_i1758_1_); + this.despawnTimer = 0; + this.setSize(0.25F, 0.25F); + this.setPosition(p_i1758_2_, p_i1758_4_, p_i1758_6_); + this.yOffset = 0.0F; + } + + /** + * The location the eye should float/move towards. Currently used for moving towards the nearest stronghold. Args: + * strongholdX, strongholdY, strongholdZ + */ + public void moveTowards(final double p_70220_1_, final int p_70220_3_, final double p_70220_4_) { + final double d2 = p_70220_1_ - this.posX; + final double d3 = p_70220_4_ - this.posZ; + final float f = MathHelper.sqrt_double((d2 * d2) + (d3 * d3)); + + if (f > 12.0F) { + this.targetX = this.posX + ((d2 / f) * 12.0D); + this.targetZ = this.posZ + ((d3 / f) * 12.0D); + this.targetY = this.posY + 8.0D; + } else { + this.targetX = p_70220_1_; + this.targetY = p_70220_3_; + this.targetZ = p_70220_4_; + } + + this.despawnTimer = 0; + this.shatterOrDrop = this.rand.nextInt(5) > 0; + } + + /** + * Sets the velocity to the args. Args: x, y, z + */ + @Override + @SideOnly(Side.CLIENT) + public void setVelocity(final double p_70016_1_, final double p_70016_3_, final double p_70016_5_) { + this.motionX = p_70016_1_; + this.motionY = p_70016_3_; + this.motionZ = p_70016_5_; + + if ((this.prevRotationPitch == 0.0F) && (this.prevRotationYaw == 0.0F)) { + final float f = MathHelper.sqrt_double((p_70016_1_ * p_70016_1_) + (p_70016_5_ * p_70016_5_)); + this.prevRotationYaw = this.rotationYaw = (float) ((Math.atan2(p_70016_1_, p_70016_5_) * 180.0D) / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float) ((Math.atan2(p_70016_3_, f) * 180.0D) / Math.PI); + } + } + + /** + * Called to update the entity's position/logic. + */ + @Override + public void onUpdate() { + this.lastTickPosX = this.posX; + this.lastTickPosY = this.posY; + this.lastTickPosZ = this.posZ; + super.onUpdate(); + this.posX += this.motionX; + this.posY += this.motionY; + this.posZ += this.motionZ; + final float f = MathHelper.sqrt_double((this.motionX * this.motionX) + (this.motionZ * this.motionZ)); + this.rotationYaw = (float) ((Math.atan2(this.motionX, this.motionZ) * 180.0D) / Math.PI); + + for (this.rotationPitch = (float) ((Math.atan2(this.motionY, f) * 180.0D) / Math.PI); + (this.rotationPitch - this.prevRotationPitch) < -180.0F; + this.prevRotationPitch -= 360.0F) { + ; + } + + while ((this.rotationPitch - this.prevRotationPitch) >= 180.0F) { + this.prevRotationPitch += 360.0F; + } + + while ((this.rotationYaw - this.prevRotationYaw) < -180.0F) { + this.prevRotationYaw -= 360.0F; + } + + while ((this.rotationYaw - this.prevRotationYaw) >= 180.0F) { + this.prevRotationYaw += 360.0F; + } + + this.rotationPitch = this.prevRotationPitch + ((this.rotationPitch - this.prevRotationPitch) * 0.2F); + this.rotationYaw = this.prevRotationYaw + ((this.rotationYaw - this.prevRotationYaw) * 0.2F); + + if (!this.worldObj.isRemote) { + final double d0 = this.targetX - this.posX; + final double d1 = this.targetZ - this.posZ; + final float f1 = (float) Math.sqrt((d0 * d0) + (d1 * d1)); + final float f2 = (float) Math.atan2(d1, d0); + double d2 = f + ((f1 - f) * 0.0025D); + + if (f1 < 1.0F) { + d2 *= 0.8D; + this.motionY *= 0.8D; + } + + this.motionX = Math.cos(f2) * d2; + this.motionZ = Math.sin(f2) * d2; + + if (this.posY < this.targetY) { + this.motionY += (1.0D - this.motionY) * 0.014999999664723873D; + } else { + this.motionY += (-1.0D - this.motionY) * 0.014999999664723873D; + } + } + + final float f3 = 0.25F; + + if (this.isInWater()) { + for (int i = 0; i < 4; ++i) { + this.worldObj.spawnParticle( + "bubble", + this.posX - (this.motionX * f3), + this.posY - (this.motionY * f3), + this.posZ - (this.motionZ * f3), + this.motionX, + this.motionY, + this.motionZ); + } + } else { + this.worldObj.spawnParticle( + "portal", + ((this.posX - (this.motionX * f3)) + (this.rand.nextDouble() * 0.6D)) - 0.3D, + this.posY - (this.motionY * f3) - 0.5D, + ((this.posZ - (this.motionZ * f3)) + (this.rand.nextDouble() * 0.6D)) - 0.3D, + this.motionX, + this.motionY, + this.motionZ); + } + + if (!this.worldObj.isRemote) { + this.setPosition(this.posX, this.posY, this.posZ); + ++this.despawnTimer; + + if ((this.despawnTimer > 80) && !this.worldObj.isRemote) { + this.setDead(); + + if (this.shatterOrDrop) { + this.worldObj.spawnEntityInWorld(new EntityItem( + this.worldObj, this.posX, this.posY, this.posZ, new ItemStack(Items.ender_eye))); + } else { + this.worldObj.playAuxSFX( + 2003, + (int) Math.round(this.posX), + (int) Math.round(this.posY), + (int) Math.round(this.posZ), + 0); + } + } + } + } + + /** + * (abstract) Protected helper method to write subclass entity data to NBT. + */ + @Override + public void writeEntityToNBT(final NBTTagCompound p_70014_1_) {} + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + @Override + public void readEntityFromNBT(final NBTTagCompound p_70037_1_) {} + + @Override + @SideOnly(Side.CLIENT) + public float getShadowSize() { + return 0.0F; + } + + /** + * Gets how bright this entity is. + */ + @Override + public float getBrightness(final float p_70013_1_) { + return 1.0F; + } + + @Override + @SideOnly(Side.CLIENT) + public int getBrightnessForRender(final float p_70070_1_) { + return 15728880; + } + + /** + * If returns false, the item will not inflict any damage against entities. + */ + @Override + public boolean canAttackWithItem() { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/core/entity/EntityTeslaTowerLightning.java b/src/main/java/gtPlusPlus/core/entity/EntityTeslaTowerLightning.java index bf629bd147..7d471bff4a 100644 --- a/src/main/java/gtPlusPlus/core/entity/EntityTeslaTowerLightning.java +++ b/src/main/java/gtPlusPlus/core/entity/EntityTeslaTowerLightning.java @@ -1,8 +1,12 @@ package gtPlusPlus.core.entity; + +import gtPlusPlus.api.damage.DamageTeslaTower; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.random.XSTR; +import gtPlusPlus.core.util.minecraft.EntityUtils; import java.util.List; import java.util.Random; import java.util.UUID; - import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; import net.minecraft.entity.effect.EntityWeatherEffect; @@ -13,156 +17,157 @@ import net.minecraft.util.MathHelper; import net.minecraft.world.EnumDifficulty; import net.minecraft.world.World; -import gtPlusPlus.api.damage.DamageTeslaTower; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.random.XSTR; -import gtPlusPlus.core.util.minecraft.EntityUtils; - -public class EntityTeslaTowerLightning extends EntityWeatherEffect -{ - /** Declares which state the lightning bolt is in. Whether it's in the air, hit the ground, etc. */ - private int lightningState; - /** A random long that is used to change the vertex of the lightning rendered in RenderLightningBolt */ - public long boltVertex; - /** Determines the time before the EntityLightningBolt is destroyed. It is a random integer decremented over time. */ - private int boltLivingTime; - - private final UUID boltID; - private final UUID boltOwnerID; - - private final Entity boltValidDamageTarget; - - - public EntityTeslaTowerLightning(World p_i1703_1_, double p_i1703_2_, double p_i1703_4_, double p_i1703_6_, Entity valid, UUID owner) - { - super(p_i1703_1_); - Logger.INFO("Plasma Bolt - Created."); - Random rand = new XSTR(p_i1703_1_.getSeed()); - this.setLocationAndAngles(p_i1703_2_, p_i1703_4_, p_i1703_6_, 0.0F, 0.0F); - this.lightningState = 2; - this.boltVertex = rand.nextLong(); - this.boltLivingTime = (1) + rand.nextInt(3) + 1; - this.boltValidDamageTarget = valid; - this.boltID = UUID.randomUUID(); - this.boltOwnerID = owner; - - //Puts fires out - if (!p_i1703_1_.isRemote && p_i1703_1_.getGameRules().getGameRuleBooleanValue("doFireTick") && (p_i1703_1_.difficultySetting == EnumDifficulty.NORMAL || p_i1703_1_.difficultySetting == EnumDifficulty.HARD) && p_i1703_1_.doChunksNearChunkExist(MathHelper.floor_double(p_i1703_2_), MathHelper.floor_double(p_i1703_4_), MathHelper.floor_double(p_i1703_6_), 10)) - { - Logger.INFO("Plasma Bolt - Putting out fires?."); - int i = MathHelper.floor_double(p_i1703_2_); - int j = MathHelper.floor_double(p_i1703_4_); - int k = MathHelper.floor_double(p_i1703_6_); - - if (p_i1703_1_.getBlock(i, j, k).getMaterial() == Material.fire) - { - p_i1703_1_.setBlock(i, j, k, Blocks.air); - } - - for (i = 0; i < 4; ++i) - { - j = MathHelper.floor_double(p_i1703_2_) + rand.nextInt(3) - 1; - k = MathHelper.floor_double(p_i1703_4_) + rand.nextInt(3) - 1; - int l = MathHelper.floor_double(p_i1703_6_) + rand.nextInt(3) - 1; - - if (p_i1703_1_.getBlock(j, k, l).getMaterial() == Material.fire) - { - p_i1703_1_.setBlock(j, k, l, Blocks.air); - } - } - } - } - - /** - * Called to update the entity's position/logic. - */ - public void onUpdate() - { - //Logger.INFO("Zap"); - super.onUpdate(); - Logger.INFO("Plasma Bolt - Tick."); - Random rand = new XSTR(this.worldObj.getSeed()); - - if (this.lightningState == 2) - { - Logger.INFO("Plasma Bolt - Playing Sound."); - this.worldObj.playSoundEffect(this.posX, this.posY, this.posZ, "ambient.weather.thunder", 10000.0F, 0.8F + rand.nextFloat() * 0.2F); - } - --this.lightningState; - - - if (this.lightningState >= 0) - { - Logger.INFO("Plasma Bolt - state >= 0."); - if (this.worldObj.isRemote) - { - Logger.INFO("Plasma Bolt - World is remote, resetting state to 2."); - this.worldObj.lastLightningBolt = 2; - } - else - { - Logger.INFO("Plasma Bolt - World is server side."); - double d0 = 3.0D; - List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, AxisAlignedBB.getBoundingBox(this.posX - d0, this.posY - d0, this.posZ - d0, this.posX + d0, this.posY + 6.0D + d0, this.posZ + d0)); - - for (int l = 0; l < list.size(); ++l) - { - Entity entity = list.get(l); - if (this.boltValidDamageTarget.getUniqueID().equals(entity.getUniqueID())){ - if (!entity.getUniqueID().equals(boltOwnerID)){ - Logger.INFO("Plasma Bolt - Hurting Entity."); - Logger.INFO("Plasma Bolt - "+entity.getCommandSenderName()+"."); - //if (!net.minecraftforge.event.ForgeEventFactory.onEntityStruckByLightning(entity, this)) - EntityUtils.doFireDamage(entity, 5); - EntityUtils.doDamage(entity, new DamageTeslaTower(entity), 20); - } - } - } - - } - } - - if (this.lightningState < 0) - { - Logger.INFO("Plasma Bolt - state < 0."); - if (this.boltLivingTime == 0) - { - Logger.INFO("Plasma Bolt - setting dead."); - this.setDead(); - } - else if (this.lightningState < -rand.nextInt(10)) - { - Logger.INFO("Plasma Bolt - dunno."); - --this.boltLivingTime; - this.lightningState = 1; - this.boltVertex = rand.nextLong(); - //Puts fires out. - if (!this.worldObj.isRemote && this.worldObj.getGameRules().getGameRuleBooleanValue("doFireTick") && this.worldObj.doChunksNearChunkExist(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ), 10)) - { - Logger.INFO("Plasma Bolt - Putting fires out [2]."); - int i = MathHelper.floor_double(this.posX); - int j = MathHelper.floor_double(this.posY); - int k = MathHelper.floor_double(this.posZ); - - if (this.worldObj.getBlock(i, j, k).getMaterial() == Material.fire) - { - this.worldObj.setBlock(i, j, k, Blocks.air); - } - } - - } - } - } - - protected void entityInit() {} - - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - protected void readEntityFromNBT(NBTTagCompound p_70037_1_) {} - - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ - protected void writeEntityToNBT(NBTTagCompound p_70014_1_) {} -} \ No newline at end of file +public class EntityTeslaTowerLightning extends EntityWeatherEffect { + /** Declares which state the lightning bolt is in. Whether it's in the air, hit the ground, etc. */ + private int lightningState; + /** A random long that is used to change the vertex of the lightning rendered in RenderLightningBolt */ + public long boltVertex; + /** Determines the time before the EntityLightningBolt is destroyed. It is a random integer decremented over time. */ + private int boltLivingTime; + + private final UUID boltID; + private final UUID boltOwnerID; + + private final Entity boltValidDamageTarget; + + public EntityTeslaTowerLightning( + World p_i1703_1_, double p_i1703_2_, double p_i1703_4_, double p_i1703_6_, Entity valid, UUID owner) { + super(p_i1703_1_); + Logger.INFO("Plasma Bolt - Created."); + Random rand = new XSTR(p_i1703_1_.getSeed()); + this.setLocationAndAngles(p_i1703_2_, p_i1703_4_, p_i1703_6_, 0.0F, 0.0F); + this.lightningState = 2; + this.boltVertex = rand.nextLong(); + this.boltLivingTime = (1) + rand.nextInt(3) + 1; + this.boltValidDamageTarget = valid; + this.boltID = UUID.randomUUID(); + this.boltOwnerID = owner; + + // Puts fires out + if (!p_i1703_1_.isRemote + && p_i1703_1_.getGameRules().getGameRuleBooleanValue("doFireTick") + && (p_i1703_1_.difficultySetting == EnumDifficulty.NORMAL + || p_i1703_1_.difficultySetting == EnumDifficulty.HARD) + && p_i1703_1_.doChunksNearChunkExist( + MathHelper.floor_double(p_i1703_2_), + MathHelper.floor_double(p_i1703_4_), + MathHelper.floor_double(p_i1703_6_), + 10)) { + Logger.INFO("Plasma Bolt - Putting out fires?."); + int i = MathHelper.floor_double(p_i1703_2_); + int j = MathHelper.floor_double(p_i1703_4_); + int k = MathHelper.floor_double(p_i1703_6_); + + if (p_i1703_1_.getBlock(i, j, k).getMaterial() == Material.fire) { + p_i1703_1_.setBlock(i, j, k, Blocks.air); + } + + for (i = 0; i < 4; ++i) { + j = MathHelper.floor_double(p_i1703_2_) + rand.nextInt(3) - 1; + k = MathHelper.floor_double(p_i1703_4_) + rand.nextInt(3) - 1; + int l = MathHelper.floor_double(p_i1703_6_) + rand.nextInt(3) - 1; + + if (p_i1703_1_.getBlock(j, k, l).getMaterial() == Material.fire) { + p_i1703_1_.setBlock(j, k, l, Blocks.air); + } + } + } + } + + /** + * Called to update the entity's position/logic. + */ + public void onUpdate() { + // Logger.INFO("Zap"); + super.onUpdate(); + Logger.INFO("Plasma Bolt - Tick."); + Random rand = new XSTR(this.worldObj.getSeed()); + + if (this.lightningState == 2) { + Logger.INFO("Plasma Bolt - Playing Sound."); + this.worldObj.playSoundEffect( + this.posX, + this.posY, + this.posZ, + "ambient.weather.thunder", + 10000.0F, + 0.8F + rand.nextFloat() * 0.2F); + } + --this.lightningState; + + if (this.lightningState >= 0) { + Logger.INFO("Plasma Bolt - state >= 0."); + if (this.worldObj.isRemote) { + Logger.INFO("Plasma Bolt - World is remote, resetting state to 2."); + this.worldObj.lastLightningBolt = 2; + } else { + Logger.INFO("Plasma Bolt - World is server side."); + double d0 = 3.0D; + List list = this.worldObj.getEntitiesWithinAABBExcludingEntity( + this, + AxisAlignedBB.getBoundingBox( + this.posX - d0, + this.posY - d0, + this.posZ - d0, + this.posX + d0, + this.posY + 6.0D + d0, + this.posZ + d0)); + + for (int l = 0; l < list.size(); ++l) { + Entity entity = list.get(l); + if (this.boltValidDamageTarget.getUniqueID().equals(entity.getUniqueID())) { + if (!entity.getUniqueID().equals(boltOwnerID)) { + Logger.INFO("Plasma Bolt - Hurting Entity."); + Logger.INFO("Plasma Bolt - " + entity.getCommandSenderName() + "."); + // if (!net.minecraftforge.event.ForgeEventFactory.onEntityStruckByLightning(entity, this)) + EntityUtils.doFireDamage(entity, 5); + EntityUtils.doDamage(entity, new DamageTeslaTower(entity), 20); + } + } + } + } + } + + if (this.lightningState < 0) { + Logger.INFO("Plasma Bolt - state < 0."); + if (this.boltLivingTime == 0) { + Logger.INFO("Plasma Bolt - setting dead."); + this.setDead(); + } else if (this.lightningState < -rand.nextInt(10)) { + Logger.INFO("Plasma Bolt - dunno."); + --this.boltLivingTime; + this.lightningState = 1; + this.boltVertex = rand.nextLong(); + // Puts fires out. + if (!this.worldObj.isRemote + && this.worldObj.getGameRules().getGameRuleBooleanValue("doFireTick") + && this.worldObj.doChunksNearChunkExist( + MathHelper.floor_double(this.posX), + MathHelper.floor_double(this.posY), + MathHelper.floor_double(this.posZ), + 10)) { + Logger.INFO("Plasma Bolt - Putting fires out [2]."); + int i = MathHelper.floor_double(this.posX); + int j = MathHelper.floor_double(this.posY); + int k = MathHelper.floor_double(this.posZ); + + if (this.worldObj.getBlock(i, j, k).getMaterial() == Material.fire) { + this.worldObj.setBlock(i, j, k, Blocks.air); + } + } + } + } + } + + protected void entityInit() {} + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + protected void readEntityFromNBT(NBTTagCompound p_70037_1_) {} + + /** + * (abstract) Protected helper method to write subclass entity data to NBT. + */ + protected void writeEntityToNBT(NBTTagCompound p_70014_1_) {} +} diff --git a/src/main/java/gtPlusPlus/core/entity/InternalEntityRegistry.java b/src/main/java/gtPlusPlus/core/entity/InternalEntityRegistry.java index 6b88d5775c..fcfcbc0b68 100644 --- a/src/main/java/gtPlusPlus/core/entity/InternalEntityRegistry.java +++ b/src/main/java/gtPlusPlus/core/entity/InternalEntityRegistry.java @@ -1,7 +1,6 @@ package gtPlusPlus.core.entity; import cpw.mods.fml.common.registry.EntityRegistry; - import gtPlusPlus.GTplusplus; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.australia.entity.type.EntityAustralianSpiderBase; @@ -22,75 +21,110 @@ import gtPlusPlus.core.util.Utils; public class InternalEntityRegistry { - static int mEntityID = 0; - - public static void registerEntities(){ - Logger.INFO("Registering GT++ Entities."); - - //EntityRegistry.registerGlobalEntityID(EntityPrimedMiningExplosive.class, "MiningCharge", EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(0, 0, 0), Utils.rgbtoHexValue(125, 125, 125)); - EntityRegistry.registerModEntity(EntityPrimedMiningExplosive.class, "MiningCharge", mEntityID++, GTplusplus.instance, 64, 20, true); - - //EntityRegistry.registerGlobalEntityID(EntitySulfuricAcidPotion.class, "throwablePotionSulfuric", EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(200, 0, 200), Utils.rgbtoHexValue(125, 125, 125)); - EntityRegistry.registerModEntity(EntitySulfuricAcidPotion.class, "throwablePotionSulfuric", mEntityID++, GTplusplus.instance, 64, 20, true); - - - //EntityRegistry.registerGlobalEntityID(EntityHydrofluoricAcidPotion.class, "throwablePotionHydrofluoric", EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(0, 0, 0), Utils.rgbtoHexValue(255, 255, 255)); - EntityRegistry.registerModEntity(EntityHydrofluoricAcidPotion.class, "throwablePotionHydrofluoric", mEntityID++, GTplusplus.instance, 64, 20, true); - - - //EntityRegistry.registerGlobalEntityID(EntityToxinballSmall.class, "toxinBall", EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(0, 25, 0), Utils.rgbtoHexValue(0, 125, 0)); - EntityRegistry.registerModEntity(EntityToxinballSmall.class, "toxinBall", mEntityID++, GTplusplus.instance, 64, 20, true); - - - //EntityRegistry.registerGlobalEntityID(EntityStaballoyConstruct.class, "constructStaballoy", EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(0, 75, 0), Utils.rgbtoHexValue(50, 220, 50)); - EntityRegistry.registerModEntity(EntityStaballoyConstruct.class, "constructStaballoy", mEntityID++, GTplusplus.instance, 64, 20, true); - ItemCustomSpawnEgg.registerEntityForSpawnEgg(0, "constructStaballoy", Utils.rgbtoHexValue(20, 200, 20), Utils.rgbtoHexValue(20, 20, 20)); - - //EntityRegistry.registerGlobalEntityID(EntitySickBlaze.class, "sickBlaze", EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(0, 75, 0), Utils.rgbtoHexValue(75, 175, 75)); - EntityRegistry.registerModEntity(EntitySickBlaze.class, "sickBlaze", mEntityID++, GTplusplus.instance, 64, 20, true); - ItemCustomSpawnEgg.registerEntityForSpawnEgg(1, "sickBlaze", Utils.rgbtoHexValue(40, 180, 40), Utils.rgbtoHexValue(75, 75, 75)); - - //EntityRegistry.registerGlobalEntityID(EntityTeslaTowerLightning.class, "plasmaBolt", EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(255, 0, 0), Utils.rgbtoHexValue(125, 125, 125)); - EntityRegistry.registerModEntity(EntityTeslaTowerLightning.class, "plasmaBolt", mEntityID++, GTplusplus.instance, 64, 5, true); - - EntityRegistry.registerModEntity(EntityThrowableBomb.class, "EntityThrowableBomb", mEntityID++, GTplusplus.instance, 64, 10, true); - - EntityRegistry.registerModEntity(EntityLightningAttack.class, "EntityLightningAttack", mEntityID++, GTplusplus.instance, 64, 20, true); - + static int mEntityID = 0; + + public static void registerEntities() { + Logger.INFO("Registering GT++ Entities."); + + // EntityRegistry.registerGlobalEntityID(EntityPrimedMiningExplosive.class, "MiningCharge", + // EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(0, 0, 0), Utils.rgbtoHexValue(125, 125, 125)); + EntityRegistry.registerModEntity( + EntityPrimedMiningExplosive.class, "MiningCharge", mEntityID++, GTplusplus.instance, 64, 20, true); + + // EntityRegistry.registerGlobalEntityID(EntitySulfuricAcidPotion.class, "throwablePotionSulfuric", + // EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(200, 0, 200), Utils.rgbtoHexValue(125, 125, + // 125)); + EntityRegistry.registerModEntity( + EntitySulfuricAcidPotion.class, + "throwablePotionSulfuric", + mEntityID++, + GTplusplus.instance, + 64, + 20, + true); + + // EntityRegistry.registerGlobalEntityID(EntityHydrofluoricAcidPotion.class, "throwablePotionHydrofluoric", + // EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(0, 0, 0), Utils.rgbtoHexValue(255, 255, 255)); + EntityRegistry.registerModEntity( + EntityHydrofluoricAcidPotion.class, + "throwablePotionHydrofluoric", + mEntityID++, + GTplusplus.instance, + 64, + 20, + true); + + // EntityRegistry.registerGlobalEntityID(EntityToxinballSmall.class, "toxinBall", + // EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(0, 25, 0), Utils.rgbtoHexValue(0, 125, 0)); + EntityRegistry.registerModEntity( + EntityToxinballSmall.class, "toxinBall", mEntityID++, GTplusplus.instance, 64, 20, true); + + // EntityRegistry.registerGlobalEntityID(EntityStaballoyConstruct.class, "constructStaballoy", + // EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(0, 75, 0), Utils.rgbtoHexValue(50, 220, 50)); + EntityRegistry.registerModEntity( + EntityStaballoyConstruct.class, "constructStaballoy", mEntityID++, GTplusplus.instance, 64, 20, true); + ItemCustomSpawnEgg.registerEntityForSpawnEgg( + 0, "constructStaballoy", Utils.rgbtoHexValue(20, 200, 20), Utils.rgbtoHexValue(20, 20, 20)); + + // EntityRegistry.registerGlobalEntityID(EntitySickBlaze.class, "sickBlaze", + // EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(0, 75, 0), Utils.rgbtoHexValue(75, 175, 75)); + EntityRegistry.registerModEntity( + EntitySickBlaze.class, "sickBlaze", mEntityID++, GTplusplus.instance, 64, 20, true); + ItemCustomSpawnEgg.registerEntityForSpawnEgg( + 1, "sickBlaze", Utils.rgbtoHexValue(40, 180, 40), Utils.rgbtoHexValue(75, 75, 75)); + + // EntityRegistry.registerGlobalEntityID(EntityTeslaTowerLightning.class, "plasmaBolt", + // EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(255, 0, 0), Utils.rgbtoHexValue(125, 125, + // 125)); + EntityRegistry.registerModEntity( + EntityTeslaTowerLightning.class, "plasmaBolt", mEntityID++, GTplusplus.instance, 64, 5, true); + + EntityRegistry.registerModEntity( + EntityThrowableBomb.class, "EntityThrowableBomb", mEntityID++, GTplusplus.instance, 64, 10, true); + + EntityRegistry.registerModEntity( + EntityLightningAttack.class, "EntityLightningAttack", mEntityID++, GTplusplus.instance, 64, 20, true); + /** * Globals, which generate spawn eggs. (Currently required for Giant chicken spawning) */ - - EntityRegistry.registerModEntity(EntityGiantChickenBase.class, "bigChickenFriendly", mEntityID++, GTplusplus.instance, 64, 20, true); - ItemCustomSpawnEgg.registerEntityForSpawnEgg(2, "bigChickenFriendly", Utils.rgbtoHexValue(255, 0, 0), Utils.rgbtoHexValue(175, 175, 175)); - EntityRegistry.registerModEntity(EntityBatKing.class, "batKing", mEntityID++, GTplusplus.instance, 64, 20, true); - ItemCustomSpawnEgg.registerEntityForSpawnEgg(3, "batKing", Utils.rgbtoHexValue(175, 175, 0), Utils.rgbtoHexValue(0, 175, 175)); - //EntityRegistry.registerModEntity(EntityGiantChickenBase.class, "bigChickenFriendly", mEntityID++, GTplusplus.instance, 64, 20, true); - - - - - - //Australia - EntityRegistry.registerModEntity(EntityAustralianSpiderBase.class, "AusSpider", mEntityID++, GTplusplus.instance, 64, 20, true); - ItemCustomSpawnEgg.registerEntityForSpawnEgg(30, "AusSpider", Utils.rgbtoHexValue(125, 0, 125), Utils.rgbtoHexValue(175, 175, 175)); + EntityRegistry.registerModEntity( + EntityGiantChickenBase.class, "bigChickenFriendly", mEntityID++, GTplusplus.instance, 64, 20, true); + ItemCustomSpawnEgg.registerEntityForSpawnEgg( + 2, "bigChickenFriendly", Utils.rgbtoHexValue(255, 0, 0), Utils.rgbtoHexValue(175, 175, 175)); + EntityRegistry.registerModEntity( + EntityBatKing.class, "batKing", mEntityID++, GTplusplus.instance, 64, 20, true); + ItemCustomSpawnEgg.registerEntityForSpawnEgg( + 3, "batKing", Utils.rgbtoHexValue(175, 175, 0), Utils.rgbtoHexValue(0, 175, 175)); + // EntityRegistry.registerModEntity(EntityGiantChickenBase.class, "bigChickenFriendly", mEntityID++, + // GTplusplus.instance, 64, 20, true); + + // Australia + EntityRegistry.registerModEntity( + EntityAustralianSpiderBase.class, "AusSpider", mEntityID++, GTplusplus.instance, 64, 20, true); + ItemCustomSpawnEgg.registerEntityForSpawnEgg( + 30, "AusSpider", Utils.rgbtoHexValue(125, 0, 125), Utils.rgbtoHexValue(175, 175, 175)); EntityRegistry.registerModEntity(EntityBoar.class, "AusBoar", mEntityID++, GTplusplus.instance, 64, 20, true); - ItemCustomSpawnEgg.registerEntityForSpawnEgg(31, "AusBoar", Utils.rgbtoHexValue(75, 75, 0), Utils.rgbtoHexValue(175, 175, 75)); + ItemCustomSpawnEgg.registerEntityForSpawnEgg( + 31, "AusBoar", Utils.rgbtoHexValue(75, 75, 0), Utils.rgbtoHexValue(175, 175, 75)); EntityRegistry.registerModEntity(EntityDingo.class, "AusDingo", mEntityID++, GTplusplus.instance, 64, 20, true); - ItemCustomSpawnEgg.registerEntityForSpawnEgg(32, "AusDingo", Utils.rgbtoHexValue(175, 125, 0), Utils.rgbtoHexValue(175, 75, 175)); - EntityRegistry.registerModEntity(EntityOctopus.class, "AusOctopus", mEntityID++, GTplusplus.instance, 32, 20, true); - ItemCustomSpawnEgg.registerEntityForSpawnEgg(33, "AusOctopus", Utils.rgbtoHexValue(150, 50, 150), Utils.rgbtoHexValue(75, 175, 175)); - //EntityRegistry.registerGlobalEntityID(EntityAustralianSpiderBase.class, "AusSpider", EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(255, 0, 0), Utils.rgbtoHexValue(175, 175, 175)); - //EntityRegistry.registerGlobalEntityID(EntityBoar.class, "AusBoar", EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(255, 0, 0), Utils.rgbtoHexValue(175, 175, 175)); - //EntityRegistry.registerGlobalEntityID(EntityDingo.class, "AusDingo", EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(255, 0, 0), Utils.rgbtoHexValue(175, 175, 175)); - //EntityRegistry.registerGlobalEntityID(EntityOctopus.class, "AusOctopus", EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(255, 0, 0), Utils.rgbtoHexValue(175, 175, 175)); - - - - - - - - } - + ItemCustomSpawnEgg.registerEntityForSpawnEgg( + 32, "AusDingo", Utils.rgbtoHexValue(175, 125, 0), Utils.rgbtoHexValue(175, 75, 175)); + EntityRegistry.registerModEntity( + EntityOctopus.class, "AusOctopus", mEntityID++, GTplusplus.instance, 32, 20, true); + ItemCustomSpawnEgg.registerEntityForSpawnEgg( + 33, "AusOctopus", Utils.rgbtoHexValue(150, 50, 150), Utils.rgbtoHexValue(75, 175, 175)); + // EntityRegistry.registerGlobalEntityID(EntityAustralianSpiderBase.class, "AusSpider", + // EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(255, 0, 0), Utils.rgbtoHexValue(175, 175, + // 175)); + // EntityRegistry.registerGlobalEntityID(EntityBoar.class, "AusBoar", EntityRegistry.findGlobalUniqueEntityId(), + // Utils.rgbtoHexValue(255, 0, 0), Utils.rgbtoHexValue(175, 175, 175)); + // EntityRegistry.registerGlobalEntityID(EntityDingo.class, "AusDingo", + // EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(255, 0, 0), Utils.rgbtoHexValue(175, 175, + // 175)); + // EntityRegistry.registerGlobalEntityID(EntityOctopus.class, "AusOctopus", + // EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(255, 0, 0), Utils.rgbtoHexValue(175, 175, + // 175)); + + } } diff --git a/src/main/java/gtPlusPlus/core/entity/ai/batking/EntityAIBatKingAttack.java b/src/main/java/gtPlusPlus/core/entity/ai/batking/EntityAIBatKingAttack.java index 52d1d6100c..810c3eadff 100644 --- a/src/main/java/gtPlusPlus/core/entity/ai/batking/EntityAIBatKingAttack.java +++ b/src/main/java/gtPlusPlus/core/entity/ai/batking/EntityAIBatKingAttack.java @@ -13,394 +13,422 @@ import net.minecraft.util.MathHelper; public class EntityAIBatKingAttack extends EntityAIBase { - private final Ranged mRangedAI; - private final Melee mMeleeAI; - private boolean mIsMelee = false; - - /** The Bat King in control of this AI. */ - private final EntityBatKing mAttackingEntity; - - /** The PathEntity of our entity. */ - private PathEntity mEntityPathEntity; - - /** The current target of Bat King in control of this AI. */ - private EntityLivingBase mEntityTarget; - - private final Class mClassTarget; - - public EntityAIBatKingAttack(EntityBatKing aAttacker, Class aClassTarget, - double aMovementSpeed, int someInt, int aMaxRangedAttackTime, float someFloat, boolean aLongMemory) { - mRangedAI = new Ranged(this, aMovementSpeed, someInt, 5, someFloat); - mMeleeAI = new Melee(this, aClassTarget, aMovementSpeed, aLongMemory); - mAttackingEntity = aAttacker; - mClassTarget = aClassTarget; - } - - @Override - public boolean shouldExecute() { - determineCombatStyle(); - EntityLivingBase entitylivingbase = this.mAttackingEntity.getAttackTarget(); - if (entitylivingbase == null) { - this.mEntityTarget = null; - return false; - } else if (!entitylivingbase.isEntityAlive()) { - return false; - } else if (this.mClassTarget != null && !this.mClassTarget.isAssignableFrom(entitylivingbase.getClass())) { - return false; - } else { - if (this.mIsMelee) { - return this.mMeleeAI.shouldExecute(); - } - else { - this.mEntityTarget = entitylivingbase; - this.mEntityPathEntity = this.mAttackingEntity.getNavigator().getPathToEntityLiving(entitylivingbase); - return mRangedAI != null && mMeleeAI != null && hasValidTarget(); - } - } - } - - public EntityBatKing getBatKing() { - return this.mAttackingEntity; - } - - public IRangedAttackMob getBatKingAsIRangedAttackMob() { - return this.mAttackingEntity; - } - - public boolean hasValidTarget() { - return this.mEntityTarget != null; - } - - public EntityLivingBase getTarget() { - return mEntityTarget; - } - - @Override - public boolean continueExecuting() { - determineCombatStyle(); - if (mIsMelee) { - return mMeleeAI.continueExecuting(); - } else { - return mRangedAI.continueExecuting(); - } - } - - @Override - public boolean isInterruptible() { - if (mIsMelee) { - - } else { - - } - return super.isInterruptible(); - } - - @Override - public void startExecuting() { - determineCombatStyle(); - if (mIsMelee) { - mMeleeAI.startExecuting(); - } else { - mRangedAI.startExecuting(); - } - } - - @Override - public void resetTask() { - determineCombatStyle(); - if (mIsMelee) { - mMeleeAI.resetTask(); - } else { - mRangedAI.resetTask(); - } - } - - @Override - public void updateTask() { - determineCombatStyle(); - if (mIsMelee) { - mMeleeAI.updateTask(); - } else { - mRangedAI.updateTask(); - } - } - - - private final void determineCombatStyle() { - boolean aisMeleeNow = this.mIsMelee; - if (this.mEntityTarget != null && EntityUtils.getDistance(getBatKing(), mEntityTarget) < 4) { - this.mIsMelee = true; - } - else { - this.mIsMelee = false; - } - if (aisMeleeNow != this.mIsMelee) { - Logger.INFO("Bat King changed combat style from "+(aisMeleeNow ? "Melee" : "Ranged")+" to "+(this.mIsMelee ? "Melee" : "Ranged")); - } - } - - private class Ranged { - - private final EntityAIBatKingAttack parentAI; - - /** - * A decrementing tick that spawns a ranged attack once this value reaches 0. It - * is then set back to the maxRangedAttackTime. - */ - private int rangedAttackTime; - private double entityMoveSpeed; - private int mCooldownTime; - private int field_96561_g; - /** - * The maximum time the AI has to wait before performing another ranged attack. - */ - private int maxRangedAttackTime; - private float field_96562_i; - private float field_82642_h; //Max range - - public Ranged(EntityAIBatKingAttack aParent, double aMovementSpeed, int someInt, - int aMaxRangedAttackTime, float someFloat) { - this.rangedAttackTime = -1; - this.parentAI = aParent; - this.entityMoveSpeed = aMovementSpeed; - this.field_96561_g = someInt; - this.maxRangedAttackTime = aMaxRangedAttackTime; - this.field_96562_i = someFloat; - this.field_82642_h = someFloat * someFloat * 8; - parentAI.setMutexBits(3); - - } - - /** - * Execute a one shot task or start executing a continuous task - */ - public void startExecuting() { - parentAI.getBatKing().getNavigator().setPath(parentAI.mEntityPathEntity, this.entityMoveSpeed); - } - - /** - * Returns whether an in-progress EntityAIBase should continue executing - */ - public boolean continueExecuting() { - return parentAI.shouldExecute() || !parentAI.getBatKing().getNavigator().noPath(); - } - - /** - * Resets the task - */ - public void resetTask() { - parentAI.mEntityTarget = null; - this.mCooldownTime = 0; - this.rangedAttackTime = -1; - } - - /** - * Updates the task - */ - public void updateTask() { - - if (MathUtils.randInt(0, 100) == 0) { - maxRangedAttackTime = MathUtils.balance(maxRangedAttackTime, 20, 40); - } - - double d0 = parentAI.getBatKing().getDistanceSq(parentAI.mEntityTarget.posX, parentAI.mEntityTarget.boundingBox.minY, - parentAI.mEntityTarget.posZ); - boolean flag = parentAI.getBatKing().getEntitySenses().canSee(parentAI.mEntityTarget); - - if (flag) { - ++this.mCooldownTime; - } else { - this.mCooldownTime = 0; - } - - if (d0 <= (double) this.field_82642_h && this.mCooldownTime >= 20) { - parentAI.getBatKing().getNavigator().clearPathEntity(); - } else { - if (parentAI.getBatKing().getNavigator().tryMoveToEntityLiving(parentAI.mEntityTarget, this.entityMoveSpeed)) { - Logger.INFO("Doing Ranged Ai Task."); - } - else { - Logger.INFO("Not Doing Ranged Ai Task."); - } - } - - parentAI.getBatKing().getLookHelper().setLookPositionWithEntity(parentAI.mEntityTarget, 30.0F, 30.0F); - float f; - Logger.INFO("Ranged AI - "+rangedAttackTime); - - if (--this.rangedAttackTime == 0) { - if (d0 > (double) this.field_82642_h || !flag) { - Logger.INFO("Stopping ranged attack. "+flag+"|"+(d0 > (double) this.field_82642_h)+"|"+d0+"|"+(double) this.field_82642_h); - return; - } - - f = MathHelper.sqrt_double(d0) / this.field_96562_i; - float f1 = f; - - if (f < 0.1F) { - f1 = 0.1F; - } - - if (f1 > 1.0F) { - f1 = 1.0F; - } - Logger.INFO("Trying to do a ranged attack."); - parentAI.getBatKingAsIRangedAttackMob().attackEntityWithRangedAttack(parentAI.mEntityTarget, f1); - this.rangedAttackTime = MathHelper.floor_float( - f * (float) (this.maxRangedAttackTime - this.field_96561_g) + (float) this.field_96561_g); - } else if (this.rangedAttackTime < 0) { - f = MathHelper.sqrt_double(d0) / this.field_96562_i; - this.rangedAttackTime = MathHelper.floor_float( - f * (float) (this.maxRangedAttackTime - this.field_96561_g) + (float) this.field_96561_g); - } - } - - } - - private class Melee { - - private final EntityAIBatKingAttack parentAI; - - /** - * An amount of decrementing ticks that allows the entity to attack once the - * tick reaches 0. - */ - int attackTick; - /** The speed with which the mob will approach the target */ - double speedTowardsTarget; - /** - * When true, the mob will continue chasing its target, even if it can't find a - * path to them right now. - */ - boolean longMemory; - Class classTarget; - private int field_75445_i; - private double field_151497_i; - private double field_151495_j; - private double field_151496_k; - - private int failedPathFindingPenalty; - - public Melee(EntityAIBatKingAttack aParent, Class aClassTarget, - double aMoveToTargetSpeed, boolean aLongMemory) { - this.parentAI = aParent; - this.classTarget = aClassTarget; - this.speedTowardsTarget = aMoveToTargetSpeed; - this.longMemory = aLongMemory; - parentAI.setMutexBits(3); - } - - /** - * Returns whether the EntityAIBase should begin execution. - */ - public boolean shouldExecute() { - if (!parentAI.hasValidTarget()) { - return false; - } - EntityLivingBase entitylivingbase = parentAI.getTarget(); - - if (entitylivingbase == null) { - return false; - } else if (!entitylivingbase.isEntityAlive()) { - return false; - } else if (this.classTarget != null && !this.classTarget.isAssignableFrom(entitylivingbase.getClass())) { - return false; - } else { - if (--this.field_75445_i <= 0) { - parentAI.mEntityPathEntity = parentAI.mAttackingEntity.getNavigator().getPathToEntityLiving(entitylivingbase); - this.field_75445_i = 4 + parentAI.mAttackingEntity.getRNG().nextInt(7); - return parentAI.mEntityPathEntity != null; - } else { - return true; - } - } - } - - /** - * Returns whether an in-progress EntityAIBase should continue executing - */ - public boolean continueExecuting() { - EntityLivingBase entitylivingbase = parentAI.mAttackingEntity.getAttackTarget(); - return entitylivingbase == null ? false - : (!entitylivingbase.isEntityAlive() ? false - : (!this.longMemory ? !parentAI.mAttackingEntity.getNavigator().noPath() - : parentAI.mAttackingEntity.isWithinHomeDistance(MathHelper.floor_double(entitylivingbase.posX), - MathHelper.floor_double(entitylivingbase.posY), - MathHelper.floor_double(entitylivingbase.posZ)))); - } - - /** - * Execute a one shot task or start executing a continuous task - */ - public void startExecuting() { - parentAI.mAttackingEntity.getNavigator().setPath(parentAI.mEntityPathEntity, this.speedTowardsTarget); - this.field_75445_i = 0; - } - - /** - * Resets the task - */ - public void resetTask() { - parentAI.mAttackingEntity.getNavigator().clearPathEntity(); - } - - /** - * Updates the task - */ - public void updateTask() { - EntityLivingBase entitylivingbase = parentAI.mAttackingEntity.getAttackTarget(); - parentAI.mAttackingEntity.getLookHelper().setLookPositionWithEntity(entitylivingbase, 30.0F, 30.0F); - double d0 = parentAI.mAttackingEntity.getDistanceSq(entitylivingbase.posX, entitylivingbase.boundingBox.minY, - entitylivingbase.posZ); - double d1 = (double) (parentAI.mAttackingEntity.width * 2.0F * parentAI.mAttackingEntity.width * 2.0F + entitylivingbase.width); - --this.field_75445_i; - - if ((this.longMemory || parentAI.mAttackingEntity.getEntitySenses().canSee(entitylivingbase)) && this.field_75445_i <= 0 - && (this.field_151497_i == 0.0D && this.field_151495_j == 0.0D && this.field_151496_k == 0.0D - || entitylivingbase.getDistanceSq(this.field_151497_i, this.field_151495_j, - this.field_151496_k) >= 1.0D - || parentAI.mAttackingEntity.getRNG().nextFloat() < 0.05F)) { - this.field_151497_i = entitylivingbase.posX; - this.field_151495_j = entitylivingbase.boundingBox.minY; - this.field_151496_k = entitylivingbase.posZ; - this.field_75445_i = failedPathFindingPenalty + 4 + parentAI.mAttackingEntity.getRNG().nextInt(7); - - if (parentAI.mAttackingEntity.getNavigator().getPath() != null) { - PathPoint finalPathPoint = parentAI.mAttackingEntity.getNavigator().getPath().getFinalPathPoint(); - if (finalPathPoint != null && entitylivingbase.getDistanceSq(finalPathPoint.xCoord, - finalPathPoint.yCoord, finalPathPoint.zCoord) < 1) { - failedPathFindingPenalty = 0; - } else { - failedPathFindingPenalty += 10; - } - } else { - failedPathFindingPenalty += 10; - } - - if (d0 > 1024.0D) { - this.field_75445_i += 10; - } else if (d0 > 256.0D) { - this.field_75445_i += 5; - } - - if (!parentAI.mAttackingEntity.getNavigator().tryMoveToEntityLiving(entitylivingbase, this.speedTowardsTarget)) { - this.field_75445_i += 15; - } - } - - this.attackTick = Math.max(this.attackTick - 1, 0); - - if (d0 <= d1 && this.attackTick <= 20) { - this.attackTick = 20; - - if (parentAI.mAttackingEntity.getHeldItem() != null) { - parentAI.mAttackingEntity.swingItem(); - } - - parentAI.mAttackingEntity.attackEntityAsMob(entitylivingbase); - } - } - - } - -} \ No newline at end of file + private final Ranged mRangedAI; + private final Melee mMeleeAI; + private boolean mIsMelee = false; + + /** The Bat King in control of this AI. */ + private final EntityBatKing mAttackingEntity; + + /** The PathEntity of our entity. */ + private PathEntity mEntityPathEntity; + + /** The current target of Bat King in control of this AI. */ + private EntityLivingBase mEntityTarget; + + private final Class mClassTarget; + + public EntityAIBatKingAttack( + EntityBatKing aAttacker, + Class aClassTarget, + double aMovementSpeed, + int someInt, + int aMaxRangedAttackTime, + float someFloat, + boolean aLongMemory) { + mRangedAI = new Ranged(this, aMovementSpeed, someInt, 5, someFloat); + mMeleeAI = new Melee(this, aClassTarget, aMovementSpeed, aLongMemory); + mAttackingEntity = aAttacker; + mClassTarget = aClassTarget; + } + + @Override + public boolean shouldExecute() { + determineCombatStyle(); + EntityLivingBase entitylivingbase = this.mAttackingEntity.getAttackTarget(); + if (entitylivingbase == null) { + this.mEntityTarget = null; + return false; + } else if (!entitylivingbase.isEntityAlive()) { + return false; + } else if (this.mClassTarget != null && !this.mClassTarget.isAssignableFrom(entitylivingbase.getClass())) { + return false; + } else { + if (this.mIsMelee) { + return this.mMeleeAI.shouldExecute(); + } else { + this.mEntityTarget = entitylivingbase; + this.mEntityPathEntity = this.mAttackingEntity.getNavigator().getPathToEntityLiving(entitylivingbase); + return mRangedAI != null && mMeleeAI != null && hasValidTarget(); + } + } + } + + public EntityBatKing getBatKing() { + return this.mAttackingEntity; + } + + public IRangedAttackMob getBatKingAsIRangedAttackMob() { + return this.mAttackingEntity; + } + + public boolean hasValidTarget() { + return this.mEntityTarget != null; + } + + public EntityLivingBase getTarget() { + return mEntityTarget; + } + + @Override + public boolean continueExecuting() { + determineCombatStyle(); + if (mIsMelee) { + return mMeleeAI.continueExecuting(); + } else { + return mRangedAI.continueExecuting(); + } + } + + @Override + public boolean isInterruptible() { + if (mIsMelee) { + + } else { + + } + return super.isInterruptible(); + } + + @Override + public void startExecuting() { + determineCombatStyle(); + if (mIsMelee) { + mMeleeAI.startExecuting(); + } else { + mRangedAI.startExecuting(); + } + } + + @Override + public void resetTask() { + determineCombatStyle(); + if (mIsMelee) { + mMeleeAI.resetTask(); + } else { + mRangedAI.resetTask(); + } + } + + @Override + public void updateTask() { + determineCombatStyle(); + if (mIsMelee) { + mMeleeAI.updateTask(); + } else { + mRangedAI.updateTask(); + } + } + + private final void determineCombatStyle() { + boolean aisMeleeNow = this.mIsMelee; + if (this.mEntityTarget != null && EntityUtils.getDistance(getBatKing(), mEntityTarget) < 4) { + this.mIsMelee = true; + } else { + this.mIsMelee = false; + } + if (aisMeleeNow != this.mIsMelee) { + Logger.INFO("Bat King changed combat style from " + (aisMeleeNow ? "Melee" : "Ranged") + " to " + + (this.mIsMelee ? "Melee" : "Ranged")); + } + } + + private class Ranged { + + private final EntityAIBatKingAttack parentAI; + + /** + * A decrementing tick that spawns a ranged attack once this value reaches 0. It + * is then set back to the maxRangedAttackTime. + */ + private int rangedAttackTime; + + private double entityMoveSpeed; + private int mCooldownTime; + private int field_96561_g; + /** + * The maximum time the AI has to wait before performing another ranged attack. + */ + private int maxRangedAttackTime; + + private float field_96562_i; + private float field_82642_h; // Max range + + public Ranged( + EntityAIBatKingAttack aParent, + double aMovementSpeed, + int someInt, + int aMaxRangedAttackTime, + float someFloat) { + this.rangedAttackTime = -1; + this.parentAI = aParent; + this.entityMoveSpeed = aMovementSpeed; + this.field_96561_g = someInt; + this.maxRangedAttackTime = aMaxRangedAttackTime; + this.field_96562_i = someFloat; + this.field_82642_h = someFloat * someFloat * 8; + parentAI.setMutexBits(3); + } + + /** + * Execute a one shot task or start executing a continuous task + */ + public void startExecuting() { + parentAI.getBatKing().getNavigator().setPath(parentAI.mEntityPathEntity, this.entityMoveSpeed); + } + + /** + * Returns whether an in-progress EntityAIBase should continue executing + */ + public boolean continueExecuting() { + return parentAI.shouldExecute() + || !parentAI.getBatKing().getNavigator().noPath(); + } + + /** + * Resets the task + */ + public void resetTask() { + parentAI.mEntityTarget = null; + this.mCooldownTime = 0; + this.rangedAttackTime = -1; + } + + /** + * Updates the task + */ + public void updateTask() { + + if (MathUtils.randInt(0, 100) == 0) { + maxRangedAttackTime = MathUtils.balance(maxRangedAttackTime, 20, 40); + } + + double d0 = parentAI.getBatKing() + .getDistanceSq( + parentAI.mEntityTarget.posX, + parentAI.mEntityTarget.boundingBox.minY, + parentAI.mEntityTarget.posZ); + boolean flag = parentAI.getBatKing().getEntitySenses().canSee(parentAI.mEntityTarget); + + if (flag) { + ++this.mCooldownTime; + } else { + this.mCooldownTime = 0; + } + + if (d0 <= (double) this.field_82642_h && this.mCooldownTime >= 20) { + parentAI.getBatKing().getNavigator().clearPathEntity(); + } else { + if (parentAI.getBatKing() + .getNavigator() + .tryMoveToEntityLiving(parentAI.mEntityTarget, this.entityMoveSpeed)) { + Logger.INFO("Doing Ranged Ai Task."); + } else { + Logger.INFO("Not Doing Ranged Ai Task."); + } + } + + parentAI.getBatKing().getLookHelper().setLookPositionWithEntity(parentAI.mEntityTarget, 30.0F, 30.0F); + float f; + Logger.INFO("Ranged AI - " + rangedAttackTime); + + if (--this.rangedAttackTime == 0) { + if (d0 > (double) this.field_82642_h || !flag) { + Logger.INFO("Stopping ranged attack. " + flag + "|" + (d0 > (double) this.field_82642_h) + "|" + d0 + + "|" + (double) this.field_82642_h); + return; + } + + f = MathHelper.sqrt_double(d0) / this.field_96562_i; + float f1 = f; + + if (f < 0.1F) { + f1 = 0.1F; + } + + if (f1 > 1.0F) { + f1 = 1.0F; + } + Logger.INFO("Trying to do a ranged attack."); + parentAI.getBatKingAsIRangedAttackMob().attackEntityWithRangedAttack(parentAI.mEntityTarget, f1); + this.rangedAttackTime = MathHelper.floor_float( + f * (float) (this.maxRangedAttackTime - this.field_96561_g) + (float) this.field_96561_g); + } else if (this.rangedAttackTime < 0) { + f = MathHelper.sqrt_double(d0) / this.field_96562_i; + this.rangedAttackTime = MathHelper.floor_float( + f * (float) (this.maxRangedAttackTime - this.field_96561_g) + (float) this.field_96561_g); + } + } + } + + private class Melee { + + private final EntityAIBatKingAttack parentAI; + + /** + * An amount of decrementing ticks that allows the entity to attack once the + * tick reaches 0. + */ + int attackTick; + /** The speed with which the mob will approach the target */ + double speedTowardsTarget; + /** + * When true, the mob will continue chasing its target, even if it can't find a + * path to them right now. + */ + boolean longMemory; + + Class classTarget; + private int field_75445_i; + private double field_151497_i; + private double field_151495_j; + private double field_151496_k; + + private int failedPathFindingPenalty; + + public Melee( + EntityAIBatKingAttack aParent, Class aClassTarget, double aMoveToTargetSpeed, boolean aLongMemory) { + this.parentAI = aParent; + this.classTarget = aClassTarget; + this.speedTowardsTarget = aMoveToTargetSpeed; + this.longMemory = aLongMemory; + parentAI.setMutexBits(3); + } + + /** + * Returns whether the EntityAIBase should begin execution. + */ + public boolean shouldExecute() { + if (!parentAI.hasValidTarget()) { + return false; + } + EntityLivingBase entitylivingbase = parentAI.getTarget(); + + if (entitylivingbase == null) { + return false; + } else if (!entitylivingbase.isEntityAlive()) { + return false; + } else if (this.classTarget != null && !this.classTarget.isAssignableFrom(entitylivingbase.getClass())) { + return false; + } else { + if (--this.field_75445_i <= 0) { + parentAI.mEntityPathEntity = + parentAI.mAttackingEntity.getNavigator().getPathToEntityLiving(entitylivingbase); + this.field_75445_i = 4 + parentAI.mAttackingEntity.getRNG().nextInt(7); + return parentAI.mEntityPathEntity != null; + } else { + return true; + } + } + } + + /** + * Returns whether an in-progress EntityAIBase should continue executing + */ + public boolean continueExecuting() { + EntityLivingBase entitylivingbase = parentAI.mAttackingEntity.getAttackTarget(); + return entitylivingbase == null + ? false + : (!entitylivingbase.isEntityAlive() + ? false + : (!this.longMemory + ? !parentAI.mAttackingEntity.getNavigator().noPath() + : parentAI.mAttackingEntity.isWithinHomeDistance( + MathHelper.floor_double(entitylivingbase.posX), + MathHelper.floor_double(entitylivingbase.posY), + MathHelper.floor_double(entitylivingbase.posZ)))); + } + + /** + * Execute a one shot task or start executing a continuous task + */ + public void startExecuting() { + parentAI.mAttackingEntity.getNavigator().setPath(parentAI.mEntityPathEntity, this.speedTowardsTarget); + this.field_75445_i = 0; + } + + /** + * Resets the task + */ + public void resetTask() { + parentAI.mAttackingEntity.getNavigator().clearPathEntity(); + } + + /** + * Updates the task + */ + public void updateTask() { + EntityLivingBase entitylivingbase = parentAI.mAttackingEntity.getAttackTarget(); + parentAI.mAttackingEntity.getLookHelper().setLookPositionWithEntity(entitylivingbase, 30.0F, 30.0F); + double d0 = parentAI.mAttackingEntity.getDistanceSq( + entitylivingbase.posX, entitylivingbase.boundingBox.minY, entitylivingbase.posZ); + double d1 = (double) (parentAI.mAttackingEntity.width * 2.0F * parentAI.mAttackingEntity.width * 2.0F + + entitylivingbase.width); + --this.field_75445_i; + + if ((this.longMemory || parentAI.mAttackingEntity.getEntitySenses().canSee(entitylivingbase)) + && this.field_75445_i <= 0 + && (this.field_151497_i == 0.0D && this.field_151495_j == 0.0D && this.field_151496_k == 0.0D + || entitylivingbase.getDistanceSq( + this.field_151497_i, this.field_151495_j, this.field_151496_k) + >= 1.0D + || parentAI.mAttackingEntity.getRNG().nextFloat() < 0.05F)) { + this.field_151497_i = entitylivingbase.posX; + this.field_151495_j = entitylivingbase.boundingBox.minY; + this.field_151496_k = entitylivingbase.posZ; + this.field_75445_i = failedPathFindingPenalty + + 4 + + parentAI.mAttackingEntity.getRNG().nextInt(7); + + if (parentAI.mAttackingEntity.getNavigator().getPath() != null) { + PathPoint finalPathPoint = + parentAI.mAttackingEntity.getNavigator().getPath().getFinalPathPoint(); + if (finalPathPoint != null + && entitylivingbase.getDistanceSq( + finalPathPoint.xCoord, finalPathPoint.yCoord, finalPathPoint.zCoord) + < 1) { + failedPathFindingPenalty = 0; + } else { + failedPathFindingPenalty += 10; + } + } else { + failedPathFindingPenalty += 10; + } + + if (d0 > 1024.0D) { + this.field_75445_i += 10; + } else if (d0 > 256.0D) { + this.field_75445_i += 5; + } + + if (!parentAI.mAttackingEntity + .getNavigator() + .tryMoveToEntityLiving(entitylivingbase, this.speedTowardsTarget)) { + this.field_75445_i += 15; + } + } + + this.attackTick = Math.max(this.attackTick - 1, 0); + + if (d0 <= d1 && this.attackTick <= 20) { + this.attackTick = 20; + + if (parentAI.mAttackingEntity.getHeldItem() != null) { + parentAI.mAttackingEntity.swingItem(); + } + + parentAI.mAttackingEntity.attackEntityAsMob(entitylivingbase); + } + } + } +} diff --git a/src/main/java/gtPlusPlus/core/entity/item/ItemEntityGiantEgg.java b/src/main/java/gtPlusPlus/core/entity/item/ItemEntityGiantEgg.java index 8e0b1b48ce..95693d24c9 100644 --- a/src/main/java/gtPlusPlus/core/entity/item/ItemEntityGiantEgg.java +++ b/src/main/java/gtPlusPlus/core/entity/item/ItemEntityGiantEgg.java @@ -1,117 +1,117 @@ package gtPlusPlus.core.entity.item; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.entity.monster.EntityGiantChickenBase; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.NBTUtils; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; public class ItemEntityGiantEgg extends EntityItem { - /** - * The maximum age of this Chicken Egg. The item will try hatch once this is reached. - */ - public int mEggAge = 10000; - public int mEggSize = -1; - - public ItemEntityGiantEgg(World aWorld) { - super(aWorld); - } - - public ItemEntityGiantEgg(World aWorld, double aX, double aY, double aZ) { - super(aWorld, aX, aY, aZ); - } - - public ItemEntityGiantEgg(World aWorld, double aX, double aY, double aZ, ItemStack aStack) { - super(aWorld, aX, aY, aZ, aStack); - } - - private boolean spawnGiantChicken() { - try { - EntityGiantChickenBase entitychicken = new EntityGiantChickenBase(this.worldObj); - entitychicken.setGrowingAge(-MathUtils.randInt(20000, 40000)); - entitychicken.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); - return this.worldObj.spawnEntityInWorld(entitychicken); - } - catch (Throwable t) { - return false; - } - } - - //These eggs also do not combine. - @Override - public boolean combineItems(EntityItem p_70289_1_) { - return false; - } - - @Override - public void writeEntityToNBT(NBTTagCompound aNBT) { - super.writeEntityToNBT(aNBT); - aNBT.setInteger("mEggAge", mEggAge); - aNBT.setInteger("mTicksExisted", this.age); - } - - @Override - public void readEntityFromNBT(NBTTagCompound aNBT) { - super.readEntityFromNBT(aNBT); - mEggAge = aNBT.getInteger("mEggAge"); - } - - //They're fireproof - @Override - public void setFire(int p_70015_1_) { - } - - @Override - public boolean isBurning() { - return false; - } - - @Override - public void onEntityUpdate() { - super.onEntityUpdate(); - Logger.INFO("1"); - //Large eggs don't despawn, because they will try hatch first. - if (this.lifespan != Integer.MAX_VALUE-1) { - this.lifespan = Integer.MAX_VALUE-1; - } - - if (this.getEntityItem() != null) { - ItemStack g = this.getEntityItem(); - NBTUtils.setInteger(g, "mTicksExisted", this.age); - NBTUtils.setInteger(g, "lifespan", this.lifespan); - NBTUtils.setBoolean(g, "playerHeld", false); - this.setEntityItemStack(g); - Logger.INFO("Writing age to NBT of stored stack item."); - } - else { - ItemStack g = ItemUtils.getSimpleStack(ModItems.itemBigEgg); - NBTUtils.setInteger(g, "mTicksExisted", this.age); - NBTUtils.setInteger(g, "lifespan", this.lifespan); - NBTUtils.setBoolean(g, "playerHeld", false); - this.setEntityItemStack(g); - Logger.INFO("Writing age to NBT of new stack item."); - - } - - if (this.age >= 1000) { - //Cache the value for efficiency - if (mEggSize == -1) - mEggSize = (this.getEntityItem() != null ? (this.getEntityItem().hasTagCompound() ? (this.getEntityItem().getTagCompound().hasKey("size") ? this.getEntityItem().getTagCompound().getInteger("size") : 1) : 1) : 1); - if (MathUtils.randInt(100*mEggSize, 1000) >= MathUtils.randInt(950, 1000)) { - //Spawn Chicken - if (spawnGiantChicken()) { - this.kill(); - } - } - } - } - - + /** + * The maximum age of this Chicken Egg. The item will try hatch once this is reached. + */ + public int mEggAge = 10000; + + public int mEggSize = -1; + + public ItemEntityGiantEgg(World aWorld) { + super(aWorld); + } + + public ItemEntityGiantEgg(World aWorld, double aX, double aY, double aZ) { + super(aWorld, aX, aY, aZ); + } + + public ItemEntityGiantEgg(World aWorld, double aX, double aY, double aZ, ItemStack aStack) { + super(aWorld, aX, aY, aZ, aStack); + } + + private boolean spawnGiantChicken() { + try { + EntityGiantChickenBase entitychicken = new EntityGiantChickenBase(this.worldObj); + entitychicken.setGrowingAge(-MathUtils.randInt(20000, 40000)); + entitychicken.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); + return this.worldObj.spawnEntityInWorld(entitychicken); + } catch (Throwable t) { + return false; + } + } + + // These eggs also do not combine. + @Override + public boolean combineItems(EntityItem p_70289_1_) { + return false; + } + + @Override + public void writeEntityToNBT(NBTTagCompound aNBT) { + super.writeEntityToNBT(aNBT); + aNBT.setInteger("mEggAge", mEggAge); + aNBT.setInteger("mTicksExisted", this.age); + } + + @Override + public void readEntityFromNBT(NBTTagCompound aNBT) { + super.readEntityFromNBT(aNBT); + mEggAge = aNBT.getInteger("mEggAge"); + } + + // They're fireproof + @Override + public void setFire(int p_70015_1_) {} + + @Override + public boolean isBurning() { + return false; + } + + @Override + public void onEntityUpdate() { + super.onEntityUpdate(); + Logger.INFO("1"); + // Large eggs don't despawn, because they will try hatch first. + if (this.lifespan != Integer.MAX_VALUE - 1) { + this.lifespan = Integer.MAX_VALUE - 1; + } + + if (this.getEntityItem() != null) { + ItemStack g = this.getEntityItem(); + NBTUtils.setInteger(g, "mTicksExisted", this.age); + NBTUtils.setInteger(g, "lifespan", this.lifespan); + NBTUtils.setBoolean(g, "playerHeld", false); + this.setEntityItemStack(g); + Logger.INFO("Writing age to NBT of stored stack item."); + } else { + ItemStack g = ItemUtils.getSimpleStack(ModItems.itemBigEgg); + NBTUtils.setInteger(g, "mTicksExisted", this.age); + NBTUtils.setInteger(g, "lifespan", this.lifespan); + NBTUtils.setBoolean(g, "playerHeld", false); + this.setEntityItemStack(g); + Logger.INFO("Writing age to NBT of new stack item."); + } + + if (this.age >= 1000) { + // Cache the value for efficiency + if (mEggSize == -1) + mEggSize = (this.getEntityItem() != null + ? (this.getEntityItem().hasTagCompound() + ? (this.getEntityItem().getTagCompound().hasKey("size") + ? this.getEntityItem().getTagCompound().getInteger("size") + : 1) + : 1) + : 1); + if (MathUtils.randInt(100 * mEggSize, 1000) >= MathUtils.randInt(950, 1000)) { + // Spawn Chicken + if (spawnGiantChicken()) { + this.kill(); + } + } + } + } } diff --git a/src/main/java/gtPlusPlus/core/entity/monster/EntityBatKing.java b/src/main/java/gtPlusPlus/core/entity/monster/EntityBatKing.java index 55e0f4c571..0a35d550a4 100644 --- a/src/main/java/gtPlusPlus/core/entity/monster/EntityBatKing.java +++ b/src/main/java/gtPlusPlus/core/entity/monster/EntityBatKing.java @@ -1,7 +1,5 @@ package gtPlusPlus.core.entity.monster; -import java.lang.reflect.Field; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.entity.ai.batking.EntityAIBatKingAttack; @@ -9,6 +7,7 @@ import gtPlusPlus.core.entity.projectile.EntityThrowableBomb; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.EntityUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import java.lang.reflect.Field; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EnumCreatureAttribute; @@ -36,677 +35,684 @@ import net.minecraft.world.World; public class EntityBatKing extends EntityMob implements IRangedAttackMob { - public int courseChangeCooldown; - public double waypointX; - public double waypointY; - public double waypointZ; - private Entity targetedEntity; - private int aggroCooldown; - public int prevAttackCounter; - public int attackCounter; - private int explosionStrength = 1; - - private EntityAIBatKingAttack aiAttack = new EntityAIBatKingAttack(this, null, 1.0D, 20, 60, 15.0F, true); - private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.2D, - false); - - public EntityBatKing(World p_i1680_1_) { - super(p_i1680_1_); - this.setSize(2.5F, 1.5F); - - this.setIsBatHanging(false); - this.isImmuneToFire = true; - this.experienceValue = 1000; - - this.tasks.addTask(3, this.aiAttack); - //this.tasks.addTask(4, this.aiAttackOnCollide); - //this.tasks.addTask(4, new EntityAIRestrictSun(this)); - //this.tasks.addTask(5, new EntityAIFleeSun(this, 1.0D)); - this.tasks.addTask(4, new EntityAIWander(this, 1.0D)); - //this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); - //this.tasks.addTask(6, new EntityAILookIdle(this)); - - this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true)); - //this.targetTasks.addTask(2, this.aiAttack); - this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true)); - this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityBat.class, 0, false)); - - } - - protected void entityInit() { - super.entityInit(); - } - - /** - * Get this Entity's EnumCreatureAttribute - */ - public EnumCreatureAttribute getCreatureAttribute() { - return EnumCreatureAttribute.UNDEAD; - } - - /** - * Gets the pitch of living sounds in living entities. - */ - protected float getSoundPitch() { - return super.getSoundPitch() * 0.15F; - } - - /** - * Returns the sound this mob makes while it's alive. - */ - protected String getLivingSound() { - int aRand = MathUtils.randInt(0, 10); - if (aRand < 6) { - return null; - } else if (aRand <= 8) { - return "mob.bat.idle"; - } else { - return "mob.blaze.breathe"; - } - } - - /** - * Returns the sound this mob makes when it is hurt. - */ - protected String getHurtSound() { - return "mob.blaze.hit"; - } - - /** - * Returns the sound this mob makes on death. - */ - protected String getDeathSound() { - return "mob.bat.death"; - } - - /** - * Returns true if this entity should push and be pushed by other entities when - * colliding. - */ - public boolean canBePushed() { - return true; - } - - protected void collideWithEntity(Entity aEntity) { - if (aEntity != null) { - if (aEntity instanceof EntityPlayer) { - EntityUtils.doDamage(aEntity, DamageSource.magic, (int) (((EntityPlayer) aEntity).getHealth() / 20)); - } - } - } - - protected void collideWithNearbyEntities() { - } - - protected void applyEntityAttributes() { - - this.getAttributeMap().registerAttribute(SharedMonsterAttributes.maxHealth); - this.getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage); - this.getAttributeMap().registerAttribute(SharedMonsterAttributes.knockbackResistance); - this.getAttributeMap().registerAttribute(SharedMonsterAttributes.movementSpeed); - this.getAttributeMap().registerAttribute(SharedMonsterAttributes.followRange); - - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(250.0D); - this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(6.0D); - this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(1D); - this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(120.0D); - } - - public boolean getIsBatHanging() { - return false; - } - - public void setIsBatHanging(boolean p_82236_1_) { - generateParticles(this); - generateParticles(this); - generateParticles(this); - for (int i = 0; i < 32; ++i) { - // - String particleName = "lava"; - if (MathUtils.randInt(0, 3) <= 2) { - particleName = "crit"; - } - this.worldObj.spawnParticle(particleName, - this.posX + (this.rand.nextDouble() - 0.5D) * (double) this.width, - this.posY + this.rand.nextDouble() * (double) this.height, - this.posZ + (this.rand.nextDouble() - 0.5D) * (double) this.width, 0.0D, 0.0D, 0.0D); - } - - } - - /** - * Returns true if the newer Entity AI code should be run - */ - protected boolean isAIEnabled() { - return true; - } - - /** - * Called to update the entity's position/logic. - */ - public void onUpdate() { - super.onUpdate(); - generateParticles(this); - - if (!this.worldObj.isRemote && (this.targetedEntity == null || this.aggroCooldown-- <= 0)) { - this.targetedEntity = this.worldObj.getClosestVulnerablePlayerToEntity(this, 100.0D); - - if (this.targetedEntity != null) { - this.aggroCooldown = 30; - if (aiAttack.hasValidTarget()) { - this.setAttackTarget(aiAttack.getTarget()); - } - else { - Logger.INFO("No valid target."); - if (ReflectionUtils.doesFieldExist(aiAttack.getClass(), "mEntityTarget")) { - Logger.INFO("Found field."); - } - else { - Logger.INFO("Did not find field."); - } - Field target = ReflectionUtils.getField(EntityAIBatKingAttack.class, "mEntityTarget"); - if (target != null) { - ReflectionUtils.setField(aiAttack, target, this.targetedEntity); - Logger.INFO("Set target."); - } - else { - Logger.INFO("Could not set via reflection."); - } - - - } - } - else { - Vec3 vec3 = RandomPositionGenerator.findRandomTarget(this, 32, 20); - if (vec3 != null) { - double xPosition = vec3.xCoord; - double yPosition = vec3.yCoord; - double zPosition = vec3.zCoord; - this.getNavigator().tryMoveToXYZ(xPosition, yPosition, zPosition, 3); - } - } - } - - } - - private static void generateParticles(EntityBatKing aKing) { - for (int i = 0; i < 20; ++i) { - // - if (MathUtils.randInt(0, 50) <= 1) { - String particleName = "smoke"; - if (MathUtils.randInt(0, 3) <= 2) { - particleName = "largesmoke"; - } - aKing.worldObj.spawnParticle(particleName, - aKing.posX + (aKing.rand.nextDouble() - 0.5D) * (double) aKing.width, - aKing.posY + aKing.rand.nextDouble() * (double) aKing.height, - aKing.posZ + (aKing.rand.nextDouble() - 0.5D) * (double) aKing.width, 0.0D, 0.0D, 0.0D); - } - if (MathUtils.randInt(0, 100) <= 1) { - String particleName = "smoke"; - int test2 = MathUtils.randInt(0, 3); - if (test2 == 2) { - particleName = "dripLava"; - } else if (test2 == 3) { - particleName = "portal"; - } - aKing.worldObj.spawnParticle(particleName, - aKing.posX + (aKing.rand.nextDouble() - 0.5D) * (double) aKing.width, - aKing.posY + aKing.rand.nextDouble() * (double) aKing.height, - aKing.posZ + (aKing.rand.nextDouble() - 0.5D) * (double) aKing.width, 0.0D, 0.0D, 0.0D); - } - } - } - - protected void updateAITasks() { - super.updateAITasks(); - } - - private boolean isFlying() { - if (this.onGround) { - return false; - } - return true; - } - - private boolean hasAir() { - BlockPos p = EntityUtils.findBlockPosUnderEntity(this); - int y = p.yPos; - int yOriginal = p.yPos; - - for (int u = 0; u<5;u++) { - if (u > 50 || y <= 0) { - break; - } - if (!this.worldObj.isAirBlock(p.xPos, y, p.zPos)) { - break; - } - y--; - } - if (yOriginal != y) { - for (int i = 0; i < y; y++) { - this.jump(); - } - return true; - } - return false; - } - - /** - * returns if this entity triggers Block.onEntityWalking on the blocks they walk - * on. used for spiders and wolves to prevent them from trampling crops - */ - protected boolean canTriggerWalking() { - return false; - } - - /** - * Return whether this entity should NOT trigger a pressure plate or a tripwire. - */ - public boolean doesEntityNotTriggerPressurePlate() { - return true; - } - - /** - * Called when the entity is attacked. - */ - public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_) { - if (this.isEntityInvulnerable()) { - return false; - } else { - if (!this.worldObj.isRemote && this.getIsBatHanging()) { - this.setIsBatHanging(false); - } - - return super.attackEntityFrom(p_70097_1_, p_70097_2_); - } - } - - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - public void readEntityFromNBT(NBTTagCompound p_70037_1_) { - super.readEntityFromNBT(p_70037_1_); - if (p_70037_1_.hasKey("ExplosionPower", 99)) { - this.explosionStrength = p_70037_1_.getInteger("ExplosionPower"); - } - } - - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ - public void writeEntityToNBT(NBTTagCompound p_70014_1_) { - super.writeEntityToNBT(p_70014_1_); - p_70014_1_.setInteger("ExplosionPower", this.explosionStrength); - } - - /** - * Attack the specified entity using a ranged attack. - */ - @Override - public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_) { - Logger.INFO("Trying to do ranged attack 1 |"+(this.targetedEntity != null)+"|"); - - if (!this.isFlying() || !this.isAirBorne) { - //this.hasAir(); - /* - * for (int i=0;i<3;i++) { this.jump(); } - */ - } - - - double d4 = 64.0D; - if (this.targetedEntity != null && this.targetedEntity.getDistanceSqToEntity(this) < d4 * d4 * 8) { - Logger.INFO("Trying to do ranged attack 2"); - double d5 = this.targetedEntity.posX - this.posX; - double d6 = this.targetedEntity.boundingBox.minY + (double) (this.targetedEntity.height / 2.0F) - - (this.posY + (double) (this.height / 2.0F)); - double d7 = this.targetedEntity.posZ - this.posZ; - this.renderYawOffset = this.rotationYaw = -((float) Math.atan2(d5, d7)) * 180.0F / (float) Math.PI; - - ++this.attackCounter; - - if (this.canEntityBeSeen(this.targetedEntity)) { - Logger.INFO("Trying to do ranged attack 3a | "+attackCounter); - - - if (this.attackCounter >= 2) { - Logger.INFO("Trying to do ranged attack 3a1"); - - this.worldObj.playAuxSFXAtEntity((EntityPlayer) null, 1008, (int) this.posX, (int) this.posY, - (int) this.posZ, 0); - setIsBatHanging(true); - - EntityThrowableBomb entitylargefireball = new EntityThrowableBomb(this.worldObj, this/*d5, d6, d7*/); - //entitylargefireball.field_92057_e = this.explosionStrength; - //entitylargefireball.accelerationX *= 2; - //entitylargefireball.accelerationY *= 2; - //entitylargefireball.accelerationZ *= 2; - double d8 = 4.0D; - Vec3 vec3 = this.getLook(1.0F); - entitylargefireball.posX = this.posX + vec3.xCoord * d8; - entitylargefireball.posY = this.posY + (double) (this.height / 2.0F) + 0.5D; - entitylargefireball.posZ = this.posZ + vec3.zCoord * d8; - this.worldObj.spawnEntityInWorld(entitylargefireball); - - for (int u=0; u 0) { - Logger.INFO("Trying to do ranged attack 5a"); - --this.attackCounter; - EntityArrow entityarrow = new EntityArrow(this.worldObj, this, p_82196_1_, MathUtils.randFloat(1f, 3f), - (float) (14 - this.worldObj.difficultySetting.getDifficultyId() * 4)); - int i = MathUtils.randInt(0, 4); - int j = MathUtils.randInt(0, 3); - int k = MathUtils.randInt(0, 3); - entityarrow.setDamage((double) (p_82196_2_ * 2.0F) + this.rand.nextGaussian() * 0.25D - + (double) ((float) this.worldObj.difficultySetting.getDifficultyId() * 0.11F)); - - boolean boostAttack = MathUtils.randInt(0, 100) <= 21; - if (boostAttack) { - if (i > 0) { - entityarrow.setDamage(entityarrow.getDamage() + (double) i * 0.5D + 0.5D); - } - - if (j > 0) { - entityarrow.setKnockbackStrength(j); - } - if (k > 0) { - entityarrow.setFire(50 * k); - } - } - - this.playSound("mob.skeleton.say", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); - this.worldObj.spawnEntityInWorld(entityarrow); - Logger.INFO("Trying to do ranged attack 5a done"); - } - } - - - - - this.attackCounter = 0; - } - } else if (this.attackCounter > 0) { - Logger.INFO("Trying to do ranged attack 3b"); - --this.attackCounter; - } - } else { - Logger.INFO("Trying to do ranged attack 4a"); - this.renderYawOffset = this.rotationYaw = -((float) Math.atan2(this.motionX, this.motionZ)) * 180.0F - / (float) Math.PI; - - if (this.attackCounter > 0) { - Logger.INFO("Trying to do ranged attack 5a"); - --this.attackCounter; - EntityArrow entityarrow = new EntityArrow(this.worldObj, this, p_82196_1_, 1.6F, - (float) (14 - this.worldObj.difficultySetting.getDifficultyId() * 4)); - int i = MathUtils.randInt(0, 4); - int j = MathUtils.randInt(0, 3); - int k = MathUtils.randInt(0, 3); - entityarrow.setDamage((double) (p_82196_2_ * 2.0F) + this.rand.nextGaussian() * 0.25D - + (double) ((float) this.worldObj.difficultySetting.getDifficultyId() * 0.11F)); - - boolean boostAttack = MathUtils.randInt(0, 100) <= 21; - if (boostAttack) { - if (i > 0) { - entityarrow.setDamage(entityarrow.getDamage() + (double) i * 0.5D + 0.5D); - } - - if (j > 0) { - entityarrow.setKnockbackStrength(j); - } - if (k > 0) { - entityarrow.setFire(50 * k); - } - } - - this.playSound("mob.skeleton.say", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); - this.worldObj.spawnEntityInWorld(entityarrow); - Logger.INFO("Trying to do ranged attack 5a done"); - } - - } - - } - - /** - * Returns the volume for the sounds this mob makes. - */ - protected float getSoundVolume() { - return 10.0F; - } - - /** - * Checks if the entity's current position is a valid location to spawn this - * entity. - */ - public boolean getCanSpawnHere() { - return super.getCanSpawnHere() && this.worldObj.difficultySetting != EnumDifficulty.PEACEFUL; - } - - /** - * Will return how many at most can spawn in a chunk at once. - */ - public int getMaxSpawnedInChunk() { - return 1; - } - - protected Item getDropItem() { - return Items.gunpowder; - } - - /** - * Drop 0-2 items of this living's type. @param par1 - Whether this entity has - * recently been hit by a player. @param par2 - Level of Looting used to kill - * this mob. - */ - protected void dropFewItems(boolean p_70628_1_, int p_70628_2_) { - int j = this.rand.nextInt(2) + this.rand.nextInt(1 + p_70628_2_); - int k; - - for (k = 0; k < j; ++k) { - this.dropItem(Items.ghast_tear, 1); - } - - j = this.rand.nextInt(3) + this.rand.nextInt(1 + p_70628_2_); - - for (k = 0; k < j; ++k) { - this.dropItem(Items.gunpowder, 1); - } - } - - @Override - protected void updateEntityActionState() { - if (!this.worldObj.isRemote && this.worldObj.difficultySetting == EnumDifficulty.PEACEFUL) { - this.setDead(); - } - - this.despawnEntity(); - this.prevAttackCounter = this.attackCounter; - double d0 = this.waypointX - this.posX; - double d1 = this.waypointY - this.posY; - double d2 = this.waypointZ - this.posZ; - double d3 = d0 * d0 + d1 * d1 + d2 * d2; - - if (d3 < 1.0D || d3 > 3600.0D) { - this.waypointX = this.posX + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F); - this.waypointY = this.posY + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F); - this.waypointZ = this.posZ + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F); - } - - if (this.courseChangeCooldown-- <= 0) { - this.courseChangeCooldown += this.rand.nextInt(5) + 2; - d3 = (double) MathHelper.sqrt_double(d3); - - if (this.isCourseTraversable(this.waypointX, this.waypointY, this.waypointZ, d3)) { - this.motionX += d0 / d3 * 0.1D; - this.motionY += d1 / d3 * 0.1D; - this.motionZ += d2 / d3 * 0.1D; - } else { - this.waypointX = this.posX; - this.waypointY = this.posY; - this.waypointZ = this.posZ; - } - } - - if (this.targetedEntity != null && this.targetedEntity.isDead) { - this.targetedEntity = null; - } - - if (this.targetedEntity == null || this.aggroCooldown-- <= 0) { - this.targetedEntity = this.worldObj.getClosestVulnerablePlayerToEntity(this, 100.0D); - - if (this.targetedEntity != null) { - this.aggroCooldown = 20; - } - } - - double d4 = 64.0D; - - if (this.targetedEntity != null && this.targetedEntity.getDistanceSqToEntity(this) < d4 * d4) { - double d5 = this.targetedEntity.posX - this.posX; - double d6 = this.targetedEntity.boundingBox.minY + (double) (this.targetedEntity.height / 2.0F) - - (this.posY + (double) (this.height / 2.0F)); - double d7 = this.targetedEntity.posZ - this.posZ; - this.renderYawOffset = this.rotationYaw = -((float) Math.atan2(d5, d7)) * 180.0F / (float) Math.PI; - - if (this.canEntityBeSeen(this.targetedEntity)) { - if (this.attackCounter == 10) { - this.worldObj.playAuxSFXAtEntity((EntityPlayer) null, 1007, (int) this.posX, (int) this.posY, - (int) this.posZ, 0); - } - - ++this.attackCounter; - - if (this.attackCounter == 20) { - this.worldObj.playAuxSFXAtEntity((EntityPlayer) null, 1008, (int) this.posX, (int) this.posY, - (int) this.posZ, 0); - EntityLargeFireball entitylargefireball = new EntityLargeFireball(this.worldObj, this, d5, d6, d7); - entitylargefireball.field_92057_e = this.explosionStrength; - double d8 = 4.0D; - Vec3 vec3 = this.getLook(1.0F); - entitylargefireball.posX = this.posX + vec3.xCoord * d8; - entitylargefireball.posY = this.posY + (double) (this.height / 2.0F) + 0.5D; - entitylargefireball.posZ = this.posZ + vec3.zCoord * d8; - this.worldObj.spawnEntityInWorld(entitylargefireball); - this.attackCounter = -40; - } - } else if (this.attackCounter > 0) { - --this.attackCounter; - } - } else { - this.renderYawOffset = this.rotationYaw = -((float) Math.atan2(this.motionX, this.motionZ)) * 180.0F - / (float) Math.PI; - - if (this.attackCounter > 0) { - --this.attackCounter; - } - } - - if (!this.worldObj.isRemote) { - byte b1 = this.dataWatcher.getWatchableObjectByte(16); - byte b0 = (byte) (this.attackCounter > 10 ? 1 : 0); - - if (b1 != b0) { - this.dataWatcher.updateObject(16, Byte.valueOf(b0)); - } - } - } - - /** - * True if the ghast has an unobstructed line of travel to the waypoint. - */ - private boolean isCourseTraversable(double p_70790_1_, double p_70790_3_, double p_70790_5_, double p_70790_7_) { - double d4 = (this.waypointX - this.posX) / p_70790_7_; - double d5 = (this.waypointY - this.posY) / p_70790_7_; - double d6 = (this.waypointZ - this.posZ) / p_70790_7_; - AxisAlignedBB axisalignedbb = this.boundingBox.copy(); - - for (int i = 1; (double) i < p_70790_7_; ++i) { - axisalignedbb.offset(d4, d5, d6); - - /* - * if (!this.worldObj.getCollidingBoundingBoxes(this, axisalignedbb).isEmpty()) - * { return false; } - */ - } - - return true; - } - - /** - * Called when the mob is falling. Calculates and applies fall damage. - */ - protected void fall(float p_70069_1_) { - } - - /** - * Takes in the distance the entity has fallen this tick and whether its on the - * ground to update the fall distance and deal fall damage if landing on the - * ground. Args: distanceFallenThisTick, onGround - */ - protected void updateFallState(double p_70064_1_, boolean p_70064_3_) { - } - - /** - * Moves the entity based on the specified heading. Args: strafe, forward - */ - public void moveEntityWithHeading(float p_70612_1_, float p_70612_2_) { - if (this.isInWater()) { - this.moveFlying(p_70612_1_, p_70612_2_, 0.02F); - this.moveEntity(this.motionX, this.motionY, this.motionZ); - this.motionX *= 0.800000011920929D; - this.motionY *= 0.800000011920929D; - this.motionZ *= 0.800000011920929D; - } else if (this.handleLavaMovement()) { - this.moveFlying(p_70612_1_, p_70612_2_, 0.02F); - this.moveEntity(this.motionX, this.motionY, this.motionZ); - this.motionX *= 0.5D; - this.motionY *= 0.5D; - this.motionZ *= 0.5D; - } else { - float f2 = 0.91F; - - if (this.onGround) { - f2 = this.worldObj.getBlock(MathHelper.floor_double(this.posX), - MathHelper.floor_double(this.boundingBox.minY) - 1, - MathHelper.floor_double(this.posZ)).slipperiness * 0.91F; - } - - float f3 = 0.16277136F / (f2 * f2 * f2); - this.moveFlying(p_70612_1_, p_70612_2_, this.onGround ? 0.1F * f3 : 0.02F); - f2 = 0.91F; - - if (this.onGround) { - f2 = this.worldObj.getBlock(MathHelper.floor_double(this.posX), - MathHelper.floor_double(this.boundingBox.minY) - 1, - MathHelper.floor_double(this.posZ)).slipperiness * 0.91F; - } - - this.moveEntity(this.motionX, this.motionY, this.motionZ); - this.motionX *= (double) f2; - this.motionY *= (double) f2; - this.motionZ *= (double) f2; - } - - this.prevLimbSwingAmount = this.limbSwingAmount; - double d1 = this.posX - this.prevPosX; - double d0 = this.posZ - this.prevPosZ; - float f4 = MathHelper.sqrt_double(d1 * d1 + d0 * d0) * 4.0F; - - if (f4 > 1.0F) { - f4 = 1.0F; - } - - this.limbSwingAmount += (f4 - this.limbSwingAmount) * 0.4F; - this.limbSwing += this.limbSwingAmount; - } - - /** - * returns true if this entity is by a ladder, false otherwise - */ - public boolean isOnLadder() { - return false; - } - -} \ No newline at end of file + public int courseChangeCooldown; + public double waypointX; + public double waypointY; + public double waypointZ; + private Entity targetedEntity; + private int aggroCooldown; + public int prevAttackCounter; + public int attackCounter; + private int explosionStrength = 1; + + private EntityAIBatKingAttack aiAttack = new EntityAIBatKingAttack(this, null, 1.0D, 20, 60, 15.0F, true); + private EntityAIAttackOnCollide aiAttackOnCollide = + new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.2D, false); + + public EntityBatKing(World p_i1680_1_) { + super(p_i1680_1_); + this.setSize(2.5F, 1.5F); + + this.setIsBatHanging(false); + this.isImmuneToFire = true; + this.experienceValue = 1000; + + this.tasks.addTask(3, this.aiAttack); + // this.tasks.addTask(4, this.aiAttackOnCollide); + // this.tasks.addTask(4, new EntityAIRestrictSun(this)); + // this.tasks.addTask(5, new EntityAIFleeSun(this, 1.0D)); + this.tasks.addTask(4, new EntityAIWander(this, 1.0D)); + // this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); + // this.tasks.addTask(6, new EntityAILookIdle(this)); + + this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true)); + // this.targetTasks.addTask(2, this.aiAttack); + this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true)); + this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityBat.class, 0, false)); + } + + protected void entityInit() { + super.entityInit(); + } + + /** + * Get this Entity's EnumCreatureAttribute + */ + public EnumCreatureAttribute getCreatureAttribute() { + return EnumCreatureAttribute.UNDEAD; + } + + /** + * Gets the pitch of living sounds in living entities. + */ + protected float getSoundPitch() { + return super.getSoundPitch() * 0.15F; + } + + /** + * Returns the sound this mob makes while it's alive. + */ + protected String getLivingSound() { + int aRand = MathUtils.randInt(0, 10); + if (aRand < 6) { + return null; + } else if (aRand <= 8) { + return "mob.bat.idle"; + } else { + return "mob.blaze.breathe"; + } + } + + /** + * Returns the sound this mob makes when it is hurt. + */ + protected String getHurtSound() { + return "mob.blaze.hit"; + } + + /** + * Returns the sound this mob makes on death. + */ + protected String getDeathSound() { + return "mob.bat.death"; + } + + /** + * Returns true if this entity should push and be pushed by other entities when + * colliding. + */ + public boolean canBePushed() { + return true; + } + + protected void collideWithEntity(Entity aEntity) { + if (aEntity != null) { + if (aEntity instanceof EntityPlayer) { + EntityUtils.doDamage(aEntity, DamageSource.magic, (int) (((EntityPlayer) aEntity).getHealth() / 20)); + } + } + } + + protected void collideWithNearbyEntities() {} + + protected void applyEntityAttributes() { + + this.getAttributeMap().registerAttribute(SharedMonsterAttributes.maxHealth); + this.getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage); + this.getAttributeMap().registerAttribute(SharedMonsterAttributes.knockbackResistance); + this.getAttributeMap().registerAttribute(SharedMonsterAttributes.movementSpeed); + this.getAttributeMap().registerAttribute(SharedMonsterAttributes.followRange); + + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(250.0D); + this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(6.0D); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(1D); + this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(120.0D); + } + + public boolean getIsBatHanging() { + return false; + } + + public void setIsBatHanging(boolean p_82236_1_) { + generateParticles(this); + generateParticles(this); + generateParticles(this); + for (int i = 0; i < 32; ++i) { + // + String particleName = "lava"; + if (MathUtils.randInt(0, 3) <= 2) { + particleName = "crit"; + } + this.worldObj.spawnParticle( + particleName, + this.posX + (this.rand.nextDouble() - 0.5D) * (double) this.width, + this.posY + this.rand.nextDouble() * (double) this.height, + this.posZ + (this.rand.nextDouble() - 0.5D) * (double) this.width, + 0.0D, + 0.0D, + 0.0D); + } + } + + /** + * Returns true if the newer Entity AI code should be run + */ + protected boolean isAIEnabled() { + return true; + } + + /** + * Called to update the entity's position/logic. + */ + public void onUpdate() { + super.onUpdate(); + generateParticles(this); + + if (!this.worldObj.isRemote && (this.targetedEntity == null || this.aggroCooldown-- <= 0)) { + this.targetedEntity = this.worldObj.getClosestVulnerablePlayerToEntity(this, 100.0D); + + if (this.targetedEntity != null) { + this.aggroCooldown = 30; + if (aiAttack.hasValidTarget()) { + this.setAttackTarget(aiAttack.getTarget()); + } else { + Logger.INFO("No valid target."); + if (ReflectionUtils.doesFieldExist(aiAttack.getClass(), "mEntityTarget")) { + Logger.INFO("Found field."); + } else { + Logger.INFO("Did not find field."); + } + Field target = ReflectionUtils.getField(EntityAIBatKingAttack.class, "mEntityTarget"); + if (target != null) { + ReflectionUtils.setField(aiAttack, target, this.targetedEntity); + Logger.INFO("Set target."); + } else { + Logger.INFO("Could not set via reflection."); + } + } + } else { + Vec3 vec3 = RandomPositionGenerator.findRandomTarget(this, 32, 20); + if (vec3 != null) { + double xPosition = vec3.xCoord; + double yPosition = vec3.yCoord; + double zPosition = vec3.zCoord; + this.getNavigator().tryMoveToXYZ(xPosition, yPosition, zPosition, 3); + } + } + } + } + + private static void generateParticles(EntityBatKing aKing) { + for (int i = 0; i < 20; ++i) { + // + if (MathUtils.randInt(0, 50) <= 1) { + String particleName = "smoke"; + if (MathUtils.randInt(0, 3) <= 2) { + particleName = "largesmoke"; + } + aKing.worldObj.spawnParticle( + particleName, + aKing.posX + (aKing.rand.nextDouble() - 0.5D) * (double) aKing.width, + aKing.posY + aKing.rand.nextDouble() * (double) aKing.height, + aKing.posZ + (aKing.rand.nextDouble() - 0.5D) * (double) aKing.width, + 0.0D, + 0.0D, + 0.0D); + } + if (MathUtils.randInt(0, 100) <= 1) { + String particleName = "smoke"; + int test2 = MathUtils.randInt(0, 3); + if (test2 == 2) { + particleName = "dripLava"; + } else if (test2 == 3) { + particleName = "portal"; + } + aKing.worldObj.spawnParticle( + particleName, + aKing.posX + (aKing.rand.nextDouble() - 0.5D) * (double) aKing.width, + aKing.posY + aKing.rand.nextDouble() * (double) aKing.height, + aKing.posZ + (aKing.rand.nextDouble() - 0.5D) * (double) aKing.width, + 0.0D, + 0.0D, + 0.0D); + } + } + } + + protected void updateAITasks() { + super.updateAITasks(); + } + + private boolean isFlying() { + if (this.onGround) { + return false; + } + return true; + } + + private boolean hasAir() { + BlockPos p = EntityUtils.findBlockPosUnderEntity(this); + int y = p.yPos; + int yOriginal = p.yPos; + + for (int u = 0; u < 5; u++) { + if (u > 50 || y <= 0) { + break; + } + if (!this.worldObj.isAirBlock(p.xPos, y, p.zPos)) { + break; + } + y--; + } + if (yOriginal != y) { + for (int i = 0; i < y; y++) { + this.jump(); + } + return true; + } + return false; + } + + /** + * returns if this entity triggers Block.onEntityWalking on the blocks they walk + * on. used for spiders and wolves to prevent them from trampling crops + */ + protected boolean canTriggerWalking() { + return false; + } + + /** + * Return whether this entity should NOT trigger a pressure plate or a tripwire. + */ + public boolean doesEntityNotTriggerPressurePlate() { + return true; + } + + /** + * Called when the entity is attacked. + */ + public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_) { + if (this.isEntityInvulnerable()) { + return false; + } else { + if (!this.worldObj.isRemote && this.getIsBatHanging()) { + this.setIsBatHanging(false); + } + + return super.attackEntityFrom(p_70097_1_, p_70097_2_); + } + } + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + public void readEntityFromNBT(NBTTagCompound p_70037_1_) { + super.readEntityFromNBT(p_70037_1_); + if (p_70037_1_.hasKey("ExplosionPower", 99)) { + this.explosionStrength = p_70037_1_.getInteger("ExplosionPower"); + } + } + + /** + * (abstract) Protected helper method to write subclass entity data to NBT. + */ + public void writeEntityToNBT(NBTTagCompound p_70014_1_) { + super.writeEntityToNBT(p_70014_1_); + p_70014_1_.setInteger("ExplosionPower", this.explosionStrength); + } + + /** + * Attack the specified entity using a ranged attack. + */ + @Override + public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_) { + Logger.INFO("Trying to do ranged attack 1 |" + (this.targetedEntity != null) + "|"); + + if (!this.isFlying() || !this.isAirBorne) { + // this.hasAir(); + /* + * for (int i=0;i<3;i++) { this.jump(); } + */ + } + + double d4 = 64.0D; + if (this.targetedEntity != null && this.targetedEntity.getDistanceSqToEntity(this) < d4 * d4 * 8) { + Logger.INFO("Trying to do ranged attack 2"); + double d5 = this.targetedEntity.posX - this.posX; + double d6 = this.targetedEntity.boundingBox.minY + + (double) (this.targetedEntity.height / 2.0F) + - (this.posY + (double) (this.height / 2.0F)); + double d7 = this.targetedEntity.posZ - this.posZ; + this.renderYawOffset = this.rotationYaw = -((float) Math.atan2(d5, d7)) * 180.0F / (float) Math.PI; + + ++this.attackCounter; + + if (this.canEntityBeSeen(this.targetedEntity)) { + Logger.INFO("Trying to do ranged attack 3a | " + attackCounter); + + if (this.attackCounter >= 2) { + Logger.INFO("Trying to do ranged attack 3a1"); + + this.worldObj.playAuxSFXAtEntity( + (EntityPlayer) null, 1008, (int) this.posX, (int) this.posY, (int) this.posZ, 0); + setIsBatHanging(true); + + EntityThrowableBomb entitylargefireball = + new EntityThrowableBomb(this.worldObj, this /*d5, d6, d7*/); + // entitylargefireball.field_92057_e = this.explosionStrength; + // entitylargefireball.accelerationX *= 2; + // entitylargefireball.accelerationY *= 2; + // entitylargefireball.accelerationZ *= 2; + double d8 = 4.0D; + Vec3 vec3 = this.getLook(1.0F); + entitylargefireball.posX = this.posX + vec3.xCoord * d8; + entitylargefireball.posY = this.posY + (double) (this.height / 2.0F) + 0.5D; + entitylargefireball.posZ = this.posZ + vec3.zCoord * d8; + this.worldObj.spawnEntityInWorld(entitylargefireball); + + for (int u = 0; u < MathUtils.randInt(2, 10); u++) { + if (this.attackCounter > 0) { + Logger.INFO("Trying to do ranged attack 5a"); + --this.attackCounter; + EntityArrow entityarrow = new EntityArrow( + this.worldObj, this, p_82196_1_, MathUtils.randFloat(1f, 3f), (float) + (14 - this.worldObj.difficultySetting.getDifficultyId() * 4)); + int i = MathUtils.randInt(0, 4); + int j = MathUtils.randInt(0, 3); + int k = MathUtils.randInt(0, 3); + entityarrow.setDamage((double) (p_82196_2_ * 2.0F) + + this.rand.nextGaussian() * 0.25D + + (double) ((float) this.worldObj.difficultySetting.getDifficultyId() * 0.11F)); + + boolean boostAttack = MathUtils.randInt(0, 100) <= 21; + if (boostAttack) { + if (i > 0) { + entityarrow.setDamage(entityarrow.getDamage() + (double) i * 0.5D + 0.5D); + } + + if (j > 0) { + entityarrow.setKnockbackStrength(j); + } + if (k > 0) { + entityarrow.setFire(50 * k); + } + } + + this.playSound( + "mob.skeleton.say", + 1.0F, + 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); + this.worldObj.spawnEntityInWorld(entityarrow); + Logger.INFO("Trying to do ranged attack 5a done"); + } + } + + this.attackCounter = 0; + } + } else if (this.attackCounter > 0) { + Logger.INFO("Trying to do ranged attack 3b"); + --this.attackCounter; + } + } else { + Logger.INFO("Trying to do ranged attack 4a"); + this.renderYawOffset = + this.rotationYaw = -((float) Math.atan2(this.motionX, this.motionZ)) * 180.0F / (float) Math.PI; + + if (this.attackCounter > 0) { + Logger.INFO("Trying to do ranged attack 5a"); + --this.attackCounter; + EntityArrow entityarrow = new EntityArrow(this.worldObj, this, p_82196_1_, 1.6F, (float) + (14 - this.worldObj.difficultySetting.getDifficultyId() * 4)); + int i = MathUtils.randInt(0, 4); + int j = MathUtils.randInt(0, 3); + int k = MathUtils.randInt(0, 3); + entityarrow.setDamage((double) (p_82196_2_ * 2.0F) + + this.rand.nextGaussian() * 0.25D + + (double) ((float) this.worldObj.difficultySetting.getDifficultyId() * 0.11F)); + + boolean boostAttack = MathUtils.randInt(0, 100) <= 21; + if (boostAttack) { + if (i > 0) { + entityarrow.setDamage(entityarrow.getDamage() + (double) i * 0.5D + 0.5D); + } + + if (j > 0) { + entityarrow.setKnockbackStrength(j); + } + if (k > 0) { + entityarrow.setFire(50 * k); + } + } + + this.playSound("mob.skeleton.say", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); + this.worldObj.spawnEntityInWorld(entityarrow); + Logger.INFO("Trying to do ranged attack 5a done"); + } + } + } + + /** + * Returns the volume for the sounds this mob makes. + */ + protected float getSoundVolume() { + return 10.0F; + } + + /** + * Checks if the entity's current position is a valid location to spawn this + * entity. + */ + public boolean getCanSpawnHere() { + return super.getCanSpawnHere() && this.worldObj.difficultySetting != EnumDifficulty.PEACEFUL; + } + + /** + * Will return how many at most can spawn in a chunk at once. + */ + public int getMaxSpawnedInChunk() { + return 1; + } + + protected Item getDropItem() { + return Items.gunpowder; + } + + /** + * Drop 0-2 items of this living's type. @param par1 - Whether this entity has + * recently been hit by a player. @param par2 - Level of Looting used to kill + * this mob. + */ + protected void dropFewItems(boolean p_70628_1_, int p_70628_2_) { + int j = this.rand.nextInt(2) + this.rand.nextInt(1 + p_70628_2_); + int k; + + for (k = 0; k < j; ++k) { + this.dropItem(Items.ghast_tear, 1); + } + + j = this.rand.nextInt(3) + this.rand.nextInt(1 + p_70628_2_); + + for (k = 0; k < j; ++k) { + this.dropItem(Items.gunpowder, 1); + } + } + + @Override + protected void updateEntityActionState() { + if (!this.worldObj.isRemote && this.worldObj.difficultySetting == EnumDifficulty.PEACEFUL) { + this.setDead(); + } + + this.despawnEntity(); + this.prevAttackCounter = this.attackCounter; + double d0 = this.waypointX - this.posX; + double d1 = this.waypointY - this.posY; + double d2 = this.waypointZ - this.posZ; + double d3 = d0 * d0 + d1 * d1 + d2 * d2; + + if (d3 < 1.0D || d3 > 3600.0D) { + this.waypointX = this.posX + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F); + this.waypointY = this.posY + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F); + this.waypointZ = this.posZ + (double) ((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F); + } + + if (this.courseChangeCooldown-- <= 0) { + this.courseChangeCooldown += this.rand.nextInt(5) + 2; + d3 = (double) MathHelper.sqrt_double(d3); + + if (this.isCourseTraversable(this.waypointX, this.waypointY, this.waypointZ, d3)) { + this.motionX += d0 / d3 * 0.1D; + this.motionY += d1 / d3 * 0.1D; + this.motionZ += d2 / d3 * 0.1D; + } else { + this.waypointX = this.posX; + this.waypointY = this.posY; + this.waypointZ = this.posZ; + } + } + + if (this.targetedEntity != null && this.targetedEntity.isDead) { + this.targetedEntity = null; + } + + if (this.targetedEntity == null || this.aggroCooldown-- <= 0) { + this.targetedEntity = this.worldObj.getClosestVulnerablePlayerToEntity(this, 100.0D); + + if (this.targetedEntity != null) { + this.aggroCooldown = 20; + } + } + + double d4 = 64.0D; + + if (this.targetedEntity != null && this.targetedEntity.getDistanceSqToEntity(this) < d4 * d4) { + double d5 = this.targetedEntity.posX - this.posX; + double d6 = this.targetedEntity.boundingBox.minY + + (double) (this.targetedEntity.height / 2.0F) + - (this.posY + (double) (this.height / 2.0F)); + double d7 = this.targetedEntity.posZ - this.posZ; + this.renderYawOffset = this.rotationYaw = -((float) Math.atan2(d5, d7)) * 180.0F / (float) Math.PI; + + if (this.canEntityBeSeen(this.targetedEntity)) { + if (this.attackCounter == 10) { + this.worldObj.playAuxSFXAtEntity( + (EntityPlayer) null, 1007, (int) this.posX, (int) this.posY, (int) this.posZ, 0); + } + + ++this.attackCounter; + + if (this.attackCounter == 20) { + this.worldObj.playAuxSFXAtEntity( + (EntityPlayer) null, 1008, (int) this.posX, (int) this.posY, (int) this.posZ, 0); + EntityLargeFireball entitylargefireball = new EntityLargeFireball(this.worldObj, this, d5, d6, d7); + entitylargefireball.field_92057_e = this.explosionStrength; + double d8 = 4.0D; + Vec3 vec3 = this.getLook(1.0F); + entitylargefireball.posX = this.posX + vec3.xCoord * d8; + entitylargefireball.posY = this.posY + (double) (this.height / 2.0F) + 0.5D; + entitylargefireball.posZ = this.posZ + vec3.zCoord * d8; + this.worldObj.spawnEntityInWorld(entitylargefireball); + this.attackCounter = -40; + } + } else if (this.attackCounter > 0) { + --this.attackCounter; + } + } else { + this.renderYawOffset = + this.rotationYaw = -((float) Math.atan2(this.motionX, this.motionZ)) * 180.0F / (float) Math.PI; + + if (this.attackCounter > 0) { + --this.attackCounter; + } + } + + if (!this.worldObj.isRemote) { + byte b1 = this.dataWatcher.getWatchableObjectByte(16); + byte b0 = (byte) (this.attackCounter > 10 ? 1 : 0); + + if (b1 != b0) { + this.dataWatcher.updateObject(16, Byte.valueOf(b0)); + } + } + } + + /** + * True if the ghast has an unobstructed line of travel to the waypoint. + */ + private boolean isCourseTraversable(double p_70790_1_, double p_70790_3_, double p_70790_5_, double p_70790_7_) { + double d4 = (this.waypointX - this.posX) / p_70790_7_; + double d5 = (this.waypointY - this.posY) / p_70790_7_; + double d6 = (this.waypointZ - this.posZ) / p_70790_7_; + AxisAlignedBB axisalignedbb = this.boundingBox.copy(); + + for (int i = 1; (double) i < p_70790_7_; ++i) { + axisalignedbb.offset(d4, d5, d6); + + /* + * if (!this.worldObj.getCollidingBoundingBoxes(this, axisalignedbb).isEmpty()) + * { return false; } + */ + } + + return true; + } + + /** + * Called when the mob is falling. Calculates and applies fall damage. + */ + protected void fall(float p_70069_1_) {} + + /** + * Takes in the distance the entity has fallen this tick and whether its on the + * ground to update the fall distance and deal fall damage if landing on the + * ground. Args: distanceFallenThisTick, onGround + */ + protected void updateFallState(double p_70064_1_, boolean p_70064_3_) {} + + /** + * Moves the entity based on the specified heading. Args: strafe, forward + */ + public void moveEntityWithHeading(float p_70612_1_, float p_70612_2_) { + if (this.isInWater()) { + this.moveFlying(p_70612_1_, p_70612_2_, 0.02F); + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.800000011920929D; + this.motionY *= 0.800000011920929D; + this.motionZ *= 0.800000011920929D; + } else if (this.handleLavaMovement()) { + this.moveFlying(p_70612_1_, p_70612_2_, 0.02F); + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.5D; + this.motionY *= 0.5D; + this.motionZ *= 0.5D; + } else { + float f2 = 0.91F; + + if (this.onGround) { + f2 = this.worldObj.getBlock( + MathHelper.floor_double(this.posX), + MathHelper.floor_double(this.boundingBox.minY) - 1, + MathHelper.floor_double(this.posZ)) + .slipperiness + * 0.91F; + } + + float f3 = 0.16277136F / (f2 * f2 * f2); + this.moveFlying(p_70612_1_, p_70612_2_, this.onGround ? 0.1F * f3 : 0.02F); + f2 = 0.91F; + + if (this.onGround) { + f2 = this.worldObj.getBlock( + MathHelper.floor_double(this.posX), + MathHelper.floor_double(this.boundingBox.minY) - 1, + MathHelper.floor_double(this.posZ)) + .slipperiness + * 0.91F; + } + + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= (double) f2; + this.motionY *= (double) f2; + this.motionZ *= (double) f2; + } + + this.prevLimbSwingAmount = this.limbSwingAmount; + double d1 = this.posX - this.prevPosX; + double d0 = this.posZ - this.prevPosZ; + float f4 = MathHelper.sqrt_double(d1 * d1 + d0 * d0) * 4.0F; + + if (f4 > 1.0F) { + f4 = 1.0F; + } + + this.limbSwingAmount += (f4 - this.limbSwingAmount) * 0.4F; + this.limbSwing += this.limbSwingAmount; + } + + /** + * returns true if this entity is by a ladder, false otherwise + */ + public boolean isOnLadder() { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/core/entity/monster/EntityGiantChickenBase.java b/src/main/java/gtPlusPlus/core/entity/monster/EntityGiantChickenBase.java index 3a094e129b..e75a7664bc 100644 --- a/src/main/java/gtPlusPlus/core/entity/monster/EntityGiantChickenBase.java +++ b/src/main/java/gtPlusPlus/core/entity/monster/EntityGiantChickenBase.java @@ -1,5 +1,8 @@ package gtPlusPlus.core.entity.monster; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.item.general.ItemGemShards; +import gtPlusPlus.core.util.math.MathUtils; import net.minecraft.entity.*; import net.minecraft.entity.ai.*; import net.minecraft.entity.effect.EntityLightningBolt; @@ -13,21 +16,16 @@ import net.minecraft.potion.Potion; import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.MathHelper; import net.minecraft.world.World; - -import gtPlusPlus.core.item.ModItems; -import gtPlusPlus.core.item.general.ItemGemShards; -import gtPlusPlus.core.util.math.MathUtils; import net.minecraftforge.common.ForgeHooks; public class EntityGiantChickenBase extends EntityChicken { - + /** The time until the next egg is spawned. */ public int timeUntilNextBigEgg; - public EntityGiantChickenBase(World aWorld) - { + public EntityGiantChickenBase(World aWorld) { super(aWorld); - this.setSize(0.6F, 1.4F); //Double + this.setSize(0.6F, 1.4F); // Double this.timeUntilNextEgg = this.rand.nextInt(6000) + 6000; this.timeUntilNextBigEgg = this.rand.nextInt(16000) + 4000; this.tasks.addTask(0, new EntityAISwimming(this)); @@ -39,11 +37,9 @@ public class EntityGiantChickenBase extends EntityChicken { this.tasks.addTask(5, new EntityAIWander(this, 1.0D)); this.tasks.addTask(5, new EntityAILookIdle(this)); this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); - } - protected void applyEntityAttributes() - { + protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(40.0D); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.35D); @@ -53,49 +49,42 @@ public class EntityGiantChickenBase extends EntityChicken { * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons * use this to react to sunlight and start to burn. */ - public void onLivingUpdate() - { + public void onLivingUpdate() { super.onLivingUpdate(); this.field_70888_h = this.field_70886_e; this.field_70884_g = this.destPos; - this.destPos = (float)((double)this.destPos + (double)(this.onGround ? -1 : 4) * 0.3D); + this.destPos = (float) ((double) this.destPos + (double) (this.onGround ? -1 : 4) * 0.3D); - if (this.destPos < 0.0F) - { + if (this.destPos < 0.0F) { this.destPos = 0.0F; } - if (this.destPos > 1.0F) - { + if (this.destPos > 1.0F) { this.destPos = 1.0F; } - if (!this.onGround && this.field_70889_i < 1.0F) - { + if (!this.onGround && this.field_70889_i < 1.0F) { this.field_70889_i = 1.0F; } - this.field_70889_i = (float)((double)this.field_70889_i * 0.9D); + this.field_70889_i = (float) ((double) this.field_70889_i * 0.9D); - if (!this.onGround && this.motionY < 0.0D) - { + if (!this.onGround && this.motionY < 0.0D) { this.motionY *= 0.6D; } - + if (MathUtils.randInt(0, 10000) <= 5) { - jump(); + jump(); } this.field_70886_e += this.field_70889_i * 2.0F; - if (!this.worldObj.isRemote && --this.timeUntilNextEgg <= 0) - { + if (!this.worldObj.isRemote && --this.timeUntilNextEgg <= 0) { this.playSound("mob.chicken.plop", 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F); this.dropItem(Items.egg, 1); this.timeUntilNextEgg = this.rand.nextInt(6000) + 6000; } - if (!this.worldObj.isRemote && !this.isChild() && --this.timeUntilNextEgg <= 0) - { + if (!this.worldObj.isRemote && !this.isChild() && --this.timeUntilNextEgg <= 0) { this.playSound("mob.chicken.plop", 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F); this.dropItem(ModItems.itemBigEgg, MathUtils.randInt(1, 4)); this.timeUntilNextBigEgg = this.rand.nextInt(16000) + 4000; @@ -105,16 +94,14 @@ public class EntityGiantChickenBase extends EntityChicken { /** * Called when the mob is falling. Calculates and applies fall damage. */ - protected void fall(float p_70069_1_) { + protected void fall(float p_70069_1_) { if (MathUtils.randInt(0, 10) <= 5) { - jump(); + jump(); } - } - protected Item getDropItem() - { + protected Item getDropItem() { return ModItems.itemBigEgg; } @@ -122,35 +109,33 @@ public class EntityGiantChickenBase extends EntityChicken { * Drop 0-2 items of this living's type. @param par1 - Whether this entity has recently been hit by a player. @param * par2 - Level of Looting used to kill this mob. */ - protected void dropFewItems(boolean recentHit, int lootLevel) - { + protected void dropFewItems(boolean recentHit, int lootLevel) { int j = this.rand.nextInt(3) + this.rand.nextInt(1 + lootLevel); - for (int k = 0; k < j; ++k) - { + for (int k = 0; k < j; ++k) { this.dropItem(Items.feather, 1); } - - //Large Egg Chance - for (int k = 0; k < j*2; ++k) - { - this.dropItem(ModItems.itemBigEgg, MathUtils.getRandomFromArray(new int[] {1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2})); + + // Large Egg Chance + for (int k = 0; k < j * 2; ++k) { + this.dropItem( + ModItems.itemBigEgg, + MathUtils.getRandomFromArray(new int[] {1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2})); } - //Chicken Corpses Dropped - int mBodies = MathUtils.getRandomFromArray(new int[] {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6}); - if (this.isBurning()) - { + // Chicken Corpses Dropped + int mBodies = MathUtils.getRandomFromArray(new int[] { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, + 6 + }); + if (this.isBurning()) { this.dropItem(Items.cooked_chicken, mBodies); - } - else - { + } else { this.dropItem(Items.chicken, mBodies); } } - public EntityGiantChickenBase createChild(EntityAgeable p_90011_1_) - { + public EntityGiantChickenBase createChild(EntityAgeable p_90011_1_) { return new EntityGiantChickenBase(this.worldObj); } @@ -158,16 +143,14 @@ public class EntityGiantChickenBase extends EntityChicken { * Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on * the animal type) */ - public boolean isBreedingItem(ItemStack aStack) - { + public boolean isBreedingItem(ItemStack aStack) { return aStack != null && aStack.getItem() instanceof ItemGemShards; } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ - public void readEntityFromNBT(NBTTagCompound aNBT) - { + public void readEntityFromNBT(NBTTagCompound aNBT) { super.readEntityFromNBT(aNBT); timeUntilNextBigEgg = aNBT.getInteger("timeUntilNextBigEgg"); } @@ -175,137 +158,135 @@ public class EntityGiantChickenBase extends EntityChicken { /** * Get the experience points the entity currently has. */ - protected int getExperiencePoints(EntityPlayer p_70693_1_) - { + protected int getExperiencePoints(EntityPlayer p_70693_1_) { return this.isChickenJockey() ? 20 : super.getExperiencePoints(p_70693_1_); } /** * (abstract) Protected helper method to write subclass entity data to NBT. */ - public void writeEntityToNBT(NBTTagCompound aNBT) - { + public void writeEntityToNBT(NBTTagCompound aNBT) { super.writeEntityToNBT(aNBT); - aNBT.setInteger("timeUntilNextBigEgg", timeUntilNextBigEgg); + aNBT.setInteger("timeUntilNextBigEgg", timeUntilNextBigEgg); } /** * Determines if an entity can be despawned, used on idle far away entities */ - protected boolean canDespawn() - { + protected boolean canDespawn() { return this.isChickenJockey() && this.riddenByEntity == null; } - public void updateRiderPosition() - { + public void updateRiderPosition() { super.updateRiderPosition(); - float f = MathHelper.sin(this.renderYawOffset * (float)Math.PI / 180.0F); - float f1 = MathHelper.cos(this.renderYawOffset * (float)Math.PI / 180.0F); + float f = MathHelper.sin(this.renderYawOffset * (float) Math.PI / 180.0F); + float f1 = MathHelper.cos(this.renderYawOffset * (float) Math.PI / 180.0F); float f2 = 0.1F; float f3 = 0.0F; - this.riddenByEntity.setPosition(this.posX + (double)(f2 * f), this.posY + (double)(this.height * 0.5F) + this.riddenByEntity.getYOffset() + (double)f3, this.posZ - (double)(f2 * f1)); + this.riddenByEntity.setPosition( + this.posX + (double) (f2 * f), + this.posY + (double) (this.height * 0.5F) + this.riddenByEntity.getYOffset() + (double) f3, + this.posZ - (double) (f2 * f1)); - if (this.riddenByEntity instanceof EntityLivingBase) - { - ((EntityLivingBase)this.riddenByEntity).renderYawOffset = this.renderYawOffset; + if (this.riddenByEntity instanceof EntityLivingBase) { + ((EntityLivingBase) this.riddenByEntity).renderYawOffset = this.renderYawOffset; } } - + public boolean isChickenJockey() { - return func_152116_bZ(); + return func_152116_bZ(); } + public void setIsChickenJockey(boolean isJockey) { - func_152117_i(isJockey); + func_152117_i(isJockey); + } + + @Override + protected Entity findPlayerToAttack() { + // TODO Auto-generated method stub + return super.findPlayerToAttack(); + } + + @Override + public boolean interact(EntityPlayer p_70085_1_) { + // TODO Auto-generated method stub + return super.interact(p_70085_1_); + } + + @Override + public void setHomeArea(int p_110171_1_, int p_110171_2_, int p_110171_3_, int p_110171_4_) { + // TODO Auto-generated method stub + super.setHomeArea(p_110171_1_, p_110171_2_, p_110171_3_, p_110171_4_); + } + + @Override + public ChunkCoordinates getHomePosition() { + // TODO Auto-generated method stub + return super.getHomePosition(); + } + + @Override + public void detachHome() { + // TODO Auto-generated method stub + super.detachHome(); } - @Override - protected Entity findPlayerToAttack() { - // TODO Auto-generated method stub - return super.findPlayerToAttack(); - } - - @Override - public boolean interact(EntityPlayer p_70085_1_) { - // TODO Auto-generated method stub - return super.interact(p_70085_1_); - } - - @Override - public void setHomeArea(int p_110171_1_, int p_110171_2_, int p_110171_3_, int p_110171_4_) { - // TODO Auto-generated method stub - super.setHomeArea(p_110171_1_, p_110171_2_, p_110171_3_, p_110171_4_); - } - - @Override - public ChunkCoordinates getHomePosition() { - // TODO Auto-generated method stub - return super.getHomePosition(); - } - - @Override - public void detachHome() { - // TODO Auto-generated method stub - super.detachHome(); - } - - @Override - public boolean hasHome() { - // TODO Auto-generated method stub - return super.hasHome(); - } - - @Override - public void eatGrassBonus() { + @Override + public boolean hasHome() { + // TODO Auto-generated method stub + return super.hasHome(); + } + + @Override + public void eatGrassBonus() { if (this.isChild()) { this.addGrowth(60); } - } - - @Override - public float getRenderSizeModifier() { - return 1.0f; - } - - @Override - protected void jump() { - this.motionY = 0.68999998688697815D; - this.motionY += 0.068999998688697815D; - if (this.isPotionActive(Potion.jump)) - { - this.motionY += (double)((float)(this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.5F); + } + + @Override + public float getRenderSizeModifier() { + return 1.0f; + } + + @Override + protected void jump() { + this.motionY = 0.68999998688697815D; + this.motionY += 0.068999998688697815D; + if (this.isPotionActive(Potion.jump)) { + this.motionY += + (double) ((float) (this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.5F); } - if (this.isSprinting()) - { + if (this.isSprinting()) { float f = this.rotationYaw * 0.017453292F; - this.motionX -= (double)(MathHelper.sin(f) * 0.2F); - this.motionZ += (double)(MathHelper.cos(f) * 0.2F); + this.motionX -= (double) (MathHelper.sin(f) * 0.2F); + this.motionZ += (double) (MathHelper.cos(f) * 0.2F); } this.isAirBorne = true; - + if (MathUtils.randInt(0, 10) < 10) { - jump(); + jump(); } - + ForgeHooks.onLivingJump(this); - } - - @Override - public void onStruckByLightning(EntityLightningBolt p_70077_1_) { - this.spawnExplosionParticle(); - this.spawnExplosionParticle(); - this.spawnExplosionParticle(); - this.spawnExplosionParticle(); - this.spawnExplosionParticle(); - this.spawnExplosionParticle(); - this.spawnExplosionParticle(); - super.onStruckByLightning(p_70077_1_); - } - - @Override - public boolean shouldDismountInWater(Entity rider) { - return true; - } -} \ No newline at end of file + } + + @Override + public void onStruckByLightning(EntityLightningBolt p_70077_1_) { + this.spawnExplosionParticle(); + this.spawnExplosionParticle(); + this.spawnExplosionParticle(); + this.spawnExplosionParticle(); + this.spawnExplosionParticle(); + this.spawnExplosionParticle(); + this.spawnExplosionParticle(); + super.onStruckByLightning(p_70077_1_); + } + + @Override + public boolean shouldDismountInWater(Entity rider) { + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/entity/monster/EntitySickBlaze.java b/src/main/java/gtPlusPlus/core/entity/monster/EntitySickBlaze.java index a530f294e1..2abc2bd6a1 100644 --- a/src/main/java/gtPlusPlus/core/entity/monster/EntitySickBlaze.java +++ b/src/main/java/gtPlusPlus/core/entity/monster/EntitySickBlaze.java @@ -2,7 +2,7 @@ package gtPlusPlus.core.entity.monster; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.core.entity.projectile.EntityToxinballSmall; import net.minecraft.entity.Entity; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.monster.EntityMob; @@ -13,213 +13,220 @@ import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.world.World; -import gtPlusPlus.core.entity.projectile.EntityToxinballSmall; - public class EntitySickBlaze extends EntityMob { - /** Random offset used in floating behaviour */ - private float heightOffset = 0.5F; - /** ticks until heightOffset is randomized */ - private int heightOffsetUpdateTime; - private int field_70846_g; - private final int mDataWatcherID = 30; - - public EntitySickBlaze(World p_i1731_1_) { - super(p_i1731_1_); - this.isImmuneToFire = true; - this.experienceValue = 10; - } - - @Override - protected void applyEntityAttributes() { - super.applyEntityAttributes(); - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D); - this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(1.5D); - this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(6.0D); - } - - @Override - protected void entityInit() { - super.entityInit(); - this.dataWatcher.addObject(mDataWatcherID, new Byte((byte) 0)); - } - - /** - * Returns the sound this mob makes while it's alive. - */ - @Override - protected String getLivingSound() { - return "mob.blaze.breathe"; - } - - /** - * Returns the sound this mob makes when it is hurt. - */ - @Override - protected String getHurtSound() { - return "mob.blaze.hit"; - } - - /** - * Returns the sound this mob makes on death. - */ - @Override - protected String getDeathSound() { - return "mob.blaze.death"; - } - - @Override - @SideOnly(Side.CLIENT) - public int getBrightnessForRender(float p_70070_1_) { - return 15728880; - } - - /** - * Gets how bright this entity is. - */ - @Override - public float getBrightness(float p_70013_1_) { - return p_70013_1_; - } - - /** - * Called frequently so the entity can update its state every tick as - * required. For example, zombies and skeletons use this to react to - * sunlight and start to burn. - */ - @Override - public void onLivingUpdate() { - if (!this.worldObj.isRemote) { - if (this.isWet()) { - this.attackEntityFrom(DamageSource.drown, 1.0F); - } - - --this.heightOffsetUpdateTime; - - if (this.heightOffsetUpdateTime <= 0) { - this.heightOffsetUpdateTime = 100; - this.heightOffset = 0.5F + (float) this.rand.nextGaussian() * 3.0F; - } - - if (this.getEntityToAttack() != null && this.getEntityToAttack().posY - + this.getEntityToAttack().getEyeHeight() > this.posY + this.getEyeHeight() + this.heightOffset) { - this.motionY += (0.30000001192092896D - this.motionY) * 0.30000001192092896D; - } - } - - if (this.rand.nextInt(24) == 0) { - /*this.worldObj.playSoundEffect(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D, "fire.fire", - 1.0F + this.rand.nextFloat(), this.rand.nextFloat() * 0.7F + 0.3F);*/ - } - - if (!this.onGround && this.motionY < 0.0D) { - this.motionY *= 0.6D; - } - - for (int i = 0; i < 2; ++i) { - this.worldObj.spawnParticle("crit", this.posX + (this.rand.nextDouble() - 0.5D) * this.width, - this.posY + this.rand.nextDouble() * this.height, - this.posZ + (this.rand.nextDouble() - 0.5D) * this.width, 0.0D, 0.0D, 0.0D); - } - - super.onLivingUpdate(); - } - - /** - * Basic mob attack. Default to touch of death in EntityCreature. Overridden - * by each mob to define their attack. - */ - @Override - protected void attackEntity(Entity entity, float p_70785_2_) { - if (this.attackTime <= 0 && p_70785_2_ < 2.0F && entity.boundingBox.maxY > this.boundingBox.minY - && entity.boundingBox.minY < this.boundingBox.maxY) { - this.attackTime = 20; - this.attackEntityAsMob(entity); - } - else if (p_70785_2_ < 30.0F) { - double d0 = entity.posX - this.posX; - double d1 = entity.boundingBox.minY + entity.height / 2.0F - (this.posY + this.height / 2.0F); - double d2 = entity.posZ - this.posZ; - - if (this.attackTime == 0) { - ++this.field_70846_g; - - if (this.field_70846_g == 1) { - this.attackTime = 60; - } - else if (this.field_70846_g <= 4) { - this.attackTime = 6; - } - else { - this.attackTime = 100; - this.field_70846_g = 0; - } - - if (this.field_70846_g > 1) { - float f1 = MathHelper.sqrt_float(p_70785_2_) * 0.5F; - this.worldObj.playAuxSFXAtEntity((EntityPlayer) null, 1009, (int) this.posX, (int) this.posY, - (int) this.posZ, 0); - - for (int i = 0; i < 1; ++i) { - EntityToxinballSmall entitysmalltoxinball = new EntityToxinballSmall(this.worldObj, this, - d0 + this.rand.nextGaussian() * f1, d1, d2 + this.rand.nextGaussian() * f1); - entitysmalltoxinball.posY = this.posY + this.height / 2.0F + 0.5D; - this.worldObj.spawnEntityInWorld(entitysmalltoxinball); - } - } - } - - this.rotationYaw = (float) (Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F; - this.hasAttacked = true; - } - } - - /** - * Called when the mob is falling. Calculates and applies fall damage. - */ - @Override - protected void fall(float p_70069_1_) { - } - - @Override - protected Item getDropItem() { - return Items.slime_ball; - } - - /** - * Returns true if the entity is on fire. Used by render to add the fire - * effect on rendering. - */ - @Override - public boolean isBurning() { - return false; - } - - /** - * Drop 0-2 items of this living's type. @param par1 - Whether this entity - * has recently been hit by a player. @param par2 - Level of Looting used to - * kill this mob. - */ - @Override - protected void dropFewItems(boolean p_70628_1_, int p_70628_2_) { - if (p_70628_1_) { - int j = this.rand.nextInt(2 + p_70628_2_); - - for (int k = 0; k < j; ++k) { - this.dropItem(getDropItem(), 1); - } - } - } - - /** - * Checks to make sure the light is not too bright where the mob is spawning - */ - @Override - protected boolean isValidLightLevel() { - return true; - } - - @Override - public int getMaxSpawnedInChunk() { - return 8; - } -} \ No newline at end of file + /** Random offset used in floating behaviour */ + private float heightOffset = 0.5F; + /** ticks until heightOffset is randomized */ + private int heightOffsetUpdateTime; + + private int field_70846_g; + private final int mDataWatcherID = 30; + + public EntitySickBlaze(World p_i1731_1_) { + super(p_i1731_1_); + this.isImmuneToFire = true; + this.experienceValue = 10; + } + + @Override + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(1.5D); + this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(6.0D); + } + + @Override + protected void entityInit() { + super.entityInit(); + this.dataWatcher.addObject(mDataWatcherID, new Byte((byte) 0)); + } + + /** + * Returns the sound this mob makes while it's alive. + */ + @Override + protected String getLivingSound() { + return "mob.blaze.breathe"; + } + + /** + * Returns the sound this mob makes when it is hurt. + */ + @Override + protected String getHurtSound() { + return "mob.blaze.hit"; + } + + /** + * Returns the sound this mob makes on death. + */ + @Override + protected String getDeathSound() { + return "mob.blaze.death"; + } + + @Override + @SideOnly(Side.CLIENT) + public int getBrightnessForRender(float p_70070_1_) { + return 15728880; + } + + /** + * Gets how bright this entity is. + */ + @Override + public float getBrightness(float p_70013_1_) { + return p_70013_1_; + } + + /** + * Called frequently so the entity can update its state every tick as + * required. For example, zombies and skeletons use this to react to + * sunlight and start to burn. + */ + @Override + public void onLivingUpdate() { + if (!this.worldObj.isRemote) { + if (this.isWet()) { + this.attackEntityFrom(DamageSource.drown, 1.0F); + } + + --this.heightOffsetUpdateTime; + + if (this.heightOffsetUpdateTime <= 0) { + this.heightOffsetUpdateTime = 100; + this.heightOffset = 0.5F + (float) this.rand.nextGaussian() * 3.0F; + } + + if (this.getEntityToAttack() != null + && this.getEntityToAttack().posY + this.getEntityToAttack().getEyeHeight() + > this.posY + this.getEyeHeight() + this.heightOffset) { + this.motionY += (0.30000001192092896D - this.motionY) * 0.30000001192092896D; + } + } + + if (this.rand.nextInt(24) == 0) { + /*this.worldObj.playSoundEffect(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D, "fire.fire", + 1.0F + this.rand.nextFloat(), this.rand.nextFloat() * 0.7F + 0.3F);*/ + } + + if (!this.onGround && this.motionY < 0.0D) { + this.motionY *= 0.6D; + } + + for (int i = 0; i < 2; ++i) { + this.worldObj.spawnParticle( + "crit", + this.posX + (this.rand.nextDouble() - 0.5D) * this.width, + this.posY + this.rand.nextDouble() * this.height, + this.posZ + (this.rand.nextDouble() - 0.5D) * this.width, + 0.0D, + 0.0D, + 0.0D); + } + + super.onLivingUpdate(); + } + + /** + * Basic mob attack. Default to touch of death in EntityCreature. Overridden + * by each mob to define their attack. + */ + @Override + protected void attackEntity(Entity entity, float p_70785_2_) { + if (this.attackTime <= 0 + && p_70785_2_ < 2.0F + && entity.boundingBox.maxY > this.boundingBox.minY + && entity.boundingBox.minY < this.boundingBox.maxY) { + this.attackTime = 20; + this.attackEntityAsMob(entity); + } else if (p_70785_2_ < 30.0F) { + double d0 = entity.posX - this.posX; + double d1 = entity.boundingBox.minY + entity.height / 2.0F - (this.posY + this.height / 2.0F); + double d2 = entity.posZ - this.posZ; + + if (this.attackTime == 0) { + ++this.field_70846_g; + + if (this.field_70846_g == 1) { + this.attackTime = 60; + } else if (this.field_70846_g <= 4) { + this.attackTime = 6; + } else { + this.attackTime = 100; + this.field_70846_g = 0; + } + + if (this.field_70846_g > 1) { + float f1 = MathHelper.sqrt_float(p_70785_2_) * 0.5F; + this.worldObj.playAuxSFXAtEntity( + (EntityPlayer) null, 1009, (int) this.posX, (int) this.posY, (int) this.posZ, 0); + + for (int i = 0; i < 1; ++i) { + EntityToxinballSmall entitysmalltoxinball = new EntityToxinballSmall( + this.worldObj, + this, + d0 + this.rand.nextGaussian() * f1, + d1, + d2 + this.rand.nextGaussian() * f1); + entitysmalltoxinball.posY = this.posY + this.height / 2.0F + 0.5D; + this.worldObj.spawnEntityInWorld(entitysmalltoxinball); + } + } + } + + this.rotationYaw = (float) (Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F; + this.hasAttacked = true; + } + } + + /** + * Called when the mob is falling. Calculates and applies fall damage. + */ + @Override + protected void fall(float p_70069_1_) {} + + @Override + protected Item getDropItem() { + return Items.slime_ball; + } + + /** + * Returns true if the entity is on fire. Used by render to add the fire + * effect on rendering. + */ + @Override + public boolean isBurning() { + return false; + } + + /** + * Drop 0-2 items of this living's type. @param par1 - Whether this entity + * has recently been hit by a player. @param par2 - Level of Looting used to + * kill this mob. + */ + @Override + protected void dropFewItems(boolean p_70628_1_, int p_70628_2_) { + if (p_70628_1_) { + int j = this.rand.nextInt(2 + p_70628_2_); + + for (int k = 0; k < j; ++k) { + this.dropItem(getDropItem(), 1); + } + } + } + + /** + * Checks to make sure the light is not too bright where the mob is spawning + */ + @Override + protected boolean isValidLightLevel() { + return true; + } + + @Override + public int getMaxSpawnedInChunk() { + return 8; + } +} diff --git a/src/main/java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java b/src/main/java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java index f6f397f59e..b0cbbe2e8d 100644 --- a/src/main/java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java +++ b/src/main/java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java @@ -1,13 +1,12 @@ package gtPlusPlus.core.entity.monster; -import java.lang.reflect.Field; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.core.world.explosions.ExplosionHandler; +import java.lang.reflect.Field; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.*; @@ -24,530 +23,613 @@ import net.minecraft.world.World; public class EntityStaballoyConstruct extends EntityIronGolem { - /* - * Determines whether or not the entity is in a fluid at all. - */ - private boolean inFluid = false; - private boolean mReflectFirstUpdate = true; - private boolean isReadyToExplode = false; - private int fuse = 60; - private int attackTimer; - - public EntityStaballoyConstruct(World world) { - super(world); - this.experienceValue = 250; - this.setSize(1.4F, 2.9F); - this.getNavigator().setAvoidsWater(true); - this.getNavigator().setBreakDoors(true); - this.getNavigator().setCanSwim(false); - this.getNavigator().setAvoidSun(false); - this.tasks.addTask(1, new EntityAIAttackOnCollide(this, 1.0D, true)); - this.tasks.addTask(2, new EntityAIMoveTowardsTarget(this, 0.9D, 32.0F)); - //this.tasks.addTask(3, new EntityAIMoveThroughVillage(this, 0.6D, true)); - this.tasks.addTask(3, new EntityAIMoveTowardsRestriction(this, 1.0D)); - this.tasks.addTask(4, new EntityAIWander(this, 0.6D)); - this.tasks.addTask(5, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); - this.tasks.addTask(6, new EntityAILookIdle(this)); - this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false)); - this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityLiving.class, 0, false, true, IMob.mobSelector)); - } - - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ - @Override - public void writeEntityToNBT(NBTTagCompound p_70014_1_) { - super.writeEntityToNBT(p_70014_1_); - p_70014_1_.setBoolean("inFluid", this.inFluid); - p_70014_1_.setBoolean("isReadyToExplode", this.isReadyToExplode); - p_70014_1_.setInteger("fuse", this.fuse); - } - - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - @Override - public void readEntityFromNBT(NBTTagCompound p_70037_1_) { - super.readEntityFromNBT(p_70037_1_); - this.inFluid = p_70037_1_.getBoolean("inFluid"); - this.isReadyToExplode = p_70037_1_.getBoolean("isReadyToExplode"); - this.fuse = p_70037_1_.getInteger("fuse"); - } - - @Override - protected void entityInit() { - super.entityInit(); - this.dataWatcher.addObject(17, Byte.valueOf((byte) 0)); - } - - /** - * Returns true if the newer Entity AI code should be run - */ - @Override - public boolean isAIEnabled() { - return true; - } - - /** - * main AI tick function, replaces updateEntityActionState - */ - @Override - protected void updateAITick() { - super.updateAITick(); - } - - @Override - protected void applyEntityAttributes() { - super.applyEntityAttributes(); - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(500.0D); - this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.5D); - } - - /** - * Decrements the entity's air supply when underwater - */ - @Override - protected int decreaseAirSupply(int p_70682_1_) { - return 0; - } - - @Override - protected void collideWithEntity(Entity p_82167_1_) { - if (p_82167_1_ instanceof IMob && this.getRNG().nextInt(20) == 0) { - this.setAttackTarget((EntityLivingBase) p_82167_1_); - } - - super.collideWithEntity(p_82167_1_); - } - - /** - * Called frequently so the entity can update its state every tick as - * required. For example, zombies and skeletons use this to react to - * sunlight and start to burn. - */ - @Override - public void onLivingUpdate() { - super.onLivingUpdate(); - - if (this.attackTimer > 0) { - --this.attackTimer; - } - - if (this.motionX * this.motionX + this.motionZ * this.motionZ > 2.500000277905201E-7D - && this.rand.nextInt(5) == 0) { - int i = MathHelper.floor_double(this.posX); - int j = MathHelper.floor_double(this.posY - 0.20000000298023224D - this.yOffset); - int k = MathHelper.floor_double(this.posZ); - Block block = this.worldObj.getBlock(i, j, k); - - - - if (block.getMaterial() != Material.air) { - this.worldObj.spawnParticle( - "blockcrack_" + Block.getIdFromBlock(block) + "_" + this.worldObj.getBlockMetadata(i, j, k), - this.posX + (this.rand.nextFloat() - 0.5D) * this.width, - this.boundingBox.minY + 0.1D, - this.posZ + (this.rand.nextFloat() - 0.5D) * this.width, - 4.0D * (this.rand.nextFloat() - 0.5D), 0.5D, - (this.rand.nextFloat() - 0.5D) * 4.0D); - } - } - } - - /** - * Returns true if this entity can attack entities of the specified class. - */ - @Override - public boolean canAttackClass(Class clazz) { - return clazz.equals(this.getClass()) ? false : true; - } - - @Override - public boolean attackEntityAsMob(Entity p_70652_1_) { - this.attackTimer = 10; - this.worldObj.setEntityState(this, (byte) 4); - boolean flag = p_70652_1_.attackEntityFrom(DamageSource.causeMobDamage(this), - 7 + this.rand.nextInt(15)); - - if (flag) { - p_70652_1_.motionY += 0.4000000059604645D; - } - - this.playSound("mob.irongolem.throw", 1.0F, 1.0F); - return flag; - } - - @Override - @SideOnly(Side.CLIENT) - public void handleHealthUpdate(byte p_70103_1_) { - if (p_70103_1_ == 4) { - this.attackTimer = 10; - this.playSound("mob.irongolem.throw", 1.0F, 1.0F); - } - else { - super.handleHealthUpdate(p_70103_1_); - } - } - - @Override - public Village getVillage() { - return null; - } - - @Override - @SideOnly(Side.CLIENT) - public int getAttackTimer() { - return this.attackTimer; - } - - /** - * Returns the sound this mob makes when it is hurt. - */ - @Override - protected String getHurtSound() { - return "mob.irongolem.hit"; - } - - /** - * Returns the sound this mob makes on death. - */ - @Override - protected String getDeathSound() { - return "mob.irongolem.death"; - } - - @Override - protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_) { - this.playSound("mob.irongolem.walk", 1.0F, 1.0F); - } - - /** - * Drop 0-2 items of this living's type. @param par1 - Whether this entity - * has recently been hit by a player. @param par2 - Level of Looting used to - * kill this mob. - */ - @Override - protected void dropFewItems(boolean p_70628_1_, int p_70628_2_) { - int lootingChance = p_70628_2_+1; - int j = this.rand.nextInt(3); - int k; - - for (k = 0; k < j; ++k) { - this.entityDropItem(ItemUtils.getItemStackOfAmountFromOreDict("blockStaballoy", 1), 0f); - } - - k = 3 + this.rand.nextInt(3); - - for (int l = 0; l < k; ++l) { - this.entityDropItem(ItemUtils.getItemStackOfAmountFromOreDict("ingotStaballoy", lootingChance), 0f); - if (MathUtils.randInt(0, 2) == 0){ - this.entityDropItem(ItemUtils.getItemStackOfAmountFromOreDict("plateStaballoy", lootingChance), 0f); - } - } - } - - @Override - public boolean isPlayerCreated() { - return false; - } - - @Override - public void setPlayerCreated(boolean p_70849_1_) { - - } - - /** - * Called when the mob's health reaches 0. - */ - @Override - public void onDeath(DamageSource p_70645_1_) { - super.onDeath(p_70645_1_); - } - - @Override - protected String getLivingSound() { //TODO - return super.getLivingSound(); - } - - @Override - public int getTalkInterval() { - return 0; - } - - @Override - protected boolean canDespawn() { - return true; - } - - @Override - public void onEntityUpdate() { - //Set Fire Immunity - if (!this.isImmuneToFire){ - this.isImmuneToFire = true; - } - - if (!this.worldObj.isRemote) { - final float hp = getHealth(); - final float modifier = MathUtils.randInt(5,10)/100F; - final float amountToExplode = (hp*modifier); - - if (hp <= amountToExplode && !isReadyToExplode){ - if (this.ticksExisted >= 50) { - //Logger.INFO("Construct has low hp, trying to enable explosions. HP: "+this.getHealth()+", Max: "+this.getMaxHealth()+", Mod: "+modifier); - //Logger.INFO("Construct required HP to be <= "+amountToExplode); - float r = MathUtils.randFloat(0, 10); - if (r <= 0.1){ - this.isReadyToExplode = true; - //Logger.INFO("Construct can now explode."); - } - } - } - //Handle Exploding - else if (hp <= amountToExplode && isReadyToExplode){ - //Logger.INFO("Trying to explode. ["+this.fuse+"]"); - if (this.fuse-- <= 0){ - //Logger.INFO("Fuse has run out."); - this.setDead(); - if (!this.worldObj.isRemote) - { - this.explode(); - } - } - else { - //Logger.INFO("Ticking fuse and spawning particles."); - - int maxFuse = 60; - int fuseUsed = maxFuse-this.fuse; - float var2 = (float) (fuseUsed * 0.1); - - this.setSize(1.4F+(var2/2), 2.9F+(var2/2)); - - float r = MathUtils.randFloat(0, 1); - int r2 = MathUtils.randInt(5, 15); - for (int o=0;o 1.0F) - { - f = 1.0F; - } - - this.playSound(this.getSplashSound(), f, 1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F); - float f1 = MathHelper.floor_double(this.boundingBox.minY); - int i; - float f2; - float f3; - - for (i = 0; i < 1.0F + this.width * 20.0F; ++i) - { - f2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width; - f3 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width; - this.worldObj.spawnParticle("bubble", this.posX + f2, f1 + 1.0F, this.posZ + f3, this.motionX, this.motionY - this.rand.nextFloat() * 0.2F, this.motionZ); - } - - for (i = 0; i < 1.0F + this.width * 20.0F; ++i) - { - f2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width; - f3 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width; - this.worldObj.spawnParticle("splash", this.posX + f2, f1 + 1.0F, this.posZ + f3, this.motionX, this.motionY, this.motionZ); - } - } - this.fallDistance = 0.0F; - this.inFluid = true; - } - else - { - this.inFluid = false; - } - return this.inFluid; - } - - @Override - public void onChunkLoad() { - // TODO Auto-generated method stub - super.onChunkLoad(); - } - - @Override - public void onStruckByLightning(EntityLightningBolt p_70077_1_) { - this.isReadyToExplode = true; - this.fuse = 20; - } - - private void explode(){ - /* float f = 12.0F; + /* + * Determines whether or not the entity is in a fluid at all. + */ + private boolean inFluid = false; + private boolean mReflectFirstUpdate = true; + private boolean isReadyToExplode = false; + private int fuse = 60; + private int attackTimer; + + public EntityStaballoyConstruct(World world) { + super(world); + this.experienceValue = 250; + this.setSize(1.4F, 2.9F); + this.getNavigator().setAvoidsWater(true); + this.getNavigator().setBreakDoors(true); + this.getNavigator().setCanSwim(false); + this.getNavigator().setAvoidSun(false); + this.tasks.addTask(1, new EntityAIAttackOnCollide(this, 1.0D, true)); + this.tasks.addTask(2, new EntityAIMoveTowardsTarget(this, 0.9D, 32.0F)); + // this.tasks.addTask(3, new EntityAIMoveThroughVillage(this, 0.6D, true)); + this.tasks.addTask(3, new EntityAIMoveTowardsRestriction(this, 1.0D)); + this.tasks.addTask(4, new EntityAIWander(this, 0.6D)); + this.tasks.addTask(5, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); + this.tasks.addTask(6, new EntityAILookIdle(this)); + this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false)); + this.targetTasks.addTask( + 2, new EntityAINearestAttackableTarget(this, EntityLiving.class, 0, false, true, IMob.mobSelector)); + } + + /** + * (abstract) Protected helper method to write subclass entity data to NBT. + */ + @Override + public void writeEntityToNBT(NBTTagCompound p_70014_1_) { + super.writeEntityToNBT(p_70014_1_); + p_70014_1_.setBoolean("inFluid", this.inFluid); + p_70014_1_.setBoolean("isReadyToExplode", this.isReadyToExplode); + p_70014_1_.setInteger("fuse", this.fuse); + } + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + @Override + public void readEntityFromNBT(NBTTagCompound p_70037_1_) { + super.readEntityFromNBT(p_70037_1_); + this.inFluid = p_70037_1_.getBoolean("inFluid"); + this.isReadyToExplode = p_70037_1_.getBoolean("isReadyToExplode"); + this.fuse = p_70037_1_.getInteger("fuse"); + } + + @Override + protected void entityInit() { + super.entityInit(); + this.dataWatcher.addObject(17, Byte.valueOf((byte) 0)); + } + + /** + * Returns true if the newer Entity AI code should be run + */ + @Override + public boolean isAIEnabled() { + return true; + } + + /** + * main AI tick function, replaces updateEntityActionState + */ + @Override + protected void updateAITick() { + super.updateAITick(); + } + + @Override + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(500.0D); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.5D); + } + + /** + * Decrements the entity's air supply when underwater + */ + @Override + protected int decreaseAirSupply(int p_70682_1_) { + return 0; + } + + @Override + protected void collideWithEntity(Entity p_82167_1_) { + if (p_82167_1_ instanceof IMob && this.getRNG().nextInt(20) == 0) { + this.setAttackTarget((EntityLivingBase) p_82167_1_); + } + + super.collideWithEntity(p_82167_1_); + } + + /** + * Called frequently so the entity can update its state every tick as + * required. For example, zombies and skeletons use this to react to + * sunlight and start to burn. + */ + @Override + public void onLivingUpdate() { + super.onLivingUpdate(); + + if (this.attackTimer > 0) { + --this.attackTimer; + } + + if (this.motionX * this.motionX + this.motionZ * this.motionZ > 2.500000277905201E-7D + && this.rand.nextInt(5) == 0) { + int i = MathHelper.floor_double(this.posX); + int j = MathHelper.floor_double(this.posY - 0.20000000298023224D - this.yOffset); + int k = MathHelper.floor_double(this.posZ); + Block block = this.worldObj.getBlock(i, j, k); + + if (block.getMaterial() != Material.air) { + this.worldObj.spawnParticle( + "blockcrack_" + Block.getIdFromBlock(block) + "_" + this.worldObj.getBlockMetadata(i, j, k), + this.posX + (this.rand.nextFloat() - 0.5D) * this.width, + this.boundingBox.minY + 0.1D, + this.posZ + (this.rand.nextFloat() - 0.5D) * this.width, + 4.0D * (this.rand.nextFloat() - 0.5D), + 0.5D, + (this.rand.nextFloat() - 0.5D) * 4.0D); + } + } + } + + /** + * Returns true if this entity can attack entities of the specified class. + */ + @Override + public boolean canAttackClass(Class clazz) { + return clazz.equals(this.getClass()) ? false : true; + } + + @Override + public boolean attackEntityAsMob(Entity p_70652_1_) { + this.attackTimer = 10; + this.worldObj.setEntityState(this, (byte) 4); + boolean flag = p_70652_1_.attackEntityFrom(DamageSource.causeMobDamage(this), 7 + this.rand.nextInt(15)); + + if (flag) { + p_70652_1_.motionY += 0.4000000059604645D; + } + + this.playSound("mob.irongolem.throw", 1.0F, 1.0F); + return flag; + } + + @Override + @SideOnly(Side.CLIENT) + public void handleHealthUpdate(byte p_70103_1_) { + if (p_70103_1_ == 4) { + this.attackTimer = 10; + this.playSound("mob.irongolem.throw", 1.0F, 1.0F); + } else { + super.handleHealthUpdate(p_70103_1_); + } + } + + @Override + public Village getVillage() { + return null; + } + + @Override + @SideOnly(Side.CLIENT) + public int getAttackTimer() { + return this.attackTimer; + } + + /** + * Returns the sound this mob makes when it is hurt. + */ + @Override + protected String getHurtSound() { + return "mob.irongolem.hit"; + } + + /** + * Returns the sound this mob makes on death. + */ + @Override + protected String getDeathSound() { + return "mob.irongolem.death"; + } + + @Override + protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_) { + this.playSound("mob.irongolem.walk", 1.0F, 1.0F); + } + + /** + * Drop 0-2 items of this living's type. @param par1 - Whether this entity + * has recently been hit by a player. @param par2 - Level of Looting used to + * kill this mob. + */ + @Override + protected void dropFewItems(boolean p_70628_1_, int p_70628_2_) { + int lootingChance = p_70628_2_ + 1; + int j = this.rand.nextInt(3); + int k; + + for (k = 0; k < j; ++k) { + this.entityDropItem(ItemUtils.getItemStackOfAmountFromOreDict("blockStaballoy", 1), 0f); + } + + k = 3 + this.rand.nextInt(3); + + for (int l = 0; l < k; ++l) { + this.entityDropItem(ItemUtils.getItemStackOfAmountFromOreDict("ingotStaballoy", lootingChance), 0f); + if (MathUtils.randInt(0, 2) == 0) { + this.entityDropItem(ItemUtils.getItemStackOfAmountFromOreDict("plateStaballoy", lootingChance), 0f); + } + } + } + + @Override + public boolean isPlayerCreated() { + return false; + } + + @Override + public void setPlayerCreated(boolean p_70849_1_) {} + + /** + * Called when the mob's health reaches 0. + */ + @Override + public void onDeath(DamageSource p_70645_1_) { + super.onDeath(p_70645_1_); + } + + @Override + protected String getLivingSound() { // TODO + return super.getLivingSound(); + } + + @Override + public int getTalkInterval() { + return 0; + } + + @Override + protected boolean canDespawn() { + return true; + } + + @Override + public void onEntityUpdate() { + // Set Fire Immunity + if (!this.isImmuneToFire) { + this.isImmuneToFire = true; + } + + if (!this.worldObj.isRemote) { + final float hp = getHealth(); + final float modifier = MathUtils.randInt(5, 10) / 100F; + final float amountToExplode = (hp * modifier); + + if (hp <= amountToExplode && !isReadyToExplode) { + if (this.ticksExisted >= 50) { + // Logger.INFO("Construct has low hp, trying to enable explosions. HP: "+this.getHealth()+", Max: + // "+this.getMaxHealth()+", Mod: "+modifier); + // Logger.INFO("Construct required HP to be <= "+amountToExplode); + float r = MathUtils.randFloat(0, 10); + if (r <= 0.1) { + this.isReadyToExplode = true; + // Logger.INFO("Construct can now explode."); + } + } + } + // Handle Exploding + else if (hp <= amountToExplode && isReadyToExplode) { + // Logger.INFO("Trying to explode. ["+this.fuse+"]"); + if (this.fuse-- <= 0) { + // Logger.INFO("Fuse has run out."); + this.setDead(); + if (!this.worldObj.isRemote) { + this.explode(); + } + } else { + // Logger.INFO("Ticking fuse and spawning particles."); + + int maxFuse = 60; + int fuseUsed = maxFuse - this.fuse; + float var2 = (float) (fuseUsed * 0.1); + + this.setSize(1.4F + (var2 / 2), 2.9F + (var2 / 2)); + + float r = MathUtils.randFloat(0, 1); + int r2 = MathUtils.randInt(5, 15); + for (int o = 0; o < r2; o++) { + if (r <= 0.3) { + this.worldObj.spawnParticle( + "smoke", + this.posX + MathUtils.randDouble(-2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + + } else if (r <= 0.6) { + this.worldObj.spawnParticle( + "largesmoke", + this.posX + MathUtils.randDouble(-2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + } + if (r <= 0.3) { + this.worldObj.spawnParticle( + "cloud", + this.posX + MathUtils.randDouble(-2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + + } else if (r <= 0.7) { + this.worldObj.spawnParticle( + "flame", + this.posX + MathUtils.randDouble(-2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + } + if (r <= 0.2) { + this.worldObj.spawnParticle( + "explode", + this.posX + MathUtils.randDouble(-2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + + } else if (r <= 0.5) { + this.worldObj.spawnParticle( + "largeexplode", + this.posX + MathUtils.randDouble(-2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + + } else if (r <= 0.7) { + this.worldObj.spawnParticle( + "hugeexplosion", + this.posX + MathUtils.randDouble(-2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + } + } + } + } else { + + } + + // Get a private field from a super class if it exists. + if (mFirstUpdateField == null) { + mFirstUpdateField = ReflectionUtils.getField(this.getClass(), "firstUpdate"); + } + if (mFirstUpdateField != null && mReflectFirstUpdate == true) { + try { + this.mReflectFirstUpdate = (boolean) mFirstUpdateField.get(this); + } catch (IllegalArgumentException | IllegalAccessException e) { + } + } + } + super.onEntityUpdate(); + } + + private static Field mFirstUpdateField; + + @Override + public int getMaxSpawnedInChunk() { + return 1; + } + + @Override + public boolean canBreatheUnderwater() { + return true; + } + + @Override + public void knockBack(Entity p_70653_1_, float p_70653_2_, double p_70653_3_, double p_70653_5_) { + // Do Nothing because he weighs metric shittonnes. + } + + @Override + protected void setOnFireFromLava() { + extinguish(); + } + + @Override + public void setFire(int p_70015_1_) { + extinguish(); + } + + @Override + protected void dealFireDamage(int p_70081_1_) {} + + @Override + public boolean isInWater() { + if (super.isInWater()) { + return true; + } else { + this.moveForward *= 0.98F; + return false; + } + } + + @Override + public boolean handleWaterMovement() { + this.moveForward *= 0.74F; + return handleFluidMovement(Material.water); + } + + @Override + public boolean handleLavaMovement() { + this.moveForward *= 0.74F; + return handleFluidMovement(Material.lava); + } + + /** + * Returns if this entity is in water and will end up adding the waters velocity to the entity + */ + public boolean handleFluidMovement(Material fluid) { + + if (this.worldObj.handleMaterialAcceleration( + this.boundingBox.expand(0.0D, -0.4000000059604645D, 0.0D).contract(0.001D, 0.001D, 0.001D), + fluid, + this)) { + if (!this.inFluid && !this.mReflectFirstUpdate) { + float f = MathHelper.sqrt_double(this.motionX * this.motionX * 0.20000000298023224D + + this.motionY * this.motionY + + this.motionZ * this.motionZ * 0.20000000298023224D) + * 0.2F; + + if (f > 1.0F) { + f = 1.0F; + } + + this.playSound(this.getSplashSound(), f, 1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F); + float f1 = MathHelper.floor_double(this.boundingBox.minY); + int i; + float f2; + float f3; + + for (i = 0; i < 1.0F + this.width * 20.0F; ++i) { + f2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width; + f3 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width; + this.worldObj.spawnParticle( + "bubble", + this.posX + f2, + f1 + 1.0F, + this.posZ + f3, + this.motionX, + this.motionY - this.rand.nextFloat() * 0.2F, + this.motionZ); + } + + for (i = 0; i < 1.0F + this.width * 20.0F; ++i) { + f2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width; + f3 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width; + this.worldObj.spawnParticle( + "splash", + this.posX + f2, + f1 + 1.0F, + this.posZ + f3, + this.motionX, + this.motionY, + this.motionZ); + } + } + this.fallDistance = 0.0F; + this.inFluid = true; + } else { + this.inFluid = false; + } + return this.inFluid; + } + + @Override + public void onChunkLoad() { + // TODO Auto-generated method stub + super.onChunkLoad(); + } + + @Override + public void onStruckByLightning(EntityLightningBolt p_70077_1_) { + this.isReadyToExplode = true; + this.fuse = 20; + } + + private void explode() { + /* float f = 12.0F; this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, f, true);*/ - if (!this.worldObj.isRemote) { - final float f = 6.5F; - ExplosionHandler explode = new ExplosionHandler(); - explode.createExplosion(this.worldObj, this, this.posX, this.posY, this.posZ, f, true, true); - - float r = MathUtils.randFloat(0, 1); - int r2 = MathUtils.randInt(20, 40); - for (int o=0;o 0) { - ((EntityLivingBase) p_70227_1_.entityHit).addPotionEffect(new PotionEffect(Potion.poison.id, 20 * b0, 1)); - ((EntityLivingBase) p_70227_1_.entityHit).addPotionEffect(new PotionEffect(Potion.confusion.id, 20 * b0, 1)); - ((EntityLivingBase) p_70227_1_.entityHit).addPotionEffect(new PotionEffect(Potion.weakness.id, 20 * b0, 1)); - } - } - } + if (this.worldObj.difficultySetting == EnumDifficulty.NORMAL) { + b0 = 10; + } else if (this.worldObj.difficultySetting == EnumDifficulty.HARD) { + b0 = 40; + } - this.worldObj.newExplosion(this, this.posX, this.posY, this.posZ, 1.0F, false, - this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing")); - this.setDead(); - } - } + if (b0 > 0) { + ((EntityLivingBase) p_70227_1_.entityHit) + .addPotionEffect(new PotionEffect(Potion.poison.id, 20 * b0, 1)); + ((EntityLivingBase) p_70227_1_.entityHit) + .addPotionEffect(new PotionEffect(Potion.confusion.id, 20 * b0, 1)); + ((EntityLivingBase) p_70227_1_.entityHit) + .addPotionEffect(new PotionEffect(Potion.weakness.id, 20 * b0, 1)); + } + } + } - -} \ No newline at end of file + this.worldObj.newExplosion( + this, + this.posX, + this.posY, + this.posZ, + 1.0F, + false, + this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing")); + this.setDead(); + } + } +} diff --git a/src/main/java/gtPlusPlus/core/entity/projectile/EntitySulfuricAcidPotion.java b/src/main/java/gtPlusPlus/core/entity/projectile/EntitySulfuricAcidPotion.java index 7660dd1b75..c153232b60 100644 --- a/src/main/java/gtPlusPlus/core/entity/projectile/EntitySulfuricAcidPotion.java +++ b/src/main/java/gtPlusPlus/core/entity/projectile/EntitySulfuricAcidPotion.java @@ -1,5 +1,9 @@ package gtPlusPlus.core.entity.projectile; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.EntityUtils; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.projectile.EntityThrowable; @@ -8,108 +12,118 @@ import net.minecraft.util.DamageSource; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; -import gregtech.api.util.GT_Utility; - -import gtPlusPlus.api.objects.minecraft.BlockPos; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.EntityUtils; - public class EntitySulfuricAcidPotion extends EntityThrowable { - public EntitySulfuricAcidPotion(World world) { - super(world); - } - - public EntitySulfuricAcidPotion(World world, EntityLivingBase entity) { - super(world, entity); - } - - public EntitySulfuricAcidPotion(World world, double posX, double posY, double posZ) { - super(world, posX, posY, posZ); - } - - /** - * Called when this EntityThrowable hits a block or entity. - */ - @Override - protected void onImpact(MovingObjectPosition object) { - int xBlock = object.blockX; - int yBlock = object.blockY; - int zBlock = object.blockZ; - if (object.entityHit != null) { - byte b0 = 6; - if (!GT_Utility.isWearingFullRadioHazmat((EntityLivingBase) object.entityHit)){ - object.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), b0); - EntityUtils.setEntityOnFire(object.entityHit, 10); - object.entityHit.fireResistance = 0; - ravage(EntityUtils.findBlockPosUnderEntity(object.entityHit)); - } - } - if (object.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK){ - ravage(new BlockPos(xBlock, yBlock, zBlock)); - } - - String mParticleType = "reddust"; - int e=0; - for (int i = 0; i < 24; ++i) { - if ((e = MathUtils.randInt(0, 5)) <= 1){ - if (e==0) - mParticleType = "largesmoke"; - if (e==1) - mParticleType = "flame"; - } - this.worldObj.spawnParticle(mParticleType, this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); - } - - if (!this.worldObj.isRemote) { - this.setDead(); - } - } - - private boolean ravage(BlockPos blockpos){ - - int radius = 1; - - for (int i=(blockpos.xPos-radius);i<(blockpos.xPos+radius);i++){ - for (int j=(blockpos.yPos-radius);j<(blockpos.yPos+radius);j++){ - for (int h=(blockpos.zPos-radius);h<(blockpos.zPos+radius);h++){ - - int mChance = MathUtils.randInt(1, 10); - if (mChance <= 3){ - Block mBlockhit = worldObj.getBlock(i, j, h); - this.worldObj.spawnParticle("flame", this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("largesmoke", this.posX+MathUtils.randDouble(2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); - - //GT_Pollution.addPollution(worldObj.getChunkFromBlockCoords(blockpos.xPos, blockpos.zPos), mPol); - - if (mBlockhit == Blocks.grass || mBlockhit == Blocks.mycelium){ - worldObj.setBlock(i, j+1, h, Blocks.fire); - worldObj.setBlock(i, j, h, Blocks.dirt); - } - else if (mBlockhit == Blocks.leaves || mBlockhit == Blocks.leaves2){ - worldObj.setBlock(i, j, h, Blocks.fire); - } - else if (mBlockhit == Blocks.tallgrass){ - worldObj.setBlock(i, j, h, Blocks.fire); - if (worldObj.getBlock(i, j-1, h) == Blocks.grass){ - worldObj.setBlock(i, j-1, h, Blocks.dirt); - } - } - else if (mBlockhit == Blocks.carrots || mBlockhit == Blocks.melon_block || mBlockhit == Blocks.pumpkin || mBlockhit == Blocks.potatoes){ - worldObj.setBlock(i, j+1, h, Blocks.fire); - worldObj.setBlock(i, j, h, Blocks.dirt); - } - else if (mBlockhit == Blocks.air){ - worldObj.setBlock(i, j, h, Blocks.fire); - } - } - } - } - } - - - return true; - } - - -} \ No newline at end of file + public EntitySulfuricAcidPotion(World world) { + super(world); + } + + public EntitySulfuricAcidPotion(World world, EntityLivingBase entity) { + super(world, entity); + } + + public EntitySulfuricAcidPotion(World world, double posX, double posY, double posZ) { + super(world, posX, posY, posZ); + } + + /** + * Called when this EntityThrowable hits a block or entity. + */ + @Override + protected void onImpact(MovingObjectPosition object) { + int xBlock = object.blockX; + int yBlock = object.blockY; + int zBlock = object.blockZ; + if (object.entityHit != null) { + byte b0 = 6; + if (!GT_Utility.isWearingFullRadioHazmat((EntityLivingBase) object.entityHit)) { + object.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), b0); + EntityUtils.setEntityOnFire(object.entityHit, 10); + object.entityHit.fireResistance = 0; + ravage(EntityUtils.findBlockPosUnderEntity(object.entityHit)); + } + } + if (object.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + ravage(new BlockPos(xBlock, yBlock, zBlock)); + } + + String mParticleType = "reddust"; + int e = 0; + for (int i = 0; i < 24; ++i) { + if ((e = MathUtils.randInt(0, 5)) <= 1) { + if (e == 0) mParticleType = "largesmoke"; + if (e == 1) mParticleType = "flame"; + } + this.worldObj.spawnParticle( + mParticleType, + this.posX + MathUtils.randDouble(-2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + } + + if (!this.worldObj.isRemote) { + this.setDead(); + } + } + + private boolean ravage(BlockPos blockpos) { + + int radius = 1; + + for (int i = (blockpos.xPos - radius); i < (blockpos.xPos + radius); i++) { + for (int j = (blockpos.yPos - radius); j < (blockpos.yPos + radius); j++) { + for (int h = (blockpos.zPos - radius); h < (blockpos.zPos + radius); h++) { + + int mChance = MathUtils.randInt(1, 10); + if (mChance <= 3) { + Block mBlockhit = worldObj.getBlock(i, j, h); + this.worldObj.spawnParticle( + "flame", + this.posX + MathUtils.randDouble(-2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largesmoke", + this.posX + MathUtils.randDouble(2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + + // GT_Pollution.addPollution(worldObj.getChunkFromBlockCoords(blockpos.xPos, blockpos.zPos), + // mPol); + + if (mBlockhit == Blocks.grass || mBlockhit == Blocks.mycelium) { + worldObj.setBlock(i, j + 1, h, Blocks.fire); + worldObj.setBlock(i, j, h, Blocks.dirt); + } else if (mBlockhit == Blocks.leaves || mBlockhit == Blocks.leaves2) { + worldObj.setBlock(i, j, h, Blocks.fire); + } else if (mBlockhit == Blocks.tallgrass) { + worldObj.setBlock(i, j, h, Blocks.fire); + if (worldObj.getBlock(i, j - 1, h) == Blocks.grass) { + worldObj.setBlock(i, j - 1, h, Blocks.dirt); + } + } else if (mBlockhit == Blocks.carrots + || mBlockhit == Blocks.melon_block + || mBlockhit == Blocks.pumpkin + || mBlockhit == Blocks.potatoes) { + worldObj.setBlock(i, j + 1, h, Blocks.fire); + worldObj.setBlock(i, j, h, Blocks.dirt); + } else if (mBlockhit == Blocks.air) { + worldObj.setBlock(i, j, h, Blocks.fire); + } + } + } + } + } + + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/entity/projectile/EntityThrowableBomb.java b/src/main/java/gtPlusPlus/core/entity/projectile/EntityThrowableBomb.java index 49daa459e0..c7003d1f0c 100644 --- a/src/main/java/gtPlusPlus/core/entity/projectile/EntityThrowableBomb.java +++ b/src/main/java/gtPlusPlus/core/entity/projectile/EntityThrowableBomb.java @@ -1,5 +1,10 @@ package gtPlusPlus.core.entity.projectile; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.EntityUtils; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.projectile.EntityThrowable; @@ -8,138 +13,301 @@ import net.minecraft.util.DamageSource; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; -import gregtech.api.util.GT_Utility; - -import gtPlusPlus.api.objects.minecraft.BlockPos; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.EntityUtils; -import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; - public class EntityThrowableBomb extends EntityThrowable { - public EntityThrowableBomb(World world) { - super(world); - } - - public EntityThrowableBomb(World world, EntityLivingBase entity) { - super(world, entity); - } - - public EntityThrowableBomb(World world, double posX, double posY, double posZ) { - super(world, posX, posY, posZ); - } - - /** - * Called when this EntityThrowable hits a block or entity. - */ - @Override - protected void onImpact(MovingObjectPosition object) { - int xBlock = object.blockX; - int yBlock = object.blockY; - int zBlock = object.blockZ; - if (object.entityHit != null) { - byte b0 = 6; - if (!GT_Utility.isWearingFullRadioHazmat((EntityLivingBase) object.entityHit)){ - object.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 20); - EntityUtils.setEntityOnFire(object.entityHit, 20); - object.entityHit.fireResistance = 0; - ravage(EntityUtils.findBlockPosUnderEntity(object.entityHit)); - } - } - if (object.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK){ + public EntityThrowableBomb(World world) { + super(world); + } - ravage(new BlockPos(xBlock, yBlock, zBlock)); - for (BlockPos aSur : new BlockPos(xBlock, yBlock, zBlock).getSurroundingBlocks()) { - ravage(new BlockPos(aSur.xPos, aSur.yPos, aSur.zPos)); - for (BlockPos aSur2 : new BlockPos(aSur.xPos, aSur.yPos, aSur.zPos).getSurroundingBlocks()) { - //ravage(new BlockPos(aSur2.xPos, aSur2.yPos, aSur2.zPos)); - } - } - } + public EntityThrowableBomb(World world, EntityLivingBase entity) { + super(world, entity); + } - String mParticleType = "reddust"; - int e=0; - for (int i = 0; i < 127; ++i) { - if ((e = MathUtils.randInt(0, 5)) <= 1){ - if (e==0) - mParticleType = "largesmoke"; - if (e==1) - mParticleType = "flame"; - } - this.worldObj.spawnParticle(mParticleType, this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); - } + public EntityThrowableBomb(World world, double posX, double posY, double posZ) { + super(world, posX, posY, posZ); + } - if (!this.worldObj.isRemote) { - this.setDead(); - } - } + /** + * Called when this EntityThrowable hits a block or entity. + */ + @Override + protected void onImpact(MovingObjectPosition object) { + int xBlock = object.blockX; + int yBlock = object.blockY; + int zBlock = object.blockZ; + if (object.entityHit != null) { + byte b0 = 6; + if (!GT_Utility.isWearingFullRadioHazmat((EntityLivingBase) object.entityHit)) { + object.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 20); + EntityUtils.setEntityOnFire(object.entityHit, 20); + object.entityHit.fireResistance = 0; + ravage(EntityUtils.findBlockPosUnderEntity(object.entityHit)); + } + } + if (object.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { - private boolean ravage(BlockPos blockpos){ + ravage(new BlockPos(xBlock, yBlock, zBlock)); + for (BlockPos aSur : new BlockPos(xBlock, yBlock, zBlock).getSurroundingBlocks()) { + ravage(new BlockPos(aSur.xPos, aSur.yPos, aSur.zPos)); + for (BlockPos aSur2 : new BlockPos(aSur.xPos, aSur.yPos, aSur.zPos).getSurroundingBlocks()) { + // ravage(new BlockPos(aSur2.xPos, aSur2.yPos, aSur2.zPos)); + } + } + } - int radius = 5; + String mParticleType = "reddust"; + int e = 0; + for (int i = 0; i < 127; ++i) { + if ((e = MathUtils.randInt(0, 5)) <= 1) { + if (e == 0) mParticleType = "largesmoke"; + if (e == 1) mParticleType = "flame"; + } + this.worldObj.spawnParticle( + mParticleType, + this.posX + MathUtils.randDouble(-2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + } - for (int i=(blockpos.xPos-radius);i<(blockpos.xPos+radius);i++){ - for (int j=(blockpos.yPos-radius);j<(blockpos.yPos+radius);j++){ - for (int h=(blockpos.zPos-radius);h<(blockpos.zPos+radius);h++){ + if (!this.worldObj.isRemote) { + this.setDead(); + } + } - int mChance = MathUtils.randInt(0, 100); - if (mChance <= 3){ - Block mBlockhit = worldObj.getBlock(i, j, h); - this.worldObj.spawnParticle("flame", this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("largesmoke", this.posX+MathUtils.randDouble(2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("flame", this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("largesmoke", this.posX+MathUtils.randDouble(2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("flame", this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("largesmoke", this.posX+MathUtils.randDouble(2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("flame", this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("largesmoke", this.posX+MathUtils.randDouble(2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("flame", this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("largesmoke", this.posX+MathUtils.randDouble(2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("flame", this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("largesmoke", this.posX+MathUtils.randDouble(2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("flame", this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("largesmoke", this.posX+MathUtils.randDouble(2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("flame", this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("largesmoke", this.posX+MathUtils.randDouble(2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("flame", this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("largesmoke", this.posX+MathUtils.randDouble(2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("flame", this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("largesmoke", this.posX+MathUtils.randDouble(2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("flame", this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("largesmoke", this.posX+MathUtils.randDouble(2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("flame", this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("largesmoke", this.posX+MathUtils.randDouble(2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); + private boolean ravage(BlockPos blockpos) { - PollutionUtils.addPollution(worldObj.getChunkFromBlockCoords(blockpos.xPos, blockpos.zPos), 500); - this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 0.01f, true); - if (mBlockhit == Blocks.grass || mBlockhit == Blocks.mycelium){ - worldObj.setBlock(i, j+1, h, Blocks.fire); - worldObj.setBlock(i, j, h, Blocks.dirt); - } - else if (mBlockhit == Blocks.leaves || mBlockhit == Blocks.leaves2){ - worldObj.setBlock(i, j, h, Blocks.fire); - } - else if (mBlockhit == Blocks.tallgrass){ - worldObj.setBlock(i, j, h, Blocks.fire); - if (worldObj.getBlock(i, j-1, h) == Blocks.grass){ - worldObj.setBlock(i, j-1, h, Blocks.dirt); - } - } - else if (mBlockhit == Blocks.carrots || mBlockhit == Blocks.melon_block || mBlockhit == Blocks.pumpkin || mBlockhit == Blocks.potatoes){ - worldObj.setBlock(i, j+1, h, Blocks.fire); - worldObj.setBlock(i, j, h, Blocks.dirt); - } - else if (mBlockhit == Blocks.air){ - worldObj.setBlock(i, j, h, Blocks.fire); - } - } - } - } - } + int radius = 5; + for (int i = (blockpos.xPos - radius); i < (blockpos.xPos + radius); i++) { + for (int j = (blockpos.yPos - radius); j < (blockpos.yPos + radius); j++) { + for (int h = (blockpos.zPos - radius); h < (blockpos.zPos + radius); h++) { - return true; - } + int mChance = MathUtils.randInt(0, 100); + if (mChance <= 3) { + Block mBlockhit = worldObj.getBlock(i, j, h); + this.worldObj.spawnParticle( + "flame", + this.posX + MathUtils.randDouble(-2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largesmoke", + this.posX + MathUtils.randDouble(2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "flame", + this.posX + MathUtils.randDouble(-2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largesmoke", + this.posX + MathUtils.randDouble(2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "flame", + this.posX + MathUtils.randDouble(-2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largesmoke", + this.posX + MathUtils.randDouble(2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "flame", + this.posX + MathUtils.randDouble(-2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largesmoke", + this.posX + MathUtils.randDouble(2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "flame", + this.posX + MathUtils.randDouble(-2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largesmoke", + this.posX + MathUtils.randDouble(2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "flame", + this.posX + MathUtils.randDouble(-2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largesmoke", + this.posX + MathUtils.randDouble(2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "flame", + this.posX + MathUtils.randDouble(-2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largesmoke", + this.posX + MathUtils.randDouble(2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "flame", + this.posX + MathUtils.randDouble(-2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largesmoke", + this.posX + MathUtils.randDouble(2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "flame", + this.posX + MathUtils.randDouble(-2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largesmoke", + this.posX + MathUtils.randDouble(2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "flame", + this.posX + MathUtils.randDouble(-2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largesmoke", + this.posX + MathUtils.randDouble(2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "flame", + this.posX + MathUtils.randDouble(-2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largesmoke", + this.posX + MathUtils.randDouble(2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "flame", + this.posX + MathUtils.randDouble(-2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largesmoke", + this.posX + MathUtils.randDouble(2, 2), + this.posY + MathUtils.randDouble(-2, 2), + this.posZ + MathUtils.randDouble(-2, 2), + 0.0D, + 0.0D, + 0.0D); + PollutionUtils.addPollution( + worldObj.getChunkFromBlockCoords(blockpos.xPos, blockpos.zPos), 500); + this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 0.01f, true); + if (mBlockhit == Blocks.grass || mBlockhit == Blocks.mycelium) { + worldObj.setBlock(i, j + 1, h, Blocks.fire); + worldObj.setBlock(i, j, h, Blocks.dirt); + } else if (mBlockhit == Blocks.leaves || mBlockhit == Blocks.leaves2) { + worldObj.setBlock(i, j, h, Blocks.fire); + } else if (mBlockhit == Blocks.tallgrass) { + worldObj.setBlock(i, j, h, Blocks.fire); + if (worldObj.getBlock(i, j - 1, h) == Blocks.grass) { + worldObj.setBlock(i, j - 1, h, Blocks.dirt); + } + } else if (mBlockhit == Blocks.carrots + || mBlockhit == Blocks.melon_block + || mBlockhit == Blocks.pumpkin + || mBlockhit == Blocks.potatoes) { + worldObj.setBlock(i, j + 1, h, Blocks.fire); + worldObj.setBlock(i, j, h, Blocks.dirt); + } else if (mBlockhit == Blocks.air) { + worldObj.setBlock(i, j, h, Blocks.fire); + } + } + } + } + } -} \ No newline at end of file + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/entity/projectile/EntityToxinball.java b/src/main/java/gtPlusPlus/core/entity/projectile/EntityToxinball.java index 4fe72345b2..7d137738be 100644 --- a/src/main/java/gtPlusPlus/core/entity/projectile/EntityToxinball.java +++ b/src/main/java/gtPlusPlus/core/entity/projectile/EntityToxinball.java @@ -1,10 +1,8 @@ package gtPlusPlus.core.entity.projectile; -import java.util.List; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import java.util.List; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -15,313 +13,316 @@ import net.minecraft.util.*; import net.minecraft.world.World; public abstract class EntityToxinball extends EntityFireball { - protected int entityX = -1; - protected int entityY = -1; - protected int entityZ = -1; - private Block block; - private boolean inGround; - private int ticksAlive; - private int ticksInAir; - - public EntityToxinball(World world) { - super(world); - this.setSize(1.0F, 1.0F); - } - - @Override - protected void entityInit() { - } - - /** - * Checks if the entity is in range to render by using the past in distance - * and comparing it to its average edge length * 64 * renderDistanceWeight - * Args: distance - */ - @Override - @SideOnly(Side.CLIENT) - public boolean isInRangeToRenderDist(double p_70112_1_) { - double d1 = this.boundingBox.getAverageEdgeLength() * 4.0D; - d1 *= 64.0D; - return p_70112_1_ < d1 * d1; - } - - public EntityToxinball(World world, double x, double y, double z, double f1, double f2, double f3) { - super(world); - this.setSize(1.0F, 1.0F); - this.setLocationAndAngles(x, y, z, this.rotationYaw, this.rotationPitch); - this.setPosition(x, y, z); - double d6 = MathHelper - .sqrt_double(f1 * f1 + f2 * f2 + f3 * f3); - this.accelerationX = f1 / d6 * 0.1D; - this.accelerationY = f2 / d6 * 0.1D; - this.accelerationZ = f3 / d6 * 0.1D; - } - - public EntityToxinball(World world, EntityLivingBase entity, double x, double y, double z) { - super(world); - this.shootingEntity = entity; - this.setSize(1.0F, 1.0F); - this.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, - entity.rotationPitch); - this.setPosition(this.entityX, this.entityY, this.entityZ); - this.yOffset = 0.0F; - this.motionX = this.motionY = this.motionZ = 0.0D; - x += this.rand.nextGaussian() * 0.4D; - y += this.rand.nextGaussian() * 0.4D; - z += this.rand.nextGaussian() * 0.4D; - double d3 = MathHelper.sqrt_double(x * x + y * y + z * z); - this.accelerationX = x / d3 * 0.1D; - this.accelerationY = y / d3 * 0.1D; - this.accelerationZ = z / d3 * 0.1D; - } - - /** - * Called to update the entity's position/logic. - */ - @Override - public void onUpdate() { - if (!this.worldObj.isRemote && (this.shootingEntity != null && this.shootingEntity.isDead - || !this.worldObj.blockExists(this.entityX, this.entityY, this.entityZ))) { - this.setDead(); - } - else { - super.onUpdate(); - this.setFire(1); - - if (this.inGround) { - if (this.worldObj.getBlock(this.entityX, this.entityY, - this.entityZ) == this.block) { - ++this.ticksAlive; - - if (this.ticksAlive == 600) { - this.setDead(); - } - - return; - } - - this.inGround = false; - this.motionX *= this.rand.nextFloat() * 0.2F; - this.motionY *= this.rand.nextFloat() * 0.2F; - this.motionZ *= this.rand.nextFloat() * 0.2F; - this.ticksAlive = 0; - this.ticksInAir = 0; - } - else { - ++this.ticksInAir; - } - - Vec3 vec3 = Vec3.createVectorHelper(this.entityX, this.entityY, this.entityZ); - Vec3 vec31 = Vec3.createVectorHelper(this.entityX + this.motionX, this.entityY + this.motionY, - this.entityZ + this.motionZ); - MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks(vec3, vec31); - vec3 = Vec3.createVectorHelper(this.entityX, this.entityY, this.entityZ); - vec31 = Vec3.createVectorHelper(this.entityX + this.motionX, this.entityY + this.motionY, - this.entityZ + this.motionZ); - - if (movingobjectposition != null) { - vec31 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, - movingobjectposition.hitVec.zCoord); - } - - Entity entity = null; - List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, - this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D)); - double d0 = 0.0D; - - for (int i = 0; i < list.size(); ++i) { - Entity entity1 = (Entity) list.get(i); - - if (entity1.canBeCollidedWith() - && (!entity1.isEntityEqual(this.shootingEntity) || this.ticksInAir >= 25)) { - float f = 0.3F; - AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f, f, f); - MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31); - - if (movingobjectposition1 != null) { - double d1 = vec3.distanceTo(movingobjectposition1.hitVec); - - if (d1 < d0 || d0 == 0.0D) { - entity = entity1; - d0 = d1; - } - } - } - } - - if (entity != null) { - movingobjectposition = new MovingObjectPosition(entity); - } - - if (movingobjectposition != null) { - this.onImpact(movingobjectposition); - } - - this.entityX += this.motionX; - this.entityY += this.motionY; - this.entityZ += this.motionZ; - float f1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); - this.rotationYaw = (float) (Math.atan2(this.motionZ, this.motionX) * 180.0D / Math.PI) + 90.0F; - - for (this.rotationPitch = (float) (Math.atan2(f1, this.motionY) * 180.0D / Math.PI) - - 90.0F; this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) { - ; - } - - while (this.rotationPitch - this.prevRotationPitch >= 180.0F) { - this.prevRotationPitch += 360.0F; - } - - while (this.rotationYaw - this.prevRotationYaw < -180.0F) { - this.prevRotationYaw -= 360.0F; - } - - while (this.rotationYaw - this.prevRotationYaw >= 180.0F) { - this.prevRotationYaw += 360.0F; - } - - this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; - this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; - float f2 = this.getMotionFactor(); - - if (this.isInWater()) { - for (int j = 0; j < 4; ++j) { - float f3 = 0.25F; - this.worldObj.spawnParticle("bubble", this.entityX - this.motionX * f3, this.entityY - this.motionY * f3, - this.entityZ - this.motionZ * f3, this.motionX, this.motionY, this.motionZ); - } - - f2 = 0.8F; - } - - this.motionX += this.accelerationX; - this.motionY += this.accelerationY; - this.motionZ += this.accelerationZ; - this.motionX *= f2; - this.motionY *= f2; - this.motionZ *= f2; - this.worldObj.spawnParticle("smoke", this.entityX, this.entityY + 0.5D, this.entityZ, 0.0D, 0.0D, 0.0D); - this.setPosition(this.entityX, this.entityY, this.entityZ); - } - } - - /** - * Return the motion factor for this projectile. The factor is multiplied by - * the original motion. - */ - @Override - protected float getMotionFactor() { - return 0.95F; - } - - /** - * Called when this EntityFireball hits a block or entity. - */ - @Override - protected abstract void onImpact(MovingObjectPosition p_70227_1_); - - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ - @Override - public void writeEntityToNBT(NBTTagCompound aTag) { - aTag.setShort("xTile", (short) this.entityX); - aTag.setShort("yTile", (short) this.entityY); - aTag.setShort("zTile", (short) this.entityZ); - aTag.setByte("inTile", (byte) Block.getIdFromBlock(this.block)); - aTag.setByte("inGround", (byte) (this.inGround ? 1 : 0)); - aTag.setTag("direction", - this.newDoubleNBTList(new double[] { this.motionX, this.motionY, this.motionZ })); - } - - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - @Override - public void readEntityFromNBT(NBTTagCompound aTag) { - this.entityX = aTag.getShort("xTile"); - this.entityY = aTag.getShort("yTile"); - this.entityZ = aTag.getShort("zTile"); - this.block = Block.getBlockById(aTag.getByte("inTile") & 255); - this.inGround = aTag.getByte("inGround") == 1; - - if (aTag.hasKey("direction", 9)) { - NBTTagList nbttaglist = aTag.getTagList("direction", 6); - this.motionX = nbttaglist.func_150309_d(0); - this.motionY = nbttaglist.func_150309_d(1); - this.motionZ = nbttaglist.func_150309_d(2); - } - else { - this.setDead(); - } - } - - /** - * Returns true if other Entities should be prevented from moving through - * this Entity. - */ - @Override - public boolean canBeCollidedWith() { - return true; - } - - @Override - public float getCollisionBorderSize() { - return 1.0F; - } - - /** - * Called when the entity is attacked. - */ - @Override - public boolean attackEntityFrom(DamageSource damage, float p_70097_2_) { - if (this.isEntityInvulnerable()) { - return false; - } - else { - this.setBeenAttacked(); - - if (damage.getEntity() != null) { - Vec3 vec3 = damage.getEntity().getLookVec(); - - if (vec3 != null) { - this.motionX = vec3.xCoord; - this.motionY = vec3.yCoord; - this.motionZ = vec3.zCoord; - this.accelerationX = this.motionX * 0.1D; - this.accelerationY = this.motionY * 0.1D; - this.accelerationZ = this.motionZ * 0.1D; - } - - if (damage.getEntity() instanceof EntityLivingBase) { - this.shootingEntity = (EntityLivingBase) damage.getEntity(); - } - - return true; - } - else { - return false; - } - } - } - - @Override - @SideOnly(Side.CLIENT) - public float getShadowSize() { - return 0.0F; - } - - /** - * Gets how bright this entity is. - */ - @Override - public float getBrightness(float p_70013_1_) { - return 1.0F; - } - - @Override - @SideOnly(Side.CLIENT) - public int getBrightnessForRender(float p_70070_1_) { - return 15728880; - } -} \ No newline at end of file + protected int entityX = -1; + protected int entityY = -1; + protected int entityZ = -1; + private Block block; + private boolean inGround; + private int ticksAlive; + private int ticksInAir; + + public EntityToxinball(World world) { + super(world); + this.setSize(1.0F, 1.0F); + } + + @Override + protected void entityInit() {} + + /** + * Checks if the entity is in range to render by using the past in distance + * and comparing it to its average edge length * 64 * renderDistanceWeight + * Args: distance + */ + @Override + @SideOnly(Side.CLIENT) + public boolean isInRangeToRenderDist(double p_70112_1_) { + double d1 = this.boundingBox.getAverageEdgeLength() * 4.0D; + d1 *= 64.0D; + return p_70112_1_ < d1 * d1; + } + + public EntityToxinball(World world, double x, double y, double z, double f1, double f2, double f3) { + super(world); + this.setSize(1.0F, 1.0F); + this.setLocationAndAngles(x, y, z, this.rotationYaw, this.rotationPitch); + this.setPosition(x, y, z); + double d6 = MathHelper.sqrt_double(f1 * f1 + f2 * f2 + f3 * f3); + this.accelerationX = f1 / d6 * 0.1D; + this.accelerationY = f2 / d6 * 0.1D; + this.accelerationZ = f3 / d6 * 0.1D; + } + + public EntityToxinball(World world, EntityLivingBase entity, double x, double y, double z) { + super(world); + this.shootingEntity = entity; + this.setSize(1.0F, 1.0F); + this.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch); + this.setPosition(this.entityX, this.entityY, this.entityZ); + this.yOffset = 0.0F; + this.motionX = this.motionY = this.motionZ = 0.0D; + x += this.rand.nextGaussian() * 0.4D; + y += this.rand.nextGaussian() * 0.4D; + z += this.rand.nextGaussian() * 0.4D; + double d3 = MathHelper.sqrt_double(x * x + y * y + z * z); + this.accelerationX = x / d3 * 0.1D; + this.accelerationY = y / d3 * 0.1D; + this.accelerationZ = z / d3 * 0.1D; + } + + /** + * Called to update the entity's position/logic. + */ + @Override + public void onUpdate() { + if (!this.worldObj.isRemote + && (this.shootingEntity != null && this.shootingEntity.isDead + || !this.worldObj.blockExists(this.entityX, this.entityY, this.entityZ))) { + this.setDead(); + } else { + super.onUpdate(); + this.setFire(1); + + if (this.inGround) { + if (this.worldObj.getBlock(this.entityX, this.entityY, this.entityZ) == this.block) { + ++this.ticksAlive; + + if (this.ticksAlive == 600) { + this.setDead(); + } + + return; + } + + this.inGround = false; + this.motionX *= this.rand.nextFloat() * 0.2F; + this.motionY *= this.rand.nextFloat() * 0.2F; + this.motionZ *= this.rand.nextFloat() * 0.2F; + this.ticksAlive = 0; + this.ticksInAir = 0; + } else { + ++this.ticksInAir; + } + + Vec3 vec3 = Vec3.createVectorHelper(this.entityX, this.entityY, this.entityZ); + Vec3 vec31 = Vec3.createVectorHelper( + this.entityX + this.motionX, this.entityY + this.motionY, this.entityZ + this.motionZ); + MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks(vec3, vec31); + vec3 = Vec3.createVectorHelper(this.entityX, this.entityY, this.entityZ); + vec31 = Vec3.createVectorHelper( + this.entityX + this.motionX, this.entityY + this.motionY, this.entityZ + this.motionZ); + + if (movingobjectposition != null) { + vec31 = Vec3.createVectorHelper( + movingobjectposition.hitVec.xCoord, + movingobjectposition.hitVec.yCoord, + movingobjectposition.hitVec.zCoord); + } + + Entity entity = null; + List list = this.worldObj.getEntitiesWithinAABBExcludingEntity( + this, + this.boundingBox + .addCoord(this.motionX, this.motionY, this.motionZ) + .expand(1.0D, 1.0D, 1.0D)); + double d0 = 0.0D; + + for (int i = 0; i < list.size(); ++i) { + Entity entity1 = (Entity) list.get(i); + + if (entity1.canBeCollidedWith() + && (!entity1.isEntityEqual(this.shootingEntity) || this.ticksInAir >= 25)) { + float f = 0.3F; + AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f, f, f); + MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31); + + if (movingobjectposition1 != null) { + double d1 = vec3.distanceTo(movingobjectposition1.hitVec); + + if (d1 < d0 || d0 == 0.0D) { + entity = entity1; + d0 = d1; + } + } + } + } + + if (entity != null) { + movingobjectposition = new MovingObjectPosition(entity); + } + + if (movingobjectposition != null) { + this.onImpact(movingobjectposition); + } + + this.entityX += this.motionX; + this.entityY += this.motionY; + this.entityZ += this.motionZ; + float f1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + this.rotationYaw = (float) (Math.atan2(this.motionZ, this.motionX) * 180.0D / Math.PI) + 90.0F; + + for (this.rotationPitch = (float) (Math.atan2(f1, this.motionY) * 180.0D / Math.PI) - 90.0F; + this.rotationPitch - this.prevRotationPitch < -180.0F; + this.prevRotationPitch -= 360.0F) { + ; + } + + while (this.rotationPitch - this.prevRotationPitch >= 180.0F) { + this.prevRotationPitch += 360.0F; + } + + while (this.rotationYaw - this.prevRotationYaw < -180.0F) { + this.prevRotationYaw -= 360.0F; + } + + while (this.rotationYaw - this.prevRotationYaw >= 180.0F) { + this.prevRotationYaw += 360.0F; + } + + this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; + this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; + float f2 = this.getMotionFactor(); + + if (this.isInWater()) { + for (int j = 0; j < 4; ++j) { + float f3 = 0.25F; + this.worldObj.spawnParticle( + "bubble", + this.entityX - this.motionX * f3, + this.entityY - this.motionY * f3, + this.entityZ - this.motionZ * f3, + this.motionX, + this.motionY, + this.motionZ); + } + + f2 = 0.8F; + } + + this.motionX += this.accelerationX; + this.motionY += this.accelerationY; + this.motionZ += this.accelerationZ; + this.motionX *= f2; + this.motionY *= f2; + this.motionZ *= f2; + this.worldObj.spawnParticle("smoke", this.entityX, this.entityY + 0.5D, this.entityZ, 0.0D, 0.0D, 0.0D); + this.setPosition(this.entityX, this.entityY, this.entityZ); + } + } + + /** + * Return the motion factor for this projectile. The factor is multiplied by + * the original motion. + */ + @Override + protected float getMotionFactor() { + return 0.95F; + } + + /** + * Called when this EntityFireball hits a block or entity. + */ + @Override + protected abstract void onImpact(MovingObjectPosition p_70227_1_); + + /** + * (abstract) Protected helper method to write subclass entity data to NBT. + */ + @Override + public void writeEntityToNBT(NBTTagCompound aTag) { + aTag.setShort("xTile", (short) this.entityX); + aTag.setShort("yTile", (short) this.entityY); + aTag.setShort("zTile", (short) this.entityZ); + aTag.setByte("inTile", (byte) Block.getIdFromBlock(this.block)); + aTag.setByte("inGround", (byte) (this.inGround ? 1 : 0)); + aTag.setTag("direction", this.newDoubleNBTList(new double[] {this.motionX, this.motionY, this.motionZ})); + } + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + @Override + public void readEntityFromNBT(NBTTagCompound aTag) { + this.entityX = aTag.getShort("xTile"); + this.entityY = aTag.getShort("yTile"); + this.entityZ = aTag.getShort("zTile"); + this.block = Block.getBlockById(aTag.getByte("inTile") & 255); + this.inGround = aTag.getByte("inGround") == 1; + + if (aTag.hasKey("direction", 9)) { + NBTTagList nbttaglist = aTag.getTagList("direction", 6); + this.motionX = nbttaglist.func_150309_d(0); + this.motionY = nbttaglist.func_150309_d(1); + this.motionZ = nbttaglist.func_150309_d(2); + } else { + this.setDead(); + } + } + + /** + * Returns true if other Entities should be prevented from moving through + * this Entity. + */ + @Override + public boolean canBeCollidedWith() { + return true; + } + + @Override + public float getCollisionBorderSize() { + return 1.0F; + } + + /** + * Called when the entity is attacked. + */ + @Override + public boolean attackEntityFrom(DamageSource damage, float p_70097_2_) { + if (this.isEntityInvulnerable()) { + return false; + } else { + this.setBeenAttacked(); + + if (damage.getEntity() != null) { + Vec3 vec3 = damage.getEntity().getLookVec(); + + if (vec3 != null) { + this.motionX = vec3.xCoord; + this.motionY = vec3.yCoord; + this.motionZ = vec3.zCoord; + this.accelerationX = this.motionX * 0.1D; + this.accelerationY = this.motionY * 0.1D; + this.accelerationZ = this.motionZ * 0.1D; + } + + if (damage.getEntity() instanceof EntityLivingBase) { + this.shootingEntity = (EntityLivingBase) damage.getEntity(); + } + + return true; + } else { + return false; + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public float getShadowSize() { + return 0.0F; + } + + /** + * Gets how bright this entity is. + */ + @Override + public float getBrightness(float p_70013_1_) { + return 1.0F; + } + + @Override + @SideOnly(Side.CLIENT) + public int getBrightnessForRender(float p_70070_1_) { + return 15728880; + } +} diff --git a/src/main/java/gtPlusPlus/core/entity/projectile/EntityToxinballSmall.java b/src/main/java/gtPlusPlus/core/entity/projectile/EntityToxinballSmall.java index 78469c9dad..2321411a2b 100644 --- a/src/main/java/gtPlusPlus/core/entity/projectile/EntityToxinballSmall.java +++ b/src/main/java/gtPlusPlus/core/entity/projectile/EntityToxinballSmall.java @@ -8,81 +8,88 @@ import net.minecraft.world.World; public class EntityToxinballSmall extends EntityToxinball { - public EntityToxinballSmall(World p_i1770_1_) { - super(p_i1770_1_); - this.setSize(0.3125F, 0.3125F); - } + public EntityToxinballSmall(World p_i1770_1_) { + super(p_i1770_1_); + this.setSize(0.3125F, 0.3125F); + } - public EntityToxinballSmall(World world, EntityLivingBase entity, double x, double y, double z) { - super(world, entity, x, y, z); - this.setSize(0.3125F, 0.3125F); - } + public EntityToxinballSmall(World world, EntityLivingBase entity, double x, double y, double z) { + super(world, entity, x, y, z); + this.setSize(0.3125F, 0.3125F); + } - public EntityToxinballSmall(World p_i1772_1_, double p_i1772_2_, double p_i1772_4_, double p_i1772_6_, double p_i1772_8_, double p_i1772_10_, double p_i1772_12_) { - super(p_i1772_1_, p_i1772_2_, p_i1772_4_, p_i1772_6_, p_i1772_8_, p_i1772_10_, p_i1772_12_); - this.setSize(0.3125F, 0.3125F); - } + public EntityToxinballSmall( + World p_i1772_1_, + double p_i1772_2_, + double p_i1772_4_, + double p_i1772_6_, + double p_i1772_8_, + double p_i1772_10_, + double p_i1772_12_) { + super(p_i1772_1_, p_i1772_2_, p_i1772_4_, p_i1772_6_, p_i1772_8_, p_i1772_10_, p_i1772_12_); + this.setSize(0.3125F, 0.3125F); + } - /** - * Called when this EntityFireball hits a block or entity. - */ - @Override - protected void onImpact(MovingObjectPosition MoP) { - if (!this.worldObj.isRemote) { - if (MoP.entityHit != null) { - if (!MoP.entityHit.isImmuneToFire() && MoP.entityHit - .attackEntityFrom(DamageSource.causeFireballDamage(this, this.shootingEntity), 5.0F)) { - MoP.entityHit.setFire(5); - } - } - else { - int i = MoP.blockX; - int j = MoP.blockY; - int k = MoP.blockZ; + /** + * Called when this EntityFireball hits a block or entity. + */ + @Override + protected void onImpact(MovingObjectPosition MoP) { + if (!this.worldObj.isRemote) { + if (MoP.entityHit != null) { + if (!MoP.entityHit.isImmuneToFire() + && MoP.entityHit.attackEntityFrom( + DamageSource.causeFireballDamage(this, this.shootingEntity), 5.0F)) { + MoP.entityHit.setFire(5); + } + } else { + int i = MoP.blockX; + int j = MoP.blockY; + int k = MoP.blockZ; - switch (MoP.sideHit) { - case 0: - --j; - break; - case 1: - ++j; - break; - case 2: - --k; - break; - case 3: - ++k; - break; - case 4: - --i; - break; - case 5: - ++i; - } + switch (MoP.sideHit) { + case 0: + --j; + break; + case 1: + ++j; + break; + case 2: + --k; + break; + case 3: + ++k; + break; + case 4: + --i; + break; + case 5: + ++i; + } - if (this.worldObj.isAirBlock(i, j, k)) { - this.worldObj.setBlock(i, j, k, Blocks.fire); - } - } + if (this.worldObj.isAirBlock(i, j, k)) { + this.worldObj.setBlock(i, j, k, Blocks.fire); + } + } - this.setDead(); - } - } + this.setDead(); + } + } - /** - * Returns true if other Entities should be prevented from moving through - * this Entity. - */ - @Override - public boolean canBeCollidedWith() { - return false; - } + /** + * Returns true if other Entities should be prevented from moving through + * this Entity. + */ + @Override + public boolean canBeCollidedWith() { + return false; + } - /** - * Called when the entity is attacked. - */ - @Override - public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_) { - return false; - } -} \ No newline at end of file + /** + * Called when the entity is attacked. + */ + @Override + public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_) { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/core/fluids/BlockFluidBase.java b/src/main/java/gtPlusPlus/core/fluids/BlockFluidBase.java index dc7c9c2e78..d8672dec2b 100644 --- a/src/main/java/gtPlusPlus/core/fluids/BlockFluidBase.java +++ b/src/main/java/gtPlusPlus/core/fluids/BlockFluidBase.java @@ -17,88 +17,87 @@ import net.minecraftforge.fluids.Fluid; public class BlockFluidBase extends BlockFluidClassic { - @SideOnly(Side.CLIENT) - protected static IIcon stillIcon; - @SideOnly(Side.CLIENT) - protected static IIcon flowingIcon; - - protected final short[] mRGB; - - - public BlockFluidBase(Fluid fluid, short[] aRGB) { - this(fluid, Material.water, aRGB); - } - - public BlockFluidBase(Fluid fluid, Material material, short[] aRGB) { - super(fluid, material); - mRGB = aRGB; - this.setHardness(100.0F); - this.setLightOpacity(3); - this.disableStats(); - } - - @Override - public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity ent) { - if (!(ent instanceof EntityLivingBase)) { - return; - } - /*EntityLivingBase player = (EntityLivingBase) ent; - int pot = world.rand.nextInt(Potion.potionTypes.length); - Potion.potionTypes[pot].performEffect(player, 40);*/ - } - - @Override - public IIcon getIcon(int side, int meta) { - return (side == 0 || side == 1) ? stillIcon : flowingIcon; - } - - @SideOnly(Side.CLIENT) - @Override - public void registerBlockIcons(IIconRegister register) { - if (stillIcon == null) { - stillIcon = register.registerIcon(CORE.MODID+ ":" + "fluids/fluid.fluid.autogenerated.still"); - } - if (flowingIcon == null) { - flowingIcon = register.registerIcon(CORE.MODID+ ":" + "fluids/fluid.fluid.autogenerated.flowing"); - } - } - - @Override - public int getBlockColor() { - if (mRGB != null && mRGB.length >= 3) { - return Utils.rgbtoHexValue(mRGB[0], mRGB[1], mRGB[2]); - } - return super.getBlockColor(); - } - - @Override - public int getRenderColor(int aMeta) { - if (mRGB != null && mRGB.length >= 3) { - return Utils.rgbtoHexValue(mRGB[0], mRGB[1], mRGB[2]); - } - return super.getRenderColor(aMeta); - } - - @Override - public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour) { - // TODO Auto-generated method stub - return super.recolourBlock(world, x, y, z, side, colour); - } - - @Override - public boolean canDisplace(IBlockAccess world, int x, int y, int z) { - if (world.getBlock(x, y, z).getMaterial().isLiquid()) { - return false; - } - return super.canDisplace(world, x, y, z); - } - - @Override - public boolean displaceIfPossible(World world, int x, int y, int z) { - if (world.getBlock(x, y, z).getMaterial().isLiquid()) { - return false; - } - return super.displaceIfPossible(world, x, y, z); - } - + @SideOnly(Side.CLIENT) + protected static IIcon stillIcon; + + @SideOnly(Side.CLIENT) + protected static IIcon flowingIcon; + + protected final short[] mRGB; + + public BlockFluidBase(Fluid fluid, short[] aRGB) { + this(fluid, Material.water, aRGB); + } + + public BlockFluidBase(Fluid fluid, Material material, short[] aRGB) { + super(fluid, material); + mRGB = aRGB; + this.setHardness(100.0F); + this.setLightOpacity(3); + this.disableStats(); + } + + @Override + public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity ent) { + if (!(ent instanceof EntityLivingBase)) { + return; + } + /*EntityLivingBase player = (EntityLivingBase) ent; + int pot = world.rand.nextInt(Potion.potionTypes.length); + Potion.potionTypes[pot].performEffect(player, 40);*/ + } + + @Override + public IIcon getIcon(int side, int meta) { + return (side == 0 || side == 1) ? stillIcon : flowingIcon; + } + + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(IIconRegister register) { + if (stillIcon == null) { + stillIcon = register.registerIcon(CORE.MODID + ":" + "fluids/fluid.fluid.autogenerated.still"); + } + if (flowingIcon == null) { + flowingIcon = register.registerIcon(CORE.MODID + ":" + "fluids/fluid.fluid.autogenerated.flowing"); + } + } + + @Override + public int getBlockColor() { + if (mRGB != null && mRGB.length >= 3) { + return Utils.rgbtoHexValue(mRGB[0], mRGB[1], mRGB[2]); + } + return super.getBlockColor(); + } + + @Override + public int getRenderColor(int aMeta) { + if (mRGB != null && mRGB.length >= 3) { + return Utils.rgbtoHexValue(mRGB[0], mRGB[1], mRGB[2]); + } + return super.getRenderColor(aMeta); + } + + @Override + public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour) { + // TODO Auto-generated method stub + return super.recolourBlock(world, x, y, z, side, colour); + } + + @Override + public boolean canDisplace(IBlockAccess world, int x, int y, int z) { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) { + return false; + } + return super.canDisplace(world, x, y, z); + } + + @Override + public boolean displaceIfPossible(World world, int x, int y, int z) { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) { + return false; + } + return super.displaceIfPossible(world, x, y, z); + } } diff --git a/src/main/java/gtPlusPlus/core/fluids/FactoryFluid.java b/src/main/java/gtPlusPlus/core/fluids/FactoryFluid.java index e3383aee91..59d0fd8839 100644 --- a/src/main/java/gtPlusPlus/core/fluids/FactoryFluid.java +++ b/src/main/java/gtPlusPlus/core/fluids/FactoryFluid.java @@ -1,4 +1,5 @@ package gtPlusPlus.core.fluids; + import gregtech.api.GregTech_API; import gtPlusPlus.core.lib.CORE; import net.minecraft.block.Block; @@ -7,43 +8,67 @@ import net.minecraftforge.fluids.Fluid; public class FactoryFluid extends Fluid implements Runnable { - private final String mTextureName; - private final short[] mRGBa; - - public FactoryFluid(String fluidName, final short[] aRGBa) { - this(fluidName, null, Short.MIN_VALUE, Short.MIN_VALUE, Short.MIN_VALUE, Short.MIN_VALUE, false, EnumRarity.common, aRGBa); - } - - public FactoryFluid(String fluidName, int luminosity, int density, int temp, int viscosity, final short[] aRGBa) { - this(fluidName, null, luminosity, density, temp, viscosity, (density == Short.MIN_VALUE || density >= 0 ? false : true), EnumRarity.common, aRGBa); - } - - public FactoryFluid(String fluidName, Block aBlock, int luminosity, int density, int temp, int viscosity, boolean gas, EnumRarity aRarity, final short[] aRGBa) { - super(fluidName); - this.mRGBa = aRGBa; - this.setBlock(aBlock); - if (luminosity != Short.MIN_VALUE) - this.setLuminosity(luminosity); - if (density != Short.MIN_VALUE) - this.setDensity(density); - if (temp != Short.MIN_VALUE) - this.setTemperature(temp); - if (viscosity != Short.MIN_VALUE) - this.setViscosity(viscosity); - this.setGaseous(gas); - this.setRarity(aRarity); - this.mTextureName = CORE.MODID+":fluids/fluid.fluid.autogenerated"; - GregTech_API.sGTBlockIconload.add(this); - } - - @Override - public int getColor() { - return (Math.max(0, Math.min(255, this.mRGBa[0])) << 16) | (Math.max(0, Math.min(255, this.mRGBa[1])) << 8) | Math.max(0, Math.min(255, this.mRGBa[2])); - } - - @Override - public void run() { - this.setIcons(GregTech_API.sBlockIcons.registerIcon(this.mTextureName)); - } - -} \ No newline at end of file + private final String mTextureName; + private final short[] mRGBa; + + public FactoryFluid(String fluidName, final short[] aRGBa) { + this( + fluidName, + null, + Short.MIN_VALUE, + Short.MIN_VALUE, + Short.MIN_VALUE, + Short.MIN_VALUE, + false, + EnumRarity.common, + aRGBa); + } + + public FactoryFluid(String fluidName, int luminosity, int density, int temp, int viscosity, final short[] aRGBa) { + this( + fluidName, + null, + luminosity, + density, + temp, + viscosity, + (density == Short.MIN_VALUE || density >= 0 ? false : true), + EnumRarity.common, + aRGBa); + } + + public FactoryFluid( + String fluidName, + Block aBlock, + int luminosity, + int density, + int temp, + int viscosity, + boolean gas, + EnumRarity aRarity, + final short[] aRGBa) { + super(fluidName); + this.mRGBa = aRGBa; + this.setBlock(aBlock); + if (luminosity != Short.MIN_VALUE) this.setLuminosity(luminosity); + if (density != Short.MIN_VALUE) this.setDensity(density); + if (temp != Short.MIN_VALUE) this.setTemperature(temp); + if (viscosity != Short.MIN_VALUE) this.setViscosity(viscosity); + this.setGaseous(gas); + this.setRarity(aRarity); + this.mTextureName = CORE.MODID + ":fluids/fluid.fluid.autogenerated"; + GregTech_API.sGTBlockIconload.add(this); + } + + @Override + public int getColor() { + return (Math.max(0, Math.min(255, this.mRGBa[0])) << 16) + | (Math.max(0, Math.min(255, this.mRGBa[1])) << 8) + | Math.max(0, Math.min(255, this.mRGBa[2])); + } + + @Override + public void run() { + this.setIcons(GregTech_API.sBlockIcons.registerIcon(this.mTextureName)); + } +} diff --git a/src/main/java/gtPlusPlus/core/fluids/FluidFactory.java b/src/main/java/gtPlusPlus/core/fluids/FluidFactory.java index d94fa35af7..af7a806d31 100644 --- a/src/main/java/gtPlusPlus/core/fluids/FluidFactory.java +++ b/src/main/java/gtPlusPlus/core/fluids/FluidFactory.java @@ -1,8 +1,5 @@ package gtPlusPlus.core.fluids; -import java.util.LinkedHashMap; -import java.util.Map; - import cpw.mods.fml.common.eventhandler.Event.Result; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.registry.GameRegistry; @@ -15,6 +12,8 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import java.util.LinkedHashMap; +import java.util.Map; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -29,186 +28,176 @@ import net.minecraftforge.fluids.FluidRegistry; public class FluidFactory { - public static final Map mNameToFluidMap = new LinkedHashMap(); - public static final Map mNameToBucketMap = new LinkedHashMap(); - public static final Map mNameToBlockMap = new LinkedHashMap(); - public static final Map mNameToMetaMap = new LinkedHashMap(); - - public static final Map mFluidToNameMap = new LinkedHashMap(); - public static final Map mFluidToBucketMap = new LinkedHashMap(); - public static final Map mFluidToBlockMap = new LinkedHashMap(); - public static final Map mFluidToMetaMap = new LinkedHashMap(); - - public static final Map mBucketToFluidMap = new LinkedHashMap(); - public static final Map mBucketToNameMap = new LinkedHashMap(); - public static final Map mBucketToBlockMap = new LinkedHashMap(); - public static final Map mBucketToMetaMap = new LinkedHashMap(); - - public static final Map mBlockToNameMap = new LinkedHashMap(); - public static final Map mBlockToFluidMap = new LinkedHashMap(); - public static final Map mBlockToBucketMap = new LinkedHashMap(); - public static final Map mBlockToMetaMap = new LinkedHashMap(); - - public static final Map mMetaToNameMap = new LinkedHashMap(); - public static final Map mMetaToFluidMap = new LinkedHashMap(); - public static final Map mMetaToBucketMap = new LinkedHashMap(); - public static final Map mMetaToBlockMap = new LinkedHashMap(); - - - //Special Colour Handling - public static final Map mMetaToColourMap = new LinkedHashMap(); - - - public static Item mGenericBucket; - private static FluidPackage mErrorFluid; - private static AutoMap mGeneratedFluids = new AutoMap(); - - public static void preInit() { - - } - - public static void init() { - mGenericBucket = new ItemGenericFluidBucket(Blocks.air); - GameRegistry.registerItem(mGenericBucket, "gtpp.bucket.generic"); - for (FluidPackage y : mGeneratedFluids) { - if (!y.valid()) { - continue; - } - GameRegistry.registerBlock(y.mBlock, FluidItemBlock.class, "gtpp_" + y.mName); - FluidContainerRegistry.registerFluidContainer(y.get(), y.mBucket, new ItemStack(Items.bucket)); - } - Utils.registerEvent(BucketHandler.INSTANCE); - } - - public static void postInit() { - - } - - /** - * Generates a 'Water' type fluid. - * @param aID - The Fluid ID (Must be unique) - * @param aUnlocalName - Unlocalized Fluid Name - * @param aRGB - a {@link Short[]} containing the RGB of the FluidPackage. - * @return - A fully constructed & registered {@linkplain FluidPackage} - */ - public static FluidPackage generate(int aID, String aUnlocalName, short[] aRGB) { - return generate(aID, aUnlocalName, Short.MIN_VALUE, Short.MIN_VALUE, Short.MIN_VALUE, Short.MIN_VALUE, aRGB); - } - - /** - * Generate a {@link FluidPackage} from the data provided. This FluidPackage is automatically registered and handled internally. - * Pass in {@link Short}.MIN_VALUE for any of the Fluid Fields (Besides ID, Name or RGB) and it will default to water values. - * @param aID - The Fluid ID (Must be unique) - * @param aUnlocalName - Unlocalized Fluid Name - * @param luminosity - How bright is the fluid. - * @param density - completely arbitrary; negative density indicates that the fluid is + public static final Map mNameToFluidMap = new LinkedHashMap(); + public static final Map mNameToBucketMap = new LinkedHashMap(); + public static final Map mNameToBlockMap = new LinkedHashMap(); + public static final Map mNameToMetaMap = new LinkedHashMap(); + + public static final Map mFluidToNameMap = new LinkedHashMap(); + public static final Map mFluidToBucketMap = new LinkedHashMap(); + public static final Map mFluidToBlockMap = new LinkedHashMap(); + public static final Map mFluidToMetaMap = new LinkedHashMap(); + + public static final Map mBucketToFluidMap = new LinkedHashMap(); + public static final Map mBucketToNameMap = new LinkedHashMap(); + public static final Map mBucketToBlockMap = new LinkedHashMap(); + public static final Map mBucketToMetaMap = new LinkedHashMap(); + + public static final Map mBlockToNameMap = new LinkedHashMap(); + public static final Map mBlockToFluidMap = new LinkedHashMap(); + public static final Map mBlockToBucketMap = new LinkedHashMap(); + public static final Map mBlockToMetaMap = new LinkedHashMap(); + + public static final Map mMetaToNameMap = new LinkedHashMap(); + public static final Map mMetaToFluidMap = new LinkedHashMap(); + public static final Map mMetaToBucketMap = new LinkedHashMap(); + public static final Map mMetaToBlockMap = new LinkedHashMap(); + + // Special Colour Handling + public static final Map mMetaToColourMap = new LinkedHashMap(); + + public static Item mGenericBucket; + private static FluidPackage mErrorFluid; + private static AutoMap mGeneratedFluids = new AutoMap(); + + public static void preInit() {} + + public static void init() { + mGenericBucket = new ItemGenericFluidBucket(Blocks.air); + GameRegistry.registerItem(mGenericBucket, "gtpp.bucket.generic"); + for (FluidPackage y : mGeneratedFluids) { + if (!y.valid()) { + continue; + } + GameRegistry.registerBlock(y.mBlock, FluidItemBlock.class, "gtpp_" + y.mName); + FluidContainerRegistry.registerFluidContainer(y.get(), y.mBucket, new ItemStack(Items.bucket)); + } + Utils.registerEvent(BucketHandler.INSTANCE); + } + + public static void postInit() {} + + /** + * Generates a 'Water' type fluid. + * @param aID - The Fluid ID (Must be unique) + * @param aUnlocalName - Unlocalized Fluid Name + * @param aRGB - a {@link Short[]} containing the RGB of the FluidPackage. + * @return - A fully constructed & registered {@linkplain FluidPackage} + */ + public static FluidPackage generate(int aID, String aUnlocalName, short[] aRGB) { + return generate(aID, aUnlocalName, Short.MIN_VALUE, Short.MIN_VALUE, Short.MIN_VALUE, Short.MIN_VALUE, aRGB); + } + + /** + * Generate a {@link FluidPackage} from the data provided. This FluidPackage is automatically registered and handled internally. + * Pass in {@link Short}.MIN_VALUE for any of the Fluid Fields (Besides ID, Name or RGB) and it will default to water values. + * @param aID - The Fluid ID (Must be unique) + * @param aUnlocalName - Unlocalized Fluid Name + * @param luminosity - How bright is the fluid. + * @param density - completely arbitrary; negative density indicates that the fluid is * lighter than air. Default value is approximately the real-life density of water in kg/m^3. - * @param temp - completely arbitrary; higher temperature indicates that the fluid is + * @param temp - completely arbitrary; higher temperature indicates that the fluid is * hotter than air. Default value is approximately the real-life room temperature of water in degrees Kelvin - * @param viscosity - completely arbitrary; negative values are not + * @param viscosity - completely arbitrary; negative values are not * permissible. Default value is approximately the real-life density of water in m/s^2 (x10^-3). * * Higher viscosity means that a fluid flows more slowly, like molasses. * Lower viscosity means that a fluid flows more quickly, like helium. - * @param aRGB - a {@link Short[]} containing the RGB of the FluidPackage. - * @return - A fully constructed & registered {@linkplain FluidPackage} - */ - public static FluidPackage generate(int aID, String aUnlocalName, int luminosity, int density, int temp, - int viscosity, short[] aRGB) { - - FluidPackage aFluidToGenerate = null; - - // Check Load Phase for some Safety, only allow this to be called in Pre-Init. - if (GTplusplus.CURRENT_LOAD_PHASE != INIT_PHASE.PRE_INIT) { - try { - throw new GregtechException("Cannot generate Fluid Packages outside of Pre-Init!"); - } catch (GregtechException e) { - e.printStackTrace(); - CORE.crash("Cannot generate Fluid Packages outside of Pre-Init!"); - } - } - - Fluid aGenFluid = fluid(aUnlocalName, luminosity, density, temp, viscosity, aRGB); - Block aGenBlock = block(aGenFluid, aRGB); - ItemStack aGenBucket = bucket(aID); - - aFluidToGenerate = new FluidPackage(aID, aUnlocalName, aGenFluid, aGenBucket, aGenBlock); - - if (aFluidToGenerate != null && aFluidToGenerate.valid()) { - FluidRegistry.registerFluid(aFluidToGenerate.get()); - mGeneratedFluids.put(aFluidToGenerate); - } - else { - // Handle Bad generation - if (mErrorFluid == null) { - mErrorFluid = new FluidPackage(0, "", FluidUtils.getWater(1).getFluid(), ItemUtils.getSimpleStack(Items.water_bucket), Blocks.water); - } - return mErrorFluid; - } - - - return aFluidToGenerate; - } - - - - private static Fluid fluid(String aUnlocalName, int luminosity, int density, int temp, - int viscosity, short[] aRGB) { - return new FactoryFluid(aUnlocalName, luminosity, density, temp, viscosity, aRGB); - } - - private static ItemStack bucket(int aID) { - return ItemGenericFluidBucket.registerFluidForBucket(aID); - } - - private static Block block(Fluid aFluidForBlock, short[] aRGB) { - if (aFluidForBlock != null) { - FluidRegistry.registerFluid(aFluidForBlock); - return new BlockFluidBase(aFluidForBlock, aRGB); - } - return Blocks.dirt; - } - - /** - * Copyright © SpaceToad, 2011 http://www.mod-buildcraft.com BuildCraft is - * distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. - * Please check the contents of the license located in - * http://www.mod-buildcraft.com/MMPL-1.0.txt - * - * Modified version of the BC BucketHandler, except using ItemStacks > Items - * (Why?) - * - * @author Alkalus - */ - - public static class BucketHandler { - - public static BucketHandler INSTANCE = new BucketHandler(); - - private BucketHandler() { - - } - - @SubscribeEvent - public void onBucketFill(FillBucketEvent event) { - ItemStack result = fillCustomBucket(event.world, event.target); - if (result == null) { - return; - } - event.result = result; - event.setResult(Result.ALLOW); - } - - private ItemStack fillCustomBucket(World world, MovingObjectPosition pos) { - Block block = world.getBlock(pos.blockX, pos.blockY, pos.blockZ); - ItemStack bucket = mBlockToBucketMap.get(block); - if (bucket != null && world.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ) == 0) { - world.setBlockToAir(pos.blockX, pos.blockY, pos.blockZ); - return ItemUtils.getSimpleStack(bucket, 1); - } else { - return null; - } - } - - } - + * @param aRGB - a {@link Short[]} containing the RGB of the FluidPackage. + * @return - A fully constructed & registered {@linkplain FluidPackage} + */ + public static FluidPackage generate( + int aID, String aUnlocalName, int luminosity, int density, int temp, int viscosity, short[] aRGB) { + + FluidPackage aFluidToGenerate = null; + + // Check Load Phase for some Safety, only allow this to be called in Pre-Init. + if (GTplusplus.CURRENT_LOAD_PHASE != INIT_PHASE.PRE_INIT) { + try { + throw new GregtechException("Cannot generate Fluid Packages outside of Pre-Init!"); + } catch (GregtechException e) { + e.printStackTrace(); + CORE.crash("Cannot generate Fluid Packages outside of Pre-Init!"); + } + } + + Fluid aGenFluid = fluid(aUnlocalName, luminosity, density, temp, viscosity, aRGB); + Block aGenBlock = block(aGenFluid, aRGB); + ItemStack aGenBucket = bucket(aID); + + aFluidToGenerate = new FluidPackage(aID, aUnlocalName, aGenFluid, aGenBucket, aGenBlock); + + if (aFluidToGenerate != null && aFluidToGenerate.valid()) { + FluidRegistry.registerFluid(aFluidToGenerate.get()); + mGeneratedFluids.put(aFluidToGenerate); + } else { + // Handle Bad generation + if (mErrorFluid == null) { + mErrorFluid = new FluidPackage( + 0, + "", + FluidUtils.getWater(1).getFluid(), + ItemUtils.getSimpleStack(Items.water_bucket), + Blocks.water); + } + return mErrorFluid; + } + + return aFluidToGenerate; + } + + private static Fluid fluid( + String aUnlocalName, int luminosity, int density, int temp, int viscosity, short[] aRGB) { + return new FactoryFluid(aUnlocalName, luminosity, density, temp, viscosity, aRGB); + } + + private static ItemStack bucket(int aID) { + return ItemGenericFluidBucket.registerFluidForBucket(aID); + } + + private static Block block(Fluid aFluidForBlock, short[] aRGB) { + if (aFluidForBlock != null) { + FluidRegistry.registerFluid(aFluidForBlock); + return new BlockFluidBase(aFluidForBlock, aRGB); + } + return Blocks.dirt; + } + + /** + * Copyright © SpaceToad, 2011 http://www.mod-buildcraft.com BuildCraft is + * distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. + * Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + * + * Modified version of the BC BucketHandler, except using ItemStacks > Items + * (Why?) + * + * @author Alkalus + */ + public static class BucketHandler { + + public static BucketHandler INSTANCE = new BucketHandler(); + + private BucketHandler() {} + + @SubscribeEvent + public void onBucketFill(FillBucketEvent event) { + ItemStack result = fillCustomBucket(event.world, event.target); + if (result == null) { + return; + } + event.result = result; + event.setResult(Result.ALLOW); + } + + private ItemStack fillCustomBucket(World world, MovingObjectPosition pos) { + Block block = world.getBlock(pos.blockX, pos.blockY, pos.blockZ); + ItemStack bucket = mBlockToBucketMap.get(block); + if (bucket != null && world.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ) == 0) { + world.setBlockToAir(pos.blockX, pos.blockY, pos.blockZ); + return ItemUtils.getSimpleStack(bucket, 1); + } else { + return null; + } + } + } } diff --git a/src/main/java/gtPlusPlus/core/fluids/FluidPackage.java b/src/main/java/gtPlusPlus/core/fluids/FluidPackage.java index 29f831776b..10e54d794d 100644 --- a/src/main/java/gtPlusPlus/core/fluids/FluidPackage.java +++ b/src/main/java/gtPlusPlus/core/fluids/FluidPackage.java @@ -28,56 +28,53 @@ import net.minecraftforge.fluids.Fluid; public class FluidPackage { + public final int mID; + public final String mName; + private final Fluid mFluid; + public final ItemStack mBucket; + public final Block mBlock; - public final int mID; - public final String mName; - private final Fluid mFluid; - public final ItemStack mBucket; - public final Block mBlock; + public FluidPackage(int aID, String aName, Fluid aFluid, ItemStack aBucket, Block aBlock) { - public FluidPackage(int aID, String aName, Fluid aFluid, ItemStack aBucket, Block aBlock) { + mNameToFluidMap.put(aName, aFluid); + mNameToBucketMap.put(aName, aBucket); + mNameToBlockMap.put(aName, aBlock); + mNameToMetaMap.put(aName, aID); - mNameToFluidMap.put(aName, aFluid); - mNameToBucketMap.put(aName, aBucket); - mNameToBlockMap.put(aName, aBlock); - mNameToMetaMap.put(aName, aID); + mFluidToNameMap.put(aFluid, aName); + mFluidToBucketMap.put(aFluid, aBucket); + mFluidToBlockMap.put(aFluid, aBlock); + mFluidToMetaMap.put(aFluid, aID); - mFluidToNameMap.put(aFluid, aName); - mFluidToBucketMap.put(aFluid, aBucket); - mFluidToBlockMap.put(aFluid, aBlock); - mFluidToMetaMap.put(aFluid, aID); + mBucketToFluidMap.put(aBucket, aFluid); + mBucketToNameMap.put(aBucket, aName); + mBucketToBlockMap.put(aBucket, aBlock); + mBucketToMetaMap.put(aBucket, aID); - mBucketToFluidMap.put(aBucket, aFluid); - mBucketToNameMap.put(aBucket, aName); - mBucketToBlockMap.put(aBucket, aBlock); - mBucketToMetaMap.put(aBucket, aID); + mBlockToNameMap.put(aBlock, aName); + mBlockToFluidMap.put(aBlock, aFluid); + mBlockToBucketMap.put(aBlock, aBucket); + mBlockToMetaMap.put(aBlock, aID); - mBlockToNameMap.put(aBlock, aName); - mBlockToFluidMap.put(aBlock, aFluid); - mBlockToBucketMap.put(aBlock, aBucket); - mBlockToMetaMap.put(aBlock, aID); + mMetaToNameMap.put(aID, aName); + mMetaToFluidMap.put(aID, aFluid); + mMetaToBucketMap.put(aID, aBucket); + mMetaToBlockMap.put(aID, aBlock); - mMetaToNameMap.put(aID, aName); - mMetaToFluidMap.put(aID, aFluid); - mMetaToBucketMap.put(aID, aBucket); - mMetaToBlockMap.put(aID, aBlock); - - mMetaToColourMap.put(aID, aFluid.getColor()); - - mID = aID; - mName = aName; - mFluid = aFluid; - mBucket = aBucket; - mBlock = aBlock; + mMetaToColourMap.put(aID, aFluid.getColor()); - } - - public Fluid get() { - return mFluid; - } - - public boolean valid() { - return mName != null && mName.length() > 0 && mFluid != null && mBucket != null && mBlock != null; - } + mID = aID; + mName = aName; + mFluid = aFluid; + mBucket = aBucket; + mBlock = aBlock; + } + public Fluid get() { + return mFluid; + } + + public boolean valid() { + return mName != null && mName.length() > 0 && mFluid != null && mBucket != null && mBlock != null; + } } diff --git a/src/main/java/gtPlusPlus/core/fluids/FluidRegistryHandler.java b/src/main/java/gtPlusPlus/core/fluids/FluidRegistryHandler.java index bc4df596de..3a0f56c2a5 100644 --- a/src/main/java/gtPlusPlus/core/fluids/FluidRegistryHandler.java +++ b/src/main/java/gtPlusPlus/core/fluids/FluidRegistryHandler.java @@ -3,51 +3,49 @@ package gtPlusPlus.core.fluids; import static gtPlusPlus.core.block.ModBlocks.*; import cpw.mods.fml.common.registry.GameRegistry; - -import net.minecraft.block.material.Material; - import gtPlusPlus.core.block.general.fluids.BlockFluidSludge; import gtPlusPlus.core.lib.CORE; +import net.minecraft.block.material.Material; import net.minecraftforge.fluids.FluidRegistry; public class FluidRegistryHandler { - //Fluids - /** - * - * Luminosity .setLuminosity(luminosity) - How much light does the fluid emit. Default: 0, Lava uses 15 - Density .setDensity(density) - How dense is the fluid, the only effect is whether or not a fluid replaces another fluid when they flow into each other. Default: 1000, the density of water at 4 degrees Celsius in kg/m³ - Temperature .setTemperature(temp) - How hot, or cold is the fluid. Has currently no effect. Default: 295, the "normal" room temperature in degrees Kelvin, this is approximately 72°F or 22°C. - Viscosity .setViscosity(viscosity) - How thick the fluid is. Determines how fast it flows. Default: 1000 for water, lava uses 6000 - Is Gaseous .setGaseous(boolean) - Indicates if the fluid is gaseous. Used for rendering. Default: false - * - */ - - public static void registerFluids(){ - run(); - } - - private static void run(){ - fluidSludge(); - } - - private static void fluidSludge(){ - //testFluid - fluidSludge.setLuminosity(8); - fluidSludge.setDensity(8196); - fluidSludge.setTemperature(295); - fluidSludge.setViscosity(3000); - fluidSludge.setGaseous(false); - fluidSludge.setUnlocalizedName("fluid.sludge"); - FluidRegistry.registerFluid(fluidSludge); - blockFluidSludge = new BlockFluidSludge(fluidSludge, Material.cactus).setBlockName("fluidBlockSludge"); - GameRegistry.registerBlock(blockFluidSludge, CORE.MODID + "_" + blockFluidSludge.getUnlocalizedName().substring(5)); - fluidSludge.setUnlocalizedName(blockFluidSludge.getUnlocalizedName()); - } - + // Fluids + /** + * + * Luminosity .setLuminosity(luminosity) + * How much light does the fluid emit. Default: 0, Lava uses 15 + * Density .setDensity(density) + * How dense is the fluid, the only effect is whether or not a fluid replaces another fluid when they flow into each other. Default: 1000, the density of water at 4 degrees Celsius in kg/m³ + * Temperature .setTemperature(temp) + * How hot, or cold is the fluid. Has currently no effect. Default: 295, the "normal" room temperature in degrees Kelvin, this is approximately 72°F or 22°C. + * Viscosity .setViscosity(viscosity) + * How thick the fluid is. Determines how fast it flows. Default: 1000 for water, lava uses 6000 + * Is Gaseous .setGaseous(boolean) + * Indicates if the fluid is gaseous. Used for rendering. Default: false + * + */ + public static void registerFluids() { + run(); + } + + private static void run() { + fluidSludge(); + } + + private static void fluidSludge() { + // testFluid + fluidSludge.setLuminosity(8); + fluidSludge.setDensity(8196); + fluidSludge.setTemperature(295); + fluidSludge.setViscosity(3000); + fluidSludge.setGaseous(false); + fluidSludge.setUnlocalizedName("fluid.sludge"); + FluidRegistry.registerFluid(fluidSludge); + blockFluidSludge = new BlockFluidSludge(fluidSludge, Material.cactus).setBlockName("fluidBlockSludge"); + GameRegistry.registerBlock( + blockFluidSludge, + CORE.MODID + "_" + blockFluidSludge.getUnlocalizedName().substring(5)); + fluidSludge.setUnlocalizedName(blockFluidSludge.getUnlocalizedName()); + } } diff --git a/src/main/java/gtPlusPlus/core/fluids/ItemGenericFluidBucket.java b/src/main/java/gtPlusPlus/core/fluids/ItemGenericFluidBucket.java index 6354be632d..ed1cc112c3 100644 --- a/src/main/java/gtPlusPlus/core/fluids/ItemGenericFluidBucket.java +++ b/src/main/java/gtPlusPlus/core/fluids/ItemGenericFluidBucket.java @@ -1,14 +1,13 @@ package gtPlusPlus.core.fluids; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - import cpw.mods.fml.common.eventhandler.Event; import gtPlusPlus.api.objects.GregtechException; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.ItemUtils; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -27,293 +26,290 @@ import net.minecraftforge.event.entity.player.FillBucketEvent; public class ItemGenericFluidBucket extends ItemBucket { - private static IIcon mBaseBucketTexture; - private static IIcon mOverlayBucketTexture; - private static AutoMap mInternalFluidCache = new AutoMap(); - - public ItemGenericFluidBucket(Block aFluid) { - super(aFluid); - this.setContainerItem(Items.bucket); - this.maxStackSize = 1; - mInternalFluidCache.put(aFluid); - } - - public static ItemStack registerFluidForBucket(int aID) { - - if (FluidFactory.mMetaToBucketMap.containsKey(aID)) { - try { - throw new GregtechException(""+aID+" is already registered! Unable to register fluid: "+FluidFactory.mMetaToFluidMap.get(aID).getLocalizedName()); - } catch (GregtechException e) { - e.printStackTrace(); - CORE.crash(""+aID+" is already registered! Unable to register fluid: "+FluidFactory.mMetaToFluidMap.get(aID).getLocalizedName()); - } - } - mInternalFluidCache.put(FluidFactory.mMetaToBlockMap.get(aID)); - return ItemUtils.simpleMetaStack(FluidFactory.mGenericBucket, aID, 1); - } - - Map mIconCache = new LinkedHashMap(); - - /** - * Called whenever this item is equipped and the right mouse button is pressed. - * Args: itemStack, world, entityPlayer - */ - public ItemStack onItemRightClick(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { - - Block isFull = FluidFactory.mMetaToBlockMap.get(aStack.getItemDamage()); - - boolean flag = isFull == Blocks.air; - MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(aWorld, aPlayer, flag); - - if (movingobjectposition == null || isFull == null) { - return aStack; - } else { - FillBucketEvent event = new FillBucketEvent(aPlayer, aStack, aWorld, movingobjectposition); - if (MinecraftForge.EVENT_BUS.post(event)) { - return aStack; - } - - if (event.getResult() == Event.Result.ALLOW) { - if (aPlayer.capabilities.isCreativeMode) { - return aStack; - } - - if (--aStack.stackSize <= 0) { - return event.result; - } - - if (!aPlayer.inventory.addItemStackToInventory(event.result)) { - aPlayer.dropPlayerItemWithRandomChoice(event.result, false); - } - - return aStack; - } - if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { - int i = movingobjectposition.blockX; - int j = movingobjectposition.blockY; - int k = movingobjectposition.blockZ; - - if (!aWorld.canMineBlock(aPlayer, i, j, k)) { - return aStack; - } - - if (flag) { - if (!aPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, aStack)) { - return aStack; - } - - Material material = aWorld.getBlock(i, j, k).getMaterial(); - int l = aWorld.getBlockMetadata(i, j, k); - - if (material == Material.water && l == 0) { - aWorld.setBlockToAir(i, j, k); - return this.func_150910_a(aStack, aPlayer, Items.water_bucket); - } - - if (material == Material.lava && l == 0) { - aWorld.setBlockToAir(i, j, k); - return this.func_150910_a(aStack, aPlayer, Items.lava_bucket); - } - } else { - if (isFull == Blocks.air) { - return new ItemStack(Items.bucket); - } - - if (movingobjectposition.sideHit == 0) { - --j; - } - - if (movingobjectposition.sideHit == 1) { - ++j; - } - - if (movingobjectposition.sideHit == 2) { - --k; - } - - if (movingobjectposition.sideHit == 3) { - ++k; - } - - if (movingobjectposition.sideHit == 4) { - --i; - } - - if (movingobjectposition.sideHit == 5) { - ++i; - } - - if (!aPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, aStack)) { - return aStack; - } - - if (this.tryPlaceContainedLiquid(isFull, aWorld, i, j, k) && !aPlayer.capabilities.isCreativeMode) { - return new ItemStack(Items.bucket); - } - } - } - - return aStack; - } - } - - private ItemStack func_150910_a(ItemStack p_150910_1_, EntityPlayer p_150910_2_, Item p_150910_3_) { - if (p_150910_2_.capabilities.isCreativeMode) { - return p_150910_1_; - } else if (--p_150910_1_.stackSize <= 0) { - return new ItemStack(p_150910_3_); - } else { - if (!p_150910_2_.inventory.addItemStackToInventory(new ItemStack(p_150910_3_))) { - p_150910_2_.dropPlayerItemWithRandomChoice(new ItemStack(p_150910_3_, 1, 0), false); - } - - return p_150910_1_; - } - } - - /** - * Attempts to place the liquid contained inside the bucket. - */ - public boolean tryPlaceContainedLiquid(Block isFull, World aWorld, int aX, int aY, int aZ) { - if (isFull == Blocks.air) { - return false; - } else { - Material material = aWorld.getBlock(aX, aY, aZ).getMaterial(); - boolean flag = !material.isSolid(); - - if (!aWorld.isAirBlock(aX, aY, aZ) && !flag) { - return false; - } else { - - if (!aWorld.isRemote && flag && !material.isLiquid()) { - aWorld.func_147480_a(aX, aY, aZ, true); - } - - aWorld.setBlock(aX, aY, aZ, isFull, 0, 3); - - return true; - } - } - } - - @Override - public IIcon getIconFromDamage(int aMeta) { - IIcon aTemp = mIconCache.get(aMeta); - return aTemp != null ? aTemp : super.getIconFromDamage(aMeta); - } - - @Override - public boolean getHasSubtypes() { - return mInternalFluidCache.size() > 0; - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - list.add(new ItemStack(item, 1, 0)); - for (Block f : mInternalFluidCache) { - Integer aMeta; - if (f != null) { - aMeta = FluidFactory.mBlockToMetaMap.get(f); - if (aMeta != null) { - list.add(new ItemStack(item, 1, aMeta)); - } - } - } - } - - @Override - public int getMaxDamage() { - return 512; - } - - @Override - public boolean isDamageable() { - return false; - } - - @Override - public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List p_77624_3_, boolean p_77624_4_) { - // TODO Auto-generated method stub - super.addInformation(p_77624_1_, p_77624_2_, p_77624_3_, p_77624_4_); - } - - @Override - public int getItemEnchantability() { - return 0; - } - - @Override - public boolean isRepairable() { - return false; - } - - @Override - public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { - if (stack != null && renderPass == 1) { - return mOverlayBucketTexture; - } - else { - return mBaseBucketTexture; - } - /*IIcon aTemp = mIconCache.get(stack.getItemDamage()); - return aTemp != null ? aTemp : super.getIcon(stack, renderPass, player, usingItem, useRemaining);*/ - } - - @Override - public boolean isBookEnchantable(ItemStack stack, ItemStack book) { - return false; - } - - @Override - public int getMaxDamage(ItemStack stack) { - return 512; - } - - @Override - public boolean isDamaged(ItemStack stack) { - return false; - } - - @Override - public int getItemEnchantability(ItemStack stack) { - return 0; - } - - @Override - public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) { - if (pass == 1) { - return mOverlayBucketTexture; - } - else { - return mBaseBucketTexture; - } - } - - @Override - public void registerIcons(final IIconRegister i) { - mBaseBucketTexture = i.registerIcon("bucket_empty"); - mOverlayBucketTexture = i.registerIcon(CORE.MODID+":bucket.generic.overlay"); - } - - @Override - public boolean tryPlaceContainedLiquid(World p_77875_1_, int p_77875_2_, int p_77875_3_, int p_77875_4_) { - return tryPlaceContainedLiquid(Blocks.air, p_77875_1_, p_77875_2_, p_77875_3_, p_77875_4_); - } - - @Override - public int getColorFromItemStack(ItemStack aStack, int aPass) { - if (aPass == 0) { - return super.getColorFromItemStack(aStack, aPass); - } - else { - return FluidFactory.mMetaToColourMap.get(aStack.getItemDamage()); - } - } - - @Override - public boolean requiresMultipleRenderPasses() { - return true; - } - - + private static IIcon mBaseBucketTexture; + private static IIcon mOverlayBucketTexture; + private static AutoMap mInternalFluidCache = new AutoMap(); + + public ItemGenericFluidBucket(Block aFluid) { + super(aFluid); + this.setContainerItem(Items.bucket); + this.maxStackSize = 1; + mInternalFluidCache.put(aFluid); + } + + public static ItemStack registerFluidForBucket(int aID) { + + if (FluidFactory.mMetaToBucketMap.containsKey(aID)) { + try { + throw new GregtechException("" + aID + " is already registered! Unable to register fluid: " + + FluidFactory.mMetaToFluidMap.get(aID).getLocalizedName()); + } catch (GregtechException e) { + e.printStackTrace(); + CORE.crash("" + aID + " is already registered! Unable to register fluid: " + + FluidFactory.mMetaToFluidMap.get(aID).getLocalizedName()); + } + } + mInternalFluidCache.put(FluidFactory.mMetaToBlockMap.get(aID)); + return ItemUtils.simpleMetaStack(FluidFactory.mGenericBucket, aID, 1); + } + + Map mIconCache = new LinkedHashMap(); + + /** + * Called whenever this item is equipped and the right mouse button is pressed. + * Args: itemStack, world, entityPlayer + */ + public ItemStack onItemRightClick(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { + + Block isFull = FluidFactory.mMetaToBlockMap.get(aStack.getItemDamage()); + + boolean flag = isFull == Blocks.air; + MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(aWorld, aPlayer, flag); + + if (movingobjectposition == null || isFull == null) { + return aStack; + } else { + FillBucketEvent event = new FillBucketEvent(aPlayer, aStack, aWorld, movingobjectposition); + if (MinecraftForge.EVENT_BUS.post(event)) { + return aStack; + } + + if (event.getResult() == Event.Result.ALLOW) { + if (aPlayer.capabilities.isCreativeMode) { + return aStack; + } + + if (--aStack.stackSize <= 0) { + return event.result; + } + + if (!aPlayer.inventory.addItemStackToInventory(event.result)) { + aPlayer.dropPlayerItemWithRandomChoice(event.result, false); + } + + return aStack; + } + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; + + if (!aWorld.canMineBlock(aPlayer, i, j, k)) { + return aStack; + } + + if (flag) { + if (!aPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, aStack)) { + return aStack; + } + + Material material = aWorld.getBlock(i, j, k).getMaterial(); + int l = aWorld.getBlockMetadata(i, j, k); + + if (material == Material.water && l == 0) { + aWorld.setBlockToAir(i, j, k); + return this.func_150910_a(aStack, aPlayer, Items.water_bucket); + } + + if (material == Material.lava && l == 0) { + aWorld.setBlockToAir(i, j, k); + return this.func_150910_a(aStack, aPlayer, Items.lava_bucket); + } + } else { + if (isFull == Blocks.air) { + return new ItemStack(Items.bucket); + } + + if (movingobjectposition.sideHit == 0) { + --j; + } + + if (movingobjectposition.sideHit == 1) { + ++j; + } + + if (movingobjectposition.sideHit == 2) { + --k; + } + + if (movingobjectposition.sideHit == 3) { + ++k; + } + + if (movingobjectposition.sideHit == 4) { + --i; + } + + if (movingobjectposition.sideHit == 5) { + ++i; + } + + if (!aPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, aStack)) { + return aStack; + } + + if (this.tryPlaceContainedLiquid(isFull, aWorld, i, j, k) && !aPlayer.capabilities.isCreativeMode) { + return new ItemStack(Items.bucket); + } + } + } + + return aStack; + } + } + + private ItemStack func_150910_a(ItemStack p_150910_1_, EntityPlayer p_150910_2_, Item p_150910_3_) { + if (p_150910_2_.capabilities.isCreativeMode) { + return p_150910_1_; + } else if (--p_150910_1_.stackSize <= 0) { + return new ItemStack(p_150910_3_); + } else { + if (!p_150910_2_.inventory.addItemStackToInventory(new ItemStack(p_150910_3_))) { + p_150910_2_.dropPlayerItemWithRandomChoice(new ItemStack(p_150910_3_, 1, 0), false); + } + + return p_150910_1_; + } + } + + /** + * Attempts to place the liquid contained inside the bucket. + */ + public boolean tryPlaceContainedLiquid(Block isFull, World aWorld, int aX, int aY, int aZ) { + if (isFull == Blocks.air) { + return false; + } else { + Material material = aWorld.getBlock(aX, aY, aZ).getMaterial(); + boolean flag = !material.isSolid(); + + if (!aWorld.isAirBlock(aX, aY, aZ) && !flag) { + return false; + } else { + + if (!aWorld.isRemote && flag && !material.isLiquid()) { + aWorld.func_147480_a(aX, aY, aZ, true); + } + + aWorld.setBlock(aX, aY, aZ, isFull, 0, 3); + + return true; + } + } + } + + @Override + public IIcon getIconFromDamage(int aMeta) { + IIcon aTemp = mIconCache.get(aMeta); + return aTemp != null ? aTemp : super.getIconFromDamage(aMeta); + } + + @Override + public boolean getHasSubtypes() { + return mInternalFluidCache.size() > 0; + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + list.add(new ItemStack(item, 1, 0)); + for (Block f : mInternalFluidCache) { + Integer aMeta; + if (f != null) { + aMeta = FluidFactory.mBlockToMetaMap.get(f); + if (aMeta != null) { + list.add(new ItemStack(item, 1, aMeta)); + } + } + } + } + + @Override + public int getMaxDamage() { + return 512; + } + + @Override + public boolean isDamageable() { + return false; + } + + @Override + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List p_77624_3_, boolean p_77624_4_) { + // TODO Auto-generated method stub + super.addInformation(p_77624_1_, p_77624_2_, p_77624_3_, p_77624_4_); + } + + @Override + public int getItemEnchantability() { + return 0; + } + + @Override + public boolean isRepairable() { + return false; + } + + @Override + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { + if (stack != null && renderPass == 1) { + return mOverlayBucketTexture; + } else { + return mBaseBucketTexture; + } + /*IIcon aTemp = mIconCache.get(stack.getItemDamage()); + return aTemp != null ? aTemp : super.getIcon(stack, renderPass, player, usingItem, useRemaining);*/ + } + + @Override + public boolean isBookEnchantable(ItemStack stack, ItemStack book) { + return false; + } + + @Override + public int getMaxDamage(ItemStack stack) { + return 512; + } + + @Override + public boolean isDamaged(ItemStack stack) { + return false; + } + + @Override + public int getItemEnchantability(ItemStack stack) { + return 0; + } + + @Override + public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) { + if (pass == 1) { + return mOverlayBucketTexture; + } else { + return mBaseBucketTexture; + } + } + + @Override + public void registerIcons(final IIconRegister i) { + mBaseBucketTexture = i.registerIcon("bucket_empty"); + mOverlayBucketTexture = i.registerIcon(CORE.MODID + ":bucket.generic.overlay"); + } + + @Override + public boolean tryPlaceContainedLiquid(World p_77875_1_, int p_77875_2_, int p_77875_3_, int p_77875_4_) { + return tryPlaceContainedLiquid(Blocks.air, p_77875_1_, p_77875_2_, p_77875_3_, p_77875_4_); + } + + @Override + public int getColorFromItemStack(ItemStack aStack, int aPass) { + if (aPass == 0) { + return super.getColorFromItemStack(aStack, aPass); + } else { + return FluidFactory.mMetaToColourMap.get(aStack.getItemDamage()); + } + } + + @Override + public boolean requiresMultipleRenderPasses() { + return true; + } } diff --git a/src/main/java/gtPlusPlus/core/gui/GUI_Base_Tile_Entity.java b/src/main/java/gtPlusPlus/core/gui/GUI_Base_Tile_Entity.java index aa10363e7c..379827a1db 100644 --- a/src/main/java/gtPlusPlus/core/gui/GUI_Base_Tile_Entity.java +++ b/src/main/java/gtPlusPlus/core/gui/GUI_Base_Tile_Entity.java @@ -5,11 +5,10 @@ import net.minecraft.inventory.Container; public abstract class GUI_Base_Tile_Entity extends GuiContainer { - public final Container mContainer; - - public GUI_Base_Tile_Entity(Container aContainer) { - super(aContainer); - mContainer = aContainer; - } + public final Container mContainer; + public GUI_Base_Tile_Entity(Container aContainer) { + super(aContainer); + mContainer = aContainer; + } } diff --git a/src/main/java/gtPlusPlus/core/gui/beta/Gui_ID_Registry.java b/src/main/java/gtPlusPlus/core/gui/beta/Gui_ID_Registry.java index 1212054f01..d36de4bf28 100644 --- a/src/main/java/gtPlusPlus/core/gui/beta/Gui_ID_Registry.java +++ b/src/main/java/gtPlusPlus/core/gui/beta/Gui_ID_Registry.java @@ -1,56 +1,54 @@ package gtPlusPlus.core.gui.beta; +import gtPlusPlus.core.interfaces.IGuiManagerMiscUtils; import java.util.HashMap; import java.util.List; import java.util.Map; -import gtPlusPlus.core.interfaces.IGuiManagerMiscUtils; - -public class Gui_ID_Registry -{ - private static final Map, MU_GuiId> classMap = new HashMap, MU_GuiId>(); - private static final Map idMap = new HashMap(); - private static int nextId = 0; - - static - { - //registerGuiHandlers(Gui_Types.Tile, Arrays.asList(new Class[] {TileAlveary.class})); - //registerGuiHandlers(MU_GuiType.Item, Arrays.asList(new Class[] { ItemBackpack.class, ItemBackpackNaturalist.class, ItemBeealyzer.class, ItemCatalogue.class, ItemFlutterlyzer.class, ItemHabitatLocator.class, ItemImprinter.class, ItemInfuser.class, ItemLetter.class, ItemSolderingIron.class, ItemTreealyzer.class })); - //registerGuiHandlers(MU_GuiType.Entity, Arrays.asList(new Class[] { EntityMinecartApiary.class, EntityMinecartBeehouse.class })); - } - - private static void registerGuiHandlers(final Gui_Types MU_GuiType, final List> guiHandlerClasses) - { - for (final Class tileGuiHandlerClass : guiHandlerClasses) - { - final MU_GuiId guiId = new MU_GuiId(nextId++, MU_GuiType, tileGuiHandlerClass); - classMap.put(tileGuiHandlerClass, guiId); - idMap.put(Integer.valueOf(guiId.getId()), guiId); - } - } - - public static MU_GuiId getGuiIdForGuiHandler(final IGuiManagerMiscUtils guiHandler) - { - final Class guiHandlerClass = guiHandler.getClass(); - MU_GuiId guiId = classMap.get(guiHandlerClass); - if (guiId == null) { - for (final Map.Entry, MU_GuiId> classGuiIdEntry : classMap.entrySet()) { - if (((Class)classGuiIdEntry.getKey()).isAssignableFrom(guiHandlerClass)) - { - guiId = classGuiIdEntry.getValue(); - break; - } - } - } - if (guiId == null) { - throw new IllegalStateException("No gui ID for gui handler: " + guiHandler); - } - return guiId; - } - - public static MU_GuiId getGuiId(final int id) - { - return idMap.get(Integer.valueOf(id)); - } - +public class Gui_ID_Registry { + private static final Map, MU_GuiId> classMap = + new HashMap, MU_GuiId>(); + private static final Map idMap = new HashMap(); + private static int nextId = 0; + + static { + // registerGuiHandlers(Gui_Types.Tile, Arrays.asList(new Class[] {TileAlveary.class})); + // registerGuiHandlers(MU_GuiType.Item, Arrays.asList(new Class[] { ItemBackpack.class, + // ItemBackpackNaturalist.class, ItemBeealyzer.class, ItemCatalogue.class, ItemFlutterlyzer.class, + // ItemHabitatLocator.class, ItemImprinter.class, ItemInfuser.class, ItemLetter.class, ItemSolderingIron.class, + // ItemTreealyzer.class })); + // registerGuiHandlers(MU_GuiType.Entity, Arrays.asList(new Class[] { EntityMinecartApiary.class, + // EntityMinecartBeehouse.class })); + } + + private static void registerGuiHandlers( + final Gui_Types MU_GuiType, final List> guiHandlerClasses) { + for (final Class tileGuiHandlerClass : guiHandlerClasses) { + final MU_GuiId guiId = new MU_GuiId(nextId++, MU_GuiType, tileGuiHandlerClass); + classMap.put(tileGuiHandlerClass, guiId); + idMap.put(Integer.valueOf(guiId.getId()), guiId); + } + } + + public static MU_GuiId getGuiIdForGuiHandler(final IGuiManagerMiscUtils guiHandler) { + final Class guiHandlerClass = guiHandler.getClass(); + MU_GuiId guiId = classMap.get(guiHandlerClass); + if (guiId == null) { + for (final Map.Entry, MU_GuiId> classGuiIdEntry : + classMap.entrySet()) { + if (((Class) classGuiIdEntry.getKey()).isAssignableFrom(guiHandlerClass)) { + guiId = classGuiIdEntry.getValue(); + break; + } + } + } + if (guiId == null) { + throw new IllegalStateException("No gui ID for gui handler: " + guiHandler); + } + return guiId; + } + + public static MU_GuiId getGuiId(final int id) { + return idMap.get(Integer.valueOf(id)); + } } diff --git a/src/main/java/gtPlusPlus/core/gui/beta/Gui_Types.java b/src/main/java/gtPlusPlus/core/gui/beta/Gui_Types.java index 9348f40c9c..bb095e74c0 100644 --- a/src/main/java/gtPlusPlus/core/gui/beta/Gui_Types.java +++ b/src/main/java/gtPlusPlus/core/gui/beta/Gui_Types.java @@ -1,8 +1,9 @@ package gtPlusPlus.core.gui.beta; -public enum Gui_Types -{ - Item, Tile, Entity; +public enum Gui_Types { + Item, + Tile, + Entity; - private Gui_Types() {} -} \ No newline at end of file + private Gui_Types() {} +} diff --git a/src/main/java/gtPlusPlus/core/gui/beta/MU_GuiId.java b/src/main/java/gtPlusPlus/core/gui/beta/MU_GuiId.java index 116ad48480..faf823fdcf 100644 --- a/src/main/java/gtPlusPlus/core/gui/beta/MU_GuiId.java +++ b/src/main/java/gtPlusPlus/core/gui/beta/MU_GuiId.java @@ -1,32 +1,27 @@ package gtPlusPlus.core.gui.beta; + import gtPlusPlus.core.interfaces.IGuiManagerMiscUtils; -public class MU_GuiId -{ - private final int id; - private final Gui_Types MU_GuiType; - private final Class guiHandlerClass; +public class MU_GuiId { + private final int id; + private final Gui_Types MU_GuiType; + private final Class guiHandlerClass; - MU_GuiId(final int id, final Gui_Types MU_GuiType, final Class guiHandlerClass) - { - this.id = id; - this.MU_GuiType = MU_GuiType; - this.guiHandlerClass = guiHandlerClass; - } + MU_GuiId(final int id, final Gui_Types MU_GuiType, final Class guiHandlerClass) { + this.id = id; + this.MU_GuiType = MU_GuiType; + this.guiHandlerClass = guiHandlerClass; + } - public Gui_Types getGuiType() - { - return this.MU_GuiType; - } + public Gui_Types getGuiType() { + return this.MU_GuiType; + } - public Class getGuiHandlerClass() - { - return this.guiHandlerClass; - } + public Class getGuiHandlerClass() { + return this.guiHandlerClass; + } - public int getId() - { - return this.id; - } + public int getId() { + return this.id; + } } - diff --git a/src/main/java/gtPlusPlus/core/gui/item/GuiBaseBackpack.java b/src/main/java/gtPlusPlus/core/gui/item/GuiBaseBackpack.java index 0ad4b9b51f..ebd26d1f26 100644 --- a/src/main/java/gtPlusPlus/core/gui/item/GuiBaseBackpack.java +++ b/src/main/java/gtPlusPlus/core/gui/item/GuiBaseBackpack.java @@ -1,8 +1,8 @@ package gtPlusPlus.core.gui.item; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL12; - +import gtPlusPlus.core.container.Container_BackpackBase; +import gtPlusPlus.core.inventories.BaseInventoryBackpack; +import gtPlusPlus.core.lib.CORE; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.OpenGlHelper; @@ -10,112 +10,115 @@ import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; -import gtPlusPlus.core.container.Container_BackpackBase; -import gtPlusPlus.core.inventories.BaseInventoryBackpack; -import gtPlusPlus.core.lib.CORE; +public class GuiBaseBackpack extends GuiContainer { + /** x and y size of the inventory window in pixels. Defined as float, passed as int + * These are used for drawing the player model. */ + private float xSize_lo; -public class GuiBaseBackpack extends GuiContainer -{ - /** x and y size of the inventory window in pixels. Defined as float, passed as int - * These are used for drawing the player model. */ - private float xSize_lo; - private float ySize_lo; + private float ySize_lo; - /** The FontRenderer used by GuiScreen */ - protected FontRenderer fontRenderer; + /** The FontRenderer used by GuiScreen */ + protected FontRenderer fontRenderer; - /** ResourceLocation takes 2 parameters: ModId, path to texture at the location: - * "src/minecraft/assets/modid/" - * - * I have provided a sample texture file that works with this tutorial. Download it - * from Forge_Tutorials/textures/gui/ - */ - private static final ResourceLocation iconLocation = new ResourceLocation(CORE.MODID, "textures/gui/itemBackpack.png"); + /** ResourceLocation takes 2 parameters: ModId, path to texture at the location: + * "src/minecraft/assets/modid/" + * + * I have provided a sample texture file that works with this tutorial. Download it + * from Forge_Tutorials/textures/gui/ + */ + private static final ResourceLocation iconLocation = + new ResourceLocation(CORE.MODID, "textures/gui/itemBackpack.png"); - /** The inventory to render on screen */ - private final BaseInventoryBackpack inventory; + /** The inventory to render on screen */ + private final BaseInventoryBackpack inventory; - public GuiBaseBackpack(final Container_BackpackBase containerItem) - { - super(containerItem); - this.inventory = containerItem.inventory; - } + public GuiBaseBackpack(final Container_BackpackBase containerItem) { + super(containerItem); + this.inventory = containerItem.inventory; + } - /** - * Draws the screen and all the components in it. - */ - @Override - public void drawScreen(final int par1, final int par2, final float par3) - { - super.drawScreen(par1, par2, par3); - this.xSize_lo = par1; - this.ySize_lo = par2; - } + /** + * Draws the screen and all the components in it. + */ + @Override + public void drawScreen(final int par1, final int par2, final float par3) { + super.drawScreen(par1, par2, par3); + this.xSize_lo = par1; + this.ySize_lo = par2; + } - /** - * Draw the foreground layer for the GuiContainer (everything in front of the items) - */ - @Override - protected void drawGuiContainerForegroundLayer(final int par1, final int par2) - { - final String s = this.inventory.hasCustomInventoryName() ? this.inventory.getInventoryName() : this.inventory.getInventoryName(); - //this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 0, 4210752); - //this.fontRenderer.drawString(I18n.translate("container.inventory"), 26, this.ySize - 96 + 4, 4210752); - } + /** + * Draw the foreground layer for the GuiContainer (everything in front of the items) + */ + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + final String s = this.inventory.hasCustomInventoryName() + ? this.inventory.getInventoryName() + : this.inventory.getInventoryName(); + // this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 0, 4210752); + // this.fontRenderer.drawString(I18n.translate("container.inventory"), 26, this.ySize - 96 + 4, 4210752); + } - /** - * Draw the background layer for the GuiContainer (everything behind the items) - */ - @Override - protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.getTextureManager().bindTexture(iconLocation); - final int k = (this.width - this.xSize) / 2; - final int l = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); - final int i1; - drawPlayerModel(k + 51, l + 75, 30, k + 51 - this.xSize_lo, (l + 75) - 50 - this.ySize_lo, this.mc.thePlayer); - } + /** + * Draw the background layer for the GuiContainer (everything behind the items) + */ + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(iconLocation); + final int k = (this.width - this.xSize) / 2; + final int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + final int i1; + drawPlayerModel(k + 51, l + 75, 30, k + 51 - this.xSize_lo, (l + 75) - 50 - this.ySize_lo, this.mc.thePlayer); + } - /** - * This renders the player model in standard inventory position (in later versions of Minecraft / Forge, you can - * simply call GuiInventory.drawEntityOnScreen directly instead of copying this code) - */ - public static void drawPlayerModel(final int x, final int y, final int scale, final float yaw, final float pitch, final EntityLivingBase entity) { - GL11.glEnable(GL11.GL_COLOR_MATERIAL); - GL11.glPushMatrix(); - GL11.glTranslatef(x, y, 50.0F); - GL11.glScalef(-scale, scale, scale); - GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); - final float f2 = entity.renderYawOffset; - final float f3 = entity.rotationYaw; - final float f4 = entity.rotationPitch; - final float f5 = entity.prevRotationYawHead; - final float f6 = entity.rotationYawHead; - GL11.glRotatef(135.0F, 0.0F, 1.0F, 0.0F); - RenderHelper.enableStandardItemLighting(); - GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-((float) Math.atan(pitch / 40.0F)) * 20.0F, 1.0F, 0.0F, 0.0F); - entity.renderYawOffset = (float) Math.atan(yaw / 40.0F) * 20.0F; - entity.rotationYaw = (float) Math.atan(yaw / 40.0F) * 40.0F; - entity.rotationPitch = -((float) Math.atan(pitch / 40.0F)) * 20.0F; - entity.rotationYawHead = entity.rotationYaw; - entity.prevRotationYawHead = entity.rotationYaw; - GL11.glTranslatef(0.0F, entity.yOffset, 0.0F); - RenderManager.instance.playerViewY = 180.0F; - RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); - entity.renderYawOffset = f2; - entity.rotationYaw = f3; - entity.rotationPitch = f4; - entity.prevRotationYawHead = f5; - entity.rotationYawHead = f6; - GL11.glPopMatrix(); - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); - GL11.glDisable(GL11.GL_TEXTURE_2D); - OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); - } + /** + * This renders the player model in standard inventory position (in later versions of Minecraft / Forge, you can + * simply call GuiInventory.drawEntityOnScreen directly instead of copying this code) + */ + public static void drawPlayerModel( + final int x, + final int y, + final int scale, + final float yaw, + final float pitch, + final EntityLivingBase entity) { + GL11.glEnable(GL11.GL_COLOR_MATERIAL); + GL11.glPushMatrix(); + GL11.glTranslatef(x, y, 50.0F); + GL11.glScalef(-scale, scale, scale); + GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); + final float f2 = entity.renderYawOffset; + final float f3 = entity.rotationYaw; + final float f4 = entity.rotationPitch; + final float f5 = entity.prevRotationYawHead; + final float f6 = entity.rotationYawHead; + GL11.glRotatef(135.0F, 0.0F, 1.0F, 0.0F); + RenderHelper.enableStandardItemLighting(); + GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-((float) Math.atan(pitch / 40.0F)) * 20.0F, 1.0F, 0.0F, 0.0F); + entity.renderYawOffset = (float) Math.atan(yaw / 40.0F) * 20.0F; + entity.rotationYaw = (float) Math.atan(yaw / 40.0F) * 40.0F; + entity.rotationPitch = -((float) Math.atan(pitch / 40.0F)) * 20.0F; + entity.rotationYawHead = entity.rotationYaw; + entity.prevRotationYawHead = entity.rotationYaw; + GL11.glTranslatef(0.0F, entity.yOffset, 0.0F); + RenderManager.instance.playerViewY = 180.0F; + RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); + entity.renderYawOffset = f2; + entity.rotationYaw = f3; + entity.rotationPitch = f4; + entity.prevRotationYawHead = f5; + entity.rotationYawHead = f6; + GL11.glPopMatrix(); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GL11.glDisable(GL11.GL_TEXTURE_2D); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + } } diff --git a/src/main/java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java b/src/main/java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java index ed347e8d30..fd8a8ed7b1 100644 --- a/src/main/java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java +++ b/src/main/java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java @@ -1,23 +1,7 @@ package gtPlusPlus.core.gui.item; -import java.util.LinkedHashSet; -import java.util.Set; - -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiScreenBook; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.client.resources.I18n; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; @@ -28,537 +12,586 @@ import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import java.util.LinkedHashSet; +import java.util.Set; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreenBook; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.resources.I18n; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; public class GuiBaseGrindle extends GuiContainer { - /** The FontRenderer used by GuiScreen */ - protected FontRenderer fontRenderer; - - private GrindleGuiButton mButtonNextPage; - private GrindleGuiButton mButtonPreviousPage; - private String[][] mPageDataArray; - private short mCurrentPage = 0; - - private static final ResourceLocation iconLocation = new ResourceLocation(CORE.MODID, "textures/gui/itemGrindle.png"); - - /** The inventory to render on screen */ - private final BaseInventoryGrindle inventory; - - public GuiBaseGrindle(final Container_Grindle containerItem) { - super(containerItem); - this.inventory = containerItem.inventory; - } - - /** - * Draws the screen and all the components in it. - */ - @Override - public void drawScreen(final int par1, final int par2, final float par3) { - super.drawScreen(par1, par2, par3); - this.updateButtons(); - } - - /** - * Draw the foreground layer for the GuiContainer (everything in front of the - * items) - */ - @Override - protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { - - try { - - // Title - this.fontRendererObj.drawStringWithShadow(I18n.format("Gregtech Information Transponder", new Object[0]), 0, - -12, Utils.rgbtoHexValue(255, 255, 255)); - ItemStack aStack = this.inventory.getStackInSlot(0); - - if (aStack != null) { - - GrindleData aDataCurrent = new GrindleData(aStack); - - if (aDataCurrent.mValid) { - - // Debug NBT Information - //NBTUtils.tryIterateNBTData(aStack); - - this.fontRendererObj.drawString(I18n.format(aDataCurrent.mTitle), 10, 8, Utils.rgbtoHexValue(125, 255, 125)); - - int tTier = aDataCurrent.mExtraInformation; - if (tTier >= 0) { - //Draw the GUI - // List prospection - this.fontRendererObj.drawString(I18n.format(aDataCurrent.mTierDim+" | Page: "+this.mCurrentPage, new Object[0]), 10, 18, Utils.rgbtoHexValue(125, 255, 125)); - // Divider - this.fontRendererObj.drawString(I18n.format("-------------------", new Object[0]), 10, 23, Utils.rgbtoHexValue(125, 125, 255)); - // Pos data - this.fontRendererObj.drawString(I18n.format(aDataCurrent.mPosInfo, new Object[0]), 10, 29, Utils.rgbtoHexValue(125, 125, 255)); - // Divider - this.fontRendererObj.drawString(I18n.format("-------------------", new Object[0]), 10, 35, Utils.rgbtoHexValue(125, 125, 255)); - int aLastYUsed = 41; - - int posOuter = 0; - int posInner = 0; - - mPageDataArray = new String[MathUtils.roundToClosestInt(Math.ceil(aDataCurrent.mListData.size() / 9.00))][9]; - for (String e : aDataCurrent.mListData) { - if (e != null) { - mPageDataArray[posInner][posOuter] = e; - if (posOuter < 8) { - posOuter++; - } - else { - posOuter = 0; - posInner++; - } - } - else { - continue; - } - } - - String[] aCurrentPage = mPageDataArray[this.mCurrentPage]; - - if (aCurrentPage != null) { - //Logger.INFO("valid Current page " + this.mCurrentPage); - if (aCurrentPage.length > 0) { - for (int i=0;i 0) { - if (!aCP.toLowerCase().contains("empty") && !aCP.toLowerCase().contains("null")) { - this.fontRendererObj.drawString(I18n.format(aCP), 10, aLastYUsed, Utils.rgbtoHexValue(125, 255, 125)); - aLastYUsed += 9; - } - } - } - } - } - } - - - - - } - - //Non-Prospecting Data - else { - //Draw the GUI - // List prospection - this.fontRendererObj.drawString(I18n.format(aDataCurrent.mTierDim, new Object[0]), 10, 18, Utils.rgbtoHexValue(125, 255, 125)); - // Divider - this.fontRendererObj.drawString(I18n.format("-------------------", new Object[0]), 10, 23, Utils.rgbtoHexValue(125, 125, 255)); - // Pos data - this.fontRendererObj.drawString(I18n.format(aDataCurrent.mPosInfo, new Object[0]), 10, 29, Utils.rgbtoHexValue(125, 125, 255)); - // Divider - this.fontRendererObj.drawString(I18n.format("-------------------", new Object[0]), 10, 35, Utils.rgbtoHexValue(125, 125, 255)); - int aLastYUsed = 41; - /*for (int i=0;i= 0) { - if (this.mPageDataArray != null) { - if (this.mCurrentPage < (this.mPageDataArray.length - 1)) { - this.mButtonNextPage.visible = true; - } else { - this.mButtonNextPage.visible = false; - } - } else { - this.mButtonNextPage.visible = false; - } - } - if (this.mCurrentPage > 0) { - this.mButtonPreviousPage.visible = true; - } - else { - this.mButtonPreviousPage.visible = false; - } - } - - - /** - * Scrolling Related - */ - @Override - protected void actionPerformed(GuiButton aButton) { - if (aButton.enabled && aButton.visible) { - if (aButton.id == 1) { - if (this.mCurrentPage < this.mPageDataArray.length - 1) { - ++this.mCurrentPage; - } - } else if (aButton.id == 2) { - if (this.mCurrentPage > 0) { - --this.mCurrentPage; - } - } - this.updateButtons(); - } - } - - /** - * Handles mouse input. - */ - @Override - public void handleMouseInput() { - super.handleMouseInput(); - int i = Mouse.getEventDWheel(); - /* - * if (i != 0) { - * - * - * this.currentScroll = (float) ((double) this.currentScroll - (double) i / - * (double) j); - * - * if (this.currentScroll < 0.0F) { this.currentScroll = 0.0F; } - * - * if (this.currentScroll > 1.0F) { this.currentScroll = 1.0F; } - * - * this.scrollTo(this.currentScroll); } - */ - } - - /** - * Called when the mouse is moved or a mouse button is released. Signature: - * (mouseX, mouseY, which) which==-1 is mouseMove, which==0 or which==1 is - * mouseUp - */ - @Override - protected void mouseMovedOrUp(int p_146286_1_, int p_146286_2_, int p_146286_3_) { - /* - * if (p_146286_3_ == 0) { int l = p_146286_1_ - this.guiLeft; int i1 = - * p_146286_2_ - this.guiTop; CreativeTabs[] acreativetabs = - * CreativeTabs.creativeTabArray; int j1 = acreativetabs.length; - * - * for (int k1 = 0; k1 < j1; ++k1) { CreativeTabs creativetabs = - * acreativetabs[k1]; - * - * if (creativetabs != null && this.func_147049_a(creativetabs, l, i1)) { - * this.setCurrentCreativeTab(creativetabs); return; } } } - */ - - super.mouseMovedOrUp(p_146286_1_, p_146286_2_, p_146286_3_); - } - - /** - * Allows Mouseover Tooltips - */ - @Override - protected void renderToolTip(ItemStack aStack, int p_146285_2_, int p_146285_3_) { - super.renderToolTip(aStack, p_146285_2_, p_146285_3_); - } - - /** - * Custom Buttons - */ - - @SideOnly(Side.CLIENT) - static class GrindleGuiButton extends GuiButton { - - public static final ResourceLocation mBookTexture; - - static { - ResourceLocation r; - try { - r = (ResourceLocation) ReflectionUtils.getField(GuiScreenBook.class, "bookGuiTextures").get(null); - - } catch (IllegalArgumentException | IllegalAccessException e) { - r = new ResourceLocation("textures/gui/book.png"); - } - mBookTexture = r; - } - - private final boolean aPageForward; - - public GrindleGuiButton(int aID, int aX, int aY, boolean aForwards) { - this(aID, aX, aY, 20, 12, aForwards); - } - - public GrindleGuiButton(int aID, int aX, int aY, int aWidth, int aHeight, boolean aForwards) { - super(aID, aX, aY, aWidth, aHeight, ""); - this.aPageForward = aForwards; - } - - /** - * Draws this button to the screen. - */ - public void drawButton(Minecraft aGame, int aX, int aY) { - if (this.visible) { - boolean flag = aX >= this.xPosition && aY >= this.yPosition - && aX < this.xPosition + this.width && aY < this.yPosition + this.height; - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - aGame.getTextureManager().bindTexture(iconLocation); - int k = 0; - int l = 192; - - if (flag) { - k += 23; - } - - if (!this.aPageForward) { - l += 13; - } - - this.drawTexturedModalRect(this.xPosition, this.yPosition, k, l, 22, 12); - } - } - } - - - public static class GrindleData { - - public static enum GrindleMode { - PROSPECTING(0), - ELEMENT(1); - private final int aModeID; - private GrindleMode (final int aMode) - { - this.aModeID = aMode; - } - - public int getMode() { - return this.aModeID; - } - } - - final boolean mValid; - final ItemStack mStack; - final String mTitle, mPosInfo, mTierDim; - final AutoMap mListData; - final GrindleMode mMode; - final int mExtraInformation; - - - public GrindleData(ItemStack iStack) { - - if (iStack == null) { - mValid = false; - mStack = null; - mTitle = null; - mListData = null; - mMode = null; - mExtraInformation = 0; - this.mTierDim = ""; - this.mPosInfo = ""; - } else { - - this.mStack = iStack; - - int aType = -1; - boolean isProspecting = false; - - // If Input stack is a Data stick/Orb, set a valid type. - if (GT_Utility.areStacksEqual(iStack, CI.getDataStick(), true)) { - aType = 0; - } else if (GT_Utility.areStacksEqual(iStack, CI.getDataOrb(), true)) { - aType = 1; - } - - NBTTagCompound tNBT = iStack.getTagCompound(); - if (tNBT == null) { - tNBT = new NBTTagCompound(); - } - - mTitle = tNBT.hasKey("title") ? tNBT.getString("title") - : (aType == 0 ? "Empty Data Stick" : (aType == 1 ? "Empty Data Orb" : "Unknown Item")); - if (mTitle.toLowerCase().contains("raw prospection data")) { - isProspecting = true; - } - - byte tTier = -1; - if (isProspecting) { - if (!tNBT.hasKey("prospection_tier") && tNBT.hasKey("prospection")) { - tTier = 0; - } else if (tNBT.hasKey("prospection_tier") && !tNBT.hasKey("prospection")) { - tTier = tNBT.getByte("prospection_tier"); - } - } - - mExtraInformation = isProspecting ? tTier : -1; - - if (tTier >= 0) { - String xPos, yPos, zPos, aDim; - String aPositionString, aInfoString; - Set aOreTypes = new LinkedHashSet(); - Set aOilTypes = new LinkedHashSet(); - - // Set variables that are shared between prospection types. - if (tTier == 0) { - String tData = tNBT.getString("prospection"); - String[] tDataArray = tData.split(","); - xPos = tDataArray[0]; - yPos = tDataArray[1]; - zPos = tDataArray[2]; - aDim = tDataArray[3]; - aOilTypes.add("Oil Type: " + tDataArray[5]); - aOilTypes.add("--------------------"); - aOreTypes.add("Ore Types: "); - for (int i = 6; tDataArray.length > i; i++) { - aOreTypes.add("-" + tDataArray[i]); - } - } else { - String tPos = tNBT.getString("prospection_pos"); - String[] tPosData = tPos.split(" "); - xPos = tPosData[1]; - yPos = tPosData[3]; - zPos = tPosData[5]; - aDim = tPosData[7]; - // Oil - String tOil = tNBT.getString("prospection_oils"); - String[] tOilData = tOil.split("\\|"); - if (tOilData.length > 0) { - aOilTypes.add("Oil Types:"); - for (String s : tOilData) { - if (s != null) { - aOilTypes.add(s); - } - } - aOilTypes.add("--------------------"); - } - - // Near - String tOresNear = tNBT.getString("prospection_near"); - String[] tOresNearData = tOresNear.split("\\|"); - // Middle - String tOresMid = tNBT.getString("prospection_middle"); - String[] tOresMidData = tOresMid.split("\\|"); - // Far - String tOresFar = tNBT.getString("prospection_far"); - String[] tOresFarData = tOresFar.split("\\|"); - - if ((tOresNearData.length + tOresMidData.length + tOresFarData.length) > 0) { - aOreTypes.add("Ore Types:"); - if (tOresNearData.length > 0) { - for (String s : tOresNearData) { - if (s != null) { - aOreTypes.add("-" + s + " - Near"); - } - } - } - if (tOresMidData.length > 0) { - for (String s : tOresMidData) { - if (s != null) { - aOreTypes.add("-" + s + " - Mid"); - } - } - } - if (tOresFarData.length > 0) { - for (String s : tOresFarData) { - if (s != null) { - aOreTypes.add("-" + s + " - Far"); - } - } - } - } - } - - mListData = new AutoMap(); - if (aOilTypes.size() > 0) { - for (String aOils : aOilTypes) { - if (aOils != null && aOils.length() > 0) { - mListData.put(aOils); - } - } - } - - if (aOreTypes.size() > 0) { - for (String aOres : aOreTypes) { - if (aOres != null && aOres.length() > 0) { - mListData.put(aOres); - } - } - } - - // Set Types - mMode = GrindleMode.PROSPECTING; - this.mTierDim = (aInfoString = "Tier: " + tTier + " | Dim: " + aDim); - this.mPosInfo = (aPositionString = "X:" + xPos + ", Y:" + yPos + ", Z:" + zPos); - this.mValid = true; - } - - // Non-Prospectic Data - else { - mValid = true; - mListData = null; - mMode = GrindleMode.ELEMENT; - this.mTierDim = "PLACEHOLDER"; - this.mPosInfo = "PLACEHOLDER"; - } - - } - - } - - } - - + /** The FontRenderer used by GuiScreen */ + protected FontRenderer fontRenderer; + + private GrindleGuiButton mButtonNextPage; + private GrindleGuiButton mButtonPreviousPage; + private String[][] mPageDataArray; + private short mCurrentPage = 0; + + private static final ResourceLocation iconLocation = + new ResourceLocation(CORE.MODID, "textures/gui/itemGrindle.png"); + + /** The inventory to render on screen */ + private final BaseInventoryGrindle inventory; + + public GuiBaseGrindle(final Container_Grindle containerItem) { + super(containerItem); + this.inventory = containerItem.inventory; + } + + /** + * Draws the screen and all the components in it. + */ + @Override + public void drawScreen(final int par1, final int par2, final float par3) { + super.drawScreen(par1, par2, par3); + this.updateButtons(); + } + + /** + * Draw the foreground layer for the GuiContainer (everything in front of the + * items) + */ + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + + try { + + // Title + this.fontRendererObj.drawStringWithShadow( + I18n.format("Gregtech Information Transponder", new Object[0]), + 0, + -12, + Utils.rgbtoHexValue(255, 255, 255)); + ItemStack aStack = this.inventory.getStackInSlot(0); + + if (aStack != null) { + + GrindleData aDataCurrent = new GrindleData(aStack); + + if (aDataCurrent.mValid) { + + // Debug NBT Information + // NBTUtils.tryIterateNBTData(aStack); + + this.fontRendererObj.drawString( + I18n.format(aDataCurrent.mTitle), 10, 8, Utils.rgbtoHexValue(125, 255, 125)); + + int tTier = aDataCurrent.mExtraInformation; + if (tTier >= 0) { + // Draw the GUI + // List prospection + this.fontRendererObj.drawString( + I18n.format(aDataCurrent.mTierDim + " | Page: " + this.mCurrentPage, new Object[0]), + 10, + 18, + Utils.rgbtoHexValue(125, 255, 125)); + // Divider + this.fontRendererObj.drawString( + I18n.format("-------------------", new Object[0]), + 10, + 23, + Utils.rgbtoHexValue(125, 125, 255)); + // Pos data + this.fontRendererObj.drawString( + I18n.format(aDataCurrent.mPosInfo, new Object[0]), + 10, + 29, + Utils.rgbtoHexValue(125, 125, 255)); + // Divider + this.fontRendererObj.drawString( + I18n.format("-------------------", new Object[0]), + 10, + 35, + Utils.rgbtoHexValue(125, 125, 255)); + int aLastYUsed = 41; + + int posOuter = 0; + int posInner = 0; + + mPageDataArray = new String + [MathUtils.roundToClosestInt(Math.ceil(aDataCurrent.mListData.size() / 9.00))][9]; + for (String e : aDataCurrent.mListData) { + if (e != null) { + mPageDataArray[posInner][posOuter] = e; + if (posOuter < 8) { + posOuter++; + } else { + posOuter = 0; + posInner++; + } + } else { + continue; + } + } + + String[] aCurrentPage = mPageDataArray[this.mCurrentPage]; + + if (aCurrentPage != null) { + // Logger.INFO("valid Current page " + this.mCurrentPage); + if (aCurrentPage.length > 0) { + for (int i = 0; i < aCurrentPage.length; i++) { + if ((aLastYUsed + 9) <= (68 + 56)) { + String aCP = aCurrentPage[i]; + // Logger.INFO("Printing "+aCP); + if (aCP != null && aCP.length() > 0) { + if (!aCP.toLowerCase().contains("empty") + && !aCP.toLowerCase().contains("null")) { + this.fontRendererObj.drawString( + I18n.format(aCP), + 10, + aLastYUsed, + Utils.rgbtoHexValue(125, 255, 125)); + aLastYUsed += 9; + } + } + } + } + } + } + + } + + // Non-Prospecting Data + else { + // Draw the GUI + // List prospection + this.fontRendererObj.drawString( + I18n.format(aDataCurrent.mTierDim, new Object[0]), + 10, + 18, + Utils.rgbtoHexValue(125, 255, 125)); + // Divider + this.fontRendererObj.drawString( + I18n.format("-------------------", new Object[0]), + 10, + 23, + Utils.rgbtoHexValue(125, 125, 255)); + // Pos data + this.fontRendererObj.drawString( + I18n.format(aDataCurrent.mPosInfo, new Object[0]), + 10, + 29, + Utils.rgbtoHexValue(125, 125, 255)); + // Divider + this.fontRendererObj.drawString( + I18n.format("-------------------", new Object[0]), + 10, + 35, + Utils.rgbtoHexValue(125, 125, 255)); + int aLastYUsed = 41; + /*for (int i=0;i= 0) { + if (this.mPageDataArray != null) { + if (this.mCurrentPage < (this.mPageDataArray.length - 1)) { + this.mButtonNextPage.visible = true; + } else { + this.mButtonNextPage.visible = false; + } + } else { + this.mButtonNextPage.visible = false; + } + } + if (this.mCurrentPage > 0) { + this.mButtonPreviousPage.visible = true; + } else { + this.mButtonPreviousPage.visible = false; + } + } + + /** + * Scrolling Related + */ + @Override + protected void actionPerformed(GuiButton aButton) { + if (aButton.enabled && aButton.visible) { + if (aButton.id == 1) { + if (this.mCurrentPage < this.mPageDataArray.length - 1) { + ++this.mCurrentPage; + } + } else if (aButton.id == 2) { + if (this.mCurrentPage > 0) { + --this.mCurrentPage; + } + } + this.updateButtons(); + } + } + + /** + * Handles mouse input. + */ + @Override + public void handleMouseInput() { + super.handleMouseInput(); + int i = Mouse.getEventDWheel(); + /* + * if (i != 0) { + * + * + * this.currentScroll = (float) ((double) this.currentScroll - (double) i / + * (double) j); + * + * if (this.currentScroll < 0.0F) { this.currentScroll = 0.0F; } + * + * if (this.currentScroll > 1.0F) { this.currentScroll = 1.0F; } + * + * this.scrollTo(this.currentScroll); } + */ + } + + /** + * Called when the mouse is moved or a mouse button is released. Signature: + * (mouseX, mouseY, which) which==-1 is mouseMove, which==0 or which==1 is + * mouseUp + */ + @Override + protected void mouseMovedOrUp(int p_146286_1_, int p_146286_2_, int p_146286_3_) { + /* + * if (p_146286_3_ == 0) { int l = p_146286_1_ - this.guiLeft; int i1 = + * p_146286_2_ - this.guiTop; CreativeTabs[] acreativetabs = + * CreativeTabs.creativeTabArray; int j1 = acreativetabs.length; + * + * for (int k1 = 0; k1 < j1; ++k1) { CreativeTabs creativetabs = + * acreativetabs[k1]; + * + * if (creativetabs != null && this.func_147049_a(creativetabs, l, i1)) { + * this.setCurrentCreativeTab(creativetabs); return; } } } + */ + + super.mouseMovedOrUp(p_146286_1_, p_146286_2_, p_146286_3_); + } + + /** + * Allows Mouseover Tooltips + */ + @Override + protected void renderToolTip(ItemStack aStack, int p_146285_2_, int p_146285_3_) { + super.renderToolTip(aStack, p_146285_2_, p_146285_3_); + } + + /** + * Custom Buttons + */ + @SideOnly(Side.CLIENT) + static class GrindleGuiButton extends GuiButton { + + public static final ResourceLocation mBookTexture; + + static { + ResourceLocation r; + try { + r = (ResourceLocation) ReflectionUtils.getField(GuiScreenBook.class, "bookGuiTextures") + .get(null); + + } catch (IllegalArgumentException | IllegalAccessException e) { + r = new ResourceLocation("textures/gui/book.png"); + } + mBookTexture = r; + } + + private final boolean aPageForward; + + public GrindleGuiButton(int aID, int aX, int aY, boolean aForwards) { + this(aID, aX, aY, 20, 12, aForwards); + } + + public GrindleGuiButton(int aID, int aX, int aY, int aWidth, int aHeight, boolean aForwards) { + super(aID, aX, aY, aWidth, aHeight, ""); + this.aPageForward = aForwards; + } + + /** + * Draws this button to the screen. + */ + public void drawButton(Minecraft aGame, int aX, int aY) { + if (this.visible) { + boolean flag = aX >= this.xPosition + && aY >= this.yPosition + && aX < this.xPosition + this.width + && aY < this.yPosition + this.height; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + aGame.getTextureManager().bindTexture(iconLocation); + int k = 0; + int l = 192; + + if (flag) { + k += 23; + } + + if (!this.aPageForward) { + l += 13; + } + + this.drawTexturedModalRect(this.xPosition, this.yPosition, k, l, 22, 12); + } + } + } + + public static class GrindleData { + + public static enum GrindleMode { + PROSPECTING(0), + ELEMENT(1); + private final int aModeID; + + private GrindleMode(final int aMode) { + this.aModeID = aMode; + } + + public int getMode() { + return this.aModeID; + } + } + + final boolean mValid; + final ItemStack mStack; + final String mTitle, mPosInfo, mTierDim; + final AutoMap mListData; + final GrindleMode mMode; + final int mExtraInformation; + + public GrindleData(ItemStack iStack) { + + if (iStack == null) { + mValid = false; + mStack = null; + mTitle = null; + mListData = null; + mMode = null; + mExtraInformation = 0; + this.mTierDim = ""; + this.mPosInfo = ""; + } else { + + this.mStack = iStack; + + int aType = -1; + boolean isProspecting = false; + + // If Input stack is a Data stick/Orb, set a valid type. + if (GT_Utility.areStacksEqual(iStack, CI.getDataStick(), true)) { + aType = 0; + } else if (GT_Utility.areStacksEqual(iStack, CI.getDataOrb(), true)) { + aType = 1; + } + + NBTTagCompound tNBT = iStack.getTagCompound(); + if (tNBT == null) { + tNBT = new NBTTagCompound(); + } + + mTitle = tNBT.hasKey("title") + ? tNBT.getString("title") + : (aType == 0 ? "Empty Data Stick" : (aType == 1 ? "Empty Data Orb" : "Unknown Item")); + if (mTitle.toLowerCase().contains("raw prospection data")) { + isProspecting = true; + } + + byte tTier = -1; + if (isProspecting) { + if (!tNBT.hasKey("prospection_tier") && tNBT.hasKey("prospection")) { + tTier = 0; + } else if (tNBT.hasKey("prospection_tier") && !tNBT.hasKey("prospection")) { + tTier = tNBT.getByte("prospection_tier"); + } + } + + mExtraInformation = isProspecting ? tTier : -1; + + if (tTier >= 0) { + String xPos, yPos, zPos, aDim; + String aPositionString, aInfoString; + Set aOreTypes = new LinkedHashSet(); + Set aOilTypes = new LinkedHashSet(); + + // Set variables that are shared between prospection types. + if (tTier == 0) { + String tData = tNBT.getString("prospection"); + String[] tDataArray = tData.split(","); + xPos = tDataArray[0]; + yPos = tDataArray[1]; + zPos = tDataArray[2]; + aDim = tDataArray[3]; + aOilTypes.add("Oil Type: " + tDataArray[5]); + aOilTypes.add("--------------------"); + aOreTypes.add("Ore Types: "); + for (int i = 6; tDataArray.length > i; i++) { + aOreTypes.add("-" + tDataArray[i]); + } + } else { + String tPos = tNBT.getString("prospection_pos"); + String[] tPosData = tPos.split(" "); + xPos = tPosData[1]; + yPos = tPosData[3]; + zPos = tPosData[5]; + aDim = tPosData[7]; + // Oil + String tOil = tNBT.getString("prospection_oils"); + String[] tOilData = tOil.split("\\|"); + if (tOilData.length > 0) { + aOilTypes.add("Oil Types:"); + for (String s : tOilData) { + if (s != null) { + aOilTypes.add(s); + } + } + aOilTypes.add("--------------------"); + } + + // Near + String tOresNear = tNBT.getString("prospection_near"); + String[] tOresNearData = tOresNear.split("\\|"); + // Middle + String tOresMid = tNBT.getString("prospection_middle"); + String[] tOresMidData = tOresMid.split("\\|"); + // Far + String tOresFar = tNBT.getString("prospection_far"); + String[] tOresFarData = tOresFar.split("\\|"); + + if ((tOresNearData.length + tOresMidData.length + tOresFarData.length) > 0) { + aOreTypes.add("Ore Types:"); + if (tOresNearData.length > 0) { + for (String s : tOresNearData) { + if (s != null) { + aOreTypes.add("-" + s + " - Near"); + } + } + } + if (tOresMidData.length > 0) { + for (String s : tOresMidData) { + if (s != null) { + aOreTypes.add("-" + s + " - Mid"); + } + } + } + if (tOresFarData.length > 0) { + for (String s : tOresFarData) { + if (s != null) { + aOreTypes.add("-" + s + " - Far"); + } + } + } + } + } + + mListData = new AutoMap(); + if (aOilTypes.size() > 0) { + for (String aOils : aOilTypes) { + if (aOils != null && aOils.length() > 0) { + mListData.put(aOils); + } + } + } + + if (aOreTypes.size() > 0) { + for (String aOres : aOreTypes) { + if (aOres != null && aOres.length() > 0) { + mListData.put(aOres); + } + } + } + + // Set Types + mMode = GrindleMode.PROSPECTING; + this.mTierDim = (aInfoString = "Tier: " + tTier + " | Dim: " + aDim); + this.mPosInfo = (aPositionString = "X:" + xPos + ", Y:" + yPos + ", Z:" + zPos); + this.mValid = true; + } + + // Non-Prospectic Data + else { + mValid = true; + mListData = null; + mMode = GrindleMode.ELEMENT; + this.mTierDim = "PLACEHOLDER"; + this.mPosInfo = "PLACEHOLDER"; + } + } + } + } } diff --git a/src/main/java/gtPlusPlus/core/gui/item/GuiScreenGrindle.java b/src/main/java/gtPlusPlus/core/gui/item/GuiScreenGrindle.java index cf94fbbb84..f9b0e8c161 100644 --- a/src/main/java/gtPlusPlus/core/gui/item/GuiScreenGrindle.java +++ b/src/main/java/gtPlusPlus/core/gui/item/GuiScreenGrindle.java @@ -1,13 +1,15 @@ package gtPlusPlus.core.gui.item; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.lwjgl.input.Keyboard; -import org.lwjgl.opengl.GL11; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.core.container.Container_Grindle; +import gtPlusPlus.core.inventories.BaseInventoryGrindle; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.NBTUtils; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; @@ -23,468 +25,487 @@ import net.minecraft.network.play.client.C17PacketCustomPayload; import net.minecraft.util.ChatAllowedCharacters; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; - -import gtPlusPlus.core.container.Container_Grindle; -import gtPlusPlus.core.inventories.BaseInventoryGrindle; -import gtPlusPlus.core.item.ModItems; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.minecraft.NBTUtils; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class GuiScreenGrindle extends GuiContainer { - private static final Logger logger = LogManager.getLogger(); - private static final ResourceLocation bookGuiTextures = new ResourceLocation("textures/gui/book.png"); - /** The player editing the book */ - private final EntityPlayer editingPlayer; - private final ItemStack bookObj; - /** Whether the book is signed or can still be edited */ - private final boolean bookIsUnsigned; - private boolean field_146481_r; - private boolean field_146480_s; - /** Update ticks since the gui was opened */ - private int updateCount; - private final int bookImageWidth = 192; - private final int bookImageHeight = 192; - private int bookTotalPages = 1; - private int currPage; - private NBTTagList bookPages; - private String bookTitle = ""; - private GuiScreenGrindle.NextPageButton buttonNextPage; - private GuiScreenGrindle.NextPageButton buttonPreviousPage; - private GuiButton buttonDone; - /** The GuiButton to sign this book. */ - private GuiButton buttonSign; - private GuiButton buttonFinalize; - private GuiButton buttonCancel; - - // Texture - private static final ResourceLocation iconLocation = new ResourceLocation(CORE.MODID, - "textures/gui/itemGrindle.png"); - - /** The inventory to render on screen */ - private final BaseInventoryGrindle inventory; - - public GuiScreenGrindle(final Container_Grindle containerItem, final EntityPlayer player) { - super(containerItem); - this.inventory = containerItem.inventory; - this.editingPlayer = player; - this.bookObj = this.inventory.getStackInSlot(0); - this.bookIsUnsigned = (this.bookObj == null ? true : false); - - if (this.bookObj != null) { - if (this.bookObj.hasTagCompound()) { - final NBTTagCompound nbttagcompound = this.bookObj.getTagCompound(); - this.bookPages = nbttagcompound.getTagList("pages", 8); - - if (this.bookPages != null) { - this.bookPages = (NBTTagList) this.bookPages.copy(); - this.bookTotalPages = this.bookPages.tagCount(); - - if (this.bookTotalPages < 1) { - this.bookTotalPages = 1; - } - } - } - - - if ((this.bookPages == null) && this.bookIsUnsigned) { this.bookPages = - new NBTTagList(); this.bookPages.appendTag(new NBTTagString("")); - this.bookTotalPages = 1; } - - } - } - - /** - * Called from the main game loop to update the screen. - */ - @Override - public void updateScreen() { - super.updateScreen(); - ++this.updateCount; - } - - /** - * Adds the buttons (and other controls) to the screen in question. - */ - @Override - @SuppressWarnings("unchecked") - public void initGui() { - this.buttonList.clear(); - Keyboard.enableRepeatEvents(true); - - if (this.bookIsUnsigned) { - this.buttonList.add(this.buttonSign = new GuiButton(3, (this.width / 2) - 100, 4 + this.bookImageHeight, 98, - 20, I18n.format("book.signButton", new Object[0]))); - this.buttonList.add(this.buttonDone = new GuiButton(0, (this.width / 2) + 2, this.bookImageHeight-4, 98, - 20, I18n.format("gui.close", new Object[0]))); - this.buttonList.add(this.buttonFinalize = new GuiButton(5, (this.width / 2) - 100, 4 + this.bookImageHeight, - 98, 20, I18n.format("book.finalizeButton", new Object[0]))); - this.buttonList.add(this.buttonCancel = new GuiButton(4, (this.width / 2) + 2, 4 + this.bookImageHeight, 98, - 20, I18n.format("gui.cancel", new Object[0]))); - } - else { - this.buttonList.add(this.buttonDone = new GuiButton(0, (this.width / 2) - 100, this.bookImageHeight+100, - 200, 20, I18n.format("gui.done", new Object[0]))); - } - - final int i = (this.width - this.bookImageWidth) / 2; - final byte b0 = 2; - this.buttonList.add(this.buttonNextPage = new GuiScreenGrindle.NextPageButton(1, i + 120, b0 + 154, true)); - this.buttonList.add(this.buttonPreviousPage = new GuiScreenGrindle.NextPageButton(2, i + 38, b0 + 154, false)); - this.updateButtons(); - } - - /** - * Called when the screen is unloaded. Used to disable keyboard repeat - * events - */ - @Override - public void onGuiClosed() { - Keyboard.enableRepeatEvents(false); - } - - private void updateButtons() { - this.buttonNextPage.visible = !this.field_146480_s - && ((this.currPage < (this.bookTotalPages - 1)) || this.bookIsUnsigned); - this.buttonPreviousPage.visible = !this.field_146480_s && (this.currPage > 0); - this.buttonDone.visible = !this.bookIsUnsigned || !this.field_146480_s; - - if (this.bookIsUnsigned) { - this.buttonSign.visible = !this.field_146480_s; - this.buttonCancel.visible = this.field_146480_s; - this.buttonFinalize.visible = this.field_146480_s; - this.buttonFinalize.enabled = this.bookTitle.trim().length() > 0; - } - } - - private void sendBookToServer(final boolean p_146462_1_) { - if (this.bookIsUnsigned && this.field_146481_r) { - if (this.bookPages != null) { - String s; - - while (this.bookPages.tagCount() > 1) { - s = this.bookPages.getStringTagAt(this.bookPages.tagCount() - 1); - - if (s.length() != 0) { - break; - } - - this.bookPages.removeTag(this.bookPages.tagCount() - 1); - } - - if (this.bookObj.hasTagCompound()) { - final NBTTagCompound nbttagcompound = this.bookObj.getTagCompound(); - nbttagcompound.setTag("pages", this.bookPages); - } - else { - this.bookObj.setTagInfo("pages", this.bookPages); - } - - s = "MC|BEdit"; - - if (p_146462_1_) { - s = "MC|BSign"; - this.bookObj.setTagInfo("author", new NBTTagString(this.editingPlayer.getCommandSenderName())); - this.bookObj.setTagInfo("title", new NBTTagString(this.bookTitle.trim())); - this.bookObj.func_150996_a(ModItems.itemGrindleTablet); - } - - final ByteBuf bytebuf = Unpooled.buffer(); - - try { - (new PacketBuffer(bytebuf)).writeItemStackToBuffer(this.bookObj); - this.mc.getNetHandler().addToSendQueue(new C17PacketCustomPayload(s, bytebuf)); - } - catch (final Exception exception) { - logger.error("Couldn\'t send book info", exception); - } - finally { - bytebuf.release(); - } - } - } - } - - @Override - protected void actionPerformed(final GuiButton button) { - if (button.enabled) { - if (button.id == 0) { - this.mc.displayGuiScreen((GuiScreen) null); - this.sendBookToServer(false); - } - else if ((button.id == 3) && this.bookIsUnsigned) { - this.field_146480_s = true; - } - else if (button.id == 1) { - if (this.currPage < (this.bookTotalPages - 1)) { - ++this.currPage; - } - else if (this.bookIsUnsigned) { - this.addNewPage(); - - if (this.currPage < (this.bookTotalPages - 1)) { - ++this.currPage; - } - } - } - else if (button.id == 2) { - if (this.currPage > 0) { - --this.currPage; - } - } - else if ((button.id == 5) && this.field_146480_s) { - this.sendBookToServer(true); - this.mc.displayGuiScreen((GuiScreen) null); - } - else if ((button.id == 4) && this.field_146480_s) { - this.field_146480_s = false; - } - - this.updateButtons(); - } - } - - private void addNewPage() { - if ((this.bookPages != null) && (this.bookPages.tagCount() < 50)) { - this.bookPages.appendTag(new NBTTagString("")); - ++this.bookTotalPages; - this.field_146481_r = true; - } - } - - /** - * Fired when a key is typed. This is the equivalent of - * KeyListener.keyTyped(KeyEvent e). - */ - @Override - protected void keyTyped(final char p_73869_1_, final int p_73869_2_) { - super.keyTyped(p_73869_1_, p_73869_2_); - - if (this.bookIsUnsigned) { - if (this.field_146480_s) { - this.func_146460_c(p_73869_1_, p_73869_2_); - } - else { - this.keyTypedInBook(p_73869_1_, p_73869_2_); - } - } - } - - /** - * Processes keystrokes when editing the text of a book - */ - private void keyTypedInBook(final char p_146463_1_, final int p_146463_2_) { - switch (p_146463_1_) { - case 22: - this.func_146459_b(GuiScreen.getClipboardString()); - return; - default: - switch (p_146463_2_) { - case 14: - final String s = this.func_146456_p(); - - if (s.length() > 0) { - this.func_146457_a(s.substring(0, s.length() - 1)); - } - - return; - case 28: - case 156: - this.func_146459_b("\n"); - return; - default: - if (ChatAllowedCharacters.isAllowedCharacter(p_146463_1_)) { - this.func_146459_b(Character.toString(p_146463_1_)); - } - } - } - } - - private void func_146460_c(final char p_146460_1_, final int p_146460_2_) { - switch (p_146460_2_) { - case 14: - if (!this.bookTitle.isEmpty()) { - this.bookTitle = this.bookTitle.substring(0, this.bookTitle.length() - 1); - this.updateButtons(); - } - - return; - case 28: - case 156: - if (!this.bookTitle.isEmpty()) { - this.sendBookToServer(true); - this.mc.displayGuiScreen((GuiScreen) null); - } - - return; - default: - if ((this.bookTitle.length() < 16) && ChatAllowedCharacters.isAllowedCharacter(p_146460_1_)) { - this.bookTitle = this.bookTitle + Character.toString(p_146460_1_); - this.updateButtons(); - this.field_146481_r = true; - } - } - } - - private String func_146456_p() { - return (this.bookPages != null) && (this.currPage >= 0) && (this.currPage < this.bookPages.tagCount()) - ? this.bookPages.getStringTagAt(this.currPage) : ""; - } - - private void func_146457_a(final String p_146457_1_) { - if ((this.bookPages != null) && (this.currPage >= 0) && (this.currPage < this.bookPages.tagCount())) { - this.bookPages.func_150304_a(this.currPage, new NBTTagString(p_146457_1_)); - this.field_146481_r = true; - } - } - - private void func_146459_b(final String p_146459_1_) { - final String s1 = this.func_146456_p(); - final String s2 = s1 + p_146459_1_; - final int i = this.fontRendererObj.splitStringWidth(s2 + "" + EnumChatFormatting.BLACK + "_", 118); - - if ((i <= 118) && (s2.length() < 256)) { - this.func_146457_a(s2); - } - } - - /** - * Draws the screen and all the components in it. - */ - @Override - public void drawScreen(final int p_73863_1_, final int p_73863_2_, final float p_73863_3_) { - - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.getTextureManager().bindTexture(iconLocation); - final int k = (this.width - this.xSize) / 2; - final int l2 = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(k, l2, 0, 0, this.xSize, this.ySize); - - //GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - //this.mc.getTextureManager().bindTexture(iconLocation); - //final int k = (this.width - this.bookImageWidth) / 2; - //this.drawTexturedModalRect(k, b0, 0, 0, this.bookImageWidth, - // this.bookImageHeight); - - String s; - String s1; - int l; - final byte b0 = 2; - - if (this.inventory.getStackInSlot(0) != null) { - this.fontRendererObj.drawString( - I18n.format("" + NBTUtils.getBookTitle(this.inventory.getStackInSlot(0)), new Object[0]), 10, 8, - Utils.rgbtoHexValue(125, 255, 125)); - } - - if (this.field_146480_s) { - s = this.bookTitle; - - if (this.bookIsUnsigned) { - if (((this.updateCount / 6) % 2) == 0) { - s = s + "" + EnumChatFormatting.BLACK + "_"; - } - else { - s = s + "" + EnumChatFormatting.GRAY + "_"; - } - } - - s1 = I18n.format("book.editTitle", new Object[0]); - l = this.fontRendererObj.getStringWidth(s1); - this.fontRendererObj.drawString(s1, k + 36 + ((116 - l) / 2), b0 + 16 + 16, 0); - final int i1 = this.fontRendererObj.getStringWidth(s); - this.fontRendererObj.drawString(s, k + 36 + ((116 - i1) / 2), b0 + 48, 0); - final String s2 = I18n.format("book.byAuthor", new Object[] { this.editingPlayer.getCommandSenderName() }); - final int j1 = this.fontRendererObj.getStringWidth(s2); - this.fontRendererObj.drawString(EnumChatFormatting.DARK_GRAY + s2, k + 36 + ((116 - j1) / 2), b0 + 48 + 10, - 0); - final String s3 = I18n.format("book.finalizeWarning", new Object[0]); - this.fontRendererObj.drawSplitString(s3, k + 36, b0 + 80, 116, 0); - } - else { - s = I18n.format("book.pageIndicator", - new Object[] { Integer.valueOf(this.currPage + 1), Integer.valueOf(this.bookTotalPages) }); - s1 = ""; - - if ((this.bookPages != null) && (this.currPage >= 0) && (this.currPage < this.bookPages.tagCount())) { - s1 = this.bookPages.getStringTagAt(this.currPage); - } - - if (this.bookIsUnsigned) { - if (this.fontRendererObj.getBidiFlag()) { - s1 = s1 + "_"; - } - else if (((this.updateCount / 6) % 2) == 0) { - s1 = s1 + "" + EnumChatFormatting.BLACK + "_"; - } - else { - s1 = s1 + "" + EnumChatFormatting.GRAY + "_"; - } - } - - l = this.fontRendererObj.getStringWidth(s); - this.fontRendererObj.drawString(s, ((k - l) + this.bookImageWidth) - 44, b0 + 16, 0); - //this.fontRendererObj.drawString(s, k+36, b0 + 16, 0); - this.fontRendererObj.drawSplitString(s1, k + 36, b0 + 16 + 16, 116, 0); - //this.fontRendererObj.drawSplitString(s1, k, b0 + 16 + 16, 116, 0); - } - - super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_); - } - - @SideOnly(Side.CLIENT) - static class NextPageButton extends GuiButton { - private final boolean field_146151_o; - - public NextPageButton(final int p_i1079_1_, final int p_i1079_2_, final int p_i1079_3_, - final boolean p_i1079_4_) { - super(p_i1079_1_, p_i1079_2_, p_i1079_3_, 23, 13, ""); - this.field_146151_o = p_i1079_4_; - } - - /** - * Draws this button to the screen. - */ - @Override - public void drawButton(final Minecraft p_146112_1_, final int p_146112_2_, final int p_146112_3_) { - if (this.visible) { - final boolean flag = (p_146112_2_ >= this.xPosition) && (p_146112_3_ >= this.yPosition) - && (p_146112_2_ < (this.xPosition + this.width)) - && (p_146112_3_ < (this.yPosition + this.height)); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - p_146112_1_.getTextureManager().bindTexture(GuiScreenGrindle.bookGuiTextures); - int k = 0; - int l = 192; - - if (flag) { - k += 23; - } - - if (!this.field_146151_o) { - l += 13; - } - - this.drawTexturedModalRect(this.xPosition, this.yPosition, k, l, 23, 13); - } - } - } - - /** - * Draw the background layer for the GuiContainer (everything behind the - * items) - */ - @Override - protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.getTextureManager().bindTexture(iconLocation); - final int k = (this.width - this.xSize) / 2; - final int l = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); - final int i1; - // drawPlayerModel(k + 51, l + 75, 30, k + 51 - this.xSize_lo, (l + 75) - // - 50 - this.ySize_lo, this.mc.thePlayer); - } -} \ No newline at end of file + private static final Logger logger = LogManager.getLogger(); + private static final ResourceLocation bookGuiTextures = new ResourceLocation("textures/gui/book.png"); + /** The player editing the book */ + private final EntityPlayer editingPlayer; + + private final ItemStack bookObj; + /** Whether the book is signed or can still be edited */ + private final boolean bookIsUnsigned; + + private boolean field_146481_r; + private boolean field_146480_s; + /** Update ticks since the gui was opened */ + private int updateCount; + + private final int bookImageWidth = 192; + private final int bookImageHeight = 192; + private int bookTotalPages = 1; + private int currPage; + private NBTTagList bookPages; + private String bookTitle = ""; + private GuiScreenGrindle.NextPageButton buttonNextPage; + private GuiScreenGrindle.NextPageButton buttonPreviousPage; + private GuiButton buttonDone; + /** The GuiButton to sign this book. */ + private GuiButton buttonSign; + + private GuiButton buttonFinalize; + private GuiButton buttonCancel; + + // Texture + private static final ResourceLocation iconLocation = + new ResourceLocation(CORE.MODID, "textures/gui/itemGrindle.png"); + + /** The inventory to render on screen */ + private final BaseInventoryGrindle inventory; + + public GuiScreenGrindle(final Container_Grindle containerItem, final EntityPlayer player) { + super(containerItem); + this.inventory = containerItem.inventory; + this.editingPlayer = player; + this.bookObj = this.inventory.getStackInSlot(0); + this.bookIsUnsigned = (this.bookObj == null ? true : false); + + if (this.bookObj != null) { + if (this.bookObj.hasTagCompound()) { + final NBTTagCompound nbttagcompound = this.bookObj.getTagCompound(); + this.bookPages = nbttagcompound.getTagList("pages", 8); + + if (this.bookPages != null) { + this.bookPages = (NBTTagList) this.bookPages.copy(); + this.bookTotalPages = this.bookPages.tagCount(); + + if (this.bookTotalPages < 1) { + this.bookTotalPages = 1; + } + } + } + + if ((this.bookPages == null) && this.bookIsUnsigned) { + this.bookPages = new NBTTagList(); + this.bookPages.appendTag(new NBTTagString("")); + this.bookTotalPages = 1; + } + } + } + + /** + * Called from the main game loop to update the screen. + */ + @Override + public void updateScreen() { + super.updateScreen(); + ++this.updateCount; + } + + /** + * Adds the buttons (and other controls) to the screen in question. + */ + @Override + @SuppressWarnings("unchecked") + public void initGui() { + this.buttonList.clear(); + Keyboard.enableRepeatEvents(true); + + if (this.bookIsUnsigned) { + this.buttonList.add( + this.buttonSign = new GuiButton( + 3, + (this.width / 2) - 100, + 4 + this.bookImageHeight, + 98, + 20, + I18n.format("book.signButton", new Object[0]))); + this.buttonList.add( + this.buttonDone = new GuiButton( + 0, + (this.width / 2) + 2, + this.bookImageHeight - 4, + 98, + 20, + I18n.format("gui.close", new Object[0]))); + this.buttonList.add( + this.buttonFinalize = new GuiButton( + 5, + (this.width / 2) - 100, + 4 + this.bookImageHeight, + 98, + 20, + I18n.format("book.finalizeButton", new Object[0]))); + this.buttonList.add( + this.buttonCancel = new GuiButton( + 4, + (this.width / 2) + 2, + 4 + this.bookImageHeight, + 98, + 20, + I18n.format("gui.cancel", new Object[0]))); + } else { + this.buttonList.add( + this.buttonDone = new GuiButton( + 0, + (this.width / 2) - 100, + this.bookImageHeight + 100, + 200, + 20, + I18n.format("gui.done", new Object[0]))); + } + + final int i = (this.width - this.bookImageWidth) / 2; + final byte b0 = 2; + this.buttonList.add(this.buttonNextPage = new GuiScreenGrindle.NextPageButton(1, i + 120, b0 + 154, true)); + this.buttonList.add(this.buttonPreviousPage = new GuiScreenGrindle.NextPageButton(2, i + 38, b0 + 154, false)); + this.updateButtons(); + } + + /** + * Called when the screen is unloaded. Used to disable keyboard repeat + * events + */ + @Override + public void onGuiClosed() { + Keyboard.enableRepeatEvents(false); + } + + private void updateButtons() { + this.buttonNextPage.visible = + !this.field_146480_s && ((this.currPage < (this.bookTotalPages - 1)) || this.bookIsUnsigned); + this.buttonPreviousPage.visible = !this.field_146480_s && (this.currPage > 0); + this.buttonDone.visible = !this.bookIsUnsigned || !this.field_146480_s; + + if (this.bookIsUnsigned) { + this.buttonSign.visible = !this.field_146480_s; + this.buttonCancel.visible = this.field_146480_s; + this.buttonFinalize.visible = this.field_146480_s; + this.buttonFinalize.enabled = this.bookTitle.trim().length() > 0; + } + } + + private void sendBookToServer(final boolean p_146462_1_) { + if (this.bookIsUnsigned && this.field_146481_r) { + if (this.bookPages != null) { + String s; + + while (this.bookPages.tagCount() > 1) { + s = this.bookPages.getStringTagAt(this.bookPages.tagCount() - 1); + + if (s.length() != 0) { + break; + } + + this.bookPages.removeTag(this.bookPages.tagCount() - 1); + } + + if (this.bookObj.hasTagCompound()) { + final NBTTagCompound nbttagcompound = this.bookObj.getTagCompound(); + nbttagcompound.setTag("pages", this.bookPages); + } else { + this.bookObj.setTagInfo("pages", this.bookPages); + } + + s = "MC|BEdit"; + + if (p_146462_1_) { + s = "MC|BSign"; + this.bookObj.setTagInfo("author", new NBTTagString(this.editingPlayer.getCommandSenderName())); + this.bookObj.setTagInfo("title", new NBTTagString(this.bookTitle.trim())); + this.bookObj.func_150996_a(ModItems.itemGrindleTablet); + } + + final ByteBuf bytebuf = Unpooled.buffer(); + + try { + (new PacketBuffer(bytebuf)).writeItemStackToBuffer(this.bookObj); + this.mc.getNetHandler().addToSendQueue(new C17PacketCustomPayload(s, bytebuf)); + } catch (final Exception exception) { + logger.error("Couldn\'t send book info", exception); + } finally { + bytebuf.release(); + } + } + } + } + + @Override + protected void actionPerformed(final GuiButton button) { + if (button.enabled) { + if (button.id == 0) { + this.mc.displayGuiScreen((GuiScreen) null); + this.sendBookToServer(false); + } else if ((button.id == 3) && this.bookIsUnsigned) { + this.field_146480_s = true; + } else if (button.id == 1) { + if (this.currPage < (this.bookTotalPages - 1)) { + ++this.currPage; + } else if (this.bookIsUnsigned) { + this.addNewPage(); + + if (this.currPage < (this.bookTotalPages - 1)) { + ++this.currPage; + } + } + } else if (button.id == 2) { + if (this.currPage > 0) { + --this.currPage; + } + } else if ((button.id == 5) && this.field_146480_s) { + this.sendBookToServer(true); + this.mc.displayGuiScreen((GuiScreen) null); + } else if ((button.id == 4) && this.field_146480_s) { + this.field_146480_s = false; + } + + this.updateButtons(); + } + } + + private void addNewPage() { + if ((this.bookPages != null) && (this.bookPages.tagCount() < 50)) { + this.bookPages.appendTag(new NBTTagString("")); + ++this.bookTotalPages; + this.field_146481_r = true; + } + } + + /** + * Fired when a key is typed. This is the equivalent of + * KeyListener.keyTyped(KeyEvent e). + */ + @Override + protected void keyTyped(final char p_73869_1_, final int p_73869_2_) { + super.keyTyped(p_73869_1_, p_73869_2_); + + if (this.bookIsUnsigned) { + if (this.field_146480_s) { + this.func_146460_c(p_73869_1_, p_73869_2_); + } else { + this.keyTypedInBook(p_73869_1_, p_73869_2_); + } + } + } + + /** + * Processes keystrokes when editing the text of a book + */ + private void keyTypedInBook(final char p_146463_1_, final int p_146463_2_) { + switch (p_146463_1_) { + case 22: + this.func_146459_b(GuiScreen.getClipboardString()); + return; + default: + switch (p_146463_2_) { + case 14: + final String s = this.func_146456_p(); + + if (s.length() > 0) { + this.func_146457_a(s.substring(0, s.length() - 1)); + } + + return; + case 28: + case 156: + this.func_146459_b("\n"); + return; + default: + if (ChatAllowedCharacters.isAllowedCharacter(p_146463_1_)) { + this.func_146459_b(Character.toString(p_146463_1_)); + } + } + } + } + + private void func_146460_c(final char p_146460_1_, final int p_146460_2_) { + switch (p_146460_2_) { + case 14: + if (!this.bookTitle.isEmpty()) { + this.bookTitle = this.bookTitle.substring(0, this.bookTitle.length() - 1); + this.updateButtons(); + } + + return; + case 28: + case 156: + if (!this.bookTitle.isEmpty()) { + this.sendBookToServer(true); + this.mc.displayGuiScreen((GuiScreen) null); + } + + return; + default: + if ((this.bookTitle.length() < 16) && ChatAllowedCharacters.isAllowedCharacter(p_146460_1_)) { + this.bookTitle = this.bookTitle + Character.toString(p_146460_1_); + this.updateButtons(); + this.field_146481_r = true; + } + } + } + + private String func_146456_p() { + return (this.bookPages != null) && (this.currPage >= 0) && (this.currPage < this.bookPages.tagCount()) + ? this.bookPages.getStringTagAt(this.currPage) + : ""; + } + + private void func_146457_a(final String p_146457_1_) { + if ((this.bookPages != null) && (this.currPage >= 0) && (this.currPage < this.bookPages.tagCount())) { + this.bookPages.func_150304_a(this.currPage, new NBTTagString(p_146457_1_)); + this.field_146481_r = true; + } + } + + private void func_146459_b(final String p_146459_1_) { + final String s1 = this.func_146456_p(); + final String s2 = s1 + p_146459_1_; + final int i = this.fontRendererObj.splitStringWidth(s2 + "" + EnumChatFormatting.BLACK + "_", 118); + + if ((i <= 118) && (s2.length() < 256)) { + this.func_146457_a(s2); + } + } + + /** + * Draws the screen and all the components in it. + */ + @Override + public void drawScreen(final int p_73863_1_, final int p_73863_2_, final float p_73863_3_) { + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(iconLocation); + final int k = (this.width - this.xSize) / 2; + final int l2 = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l2, 0, 0, this.xSize, this.ySize); + + // GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + // this.mc.getTextureManager().bindTexture(iconLocation); + // final int k = (this.width - this.bookImageWidth) / 2; + // this.drawTexturedModalRect(k, b0, 0, 0, this.bookImageWidth, + // this.bookImageHeight); + + String s; + String s1; + int l; + final byte b0 = 2; + + if (this.inventory.getStackInSlot(0) != null) { + this.fontRendererObj.drawString( + I18n.format("" + NBTUtils.getBookTitle(this.inventory.getStackInSlot(0)), new Object[0]), + 10, + 8, + Utils.rgbtoHexValue(125, 255, 125)); + } + + if (this.field_146480_s) { + s = this.bookTitle; + + if (this.bookIsUnsigned) { + if (((this.updateCount / 6) % 2) == 0) { + s = s + "" + EnumChatFormatting.BLACK + "_"; + } else { + s = s + "" + EnumChatFormatting.GRAY + "_"; + } + } + + s1 = I18n.format("book.editTitle", new Object[0]); + l = this.fontRendererObj.getStringWidth(s1); + this.fontRendererObj.drawString(s1, k + 36 + ((116 - l) / 2), b0 + 16 + 16, 0); + final int i1 = this.fontRendererObj.getStringWidth(s); + this.fontRendererObj.drawString(s, k + 36 + ((116 - i1) / 2), b0 + 48, 0); + final String s2 = I18n.format("book.byAuthor", new Object[] {this.editingPlayer.getCommandSenderName()}); + final int j1 = this.fontRendererObj.getStringWidth(s2); + this.fontRendererObj.drawString( + EnumChatFormatting.DARK_GRAY + s2, k + 36 + ((116 - j1) / 2), b0 + 48 + 10, 0); + final String s3 = I18n.format("book.finalizeWarning", new Object[0]); + this.fontRendererObj.drawSplitString(s3, k + 36, b0 + 80, 116, 0); + } else { + s = I18n.format( + "book.pageIndicator", + new Object[] {Integer.valueOf(this.currPage + 1), Integer.valueOf(this.bookTotalPages)}); + s1 = ""; + + if ((this.bookPages != null) && (this.currPage >= 0) && (this.currPage < this.bookPages.tagCount())) { + s1 = this.bookPages.getStringTagAt(this.currPage); + } + + if (this.bookIsUnsigned) { + if (this.fontRendererObj.getBidiFlag()) { + s1 = s1 + "_"; + } else if (((this.updateCount / 6) % 2) == 0) { + s1 = s1 + "" + EnumChatFormatting.BLACK + "_"; + } else { + s1 = s1 + "" + EnumChatFormatting.GRAY + "_"; + } + } + + l = this.fontRendererObj.getStringWidth(s); + this.fontRendererObj.drawString(s, ((k - l) + this.bookImageWidth) - 44, b0 + 16, 0); + // this.fontRendererObj.drawString(s, k+36, b0 + 16, 0); + this.fontRendererObj.drawSplitString(s1, k + 36, b0 + 16 + 16, 116, 0); + // this.fontRendererObj.drawSplitString(s1, k, b0 + 16 + 16, 116, 0); + } + + super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_); + } + + @SideOnly(Side.CLIENT) + static class NextPageButton extends GuiButton { + private final boolean field_146151_o; + + public NextPageButton( + final int p_i1079_1_, final int p_i1079_2_, final int p_i1079_3_, final boolean p_i1079_4_) { + super(p_i1079_1_, p_i1079_2_, p_i1079_3_, 23, 13, ""); + this.field_146151_o = p_i1079_4_; + } + + /** + * Draws this button to the screen. + */ + @Override + public void drawButton(final Minecraft p_146112_1_, final int p_146112_2_, final int p_146112_3_) { + if (this.visible) { + final boolean flag = (p_146112_2_ >= this.xPosition) + && (p_146112_3_ >= this.yPosition) + && (p_146112_2_ < (this.xPosition + this.width)) + && (p_146112_3_ < (this.yPosition + this.height)); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + p_146112_1_.getTextureManager().bindTexture(GuiScreenGrindle.bookGuiTextures); + int k = 0; + int l = 192; + + if (flag) { + k += 23; + } + + if (!this.field_146151_o) { + l += 13; + } + + this.drawTexturedModalRect(this.xPosition, this.yPosition, k, l, 23, 13); + } + } + } + + /** + * Draw the background layer for the GuiContainer (everything behind the + * items) + */ + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(iconLocation); + final int k = (this.width - this.xSize) / 2; + final int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + final int i1; + // drawPlayerModel(k + 51, l + 75, 30, k + 51 - this.xSize_lo, (l + 75) + // - 50 - this.ySize_lo, this.mc.thePlayer); + } +} diff --git a/src/main/java/gtPlusPlus/core/gui/item/box/GuiBaseBox.java b/src/main/java/gtPlusPlus/core/gui/item/box/GuiBaseBox.java index 97ec58bfa4..575419857d 100644 --- a/src/main/java/gtPlusPlus/core/gui/item/box/GuiBaseBox.java +++ b/src/main/java/gtPlusPlus/core/gui/item/box/GuiBaseBox.java @@ -1,8 +1,5 @@ package gtPlusPlus.core.gui.item.box; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL12; - import gtPlusPlus.core.item.tool.misc.box.ContainerBoxBase; import gtPlusPlus.core.item.tool.misc.box.CustomBoxInventory; import net.minecraft.client.gui.inventory.GuiContainer; @@ -12,105 +9,114 @@ import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.resources.I18n; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; public class GuiBaseBox extends GuiContainer { - /** - * x and y size of the inventory window in pixels. Defined as float, passed as - * int These are used for drawing the player model. - */ - private float xSize_lo; - private float ySize_lo; + /** + * x and y size of the inventory window in pixels. Defined as float, passed as + * int These are used for drawing the player model. + */ + private float xSize_lo; + + private float ySize_lo; - /** - * ResourceLocation takes 2 parameters: ModId, path to texture at the location: - * "src/minecraft/assets/modid/" - * - * I have provided a sample texture file that works with this tutorial. Download - * it from Forge_Tutorials/textures/gui/ - */ - private final ResourceLocation iconLocation; + /** + * ResourceLocation takes 2 parameters: ModId, path to texture at the location: + * "src/minecraft/assets/modid/" + * + * I have provided a sample texture file that works with this tutorial. Download + * it from Forge_Tutorials/textures/gui/ + */ + private final ResourceLocation iconLocation; - /** The inventory to render on screen */ - private final CustomBoxInventory inventory; + /** The inventory to render on screen */ + private final CustomBoxInventory inventory; - public GuiBaseBox(ContainerBoxBase containerItem, ResourceLocation aGuiTexture) { - super(containerItem); - this.inventory = containerItem.getInventoryObject(); - this.iconLocation = aGuiTexture; - } + public GuiBaseBox(ContainerBoxBase containerItem, ResourceLocation aGuiTexture) { + super(containerItem); + this.inventory = containerItem.getInventoryObject(); + this.iconLocation = aGuiTexture; + } - /** - * Draws the screen and all the components in it. - */ - public void drawScreen(int par1, int par2, float par3) { - super.drawScreen(par1, par2, par3); - this.xSize_lo = (float) par1; - this.ySize_lo = (float) par2; - } + /** + * Draws the screen and all the components in it. + */ + public void drawScreen(int par1, int par2, float par3) { + super.drawScreen(par1, par2, par3); + this.xSize_lo = (float) par1; + this.ySize_lo = (float) par2; + } - /** - * Draw the foreground layer for the GuiContainer (everything in front of the - * items) - */ - protected void drawGuiContainerForegroundLayer(int par1, int par2) { - String s = this.inventory.hasCustomInventoryName() ? this.inventory.getInventoryName() - : I18n.format(this.inventory.getInventoryName()); - this.fontRendererObj.drawString(s, this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2, 0, 4210752); - this.fontRendererObj.drawString(I18n.format("container.inventory"), 26, this.ySize - 96 + 4, 4210752); - } + /** + * Draw the foreground layer for the GuiContainer (everything in front of the + * items) + */ + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + String s = this.inventory.hasCustomInventoryName() + ? this.inventory.getInventoryName() + : I18n.format(this.inventory.getInventoryName()); + this.fontRendererObj.drawString(s, this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2, 0, 4210752); + this.fontRendererObj.drawString(I18n.format("container.inventory"), 26, this.ySize - 96 + 4, 4210752); + } - /** - * Draw the background layer for the GuiContainer (everything behind the items) - */ - protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.getTextureManager().bindTexture(iconLocation); - int k = (this.width - this.xSize) / 2; - int l = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); - int i1; - drawPlayerModel(k + 51, l + 75, 30, (float) (k + 51) - this.xSize_lo, (float) (l + 75 - 50) - this.ySize_lo, - this.mc.thePlayer); - } + /** + * Draw the background layer for the GuiContainer (everything behind the items) + */ + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(iconLocation); + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + int i1; + drawPlayerModel( + k + 51, + l + 75, + 30, + (float) (k + 51) - this.xSize_lo, + (float) (l + 75 - 50) - this.ySize_lo, + this.mc.thePlayer); + } - /** - * This renders the player model in standard inventory position (in later - * versions of Minecraft / Forge, you can simply call - * GuiInventory.drawEntityOnScreen directly instead of copying this code) - */ - public static void drawPlayerModel(int x, int y, int scale, float yaw, float pitch, EntityLivingBase entity) { - GL11.glEnable(GL11.GL_COLOR_MATERIAL); - GL11.glPushMatrix(); - GL11.glTranslatef(x, y, 50.0F); - GL11.glScalef(-scale, scale, scale); - GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); - float f2 = entity.renderYawOffset; - float f3 = entity.rotationYaw; - float f4 = entity.rotationPitch; - float f5 = entity.prevRotationYawHead; - float f6 = entity.rotationYawHead; - GL11.glRotatef(135.0F, 0.0F, 1.0F, 0.0F); - RenderHelper.enableStandardItemLighting(); - GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-((float) Math.atan(pitch / 40.0F)) * 20.0F, 1.0F, 0.0F, 0.0F); - entity.renderYawOffset = (float) Math.atan(yaw / 40.0F) * 20.0F; - entity.rotationYaw = (float) Math.atan(yaw / 40.0F) * 40.0F; - entity.rotationPitch = -((float) Math.atan(pitch / 40.0F)) * 20.0F; - entity.rotationYawHead = entity.rotationYaw; - entity.prevRotationYawHead = entity.rotationYaw; - GL11.glTranslatef(0.0F, entity.yOffset, 0.0F); - RenderManager.instance.playerViewY = 180.0F; - RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); - entity.renderYawOffset = f2; - entity.rotationYaw = f3; - entity.rotationPitch = f4; - entity.prevRotationYawHead = f5; - entity.rotationYawHead = f6; - GL11.glPopMatrix(); - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); - GL11.glDisable(GL11.GL_TEXTURE_2D); - OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); - } -} \ No newline at end of file + /** + * This renders the player model in standard inventory position (in later + * versions of Minecraft / Forge, you can simply call + * GuiInventory.drawEntityOnScreen directly instead of copying this code) + */ + public static void drawPlayerModel(int x, int y, int scale, float yaw, float pitch, EntityLivingBase entity) { + GL11.glEnable(GL11.GL_COLOR_MATERIAL); + GL11.glPushMatrix(); + GL11.glTranslatef(x, y, 50.0F); + GL11.glScalef(-scale, scale, scale); + GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); + float f2 = entity.renderYawOffset; + float f3 = entity.rotationYaw; + float f4 = entity.rotationPitch; + float f5 = entity.prevRotationYawHead; + float f6 = entity.rotationYawHead; + GL11.glRotatef(135.0F, 0.0F, 1.0F, 0.0F); + RenderHelper.enableStandardItemLighting(); + GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-((float) Math.atan(pitch / 40.0F)) * 20.0F, 1.0F, 0.0F, 0.0F); + entity.renderYawOffset = (float) Math.atan(yaw / 40.0F) * 20.0F; + entity.rotationYaw = (float) Math.atan(yaw / 40.0F) * 40.0F; + entity.rotationPitch = -((float) Math.atan(pitch / 40.0F)) * 20.0F; + entity.rotationYawHead = entity.rotationYaw; + entity.prevRotationYawHead = entity.rotationYaw; + GL11.glTranslatef(0.0F, entity.yOffset, 0.0F); + RenderManager.instance.playerViewY = 180.0F; + RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); + entity.renderYawOffset = f2; + entity.rotationYaw = f3; + entity.rotationPitch = f4; + entity.prevRotationYawHead = f5; + entity.rotationYawHead = f6; + GL11.glPopMatrix(); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GL11.glDisable(GL11.GL_TEXTURE_2D); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + } +} diff --git a/src/main/java/gtPlusPlus/core/gui/item/box/LunchBoxGui.java b/src/main/java/gtPlusPlus/core/gui/item/box/LunchBoxGui.java index 28e3913ac8..0b8d76a6b4 100644 --- a/src/main/java/gtPlusPlus/core/gui/item/box/LunchBoxGui.java +++ b/src/main/java/gtPlusPlus/core/gui/item/box/LunchBoxGui.java @@ -5,7 +5,7 @@ import gtPlusPlus.core.lib.CORE; import net.minecraft.util.ResourceLocation; public class LunchBoxGui extends GuiBaseBox { - public LunchBoxGui(ContainerBoxBase containerItem) { - super(containerItem, new ResourceLocation(CORE.MODID, "textures/gui/schematic_rocket_GS1.png")); - } + public LunchBoxGui(ContainerBoxBase containerItem) { + super(containerItem, new ResourceLocation(CORE.MODID, "textures/gui/schematic_rocket_GS1.png")); + } } diff --git a/src/main/java/gtPlusPlus/core/gui/item/box/MagicBagGui.java b/src/main/java/gtPlusPlus/core/gui/item/box/MagicBagGui.java index 958cdd3c70..c2665d2bf0 100644 --- a/src/main/java/gtPlusPlus/core/gui/item/box/MagicBagGui.java +++ b/src/main/java/gtPlusPlus/core/gui/item/box/MagicBagGui.java @@ -5,7 +5,7 @@ import gtPlusPlus.core.lib.CORE; import net.minecraft.util.ResourceLocation; public class MagicBagGui extends GuiBaseBox { - public MagicBagGui(ContainerBoxBase containerItem) { - super(containerItem, new ResourceLocation(CORE.MODID, "textures/gui/schematic_rocket_GS1.png")); - } + public MagicBagGui(ContainerBoxBase containerItem) { + super(containerItem, new ResourceLocation(CORE.MODID, "textures/gui/schematic_rocket_GS1.png")); + } } diff --git a/src/main/java/gtPlusPlus/core/gui/item/box/ToolBoxGui.java b/src/main/java/gtPlusPlus/core/gui/item/box/ToolBoxGui.java index c440c017e9..01e3a38b4d 100644 --- a/src/main/java/gtPlusPlus/core/gui/item/box/ToolBoxGui.java +++ b/src/main/java/gtPlusPlus/core/gui/item/box/ToolBoxGui.java @@ -5,7 +5,7 @@ import gtPlusPlus.core.lib.CORE; import net.minecraft.util.ResourceLocation; public class ToolBoxGui extends GuiBaseBox { - public ToolBoxGui(ContainerBoxBase containerItem) { - super(containerItem, new ResourceLocation(CORE.MODID, "textures/gui/schematic_rocket_GS1.png")); - } + public ToolBoxGui(ContainerBoxBase containerItem) { + super(containerItem, new ResourceLocation(CORE.MODID, "textures/gui/schematic_rocket_GS1.png")); + } } diff --git a/src/main/java/gtPlusPlus/core/gui/machine/GUI_CircuitProgrammer.java b/src/main/java/gtPlusPlus/core/gui/machine/GUI_CircuitProgrammer.java index 2ab5b58aa7..94e7aab248 100644 --- a/src/main/java/gtPlusPlus/core/gui/machine/GUI_CircuitProgrammer.java +++ b/src/main/java/gtPlusPlus/core/gui/machine/GUI_CircuitProgrammer.java @@ -1,44 +1,42 @@ package gtPlusPlus.core.gui.machine; -import org.lwjgl.opengl.GL11; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; import gtPlusPlus.core.container.Container_CircuitProgrammer; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.tileentities.general.TileEntityCircuitProgrammer; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class GUI_CircuitProgrammer extends GuiContainer { - private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation(CORE.MODID, "textures/gui/CircuitProgrammer.png"); - - public GUI_CircuitProgrammer(final InventoryPlayer player_inventory, final TileEntityCircuitProgrammer te){ - super(new Container_CircuitProgrammer(player_inventory, te)); - } - - @Override - protected void drawGuiContainerForegroundLayer(final int i, final int j){ - super.drawGuiContainerForegroundLayer(i, j); - } - - @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j){ - GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - this.mc.renderEngine.bindTexture(craftingTableGuiTextures); - final int x = (this.width - this.xSize) / 2; - final int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } - - //This method is called when the Gui is first called! - @Override - public void initGui(){ - super.initGui(); - } - -} \ No newline at end of file + private static final ResourceLocation craftingTableGuiTextures = + new ResourceLocation(CORE.MODID, "textures/gui/CircuitProgrammer.png"); + + public GUI_CircuitProgrammer(final InventoryPlayer player_inventory, final TileEntityCircuitProgrammer te) { + super(new Container_CircuitProgrammer(player_inventory, te)); + } + + @Override + protected void drawGuiContainerForegroundLayer(final int i, final int j) { + super.drawGuiContainerForegroundLayer(i, j); + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j) { + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + this.mc.renderEngine.bindTexture(craftingTableGuiTextures); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } + + // This method is called when the Gui is first called! + @Override + public void initGui() { + super.initGui(); + } +} diff --git a/src/main/java/gtPlusPlus/core/gui/machine/GUI_DecayablesChest.java b/src/main/java/gtPlusPlus/core/gui/machine/GUI_DecayablesChest.java index 094629ae48..76c718511a 100644 --- a/src/main/java/gtPlusPlus/core/gui/machine/GUI_DecayablesChest.java +++ b/src/main/java/gtPlusPlus/core/gui/machine/GUI_DecayablesChest.java @@ -1,59 +1,53 @@ package gtPlusPlus.core.gui.machine; -import org.lwjgl.opengl.GL11; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; - import gtPlusPlus.core.container.Container_DecayablesChest; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.tileentities.general.TileEntityDecayablesChest; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class GUI_DecayablesChest extends GuiContainer { - private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation(CORE.MODID, "textures/gui/FishTrap.png"); - - public GUI_DecayablesChest(final InventoryPlayer player_inventory, final TileEntityDecayablesChest te){ - super(new Container_DecayablesChest(player_inventory, te)); - } - - - @Override - protected void drawGuiContainerForegroundLayer(final int i, final int j){ - //this.fontRendererObj.drawString(I18n.format("Workbench", new Object[0]), 28, 6, 4210752); - //this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); - - } - - - @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j){ - GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - this.mc.renderEngine.bindTexture(craftingTableGuiTextures); - final int x = (this.width - this.xSize) / 2; - final int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } - - - //This method is called when the Gui is first called! - @Override - public void initGui() - { - //You have to add this line for the Gui to function properly! - super.initGui(); - - //The parameters of GuiButton are(id, x, y, width, height, text); - //this.buttonList.add(new GuiButton( 1, 367, 132, 18, 18, "X")); - //this.buttonList.add(new GuiButton( 2, 385, 132, 18, 18, "Y")); - //NOTE: the id always has to be different or else it might get called twice or never! - - //Add any other buttons here too! - } - -} \ No newline at end of file + private static final ResourceLocation craftingTableGuiTextures = + new ResourceLocation(CORE.MODID, "textures/gui/FishTrap.png"); + + public GUI_DecayablesChest(final InventoryPlayer player_inventory, final TileEntityDecayablesChest te) { + super(new Container_DecayablesChest(player_inventory, te)); + } + + @Override + protected void drawGuiContainerForegroundLayer(final int i, final int j) { + // this.fontRendererObj.drawString(I18n.format("Workbench", new Object[0]), 28, 6, 4210752); + // this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, + // 4210752); + + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j) { + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + this.mc.renderEngine.bindTexture(craftingTableGuiTextures); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } + + // This method is called when the Gui is first called! + @Override + public void initGui() { + // You have to add this line for the Gui to function properly! + super.initGui(); + + // The parameters of GuiButton are(id, x, y, width, height, text); + // this.buttonList.add(new GuiButton( 1, 367, 132, 18, 18, "X")); + // this.buttonList.add(new GuiButton( 2, 385, 132, 18, 18, "Y")); + // NOTE: the id always has to be different or else it might get called twice or never! + + // Add any other buttons here too! + } +} diff --git a/src/main/java/gtPlusPlus/core/gui/machine/GUI_EggBox.java b/src/main/java/gtPlusPlus/core/gui/machine/GUI_EggBox.java index 49d9890d3a..a931fc93c5 100644 --- a/src/main/java/gtPlusPlus/core/gui/machine/GUI_EggBox.java +++ b/src/main/java/gtPlusPlus/core/gui/machine/GUI_EggBox.java @@ -1,60 +1,53 @@ package gtPlusPlus.core.gui.machine; -import org.lwjgl.opengl.GL11; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.core.container.Container_EggBox; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.general.TileEntityEggBox; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; - -import gtPlusPlus.core.container.Container_EggBox; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.tileentities.general.TileEntityEggBox; +import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class GUI_EggBox extends GuiContainer { - private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation(CORE.MODID, "textures/gui/FishTrap.png"); - - public GUI_EggBox(final InventoryPlayer player_inventory, final TileEntityEggBox te){ - super(new Container_EggBox(player_inventory, te)); - } - - - @Override - protected void drawGuiContainerForegroundLayer(final int i, final int j){ - //this.fontRendererObj.drawString(I18n.format("Workbench", new Object[0]), 28, 6, 4210752); - this.fontRendererObj.drawString(I18n.format("container.EggBox", new Object[0]), 8, this.ySize - 96 + 2, 4210752); - - } - - - @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j){ - GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - this.mc.renderEngine.bindTexture(craftingTableGuiTextures); - final int x = (this.width - this.xSize) / 2; - final int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } - - - //This method is called when the Gui is first called! - @Override - public void initGui() - { - //You have to add this line for the Gui to function properly! - super.initGui(); - - //The parameters of GuiButton are(id, x, y, width, height, text); - //this.buttonList.add(new GuiButton( 1, 367, 132, 18, 18, "X")); - //this.buttonList.add(new GuiButton( 2, 385, 132, 18, 18, "Y")); - //NOTE: the id always has to be different or else it might get called twice or never! - - //Add any other buttons here too! - } - -} \ No newline at end of file + private static final ResourceLocation craftingTableGuiTextures = + new ResourceLocation(CORE.MODID, "textures/gui/FishTrap.png"); + + public GUI_EggBox(final InventoryPlayer player_inventory, final TileEntityEggBox te) { + super(new Container_EggBox(player_inventory, te)); + } + + @Override + protected void drawGuiContainerForegroundLayer(final int i, final int j) { + // this.fontRendererObj.drawString(I18n.format("Workbench", new Object[0]), 28, 6, 4210752); + this.fontRendererObj.drawString( + I18n.format("container.EggBox", new Object[0]), 8, this.ySize - 96 + 2, 4210752); + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j) { + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + this.mc.renderEngine.bindTexture(craftingTableGuiTextures); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } + + // This method is called when the Gui is first called! + @Override + public void initGui() { + // You have to add this line for the Gui to function properly! + super.initGui(); + + // The parameters of GuiButton are(id, x, y, width, height, text); + // this.buttonList.add(new GuiButton( 1, 367, 132, 18, 18, "X")); + // this.buttonList.add(new GuiButton( 2, 385, 132, 18, 18, "Y")); + // NOTE: the id always has to be different or else it might get called twice or never! + + // Add any other buttons here too! + } +} diff --git a/src/main/java/gtPlusPlus/core/gui/machine/GUI_FishTrap.java b/src/main/java/gtPlusPlus/core/gui/machine/GUI_FishTrap.java index 3d3bad7ece..e751f6eeee 100644 --- a/src/main/java/gtPlusPlus/core/gui/machine/GUI_FishTrap.java +++ b/src/main/java/gtPlusPlus/core/gui/machine/GUI_FishTrap.java @@ -1,59 +1,53 @@ package gtPlusPlus.core.gui.machine; -import org.lwjgl.opengl.GL11; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; - import gtPlusPlus.core.container.Container_FishTrap; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.tileentities.general.TileEntityFishTrap; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class GUI_FishTrap extends GuiContainer { - private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation(CORE.MODID, "textures/gui/FishTrap.png"); - - public GUI_FishTrap(final InventoryPlayer player_inventory, final TileEntityFishTrap te){ - super(new Container_FishTrap(player_inventory, te)); - } - - - @Override - protected void drawGuiContainerForegroundLayer(final int i, final int j){ - //this.fontRendererObj.drawString(I18n.format("Workbench", new Object[0]), 28, 6, 4210752); - //this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); - - } - - - @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j){ - GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - this.mc.renderEngine.bindTexture(craftingTableGuiTextures); - final int x = (this.width - this.xSize) / 2; - final int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } - - - //This method is called when the Gui is first called! - @Override - public void initGui() - { - //You have to add this line for the Gui to function properly! - super.initGui(); - - //The parameters of GuiButton are(id, x, y, width, height, text); - //this.buttonList.add(new GuiButton( 1, 367, 132, 18, 18, "X")); - //this.buttonList.add(new GuiButton( 2, 385, 132, 18, 18, "Y")); - //NOTE: the id always has to be different or else it might get called twice or never! - - //Add any other buttons here too! - } - -} \ No newline at end of file + private static final ResourceLocation craftingTableGuiTextures = + new ResourceLocation(CORE.MODID, "textures/gui/FishTrap.png"); + + public GUI_FishTrap(final InventoryPlayer player_inventory, final TileEntityFishTrap te) { + super(new Container_FishTrap(player_inventory, te)); + } + + @Override + protected void drawGuiContainerForegroundLayer(final int i, final int j) { + // this.fontRendererObj.drawString(I18n.format("Workbench", new Object[0]), 28, 6, 4210752); + // this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, + // 4210752); + + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j) { + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + this.mc.renderEngine.bindTexture(craftingTableGuiTextures); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } + + // This method is called when the Gui is first called! + @Override + public void initGui() { + // You have to add this line for the Gui to function properly! + super.initGui(); + + // The parameters of GuiButton are(id, x, y, width, height, text); + // this.buttonList.add(new GuiButton( 1, 367, 132, 18, 18, "X")); + // this.buttonList.add(new GuiButton( 2, 385, 132, 18, 18, "Y")); + // NOTE: the id always has to be different or else it might get called twice or never! + + // Add any other buttons here too! + } +} diff --git a/src/main/java/gtPlusPlus/core/gui/machine/GUI_HeliumGenerator.java b/src/main/java/gtPlusPlus/core/gui/machine/GUI_HeliumGenerator.java index 44d5c2ff9c..6aafc46a08 100644 --- a/src/main/java/gtPlusPlus/core/gui/machine/GUI_HeliumGenerator.java +++ b/src/main/java/gtPlusPlus/core/gui/machine/GUI_HeliumGenerator.java @@ -1,39 +1,36 @@ package gtPlusPlus.core.gui.machine; -import org.lwjgl.opengl.GL11; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; - import gtPlusPlus.core.container.Container_HeliumGenerator; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.tileentities.general.TileEntityHeliumGenerator; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class GUI_HeliumGenerator extends GuiContainer { - private static final ResourceLocation guiTexture = new ResourceLocation(CORE.MODID, "textures/gui/helium_collector_gui.png"); - - public GUI_HeliumGenerator(final InventoryPlayer player_inventory, final TileEntityHeliumGenerator te){ - super(new Container_HeliumGenerator(player_inventory, te)); - } - - @Override - protected void drawGuiContainerForegroundLayer(final int i, final int j){ - //this.fontRendererObj.drawString(I18n.format("", new Object[0]), 28, 6, 4210752); - } - - @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j){ - GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - this.mc.renderEngine.bindTexture(guiTexture); - final int x = (this.width - this.xSize) / 2; - final int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } - -} \ No newline at end of file + private static final ResourceLocation guiTexture = + new ResourceLocation(CORE.MODID, "textures/gui/helium_collector_gui.png"); + + public GUI_HeliumGenerator(final InventoryPlayer player_inventory, final TileEntityHeliumGenerator te) { + super(new Container_HeliumGenerator(player_inventory, te)); + } + + @Override + protected void drawGuiContainerForegroundLayer(final int i, final int j) { + // this.fontRendererObj.drawString(I18n.format("", new Object[0]), 28, 6, 4210752); + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j) { + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + this.mc.renderEngine.bindTexture(guiTexture); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } +} diff --git a/src/main/java/gtPlusPlus/core/gui/machine/GUI_ModularityTable.java b/src/main/java/gtPlusPlus/core/gui/machine/GUI_ModularityTable.java index bbd4dd0ad8..14e37a7f87 100644 --- a/src/main/java/gtPlusPlus/core/gui/machine/GUI_ModularityTable.java +++ b/src/main/java/gtPlusPlus/core/gui/machine/GUI_ModularityTable.java @@ -1,83 +1,75 @@ package gtPlusPlus.core.gui.machine; -import org.lwjgl.opengl.GL11; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.core.container.Container_ModularityTable; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.machines.TileEntityModularityTable; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; - -import gtPlusPlus.core.container.Container_ModularityTable; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.tileentities.machines.TileEntityModularityTable; +import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class GUI_ModularityTable extends GuiContainer { - private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation(CORE.MODID, "textures/gui/ModularityTable.png"); - private Container_ModularityTable mThisContainer; - private TileEntityModularityTable mThisTile; - private int mRecipeTime = -1; - - public GUI_ModularityTable(final InventoryPlayer player_inventory, final TileEntityModularityTable tile){ - super(new Container_ModularityTable(player_inventory, tile)); - this.mThisContainer = tile.getContainer(); - this.mThisTile = tile; - if (this.mThisTile.getRecipeTime() > -1){ - this.mRecipeTime = this.mThisTile.getRecipeTime(); - } - } - - - @Override - protected void drawGuiContainerForegroundLayer(final int i, final int j){ - if (this.mThisTile.getRecipeTime() > -1){ - this.mRecipeTime = this.mThisTile.getRecipeTime(); - } - //Utils.LOG_INFO("Container: "+this.mRecipeTime); - this.fontRendererObj.drawString(I18n.format("Modularity Table", new Object[0]), 8, 6, 4210752); - if (mRecipeTime > -1){ - this.fontRendererObj.drawString(I18n.format("Time", new Object[0]), 84, 42, 4210752); - this.fontRendererObj.drawString(I18n.format("Remaining", new Object[0]), 84, 50, 4210752); - this.fontRendererObj.drawString(I18n.format(""+this.mRecipeTime+" Ticks", new Object[0]), 84, 58, 4210752); - } - this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); - - } - - - @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j){ - GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - this.mc.renderEngine.bindTexture(craftingTableGuiTextures); - final int x = (this.width - this.xSize) / 2; - final int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } - - - //This method is called when the Gui is first called! - @Override - public void initGui(){ - //You have to add this line for the Gui to function properly! - super.initGui(); - - //The parameters of GuiButton are(id, x, y, width, height, text); - //this.buttonList.add(new GuiButton( 1, 367, 132, 18, 18, "X")); - //this.buttonList.add(new GuiButton( 2, 385, 132, 18, 18, "Y")); - //NOTE: the id always has to be different or else it might get called twice or never! - - //Add any other buttons here too! - } - - @Override - protected void actionPerformed(final GuiButton B){ - - - } - -} \ No newline at end of file + private static final ResourceLocation craftingTableGuiTextures = + new ResourceLocation(CORE.MODID, "textures/gui/ModularityTable.png"); + private Container_ModularityTable mThisContainer; + private TileEntityModularityTable mThisTile; + private int mRecipeTime = -1; + + public GUI_ModularityTable(final InventoryPlayer player_inventory, final TileEntityModularityTable tile) { + super(new Container_ModularityTable(player_inventory, tile)); + this.mThisContainer = tile.getContainer(); + this.mThisTile = tile; + if (this.mThisTile.getRecipeTime() > -1) { + this.mRecipeTime = this.mThisTile.getRecipeTime(); + } + } + + @Override + protected void drawGuiContainerForegroundLayer(final int i, final int j) { + if (this.mThisTile.getRecipeTime() > -1) { + this.mRecipeTime = this.mThisTile.getRecipeTime(); + } + // Utils.LOG_INFO("Container: "+this.mRecipeTime); + this.fontRendererObj.drawString(I18n.format("Modularity Table", new Object[0]), 8, 6, 4210752); + if (mRecipeTime > -1) { + this.fontRendererObj.drawString(I18n.format("Time", new Object[0]), 84, 42, 4210752); + this.fontRendererObj.drawString(I18n.format("Remaining", new Object[0]), 84, 50, 4210752); + this.fontRendererObj.drawString( + I18n.format("" + this.mRecipeTime + " Ticks", new Object[0]), 84, 58, 4210752); + } + this.fontRendererObj.drawString( + I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j) { + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + this.mc.renderEngine.bindTexture(craftingTableGuiTextures); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } + + // This method is called when the Gui is first called! + @Override + public void initGui() { + // You have to add this line for the Gui to function properly! + super.initGui(); + + // The parameters of GuiButton are(id, x, y, width, height, text); + // this.buttonList.add(new GuiButton( 1, 367, 132, 18, 18, "X")); + // this.buttonList.add(new GuiButton( 2, 385, 132, 18, 18, "Y")); + // NOTE: the id always has to be different or else it might get called twice or never! + + // Add any other buttons here too! + } + + @Override + protected void actionPerformed(final GuiButton B) {} +} diff --git a/src/main/java/gtPlusPlus/core/gui/machine/GUI_PestKiller.java b/src/main/java/gtPlusPlus/core/gui/machine/GUI_PestKiller.java index 881c6c82a1..45a1bb6049 100644 --- a/src/main/java/gtPlusPlus/core/gui/machine/GUI_PestKiller.java +++ b/src/main/java/gtPlusPlus/core/gui/machine/GUI_PestKiller.java @@ -1,9 +1,5 @@ package gtPlusPlus.core.gui.machine; -import java.awt.Color; - -import org.lwjgl.opengl.GL11; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.core.container.Container_PestKiller; @@ -11,6 +7,7 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.MISC_MATERIALS; import gtPlusPlus.core.tileentities.machines.TileEntityPestKiller; import gtPlusPlus.core.util.math.MathUtils; +import java.awt.Color; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.InventoryPlayer; @@ -18,142 +15,138 @@ import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.IFluidTank; +import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class GUI_PestKiller extends GuiContainer { - private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation(CORE.MODID, "textures/gui/PestKiller.png"); - private final TileEntityPestKiller mTileKiller; + private static final ResourceLocation craftingTableGuiTextures = + new ResourceLocation(CORE.MODID, "textures/gui/PestKiller.png"); + private final TileEntityPestKiller mTileKiller; + + public GUI_PestKiller(final InventoryPlayer player_inventory, final TileEntityPestKiller te) { + super(new Container_PestKiller(player_inventory, te)); + mTileKiller = te; + } + + @Override + protected void drawGuiContainerForegroundLayer(final int i, final int j) { + if (mTileKiller != null) { + this.fontRendererObj.drawString(I18n.format(mTileKiller.getInventoryName(), new Object[0]), 4, 6, 4210752); + drawFluidTank(mTileKiller.getTank(), 134, 35); + } + } - public GUI_PestKiller(final InventoryPlayer player_inventory, final TileEntityPestKiller te) { - super(new Container_PestKiller(player_inventory, te)); - mTileKiller = te; - } + @Override + protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j) { + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + this.mc.renderEngine.bindTexture(craftingTableGuiTextures); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } - @Override - protected void drawGuiContainerForegroundLayer(final int i, final int j) { - if (mTileKiller != null) { - this.fontRendererObj.drawString(I18n.format(mTileKiller.getInventoryName(), new Object[0]), 4, 6, 4210752); - drawFluidTank(mTileKiller.getTank(), 134, 35); - } - } + // This method is called when the Gui is first called! + @Override + public void initGui() { + super.initGui(); + } - @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j) { - GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - this.mc.renderEngine.bindTexture(craftingTableGuiTextures); - final int x = (this.width - this.xSize) / 2; - final int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } + private void drawFluidTank(IFluidTank tank, int x, int y) { + Color startGrad = new Color(50, 50, 50); + Color endGrad = new Color(20, 20, 20); + Container_PestKiller aCont = (Container_PestKiller) this.inventorySlots; - // This method is called when the Gui is first called! - @Override - public void initGui() { - super.initGui(); - } + double aPercentage = 0; + double aDivisor = (100 / 16); + int aFrameHeight = 16; - private void drawFluidTank(IFluidTank tank, int x, int y) { - Color startGrad = new Color(50, 50, 50); - Color endGrad = new Color(20, 20, 20); - Container_PestKiller aCont = (Container_PestKiller) this.inventorySlots; - - double aPercentage = 0; - double aDivisor = (100/16); - int aFrameHeight = 16; - - boolean didRender = false; - if (aCont != null) { - TileEntityPestKiller aTile = mTileKiller; - if (aTile != null) { - FluidTank aTank = aTile.getTank(); - int aTier = aTile.getTier(); - drawGradientRect(x, y, x+16, y+16, startGrad.getRGB(), endGrad.getRGB()); - if (aTier <= 0 || aTier > 2) { - if (aTank != null && aTank.getFluidAmount() > 0) { - aPercentage = MathUtils.findPercentage(aTank.getFluidAmount(), aTank.getCapacity()); - //Logger.INFO("Percent = "+aPercentage); - aFrameHeight = (int) (aPercentage / aDivisor); - //Logger.INFO("Frame Height = "+aFrameHeight); - } - this.fontRendererObj.drawString("Tier: 0", 4, 18, 4210752); - this.fontRendererObj.drawString("Range: 1x1", 4, 30, 4210752); - this.fontRendererObj.drawString("Poison: None", 4, 42, 4210752); - this.fontRendererObj.drawString("Amount: 0", 4, 64, 4210752); - didRender = true; - } - else if (aTier == 1) { - if (aTank != null && aTank.getFluidAmount() > 0) { - aPercentage = MathUtils.findPercentage(aTank.getFluidAmount(), aTank.getCapacity()); - //Logger.INFO("Percent = "+aPercentage); - aFrameHeight = (int) (aPercentage / aDivisor); - //Logger.INFO("Frame Height = "+aFrameHeight); - } - startGrad = new Color(240, 50, 240); - endGrad = new Color(130, 30, 130); - drawGradientRect(x, y+(16-aFrameHeight), x+16, y+16, startGrad.getRGB(), endGrad.getRGB()); - this.fontRendererObj.drawString("Tier: 1", 4, 18, 4210752); - this.fontRendererObj.drawString("Range: 5x5", 4, 30, 4210752); - this.fontRendererObj.drawString("Poison: ", 4, 42, 4210752); - this.fontRendererObj.drawString(""+aTile.getTank().getFluid().getLocalizedName(), 4, 54, 4210752); - this.fontRendererObj.drawString("Amount: "+aTile.getTank().getFluidAmount(), 4, 64, 4210752); - didRender = true; - } - else if (aTier == 2) { - if (aTank != null && aTank.getFluidAmount() > 0) { - aPercentage = MathUtils.findPercentage(aTank.getFluidAmount(), aTank.getCapacity()); - //Logger.INFO("Percent = "+aPercentage); - aFrameHeight = (int) (aPercentage / aDivisor); - //Logger.INFO("Frame Height = "+aFrameHeight); - } - short[] aRGB = MISC_MATERIALS.HYDROGEN_CYANIDE.getRGB(); - startGrad = new Color(aRGB[0], aRGB[1], aRGB[2]); - endGrad = new Color(Math.max(aRGB[0], 0), Math.max(aRGB[1], 0), Math.max(aRGB[2], 0)); - drawGradientRect(x, y+(16-aFrameHeight), x+16, y+16, startGrad.getRGB(), endGrad.getRGB()); - this.fontRendererObj.drawString("Tier: 2", 4, 18, 4210752); - this.fontRendererObj.drawString("Range: 9x9", 4, 30, 4210752); - this.fontRendererObj.drawString("Poison: ", 4, 42, 4210752); - this.fontRendererObj.drawString(""+aTile.getTank().getFluid().getLocalizedName(), 4, 54, 4210752); - this.fontRendererObj.drawString("Amount: "+aTile.getTank().getFluidAmount(), 4, 64, 4210752); - didRender = true; - } - } - } - if (!didRender) { - startGrad = new Color(255, 30, 120); - endGrad = new Color(255, 0, 50); - drawGradientRect(x, y, x+16, y+16, startGrad.getRGB(), endGrad.getRGB()); - this.fontRendererObj.drawString("Tier: 0", 4, 18, 4210752); - } - - - - - - - /* - * FluidStack fluid = tank.getFluid(); TextureManager manager = - * mc.getTextureManager(); if (fluid != null) { - * manager.bindTexture(manager.getResourceLocation(0)); float amount = - * fluid.amount; float capacity = tank.getCapacity(); float scale = amount / - * capacity; int fluidTankHeight = 60; int fluidAmount = (int) (scale * - * fluidTankHeight); drawFluid(x, y + fluidTankHeight - fluidAmount, - * fluid.getFluid().getIcon(fluid), 16, fluidAmount); } - */ - } + boolean didRender = false; + if (aCont != null) { + TileEntityPestKiller aTile = mTileKiller; + if (aTile != null) { + FluidTank aTank = aTile.getTank(); + int aTier = aTile.getTier(); + drawGradientRect(x, y, x + 16, y + 16, startGrad.getRGB(), endGrad.getRGB()); + if (aTier <= 0 || aTier > 2) { + if (aTank != null && aTank.getFluidAmount() > 0) { + aPercentage = MathUtils.findPercentage(aTank.getFluidAmount(), aTank.getCapacity()); + // Logger.INFO("Percent = "+aPercentage); + aFrameHeight = (int) (aPercentage / aDivisor); + // Logger.INFO("Frame Height = "+aFrameHeight); + } + this.fontRendererObj.drawString("Tier: 0", 4, 18, 4210752); + this.fontRendererObj.drawString("Range: 1x1", 4, 30, 4210752); + this.fontRendererObj.drawString("Poison: None", 4, 42, 4210752); + this.fontRendererObj.drawString("Amount: 0", 4, 64, 4210752); + didRender = true; + } else if (aTier == 1) { + if (aTank != null && aTank.getFluidAmount() > 0) { + aPercentage = MathUtils.findPercentage(aTank.getFluidAmount(), aTank.getCapacity()); + // Logger.INFO("Percent = "+aPercentage); + aFrameHeight = (int) (aPercentage / aDivisor); + // Logger.INFO("Frame Height = "+aFrameHeight); + } + startGrad = new Color(240, 50, 240); + endGrad = new Color(130, 30, 130); + drawGradientRect(x, y + (16 - aFrameHeight), x + 16, y + 16, startGrad.getRGB(), endGrad.getRGB()); + this.fontRendererObj.drawString("Tier: 1", 4, 18, 4210752); + this.fontRendererObj.drawString("Range: 5x5", 4, 30, 4210752); + this.fontRendererObj.drawString("Poison: ", 4, 42, 4210752); + this.fontRendererObj.drawString( + "" + aTile.getTank().getFluid().getLocalizedName(), 4, 54, 4210752); + this.fontRendererObj.drawString("Amount: " + aTile.getTank().getFluidAmount(), 4, 64, 4210752); + didRender = true; + } else if (aTier == 2) { + if (aTank != null && aTank.getFluidAmount() > 0) { + aPercentage = MathUtils.findPercentage(aTank.getFluidAmount(), aTank.getCapacity()); + // Logger.INFO("Percent = "+aPercentage); + aFrameHeight = (int) (aPercentage / aDivisor); + // Logger.INFO("Frame Height = "+aFrameHeight); + } + short[] aRGB = MISC_MATERIALS.HYDROGEN_CYANIDE.getRGB(); + startGrad = new Color(aRGB[0], aRGB[1], aRGB[2]); + endGrad = new Color(Math.max(aRGB[0], 0), Math.max(aRGB[1], 0), Math.max(aRGB[2], 0)); + drawGradientRect(x, y + (16 - aFrameHeight), x + 16, y + 16, startGrad.getRGB(), endGrad.getRGB()); + this.fontRendererObj.drawString("Tier: 2", 4, 18, 4210752); + this.fontRendererObj.drawString("Range: 9x9", 4, 30, 4210752); + this.fontRendererObj.drawString("Poison: ", 4, 42, 4210752); + this.fontRendererObj.drawString( + "" + aTile.getTank().getFluid().getLocalizedName(), 4, 54, 4210752); + this.fontRendererObj.drawString("Amount: " + aTile.getTank().getFluidAmount(), 4, 64, 4210752); + didRender = true; + } + } + } + if (!didRender) { + startGrad = new Color(255, 30, 120); + endGrad = new Color(255, 0, 50); + drawGradientRect(x, y, x + 16, y + 16, startGrad.getRGB(), endGrad.getRGB()); + this.fontRendererObj.drawString("Tier: 0", 4, 18, 4210752); + } - private void drawFluid(int x, int y, IIcon icon, int width, int height) { - int i = 0; - int j = 0; - int drawHeight = 0; - int drawWidth = 0; - for (i = 0; i < width; i += 16) { - for (j = 0; j < height; j += 16) { - drawWidth = Math.min(width - i, 16); - drawHeight = Math.min(height - j, 16); - drawTexturedModelRectFromIcon(x + i, y + j, icon, drawWidth, drawHeight); - } - } - } + /* + * FluidStack fluid = tank.getFluid(); TextureManager manager = + * mc.getTextureManager(); if (fluid != null) { + * manager.bindTexture(manager.getResourceLocation(0)); float amount = + * fluid.amount; float capacity = tank.getCapacity(); float scale = amount / + * capacity; int fluidTankHeight = 60; int fluidAmount = (int) (scale * + * fluidTankHeight); drawFluid(x, y + fluidTankHeight - fluidAmount, + * fluid.getFluid().getIcon(fluid), 16, fluidAmount); } + */ + } -} \ No newline at end of file + private void drawFluid(int x, int y, IIcon icon, int width, int height) { + int i = 0; + int j = 0; + int drawHeight = 0; + int drawWidth = 0; + for (i = 0; i < width; i += 16) { + for (j = 0; j < height; j += 16) { + drawWidth = Math.min(width - i, 16); + drawHeight = Math.min(height - j, 16); + drawTexturedModelRectFromIcon(x + i, y + j, icon, drawWidth, drawHeight); + } + } + } +} diff --git a/src/main/java/gtPlusPlus/core/gui/machine/GUI_ProjectTable.java b/src/main/java/gtPlusPlus/core/gui/machine/GUI_ProjectTable.java index 4870269080..37258584af 100644 --- a/src/main/java/gtPlusPlus/core/gui/machine/GUI_ProjectTable.java +++ b/src/main/java/gtPlusPlus/core/gui/machine/GUI_ProjectTable.java @@ -1,65 +1,57 @@ package gtPlusPlus.core.gui.machine; -import org.lwjgl.opengl.GL11; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.core.container.Container_ProjectTable; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.machines.TileEntityProjectTable; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; - -import gtPlusPlus.core.container.Container_ProjectTable; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.tileentities.machines.TileEntityProjectTable; +import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class GUI_ProjectTable extends GuiContainer { - private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation(CORE.MODID, "textures/gui/ProjectTable.png"); - - public GUI_ProjectTable(final InventoryPlayer player_inventory, final TileEntityProjectTable tile){ - super(new Container_ProjectTable(player_inventory, tile)); - } - - - @Override - protected void drawGuiContainerForegroundLayer(final int i, final int j){ - //this.fontRendererObj.drawString(I18n.format("Workbench", new Object[0]), 28, 6, 4210752); - //this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); - - } - - - @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j){ - GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - this.mc.renderEngine.bindTexture(craftingTableGuiTextures); - final int x = (this.width - this.xSize) / 2; - final int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } - - - //This method is called when the Gui is first called! - @Override - public void initGui(){ - //You have to add this line for the Gui to function properly! - super.initGui(); - - //The parameters of GuiButton are(id, x, y, width, height, text); - //this.buttonList.add(new GuiButton( 1, 367, 132, 18, 18, "X")); - //this.buttonList.add(new GuiButton( 2, 385, 132, 18, 18, "Y")); - //NOTE: the id always has to be different or else it might get called twice or never! - - //Add any other buttons here too! - } - - @Override - protected void actionPerformed(final GuiButton B){ - - - } - -} \ No newline at end of file + private static final ResourceLocation craftingTableGuiTextures = + new ResourceLocation(CORE.MODID, "textures/gui/ProjectTable.png"); + + public GUI_ProjectTable(final InventoryPlayer player_inventory, final TileEntityProjectTable tile) { + super(new Container_ProjectTable(player_inventory, tile)); + } + + @Override + protected void drawGuiContainerForegroundLayer(final int i, final int j) { + // this.fontRendererObj.drawString(I18n.format("Workbench", new Object[0]), 28, 6, 4210752); + // this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, + // 4210752); + + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j) { + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + this.mc.renderEngine.bindTexture(craftingTableGuiTextures); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } + + // This method is called when the Gui is first called! + @Override + public void initGui() { + // You have to add this line for the Gui to function properly! + super.initGui(); + + // The parameters of GuiButton are(id, x, y, width, height, text); + // this.buttonList.add(new GuiButton( 1, 367, 132, 18, 18, "X")); + // this.buttonList.add(new GuiButton( 2, 385, 132, 18, 18, "Y")); + // NOTE: the id always has to be different or else it might get called twice or never! + + // Add any other buttons here too! + } + + @Override + protected void actionPerformed(final GuiButton B) {} +} diff --git a/src/main/java/gtPlusPlus/core/gui/machine/GUI_RoundRobinator.java b/src/main/java/gtPlusPlus/core/gui/machine/GUI_RoundRobinator.java index edb53e8ec0..fc1f0c7bed 100644 --- a/src/main/java/gtPlusPlus/core/gui/machine/GUI_RoundRobinator.java +++ b/src/main/java/gtPlusPlus/core/gui/machine/GUI_RoundRobinator.java @@ -1,10 +1,5 @@ package gtPlusPlus.core.gui.machine; -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -import org.lwjgl.opengl.GL11; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.core.container.Container_RoundRobinator; @@ -13,108 +8,114 @@ import gtPlusPlus.core.tileentities.machines.TileEntityRoundRobinator; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import java.lang.reflect.Method; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class GUI_RoundRobinator extends GuiContainer { - private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation(CORE.MODID, "textures/gui/RoundRobinator.png"); - private TileEntityRoundRobinator mTile; - private Container_RoundRobinator mContainer; - private static final Method mDrawItemStack; - - static { - mDrawItemStack = ReflectionUtils.getMethod(GuiContainer.class, "drawItemStack", new Class[] {ItemStack.class, int.class, int.class, String.class}); - } - - public GUI_RoundRobinator(final InventoryPlayer player_inventory, final TileEntityRoundRobinator te){ - this(new Container_RoundRobinator(player_inventory, te)); - mTile = te; - } - - private GUI_RoundRobinator(final Container_RoundRobinator aContainer){ - super(aContainer); - mContainer = aContainer; - } - - @Override - protected void drawGuiContainerForegroundLayer(final int i, final int j){ - super.drawGuiContainerForegroundLayer(i, j); - - int xStart = 134; - int yStart = 31; - mTile = this.mContainer.tile_entity; - - int tier = mContainer.mTier; - int aTickRate = mContainer.mTickRate; - - fontRendererObj.drawString("Round Robinator", 85, 4, Utils.rgbtoHexValue(50, 150, 50)); - fontRendererObj.drawString("Tier: "+tier, 85, 12, Utils.rgbtoHexValue(50, 150, 50)); - fontRendererObj.drawString("Rate: 1 Item/"+aTickRate+"t", 85, 20, Utils.rgbtoHexValue(50, 150, 50)); - - boolean[] aStates = new boolean[] {mContainer.mSide_1 == 0 ? false : true, mContainer.mSide_2 == 0 ? false : true, mContainer.mSide_3 == 0 ? false : true,mContainer.mSide_4 == 0 ? false : true}; - - fontRendererObj.drawString("West: "+(aStates[0] ? "Active" : "Disabled"), 5, 5, Utils.rgbtoHexValue(50, 50, 50)); - fontRendererObj.drawString("North: "+(aStates[1] ? "Active" : "Disabled"), 5, 15, Utils.rgbtoHexValue(50, 50, 50)); - fontRendererObj.drawString("South: "+(aStates[2] ? "Active" : "Disabled"), 5, 25, Utils.rgbtoHexValue(50, 50, 50)); - fontRendererObj.drawString("East: "+(aStates[3] ? "Active" : "Disabled"), 5, 35, Utils.rgbtoHexValue(50, 50, 50)); - fontRendererObj.drawString("Toggling South will visually", 5, 65, Utils.rgbtoHexValue(150, 50, 50)); - fontRendererObj.drawString("toggle East, This is a visual bug.", 5, 74, Utils.rgbtoHexValue(150, 50, 50)); - drawStatus(aStates[0], xStart, yStart); - drawStatus(aStates[1], xStart+18, yStart); - drawStatus(aStates[2], xStart, yStart+18); - drawStatus(aStates[3], xStart+18, yStart+18); - - } - - @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j){ - GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - this.mc.renderEngine.bindTexture(craftingTableGuiTextures); - final int x = (this.width - this.xSize) / 2; - final int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - - - - } - - private static ItemStack aGreenGlass; - private static ItemStack aRedGlass; - - private void drawStatus(boolean aStateActive, int x, int y) { - if (aGreenGlass == null) { - Item pane = ItemUtils.getSimpleStack(Blocks.stained_glass_pane).getItem(); - aGreenGlass = ItemUtils.simpleMetaStack(pane, 5, 1); - } - if (aRedGlass == null) { - Item pane = ItemUtils.getSimpleStack(Blocks.stained_glass_pane).getItem(); - aRedGlass = ItemUtils.simpleMetaStack(pane, 14, 1); - } - if (mDrawItemStack != null) { - try { - if (aStateActive) { - mDrawItemStack.invoke(this, new Object[]{aGreenGlass, x, y, ""}); - } - else { - mDrawItemStack.invoke(this, new Object[]{aRedGlass, x, y, ""}); - } - } - catch (Throwable t) { - t.printStackTrace(); - } - } - } - - //This method is called when the Gui is first called! - @Override - public void initGui(){ - super.initGui(); - } - -} \ No newline at end of file + private static final ResourceLocation craftingTableGuiTextures = + new ResourceLocation(CORE.MODID, "textures/gui/RoundRobinator.png"); + private TileEntityRoundRobinator mTile; + private Container_RoundRobinator mContainer; + private static final Method mDrawItemStack; + + static { + mDrawItemStack = ReflectionUtils.getMethod( + GuiContainer.class, "drawItemStack", new Class[] {ItemStack.class, int.class, int.class, String.class}); + } + + public GUI_RoundRobinator(final InventoryPlayer player_inventory, final TileEntityRoundRobinator te) { + this(new Container_RoundRobinator(player_inventory, te)); + mTile = te; + } + + private GUI_RoundRobinator(final Container_RoundRobinator aContainer) { + super(aContainer); + mContainer = aContainer; + } + + @Override + protected void drawGuiContainerForegroundLayer(final int i, final int j) { + super.drawGuiContainerForegroundLayer(i, j); + + int xStart = 134; + int yStart = 31; + mTile = this.mContainer.tile_entity; + + int tier = mContainer.mTier; + int aTickRate = mContainer.mTickRate; + + fontRendererObj.drawString("Round Robinator", 85, 4, Utils.rgbtoHexValue(50, 150, 50)); + fontRendererObj.drawString("Tier: " + tier, 85, 12, Utils.rgbtoHexValue(50, 150, 50)); + fontRendererObj.drawString("Rate: 1 Item/" + aTickRate + "t", 85, 20, Utils.rgbtoHexValue(50, 150, 50)); + + boolean[] aStates = new boolean[] { + mContainer.mSide_1 == 0 ? false : true, + mContainer.mSide_2 == 0 ? false : true, + mContainer.mSide_3 == 0 ? false : true, + mContainer.mSide_4 == 0 ? false : true + }; + + fontRendererObj.drawString( + "West: " + (aStates[0] ? "Active" : "Disabled"), 5, 5, Utils.rgbtoHexValue(50, 50, 50)); + fontRendererObj.drawString( + "North: " + (aStates[1] ? "Active" : "Disabled"), 5, 15, Utils.rgbtoHexValue(50, 50, 50)); + fontRendererObj.drawString( + "South: " + (aStates[2] ? "Active" : "Disabled"), 5, 25, Utils.rgbtoHexValue(50, 50, 50)); + fontRendererObj.drawString( + "East: " + (aStates[3] ? "Active" : "Disabled"), 5, 35, Utils.rgbtoHexValue(50, 50, 50)); + fontRendererObj.drawString("Toggling South will visually", 5, 65, Utils.rgbtoHexValue(150, 50, 50)); + fontRendererObj.drawString("toggle East, This is a visual bug.", 5, 74, Utils.rgbtoHexValue(150, 50, 50)); + drawStatus(aStates[0], xStart, yStart); + drawStatus(aStates[1], xStart + 18, yStart); + drawStatus(aStates[2], xStart, yStart + 18); + drawStatus(aStates[3], xStart + 18, yStart + 18); + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j) { + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + this.mc.renderEngine.bindTexture(craftingTableGuiTextures); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } + + private static ItemStack aGreenGlass; + private static ItemStack aRedGlass; + + private void drawStatus(boolean aStateActive, int x, int y) { + if (aGreenGlass == null) { + Item pane = ItemUtils.getSimpleStack(Blocks.stained_glass_pane).getItem(); + aGreenGlass = ItemUtils.simpleMetaStack(pane, 5, 1); + } + if (aRedGlass == null) { + Item pane = ItemUtils.getSimpleStack(Blocks.stained_glass_pane).getItem(); + aRedGlass = ItemUtils.simpleMetaStack(pane, 14, 1); + } + if (mDrawItemStack != null) { + try { + if (aStateActive) { + mDrawItemStack.invoke(this, new Object[] {aGreenGlass, x, y, ""}); + } else { + mDrawItemStack.invoke(this, new Object[] {aRedGlass, x, y, ""}); + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + } + + // This method is called when the Gui is first called! + @Override + public void initGui() { + super.initGui(); + } +} diff --git a/src/main/java/gtPlusPlus/core/gui/machine/GUI_ScrollTest.java b/src/main/java/gtPlusPlus/core/gui/machine/GUI_ScrollTest.java index 8a1f7c3fe9..d54f6b9364 100644 --- a/src/main/java/gtPlusPlus/core/gui/machine/GUI_ScrollTest.java +++ b/src/main/java/gtPlusPlus/core/gui/machine/GUI_ScrollTest.java @@ -1,5 +1,9 @@ package gtPlusPlus.core.gui.machine; +import com.google.common.collect.Lists; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import java.io.File; import java.io.IOException; import java.net.URI; @@ -7,16 +11,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.lwjgl.Sys; - -import com.google.common.collect.Lists; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiOptionButton; import net.minecraft.client.gui.GuiResourcePackAvailable; @@ -28,10 +22,12 @@ import net.minecraft.client.resources.ResourcePackListEntryFound; import net.minecraft.client.resources.ResourcePackRepository; import net.minecraft.client.resources.ResourcePackRepository.Entry; import net.minecraft.util.Util; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.Sys; @SideOnly(Side.CLIENT) -public class GUI_ScrollTest extends GuiScreen -{ +public class GUI_ScrollTest extends GuiScreen { private static final Logger logger = LogManager.getLogger(); private GuiScreen aThisGUIScreen; private List field_146966_g; @@ -40,8 +36,7 @@ public class GUI_ScrollTest extends GuiScreen private GuiResourcePackSelected MapOfActiveResourcePacks; private static final String __OBFID = "CL_00000820"; - public GUI_ScrollTest(GuiScreen p_i45050_1_) - { + public GUI_ScrollTest(GuiScreen p_i45050_1_) { this.aThisGUIScreen = p_i45050_1_; } @@ -49,10 +44,11 @@ public class GUI_ScrollTest extends GuiScreen * Adds the buttons (and other controls) to the screen in question. */ @SuppressWarnings("unchecked") - public void initGui() - { - this.buttonList.add(new GuiOptionButton(2, this.width / 2 - 154, this.height - 48, I18n.format("resourcePack.openFolder", new Object[0]))); - this.buttonList.add(new GuiOptionButton(1, this.width / 2 + 4, this.height - 48, I18n.format("gui.done", new Object[0]))); + public void initGui() { + this.buttonList.add(new GuiOptionButton( + 2, this.width / 2 - 154, this.height - 48, I18n.format("resourcePack.openFolder", new Object[0]))); + this.buttonList.add( + new GuiOptionButton(1, this.width / 2 + 4, this.height - 48, I18n.format("gui.done", new Object[0]))); this.field_146966_g = new ArrayList(); this.field_146969_h = new ArrayList(); ResourcePackRepository resourcepackrepository = this.mc.getResourcePackRepository(); @@ -62,21 +58,19 @@ public class GUI_ScrollTest extends GuiScreen Iterator iterator = arraylist.iterator(); ResourcePackRepository.Entry entry; - while (iterator.hasNext()) - { - entry = (ResourcePackRepository.Entry)iterator.next(); - //this.field_146966_g.add(new ResourcePackListEntryFound(this, entry)); + while (iterator.hasNext()) { + entry = (ResourcePackRepository.Entry) iterator.next(); + // this.field_146966_g.add(new ResourcePackListEntryFound(this, entry)); } iterator = Lists.reverse(resourcepackrepository.getRepositoryEntries()).iterator(); - while (iterator.hasNext()) - { - entry = (ResourcePackRepository.Entry)iterator.next(); - //this.field_146969_h.add(new ResourcePackListEntryFound(this, entry)); + while (iterator.hasNext()) { + entry = (ResourcePackRepository.Entry) iterator.next(); + // this.field_146969_h.add(new ResourcePackListEntryFound(this, entry)); } - //this.field_146969_h.add(new ResourcePackListEntryDefault(this)); + // this.field_146969_h.add(new ResourcePackListEntryDefault(this)); this.MapOfFreeResourcePacks = new GuiResourcePackAvailable(this.mc, 200, this.height, this.field_146966_g); this.MapOfFreeResourcePacks.setSlotXBoundsFromLeft(this.width / 2 - 4 - 200); this.MapOfFreeResourcePacks.registerScrollButtons(7, 8); @@ -85,95 +79,73 @@ public class GUI_ScrollTest extends GuiScreen this.MapOfActiveResourcePacks.registerScrollButtons(7, 8); } - public boolean func_146961_a(ResourcePackListEntry p_146961_1_) - { + public boolean func_146961_a(ResourcePackListEntry p_146961_1_) { return this.field_146969_h.contains(p_146961_1_); } - public List func_146962_b(ResourcePackListEntry p_146962_1_) - { + public List func_146962_b(ResourcePackListEntry p_146962_1_) { return this.func_146961_a(p_146962_1_) ? this.field_146969_h : this.field_146966_g; } - public List func_146964_g() - { + public List func_146964_g() { return this.field_146966_g; } - public List func_146963_h() - { + public List func_146963_h() { return this.field_146969_h; } - protected void actionPerformed(GuiButton p_146284_1_) - { - if (p_146284_1_.enabled) - { - if (p_146284_1_.id == 2) - { + protected void actionPerformed(GuiButton p_146284_1_) { + if (p_146284_1_.enabled) { + if (p_146284_1_.id == 2) { File file1 = this.mc.getResourcePackRepository().getDirResourcepacks(); String s = file1.getAbsolutePath(); - if (Util.getOSType() == Util.EnumOS.OSX) - { - try - { + if (Util.getOSType() == Util.EnumOS.OSX) { + try { logger.info(s); Runtime.getRuntime().exec(new String[] {"/usr/bin/open", s}); return; - } - catch (IOException ioexception1) - { + } catch (IOException ioexception1) { logger.error("Couldn\'t open file", ioexception1); } - } - else if (Util.getOSType() == Util.EnumOS.WINDOWS) - { + } else if (Util.getOSType() == Util.EnumOS.WINDOWS) { String s1 = String.format("cmd.exe /C start \"Open file\" \"%s\"", new Object[] {s}); - try - { + try { Runtime.getRuntime().exec(s1); return; - } - catch (IOException ioexception) - { + } catch (IOException ioexception) { logger.error("Couldn\'t open file", ioexception); } } boolean flag = false; - try - { + try { Class oclass = ReflectionUtils.getClass("java.awt.Desktop"); - Object object = ReflectionUtils.getMethod(oclass, "getDesktop", new Class[0]).invoke((Object)null, new Object[0]); - ReflectionUtils.getMethod(oclass, "browse", new Class[] {URI.class}).invoke(object, new Object[] {file1.toURI()}); - } - catch (Throwable throwable) - { + Object object = ReflectionUtils.getMethod(oclass, "getDesktop", new Class[0]) + .invoke((Object) null, new Object[0]); + ReflectionUtils.getMethod(oclass, "browse", new Class[] {URI.class}) + .invoke(object, new Object[] {file1.toURI()}); + } catch (Throwable throwable) { logger.error("Couldn\'t open link", throwable); flag = true; } - if (flag) - { + if (flag) { logger.info("Opening via system class!"); Sys.openURL("file://" + s); } - } - else if (p_146284_1_.id == 1) - { + } else if (p_146284_1_.id == 1) { ArrayList arraylist = Lists.newArrayList(); Iterator iterator = this.field_146969_h.iterator(); - while (iterator.hasNext()) - { - ResourcePackListEntry resourcepacklistentry = (ResourcePackListEntry)iterator.next(); + while (iterator.hasNext()) { + ResourcePackListEntry resourcepacklistentry = (ResourcePackListEntry) iterator.next(); - if (resourcepacklistentry instanceof ResourcePackListEntryFound) - { - arraylist.add(((ResourcePackListEntryFound)resourcepacklistentry).func_148318_i()); + if (resourcepacklistentry instanceof ResourcePackListEntryFound) { + arraylist.add(((ResourcePackListEntryFound) resourcepacklistentry).func_148318_i()); } } @@ -182,9 +154,8 @@ public class GUI_ScrollTest extends GuiScreen this.mc.gameSettings.resourcePacks.clear(); iterator = arraylist.iterator(); - while (iterator.hasNext()) - { - ResourcePackRepository.Entry entry = (ResourcePackRepository.Entry)iterator.next(); + while (iterator.hasNext()) { + ResourcePackRepository.Entry entry = (ResourcePackRepository.Entry) iterator.next(); this.mc.gameSettings.resourcePacks.add(entry.getResourcePackName()); } @@ -198,8 +169,7 @@ public class GUI_ScrollTest extends GuiScreen /** * Called when the mouse is clicked. */ - protected void mouseClicked(int p_73864_1_, int p_73864_2_, int p_73864_3_) - { + protected void mouseClicked(int p_73864_1_, int p_73864_2_, int p_73864_3_) { super.mouseClicked(p_73864_1_, p_73864_2_, p_73864_3_); this.MapOfFreeResourcePacks.func_148179_a(p_73864_1_, p_73864_2_, p_73864_3_); this.MapOfActiveResourcePacks.func_148179_a(p_73864_1_, p_73864_2_, p_73864_3_); @@ -209,21 +179,25 @@ public class GUI_ScrollTest extends GuiScreen * Called when the mouse is moved or a mouse button is released. Signature: (mouseX, mouseY, which) which==-1 is * mouseMove, which==0 or which==1 is mouseUp */ - protected void mouseMovedOrUp(int p_146286_1_, int p_146286_2_, int p_146286_3_) - { + protected void mouseMovedOrUp(int p_146286_1_, int p_146286_2_, int p_146286_3_) { super.mouseMovedOrUp(p_146286_1_, p_146286_2_, p_146286_3_); } /** * Draws the screen and all the components in it. */ - public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_) - { + public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_) { this.drawBackground(0); this.MapOfFreeResourcePacks.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_); this.MapOfActiveResourcePacks.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_); - this.drawCenteredString(this.fontRendererObj, I18n.format("resourcePack.title", new Object[0]), this.width / 2, 16, 16777215); - this.drawCenteredString(this.fontRendererObj, I18n.format("resourcePack.folderInfo", new Object[0]), this.width / 2 - 77, this.height - 26, 8421504); + this.drawCenteredString( + this.fontRendererObj, I18n.format("resourcePack.title", new Object[0]), this.width / 2, 16, 16777215); + this.drawCenteredString( + this.fontRendererObj, + I18n.format("resourcePack.folderInfo", new Object[0]), + this.width / 2 - 77, + this.height - 26, + 8421504); super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_); } -} \ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/core/gui/machine/GUI_SuperJukebox.java b/src/main/java/gtPlusPlus/core/gui/machine/GUI_SuperJukebox.java index d3d8f1e814..2349e0024d 100644 --- a/src/main/java/gtPlusPlus/core/gui/machine/GUI_SuperJukebox.java +++ b/src/main/java/gtPlusPlus/core/gui/machine/GUI_SuperJukebox.java @@ -1,90 +1,83 @@ package gtPlusPlus.core.gui.machine; -import java.util.ArrayList; -import java.util.List; - -import org.lwjgl.opengl.GL11; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.core.block.machine.Machine_SuperJukebox.TileEntitySuperJukebox; import gtPlusPlus.core.container.Container_SuperJukebox; import gtPlusPlus.core.gui.GUI_Base_Tile_Entity; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.slots.SlotNoInput; -import net.minecraft.client.gui.inventory.GuiContainer; +import java.util.ArrayList; +import java.util.List; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class GUI_SuperJukebox extends GUI_Base_Tile_Entity { - private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation(CORE.MODID, "textures/gui/SuperJukebox.png"); - private final Container_SuperJukebox mThisContainer; - - public GUI_SuperJukebox(final InventoryPlayer player_inventory, final TileEntitySuperJukebox te){ - super(new Container_SuperJukebox(player_inventory, te)); - mThisContainer = (Container_SuperJukebox) this.mContainer; - } + private static final ResourceLocation craftingTableGuiTextures = + new ResourceLocation(CORE.MODID, "textures/gui/SuperJukebox.png"); + private final Container_SuperJukebox mThisContainer; + + public GUI_SuperJukebox(final InventoryPlayer player_inventory, final TileEntitySuperJukebox te) { + super(new Container_SuperJukebox(player_inventory, te)); + mThisContainer = (Container_SuperJukebox) this.mContainer; + } + + // This method is called when the Gui is first called! + @Override + public void initGui() { + super.initGui(); + } + + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + super.drawGuiContainerForegroundLayer(par1, par2); + + boolean a = mThisContainer.isPlaying; + boolean b = mThisContainer.isLooping; - //This method is called when the Gui is first called! - @Override - public void initGui(){ - super.initGui(); - } + if (a && b) { + this.fontRendererObj.drawString("[X] [X]", 72, 74, 4210752); + } else if (a && !b) { + this.fontRendererObj.drawString("[X] [ ]", 72, 74, 4210752); + } else if (!a && b) { + this.fontRendererObj.drawString("[ ] [X]", 72, 74, 4210752); + } else { + this.fontRendererObj.drawString("[ ] [ ]", 72, 74, 4210752); + } - @Override - protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { - super.drawGuiContainerForegroundLayer(par1, par2); + this.drawTooltip(par1, par2); + } - boolean a = mThisContainer.isPlaying; - boolean b = mThisContainer.isLooping; - - if (a && b) { - this.fontRendererObj.drawString("[X] [X]", 72, 74, 4210752); - } - else if (a && !b) { - this.fontRendererObj.drawString("[X] [ ]", 72, 74, 4210752); - } - else if (!a && b) { - this.fontRendererObj.drawString("[ ] [X]", 72, 74, 4210752); - } - else { - this.fontRendererObj.drawString("[ ] [ ]", 72, 74, 4210752); - } - - this.drawTooltip(par1, par2); - } + private void drawTooltip(final int x2, final int y2) { + final int xStart = (this.width - this.xSize) / 2; + final int yStart = (this.height - this.ySize) / 2; + final int x3 = x2 - xStart; + final int y3 = y2 - yStart + 5; + final List list = new ArrayList(); - private void drawTooltip(final int x2, final int y2) { - final int xStart = (this.width - this.xSize) / 2; - final int yStart = (this.height - this.ySize) / 2; - final int x3 = x2 - xStart; - final int y3 = y2 - yStart + 5; - final List list = new ArrayList(); - - if (y3 >= 17 && y3 <= 33) { - if (x3 >= 80 && x3 <= 96) { - list.add("Play"); - } - } - if (y3 >= 35 && y3 <= 53) { - if (x3 >= 80 && x3 <= 96) { - list.add("Loop"); - } - } - if (!list.isEmpty()) { - this.drawHoveringText(list, x3, y3, this.fontRendererObj); - } - } + if (y3 >= 17 && y3 <= 33) { + if (x3 >= 80 && x3 <= 96) { + list.add("Play"); + } + } + if (y3 >= 35 && y3 <= 53) { + if (x3 >= 80 && x3 <= 96) { + list.add("Loop"); + } + } + if (!list.isEmpty()) { + this.drawHoveringText(list, x3, y3, this.fontRendererObj); + } + } - @Override - protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { - GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - this.mc.renderEngine.bindTexture(craftingTableGuiTextures); - final int x = (this.width - this.xSize) / 2; - final int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } - -} \ No newline at end of file + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + this.mc.renderEngine.bindTexture(craftingTableGuiTextures); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } +} diff --git a/src/main/java/gtPlusPlus/core/gui/machine/GUI_TradeTable.java b/src/main/java/gtPlusPlus/core/gui/machine/GUI_TradeTable.java index 7c71f09302..dd59baf697 100644 --- a/src/main/java/gtPlusPlus/core/gui/machine/GUI_TradeTable.java +++ b/src/main/java/gtPlusPlus/core/gui/machine/GUI_TradeTable.java @@ -1,50 +1,49 @@ package gtPlusPlus.core.gui.machine; -import org.lwjgl.opengl.GL11; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.client.resources.I18n; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.container.Container_TradeTable; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.tileentities.machines.TileEntityTradeTable; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class GUI_TradeTable extends GuiContainer { - TileEntityTradeTable mThisTable; - String mOwnerName; - - private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation(CORE.MODID, "textures/gui/ProjectTable.png"); - - public GUI_TradeTable(final InventoryPlayer player_inventory, final TileEntityTradeTable te, final String mOwnerName){ - super(new Container_TradeTable(player_inventory, te)); - if (te.isServerSide()){ - mThisTable = te; - this.mOwnerName = mOwnerName; - Logger.INFO("Set valid TE in GUI"); - } - } - - @Override - protected void drawGuiContainerForegroundLayer(final int i, final int j){ - this.fontRendererObj.drawString(I18n.format("Owner - "+this.mOwnerName, new Object[0]), 28, 66, 4210752); - //this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); - } - - @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j){ - GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - this.mc.renderEngine.bindTexture(craftingTableGuiTextures); - final int x = (this.width - this.xSize) / 2; - final int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } - -} \ No newline at end of file + TileEntityTradeTable mThisTable; + String mOwnerName; + + private static final ResourceLocation craftingTableGuiTextures = + new ResourceLocation(CORE.MODID, "textures/gui/ProjectTable.png"); + + public GUI_TradeTable( + final InventoryPlayer player_inventory, final TileEntityTradeTable te, final String mOwnerName) { + super(new Container_TradeTable(player_inventory, te)); + if (te.isServerSide()) { + mThisTable = te; + this.mOwnerName = mOwnerName; + Logger.INFO("Set valid TE in GUI"); + } + } + + @Override + protected void drawGuiContainerForegroundLayer(final int i, final int j) { + this.fontRendererObj.drawString(I18n.format("Owner - " + this.mOwnerName, new Object[0]), 28, 66, 4210752); + // this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, + // 4210752); + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j) { + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + this.mc.renderEngine.bindTexture(craftingTableGuiTextures); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } +} diff --git a/src/main/java/gtPlusPlus/core/gui/machine/GUI_VolumetricFlaskSetter.java b/src/main/java/gtPlusPlus/core/gui/machine/GUI_VolumetricFlaskSetter.java index 512f31dd47..1405d0229d 100644 --- a/src/main/java/gtPlusPlus/core/gui/machine/GUI_VolumetricFlaskSetter.java +++ b/src/main/java/gtPlusPlus/core/gui/machine/GUI_VolumetricFlaskSetter.java @@ -1,8 +1,5 @@ package gtPlusPlus.core.gui.machine; -import org.lwjgl.input.Keyboard; -import org.lwjgl.opengl.GL11; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.api.objects.Logger; @@ -15,260 +12,226 @@ import gtPlusPlus.core.tileentities.general.TileEntityVolumetricFlaskSetter; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.resources.I18n; import net.minecraft.util.ResourceLocation; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class GUI_VolumetricFlaskSetter extends GuiContainer { - private static final ResourceLocation mGuiTextures = new ResourceLocation( - CORE.MODID, "textures/gui/VolumetricFlaskSetter.png" - ); - private Container_VolumetricFlaskSetter mContainer; - private boolean mIsOpen = false; - private GuiValueField mText; - private TileEntityVolumetricFlaskSetter mTile; - - public GUI_VolumetricFlaskSetter(Container_VolumetricFlaskSetter aContainer) { - super(aContainer); - mContainer = aContainer; - mTile = mContainer.mTileEntity; - } - - @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j) { - GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - this.mc.renderEngine.bindTexture(mGuiTextures); - final int x = (this.width - this.xSize) / 2; - final int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - } - - @Override - protected void drawGuiContainerForegroundLayer(final int i, final int j) { - super.drawGuiContainerForegroundLayer(i, j); - this.mText.drawTextBox(); - this.fontRendererObj.drawString( - I18n.format("container.VolumetricFlaskSetter", new Object[0]), 4, 3, 4210752 - ); - int aYVal = 49; - this.fontRendererObj.drawString( - I18n.format("0 = 16l", new Object[0]), 8, aYVal, 4210752 - ); - this.fontRendererObj.drawString( - I18n.format("4 = 576l", new Object[0]), 64, aYVal, 4210752 - ); - this.fontRendererObj.drawString( - I18n.format("1 = 36l", new Object[0]), 8, aYVal += 8, 4210752 - ); - this.fontRendererObj.drawString( - I18n.format("5 = 720l", new Object[0]), 64, aYVal, 4210752 - ); - this.fontRendererObj.drawString( - I18n.format("2 = 144l", new Object[0]), 8, aYVal += 8, 4210752 - ); - this.fontRendererObj.drawString( - I18n.format("6 = 864l", new Object[0]), 64, aYVal, 4210752 - ); - this.fontRendererObj.drawString( - I18n.format("3 = 432l", new Object[0]), 8, aYVal += 8, 4210752 - ); - this.fontRendererObj.drawString( - I18n.format("-> = Custom", new Object[0]), 59, aYVal, 4210752 - ); - - } - - public void drawScreen(int par1, int par2, float par3) { - this.drawDefaultBackground(); - super.drawScreen(par1, par2, par3); - } - - protected String getText() { - return this.mText.getText(); - } - - public void initGui() { - super.initGui(); - // Keyboard.enableRepeatEvents(true); - mIsOpen = true; - this.mText = new GuiValueField( - this.fontRendererObj, 26, 31, this.width / 2 - - 62, this.height / 2 - 52, 106, 14, this - ); - mText.setMaxStringLength(5); - mText.setEnableBackgroundDrawing(true); - mText.setText("0"); - mText.setFocused(true); - } - - public boolean isNumber(char c) { - boolean isNum = ((c >= 48 && c <= 57) || c == 45); - if (isNum) { - log("Found Digit: "+c+" | char value"); - } - else { - switch (c) { - case '0' : - case '1' : - case '2' : - case '3' : - case '4' : - case '5' : - case '6' : - case '7' : - case '8' : - case '9' : - log("Found Digit: "+c+" | char switch"); - return true; - } - } - return isNum; - } - - public boolean isNumber(int c) { - switch (c) { - case Keyboard.KEY_0 : - case Keyboard.KEY_1 : - case Keyboard.KEY_2 : - case Keyboard.KEY_3 : - case Keyboard.KEY_4 : - case Keyboard.KEY_5 : - case Keyboard.KEY_6 : - case Keyboard.KEY_7 : - case Keyboard.KEY_8 : - case Keyboard.KEY_9 : - case Keyboard.KEY_NUMPAD0 : - case Keyboard.KEY_NUMPAD1 : - case Keyboard.KEY_NUMPAD2 : - case Keyboard.KEY_NUMPAD3 : - case Keyboard.KEY_NUMPAD4 : - case Keyboard.KEY_NUMPAD5 : - case Keyboard.KEY_NUMPAD6 : - case Keyboard.KEY_NUMPAD7 : - case Keyboard.KEY_NUMPAD8 : - case Keyboard.KEY_NUMPAD9 : - log("Found Digit: "+Keyboard.getKeyName(c)+" | LWJGL Keybinding"); - return true; - } - return false; - } - - protected void keyTyped(char par1, int par2) { - if (mIsOpen) { - log("Pressed " + par1 + " | " + par2); - if (mText.isFocused()) { - log("Text box has focus."); - if (par2 == Keyboard.KEY_RETURN) { - log("Pressed Enter, unfocusing."); - mText.setFocused(false); - } - else if (par2 == Keyboard.KEY_BACK) { - log("Pressed Backspace."); - String aCurrentText = getText(); - if (aCurrentText.length() > 0) { - this.mText.setText( - aCurrentText.substring( - 0, aCurrentText.length() - 1 - ) - ); - if (getText().length() <= 0) { - setText(0); - } - sendUpdateToServer(); - } - } - else { - if (isNumber(par2) || isNumber(par1)) { - log("Pressed number."); - if (this.mText.getText().equals("0")) { - this.mText.textboxKeyTyped(par1, par2); - sendUpdateToServer(); - } - else { - this.mText.textboxKeyTyped(par1, par2); - sendUpdateToServer(); - } - } - else { - log("Pressed unused key."); - super.keyTyped(par1, par2); - } - } - } - else { - log("Text box not focused."); - super.keyTyped(par1, par2); - } - } - else { - log("Gui is not open?"); - } - } - - protected void mouseClicked(int x, int y, int btn) { - if (mIsOpen) { - log("Clicked."); - this.mText.mouseClicked(x, y, btn); - if (!mText.didClickInTextField(x, y)) { - log("Did not click in text box, passing to super."); - super.mouseClicked(x, y, btn); - } - } - else { - log("Gui is not open?"); - } - } - - @Override - public void onGuiClosed() { - mIsOpen = false; - mText.setEnabled(false); - mText.setVisible(false); - super.onGuiClosed(); - // Keyboard.enableRepeatEvents(false); - } - - public int parse(String aValue) { - try { - return Integer.parseInt(getText()); - } - catch (NumberFormatException e) { - return 0; - } - } - - public void sendUpdateToServer() { - if (getText().length() > 0) { - PacketHandler.sendToServer(new Packet_VolumetricFlaskGui(mTile, parse(getText()))); - } - } - - public void setText(int aValue) { - this.mText.setText("" + aValue); - } - - public void updateScreen() { - super.updateScreen(); - // Update Textbox to 0 if Empty - if (getText().length() <= 0) { - this.mText.setText("0"); - sendUpdateToServer(); - } - this.mText.updateCursorCounter(); - - // Check TextBox Value is correct - if (getText().length() > 0) { - int aCustomValue = parse(getText()); - int aTileValue = ((Container_VolumetricFlaskSetter) mContainer).mCustomValue; - if (mContainer != null) { - if (aTileValue != aCustomValue) { - setText(aTileValue); - } - } - } - } - - public void log(String aString) { - Logger.INFO("[Flask-GUI] "+aString); - } - + private static final ResourceLocation mGuiTextures = + new ResourceLocation(CORE.MODID, "textures/gui/VolumetricFlaskSetter.png"); + private Container_VolumetricFlaskSetter mContainer; + private boolean mIsOpen = false; + private GuiValueField mText; + private TileEntityVolumetricFlaskSetter mTile; + + public GUI_VolumetricFlaskSetter(Container_VolumetricFlaskSetter aContainer) { + super(aContainer); + mContainer = aContainer; + mTile = mContainer.mTileEntity; + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j) { + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + this.mc.renderEngine.bindTexture(mGuiTextures); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } + + @Override + protected void drawGuiContainerForegroundLayer(final int i, final int j) { + super.drawGuiContainerForegroundLayer(i, j); + this.mText.drawTextBox(); + this.fontRendererObj.drawString(I18n.format("container.VolumetricFlaskSetter", new Object[0]), 4, 3, 4210752); + int aYVal = 49; + this.fontRendererObj.drawString(I18n.format("0 = 16l", new Object[0]), 8, aYVal, 4210752); + this.fontRendererObj.drawString(I18n.format("4 = 576l", new Object[0]), 64, aYVal, 4210752); + this.fontRendererObj.drawString(I18n.format("1 = 36l", new Object[0]), 8, aYVal += 8, 4210752); + this.fontRendererObj.drawString(I18n.format("5 = 720l", new Object[0]), 64, aYVal, 4210752); + this.fontRendererObj.drawString(I18n.format("2 = 144l", new Object[0]), 8, aYVal += 8, 4210752); + this.fontRendererObj.drawString(I18n.format("6 = 864l", new Object[0]), 64, aYVal, 4210752); + this.fontRendererObj.drawString(I18n.format("3 = 432l", new Object[0]), 8, aYVal += 8, 4210752); + this.fontRendererObj.drawString(I18n.format("-> = Custom", new Object[0]), 59, aYVal, 4210752); + } + + public void drawScreen(int par1, int par2, float par3) { + this.drawDefaultBackground(); + super.drawScreen(par1, par2, par3); + } + + protected String getText() { + return this.mText.getText(); + } + + public void initGui() { + super.initGui(); + // Keyboard.enableRepeatEvents(true); + mIsOpen = true; + this.mText = new GuiValueField( + this.fontRendererObj, 26, 31, this.width / 2 - 62, this.height / 2 - 52, 106, 14, this); + mText.setMaxStringLength(5); + mText.setEnableBackgroundDrawing(true); + mText.setText("0"); + mText.setFocused(true); + } + + public boolean isNumber(char c) { + boolean isNum = ((c >= 48 && c <= 57) || c == 45); + if (isNum) { + log("Found Digit: " + c + " | char value"); + } else { + switch (c) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + log("Found Digit: " + c + " | char switch"); + return true; + } + } + return isNum; + } + + public boolean isNumber(int c) { + switch (c) { + case Keyboard.KEY_0: + case Keyboard.KEY_1: + case Keyboard.KEY_2: + case Keyboard.KEY_3: + case Keyboard.KEY_4: + case Keyboard.KEY_5: + case Keyboard.KEY_6: + case Keyboard.KEY_7: + case Keyboard.KEY_8: + case Keyboard.KEY_9: + case Keyboard.KEY_NUMPAD0: + case Keyboard.KEY_NUMPAD1: + case Keyboard.KEY_NUMPAD2: + case Keyboard.KEY_NUMPAD3: + case Keyboard.KEY_NUMPAD4: + case Keyboard.KEY_NUMPAD5: + case Keyboard.KEY_NUMPAD6: + case Keyboard.KEY_NUMPAD7: + case Keyboard.KEY_NUMPAD8: + case Keyboard.KEY_NUMPAD9: + log("Found Digit: " + Keyboard.getKeyName(c) + " | LWJGL Keybinding"); + return true; + } + return false; + } + + protected void keyTyped(char par1, int par2) { + if (mIsOpen) { + log("Pressed " + par1 + " | " + par2); + if (mText.isFocused()) { + log("Text box has focus."); + if (par2 == Keyboard.KEY_RETURN) { + log("Pressed Enter, unfocusing."); + mText.setFocused(false); + } else if (par2 == Keyboard.KEY_BACK) { + log("Pressed Backspace."); + String aCurrentText = getText(); + if (aCurrentText.length() > 0) { + this.mText.setText(aCurrentText.substring(0, aCurrentText.length() - 1)); + if (getText().length() <= 0) { + setText(0); + } + sendUpdateToServer(); + } + } else { + if (isNumber(par2) || isNumber(par1)) { + log("Pressed number."); + if (this.mText.getText().equals("0")) { + this.mText.textboxKeyTyped(par1, par2); + sendUpdateToServer(); + } else { + this.mText.textboxKeyTyped(par1, par2); + sendUpdateToServer(); + } + } else { + log("Pressed unused key."); + super.keyTyped(par1, par2); + } + } + } else { + log("Text box not focused."); + super.keyTyped(par1, par2); + } + } else { + log("Gui is not open?"); + } + } + + protected void mouseClicked(int x, int y, int btn) { + if (mIsOpen) { + log("Clicked."); + this.mText.mouseClicked(x, y, btn); + if (!mText.didClickInTextField(x, y)) { + log("Did not click in text box, passing to super."); + super.mouseClicked(x, y, btn); + } + } else { + log("Gui is not open?"); + } + } + + @Override + public void onGuiClosed() { + mIsOpen = false; + mText.setEnabled(false); + mText.setVisible(false); + super.onGuiClosed(); + // Keyboard.enableRepeatEvents(false); + } + + public int parse(String aValue) { + try { + return Integer.parseInt(getText()); + } catch (NumberFormatException e) { + return 0; + } + } + + public void sendUpdateToServer() { + if (getText().length() > 0) { + PacketHandler.sendToServer(new Packet_VolumetricFlaskGui(mTile, parse(getText()))); + } + } + + public void setText(int aValue) { + this.mText.setText("" + aValue); + } + + public void updateScreen() { + super.updateScreen(); + // Update Textbox to 0 if Empty + if (getText().length() <= 0) { + this.mText.setText("0"); + sendUpdateToServer(); + } + this.mText.updateCursorCounter(); + + // Check TextBox Value is correct + if (getText().length() > 0) { + int aCustomValue = parse(getText()); + int aTileValue = ((Container_VolumetricFlaskSetter) mContainer).mCustomValue; + if (mContainer != null) { + if (aTileValue != aCustomValue) { + setText(aTileValue); + } + } + } + } + + public void log(String aString) { + Logger.INFO("[Flask-GUI] " + aString); + } } diff --git a/src/main/java/gtPlusPlus/core/gui/widget/GuiValueField.java b/src/main/java/gtPlusPlus/core/gui/widget/GuiValueField.java index c9c294ea1c..97ccf0b248 100644 --- a/src/main/java/gtPlusPlus/core/gui/widget/GuiValueField.java +++ b/src/main/java/gtPlusPlus/core/gui/widget/GuiValueField.java @@ -1,98 +1,112 @@ package gtPlusPlus.core.gui.widget; -import java.lang.reflect.Field; - import gtPlusPlus.core.gui.machine.GUI_VolumetricFlaskSetter; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.preloader.DevHelper; +import java.lang.reflect.Field; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiTextField; public class GuiValueField extends GuiTextField { - private final FontRenderer mFontRenderer; - private final int mScreenLocationX; - private final int mScreenLocationY; - private final GUI_VolumetricFlaskSetter mGUI; + private final FontRenderer mFontRenderer; + private final int mScreenLocationX; + private final int mScreenLocationY; + private final GUI_VolumetricFlaskSetter mGUI; - public GuiValueField(FontRenderer aFontRenderer, int aX, int aY, int aScreenLocationX, int aScreenLocationY, int aWidth, int aHeight, GUI_VolumetricFlaskSetter aGUI) { - super(aFontRenderer, aX, aY, aWidth, aHeight); - mFontRenderer = aFontRenderer; - mScreenLocationX = aScreenLocationX; - mScreenLocationY = aScreenLocationY; - mGUI = aGUI; - } + public GuiValueField( + FontRenderer aFontRenderer, + int aX, + int aY, + int aScreenLocationX, + int aScreenLocationY, + int aWidth, + int aHeight, + GUI_VolumetricFlaskSetter aGUI) { + super(aFontRenderer, aX, aY, aWidth, aHeight); + mFontRenderer = aFontRenderer; + mScreenLocationX = aScreenLocationX; + mScreenLocationY = aScreenLocationY; + mGUI = aGUI; + } - public boolean canLoseFocus() { - Field canLoseFocus = ReflectionUtils.getField(GuiTextField.class, DevHelper.isObfuscatedEnvironment() ? "field_146212_n" : "canLoseFocus"); - if (canLoseFocus != null) { - return (boolean) ReflectionUtils.getFieldValue(canLoseFocus, this); - } - return true; - } + public boolean canLoseFocus() { + Field canLoseFocus = ReflectionUtils.getField( + GuiTextField.class, DevHelper.isObfuscatedEnvironment() ? "field_146212_n" : "canLoseFocus"); + if (canLoseFocus != null) { + return (boolean) ReflectionUtils.getFieldValue(canLoseFocus, this); + } + return true; + } - @Override - public boolean isFocused() { - return super.isFocused(); - } + @Override + public boolean isFocused() { + return super.isFocused(); + } - public boolean isBackgroundDrawingEnabled() { - Field enableBackgroundDrawing = ReflectionUtils.getField(GuiTextField.class, DevHelper.isObfuscatedEnvironment() ? "field_146215_m" : "enableBackgroundDrawing"); - if (enableBackgroundDrawing != null) { - return (boolean) ReflectionUtils.getFieldValue(enableBackgroundDrawing, this); - } - return true; - } - - public int getLineScrollOffset() { - Field lineScrollOffset = ReflectionUtils.getField(GuiTextField.class, DevHelper.isObfuscatedEnvironment() ? "field_146225_q" : "lineScrollOffset"); - if (lineScrollOffset != null) { - return (int) ReflectionUtils.getFieldValue(lineScrollOffset, this); - } - return 0; - } + public boolean isBackgroundDrawingEnabled() { + Field enableBackgroundDrawing = ReflectionUtils.getField( + GuiTextField.class, DevHelper.isObfuscatedEnvironment() ? "field_146215_m" : "enableBackgroundDrawing"); + if (enableBackgroundDrawing != null) { + return (boolean) ReflectionUtils.getFieldValue(enableBackgroundDrawing, this); + } + return true; + } - public boolean didClickInTextField(int aX, int aY) { - mGUI.log("Clicked at X:"+aX+", Y:"+aY); - boolean aDidClick = aX >= this.mScreenLocationX && aX < this.mScreenLocationX + this.width && aY >= this.mScreenLocationY && aY < this.mScreenLocationY + this.height; - mGUI.log("Did click in textbox? "+aDidClick); - mGUI.log("Expected Region: X:"+mScreenLocationX+"-"+(this.mScreenLocationX + this.width)); - mGUI.log("Expected Region: Y:"+mScreenLocationY+"-"+(this.mScreenLocationY + this.height)); - return aDidClick; - } + public int getLineScrollOffset() { + Field lineScrollOffset = ReflectionUtils.getField( + GuiTextField.class, DevHelper.isObfuscatedEnvironment() ? "field_146225_q" : "lineScrollOffset"); + if (lineScrollOffset != null) { + return (int) ReflectionUtils.getFieldValue(lineScrollOffset, this); + } + return 0; + } - /** - * Args: x, y, buttonClicked - */ - @Override - public void mouseClicked(int aX, int aY, int aButton){ - boolean aDidClick = didClickInTextField(aX, aY); + public boolean didClickInTextField(int aX, int aY) { + mGUI.log("Clicked at X:" + aX + ", Y:" + aY); + boolean aDidClick = aX >= this.mScreenLocationX + && aX < this.mScreenLocationX + this.width + && aY >= this.mScreenLocationY + && aY < this.mScreenLocationY + this.height; + mGUI.log("Did click in textbox? " + aDidClick); + mGUI.log("Expected Region: X:" + mScreenLocationX + "-" + (this.mScreenLocationX + this.width)); + mGUI.log("Expected Region: Y:" + mScreenLocationY + "-" + (this.mScreenLocationY + this.height)); + return aDidClick; + } - mGUI.log("Did click inside text box? "+aDidClick); - mGUI.log("Focus 1: "+this.isFocused()); - this.setFocused(aDidClick); - mGUI.log("Focus 2: "+this.isFocused()); - if (isFocused()) { - int l = aX - this.mScreenLocationX; - if (isBackgroundDrawingEnabled()) { - l -= 4; - } - if (aButton == 0) { - mGUI.log("Left clicked in text box."); - String s = this.mFontRenderer.trimStringToWidth(this.getText().substring(getLineScrollOffset()), this.getWidth()); - this.setCursorPosition(this.mFontRenderer.trimStringToWidth(s, l).length() + getLineScrollOffset()); - } - else if (aButton == 1) { - mGUI.log("Right clicked in text box."); - mGUI.setText(0); - mGUI.sendUpdateToServer(); - String s = this.mFontRenderer.trimStringToWidth(this.getText().substring(getLineScrollOffset()), this.getWidth()); - this.setCursorPosition(this.mFontRenderer.trimStringToWidth(s, l).length() + getLineScrollOffset()); - } - } - else { - mGUI.log("Clicked, but no focus."); - } - } + /** + * Args: x, y, buttonClicked + */ + @Override + public void mouseClicked(int aX, int aY, int aButton) { + boolean aDidClick = didClickInTextField(aX, aY); + mGUI.log("Did click inside text box? " + aDidClick); + mGUI.log("Focus 1: " + this.isFocused()); + this.setFocused(aDidClick); + mGUI.log("Focus 2: " + this.isFocused()); + if (isFocused()) { + int l = aX - this.mScreenLocationX; + if (isBackgroundDrawingEnabled()) { + l -= 4; + } + if (aButton == 0) { + mGUI.log("Left clicked in text box."); + String s = this.mFontRenderer.trimStringToWidth( + this.getText().substring(getLineScrollOffset()), this.getWidth()); + this.setCursorPosition( + this.mFontRenderer.trimStringToWidth(s, l).length() + getLineScrollOffset()); + } else if (aButton == 1) { + mGUI.log("Right clicked in text box."); + mGUI.setText(0); + mGUI.sendUpdateToServer(); + String s = this.mFontRenderer.trimStringToWidth( + this.getText().substring(getLineScrollOffset()), this.getWidth()); + this.setCursorPosition( + this.mFontRenderer.trimStringToWidth(s, l).length() + getLineScrollOffset()); + } + } else { + mGUI.log("Clicked, but no focus."); + } + } } diff --git a/src/main/java/gtPlusPlus/core/handler/AchievementHandler.java b/src/main/java/gtPlusPlus/core/handler/AchievementHandler.java index fa10f4def3..8fe7c355d5 100644 --- a/src/main/java/gtPlusPlus/core/handler/AchievementHandler.java +++ b/src/main/java/gtPlusPlus/core/handler/AchievementHandler.java @@ -1,15 +1,11 @@ package gtPlusPlus.core.handler; -import java.util.concurrent.ConcurrentHashMap; - import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; import cpw.mods.fml.common.gameevent.PlayerEvent.ItemSmeltedEvent; -import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; import gregtech.api.util.GT_Log; -import gregtech.common.items.GT_MetaGenerated_Tool_01; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.item.ModItems; @@ -21,6 +17,7 @@ import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; +import java.util.concurrent.ConcurrentHashMap; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.stats.Achievement; @@ -30,392 +27,396 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.EntityItemPickupEvent; public class AchievementHandler { - - public ConcurrentHashMap achievementList = new ConcurrentHashMap(); - public ConcurrentHashMap issuedAchievements = new ConcurrentHashMap(); - - public int adjX = 5; - public int adjY = 9; - - private static final String aBaseAchievementName = "gtpp.start"; - - public AchievementHandler() { - - Logger.INFO("Initializing GT++ achievements"); - GT_Log.out.println("Initializing GT++ achievements"); - - //register first - this.registerAchievement(aBaseAchievementName, 0, 0, MetaGeneratedGregtechTools.INSTANCE.getToolWithStats(MetaGeneratedGregtechTools.ANGLE_GRINDER, 1, Materials.Osmium, Materials.Osmium, null), "", true); - - //Useful Info - boolean cores = CORE.ConfigSwitches.requireControlCores; - if (cores || GregtechMeta_MultiBlockBase.DEBUG_DISABLE_CORES_TEMPORARILY) { - this.registerAchievement("hatch.control", -2, -2, GregtechItemList.Hatch_Control_Core.get(1), aBaseAchievementName, false); - } - this.registerAchievement("hatch.dynamo.buffered", 2, -2, GregtechItemList.Hatch_Buffer_Dynamo_IV.get(1), aBaseAchievementName, false); - //First multi anyone really needs - this.registerAchievement("multi.abs", -4, -2, GregtechItemList.Industrial_AlloyBlastSmelter.get(1), cores ? "hatch.control" : aBaseAchievementName, true); - - //Material Advancement - this.registerAchievement("dust.potin", 0, 2, ALLOY.POTIN.getDust(1), aBaseAchievementName, false); - this.registerAchievement("dust.eglin", 0, 4, ALLOY.EGLIN_STEEL.getDust(1), "dust.potin", false); - this.registerAchievement("dust.staballoy", 0, 6, ALLOY.STABALLOY.getDust(1), "dust.eglin", false); - this.registerAchievement("dust.quantum", 0, 8, ALLOY.QUANTUM.getDust(1), "dust.staballoy", true); - this.registerAchievement("dust.hypogen", 0, 10, ELEMENT.STANDALONE.HYPOGEN.getDust(1), "dust.quantum", true); - - - //Blocks - this.registerAchievement("block.fishtrap", -2, 2, ItemUtils.getSimpleStack(ModBlocks.blockFishTrap), "dust.potin", false); - this.registerAchievement("block.withercage", -2, 4, ItemUtils.getSimpleStack(ModBlocks.blockWitherGuard), "dust.eglin", false); - - - //Machines (-10/-8/-6) - this.registerAchievement("rtg", -16, -10, GregtechItemList.RTG.get(1), aBaseAchievementName, false); - this.registerAchievement("dehydrate", -15, -10, GregtechItemList.GT_Dehydrator_HV.get(1), aBaseAchievementName, false); - this.registerAchievement("semifluid", -14, -10, GregtechItemList.Generator_SemiFluid_HV.get(1), aBaseAchievementName, false); - this.registerAchievement("earlywasher", -13, -10, GregtechItemList.SimpleDustWasher_ULV.get(1), aBaseAchievementName, false); - this.registerAchievement("advancedsteam", -12, -10, GregtechItemList.Boiler_Advanced_MV.get(1), aBaseAchievementName, false); - if (PollutionUtils.isPollutionEnabled()) { - this.registerAchievement("pollutionremoval", -11, -10, GregtechItemList.Pollution_Cleaner_IV.get(1), aBaseAchievementName, false); - } - this.registerAchievement("hiampxform", -10, -10, GregtechItemList.Transformer_HA_HV_MV.get(1), aBaseAchievementName, false); - - - //Multis (-4/-2/0) - this.registerAchievement("multi.pss", -16, -7, GregtechItemList.PowerSubStation.get(1), "multi.abs", false); - this.registerAchievement("multi.cyclo", -15, -7, GregtechItemList.COMET_Cyclotron.get(1), "multi.abs", false); - this.registerAchievement("multi.sifter", -14, -7, GregtechItemList.Industrial_Sifter.get(1), "dust.eglin", false); - this.registerAchievement("multi.cokeoven", -13, -7, GregtechItemList.Industrial_CokeOven.get(1), "multi.abs", false); - this.registerAchievement("multi.boiler.thermal", -12, -7, GregtechItemList.GT4_Thermal_Boiler.get(1), "multi.abs", false); - this.registerAchievement("multi.zhuhai", -11, -7, GregtechItemList.Industrial_FishingPond.get(1), aBaseAchievementName, false); - //this.registerAchievement("rtg", -4, -4, GregtechItemList.RTG.get(1), aBaseAchievementName, false); - - //Casings - this.registerAchievement("casing.abs", 2, -10, GregtechItemList.Casing_Coil_BlastSmelter.get(1), aBaseAchievementName, false); - this.registerAchievement("casing.cyclotron.coil", 3, -10, GregtechItemList.Casing_Cyclotron_Coil.get(1), aBaseAchievementName, false); - this.registerAchievement("casing.multiuse", 4, -10, GregtechItemList.Casing_Multi_Use.get(1), aBaseAchievementName, false); - this.registerAchievement("casing.containment", 5, -10, GregtechItemList.Casing_Containment.get(1), aBaseAchievementName, false); - - - - - - - - - //Radioactive - this.registerAchievement("decay.neptunium238", 11, 8, ItemUtils.getSimpleStack(ModItems.dustNeptunium238), "multi.cyclo", false); - this.registerAchievement("decay.radium226", 12, 8, ItemUtils.getSimpleStack(ModItems.dustRadium226), "multi.cyclo", false); - this.registerAchievement("decay.molybdenum99", 13, 8, ItemUtils.getSimpleStack(ModItems.dustMolybdenum99), "multi.cyclo", false); - this.registerAchievement("decay.technetium99m", 14, 8, ItemUtils.getSimpleStack(ModItems.dustTechnetium99M), "multi.cyclo", false); - this.registerAchievement("decay.technetium99", 15, 8, ItemUtils.getSimpleStack(ModItems.dustTechnetium99), "multi.cyclo", false); - - - - - - - - - - - - - AchievementPage.registerAchievementPage( - new AchievementPage("GT++", (Achievement[]) ((Achievement[]) this.achievementList.values() - .toArray(new Achievement[this.achievementList.size()])))); - MinecraftForge.EVENT_BUS.register(this); - FMLCommonHandler.instance().bus().register(this); - - - } - - public Achievement registerAchievement(String textId, int x, int y, ItemStack icon, Achievement requirement, - boolean special) { - Achievement achievement = new Achievement(textId, textId, this.adjX + x, this.adjY + y, icon, requirement); - if (special) { - achievement.setSpecial(); - } - - achievement.registerStat(); - if (CORE.DEVENV) { - GT_Log.out.println("achievement." + textId + "="); - GT_Log.out.println("achievement." + textId + ".desc="); - } - - this.achievementList.put(textId, achievement); - return achievement; - } - - public Achievement registerAchievement(String textId, int x, int y, ItemStack icon, String requirement, - boolean special) { - Achievement achievement = new Achievement(textId, textId, this.adjX + x, this.adjY + y, icon, - this.getAchievement(requirement)); - if (special) { - achievement.setSpecial(); - } - - achievement.registerStat(); - if (CORE.DEVENV) { - GT_Log.out.println("achievement." + textId + "="); - GT_Log.out.println("achievement." + textId + ".desc="); - } - - this.achievementList.put(textId, achievement); - return achievement; - } - - public void issueAchievement(EntityPlayer entityplayer, String textId) { - if (entityplayer != null) { - entityplayer.triggerAchievement((StatBase) this.achievementList.get(textId)); - } - } - - public Achievement getAchievement(String textId) { - return this.achievementList.containsKey(textId) ? (Achievement) this.achievementList.get(textId) : null; - } - - - /** - * A generic handler that will give an achievement for an item. - * Useful to only write this once, then call it from all handlers. - * @param aStack - The Itemstack to check for achievements. - * @param aPlayer - The player to unlock for. - */ - private void handleAchivement(ItemStack aStack, EntityPlayer aPlayer) { - - if (aPlayer != null && aStack != null) { - /* - * Copy this to all events because I am lazy - Alk 2019 - */ - - //Safe name - String aUnlocalName = ItemUtils.getUnlocalizedItemName(aStack); - - - boolean isValid = false; - //Check if valid name // mod - String aModID = ItemUtils.getModId(aStack); - - if (aModID == null || aModID.length() <= 0 || aModID.isEmpty()) { - return; - } - - if (aModID != null && (ItemUtils.getModId(aStack).equals(CORE.MODID) || ItemUtils.getModId(aStack).equalsIgnoreCase("gregtech"))) { - isValid = true; - } - if (!isValid) { - return; - } - - //Should unlock base achievement from *ANY* GT++ item. (Too lazy to special case GT machineBlocks though) - if (ItemUtils.getModId(aStack).equals(CORE.MODID)) { - this.issueAchievement(aPlayer, aBaseAchievementName); - } - - if (aUnlocalName.contains("item.")) { - aUnlocalName = aUnlocalName.substring(5); - } - else if (aUnlocalName.contains("tile.")) { - aUnlocalName = aUnlocalName.substring(5); - } - - //Logger.INFO("Picked up "+aUnlocalName); - - - /** - * Misc Blocks - */ - - if (aUnlocalName.equals("blockFishTrap")) { - this.issueAchievement(aPlayer, "block.fishtrap"); - } - if (aUnlocalName.equals("blockBlackGate")) { - this.issueAchievement(aPlayer, "block.withercage"); - } - - - /** - * Decayables - */ - if (aUnlocalName.equals("dustNeptunium238")) { - this.issueAchievement(aPlayer, "decay.neptunium238"); - } - else if (aUnlocalName.equals("dustRadium226")) { - this.issueAchievement(aPlayer, "decay.radium226"); - } - else if (aUnlocalName.equals("dustMolybdenum99")) { - this.issueAchievement(aPlayer, "decay.molybdenum99"); - } - else if (aUnlocalName.equals("dustTechnetium99M")) { - this.issueAchievement(aPlayer, "decay.technetium99m"); - } - else if (aUnlocalName.equals("dustTechnetium99")) { - this.issueAchievement(aPlayer, "decay.technetium99"); - } - - /** - * Random Materials worthy of Achievements - */ - else if (aUnlocalName.equals("itemDustPotin")) { - this.issueAchievement(aPlayer, "dust.potin"); - } - else if (aUnlocalName.equals("itemDustEglinSteel")) { - this.issueAchievement(aPlayer, "dust.eglin"); - } - else if (aUnlocalName.equals("itemDustStaballoy")) { - this.issueAchievement(aPlayer, "dust.staballoy"); - } - else if (aUnlocalName.equals("itemDustQuantum")) { - this.issueAchievement(aPlayer, "dust.quantum"); - } - else if (aUnlocalName.equals("itemDustHypogen")) { - this.issueAchievement(aPlayer, "dust.hypogen"); - } - - - - /** - * Machines - */ - - else if (aUnlocalName.startsWith("gt.blockmachines.")) { - - //Readability - String aStartsWith = "gt.blockmachines."; - - /** - * Single Blocks - */ - - //RTG - if (aUnlocalName.startsWith(aStartsWith + "basicgenerator.rtg")) { - this.issueAchievement(aPlayer, "rtg"); - } - //Dehydrator - else if (aUnlocalName.startsWith(aStartsWith + "machine.dehydrator.tier.")) { - this.issueAchievement(aPlayer, "dehydrate"); - } - //SemiFluids - else if (aUnlocalName.startsWith(aStartsWith + "basicgenerator.semifluid.tier.")) { - this.issueAchievement(aPlayer, "semifluid"); - } - //Simple Washer - else if (aUnlocalName.startsWith(aStartsWith + "simplewasher.01.tier.")) { - this.issueAchievement(aPlayer, "earlywasher"); - } - //Advanced Boilers - else if (aUnlocalName.startsWith(aStartsWith + "electricboiler.")) { - this.issueAchievement(aPlayer, "advancedsteam"); - } - //Scrubers - else if (aUnlocalName.startsWith(aStartsWith + "pollutioncleaner.01.tier.")) { - this.issueAchievement(aPlayer, "pollutionremoval"); - } - //High-amp xformers - else if (aUnlocalName.startsWith(aStartsWith + "transformer.ha.tier.")) { - this.issueAchievement(aPlayer, "hiampxform"); - } - //Buffered Dynamos - else if (aUnlocalName.startsWith(aStartsWith + "hatch.dynamo.buffer.tier.")) { - this.issueAchievement(aPlayer, "hatch.dynamo.buffered"); - } - //Control Core Hatch - else if (aUnlocalName.startsWith(aStartsWith + "hatch.control.adv")) { - this.issueAchievement(aPlayer, "hatch.control"); - } - - - - /** - * Multis - */ - - //ABS - else if (aUnlocalName.equals(aStartsWith + "industrialsalloyamelter.controller.tier.single")) { - this.issueAchievement(aPlayer, "multi.abs"); - } - //PSS - else if (aUnlocalName.equals(aStartsWith + "substation.01.input.single")) { - this.issueAchievement(aPlayer, "multi.pss"); - } - //Cyclotron - else if (aUnlocalName.startsWith(aStartsWith + "cyclotron.tier.single")) { - this.issueAchievement(aPlayer, "multi.cyclo"); - } - //Sifter - else if (aUnlocalName.equals(aStartsWith + "industrialsifter.controller.tier.single")) { - this.issueAchievement(aPlayer, "multi.sifter"); - } - //Coke Oven - else if (aUnlocalName.equals(aStartsWith + "industrialcokeoven.controller.tier.single")) { - this.issueAchievement(aPlayer, "multi.cokeoven"); - } - //Thermal Boiler - else if (aUnlocalName.equals(aStartsWith + "gtplusplus.thermal.boiler")) { - this.issueAchievement(aPlayer, "multi.boiler.thermal"); - } - //Zhuhai - else if (aUnlocalName.equals(aStartsWith + "industrial.fishpond.controller.tier.single")) { - this.issueAchievement(aPlayer, "multi.zhuhai"); - } - - } - - /** - * Casings - */ - - else if (aUnlocalName.equals("gtplusplus.blockcasings.14")) { - this.issueAchievement(aPlayer, "casing.abs"); - } - - else if (aUnlocalName.equals("gtplusplus.blockcasings.2.9")) { - this.issueAchievement(aPlayer, "casing.cyclotron.coil"); - } - - else if (aUnlocalName.equals("gtplusplus.blockcasings.3.2")) { - this.issueAchievement(aPlayer, "casing.multiuse"); - } - else if (aUnlocalName.equals("gtplusplus.blockcasings.3.15")) { - this.issueAchievement(aPlayer, "casing.containment"); - } - } - } - - - - - /* - * Handle achievements for all vanilla types of obtianment. - */ - - - - @SubscribeEvent - public void onCrafting(ItemCraftedEvent event) { - EntityPlayer player = event.player; - ItemStack stack = event.crafting; - if (player != null && stack != null) { - handleAchivement(stack, player); - } - } - - @SubscribeEvent - public void onSmelting(ItemSmeltedEvent event) { - EntityPlayer player = event.player; - ItemStack stack = event.smelting; - if (player != null && stack != null) { - handleAchivement(stack, player); - } - } - - @SubscribeEvent - public void onItemPickup(EntityItemPickupEvent event) { - EntityPlayer player = event.entityPlayer; - ItemStack stack = event.item.getEntityItem(); - if (player != null && stack != null) { - handleAchivement(stack, player); - } - } -} \ No newline at end of file + + public ConcurrentHashMap achievementList = new ConcurrentHashMap(); + public ConcurrentHashMap issuedAchievements = new ConcurrentHashMap(); + + public int adjX = 5; + public int adjY = 9; + + private static final String aBaseAchievementName = "gtpp.start"; + + public AchievementHandler() { + + Logger.INFO("Initializing GT++ achievements"); + GT_Log.out.println("Initializing GT++ achievements"); + + // register first + this.registerAchievement( + aBaseAchievementName, + 0, + 0, + MetaGeneratedGregtechTools.INSTANCE.getToolWithStats( + MetaGeneratedGregtechTools.ANGLE_GRINDER, 1, Materials.Osmium, Materials.Osmium, null), + "", + true); + + // Useful Info + boolean cores = CORE.ConfigSwitches.requireControlCores; + if (cores || GregtechMeta_MultiBlockBase.DEBUG_DISABLE_CORES_TEMPORARILY) { + this.registerAchievement( + "hatch.control", -2, -2, GregtechItemList.Hatch_Control_Core.get(1), aBaseAchievementName, false); + } + this.registerAchievement( + "hatch.dynamo.buffered", + 2, + -2, + GregtechItemList.Hatch_Buffer_Dynamo_IV.get(1), + aBaseAchievementName, + false); + // First multi anyone really needs + this.registerAchievement( + "multi.abs", + -4, + -2, + GregtechItemList.Industrial_AlloyBlastSmelter.get(1), + cores ? "hatch.control" : aBaseAchievementName, + true); + + // Material Advancement + this.registerAchievement("dust.potin", 0, 2, ALLOY.POTIN.getDust(1), aBaseAchievementName, false); + this.registerAchievement("dust.eglin", 0, 4, ALLOY.EGLIN_STEEL.getDust(1), "dust.potin", false); + this.registerAchievement("dust.staballoy", 0, 6, ALLOY.STABALLOY.getDust(1), "dust.eglin", false); + this.registerAchievement("dust.quantum", 0, 8, ALLOY.QUANTUM.getDust(1), "dust.staballoy", true); + this.registerAchievement("dust.hypogen", 0, 10, ELEMENT.STANDALONE.HYPOGEN.getDust(1), "dust.quantum", true); + + // Blocks + this.registerAchievement( + "block.fishtrap", -2, 2, ItemUtils.getSimpleStack(ModBlocks.blockFishTrap), "dust.potin", false); + this.registerAchievement( + "block.withercage", -2, 4, ItemUtils.getSimpleStack(ModBlocks.blockWitherGuard), "dust.eglin", false); + + // Machines (-10/-8/-6) + this.registerAchievement("rtg", -16, -10, GregtechItemList.RTG.get(1), aBaseAchievementName, false); + this.registerAchievement( + "dehydrate", -15, -10, GregtechItemList.GT_Dehydrator_HV.get(1), aBaseAchievementName, false); + this.registerAchievement( + "semifluid", -14, -10, GregtechItemList.Generator_SemiFluid_HV.get(1), aBaseAchievementName, false); + this.registerAchievement( + "earlywasher", -13, -10, GregtechItemList.SimpleDustWasher_ULV.get(1), aBaseAchievementName, false); + this.registerAchievement( + "advancedsteam", -12, -10, GregtechItemList.Boiler_Advanced_MV.get(1), aBaseAchievementName, false); + if (PollutionUtils.isPollutionEnabled()) { + this.registerAchievement( + "pollutionremoval", + -11, + -10, + GregtechItemList.Pollution_Cleaner_IV.get(1), + aBaseAchievementName, + false); + } + this.registerAchievement( + "hiampxform", -10, -10, GregtechItemList.Transformer_HA_HV_MV.get(1), aBaseAchievementName, false); + + // Multis (-4/-2/0) + this.registerAchievement("multi.pss", -16, -7, GregtechItemList.PowerSubStation.get(1), "multi.abs", false); + this.registerAchievement("multi.cyclo", -15, -7, GregtechItemList.COMET_Cyclotron.get(1), "multi.abs", false); + this.registerAchievement( + "multi.sifter", -14, -7, GregtechItemList.Industrial_Sifter.get(1), "dust.eglin", false); + this.registerAchievement( + "multi.cokeoven", -13, -7, GregtechItemList.Industrial_CokeOven.get(1), "multi.abs", false); + this.registerAchievement( + "multi.boiler.thermal", -12, -7, GregtechItemList.GT4_Thermal_Boiler.get(1), "multi.abs", false); + this.registerAchievement( + "multi.zhuhai", -11, -7, GregtechItemList.Industrial_FishingPond.get(1), aBaseAchievementName, false); + // this.registerAchievement("rtg", -4, -4, GregtechItemList.RTG.get(1), aBaseAchievementName, false); + + // Casings + this.registerAchievement( + "casing.abs", 2, -10, GregtechItemList.Casing_Coil_BlastSmelter.get(1), aBaseAchievementName, false); + this.registerAchievement( + "casing.cyclotron.coil", + 3, + -10, + GregtechItemList.Casing_Cyclotron_Coil.get(1), + aBaseAchievementName, + false); + this.registerAchievement( + "casing.multiuse", 4, -10, GregtechItemList.Casing_Multi_Use.get(1), aBaseAchievementName, false); + this.registerAchievement( + "casing.containment", 5, -10, GregtechItemList.Casing_Containment.get(1), aBaseAchievementName, false); + + // Radioactive + this.registerAchievement( + "decay.neptunium238", 11, 8, ItemUtils.getSimpleStack(ModItems.dustNeptunium238), "multi.cyclo", false); + this.registerAchievement( + "decay.radium226", 12, 8, ItemUtils.getSimpleStack(ModItems.dustRadium226), "multi.cyclo", false); + this.registerAchievement( + "decay.molybdenum99", 13, 8, ItemUtils.getSimpleStack(ModItems.dustMolybdenum99), "multi.cyclo", false); + this.registerAchievement( + "decay.technetium99m", + 14, + 8, + ItemUtils.getSimpleStack(ModItems.dustTechnetium99M), + "multi.cyclo", + false); + this.registerAchievement( + "decay.technetium99", 15, 8, ItemUtils.getSimpleStack(ModItems.dustTechnetium99), "multi.cyclo", false); + + AchievementPage.registerAchievementPage(new AchievementPage("GT++", (Achievement[]) + ((Achievement[]) this.achievementList.values().toArray(new Achievement[this.achievementList.size()])))); + MinecraftForge.EVENT_BUS.register(this); + FMLCommonHandler.instance().bus().register(this); + } + + public Achievement registerAchievement( + String textId, int x, int y, ItemStack icon, Achievement requirement, boolean special) { + Achievement achievement = new Achievement(textId, textId, this.adjX + x, this.adjY + y, icon, requirement); + if (special) { + achievement.setSpecial(); + } + + achievement.registerStat(); + if (CORE.DEVENV) { + GT_Log.out.println("achievement." + textId + "="); + GT_Log.out.println("achievement." + textId + ".desc="); + } + + this.achievementList.put(textId, achievement); + return achievement; + } + + public Achievement registerAchievement( + String textId, int x, int y, ItemStack icon, String requirement, boolean special) { + Achievement achievement = + new Achievement(textId, textId, this.adjX + x, this.adjY + y, icon, this.getAchievement(requirement)); + if (special) { + achievement.setSpecial(); + } + + achievement.registerStat(); + if (CORE.DEVENV) { + GT_Log.out.println("achievement." + textId + "="); + GT_Log.out.println("achievement." + textId + ".desc="); + } + + this.achievementList.put(textId, achievement); + return achievement; + } + + public void issueAchievement(EntityPlayer entityplayer, String textId) { + if (entityplayer != null) { + entityplayer.triggerAchievement((StatBase) this.achievementList.get(textId)); + } + } + + public Achievement getAchievement(String textId) { + return this.achievementList.containsKey(textId) ? (Achievement) this.achievementList.get(textId) : null; + } + + /** + * A generic handler that will give an achievement for an item. + * Useful to only write this once, then call it from all handlers. + * @param aStack - The Itemstack to check for achievements. + * @param aPlayer - The player to unlock for. + */ + private void handleAchivement(ItemStack aStack, EntityPlayer aPlayer) { + + if (aPlayer != null && aStack != null) { + /* + * Copy this to all events because I am lazy - Alk 2019 + */ + + // Safe name + String aUnlocalName = ItemUtils.getUnlocalizedItemName(aStack); + + boolean isValid = false; + // Check if valid name // mod + String aModID = ItemUtils.getModId(aStack); + + if (aModID == null || aModID.length() <= 0 || aModID.isEmpty()) { + return; + } + + if (aModID != null + && (ItemUtils.getModId(aStack).equals(CORE.MODID) + || ItemUtils.getModId(aStack).equalsIgnoreCase("gregtech"))) { + isValid = true; + } + if (!isValid) { + return; + } + + // Should unlock base achievement from *ANY* GT++ item. (Too lazy to special case GT machineBlocks though) + if (ItemUtils.getModId(aStack).equals(CORE.MODID)) { + this.issueAchievement(aPlayer, aBaseAchievementName); + } + + if (aUnlocalName.contains("item.")) { + aUnlocalName = aUnlocalName.substring(5); + } else if (aUnlocalName.contains("tile.")) { + aUnlocalName = aUnlocalName.substring(5); + } + + // Logger.INFO("Picked up "+aUnlocalName); + + /** + * Misc Blocks + */ + if (aUnlocalName.equals("blockFishTrap")) { + this.issueAchievement(aPlayer, "block.fishtrap"); + } + if (aUnlocalName.equals("blockBlackGate")) { + this.issueAchievement(aPlayer, "block.withercage"); + } + + /** + * Decayables + */ + if (aUnlocalName.equals("dustNeptunium238")) { + this.issueAchievement(aPlayer, "decay.neptunium238"); + } else if (aUnlocalName.equals("dustRadium226")) { + this.issueAchievement(aPlayer, "decay.radium226"); + } else if (aUnlocalName.equals("dustMolybdenum99")) { + this.issueAchievement(aPlayer, "decay.molybdenum99"); + } else if (aUnlocalName.equals("dustTechnetium99M")) { + this.issueAchievement(aPlayer, "decay.technetium99m"); + } else if (aUnlocalName.equals("dustTechnetium99")) { + this.issueAchievement(aPlayer, "decay.technetium99"); + } + + /** + * Random Materials worthy of Achievements + */ + else if (aUnlocalName.equals("itemDustPotin")) { + this.issueAchievement(aPlayer, "dust.potin"); + } else if (aUnlocalName.equals("itemDustEglinSteel")) { + this.issueAchievement(aPlayer, "dust.eglin"); + } else if (aUnlocalName.equals("itemDustStaballoy")) { + this.issueAchievement(aPlayer, "dust.staballoy"); + } else if (aUnlocalName.equals("itemDustQuantum")) { + this.issueAchievement(aPlayer, "dust.quantum"); + } else if (aUnlocalName.equals("itemDustHypogen")) { + this.issueAchievement(aPlayer, "dust.hypogen"); + } + + /** + * Machines + */ + else if (aUnlocalName.startsWith("gt.blockmachines.")) { + + // Readability + String aStartsWith = "gt.blockmachines."; + + /** + * Single Blocks + */ + + // RTG + if (aUnlocalName.startsWith(aStartsWith + "basicgenerator.rtg")) { + this.issueAchievement(aPlayer, "rtg"); + } + // Dehydrator + else if (aUnlocalName.startsWith(aStartsWith + "machine.dehydrator.tier.")) { + this.issueAchievement(aPlayer, "dehydrate"); + } + // SemiFluids + else if (aUnlocalName.startsWith(aStartsWith + "basicgenerator.semifluid.tier.")) { + this.issueAchievement(aPlayer, "semifluid"); + } + // Simple Washer + else if (aUnlocalName.startsWith(aStartsWith + "simplewasher.01.tier.")) { + this.issueAchievement(aPlayer, "earlywasher"); + } + // Advanced Boilers + else if (aUnlocalName.startsWith(aStartsWith + "electricboiler.")) { + this.issueAchievement(aPlayer, "advancedsteam"); + } + // Scrubers + else if (aUnlocalName.startsWith(aStartsWith + "pollutioncleaner.01.tier.")) { + this.issueAchievement(aPlayer, "pollutionremoval"); + } + // High-amp xformers + else if (aUnlocalName.startsWith(aStartsWith + "transformer.ha.tier.")) { + this.issueAchievement(aPlayer, "hiampxform"); + } + // Buffered Dynamos + else if (aUnlocalName.startsWith(aStartsWith + "hatch.dynamo.buffer.tier.")) { + this.issueAchievement(aPlayer, "hatch.dynamo.buffered"); + } + // Control Core Hatch + else if (aUnlocalName.startsWith(aStartsWith + "hatch.control.adv")) { + this.issueAchievement(aPlayer, "hatch.control"); + } + + /** + * Multis + */ + + // ABS + else if (aUnlocalName.equals(aStartsWith + "industrialsalloyamelter.controller.tier.single")) { + this.issueAchievement(aPlayer, "multi.abs"); + } + // PSS + else if (aUnlocalName.equals(aStartsWith + "substation.01.input.single")) { + this.issueAchievement(aPlayer, "multi.pss"); + } + // Cyclotron + else if (aUnlocalName.startsWith(aStartsWith + "cyclotron.tier.single")) { + this.issueAchievement(aPlayer, "multi.cyclo"); + } + // Sifter + else if (aUnlocalName.equals(aStartsWith + "industrialsifter.controller.tier.single")) { + this.issueAchievement(aPlayer, "multi.sifter"); + } + // Coke Oven + else if (aUnlocalName.equals(aStartsWith + "industrialcokeoven.controller.tier.single")) { + this.issueAchievement(aPlayer, "multi.cokeoven"); + } + // Thermal Boiler + else if (aUnlocalName.equals(aStartsWith + "gtplusplus.thermal.boiler")) { + this.issueAchievement(aPlayer, "multi.boiler.thermal"); + } + // Zhuhai + else if (aUnlocalName.equals(aStartsWith + "industrial.fishpond.controller.tier.single")) { + this.issueAchievement(aPlayer, "multi.zhuhai"); + } + + } + + /** + * Casings + */ + else if (aUnlocalName.equals("gtplusplus.blockcasings.14")) { + this.issueAchievement(aPlayer, "casing.abs"); + } else if (aUnlocalName.equals("gtplusplus.blockcasings.2.9")) { + this.issueAchievement(aPlayer, "casing.cyclotron.coil"); + } else if (aUnlocalName.equals("gtplusplus.blockcasings.3.2")) { + this.issueAchievement(aPlayer, "casing.multiuse"); + } else if (aUnlocalName.equals("gtplusplus.blockcasings.3.15")) { + this.issueAchievement(aPlayer, "casing.containment"); + } + } + } + + /* + * Handle achievements for all vanilla types of obtianment. + */ + + @SubscribeEvent + public void onCrafting(ItemCraftedEvent event) { + EntityPlayer player = event.player; + ItemStack stack = event.crafting; + if (player != null && stack != null) { + handleAchivement(stack, player); + } + } + + @SubscribeEvent + public void onSmelting(ItemSmeltedEvent event) { + EntityPlayer player = event.player; + ItemStack stack = event.smelting; + if (player != null && stack != null) { + handleAchivement(stack, player); + } + } + + @SubscribeEvent + public void onItemPickup(EntityItemPickupEvent event) { + EntityPlayer player = event.entityPlayer; + ItemStack stack = event.item.getEntityItem(); + if (player != null && stack != null) { + handleAchivement(stack, player); + } + } +} diff --git a/src/main/java/gtPlusPlus/core/handler/BookHandler.java b/src/main/java/gtPlusPlus/core/handler/BookHandler.java index 1363a70fe4..747c1055e1 100644 --- a/src/main/java/gtPlusPlus/core/handler/BookHandler.java +++ b/src/main/java/gtPlusPlus/core/handler/BookHandler.java @@ -1,7 +1,7 @@ package gtPlusPlus.core.handler; -import java.util.HashMap; -import java.util.Map; +import static gtPlusPlus.core.util.Utils.addBookPagesLocalization; +import static gtPlusPlus.core.util.Utils.addBookTitleLocalization; import gregtech.api.enums.GT_Values; import gregtech.api.util.GT_OreDictUnificator; @@ -10,415 +10,387 @@ import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.RecipeUtils; +import java.util.HashMap; +import java.util.Map; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; -import static gtPlusPlus.core.util.Utils.addBookPagesLocalization; -import static gtPlusPlus.core.util.Utils.addBookTitleLocalization; - public class BookHandler { - public static int mBookKeeperCount = 0; - - public static Map mBookMap = new HashMap(); - - public static BookTemplate book_ThermalBoiler; - public static BookTemplate book_MultiPowerStation; - public static BookTemplate book_ModularBauble; - public static BookTemplate book_MultiMachineManual; - public static BookTemplate book_NuclearManual; - public static BookTemplate book_MultiChemicalPlant; - - public static void run(){ - - Logger.INFO("Writing books."); - - //Thermal Boiler - book_ThermalBoiler = writeBookTemplate( - "Manual_Thermal_Boiler", "Thermal Boiler Manual", "GregoriusT", - new String[] { - "This Book explains how to set up and run your Thermal Boiler. We are not responsible for any Damage done by this Book itself nor its content.", - "First you need to craft the following things for a Thermal Boiler to Function: The Main Boiler Block, 20 Thermal Containment Casings, two Input Hatches, two Output Hatches, a bunch of different Tools and a Maintenance Hatch.", - "To begin the building, lay out the first 3x3 layer of Machine Casings on the ground (with a Hatch in the Middle), then place the Boiler Block facing outward in the middle of one of the 3m wide Sides.", - "Now grab 3 other Hatches and place them on the remaining three 3m wide Sides also facing outwards. And now the four corners of the Machine need also a Machine Casing. There should only be a Hole left in the middle of the Cube.", - "So, now place a 3x3 of Machine Casings on top, at the 3rd Layer with the last Hatch in the middle facing outwards as well.", - "When accessing the Boiler Block, it should now stop telling you, that the structure is incomplete (bottom Line of that Screen). Now go with a bunch of different Tools (Metal Hammer, Rubber Hammer, Screwdriver, Wrench, Soldering Iron and Crowbar)", - "to the Maintenance Hatch and access it. After that you grab the 6 Tools and rightclick the Slot with each of them in your Hand in the Maintenance GUI. Note that you need Soldering Tin/Lead in your Inventory to use the Soldering Iron.", - "The Main Block should now tell you that you need to use the Rubber Hammer on it to (re)activate the Machine. The Rubber Hammer can enable and disable Machines. The Machine disables itself after something important broke.", - "If you want to use Lava with this Device, then you should add a Lava Filter to extract additional Resources from the Lava. If the Filter breaks, the Machine won't explode like a Turbine would. If you use molten Salt, then you won't need a Filter.", - "You will get Obsidian when processing Lava, however if a Filter is used, you will get sometimes an Ingot instead of a Block of Obsidian. When using molten Salt, you will get the Salt back.", - "So, now for the Maintenance. After a few Hours of running nonstop, your Boiler will get small Problems, which don't prevent it from running, these Problems just decrease Efficiency. Every Problem listed on the Screen does -10% Efficiency.", - "To fix these Problems, just go to the Maintenance Hatch and click with the problem corresponding Tool on the Slot to repair. If all six possible runtime Problems happen, the Machine will auto-shutdown no matter what. No Explosion, it's just stopping.", - "The Thermal Boiler will produce 800 Liters of Steam per tick for about 5 or 6 Liters of Water per tick at reaching 100% Efficiency. In case of Lava it consumes 1666 Liters every Second.", - "A Thermal Boiler is worth about 33 small Thermal Generators, and as the Boilers get much less Efficient, when not having enough Fuel, you should consider making a large Nether Pump for Lava, or a good Nuclear Reactor for molten Salt.", - "Input and Output Slots are fully optional, you can place multiple ones of them or even none on the Machine. A Machine without Input couldn't process any Recipes, while a Machine without Output just voids all outputted Items and Liquids.", - "It might be useful to use the Screwdriver on the Output Hatches to determine what is outputted where." }); - - - - //Test Novel - book_MultiPowerStation = writeBookTemplate( - "Manual_Multi_PowerStation", - "Power Storage & You [Version 0.64]", - "Alkalus", - new String[] { - //Page 1 - "So, when it comes to power storage you really have three separate options:\n"+ - " \n"+ - "Battery Buffers,\n"+ - "Energy Buffers,\n"+ - "The Power Sub-Station\n", - //Page 2 - "Battery Buffer\n" + - " \n" + - "Is rather portable. Allowing you to throw set one up and insert batteries where ever you may need."+"\n"+ - "They output 1A for each battery stored inside, up to a maximum of 16A.", - //Page 3 - "Energy Buffer\n" + - " \n" + - "Is a more optimal choice for storage in your base. Once placed down, they cannot be moved without losing all stored power."+"\n"+ - "Energy Buffers can output 4A from the output side, however accept 16A as input.", - //Page 4 - "The Power Sub-Station"+ - " \n"+ - "Is used for storing Insane amounts of power later game."+"\n"+ - "Consumes 2% of the average voltage of all energy type hatches every tick."+"\n", - //Page 5 - "Allows Insertion/Removal of power from the rear face of the controller, swap with a screwdriver."+"\n"+ - "Variable Height Structure, between 4-16Y. Inserted Redox Cells dictate max energy tier of structure."+"\n", - //Page 6 - "Redox Cells cannot be placed into the Top or Bottom layer and only take up 3xhx3 internally."+"\n"+ - "Different Tier cells CANNOT be mixed together."+"\n", - //Page 7 - "All Hatches Must be HV at a Minimum, this minimum tier is in place to stop people abusing ULV/LV hatches to lower the avg/t."+"\n"+ - "Currently the GUI will NOT display anything at all until the structure forms, this is a known bug."+"\n", - //Page 8 - "Valid Hatches:\n"+ - "Energy Hatch,\n"+ - "Dynamo Hatch,\n"+ - "Charging Bus,\n"+ - "Discharging Bus,\n"+ - "Dynamo Buffer,\n"+ - "Multi-Amp Dynamo Hatch.\n\n\n"+ - "Structure MUST contain at least one energy input and one energy output hatch." - }); - - //Test Novel - book_ModularBauble = writeBookTemplate( - "Manual_Modular_Bauble", "How to: Modular Baubles", "Alkalus", - new String[] { - "Concept: This idea came from wanting flexibility. \n" + - "First step, Build a Modularity table to begin customisation of your Bauble. \n" - + " After this has been constructed, you can now combine the upgrades listed within this book to improve the baubles level/100.", - "Defence:\n" - + "Can be upgraded by combining metal plates with the bauble. \n" - + " | +1 | Aluminium \n" - + " | +2 | Stainless Steel \n" - + " | +3 | Tungsten \n" - + " | +4 | Tungsten Steel \n" - + " | +5 | Naquadah \n", - "There was once a sad and lonely oak tree. \n", - "There was once a sad and lonely oak tree. \n", - "There was once a sad and lonely oak tree. \n"}); - - //Test Novel - //20/21/22 - book_MultiMachineManual = writeBookTemplate( - "Manual_Multi_Machine", "Multi-Machine Manual", "Alkalus", - new String[] { - "This Multiblock, depending upon the mode used, can function as a variety of different machines. The idea behind this, was that most of these machines are rather niche compared to any others, as such, not used often.", - "To build, you need to construct a hollow 3x3x3 structure made from Multi-Use casings, With a minimum of 6. Any Casing position can be substituted out with an Input Hatch/Bus, an Output Hatch/Bus, Muffler, Maint. Hatch or Energy Injector Hatch.", - "The Mode can be set by using a Screwdriver on the controller block. Each mode allows the use of Numbered Circuits, to allow a different machine 'type' for each input bus.", - "[Metal Work] Mode A - Allows the multiblock to function as a Compressor, a Lathe or an Electro-Magnet. To allow a hatch to run in Compressor mode, insert a No. 20 circuit. For Lathe, use No. 21 and for Electro-Magnet use No. 22.", - "[Fluid Work] Mode B - Allows the multiblock to function as a Fermenter, a Fluid Extractor or an Extractor. To allow a hatch to run in Fermenter mode, insert a No. 20 circuit. For Fluid Extractor, use No. 21 and for Extractor use No. 22.", - "[Misc. Work] Mode C - Allows the multiblock to function as a Laser Engraver, an Autoclave or a Fluid Solidifier. To allow a hatch to run in Laser Engraver mode, insert a No. 20 circuit. For Autoclave, use No. 21 and for Solidifier use No. 22.", - }); - - book_NuclearManual = writeBookTemplate( - "Manual_NuclearStuff_1", "Nuclear Chemistry [FFPP]", "Alkalus", - new String[] { - //Page 1 - "Fission Fuel Processing Plant\n" - + "Size: 3x9x3 [LxHxW]\n" - + "Controller: Center, Bottom\n" - + "4x Input Hatch\n" - + "2x Output Hatch\n" - + "1x Output Bus\n" - + "1x ZPM+ Muffler\n" - + "1x Maintenance Hatch\n" - + "1x Energy Hatch\n", - //Page 2 - "[1] 7x Hastelloy-X or I/O\n" - + "[2] 5x Incoloy-DS Fluid Containment\n" - + "[3] 4x Zeron-100 Shielding\n" - + "[4] 17x Hastelloy-N Sealant Case" - + "\n" - + "Multiblock Construction\n" - + "Convention is [LxHxW]\n" - + "\n", - //Page 3 - "Layer 1/2:\n" - + "[1][1][1]\n" - + "[1][1][1]\n" - + "[1][1][1]\n" - + "\n" - + "Layer 3/5/6\n" - + "[ ][4][ ]\n" - + "[4][2][4]\n" - + "[ ][4][ ]\n" - + "\n", - //Page 4 - "Layer 4\n" - + "[ ][3][ ]\n" - + "[3][2][3]\n" - + "[ ][3][ ]\n" - + "\n" - + "Layer 7/8/9\n" - + "[ ][ ][ ]\n" - + "[ ][3][ ]\n" - + "[ ][ ][ ]\n" - , - //Page 5 - "Fission Fuel\n"+ - "Processing Plant"+ - "----------------------\n"+ - "This structure is used to produce the Molten Salts required to run a Liquid Fluorine Thorium Reactor [LFTR]." - - }); - - - book_MultiChemicalPlant = writeBookTemplate( - "book_Multi_ChemicalPlant", "Chemical Plant Manual", "Alkalus", - new String[] { - - // Intro - "This book will explain how the Chemical Plant is constructed, which blocks are valid to upgrade it and also how the upgrades work.", - - // Info - "Solid Casings = Plant tier" + "\n" + - "Machine Casings = Hatch tier" + "\n" + - "Higher tier coils More Speed" + "\n" + - "T1 50% , T2 100% , T3 150%, etc" + "\n", - - "Higher tier pipe casings boost parallel"+ "\n" + - "and reduce catalyst consumption." + "\n" + - "+2 parallel per tier, 20% extra chance of"+ "\n" + - "not damaging catalyst per tier.", - - "Awakened Draconium Coil (or above) with" + "\n" + - "Tungstensteel Pipe Casing" + "\n" + - "does not damage catalyst at all.", - - - // Machine Casings - "Valid Solid Machine Casings:" + "\n" + - "0 - Strong Bronze" + "\n" + - "1 - Solid Steel" + "\n" + - "2 - Sturdy Aluminium" + "\n" + - "3 - Clean Stainless Steel" + "\n" + - "4 - Stable Titanium" + "\n" + - "5 - Robust Tungstensteel" + "\n" + - "6 - Vigorous Laurenium" + "\n" + - "7 - Rugged Botmium", - - // Machine Casings - "Valid Tiered Machine Casings:" + "\n" + "\n" + - "1 - " + GT_Values.VN[0] + "\n" + - "2 - " + GT_Values.VN[1] + "\n" + - "3 - " + GT_Values.VN[2] + "\n" + - "4 - " + GT_Values.VN[3] + "\n" + - "5 - " + GT_Values.VN[4] + "\n" + - "6 - " + GT_Values.VN[5] + "\n" + - "7 - " + GT_Values.VN[6] + "\n" + - "8 - " + GT_Values.VN[7] + "\n" + - "9 - " + GT_Values.VN[8] + "\n" + - "10 - " + GT_Values.VN[9], - - // Pipe Casings - "Valid Pipe Casings:" + "\n" + "\n" + - "1 - Bronze" + "\n" + - "2 - Steel" + "\n" + - "3 - Titanium" + "\n" + - "4 - Tungstensteel", - - //Coils - "Valid Coils:" + "\n" + "\n" + - "1 - Cupronickel" + "\n" + - "2 - Kanthal" + "\n" + - "3 - Nichrome" + "\n" + - "4 - Tungstensteel" + "\n" + - "5 - HSS-G" + "\n" + - "6 - HSS-S" + "\n" + - "7 - Naquadah" + "\n" + - "8 - Naquadah Alloy" + "\n" + - "9 - Trinium" + "\n" + - "10 - Fluxed Electrum", - - "11 - Awakened Draconium" + "\n" + - "12 - Infinity" + "\n" + - "13 - Hypogen" + "\n" + - "14 - Eternal", - - // Requirements - "Multiblock Requirements:" + "\n" + "\n" + - "27x Coils" + "\n" + - "18x Pipe Casings" + "\n" + - "57x Tiered Machine Casings" + "\n" + - "70+ Solid Casings" + "\n" + - "1x Catalyst Housing (Catalysts cannot go inside an Input Bus)", - - // Construction Guide - "Construction Guide Pt1:" + "\n" + "\n" + - "Controller is placed on a middle casing in the bottom layer" + "\n" + - "Hatches can only be placed on the bottom layer edges", - - "Construction Guide Pt2:" + "\n" + "\n" + - "7x7x7 Hollow frame of solid casings" + "\n" + - "5x1x5 layer of solid casings (fills in top layer)" + "\n" + - "5x1x5 layer of machine casings (fills in bottom layer)", - - "Construction Guide Pt3:" + "\n" + - "In the central 3x5x3:" + "\n" + - "3x1x3 layer of Coils, surrounded by ring of Machine Casings" + "\n" + - "3x1x3 layer of Pipe Casings" + "\n" + - "3x1x3 layer of Coils" + "\n" + - "3x1x3 layer of Pipe Casings" + "\n" + - "3x1x3 layer of Coils, surrounded by ring of Machine Casings", - - // Construction Guide Info - "Information:" + "\n" + "\n" + - "A = Air" + "\n" + - "X = Solid Casing" + "\n" + - "M = Machine Casing" + "\n" + - "P = Pipe Casing" + "\n" + - "C = Coil Casing", - - "Layer 1:" + "\n" + "\n" + - "XXXXXXX" + "\n" + - "XMMMMMX" + "\n" + - "XMMMMMX" + "\n" + - "XMMMMMX" + "\n" + - "XMMMMMX" + "\n" + - "XMMMMMX" + "\n" + - "XXXXXXX", - - "Layer 2:" + "\n" + "\n" + - "XAAAAAX" + "\n" + - "AMMMMMA" + "\n" + - "AMCCCMA" + "\n" + - "AMCCCMA" + "\n" + - "AMCCCMA" + "\n" + - "AMMMMMA" + "\n" + - "XAAAAAX", - - "Layer 3:" + "\n" + "\n" + - "XAAAAAX" + "\n" + - "AAAAAAA" + "\n" + - "AAPPPAA" + "\n" + - "AAPPPAA" + "\n" + - "AAPPPAA" + "\n" + - "AAAAAAA" + "\n" + - "XAAAAAX", - - "Layer 4:" + "\n" + "\n" + - "XAAAAAX" + "\n" + - "AAAAAAA" + "\n" + - "AACCCAA" + "\n" + - "AACCCAA" + "\n" + - "AACCCAA" + "\n" + - "AAAAAAA" + "\n" + - "XAAAAAX", - - "Layer 5:" + "\n" + "\n" + - "XAAAAAX" + "\n" + - "AAAAAAA" + "\n" + - "AAPPPAA" + "\n" + - "AAPPPAA" + "\n" + - "AAPPPAA" + "\n" + - "AAAAAAA" + "\n" + - "XAAAAAX", - - "Layer 6:" + "\n" + "\n" + - "XAAAAAX" + "\n" + - "AMMMMMA" + "\n" + - "AMCCCMA" + "\n" + - "AMCCCMA" + "\n" + - "AMCCCMA" + "\n" + - "AMMMMMA" + "\n" + - "XAAAAAX", - - "Layer 7:" + "\n" + "\n" + - "XXXXXXX" + "\n" + - "XXXXXXX" + "\n" + - "XXXXXXX" + "\n" + - "XXXXXXX" + "\n" + - "XXXXXXX" + "\n" + - "XXXXXXX" + "\n" + - "XXXXXXX", - }); - - } - - - - - public static ItemStack ItemBookWritten_ThermalBoiler; - public static ItemStack ItemBookWritten_NuclearManual; - public static ItemStack ItemBookWritten_ModularBaubles; - public static ItemStack ItemBookWritten_MultiPowerStorage; - public static ItemStack ItemBookWritten_MultiMachineManual; - public static ItemStack ItemBookWritten_MultiChemicalPlant; - - public static void runLater(){ - ItemBookWritten_ThermalBoiler = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, 0, 1); - ItemBookWritten_MultiPowerStorage = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, 1, 1); - ItemBookWritten_ModularBaubles = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, 2, 1); - ItemBookWritten_MultiMachineManual = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, 3, 1); - ItemBookWritten_NuclearManual = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, 4, 1); - ItemBookWritten_MultiChemicalPlant = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, 5, 1); - - //Multiblock Manuals - RecipeUtils.addShapelessGregtechRecipe(new ItemStack[]{ItemUtils.getSimpleStack(Items.writable_book), ItemUtils.getSimpleStack(Items.lava_bucket)}, ItemBookWritten_ThermalBoiler); - RecipeUtils.addShapelessGregtechRecipe(new ItemStack[]{ItemUtils.getSimpleStack(Items.writable_book), ItemUtils.getItemStackOfAmountFromOreDict(CI.craftingToolWrench, 1)}, ItemBookWritten_MultiMachineManual); - RecipeUtils.addShapelessGregtechRecipe(new ItemStack[]{ItemUtils.getSimpleStack(Items.writable_book), ItemUtils.getItemStackOfAmountFromOreDict("wireGt01Tin", 1)}, ItemBookWritten_MultiPowerStorage); - RecipeUtils.addShapelessGregtechRecipe(new ItemStack[]{ItemUtils.getSimpleStack(Items.writable_book), ItemUtils.getItemStackOfAmountFromOreDict("dustUranium", 1)}, ItemBookWritten_NuclearManual); - RecipeUtils.addShapelessGregtechRecipe(new ItemStack[]{ItemUtils.getSimpleStack(Items.writable_book), ItemUtils.getItemStackOfAmountFromOreDict("wireGt01Copper", 1)}, ItemBookWritten_MultiChemicalPlant); - - for (int i=0;i mBookMap = new HashMap(); + + public static BookTemplate book_ThermalBoiler; + public static BookTemplate book_MultiPowerStation; + public static BookTemplate book_ModularBauble; + public static BookTemplate book_MultiMachineManual; + public static BookTemplate book_NuclearManual; + public static BookTemplate book_MultiChemicalPlant; + + public static void run() { + + Logger.INFO("Writing books."); + + // Thermal Boiler + book_ThermalBoiler = + writeBookTemplate("Manual_Thermal_Boiler", "Thermal Boiler Manual", "GregoriusT", new String[] { + "This Book explains how to set up and run your Thermal Boiler. We are not responsible for any Damage done by this Book itself nor its content.", + "First you need to craft the following things for a Thermal Boiler to Function: The Main Boiler Block, 20 Thermal Containment Casings, two Input Hatches, two Output Hatches, a bunch of different Tools and a Maintenance Hatch.", + "To begin the building, lay out the first 3x3 layer of Machine Casings on the ground (with a Hatch in the Middle), then place the Boiler Block facing outward in the middle of one of the 3m wide Sides.", + "Now grab 3 other Hatches and place them on the remaining three 3m wide Sides also facing outwards. And now the four corners of the Machine need also a Machine Casing. There should only be a Hole left in the middle of the Cube.", + "So, now place a 3x3 of Machine Casings on top, at the 3rd Layer with the last Hatch in the middle facing outwards as well.", + "When accessing the Boiler Block, it should now stop telling you, that the structure is incomplete (bottom Line of that Screen). Now go with a bunch of different Tools (Metal Hammer, Rubber Hammer, Screwdriver, Wrench, Soldering Iron and Crowbar)", + "to the Maintenance Hatch and access it. After that you grab the 6 Tools and rightclick the Slot with each of them in your Hand in the Maintenance GUI. Note that you need Soldering Tin/Lead in your Inventory to use the Soldering Iron.", + "The Main Block should now tell you that you need to use the Rubber Hammer on it to (re)activate the Machine. The Rubber Hammer can enable and disable Machines. The Machine disables itself after something important broke.", + "If you want to use Lava with this Device, then you should add a Lava Filter to extract additional Resources from the Lava. If the Filter breaks, the Machine won't explode like a Turbine would. If you use molten Salt, then you won't need a Filter.", + "You will get Obsidian when processing Lava, however if a Filter is used, you will get sometimes an Ingot instead of a Block of Obsidian. When using molten Salt, you will get the Salt back.", + "So, now for the Maintenance. After a few Hours of running nonstop, your Boiler will get small Problems, which don't prevent it from running, these Problems just decrease Efficiency. Every Problem listed on the Screen does -10% Efficiency.", + "To fix these Problems, just go to the Maintenance Hatch and click with the problem corresponding Tool on the Slot to repair. If all six possible runtime Problems happen, the Machine will auto-shutdown no matter what. No Explosion, it's just stopping.", + "The Thermal Boiler will produce 800 Liters of Steam per tick for about 5 or 6 Liters of Water per tick at reaching 100% Efficiency. In case of Lava it consumes 1666 Liters every Second.", + "A Thermal Boiler is worth about 33 small Thermal Generators, and as the Boilers get much less Efficient, when not having enough Fuel, you should consider making a large Nether Pump for Lava, or a good Nuclear Reactor for molten Salt.", + "Input and Output Slots are fully optional, you can place multiple ones of them or even none on the Machine. A Machine without Input couldn't process any Recipes, while a Machine without Output just voids all outputted Items and Liquids.", + "It might be useful to use the Screwdriver on the Output Hatches to determine what is outputted where." + }); + + // Test Novel + book_MultiPowerStation = writeBookTemplate( + "Manual_Multi_PowerStation", "Power Storage & You [Version 0.64]", "Alkalus", new String[] { + // Page 1 + "So, when it comes to power storage you really have three separate options:\n" + " \n" + + "Battery Buffers,\n" + + "Energy Buffers,\n" + + "The Power Sub-Station\n", + // Page 2 + "Battery Buffer\n" + " \n" + + "Is rather portable. Allowing you to throw set one up and insert batteries where ever you may need." + + "\n" + "They output 1A for each battery stored inside, up to a maximum of 16A.", + // Page 3 + "Energy Buffer\n" + " \n" + + "Is a more optimal choice for storage in your base. Once placed down, they cannot be moved without losing all stored power." + + "\n" + "Energy Buffers can output 4A from the output side, however accept 16A as input.", + // Page 4 + "The Power Sub-Station" + " \n" + + "Is used for storing Insane amounts of power later game." + + "\n" + "Consumes 2% of the average voltage of all energy type hatches every tick." + + "\n", + // Page 5 + "Allows Insertion/Removal of power from the rear face of the controller, swap with a screwdriver." + + "\n" + + "Variable Height Structure, between 4-16Y. Inserted Redox Cells dictate max energy tier of structure." + + "\n", + // Page 6 + "Redox Cells cannot be placed into the Top or Bottom layer and only take up 3xhx3 internally." + + "\n" + "Different Tier cells CANNOT be mixed together." + "\n", + // Page 7 + "All Hatches Must be HV at a Minimum, this minimum tier is in place to stop people abusing ULV/LV hatches to lower the avg/t." + + "\n" + + "Currently the GUI will NOT display anything at all until the structure forms, this is a known bug." + + "\n", + // Page 8 + "Valid Hatches:\n" + "Energy Hatch,\n" + + "Dynamo Hatch,\n" + + "Charging Bus,\n" + + "Discharging Bus,\n" + + "Dynamo Buffer,\n" + + "Multi-Amp Dynamo Hatch.\n\n\n" + + "Structure MUST contain at least one energy input and one energy output hatch." + }); + + // Test Novel + book_ModularBauble = + writeBookTemplate("Manual_Modular_Bauble", "How to: Modular Baubles", "Alkalus", new String[] { + "Concept: This idea came from wanting flexibility. \n" + + "First step, Build a Modularity table to begin customisation of your Bauble. \n" + + " After this has been constructed, you can now combine the upgrades listed within this book to improve the baubles level/100.", + "Defence:\n" + + "Can be upgraded by combining metal plates with the bauble. \n" + + " | +1 | Aluminium \n" + + " | +2 | Stainless Steel \n" + + " | +3 | Tungsten \n" + + " | +4 | Tungsten Steel \n" + + " | +5 | Naquadah \n", + "There was once a sad and lonely oak tree. \n", + "There was once a sad and lonely oak tree. \n", + "There was once a sad and lonely oak tree. \n" + }); + + // Test Novel + // 20/21/22 + book_MultiMachineManual = + writeBookTemplate("Manual_Multi_Machine", "Multi-Machine Manual", "Alkalus", new String[] { + "This Multiblock, depending upon the mode used, can function as a variety of different machines. The idea behind this, was that most of these machines are rather niche compared to any others, as such, not used often.", + "To build, you need to construct a hollow 3x3x3 structure made from Multi-Use casings, With a minimum of 6. Any Casing position can be substituted out with an Input Hatch/Bus, an Output Hatch/Bus, Muffler, Maint. Hatch or Energy Injector Hatch.", + "The Mode can be set by using a Screwdriver on the controller block. Each mode allows the use of Numbered Circuits, to allow a different machine 'type' for each input bus.", + "[Metal Work] Mode A - Allows the multiblock to function as a Compressor, a Lathe or an Electro-Magnet. To allow a hatch to run in Compressor mode, insert a No. 20 circuit. For Lathe, use No. 21 and for Electro-Magnet use No. 22.", + "[Fluid Work] Mode B - Allows the multiblock to function as a Fermenter, a Fluid Extractor or an Extractor. To allow a hatch to run in Fermenter mode, insert a No. 20 circuit. For Fluid Extractor, use No. 21 and for Extractor use No. 22.", + "[Misc. Work] Mode C - Allows the multiblock to function as a Laser Engraver, an Autoclave or a Fluid Solidifier. To allow a hatch to run in Laser Engraver mode, insert a No. 20 circuit. For Autoclave, use No. 21 and for Solidifier use No. 22.", + }); + + book_NuclearManual = + writeBookTemplate("Manual_NuclearStuff_1", "Nuclear Chemistry [FFPP]", "Alkalus", new String[] { + // Page 1 + "Fission Fuel Processing Plant\n" + + "Size: 3x9x3 [LxHxW]\n" + + "Controller: Center, Bottom\n" + + "4x Input Hatch\n" + + "2x Output Hatch\n" + + "1x Output Bus\n" + + "1x ZPM+ Muffler\n" + + "1x Maintenance Hatch\n" + + "1x Energy Hatch\n", + // Page 2 + "[1] 7x Hastelloy-X or I/O\n" + + "[2] 5x Incoloy-DS Fluid Containment\n" + + "[3] 4x Zeron-100 Shielding\n" + + "[4] 17x Hastelloy-N Sealant Case" + + "\n" + + "Multiblock Construction\n" + + "Convention is [LxHxW]\n" + + "\n", + // Page 3 + "Layer 1/2:\n" + + "[1][1][1]\n" + + "[1][1][1]\n" + + "[1][1][1]\n" + + "\n" + + "Layer 3/5/6\n" + + "[ ][4][ ]\n" + + "[4][2][4]\n" + + "[ ][4][ ]\n" + + "\n", + // Page 4 + "Layer 4\n" + + "[ ][3][ ]\n" + + "[3][2][3]\n" + + "[ ][3][ ]\n" + + "\n" + + "Layer 7/8/9\n" + + "[ ][ ][ ]\n" + + "[ ][3][ ]\n" + + "[ ][ ][ ]\n", + // Page 5 + "Fission Fuel\n" + "Processing Plant" + + "----------------------\n" + + "This structure is used to produce the Molten Salts required to run a Liquid Fluorine Thorium Reactor [LFTR]." + }); + + book_MultiChemicalPlant = + writeBookTemplate("book_Multi_ChemicalPlant", "Chemical Plant Manual", "Alkalus", new String[] { + + // Intro + "This book will explain how the Chemical Plant is constructed, which blocks are valid to upgrade it and also how the upgrades work.", + + // Info + "Solid Casings = Plant tier" + "\n" + "Machine Casings = Hatch tier" + + "\n" + "Higher tier coils More Speed" + + "\n" + "T1 50% , T2 100% , T3 150%, etc" + + "\n", + "Higher tier pipe casings boost parallel" + "\n" + "and reduce catalyst consumption." + + "\n" + "+2 parallel per tier, 20% extra chance of" + + "\n" + "not damaging catalyst per tier.", + "Awakened Draconium Coil (or above) with" + "\n" + "Tungstensteel Pipe Casing" + "\n" + + "does not damage catalyst at all.", + + // Machine Casings + "Valid Solid Machine Casings:" + "\n" + "0 - Strong Bronze" + + "\n" + "1 - Solid Steel" + + "\n" + "2 - Sturdy Aluminium" + + "\n" + "3 - Clean Stainless Steel" + + "\n" + "4 - Stable Titanium" + + "\n" + "5 - Robust Tungstensteel" + + "\n" + "6 - Vigorous Laurenium" + + "\n" + "7 - Rugged Botmium", + + // Machine Casings + "Valid Tiered Machine Casings:" + "\n" + "\n" + "1 - " + + GT_Values.VN[0] + "\n" + "2 - " + + GT_Values.VN[1] + "\n" + "3 - " + + GT_Values.VN[2] + "\n" + "4 - " + + GT_Values.VN[3] + "\n" + "5 - " + + GT_Values.VN[4] + "\n" + "6 - " + + GT_Values.VN[5] + "\n" + "7 - " + + GT_Values.VN[6] + "\n" + "8 - " + + GT_Values.VN[7] + "\n" + "9 - " + + GT_Values.VN[8] + "\n" + "10 - " + + GT_Values.VN[9], + + // Pipe Casings + "Valid Pipe Casings:" + "\n" + "\n" + "1 - Bronze" + + "\n" + "2 - Steel" + + "\n" + "3 - Titanium" + + "\n" + "4 - Tungstensteel", + + // Coils + "Valid Coils:" + "\n" + "\n" + "1 - Cupronickel" + + "\n" + "2 - Kanthal" + + "\n" + "3 - Nichrome" + + "\n" + "4 - Tungstensteel" + + "\n" + "5 - HSS-G" + + "\n" + "6 - HSS-S" + + "\n" + "7 - Naquadah" + + "\n" + "8 - Naquadah Alloy" + + "\n" + "9 - Trinium" + + "\n" + "10 - Fluxed Electrum", + "11 - Awakened Draconium" + "\n" + "12 - Infinity" + "\n" + "13 - Hypogen" + "\n" + "14 - Eternal", + + // Requirements + "Multiblock Requirements:" + "\n" + "\n" + "27x Coils" + + "\n" + "18x Pipe Casings" + + "\n" + "57x Tiered Machine Casings" + + "\n" + "70+ Solid Casings" + + "\n" + "1x Catalyst Housing (Catalysts cannot go inside an Input Bus)", + + // Construction Guide + "Construction Guide Pt1:" + "\n" + "\n" + + "Controller is placed on a middle casing in the bottom layer" + + "\n" + "Hatches can only be placed on the bottom layer edges", + "Construction Guide Pt2:" + "\n" + "\n" + "7x7x7 Hollow frame of solid casings" + + "\n" + "5x1x5 layer of solid casings (fills in top layer)" + + "\n" + "5x1x5 layer of machine casings (fills in bottom layer)", + "Construction Guide Pt3:" + "\n" + "In the central 3x5x3:" + + "\n" + "3x1x3 layer of Coils, surrounded by ring of Machine Casings" + + "\n" + "3x1x3 layer of Pipe Casings" + + "\n" + "3x1x3 layer of Coils" + + "\n" + "3x1x3 layer of Pipe Casings" + + "\n" + "3x1x3 layer of Coils, surrounded by ring of Machine Casings", + + // Construction Guide Info + "Information:" + "\n" + "\n" + "A = Air" + + "\n" + "X = Solid Casing" + + "\n" + "M = Machine Casing" + + "\n" + "P = Pipe Casing" + + "\n" + "C = Coil Casing", + "Layer 1:" + "\n" + "\n" + "XXXXXXX" + + "\n" + "XMMMMMX" + + "\n" + "XMMMMMX" + + "\n" + "XMMMMMX" + + "\n" + "XMMMMMX" + + "\n" + "XMMMMMX" + + "\n" + "XXXXXXX", + "Layer 2:" + "\n" + "\n" + "XAAAAAX" + + "\n" + "AMMMMMA" + + "\n" + "AMCCCMA" + + "\n" + "AMCCCMA" + + "\n" + "AMCCCMA" + + "\n" + "AMMMMMA" + + "\n" + "XAAAAAX", + "Layer 3:" + "\n" + "\n" + "XAAAAAX" + + "\n" + "AAAAAAA" + + "\n" + "AAPPPAA" + + "\n" + "AAPPPAA" + + "\n" + "AAPPPAA" + + "\n" + "AAAAAAA" + + "\n" + "XAAAAAX", + "Layer 4:" + "\n" + "\n" + "XAAAAAX" + + "\n" + "AAAAAAA" + + "\n" + "AACCCAA" + + "\n" + "AACCCAA" + + "\n" + "AACCCAA" + + "\n" + "AAAAAAA" + + "\n" + "XAAAAAX", + "Layer 5:" + "\n" + "\n" + "XAAAAAX" + + "\n" + "AAAAAAA" + + "\n" + "AAPPPAA" + + "\n" + "AAPPPAA" + + "\n" + "AAPPPAA" + + "\n" + "AAAAAAA" + + "\n" + "XAAAAAX", + "Layer 6:" + "\n" + "\n" + "XAAAAAX" + + "\n" + "AMMMMMA" + + "\n" + "AMCCCMA" + + "\n" + "AMCCCMA" + + "\n" + "AMCCCMA" + + "\n" + "AMMMMMA" + + "\n" + "XAAAAAX", + "Layer 7:" + "\n" + "\n" + "XXXXXXX" + + "\n" + "XXXXXXX" + + "\n" + "XXXXXXX" + + "\n" + "XXXXXXX" + + "\n" + "XXXXXXX" + + "\n" + "XXXXXXX" + + "\n" + "XXXXXXX", + }); + } + + public static ItemStack ItemBookWritten_ThermalBoiler; + public static ItemStack ItemBookWritten_NuclearManual; + public static ItemStack ItemBookWritten_ModularBaubles; + public static ItemStack ItemBookWritten_MultiPowerStorage; + public static ItemStack ItemBookWritten_MultiMachineManual; + public static ItemStack ItemBookWritten_MultiChemicalPlant; + + public static void runLater() { + ItemBookWritten_ThermalBoiler = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, 0, 1); + ItemBookWritten_MultiPowerStorage = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, 1, 1); + ItemBookWritten_ModularBaubles = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, 2, 1); + ItemBookWritten_MultiMachineManual = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, 3, 1); + ItemBookWritten_NuclearManual = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, 4, 1); + ItemBookWritten_MultiChemicalPlant = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, 5, 1); + + // Multiblock Manuals + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[] { + ItemUtils.getSimpleStack(Items.writable_book), ItemUtils.getSimpleStack(Items.lava_bucket) + }, + ItemBookWritten_ThermalBoiler); + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[] { + ItemUtils.getSimpleStack(Items.writable_book), + ItemUtils.getItemStackOfAmountFromOreDict(CI.craftingToolWrench, 1) + }, + ItemBookWritten_MultiMachineManual); + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[] { + ItemUtils.getSimpleStack(Items.writable_book), + ItemUtils.getItemStackOfAmountFromOreDict("wireGt01Tin", 1) + }, + ItemBookWritten_MultiPowerStorage); + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[] { + ItemUtils.getSimpleStack(Items.writable_book), + ItemUtils.getItemStackOfAmountFromOreDict("dustUranium", 1) + }, + ItemBookWritten_NuclearManual); + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[] { + ItemUtils.getSimpleStack(Items.writable_book), + ItemUtils.getItemStackOfAmountFromOreDict("wireGt01Copper", 1) + }, + ItemBookWritten_MultiChemicalPlant); + + for (int i = 0; i < mBookKeeperCount; i++) { + ItemStack bookstack = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, i, 1); + GT_OreDictUnificator.registerOre("bookWritten", bookstack); + GT_OreDictUnificator.registerOre("craftingBook", bookstack); + } + } - private static BookTemplate writeBookTemplate(String aMapping, String aTitle, String aAuthor, String[] aPages){ - mBookKeeperCount++; + private static BookTemplate writeBookTemplate(String aMapping, String aTitle, String aAuthor, String[] aPages) { + mBookKeeperCount++; for (int i = 0; i < aPages.length; i++) { aPages[i] = aPages[i].replaceAll("\n", "
"); } addBookTitleLocalization(aTitle); addBookPagesLocalization(aTitle, aPages); BookTemplate mTemp = new BookTemplate(mBookKeeperCount, aMapping, aTitle, aAuthor, aPages); - mBookMap.put(mBookKeeperCount-1, mTemp); - return mTemp; - } - - public static class BookTemplate { - public final int mMeta; - public final String mMapping; - public final String mTitle; - public final String mAuthor; - public final String[] mPages; - - BookTemplate(int aMeta, String aMapping, String aTitle, String aAuthor, String[] aPages){ - this.mMeta = aMeta; - this.mMapping = aMapping; - this.mTitle = aTitle; - this.mAuthor = aAuthor; - this.mPages = aPages; - } - } + mBookMap.put(mBookKeeperCount - 1, mTemp); + return mTemp; + } + + public static class BookTemplate { + public final int mMeta; + public final String mMapping; + public final String mTitle; + public final String mAuthor; + public final String[] mPages; + + BookTemplate(int aMeta, String aMapping, String aTitle, String aAuthor, String[] aPages) { + this.mMeta = aMeta; + this.mMapping = aMapping; + this.mTitle = aTitle; + this.mAuthor = aAuthor; + this.mPages = aPages; + } + } } - - diff --git a/src/main/java/gtPlusPlus/core/handler/BurnableFuelHandler.java b/src/main/java/gtPlusPlus/core/handler/BurnableFuelHandler.java index 82bcdc84e6..b0006b5f9c 100644 --- a/src/main/java/gtPlusPlus/core/handler/BurnableFuelHandler.java +++ b/src/main/java/gtPlusPlus/core/handler/BurnableFuelHandler.java @@ -1,35 +1,32 @@ package gtPlusPlus.core.handler; import cpw.mods.fml.common.IFuelHandler; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; -public class BurnableFuelHandler implements IFuelHandler{ +public class BurnableFuelHandler implements IFuelHandler { - @Override - public int getBurnTime(ItemStack aStack) { - //Iterate over my burnables. - for (Pair temp : CORE.burnables) { - int aStackID = Item.getIdFromItem(aStack.getItem()); - int burnID = Item.getIdFromItem(temp.getValue().getItem()); - if (aStackID == burnID){ - int burn = temp.getKey(); - ItemStack fuel = temp.getValue(); - ItemStack testItem = ItemUtils.getSimpleStack(fuel, aStack.stackSize); + @Override + public int getBurnTime(ItemStack aStack) { + // Iterate over my burnables. + for (Pair temp : CORE.burnables) { + int aStackID = Item.getIdFromItem(aStack.getItem()); + int burnID = Item.getIdFromItem(temp.getValue().getItem()); + if (aStackID == burnID) { + int burn = temp.getKey(); + ItemStack fuel = temp.getValue(); + ItemStack testItem = ItemUtils.getSimpleStack(fuel, aStack.stackSize); - if (aStack.isItemEqual(testItem)){ - return burn; - } - } - } - - //If it's not my fuel, return 0. - return 0; - } + if (aStack.isItemEqual(testItem)) { + return burn; + } + } + } + // If it's not my fuel, return 0. + return 0; + } } diff --git a/src/main/java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/main/java/gtPlusPlus/core/handler/COMPAT_HANDLER.java index 79446db6e6..93f6df7595 100644 --- a/src/main/java/gtPlusPlus/core/handler/COMPAT_HANDLER.java +++ b/src/main/java/gtPlusPlus/core/handler/COMPAT_HANDLER.java @@ -2,10 +2,6 @@ package gtPlusPlus.core.handler; import static gtPlusPlus.core.lib.LoadedMods.Gregtech; -import java.util.LinkedList; -import java.util.Queue; -import java.util.Set; - import cpw.mods.fml.common.event.FMLLoadCompleteEvent; import gregtech.api.enums.GT_Values; import gregtech.api.util.GT_OreDictUnificator; @@ -47,281 +43,275 @@ import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoader_GTNH; import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoader_GlueLine; import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoader_Nuclear; import gtPlusPlus.xmod.gregtech.registration.gregtech.*; +import java.util.LinkedList; +import java.util.Queue; +import java.util.Set; import net.minecraft.item.ItemStack; public class COMPAT_HANDLER { - public static Queue RemoveRecipeQueue = new LinkedList<>(); - public static Queue AddRecipeQueue = new LinkedList<>(); - public static Boolean areInitItemsLoaded = false; - - - public static void registerMyModsOreDictEntries(){ + public static Queue RemoveRecipeQueue = new LinkedList<>(); + public static Queue AddRecipeQueue = new LinkedList<>(); + public static Boolean areInitItemsLoaded = false; - Logger.INFO("Registering Materials with OreDict."); - //In-house + public static void registerMyModsOreDictEntries() { - //tools - GT_OreDictUnificator.registerOre("craftingToolSandHammer", new ItemStack(ModItems.itemSandstoneHammer)); + Logger.INFO("Registering Materials with OreDict."); + // In-house - for(int i=1; i<=10; i++){ - GT_OreDictUnificator.registerOre("bufferCore_"+GT_Values.VN[i-1], new ItemStack(ItemUtils.getItemFromFQRN("miscutils:item.itemBufferCore"+i))); - } - } + // tools + GT_OreDictUnificator.registerOre("craftingToolSandHammer", new ItemStack(ModItems.itemSandstoneHammer)); - public static void registerGregtechMachines() { - if (Gregtech) { + for (int i = 1; i <= 10; i++) { + GT_OreDictUnificator.registerOre( + "bufferCore_" + GT_Values.VN[i - 1], + new ItemStack(ItemUtils.getItemFromFQRN("miscutils:item.itemBufferCore" + i))); + } + } - //Debug - GregtechItemList.Garbage_Collector_Debug_Machine.set( - new GregtechMetaGarbageCollector( - "garbagecollector.01.tier.single", - "JVM Garbage Collector", - "Useful for debugging or smoother performance on local servers").getStackForm(1L)); - - - //Free IDs - /* - --- - 859 - to - 868 - --- - 911 - to - 940 - */ + public static void registerGregtechMachines() { + if (Gregtech) { - new RECIPES_LaserEngraver(); - new RECIPES_Extruder(); - GregtechGeneratorsULV.run(); - GregtechEnergyBuffer.run(); - GregtechLFTR.run(); - GregtechSteamCondenser.run(); - GregtechSafeBlock.run(); - //GregtechSuperConductionPoint.run(); - GregtechIronBlastFurnace.run(); - GregtechIndustrialCentrifuge.run(); - GregtechIndustrialCokeOven.run(); - GregtechIndustrialPlatePress.run(); - GregtechRocketFuelGenerator.run(); - GregtechIndustrialElectrolyzer.run(); - GregtechIndustrialMacerator.run(); - GregtechIndustrialWiremill.run(); - GregtechIndustrialMassFabricator.run(); - GregtechIndustrialBlastSmelter.run(); - GregtechSolarGenerators.run(); - GregtechPowerSubStation.run(); - GregtechDehydrator.run(); - GregtechAdvancedBoilers.run(); - GregtechPollutionDevices.run(); - GregtechTieredFluidTanks.run(); - //GregtechIndustrialMultiTank.run(); - GregtechGeothermalThermalGenerator.run(); - Gregtech4Content.run(); - GregtechIndustrialFuelRefinery.run(); - GregtechTreeFarmerTE.run(); - GregtechIndustrialTreeFarm.run(); - GregtechIndustrialSifter.run(); - GregtechSimpleWasher.run(); - GregtechRTG.run(); - GregtechCyclotron.run(); - GregtechHiAmpTransformer.run(); - GregtechIndustrialThermalCentrifuge.run(); - GregtechIndustrialWashPlant.run(); - GregtechSemiFluidgenerators.run(); - GregtechAdvancedMixer.run(); - GregtechWirelessChargers.run(); - GregtechIndustrialGeneratorArray.run(); - GregtechIndustrialCuttingFactory.run(); - //GregtechMiniRaFusion.run(); - GregtechComponentAssembler.run(); - GregtechTeslaTower.run(); - GregtechSuperChests.run(); - GregtechIndustrialFishPond.run(); - GregtechTieredChunkloaders.run(); - GregtechIndustrialExtruder.run(); - GregtechIndustrialMultiMachine.run(); - //GregtechBedrockPlatforms.run(); - GregtechBufferDynamos.run(); - GregtechAmazonWarehouse.run(); - GregtechFactoryGradeReplacementMultis.run(); - GregtechThaumcraftDevices.run(); - GregtechThreadedBuffers.run(); - GregtechIndustrialMixer.run(); - GregtechCustomHatches.run(); - //GregtechNaqReactor.run(); - GregtechIndustrialArcFurnace.run(); - GregtechSolarTower.run(); - GregtechLargeTurbinesAndHeatExchanger.run(); - GregtechPowerBreakers.run(); - GregtechFluidReactor.run(); - GregtechAlgaeContent.run(); - GregtechIndustrialAlloySmelter.run(); - GregtechIsaMill.run(); - GregtechSteamMultis.run(); - GregtechIndustrialForgeHammer.run(); - GregtechMolecularTransformer.run(); - GregtechIndustrialElementDuplicator.run(); - GregtechIndustrialRockBreaker.run(); - GregtechIndustrialChisel.run(); - GregtechIndustrialFluidHeater.run(); + // Debug + GregtechItemList.Garbage_Collector_Debug_Machine.set(new GregtechMetaGarbageCollector( + "garbagecollector.01.tier.single", + "JVM Garbage Collector", + "Useful for debugging or smoother performance on local servers") + .getStackForm(1L)); - //New Horizons Content - NewHorizonsAccelerator.run(); - } + // Free IDs + /* + --- + 859 + to + 868 + --- + 911 + to + 940 + */ - } + new RECIPES_LaserEngraver(); + new RECIPES_Extruder(); + GregtechGeneratorsULV.run(); + GregtechEnergyBuffer.run(); + GregtechLFTR.run(); + GregtechSteamCondenser.run(); + GregtechSafeBlock.run(); + // GregtechSuperConductionPoint.run(); + GregtechIronBlastFurnace.run(); + GregtechIndustrialCentrifuge.run(); + GregtechIndustrialCokeOven.run(); + GregtechIndustrialPlatePress.run(); + GregtechRocketFuelGenerator.run(); + GregtechIndustrialElectrolyzer.run(); + GregtechIndustrialMacerator.run(); + GregtechIndustrialWiremill.run(); + GregtechIndustrialMassFabricator.run(); + GregtechIndustrialBlastSmelter.run(); + GregtechSolarGenerators.run(); + GregtechPowerSubStation.run(); + GregtechDehydrator.run(); + GregtechAdvancedBoilers.run(); + GregtechPollutionDevices.run(); + GregtechTieredFluidTanks.run(); + // GregtechIndustrialMultiTank.run(); + GregtechGeothermalThermalGenerator.run(); + Gregtech4Content.run(); + GregtechIndustrialFuelRefinery.run(); + GregtechTreeFarmerTE.run(); + GregtechIndustrialTreeFarm.run(); + GregtechIndustrialSifter.run(); + GregtechSimpleWasher.run(); + GregtechRTG.run(); + GregtechCyclotron.run(); + GregtechHiAmpTransformer.run(); + GregtechIndustrialThermalCentrifuge.run(); + GregtechIndustrialWashPlant.run(); + GregtechSemiFluidgenerators.run(); + GregtechAdvancedMixer.run(); + GregtechWirelessChargers.run(); + GregtechIndustrialGeneratorArray.run(); + GregtechIndustrialCuttingFactory.run(); + // GregtechMiniRaFusion.run(); + GregtechComponentAssembler.run(); + GregtechTeslaTower.run(); + GregtechSuperChests.run(); + GregtechIndustrialFishPond.run(); + GregtechTieredChunkloaders.run(); + GregtechIndustrialExtruder.run(); + GregtechIndustrialMultiMachine.run(); + // GregtechBedrockPlatforms.run(); + GregtechBufferDynamos.run(); + GregtechAmazonWarehouse.run(); + GregtechFactoryGradeReplacementMultis.run(); + GregtechThaumcraftDevices.run(); + GregtechThreadedBuffers.run(); + GregtechIndustrialMixer.run(); + GregtechCustomHatches.run(); + // GregtechNaqReactor.run(); + GregtechIndustrialArcFurnace.run(); + GregtechSolarTower.run(); + GregtechLargeTurbinesAndHeatExchanger.run(); + GregtechPowerBreakers.run(); + GregtechFluidReactor.run(); + GregtechAlgaeContent.run(); + GregtechIndustrialAlloySmelter.run(); + GregtechIsaMill.run(); + GregtechSteamMultis.run(); + GregtechIndustrialForgeHammer.run(); + GregtechMolecularTransformer.run(); + GregtechIndustrialElementDuplicator.run(); + GregtechIndustrialRockBreaker.run(); + GregtechIndustrialChisel.run(); + GregtechIndustrialFluidHeater.run(); - //InterMod - public static void intermodOreDictionarySupport(){ + // New Horizons Content + NewHorizonsAccelerator.run(); + } + } - if (LoadedMods.Big_Reactors){ - COMPAT_BigReactors.OreDict(); - } - if (LoadedMods.EnderIO){ - COMPAT_EnderIO.OreDict(); - } - if (LoadedMods.MorePlanets){ - COMPAT_MorePlanets.OreDict(); - } - if (LoadedMods.OpenBlocks){ - COMPAT_OpenBlocks.OreDict(); - } - if (LoadedMods.Railcraft){ - COMPAT_Railcraft.OreDict(); - } - if (LoadedMods.Simply_Jetpacks){ - COMPAT_SimplyJetpacks.OreDict(); - } - if (LoadedMods.RFTools){ - COMPAT_RFTools.OreDict(); - } - if (LoadedMods.Thaumcraft){ - COMPAT_Thaumcraft.OreDict(); - } - if (LoadedMods.Extra_Utils){ - COMPAT_ExtraUtils.OreDict(); - } - if (LoadedMods.PneumaticCraft){ - COMPAT_PneumaticCraft.OreDict(); - } - if (LoadedMods.CompactWindmills){ - COMPAT_CompactWindmills.OreDict(); - } - if (LoadedMods.IndustrialCraft2){ - COMPAT_IC2.OreDict(); - } - if (LoadedMods.PamsHarvestcraft){ - COMPAT_HarvestCraft.OreDict(); - } - if (LoadedMods.Witchery) { - COMPAT_Witchery.OreDict(); - } - } + // InterMod + public static void intermodOreDictionarySupport() { - public static void RemoveRecipesFromOtherMods(){ - //Removal of Recipes - for(final Object item : RemoveRecipeQueue){ - RecipeUtils.removeCraftingRecipe(item); - } - } + if (LoadedMods.Big_Reactors) { + COMPAT_BigReactors.OreDict(); + } + if (LoadedMods.EnderIO) { + COMPAT_EnderIO.OreDict(); + } + if (LoadedMods.MorePlanets) { + COMPAT_MorePlanets.OreDict(); + } + if (LoadedMods.OpenBlocks) { + COMPAT_OpenBlocks.OreDict(); + } + if (LoadedMods.Railcraft) { + COMPAT_Railcraft.OreDict(); + } + if (LoadedMods.Simply_Jetpacks) { + COMPAT_SimplyJetpacks.OreDict(); + } + if (LoadedMods.RFTools) { + COMPAT_RFTools.OreDict(); + } + if (LoadedMods.Thaumcraft) { + COMPAT_Thaumcraft.OreDict(); + } + if (LoadedMods.Extra_Utils) { + COMPAT_ExtraUtils.OreDict(); + } + if (LoadedMods.PneumaticCraft) { + COMPAT_PneumaticCraft.OreDict(); + } + if (LoadedMods.CompactWindmills) { + COMPAT_CompactWindmills.OreDict(); + } + if (LoadedMods.IndustrialCraft2) { + COMPAT_IC2.OreDict(); + } + if (LoadedMods.PamsHarvestcraft) { + COMPAT_HarvestCraft.OreDict(); + } + if (LoadedMods.Witchery) { + COMPAT_Witchery.OreDict(); + } + } - public static void InitialiseHandlerThenAddRecipes(){ - RegistrationHandler.run(); - } - public static void InitialiseLateHandlerThenAddRecipes(){ - LateRegistrationHandler.run(); - } + public static void RemoveRecipesFromOtherMods() { + // Removal of Recipes + for (final Object item : RemoveRecipeQueue) { + RecipeUtils.removeCraftingRecipe(item); + } + } - public static void startLoadingGregAPIBasedRecipes(){ - //Add hand-made recipes - RECIPES_GREGTECH.run(); - RecipeLoader_GTNH.generate(); - RecipeLoader_Nuclear.generate(); - RecipeLoader_GlueLine.generate(); - //Add autogenerated Recipes from Item Components - for (Set> m : MaterialGenerator.mRecipeMapsToGenerate) { - for (RunnableWithInfo r : m) { - try { - r.run(); - Logger.INFO("[FIND] "+r.getInfoData().getLocalizedName()+" recipes generated."); - } - catch (Throwable t) { - t.printStackTrace(); - Logger.INFO("[ERROR] "+r.getInfoData().getLocalizedName()+" recipes failed to generated."); - } - } - } - RecipeGen_Recycling.executeGenerators(); - runQueuedMisc(); - - // Do Fluid Canning Last, because they're not executed on demand, but rather queued. - RecipeGen_FluidCanning.init(); - } - + public static void InitialiseHandlerThenAddRecipes() { + RegistrationHandler.run(); + } + public static void InitialiseLateHandlerThenAddRecipes() { + LateRegistrationHandler.run(); + } - public static void onLoadComplete(FMLLoadCompleteEvent event) { - runQueuedOnLoadComplete(event); - } + public static void startLoadingGregAPIBasedRecipes() { + // Add hand-made recipes + RECIPES_GREGTECH.run(); + RecipeLoader_GTNH.generate(); + RecipeLoader_Nuclear.generate(); + RecipeLoader_GlueLine.generate(); + // Add autogenerated Recipes from Item Components + for (Set> m : MaterialGenerator.mRecipeMapsToGenerate) { + for (RunnableWithInfo r : m) { + try { + r.run(); + Logger.INFO("[FIND] " + r.getInfoData().getLocalizedName() + " recipes generated."); + } catch (Throwable t) { + t.printStackTrace(); + Logger.INFO("[ERROR] " + r.getInfoData().getLocalizedName() + " recipes failed to generated."); + } + } + } + RecipeGen_Recycling.executeGenerators(); + runQueuedMisc(); - public static final AutoMap> mRecipesToGenerate = new AutoMap>(); - public static final AutoMap> mGtRecipesToGenerate = new AutoMap>(); + // Do Fluid Canning Last, because they're not executed on demand, but rather queued. + RecipeGen_FluidCanning.init(); + } - public static final AutoMap> mObjectsToRunInPostInit = new AutoMap>(); - public static final AutoMap mObjectsToRunInOnLoadComplete = new AutoMap(); + public static void onLoadComplete(FMLLoadCompleteEvent event) { + runQueuedOnLoadComplete(event); + } - public static void runQueuedRecipes() { - //Add autogenerated Recipes from Item Components - for (RunnableWithInfo m : mRecipesToGenerate) { - try { - m.run(); - } - catch (Throwable t) { - t.printStackTrace(); - Logger.INFO("[ERROR] "+m.getInfoData()+" recipe failed to generated."); - } + public static final AutoMap> mRecipesToGenerate = new AutoMap>(); + public static final AutoMap> mGtRecipesToGenerate = + new AutoMap>(); - } - for (RunnableWithInfo m : mGtRecipesToGenerate) { - try { - m.run(); - } - catch (Throwable t) { - t.printStackTrace(); - Logger.INFO("[ERROR] "+m.getInfoData()+" recipe failed to generated."); - } + public static final AutoMap> mObjectsToRunInPostInit = + new AutoMap>(); + public static final AutoMap mObjectsToRunInOnLoadComplete = new AutoMap(); - } - } - - public static void runQueuedMisc() { - for (RunnableWithInfo m : mObjectsToRunInPostInit) { - try { - m.run(); - } - catch (Throwable t) { - t.printStackTrace(); - Logger.INFO("[ERROR] "+m.getInfoData()); - } + public static void runQueuedRecipes() { + // Add autogenerated Recipes from Item Components + for (RunnableWithInfo m : mRecipesToGenerate) { + try { + m.run(); + } catch (Throwable t) { + t.printStackTrace(); + Logger.INFO("[ERROR] " + m.getInfoData() + " recipe failed to generated."); + } + } + for (RunnableWithInfo m : mGtRecipesToGenerate) { + try { + m.run(); + } catch (Throwable t) { + t.printStackTrace(); + Logger.INFO("[ERROR] " + m.getInfoData() + " recipe failed to generated."); + } + } + } - } - } - - /** - * Generally used to register GT recipe map changes after they've been populated. - */ - public static void runQueuedOnLoadComplete(FMLLoadCompleteEvent event) { - for (ItemPackage m : mObjectsToRunInOnLoadComplete) { - try { - m.onLoadComplete(event); - } - catch (Throwable t) { - t.printStackTrace(); - Logger.INFO("[ERROR] "+m.getInfoData()); - } + public static void runQueuedMisc() { + for (RunnableWithInfo m : mObjectsToRunInPostInit) { + try { + m.run(); + } catch (Throwable t) { + t.printStackTrace(); + Logger.INFO("[ERROR] " + m.getInfoData()); + } + } + } - } - } + /** + * Generally used to register GT recipe map changes after they've been populated. + */ + public static void runQueuedOnLoadComplete(FMLLoadCompleteEvent event) { + for (ItemPackage m : mObjectsToRunInOnLoadComplete) { + try { + m.onLoadComplete(event); + } catch (Throwable t) { + t.printStackTrace(); + Logger.INFO("[ERROR] " + m.getInfoData()); + } + } + } } diff --git a/src/main/java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java b/src/main/java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java index 166c0f228b..58762cca9d 100644 --- a/src/main/java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java +++ b/src/main/java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java @@ -24,70 +24,68 @@ import gtPlusPlus.xmod.tinkers.HANDLER_Tinkers; public class COMPAT_IntermodStaging { - public static void preInit(FMLPreInitializationEvent preinit){ - HANDLER_GT.preInit(); - HANDLER_GC.preInit(); - HANDLER_TF.preInit(); - HANDLER_FR.preInit(); - HANDLER_IC2.preInit(); - HANDLER_Computronics.preInit(); - HANDLER_BiomesOPlenty.preInit(); - //HANDLER_Mekanism.preInit(); - HANDLER_Thaumcraft.preInit(); - HANDLER_Tinkers.preInit(); - HANDLER_SC2.preInit(); - HANDLER_GalactiCraft.preInit(); - HANDLER_CropsPlusPlus.preInit(preinit); - HANDLER_Railcraft.preInit(); - HANDLER_Reliquary.preInit(); - HANDLER_OpenBlocks.preInit(); - HANDLER_SpiceOfLife.preInit(); - } + public static void preInit(FMLPreInitializationEvent preinit) { + HANDLER_GT.preInit(); + HANDLER_GC.preInit(); + HANDLER_TF.preInit(); + HANDLER_FR.preInit(); + HANDLER_IC2.preInit(); + HANDLER_Computronics.preInit(); + HANDLER_BiomesOPlenty.preInit(); + // HANDLER_Mekanism.preInit(); + HANDLER_Thaumcraft.preInit(); + HANDLER_Tinkers.preInit(); + HANDLER_SC2.preInit(); + HANDLER_GalactiCraft.preInit(); + HANDLER_CropsPlusPlus.preInit(preinit); + HANDLER_Railcraft.preInit(); + HANDLER_Reliquary.preInit(); + HANDLER_OpenBlocks.preInit(); + HANDLER_SpiceOfLife.preInit(); + } - public static void init(FMLInitializationEvent init){ - HANDLER_GT.init(); - HANDLER_GC.init(); - HANDLER_TF.init(); - HANDLER_FR.Init(); - HANDLER_IC2.init(); - HANDLER_Computronics.init(); - HANDLER_BiomesOPlenty.init(); - //HANDLER_Mekanism.init(); - HANDLER_Thaumcraft.init(); - HANDLER_Tinkers.init(); - HANDLER_SC2.init(); - HANDLER_GalactiCraft.init(); - HANDLER_CropsPlusPlus.init(init); - HANDLER_Railcraft.init(); - HANDLER_Reliquary.init(); - HANDLER_OpenBlocks.init(); - HANDLER_SpiceOfLife.init(); - } - - public static void postInit(FMLPostInitializationEvent postinit){ - HANDLER_GT.postInit(); - HANDLER_GC.postInit(); - HANDLER_TF.postInit(); - HANDLER_FR.postInit(); - HANDLER_IC2.postInit(); - HANDLER_Computronics.postInit(); - HANDLER_BiomesOPlenty.postInit(); - //HANDLER_Mekanism.postInit(); - HANDLER_Thaumcraft.postInit(); - HANDLER_Tinkers.postInit(); - HANDLER_SC2.postInit(); - HANDLER_GalactiCraft.postInit(); - HANDLER_CropsPlusPlus.postInit(postinit); - HANDLER_Railcraft.postInit(); - HANDLER_Reliquary.postInit(); - HANDLER_OpenBlocks.postInit(); - HANDLER_SpiceOfLife.postInit(); - HANDLER_AdvSolar.postInit(); - } - - public static void onLoadComplete(FMLLoadCompleteEvent event) { - HANDLER_GT.onLoadComplete(event); - } + public static void init(FMLInitializationEvent init) { + HANDLER_GT.init(); + HANDLER_GC.init(); + HANDLER_TF.init(); + HANDLER_FR.Init(); + HANDLER_IC2.init(); + HANDLER_Computronics.init(); + HANDLER_BiomesOPlenty.init(); + // HANDLER_Mekanism.init(); + HANDLER_Thaumcraft.init(); + HANDLER_Tinkers.init(); + HANDLER_SC2.init(); + HANDLER_GalactiCraft.init(); + HANDLER_CropsPlusPlus.init(init); + HANDLER_Railcraft.init(); + HANDLER_Reliquary.init(); + HANDLER_OpenBlocks.init(); + HANDLER_SpiceOfLife.init(); + } + public static void postInit(FMLPostInitializationEvent postinit) { + HANDLER_GT.postInit(); + HANDLER_GC.postInit(); + HANDLER_TF.postInit(); + HANDLER_FR.postInit(); + HANDLER_IC2.postInit(); + HANDLER_Computronics.postInit(); + HANDLER_BiomesOPlenty.postInit(); + // HANDLER_Mekanism.postInit(); + HANDLER_Thaumcraft.postInit(); + HANDLER_Tinkers.postInit(); + HANDLER_SC2.postInit(); + HANDLER_GalactiCraft.postInit(); + HANDLER_CropsPlusPlus.postInit(postinit); + HANDLER_Railcraft.postInit(); + HANDLER_Reliquary.postInit(); + HANDLER_OpenBlocks.postInit(); + HANDLER_SpiceOfLife.postInit(); + HANDLER_AdvSolar.postInit(); + } + public static void onLoadComplete(FMLLoadCompleteEvent event) { + HANDLER_GT.onLoadComplete(event); + } } diff --git a/src/main/java/gtPlusPlus/core/handler/CraftingManager.java b/src/main/java/gtPlusPlus/core/handler/CraftingManager.java index 6fb580cc32..7c7069b631 100644 --- a/src/main/java/gtPlusPlus/core/handler/CraftingManager.java +++ b/src/main/java/gtPlusPlus/core/handler/CraftingManager.java @@ -2,16 +2,12 @@ package gtPlusPlus.core.handler; public class CraftingManager { - public static void mainRegistry() { - addCraftingRecipies(); - addSmeltingRecipies(); - } + public static void mainRegistry() { + addCraftingRecipies(); + addSmeltingRecipies(); + } - public static void addCraftingRecipies() { + public static void addCraftingRecipies() {} - } - - public static void addSmeltingRecipies() { - - } + public static void addSmeltingRecipies() {} } diff --git a/src/main/java/gtPlusPlus/core/handler/EnumHelperHandler.java b/src/main/java/gtPlusPlus/core/handler/EnumHelperHandler.java index d164efa3d7..c22cb3bc56 100644 --- a/src/main/java/gtPlusPlus/core/handler/EnumHelperHandler.java +++ b/src/main/java/gtPlusPlus/core/handler/EnumHelperHandler.java @@ -6,16 +6,14 @@ import gtPlusPlus.xmod.ic2.CustomInternalName; public class EnumHelperHandler { - public static void init() { + public static void init() { - if (LoadedMods.IndustrialCraft2) { - CustomInternalName.init(); - } - - if (LoadedMods.Gregtech) { - HANDLER_GT.addNewOrePrefixes(); - } - - } + if (LoadedMods.IndustrialCraft2) { + CustomInternalName.init(); + } + if (LoadedMods.Gregtech) { + HANDLER_GT.addNewOrePrefixes(); + } + } } diff --git a/src/main/java/gtPlusPlus/core/handler/GuiHandler.java b/src/main/java/gtPlusPlus/core/handler/GuiHandler.java index 1be3578ed0..9e81f42a2f 100644 --- a/src/main/java/gtPlusPlus/core/handler/GuiHandler.java +++ b/src/main/java/gtPlusPlus/core/handler/GuiHandler.java @@ -63,192 +63,197 @@ import net.minecraft.world.World; public class GuiHandler implements IGuiHandler { - public static final int GUI1 = 0; // Project Table - public static final int GUI2 = 1; // Helium Generator - public static final int GUI3 = 2; // BackpackHandler - public static final int GUI4 = 3; // Workbench - public static final int GUI5 = 4; // Workbench Adv - public static final int GUI6 = 5; // Fish trap - public static final int GUI7 = 6; // Trade table - public static final int GUI8 = 7; // Circuit Programmer - public static final int GUI9 = 8; // Grindle - public static final int GUI10 = 9; // Universal Toolbox - public static final int GUI11 = 10; // Auto Lunchbox - public static final int GUI12 = 11; // Bag for Magic Tools - public static final int GUI13 = 12; // Decayables Chest - public static final int GUI14 = 13; // Super Jukebox - public static final int GUI15 = 14; // Pest Killer - public static final int GUI16 = 15; // Round-Robinator - public static final int GUI17 = 16; // Egg Box - public static final int GUI18 = 17; // Volumetric Flask Setter - - public static void init() { - - Logger.INFO("Registering GUIs."); - NetworkRegistry.INSTANCE.registerGuiHandler(GTplusplus.instance, new GuiHandler()); - // Register GuiHandler - // NetworkRegistry.INSTANCE.registerGuiHandler(GTplusplus.instance, new - // GuiHandler()); - } - - @Override // ContainerModTileEntity - public Object getServerGuiElement(final int ID, final EntityPlayer player, final World world, final int x, - final int y, final int z) { - final TileEntity te = world.getTileEntity(x, y, z); - - if (te != null) { - if (ID == GUI1) { - return new Container_ProjectTable(player.inventory, (TileEntityProjectTable) te); - } else if (ID == GUI2) { - return new Container_ModularityTable(player.inventory, (TileEntityModularityTable) te); - } - } - - if (ID == GUI3) { - // Use the player's held item to create the inventory - return new Container_BackpackBase(player, player.inventory, - new BaseInventoryBackpack(player.getHeldItem())); - } - - if (te != null) { - if (ID == GUI4) { - //return new Container_Workbench(player.inventory, (TileEntityWorkbench) te); - } else if (ID == GUI5) { - Logger.INFO("sad"); - //return new Container_WorkbenchAdvanced(player.inventory, (TileEntityWorkbenchAdvanced) te); - } else if (ID == GUI6) { - return new Container_FishTrap(player.inventory, (TileEntityFishTrap) te); - } else if (ID == GUI7) { - return new Container_TradeTable(player.inventory, (TileEntityTradeTable) te); - } else if (ID == GUI8) { - return new Container_CircuitProgrammer(player.inventory, (TileEntityCircuitProgrammer) te); - } else if (ID == GUI13) { - return new Container_DecayablesChest(player.inventory, (TileEntityDecayablesChest) te); - } else if (ID == GUI14) { - return new Container_SuperJukebox(player.inventory, (TileEntitySuperJukebox) te); - } else if (ID == GUI15) { - return new Container_PestKiller(player.inventory, (TileEntityPestKiller) te); - } else if (ID == GUI16) { - return new Container_RoundRobinator(player.inventory, (TileEntityRoundRobinator) te); - } else if (ID == GUI17) { - return new Container_EggBox(player.inventory, (TileEntityEggBox) te); - } else if (ID == GUI18) { - return new Container_VolumetricFlaskSetter(player.inventory, (TileEntityVolumetricFlaskSetter) te); - } - } - - if (ID == GUI9) { - return new Container_Grindle(player, player.inventory, new BaseInventoryGrindle(player.getHeldItem())); - } - // Tool, lunch, magic - if (ID == GUI10) { - return new ToolBoxContainer(player, player.inventory, new ToolBoxInventory(player.getHeldItem())); - } - if (ID == GUI11) { - return new LunchBoxContainer(player, player.inventory, new LunchBoxInventory(player.getHeldItem())); - } - if (ID == GUI12) { - return new MagicBagContainer(player, player.inventory, new MagicBagInventory(player.getHeldItem())); - } - - return null; - } - - @Override // GuiModTileEntity - public Object getClientGuiElement(final int ID, final EntityPlayer player, final World world, final int x, - final int y, final int z) { - Logger.WARNING("getClientGuiElement Called by: " + player + ", in world: " + player.dimension + " at x:" + x - + ", y:" + y + ", z:" + z + "."); - final TileEntity te = world.getTileEntity(x, y, z); - if (te != null) { - if (ID == GUI1) { - return new GUI_ProjectTable(player.inventory, (TileEntityProjectTable) te); - } else if (ID == GUI2) { - return new GUI_ModularityTable(player.inventory, (TileEntityModularityTable) te); - } - } - - if (ID == GUI3) { - // We have to cast the new container as our custom class - // and pass in currently held item for the inventory - return new GuiBaseBackpack(new Container_BackpackBase(player, player.inventory, - new BaseInventoryBackpack(player.getHeldItem()))); - } - - if (te != null) { - if (ID == GUI4) { - //return new GUI_Workbench(player.inventory, (TileEntityWorkbench) te); - } else if (ID == GUI5) { - Logger.INFO("sad"); - //return new GUI_WorkbenchAdvanced(player.inventory, (TileEntityWorkbenchAdvanced) te); - } else if (ID == GUI6) { - return new GUI_FishTrap(player.inventory, (TileEntityFishTrap) te); - } else if (ID == GUI7) { - return new GUI_TradeTable(player.inventory, (TileEntityTradeTable) te, - ((TileEntityBase) te).getOwner()); - } else if (ID == GUI8) { - return new GUI_CircuitProgrammer(player.inventory, (TileEntityCircuitProgrammer) te); - } else if (ID == GUI13) { - return new GUI_DecayablesChest(player.inventory, (TileEntityDecayablesChest) te); - } else if (ID == GUI14) { - return new GUI_SuperJukebox(player.inventory, (TileEntitySuperJukebox) te); - } else if (ID == GUI15) { - return new GUI_PestKiller(player.inventory, (TileEntityPestKiller) te); - } else if (ID == GUI16) { - return new GUI_RoundRobinator(player.inventory, (TileEntityRoundRobinator) te); - } else if (ID == GUI17) { - return new GUI_EggBox(player.inventory, (TileEntityEggBox) te); - } else if (ID == GUI18) { - return new GUI_VolumetricFlaskSetter(new Container_VolumetricFlaskSetter(player.inventory, (TileEntityVolumetricFlaskSetter) te)); - } - } - - if (ID == GUI9) { - return new GuiBaseGrindle( - new Container_Grindle(player, player.inventory, new BaseInventoryGrindle(player.getHeldItem()))); - } - - // Tool, lunch, magic - if (ID == GUI10) { - return new ToolBoxGui( - new ToolBoxContainer(player, player.inventory, new ToolBoxInventory(player.getHeldItem()))); - } - if (ID == GUI11) { - return new LunchBoxGui( - new LunchBoxContainer(player, player.inventory, new LunchBoxInventory(player.getHeldItem()))); - } - if (ID == GUI12) { - return new MagicBagGui( - new MagicBagContainer(player, player.inventory, new MagicBagInventory(player.getHeldItem()))); - } - - return null; - } - - // New Methods - public static void openGui(final EntityPlayer entityplayer, final IGuiManager guiHandler) { - openGui(entityplayer, guiHandler, (short) 0); - } - - public static void openGui(final EntityPlayer entityplayer, final IGuiManager guiHandler, final short data) { - final int guiData = encodeGuiData(guiHandler, data); - final ChunkCoordinates coordinates = guiHandler.getCoordinates(); - entityplayer.openGui(GTplusplus.instance, guiData, entityplayer.worldObj, coordinates.posX, coordinates.posY, - coordinates.posZ); - } - - private static int encodeGuiData(final IGuiManager guiHandler, final short data) { - final MU_GuiId guiId = Gui_ID_Registry.getGuiIdForGuiHandler(guiHandler); - return (data << 16) | guiId.getId(); - } - - private static MU_GuiId decodeGuiID(final int guiData) { - final int guiId = guiData & 0xFF; - return Gui_ID_Registry.getGuiId(guiId); - } - - private static short decodeGuiData(final int guiId) { - return (short) (guiId >> 16); - } - -} \ No newline at end of file + public static final int GUI1 = 0; // Project Table + public static final int GUI2 = 1; // Helium Generator + public static final int GUI3 = 2; // BackpackHandler + public static final int GUI4 = 3; // Workbench + public static final int GUI5 = 4; // Workbench Adv + public static final int GUI6 = 5; // Fish trap + public static final int GUI7 = 6; // Trade table + public static final int GUI8 = 7; // Circuit Programmer + public static final int GUI9 = 8; // Grindle + public static final int GUI10 = 9; // Universal Toolbox + public static final int GUI11 = 10; // Auto Lunchbox + public static final int GUI12 = 11; // Bag for Magic Tools + public static final int GUI13 = 12; // Decayables Chest + public static final int GUI14 = 13; // Super Jukebox + public static final int GUI15 = 14; // Pest Killer + public static final int GUI16 = 15; // Round-Robinator + public static final int GUI17 = 16; // Egg Box + public static final int GUI18 = 17; // Volumetric Flask Setter + + public static void init() { + + Logger.INFO("Registering GUIs."); + NetworkRegistry.INSTANCE.registerGuiHandler(GTplusplus.instance, new GuiHandler()); + // Register GuiHandler + // NetworkRegistry.INSTANCE.registerGuiHandler(GTplusplus.instance, new + // GuiHandler()); + } + + @Override // ContainerModTileEntity + public Object getServerGuiElement( + final int ID, final EntityPlayer player, final World world, final int x, final int y, final int z) { + final TileEntity te = world.getTileEntity(x, y, z); + + if (te != null) { + if (ID == GUI1) { + return new Container_ProjectTable(player.inventory, (TileEntityProjectTable) te); + } else if (ID == GUI2) { + return new Container_ModularityTable(player.inventory, (TileEntityModularityTable) te); + } + } + + if (ID == GUI3) { + // Use the player's held item to create the inventory + return new Container_BackpackBase( + player, player.inventory, new BaseInventoryBackpack(player.getHeldItem())); + } + + if (te != null) { + if (ID == GUI4) { + // return new Container_Workbench(player.inventory, (TileEntityWorkbench) te); + } else if (ID == GUI5) { + Logger.INFO("sad"); + // return new Container_WorkbenchAdvanced(player.inventory, (TileEntityWorkbenchAdvanced) te); + } else if (ID == GUI6) { + return new Container_FishTrap(player.inventory, (TileEntityFishTrap) te); + } else if (ID == GUI7) { + return new Container_TradeTable(player.inventory, (TileEntityTradeTable) te); + } else if (ID == GUI8) { + return new Container_CircuitProgrammer(player.inventory, (TileEntityCircuitProgrammer) te); + } else if (ID == GUI13) { + return new Container_DecayablesChest(player.inventory, (TileEntityDecayablesChest) te); + } else if (ID == GUI14) { + return new Container_SuperJukebox(player.inventory, (TileEntitySuperJukebox) te); + } else if (ID == GUI15) { + return new Container_PestKiller(player.inventory, (TileEntityPestKiller) te); + } else if (ID == GUI16) { + return new Container_RoundRobinator(player.inventory, (TileEntityRoundRobinator) te); + } else if (ID == GUI17) { + return new Container_EggBox(player.inventory, (TileEntityEggBox) te); + } else if (ID == GUI18) { + return new Container_VolumetricFlaskSetter(player.inventory, (TileEntityVolumetricFlaskSetter) te); + } + } + + if (ID == GUI9) { + return new Container_Grindle(player, player.inventory, new BaseInventoryGrindle(player.getHeldItem())); + } + // Tool, lunch, magic + if (ID == GUI10) { + return new ToolBoxContainer(player, player.inventory, new ToolBoxInventory(player.getHeldItem())); + } + if (ID == GUI11) { + return new LunchBoxContainer(player, player.inventory, new LunchBoxInventory(player.getHeldItem())); + } + if (ID == GUI12) { + return new MagicBagContainer(player, player.inventory, new MagicBagInventory(player.getHeldItem())); + } + + return null; + } + + @Override // GuiModTileEntity + public Object getClientGuiElement( + final int ID, final EntityPlayer player, final World world, final int x, final int y, final int z) { + Logger.WARNING("getClientGuiElement Called by: " + player + ", in world: " + player.dimension + " at x:" + x + + ", y:" + y + ", z:" + z + "."); + final TileEntity te = world.getTileEntity(x, y, z); + if (te != null) { + if (ID == GUI1) { + return new GUI_ProjectTable(player.inventory, (TileEntityProjectTable) te); + } else if (ID == GUI2) { + return new GUI_ModularityTable(player.inventory, (TileEntityModularityTable) te); + } + } + + if (ID == GUI3) { + // We have to cast the new container as our custom class + // and pass in currently held item for the inventory + return new GuiBaseBackpack(new Container_BackpackBase( + player, player.inventory, new BaseInventoryBackpack(player.getHeldItem()))); + } + + if (te != null) { + if (ID == GUI4) { + // return new GUI_Workbench(player.inventory, (TileEntityWorkbench) te); + } else if (ID == GUI5) { + Logger.INFO("sad"); + // return new GUI_WorkbenchAdvanced(player.inventory, (TileEntityWorkbenchAdvanced) te); + } else if (ID == GUI6) { + return new GUI_FishTrap(player.inventory, (TileEntityFishTrap) te); + } else if (ID == GUI7) { + return new GUI_TradeTable( + player.inventory, (TileEntityTradeTable) te, ((TileEntityBase) te).getOwner()); + } else if (ID == GUI8) { + return new GUI_CircuitProgrammer(player.inventory, (TileEntityCircuitProgrammer) te); + } else if (ID == GUI13) { + return new GUI_DecayablesChest(player.inventory, (TileEntityDecayablesChest) te); + } else if (ID == GUI14) { + return new GUI_SuperJukebox(player.inventory, (TileEntitySuperJukebox) te); + } else if (ID == GUI15) { + return new GUI_PestKiller(player.inventory, (TileEntityPestKiller) te); + } else if (ID == GUI16) { + return new GUI_RoundRobinator(player.inventory, (TileEntityRoundRobinator) te); + } else if (ID == GUI17) { + return new GUI_EggBox(player.inventory, (TileEntityEggBox) te); + } else if (ID == GUI18) { + return new GUI_VolumetricFlaskSetter( + new Container_VolumetricFlaskSetter(player.inventory, (TileEntityVolumetricFlaskSetter) te)); + } + } + + if (ID == GUI9) { + return new GuiBaseGrindle( + new Container_Grindle(player, player.inventory, new BaseInventoryGrindle(player.getHeldItem()))); + } + + // Tool, lunch, magic + if (ID == GUI10) { + return new ToolBoxGui( + new ToolBoxContainer(player, player.inventory, new ToolBoxInventory(player.getHeldItem()))); + } + if (ID == GUI11) { + return new LunchBoxGui( + new LunchBoxContainer(player, player.inventory, new LunchBoxInventory(player.getHeldItem()))); + } + if (ID == GUI12) { + return new MagicBagGui( + new MagicBagContainer(player, player.inventory, new MagicBagInventory(player.getHeldItem()))); + } + + return null; + } + + // New Methods + public static void openGui(final EntityPlayer entityplayer, final IGuiManager guiHandler) { + openGui(entityplayer, guiHandler, (short) 0); + } + + public static void openGui(final EntityPlayer entityplayer, final IGuiManager guiHandler, final short data) { + final int guiData = encodeGuiData(guiHandler, data); + final ChunkCoordinates coordinates = guiHandler.getCoordinates(); + entityplayer.openGui( + GTplusplus.instance, + guiData, + entityplayer.worldObj, + coordinates.posX, + coordinates.posY, + coordinates.posZ); + } + + private static int encodeGuiData(final IGuiManager guiHandler, final short data) { + final MU_GuiId guiId = Gui_ID_Registry.getGuiIdForGuiHandler(guiHandler); + return (data << 16) | guiId.getId(); + } + + private static MU_GuiId decodeGuiID(final int guiData) { + final int guiId = guiData & 0xFF; + return Gui_ID_Registry.getGuiId(guiId); + } + + private static short decodeGuiData(final int guiId) { + return (short) (guiId >> 16); + } +} diff --git a/src/main/java/gtPlusPlus/core/handler/MobMentality.java b/src/main/java/gtPlusPlus/core/handler/MobMentality.java index acc289fecd..40a4f73d94 100644 --- a/src/main/java/gtPlusPlus/core/handler/MobMentality.java +++ b/src/main/java/gtPlusPlus/core/handler/MobMentality.java @@ -1,10 +1,9 @@ package gtPlusPlus.core.handler; -import java.util.*; - import cpw.mods.fml.common.eventhandler.SubscribeEvent; import gtPlusPlus.core.util.minecraft.EntityUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; +import java.util.*; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.IMob; @@ -13,46 +12,46 @@ import net.minecraftforge.event.entity.living.LivingHurtEvent; public class MobMentality { - public static HashSet> sIgnoredTypes = new HashSet>(); - - @SubscribeEvent - public void onEntityDamaged(LivingHurtEvent event) { - final EntityLivingBase target = event.entityLiving; - for (Class aEntityClass : sIgnoredTypes) { - if (aEntityClass.isInstance(target)) { - return; - } - } - if (target instanceof EntityLivingBase) { - final EntityLivingBase entity = target; - final Entity attacker = event.source.getSourceOfDamage(); - if (/*this.configuration.shouldIgnoreNeutralMobs() && */!(entity instanceof IMob)) { - return; - } - if (attacker == null) { - return; - } - if (attacker instanceof EntityLivingBase && !PlayerUtils.isRealPlayer((EntityLivingBase) attacker)) { - return; - } - if (attacker instanceof EntityPlayer && PlayerUtils.isCreative((EntityPlayer) attacker)) { - return; - } - if (attacker instanceof EntityLivingBase) { - List aEntityList = target.worldObj.loadedEntityList; - List aRangedEntity = new ArrayList(); - for (Entity aEntity : aEntityList) { - if (target.getClass().isInstance(aEntity)) { - if (EntityUtils.getDistance(target, aEntity) <= 32) { - aRangedEntity.add((EntityLivingBase) aEntity); - } - } - } - for (EntityLivingBase aEntity : aRangedEntity) { - aEntity.setRevengeTarget((EntityLivingBase) attacker); - } - } - } - } + public static HashSet> sIgnoredTypes = new HashSet>(); + @SubscribeEvent + public void onEntityDamaged(LivingHurtEvent event) { + final EntityLivingBase target = event.entityLiving; + for (Class aEntityClass : sIgnoredTypes) { + if (aEntityClass.isInstance(target)) { + return; + } + } + if (target instanceof EntityLivingBase) { + final EntityLivingBase entity = target; + final Entity attacker = event.source.getSourceOfDamage(); + if ( + /*this.configuration.shouldIgnoreNeutralMobs() && */ !(entity instanceof IMob)) { + return; + } + if (attacker == null) { + return; + } + if (attacker instanceof EntityLivingBase && !PlayerUtils.isRealPlayer((EntityLivingBase) attacker)) { + return; + } + if (attacker instanceof EntityPlayer && PlayerUtils.isCreative((EntityPlayer) attacker)) { + return; + } + if (attacker instanceof EntityLivingBase) { + List aEntityList = target.worldObj.loadedEntityList; + List aRangedEntity = new ArrayList(); + for (Entity aEntity : aEntityList) { + if (target.getClass().isInstance(aEntity)) { + if (EntityUtils.getDistance(target, aEntity) <= 32) { + aRangedEntity.add((EntityLivingBase) aEntity); + } + } + } + for (EntityLivingBase aEntity : aRangedEntity) { + aEntity.setRevengeTarget((EntityLivingBase) attacker); + } + } + } + } } diff --git a/src/main/java/gtPlusPlus/core/handler/OldCircuitHandler.java b/src/main/java/gtPlusPlus/core/handler/OldCircuitHandler.java index e20e13a337..231ae98093 100644 --- a/src/main/java/gtPlusPlus/core/handler/OldCircuitHandler.java +++ b/src/main/java/gtPlusPlus/core/handler/OldCircuitHandler.java @@ -2,65 +2,94 @@ package gtPlusPlus.core.handler; import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableOldGTcircuits; -import java.lang.reflect.Field; -import java.util.HashSet; - -import org.apache.commons.lang3.reflect.FieldUtils; - import gregtech.api.enums.GT_Values; import gregtech.api.util.EmptyRecipeMap; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.RECIPES_Old_Circuits; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechItems; +import java.lang.reflect.Field; +import java.util.HashSet; +import org.apache.commons.lang3.reflect.FieldUtils; public class OldCircuitHandler { - public static void preInit(){ - if (enableOldGTcircuits && CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && !CORE.GTNH){ - removeCircuitRecipeMap(); //Bye shitty recipes. - } - } - - public static void init(){ - - } + public static void preInit() { + if (enableOldGTcircuits && CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && !CORE.GTNH) { + removeCircuitRecipeMap(); // Bye shitty recipes. + } + } - public static void postInit(){ - if (enableOldGTcircuits && CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && !CORE.GTNH){ - RECIPES_Old_Circuits.handleCircuits(); - new RECIPES_Old_Circuits(); - } - } + public static void init() {} - public static boolean addCircuitItems() { - if (enableOldGTcircuits && CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && !CORE.GTNH){ - return MetaGeneratedGregtechItems.INSTANCE.registerOldCircuits(); - } - return false; - } + public static void postInit() { + if (enableOldGTcircuits && CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && !CORE.GTNH) { + RECIPES_Old_Circuits.handleCircuits(); + new RECIPES_Old_Circuits(); + } + } - private static boolean removeCircuitRecipeMap(){ - if (enableOldGTcircuits && CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && !CORE.GTNH){ - try { - Logger.INFO("[Old Feature - Circuits] Trying to override the Circuit Assembler Recipe map, so that no recipes for new circuits get added."); - ReflectionUtils.setFinalStatic(GT_Recipe_Map.class.getDeclaredField("sCircuitAssemblerRecipes"), new EmptyRecipeMap(new HashSet(0), "gt.recipe.removed", "Removed", null, GT_Values.RES_PATH_GUI + "basicmachines/Default", 0, 0, 0, 0, 0, GT_Values.E, 0, GT_Values.E, true, false)); - Field jaffar = GT_Recipe_Map.class.getDeclaredField("sCircuitAssemblerRecipes"); - FieldUtils.removeFinalModifier(jaffar, true); - jaffar.set(null, new EmptyRecipeMap(new HashSet(0), "gt.recipe.removed", "Removed", null, GT_Values.RES_PATH_GUI + "basicmachines/Default", 0, 0, 0, 0, 0, GT_Values.E, 0, GT_Values.E, true, false)); - Logger.INFO("[Old Feature - Circuits] Successfully replaced circuit assembler recipe map with one that cannot hold recipes."); - } - catch (Exception e) { - Logger.INFO("[Old Feature - Circuits] Failed removing circuit assembler recipe map."); - return false; - } - return true; - } - return false; - } + public static boolean addCircuitItems() { + if (enableOldGTcircuits && CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && !CORE.GTNH) { + return MetaGeneratedGregtechItems.INSTANCE.registerOldCircuits(); + } + return false; + } + private static boolean removeCircuitRecipeMap() { + if (enableOldGTcircuits && CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && !CORE.GTNH) { + try { + Logger.INFO( + "[Old Feature - Circuits] Trying to override the Circuit Assembler Recipe map, so that no recipes for new circuits get added."); + ReflectionUtils.setFinalStatic( + GT_Recipe_Map.class.getDeclaredField("sCircuitAssemblerRecipes"), + new EmptyRecipeMap( + new HashSet(0), + "gt.recipe.removed", + "Removed", + null, + GT_Values.RES_PATH_GUI + "basicmachines/Default", + 0, + 0, + 0, + 0, + 0, + GT_Values.E, + 0, + GT_Values.E, + true, + false)); + Field jaffar = GT_Recipe_Map.class.getDeclaredField("sCircuitAssemblerRecipes"); + FieldUtils.removeFinalModifier(jaffar, true); + jaffar.set( + null, + new EmptyRecipeMap( + new HashSet(0), + "gt.recipe.removed", + "Removed", + null, + GT_Values.RES_PATH_GUI + "basicmachines/Default", + 0, + 0, + 0, + 0, + 0, + GT_Values.E, + 0, + GT_Values.E, + true, + false)); + Logger.INFO( + "[Old Feature - Circuits] Successfully replaced circuit assembler recipe map with one that cannot hold recipes."); + } catch (Exception e) { + Logger.INFO("[Old Feature - Circuits] Failed removing circuit assembler recipe map."); + return false; + } + return true; + } + return false; + } } diff --git a/src/main/java/gtPlusPlus/core/handler/PacketHandler.java b/src/main/java/gtPlusPlus/core/handler/PacketHandler.java index 382b82df29..d77d958373 100644 --- a/src/main/java/gtPlusPlus/core/handler/PacketHandler.java +++ b/src/main/java/gtPlusPlus/core/handler/PacketHandler.java @@ -15,77 +15,79 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; public class PacketHandler { - - private static byte packetId = 0; - private static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(CORE.MODID); + private static byte packetId = 0; - public static final void init() { - registerMessage(Packet_VolumetricFlaskGui.class, Packet_VolumetricFlaskGui.class); - registerMessage(Packet_VolumetricFlaskGui2.class, Packet_VolumetricFlaskGui2.class); - } - - /** - * Registers a message and message handler - */ - private static final void registerMessage(Class handlerClass, Class messageClass) { - Side side = AbstractClientMessageHandler.class.isAssignableFrom(handlerClass) ? Side.CLIENT : Side.SERVER; - registerMessage(handlerClass, messageClass, side); - } - - private static final void registerMessage(Class handlerClass, Class messageClass, Side side) { - INSTANCE.registerMessage(handlerClass, messageClass, packetId++, side); - if (AbstractPacket.class.isInstance(messageClass.getClass())) { - AbstractPacket aPacket = ReflectionUtils.createNewInstanceFromConstructor(ReflectionUtils.getConstructor(messageClass, new Class[] {}), new Object[] {}); - if (aPacket != null) { - Logger.INFO("Registered Packet: "+aPacket.getPacketName()); - } - } - } + private static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(CORE.MODID); - /** - * Send this message to the specified player. - * See {@link SimpleNetworkWrapper#sendTo(IMessage, EntityPlayerMP)} - */ - public static final void sendTo(IMessage message, EntityPlayerMP player) { - INSTANCE.sendTo(message, player); - } + public static final void init() { + registerMessage(Packet_VolumetricFlaskGui.class, Packet_VolumetricFlaskGui.class); + registerMessage(Packet_VolumetricFlaskGui2.class, Packet_VolumetricFlaskGui2.class); + } - /** - * Send this message to everyone within a certain range of a point. - * See {@link SimpleNetworkWrapper#sendToDimension(IMessage, NetworkRegistry.TargetPoint)} - */ - public static final void sendToAllAround(IMessage message, NetworkRegistry.TargetPoint point) { - INSTANCE.sendToAllAround(message, point); - } + /** + * Registers a message and message handler + */ + private static final void registerMessage(Class handlerClass, Class messageClass) { + Side side = AbstractClientMessageHandler.class.isAssignableFrom(handlerClass) ? Side.CLIENT : Side.SERVER; + registerMessage(handlerClass, messageClass, side); + } - /** - * Sends a message to everyone within a certain range of the coordinates in the same dimension. - */ - public static final void sendToAllAround(IMessage message, int dimension, double x, double y, double z, double range) { - sendToAllAround(message, new NetworkRegistry.TargetPoint(dimension, x, y, z, range)); - } + private static final void registerMessage(Class handlerClass, Class messageClass, Side side) { + INSTANCE.registerMessage(handlerClass, messageClass, packetId++, side); + if (AbstractPacket.class.isInstance(messageClass.getClass())) { + AbstractPacket aPacket = ReflectionUtils.createNewInstanceFromConstructor( + ReflectionUtils.getConstructor(messageClass, new Class[] {}), new Object[] {}); + if (aPacket != null) { + Logger.INFO("Registered Packet: " + aPacket.getPacketName()); + } + } + } - /** - * Sends a message to everyone within a certain range of the player provided. - */ - public static final void sendToAllAround(IMessage message, EntityPlayer player, double range) { - sendToAllAround(message, player.worldObj.provider.dimensionId, player.posX, player.posY, player.posZ, range); - } + /** + * Send this message to the specified player. + * See {@link SimpleNetworkWrapper#sendTo(IMessage, EntityPlayerMP)} + */ + public static final void sendTo(IMessage message, EntityPlayerMP player) { + INSTANCE.sendTo(message, player); + } - /** - * Send this message to everyone within the supplied dimension. - * See {@link SimpleNetworkWrapper#sendToDimension(IMessage, int)} - */ - public static final void sendToDimension(IMessage message, int dimensionId) { - INSTANCE.sendToDimension(message, dimensionId); - } + /** + * Send this message to everyone within a certain range of a point. + * See {@link SimpleNetworkWrapper#sendToDimension(IMessage, NetworkRegistry.TargetPoint)} + */ + public static final void sendToAllAround(IMessage message, NetworkRegistry.TargetPoint point) { + INSTANCE.sendToAllAround(message, point); + } - /** - * Send this message to the server. - * See {@link SimpleNetworkWrapper#sendToServer(IMessage)} - */ - public static final void sendToServer(IMessage message) { - INSTANCE.sendToServer(message); - } + /** + * Sends a message to everyone within a certain range of the coordinates in the same dimension. + */ + public static final void sendToAllAround( + IMessage message, int dimension, double x, double y, double z, double range) { + sendToAllAround(message, new NetworkRegistry.TargetPoint(dimension, x, y, z, range)); + } + + /** + * Sends a message to everyone within a certain range of the player provided. + */ + public static final void sendToAllAround(IMessage message, EntityPlayer player, double range) { + sendToAllAround(message, player.worldObj.provider.dimensionId, player.posX, player.posY, player.posZ, range); + } + + /** + * Send this message to everyone within the supplied dimension. + * See {@link SimpleNetworkWrapper#sendToDimension(IMessage, int)} + */ + public static final void sendToDimension(IMessage message, int dimensionId) { + INSTANCE.sendToDimension(message, dimensionId); + } + + /** + * Send this message to the server. + * See {@link SimpleNetworkWrapper#sendToServer(IMessage)} + */ + public static final void sendToServer(IMessage message) { + INSTANCE.sendToServer(message); + } } diff --git a/src/main/java/gtPlusPlus/core/handler/Recipes/DecayableRecipe.java b/src/main/java/gtPlusPlus/core/handler/Recipes/DecayableRecipe.java index 360b0440a2..d8e069b5fa 100644 --- a/src/main/java/gtPlusPlus/core/handler/Recipes/DecayableRecipe.java +++ b/src/main/java/gtPlusPlus/core/handler/Recipes/DecayableRecipe.java @@ -7,33 +7,33 @@ import net.minecraft.item.ItemStack; public class DecayableRecipe { - public static final AutoMap mRecipes = new AutoMap(); - - - public final int mTime; - public final ItemStack mInput; - public final ItemStack mOutput; + public static final AutoMap mRecipes = new AutoMap(); - public DecayableRecipe(int time, ItemStack input, ItemStack output) { - mTime = time; - mInput = input; - mOutput = output; - mRecipes.put(this); - } + public final int mTime; + public final ItemStack mInput; + public final ItemStack mOutput; - @Override - public boolean equals(Object o) { - if (o instanceof DecayableRecipe) { - DecayableRecipe i = (DecayableRecipe) o; - if (i.mTime == this.mTime && GT_Utility.areStacksEqual(mInput, i.mInput) && GT_Utility.areStacksEqual(mOutput, i.mOutput)) { - return true; - } - } - return false; - } + public DecayableRecipe(int time, ItemStack input, ItemStack output) { + mTime = time; + mInput = input; + mOutput = output; + mRecipes.put(this); + } - public boolean isValid() { - return (mTime > 0 && ItemUtils.checkForInvalidItems(mInput) && ItemUtils.checkForInvalidItems(mOutput)); - } + @Override + public boolean equals(Object o) { + if (o instanceof DecayableRecipe) { + DecayableRecipe i = (DecayableRecipe) o; + if (i.mTime == this.mTime + && GT_Utility.areStacksEqual(mInput, i.mInput) + && GT_Utility.areStacksEqual(mOutput, i.mOutput)) { + return true; + } + } + return false; + } + public boolean isValid() { + return (mTime > 0 && ItemUtils.checkForInvalidItems(mInput) && ItemUtils.checkForInvalidItems(mOutput)); + } } diff --git a/src/main/java/gtPlusPlus/core/handler/Recipes/LateRegistrationHandler.java b/src/main/java/gtPlusPlus/core/handler/Recipes/LateRegistrationHandler.java index 5bf6374725..3e20194498 100644 --- a/src/main/java/gtPlusPlus/core/handler/Recipes/LateRegistrationHandler.java +++ b/src/main/java/gtPlusPlus/core/handler/Recipes/LateRegistrationHandler.java @@ -6,23 +6,22 @@ import gtPlusPlus.core.recipe.ShapedRecipeObject; public class LateRegistrationHandler { - public static int recipesSuccess = 0; - public static int recipesFailed = 0; + public static int recipesSuccess = 0; + public static int recipesFailed = 0; - public static void run(){ - init(); - } - - private final static void init(){ - for(final ShapedRecipeObject item : COMPAT_HANDLER.AddRecipeQueue){ - item.buildRecipe(); - } - try { - Thread.sleep(10); - } catch (final InterruptedException e) { - Logger.INFO(e.toString()); - } - Logger.INFO("Late Recipes Loaded: "+recipesSuccess+" Failed: "+recipesFailed); - } + public static void run() { + init(); + } + private static final void init() { + for (final ShapedRecipeObject item : COMPAT_HANDLER.AddRecipeQueue) { + item.buildRecipe(); + } + try { + Thread.sleep(10); + } catch (final InterruptedException e) { + Logger.INFO(e.toString()); + } + Logger.INFO("Late Recipes Loaded: " + recipesSuccess + " Failed: " + recipesFailed); + } } diff --git a/src/main/java/gtPlusPlus/core/handler/Recipes/RegistrationHandler.java b/src/main/java/gtPlusPlus/core/handler/Recipes/RegistrationHandler.java index 4192e71091..f240656dd7 100644 --- a/src/main/java/gtPlusPlus/core/handler/Recipes/RegistrationHandler.java +++ b/src/main/java/gtPlusPlus/core/handler/Recipes/RegistrationHandler.java @@ -6,22 +6,21 @@ import gtPlusPlus.core.recipe.*; public class RegistrationHandler { - public static int recipesSuccess = 0; - public static int recipesFailed = 0; + public static int recipesSuccess = 0; + public static int recipesFailed = 0; - public static void run(){ - init(); - } - - private final static void init(){ - RECIPES_Tools.loadRecipes(); - RECIPES_General.loadRecipes(); - RECIPES_Machines.loadRecipes(); - RECIPES_Shapeless.loadRecipes(); - RECIPES_MachineComponents.loadRecipes(); - RECIPE_Batteries.loadRecipes(); - Logger.INFO("Loaded: "+recipesSuccess+" Failed: "+recipesFailed); - COMPAT_HANDLER.areInitItemsLoaded = true; - } + public static void run() { + init(); + } + private static final void init() { + RECIPES_Tools.loadRecipes(); + RECIPES_General.loadRecipes(); + RECIPES_Machines.loadRecipes(); + RECIPES_Shapeless.loadRecipes(); + RECIPES_MachineComponents.loadRecipes(); + RECIPE_Batteries.loadRecipes(); + Logger.INFO("Loaded: " + recipesSuccess + " Failed: " + recipesFailed); + COMPAT_HANDLER.areInitItemsLoaded = true; + } } diff --git a/src/main/java/gtPlusPlus/core/handler/StopAnnoyingFuckingAchievements.java b/src/main/java/gtPlusPlus/core/handler/StopAnnoyingFuckingAchievements.java index 8499f98525..50364f43a3 100644 --- a/src/main/java/gtPlusPlus/core/handler/StopAnnoyingFuckingAchievements.java +++ b/src/main/java/gtPlusPlus/core/handler/StopAnnoyingFuckingAchievements.java @@ -1,49 +1,47 @@ package gtPlusPlus.core.handler; -import java.lang.reflect.Field; - import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import java.lang.reflect.Field; import net.minecraft.stats.AchievementList; import net.minecraftforge.event.entity.player.AchievementEvent; public class StopAnnoyingFuckingAchievements { - /** - * Stops me getting fireworks every fucking time I open my inventory upon first loading a dev client. - * @param event - */ - @SubscribeEvent(priority=EventPriority.HIGHEST) - public void FUCK_OFF(AchievementEvent event) { - if (Utils.isClient()) { - doClientStuff(); - } - if (event.achievement.equals(AchievementList.openInventory)) { - event.setCanceled(true); - } - } - - @SideOnly(Side.CLIENT) - private final void doClientStuff() { - Class aMC = ReflectionUtils.getClass("net.minecraft.client.Minecraft"); - if (aMC != null) { - Field aInstanceMC = ReflectionUtils.getField(aMC, "theMinecraft"); - Object aMcObj = ReflectionUtils.getFieldValue(null, aInstanceMC); - Class aClazz2 = aMcObj.getClass(); - if (aClazz2 != null) { - Field aGameSettings = ReflectionUtils.getField(aClazz2, "gameSettings"); - Object aGameSettingsObj = ReflectionUtils.getFieldValue(aInstanceMC, aGameSettings); - Class aClazz3 = aGameSettingsObj.getClass(); - if (aClazz3 != null) { - Field ainvHint = ReflectionUtils.getField(aClazz3, "showInventoryAchievementHint"); - ReflectionUtils.setField(aGameSettingsObj, ainvHint, false); - } - } - } - } + /** + * Stops me getting fireworks every fucking time I open my inventory upon first loading a dev client. + * @param event + */ + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void FUCK_OFF(AchievementEvent event) { + if (Utils.isClient()) { + doClientStuff(); + } + if (event.achievement.equals(AchievementList.openInventory)) { + event.setCanceled(true); + } + } + @SideOnly(Side.CLIENT) + private final void doClientStuff() { + Class aMC = ReflectionUtils.getClass("net.minecraft.client.Minecraft"); + if (aMC != null) { + Field aInstanceMC = ReflectionUtils.getField(aMC, "theMinecraft"); + Object aMcObj = ReflectionUtils.getFieldValue(null, aInstanceMC); + Class aClazz2 = aMcObj.getClass(); + if (aClazz2 != null) { + Field aGameSettings = ReflectionUtils.getField(aClazz2, "gameSettings"); + Object aGameSettingsObj = ReflectionUtils.getFieldValue(aInstanceMC, aGameSettings); + Class aClazz3 = aGameSettingsObj.getClass(); + if (aClazz3 != null) { + Field ainvHint = ReflectionUtils.getField(aClazz3, "showInventoryAchievementHint"); + ReflectionUtils.setField(aGameSettingsObj, ainvHint, false); + } + } + } + } } diff --git a/src/main/java/gtPlusPlus/core/handler/events/BlockEventHandler.java b/src/main/java/gtPlusPlus/core/handler/events/BlockEventHandler.java index 03bb99bb2a..c3eee57118 100644 --- a/src/main/java/gtPlusPlus/core/handler/events/BlockEventHandler.java +++ b/src/main/java/gtPlusPlus/core/handler/events/BlockEventHandler.java @@ -3,8 +3,6 @@ package gtPlusPlus.core.handler.events; import static gtPlusPlus.core.lib.CORE.ConfigSwitches.chanceToDropDrainedShard; import static gtPlusPlus.core.lib.CORE.ConfigSwitches.chanceToDropFluoriteOre; -import java.util.ArrayList; - import cpw.mods.fml.common.eventhandler.SubscribeEvent; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.item.ModItems; @@ -13,6 +11,7 @@ import gtPlusPlus.core.material.nuclear.FLUORIDES; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; +import java.util.ArrayList; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -23,207 +22,209 @@ import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.oredict.OreDictionary; public class BlockEventHandler { - public static ArrayList oreLimestone; - public static ArrayList blockLimestone; - public static ItemStack fluoriteOre; - - public static void init() { - //Set Variables for Fluorite Block handling - Logger.INFO("Setting some Variables for the block break event handler."); - BlockEventHandler.oreLimestone = OreDictionary.getOres("oreLimestone"); - BlockEventHandler.blockLimestone = OreDictionary.getOres("limestone"); - BlockEventHandler.fluoriteOre = FLUORIDES.FLUORITE.getOre(1); - } - - @SubscribeEvent - public void onBlockLeftClicked(final PlayerInteractEvent event) { - /* - * if (event.action != PlayerInteractEvent.Action.LEFT_CLICK_BLOCK) return; - * - * ItemStack heldItem = event.entityPlayer.getHeldItem(); Block block = - * event.world.getBlock(event.x, event.y, event.z); - * - * // If the block clicked was Stone, the player was holding an Iron Pickaxe and - * a random integer from 0 (inclusive) to 2 (exclusive) is 0 (50% chance) if - * (block == Blocks.stone && heldItem != null && heldItem.getItem() == - * Items.iron_pickaxe && random.nextInt(2) == 0) { ForgeDirection direction = - * ForgeDirection.getOrientation(event.face); // Convert the numeric face to a - * ForgeDirection int fireX = event.x + direction.offsetX, fireY = event.y + - * direction.offsetY, fireZ = event.z + direction.offsetZ; // Offset the block's - * coordinates according to the direction - * - * if (event.world.isAirBlock(fireX, fireY, fireZ)) { // If the block at the new - * coordinates is Air event.world.setBlock(fireX, fireY, fireZ, Blocks.fire); // - * Replace it with Fire event.useBlock = Event.Result.DENY; // Prevent the Fire - * from being extinguished (also prevents Block#onBlockClicked from being - * called) } } - */ - } - - @SubscribeEvent - public void onEntityDrop(final LivingDropsEvent event) { - /* - * if (event.entityLiving instanceof EntityPig && event.source instanceof - * EntityDamageSource) { // getEntity will return the Entity that caused the - * damage,even for indirect damage sources like arrows/fireballs // (where it - * will return the Entity that shot the projectile rather than the projectile - * itself) Entity sourceEntity = event.source.getEntity(); ItemStack heldItem = - * sourceEntity instanceof EntityLiving ? ((EntityLiving) - * sourceEntity).getHeldItem() : sourceEntity instanceof EntityPlayer ? - * ((EntityPlayer) sourceEntity).getHeldItem() : null; - * - * if (heldItem != null && heldItem.getItem() == Items.iron_pickaxe) { - * System.out.println("EntityPig drops event"); event.drops.clear(); - * event.entityLiving.dropItem(Items.diamond, 64); } } - */ - } - - @SubscribeEvent - public void onBlockBreak(final BlockEvent.BreakEvent event) { - - } - - - // Used to handle Thaumcraft Shards when TC is not installed. - @SubscribeEvent - public void harvestDrops(final BlockEvent.HarvestDropsEvent event) { - try { - - if (event != null && event.harvester != null && event.harvester.worldObj != null) { - if (!event.harvester.worldObj.isRemote) { - - EntityPlayer p = event.harvester; - - if (PlayerUtils.isRealPlayer(p)) { - // Spawns Fluorite from Lime Stone - if (chanceToDropFluoriteOre != 0) { - if (!oreLimestone.isEmpty() || !blockLimestone.isEmpty()) { - - ArrayList mBlockTypes = new ArrayList(); - if (!oreLimestone.isEmpty()) { - for (int i = 0; i < oreLimestone.size(); i++) { - if (ItemUtils.getModId(oreLimestone.get(i)) != null - && !ItemUtils.getModId(oreLimestone.get(i)).toLowerCase() - .contains("biomesoplenty")) { - if (!mBlockTypes - .contains(Block.getBlockFromItem(oreLimestone.get(i).getItem()))) { - mBlockTypes.add(Block.getBlockFromItem(oreLimestone.get(i).getItem())); - } - } - } - } - if (!blockLimestone.isEmpty()) { - for (int i = 0; i < blockLimestone.size(); i++) { - if (ItemUtils.getModId(blockLimestone.get(i)) != null - && !ItemUtils.getModId(blockLimestone.get(i)).toLowerCase() - .contains("biomesoplenty")) { - if (!mBlockTypes.contains( - Block.getBlockFromItem(blockLimestone.get(i).getItem()))) { - mBlockTypes - .add(Block.getBlockFromItem(blockLimestone.get(i).getItem())); - } - } - } - } - - Logger.WARNING("Found Limestone in OreDict."); - if (!mBlockTypes.isEmpty()) { - Logger.WARNING("1a | " + event.block.getUnlocalizedName()); - for (final Block temp : mBlockTypes) { - Logger.WARNING("2a - " + temp.getUnlocalizedName()); - if (event.block == temp) { - Logger.WARNING("3a - found " + temp.getUnlocalizedName()); - if (MathUtils.randInt(1, chanceToDropFluoriteOre) == 1) { - Logger.WARNING("4a"); - event.drops.clear(); - event.drops.add(fluoriteOre.copy()); - } - } - } - } - } - - if (event.block.getUnlocalizedName().toLowerCase().contains("limestone")) { - Logger.WARNING("1c"); - if (MathUtils.randInt(1, chanceToDropFluoriteOre) == 1) { - Logger.WARNING("2c"); - event.drops.clear(); - event.drops.add(fluoriteOre.copy()); - } - } - - if (event.block == Blocks.sandstone) { - if (MathUtils.randInt(1, chanceToDropFluoriteOre * 20) == 1) { - event.drops.clear(); - event.drops.add(fluoriteOre.copy()); - } - } - } - } - - // Do things that can occur for fake players and real players - - // Spawn Dull Shards (Can spawn from Tree Logs, Grass or Stone. Stone going to - // be the most common source.) - if (((event.block == Blocks.stone) || (event.block == Blocks.sandstone) - || (event.block == Blocks.log) || (event.block == Blocks.log2) - || (event.block == Blocks.grass)) && !LoadedMods.Thaumcraft - && (chanceToDropDrainedShard != 0)) { - // small chance for one to spawn per stone mined. 1 per 3 stacks~ - if (MathUtils.randInt(1, chanceToDropDrainedShard) == 1) { - // Let's sort out a lucky charm for the player. - final int FancyChance = MathUtils.randInt(1, 4); - if (MathUtils.randInt(1, 100) < 90) { - event.drops.add(new ItemStack(ModItems.shardDull)); - } - // Make a Fire Shard - else if (FancyChance == 1) { - event.drops.add(new ItemStack(ModItems.shardIgnis)); - } - // Make a Water Shard. - else if (FancyChance == 2) { - event.drops.add(new ItemStack(ModItems.shardAqua)); - } - // Make an Earth Shard. - else if (FancyChance == 3) { - event.drops.add(new ItemStack(ModItems.shardTerra)); - } - // Make an Air Shard. - else if (FancyChance == 4) { - event.drops.add(new ItemStack(ModItems.shardAer)); - } - } else { - Logger.WARNING("invalid chance"); - } - } - - } - } - } catch (Throwable r) { - Logger.INFO("Block Event Handler Failed. Please Report this to Alkalus."); - r.printStackTrace(); - } - } - - @SubscribeEvent - public void logsHarvest(final BlockEvent.HarvestDropsEvent event) { - /* - * if (event.block instanceof BlockLog) { // - * http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/ - * modification-development/2444501-harvestdropevent-changing-drops-of-vanilla- - * blocks - * - * // Utils.sendServerMessage("Logs! Harvester: %s Drops: %s", event.harvester - * != null ? event.harvester.getCommandSenderName() : "", - * event.drops.stream().map(ItemStack.toString()).collect(Collectors. - * joining(", "))); if (event.harvester != null) { ItemStack heldItem = - * event.harvester.getHeldItem(); if (heldItem == null || - * heldItem.getItem().getHarvestLevel(heldItem, "axe") < 1) { - * event.drops.clear(); - * Utils.sendServerMessage("Harvester had wrong tool, clearing drops"); } else { - * Utils.sendServerMessage("Harvester had correct tool, not clearing drops"); } - * } else { event.drops.clear(); - * Utils.sendServerMessage("No harvester, clearing drops"); } } - */ - } + public static ArrayList oreLimestone; + public static ArrayList blockLimestone; + public static ItemStack fluoriteOre; + + public static void init() { + // Set Variables for Fluorite Block handling + Logger.INFO("Setting some Variables for the block break event handler."); + BlockEventHandler.oreLimestone = OreDictionary.getOres("oreLimestone"); + BlockEventHandler.blockLimestone = OreDictionary.getOres("limestone"); + BlockEventHandler.fluoriteOre = FLUORIDES.FLUORITE.getOre(1); + } + + @SubscribeEvent + public void onBlockLeftClicked(final PlayerInteractEvent event) { + /* + * if (event.action != PlayerInteractEvent.Action.LEFT_CLICK_BLOCK) return; + * + * ItemStack heldItem = event.entityPlayer.getHeldItem(); Block block = + * event.world.getBlock(event.x, event.y, event.z); + * + * // If the block clicked was Stone, the player was holding an Iron Pickaxe and + * a random integer from 0 (inclusive) to 2 (exclusive) is 0 (50% chance) if + * (block == Blocks.stone && heldItem != null && heldItem.getItem() == + * Items.iron_pickaxe && random.nextInt(2) == 0) { ForgeDirection direction = + * ForgeDirection.getOrientation(event.face); // Convert the numeric face to a + * ForgeDirection int fireX = event.x + direction.offsetX, fireY = event.y + + * direction.offsetY, fireZ = event.z + direction.offsetZ; // Offset the block's + * coordinates according to the direction + * + * if (event.world.isAirBlock(fireX, fireY, fireZ)) { // If the block at the new + * coordinates is Air event.world.setBlock(fireX, fireY, fireZ, Blocks.fire); // + * Replace it with Fire event.useBlock = Event.Result.DENY; // Prevent the Fire + * from being extinguished (also prevents Block#onBlockClicked from being + * called) } } + */ + } + + @SubscribeEvent + public void onEntityDrop(final LivingDropsEvent event) { + /* + * if (event.entityLiving instanceof EntityPig && event.source instanceof + * EntityDamageSource) { // getEntity will return the Entity that caused the + * damage,even for indirect damage sources like arrows/fireballs // (where it + * will return the Entity that shot the projectile rather than the projectile + * itself) Entity sourceEntity = event.source.getEntity(); ItemStack heldItem = + * sourceEntity instanceof EntityLiving ? ((EntityLiving) + * sourceEntity).getHeldItem() : sourceEntity instanceof EntityPlayer ? + * ((EntityPlayer) sourceEntity).getHeldItem() : null; + * + * if (heldItem != null && heldItem.getItem() == Items.iron_pickaxe) { + * System.out.println("EntityPig drops event"); event.drops.clear(); + * event.entityLiving.dropItem(Items.diamond, 64); } } + */ + } + + @SubscribeEvent + public void onBlockBreak(final BlockEvent.BreakEvent event) {} + + // Used to handle Thaumcraft Shards when TC is not installed. + @SubscribeEvent + public void harvestDrops(final BlockEvent.HarvestDropsEvent event) { + try { + + if (event != null && event.harvester != null && event.harvester.worldObj != null) { + if (!event.harvester.worldObj.isRemote) { + + EntityPlayer p = event.harvester; + + if (PlayerUtils.isRealPlayer(p)) { + // Spawns Fluorite from Lime Stone + if (chanceToDropFluoriteOre != 0) { + if (!oreLimestone.isEmpty() || !blockLimestone.isEmpty()) { + + ArrayList mBlockTypes = new ArrayList(); + if (!oreLimestone.isEmpty()) { + for (int i = 0; i < oreLimestone.size(); i++) { + if (ItemUtils.getModId(oreLimestone.get(i)) != null + && !ItemUtils.getModId(oreLimestone.get(i)) + .toLowerCase() + .contains("biomesoplenty")) { + if (!mBlockTypes.contains(Block.getBlockFromItem( + oreLimestone.get(i).getItem()))) { + mBlockTypes.add(Block.getBlockFromItem( + oreLimestone.get(i).getItem())); + } + } + } + } + if (!blockLimestone.isEmpty()) { + for (int i = 0; i < blockLimestone.size(); i++) { + if (ItemUtils.getModId(blockLimestone.get(i)) != null + && !ItemUtils.getModId(blockLimestone.get(i)) + .toLowerCase() + .contains("biomesoplenty")) { + if (!mBlockTypes.contains(Block.getBlockFromItem( + blockLimestone.get(i).getItem()))) { + mBlockTypes.add(Block.getBlockFromItem( + blockLimestone.get(i).getItem())); + } + } + } + } + + Logger.WARNING("Found Limestone in OreDict."); + if (!mBlockTypes.isEmpty()) { + Logger.WARNING("1a | " + event.block.getUnlocalizedName()); + for (final Block temp : mBlockTypes) { + Logger.WARNING("2a - " + temp.getUnlocalizedName()); + if (event.block == temp) { + Logger.WARNING("3a - found " + temp.getUnlocalizedName()); + if (MathUtils.randInt(1, chanceToDropFluoriteOre) == 1) { + Logger.WARNING("4a"); + event.drops.clear(); + event.drops.add(fluoriteOre.copy()); + } + } + } + } + } + + if (event.block.getUnlocalizedName().toLowerCase().contains("limestone")) { + Logger.WARNING("1c"); + if (MathUtils.randInt(1, chanceToDropFluoriteOre) == 1) { + Logger.WARNING("2c"); + event.drops.clear(); + event.drops.add(fluoriteOre.copy()); + } + } + + if (event.block == Blocks.sandstone) { + if (MathUtils.randInt(1, chanceToDropFluoriteOre * 20) == 1) { + event.drops.clear(); + event.drops.add(fluoriteOre.copy()); + } + } + } + } + + // Do things that can occur for fake players and real players + + // Spawn Dull Shards (Can spawn from Tree Logs, Grass or Stone. Stone going to + // be the most common source.) + if (((event.block == Blocks.stone) + || (event.block == Blocks.sandstone) + || (event.block == Blocks.log) + || (event.block == Blocks.log2) + || (event.block == Blocks.grass)) + && !LoadedMods.Thaumcraft + && (chanceToDropDrainedShard != 0)) { + // small chance for one to spawn per stone mined. 1 per 3 stacks~ + if (MathUtils.randInt(1, chanceToDropDrainedShard) == 1) { + // Let's sort out a lucky charm for the player. + final int FancyChance = MathUtils.randInt(1, 4); + if (MathUtils.randInt(1, 100) < 90) { + event.drops.add(new ItemStack(ModItems.shardDull)); + } + // Make a Fire Shard + else if (FancyChance == 1) { + event.drops.add(new ItemStack(ModItems.shardIgnis)); + } + // Make a Water Shard. + else if (FancyChance == 2) { + event.drops.add(new ItemStack(ModItems.shardAqua)); + } + // Make an Earth Shard. + else if (FancyChance == 3) { + event.drops.add(new ItemStack(ModItems.shardTerra)); + } + // Make an Air Shard. + else if (FancyChance == 4) { + event.drops.add(new ItemStack(ModItems.shardAer)); + } + } else { + Logger.WARNING("invalid chance"); + } + } + } + } + } catch (Throwable r) { + Logger.INFO("Block Event Handler Failed. Please Report this to Alkalus."); + r.printStackTrace(); + } + } + + @SubscribeEvent + public void logsHarvest(final BlockEvent.HarvestDropsEvent event) { + /* + * if (event.block instanceof BlockLog) { // + * http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/ + * modification-development/2444501-harvestdropevent-changing-drops-of-vanilla- + * blocks + * + * // Utils.sendServerMessage("Logs! Harvester: %s Drops: %s", event.harvester + * != null ? event.harvester.getCommandSenderName() : "", + * event.drops.stream().map(ItemStack.toString()).collect(Collectors. + * joining(", "))); if (event.harvester != null) { ItemStack heldItem = + * event.harvester.getHeldItem(); if (heldItem == null || + * heldItem.getItem().getHarvestLevel(heldItem, "axe") < 1) { + * event.drops.clear(); + * Utils.sendServerMessage("Harvester had wrong tool, clearing drops"); } else { + * Utils.sendServerMessage("Harvester had correct tool, not clearing drops"); } + * } else { event.drops.clear(); + * Utils.sendServerMessage("No harvester, clearing drops"); } } + */ + } } diff --git a/src/main/java/gtPlusPlus/core/handler/events/CustomMovementHandler.java b/src/main/java/gtPlusPlus/core/handler/events/CustomMovementHandler.java index b70e58d009..523b926882 100644 --- a/src/main/java/gtPlusPlus/core/handler/events/CustomMovementHandler.java +++ b/src/main/java/gtPlusPlus/core/handler/events/CustomMovementHandler.java @@ -11,153 +11,132 @@ import net.minecraft.util.MovementInputFromOptions; public class CustomMovementHandler { - public boolean isDisabled; - public boolean canDoubleTap; - - public boolean sprint = false; - public boolean sprintHeldAndReleased = false; - public boolean sprintDoubleTapped = false; - - private long lastPressed; - private long lastSprintPressed; - private boolean handledSneakPress; - private boolean handledSprintPress; - private boolean wasRiding; - - /* - * MovementInputFromOptions.updatePlayerMoveState() - */ - public void update(final Minecraft mc, final MovementInputFromOptions options, final EntityPlayerSP thisPlayer) - { - options.moveStrafe = 0.0F; - options.moveForward = 0.0F; - - final GameSettings settings = mc.gameSettings; - - if(settings.keyBindForward.getIsKeyPressed()) - { - ++options.moveForward; - } - - if(settings.keyBindBack.getIsKeyPressed()) - { - --options.moveForward; - } - - if(settings.keyBindLeft.getIsKeyPressed()) - { - ++options.moveStrafe; - } - - if(settings.keyBindRight.getIsKeyPressed()) - { - --options.moveStrafe; - } - - options.jump = settings.keyBindJump.getIsKeyPressed(); - - // - // Sneak Toggle - Essentially the same as old ToggleSneak - // - - // Check to see if Enabled - Added 6/17/14 to provide option to disable Sneak Toggle - final boolean isSneaking = SneakManager.get(thisPlayer).Sneaking(); - //Utils.LOG_INFO("Can sneak: "+isSneaking); - //Utils.LOG_INFO("Can sprint: "+SneakManager.Sprinting()); - if (isSneaking) - { - // Key Pressed - if (settings.keyBindSneak.getIsKeyPressed() && !this.handledSneakPress) - { - // Descend if we are flying, note if we were riding (so we can unsneak once dismounted) - if(thisPlayer.isRiding() || thisPlayer.capabilities.isFlying) - { - options.sneak = true; - this.wasRiding = thisPlayer.isRiding(); - } - else - { - options.sneak = !options.sneak; - } - - this.lastPressed = System.currentTimeMillis(); - this.handledSneakPress = true; - } - - // Key Released - if (!settings.keyBindSneak.getIsKeyPressed() && this.handledSneakPress) - { - // If we are flying or riding, stop sneaking after descent/dismount. - if(thisPlayer.capabilities.isFlying || this.wasRiding) - { - options.sneak = false; - this.wasRiding = false; - } - // If the key was held down for more than 300ms, stop sneaking upon release. - else if((System.currentTimeMillis() - this.lastPressed) > 300L) - { - options.sneak = false; - } - - this.handledSneakPress = false; - } - } - else - { - options.sneak = settings.keyBindSneak.getIsKeyPressed(); - } - - if(options.sneak || SneakManager.get(thisPlayer).Sneaking()) - { - options.moveStrafe = (float)(options.moveStrafe * 0.3D); - options.moveForward = (float)(options.moveForward * 0.3D); - } - - // - // Sprint Toggle - Updated 6/18/2014 - // - - // Establish conditions where we don't want to start a sprint - sneaking, riding, flying, hungry - final boolean enoughHunger = (thisPlayer.getFoodStats().getFoodLevel() > 6.0F) || thisPlayer.capabilities.isFlying; - final boolean canSprint = !options.sneak && !thisPlayer.isRiding() && !thisPlayer.capabilities.isFlying && enoughHunger; - - this.isDisabled = !SneakManager.get(thisPlayer).Sprinting(); - this.canDoubleTap = SneakManager.get(thisPlayer).optionDoubleTap; - - // Key Pressed - if((canSprint || this.isDisabled) && settings.keyBindSprint.getIsKeyPressed() && !this.handledSprintPress) - { - if(!this.isDisabled) - { - this.sprint = !this.sprint; - this.lastSprintPressed = System.currentTimeMillis(); - this.handledSprintPress = true; - this.sprintHeldAndReleased = false; - } - } - - // Key Released - if((canSprint || this.isDisabled) && !settings.keyBindSprint.getIsKeyPressed() && this.handledSprintPress) - { - // Was key held for longer than 300ms? If so, mark it so we can resume vanilla behavior - if((System.currentTimeMillis() - this.lastSprintPressed) > 300L) - { - this.sprintHeldAndReleased = true; - } - this.handledSprintPress = false; - } - - } - - public void UpdateSprint(final boolean newValue, final boolean doubleTapped, SneakManager aSneak){ - if (!aSneak.Sprinting()){ - this.sprint = false; - this.sprintDoubleTapped = doubleTapped; - } - else{ - this.sprint = newValue; - this.sprintDoubleTapped = doubleTapped; - } - } - -} \ No newline at end of file + public boolean isDisabled; + public boolean canDoubleTap; + + public boolean sprint = false; + public boolean sprintHeldAndReleased = false; + public boolean sprintDoubleTapped = false; + + private long lastPressed; + private long lastSprintPressed; + private boolean handledSneakPress; + private boolean handledSprintPress; + private boolean wasRiding; + + /* + * MovementInputFromOptions.updatePlayerMoveState() + */ + public void update(final Minecraft mc, final MovementInputFromOptions options, final EntityPlayerSP thisPlayer) { + options.moveStrafe = 0.0F; + options.moveForward = 0.0F; + + final GameSettings settings = mc.gameSettings; + + if (settings.keyBindForward.getIsKeyPressed()) { + ++options.moveForward; + } + + if (settings.keyBindBack.getIsKeyPressed()) { + --options.moveForward; + } + + if (settings.keyBindLeft.getIsKeyPressed()) { + ++options.moveStrafe; + } + + if (settings.keyBindRight.getIsKeyPressed()) { + --options.moveStrafe; + } + + options.jump = settings.keyBindJump.getIsKeyPressed(); + + // + // Sneak Toggle - Essentially the same as old ToggleSneak + // + + // Check to see if Enabled - Added 6/17/14 to provide option to disable Sneak Toggle + final boolean isSneaking = SneakManager.get(thisPlayer).Sneaking(); + // Utils.LOG_INFO("Can sneak: "+isSneaking); + // Utils.LOG_INFO("Can sprint: "+SneakManager.Sprinting()); + if (isSneaking) { + // Key Pressed + if (settings.keyBindSneak.getIsKeyPressed() && !this.handledSneakPress) { + // Descend if we are flying, note if we were riding (so we can unsneak once dismounted) + if (thisPlayer.isRiding() || thisPlayer.capabilities.isFlying) { + options.sneak = true; + this.wasRiding = thisPlayer.isRiding(); + } else { + options.sneak = !options.sneak; + } + + this.lastPressed = System.currentTimeMillis(); + this.handledSneakPress = true; + } + + // Key Released + if (!settings.keyBindSneak.getIsKeyPressed() && this.handledSneakPress) { + // If we are flying or riding, stop sneaking after descent/dismount. + if (thisPlayer.capabilities.isFlying || this.wasRiding) { + options.sneak = false; + this.wasRiding = false; + } + // If the key was held down for more than 300ms, stop sneaking upon release. + else if ((System.currentTimeMillis() - this.lastPressed) > 300L) { + options.sneak = false; + } + + this.handledSneakPress = false; + } + } else { + options.sneak = settings.keyBindSneak.getIsKeyPressed(); + } + + if (options.sneak || SneakManager.get(thisPlayer).Sneaking()) { + options.moveStrafe = (float) (options.moveStrafe * 0.3D); + options.moveForward = (float) (options.moveForward * 0.3D); + } + + // + // Sprint Toggle - Updated 6/18/2014 + // + + // Establish conditions where we don't want to start a sprint - sneaking, riding, flying, hungry + final boolean enoughHunger = + (thisPlayer.getFoodStats().getFoodLevel() > 6.0F) || thisPlayer.capabilities.isFlying; + final boolean canSprint = + !options.sneak && !thisPlayer.isRiding() && !thisPlayer.capabilities.isFlying && enoughHunger; + + this.isDisabled = !SneakManager.get(thisPlayer).Sprinting(); + this.canDoubleTap = SneakManager.get(thisPlayer).optionDoubleTap; + + // Key Pressed + if ((canSprint || this.isDisabled) && settings.keyBindSprint.getIsKeyPressed() && !this.handledSprintPress) { + if (!this.isDisabled) { + this.sprint = !this.sprint; + this.lastSprintPressed = System.currentTimeMillis(); + this.handledSprintPress = true; + this.sprintHeldAndReleased = false; + } + } + + // Key Released + if ((canSprint || this.isDisabled) && !settings.keyBindSprint.getIsKeyPressed() && this.handledSprintPress) { + // Was key held for longer than 300ms? If so, mark it so we can resume vanilla behavior + if ((System.currentTimeMillis() - this.lastSprintPressed) > 300L) { + this.sprintHeldAndReleased = true; + } + this.handledSprintPress = false; + } + } + + public void UpdateSprint(final boolean newValue, final boolean doubleTapped, SneakManager aSneak) { + if (!aSneak.Sprinting()) { + this.sprint = false; + this.sprintDoubleTapped = doubleTapped; + } else { + this.sprint = newValue; + this.sprintDoubleTapped = doubleTapped; + } + } +} diff --git a/src/main/java/gtPlusPlus/core/handler/events/EnderDragonDeathHandler.java b/src/main/java/gtPlusPlus/core/handler/events/EnderDragonDeathHandler.java index 967a51fad6..fd88d735e8 100644 --- a/src/main/java/gtPlusPlus/core/handler/events/EnderDragonDeathHandler.java +++ b/src/main/java/gtPlusPlus/core/handler/events/EnderDragonDeathHandler.java @@ -10,51 +10,52 @@ import net.minecraftforge.event.entity.living.LivingDropsEvent; public class EnderDragonDeathHandler { - private static final String mDragonClassName = "chylex.hee.entity.boss.EntityBossDragon"; - private static final boolean mHEE; - private static final Class mHardcoreDragonClass; - - private static final String mChaosDragonClassName = "com.brandon3055.draconicevolution.common.entity.EntityCustomDragon"; - private static final boolean mDE; - private static final Class mChaoseDragonClass; - - static { - mHEE = ReflectionUtils.doesClassExist(mDragonClassName); - mHardcoreDragonClass = (mHEE ? ReflectionUtils.getClass(mDragonClassName) : null); - mDE = ReflectionUtils.doesClassExist(mChaosDragonClassName); - mChaoseDragonClass = (mDE ? ReflectionUtils.getClass(mChaosDragonClassName) : null); - } - - @SubscribeEvent - public void onEntityDrop(LivingDropsEvent event) { - - int aCountTotal = 0; - - if (mHEE && mHardcoreDragonClass != null && mHardcoreDragonClass.isInstance(event.entityLiving)) { - for (int y = 0; y < MathUtils.randInt(100, 250); y++) { - int aAmount = MathUtils.randInt(5, 25); - event.entityLiving.entityDropItem(ELEMENT.STANDALONE.DRAGON_METAL.getNugget(aAmount), MathUtils.randFloat(0, 1)); - aCountTotal = +aAmount; - } - } - else if (mDE && mChaoseDragonClass != null && mChaoseDragonClass.isInstance(event.entityLiving)) { - for (int y = 0; y < MathUtils.randInt(100, 200); y++) { - int aAmount = MathUtils.randInt(1, 5); - event.entityLiving.entityDropItem(ELEMENT.STANDALONE.DRAGON_METAL.getIngot(aAmount), MathUtils.randFloat(0, 1)); - aCountTotal = +aAmount; - } - } - else if (event.entityLiving instanceof EntityDragon) { - for (int y = 0; y < MathUtils.randInt(25, 50); y++) { - int aAmount = MathUtils.randInt(1, 10); - event.entityLiving.entityDropItem(ELEMENT.STANDALONE.DRAGON_METAL.getNugget(aAmount), MathUtils.randFloat(0, 1)); - aCountTotal = +aAmount; - } - } - if (aCountTotal > 0) { - PlayerUtils.messageAllPlayers(aCountTotal + " Shards of Dragons Blood have crystalized into a metallic form."); - } - - } - + private static final String mDragonClassName = "chylex.hee.entity.boss.EntityBossDragon"; + private static final boolean mHEE; + private static final Class mHardcoreDragonClass; + + private static final String mChaosDragonClassName = + "com.brandon3055.draconicevolution.common.entity.EntityCustomDragon"; + private static final boolean mDE; + private static final Class mChaoseDragonClass; + + static { + mHEE = ReflectionUtils.doesClassExist(mDragonClassName); + mHardcoreDragonClass = (mHEE ? ReflectionUtils.getClass(mDragonClassName) : null); + mDE = ReflectionUtils.doesClassExist(mChaosDragonClassName); + mChaoseDragonClass = (mDE ? ReflectionUtils.getClass(mChaosDragonClassName) : null); + } + + @SubscribeEvent + public void onEntityDrop(LivingDropsEvent event) { + + int aCountTotal = 0; + + if (mHEE && mHardcoreDragonClass != null && mHardcoreDragonClass.isInstance(event.entityLiving)) { + for (int y = 0; y < MathUtils.randInt(100, 250); y++) { + int aAmount = MathUtils.randInt(5, 25); + event.entityLiving.entityDropItem( + ELEMENT.STANDALONE.DRAGON_METAL.getNugget(aAmount), MathUtils.randFloat(0, 1)); + aCountTotal = +aAmount; + } + } else if (mDE && mChaoseDragonClass != null && mChaoseDragonClass.isInstance(event.entityLiving)) { + for (int y = 0; y < MathUtils.randInt(100, 200); y++) { + int aAmount = MathUtils.randInt(1, 5); + event.entityLiving.entityDropItem( + ELEMENT.STANDALONE.DRAGON_METAL.getIngot(aAmount), MathUtils.randFloat(0, 1)); + aCountTotal = +aAmount; + } + } else if (event.entityLiving instanceof EntityDragon) { + for (int y = 0; y < MathUtils.randInt(25, 50); y++) { + int aAmount = MathUtils.randInt(1, 10); + event.entityLiving.entityDropItem( + ELEMENT.STANDALONE.DRAGON_METAL.getNugget(aAmount), MathUtils.randFloat(0, 1)); + aCountTotal = +aAmount; + } + } + if (aCountTotal > 0) { + PlayerUtils.messageAllPlayers( + aCountTotal + " Shards of Dragons Blood have crystalized into a metallic form."); + } + } } diff --git a/src/main/java/gtPlusPlus/core/handler/events/EntityDeathHandler.java b/src/main/java/gtPlusPlus/core/handler/events/EntityDeathHandler.java index 391672e028..9548d80f62 100644 --- a/src/main/java/gtPlusPlus/core/handler/events/EntityDeathHandler.java +++ b/src/main/java/gtPlusPlus/core/handler/events/EntityDeathHandler.java @@ -1,8 +1,5 @@ package gtPlusPlus.core.handler.events; -import java.util.HashMap; -import java.util.HashSet; - import cpw.mods.fml.common.eventhandler.SubscribeEvent; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; @@ -11,6 +8,8 @@ import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; +import java.util.HashMap; +import java.util.HashSet; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -18,107 +17,107 @@ import net.minecraftforge.event.entity.living.LivingDropsEvent; public class EntityDeathHandler { - - private static final HashMap>> mMobDropMap = new HashMap>>(); - private static final HashSet mInternalClassKeyCache = new HashSet(); - - /** - * Provides the ability to provide custom drops upon the death of EntityLivingBase objects. - * @param aMobClass - The Base Class you want to drop this item. - * @param aStack - The ItemStack, stack size is not respected. - * @param aMaxAmount - The maximum size of the ItemStack which drops. - * @param aChance - Chance out of 10000, where 100 is 1%. (1 = 0.01% - this is ok) - */ - public static void registerDropsForMob(Class aMobClass, ItemStack aStack, int aMaxAmount, int aChance) { - Triplet aData = new Triplet(aStack, aMaxAmount, aChance); - AutoMap> aDataMap = mMobDropMap.get(aMobClass); - if (aDataMap == null) { - aDataMap = new AutoMap>(); - } - aDataMap.put(aData); - mMobDropMap.put(aMobClass, aDataMap); - - Logger.INFO("[Loot] Registered "+aStack.getDisplayName()+" (1-"+aMaxAmount+") as a valid drop for "+aMobClass.getCanonicalName()); - - if (!mInternalClassKeyCache.contains(aMobClass)) { - mInternalClassKeyCache.add(aMobClass); - } - - } - - private static ItemStack processItemDropTriplet(Triplet aData) { - ItemStack aLoot = aData.getValue_1(); - int aMaxDrop = aData.getValue_2(); - int aChanceOutOf10000 = aData.getValue_3(); - if (MathUtils.randInt(0, 10000) <= aChanceOutOf10000) { - aLoot = ItemUtils.getSimpleStack(aLoot, MathUtils.randInt(1, aMaxDrop)); - if (ItemUtils.checkForInvalidItems(aLoot)) { - return aLoot; - } - } - return null; - } - - private static boolean processDropsForMob(EntityLivingBase entityLiving) { - AutoMap> aMobData = mMobDropMap.get(entityLiving.getClass()); - boolean aDidDrop = false; - if (aMobData != null) { - if (!aMobData.isEmpty()) { - ItemStack aPossibleDrop; - for (Triplet g : aMobData) { - aPossibleDrop = processItemDropTriplet(g); - if (aPossibleDrop != null) { - if (entityLiving.entityDropItem(aPossibleDrop, MathUtils.randFloat(0, 1)) != null) { - aDidDrop = true; - } - } - } - } - } - return aDidDrop; - } - - - - private static void dropMeatFromPlayer(EntityPlayer aPlayer) { - - // always drop some meat. - int aBigMeatStackSize1 = MathUtils.randInt(4, 8); - aPlayer.entityDropItem(ItemUtils.simpleMetaStack(ModItems.itemMetaFood, 0, aBigMeatStackSize1), MathUtils.randInt(0, 1)); - - // additional chances for more meat. - if (MathUtils.randInt(0, 10) < 7) { - int aBigMeatStackSize2 = MathUtils.randInt(4, 8); - aPlayer.entityDropItem(ItemUtils.simpleMetaStack(ModItems.itemMetaFood, 0, aBigMeatStackSize2), MathUtils.randInt(0, 1)); - } - if (MathUtils.randInt(0, 10) < 4) { - int aBigMeatStackSize3 = MathUtils.randInt(4, 8); - aPlayer.entityDropItem(ItemUtils.simpleMetaStack(ModItems.itemMetaFood, 0, aBigMeatStackSize3), MathUtils.randInt(0, 1)); - } - if (MathUtils.randInt(0, 10) < 2) { - int aBigMeatStackSize4 = MathUtils.randInt(4, 8); - aPlayer.entityDropItem(ItemUtils.simpleMetaStack(ModItems.itemMetaFood, 0, aBigMeatStackSize4), MathUtils.randInt(0, 1)); - } - - } - - @SubscribeEvent - public void onEntityDrop(LivingDropsEvent event) { - boolean aDidDrop = false; - if (event == null || event.entityLiving == null) { - return; - } - if (PlayerUtils.isRealPlayer(event.entityLiving)) { - EntityPlayer aPlayer = (EntityPlayer) event.entityLiving; - dropMeatFromPlayer(aPlayer); - } - else { - for (Class c : mInternalClassKeyCache) { - if (c.isInstance(event.entityLiving)) { - aDidDrop = processDropsForMob(event.entityLiving); - } - } - } - } - + private static final HashMap>> mMobDropMap = + new HashMap>>(); + private static final HashSet mInternalClassKeyCache = new HashSet(); + + /** + * Provides the ability to provide custom drops upon the death of EntityLivingBase objects. + * @param aMobClass - The Base Class you want to drop this item. + * @param aStack - The ItemStack, stack size is not respected. + * @param aMaxAmount - The maximum size of the ItemStack which drops. + * @param aChance - Chance out of 10000, where 100 is 1%. (1 = 0.01% - this is ok) + */ + public static void registerDropsForMob(Class aMobClass, ItemStack aStack, int aMaxAmount, int aChance) { + Triplet aData = + new Triplet(aStack, aMaxAmount, aChance); + AutoMap> aDataMap = mMobDropMap.get(aMobClass); + if (aDataMap == null) { + aDataMap = new AutoMap>(); + } + aDataMap.put(aData); + mMobDropMap.put(aMobClass, aDataMap); + + Logger.INFO("[Loot] Registered " + aStack.getDisplayName() + " (1-" + aMaxAmount + ") as a valid drop for " + + aMobClass.getCanonicalName()); + + if (!mInternalClassKeyCache.contains(aMobClass)) { + mInternalClassKeyCache.add(aMobClass); + } + } + + private static ItemStack processItemDropTriplet(Triplet aData) { + ItemStack aLoot = aData.getValue_1(); + int aMaxDrop = aData.getValue_2(); + int aChanceOutOf10000 = aData.getValue_3(); + if (MathUtils.randInt(0, 10000) <= aChanceOutOf10000) { + aLoot = ItemUtils.getSimpleStack(aLoot, MathUtils.randInt(1, aMaxDrop)); + if (ItemUtils.checkForInvalidItems(aLoot)) { + return aLoot; + } + } + return null; + } + + private static boolean processDropsForMob(EntityLivingBase entityLiving) { + AutoMap> aMobData = mMobDropMap.get(entityLiving.getClass()); + boolean aDidDrop = false; + if (aMobData != null) { + if (!aMobData.isEmpty()) { + ItemStack aPossibleDrop; + for (Triplet g : aMobData) { + aPossibleDrop = processItemDropTriplet(g); + if (aPossibleDrop != null) { + if (entityLiving.entityDropItem(aPossibleDrop, MathUtils.randFloat(0, 1)) != null) { + aDidDrop = true; + } + } + } + } + } + return aDidDrop; + } + + private static void dropMeatFromPlayer(EntityPlayer aPlayer) { + + // always drop some meat. + int aBigMeatStackSize1 = MathUtils.randInt(4, 8); + aPlayer.entityDropItem( + ItemUtils.simpleMetaStack(ModItems.itemMetaFood, 0, aBigMeatStackSize1), MathUtils.randInt(0, 1)); + + // additional chances for more meat. + if (MathUtils.randInt(0, 10) < 7) { + int aBigMeatStackSize2 = MathUtils.randInt(4, 8); + aPlayer.entityDropItem( + ItemUtils.simpleMetaStack(ModItems.itemMetaFood, 0, aBigMeatStackSize2), MathUtils.randInt(0, 1)); + } + if (MathUtils.randInt(0, 10) < 4) { + int aBigMeatStackSize3 = MathUtils.randInt(4, 8); + aPlayer.entityDropItem( + ItemUtils.simpleMetaStack(ModItems.itemMetaFood, 0, aBigMeatStackSize3), MathUtils.randInt(0, 1)); + } + if (MathUtils.randInt(0, 10) < 2) { + int aBigMeatStackSize4 = MathUtils.randInt(4, 8); + aPlayer.entityDropItem( + ItemUtils.simpleMetaStack(ModItems.itemMetaFood, 0, aBigMeatStackSize4), MathUtils.randInt(0, 1)); + } + } + + @SubscribeEvent + public void onEntityDrop(LivingDropsEvent event) { + boolean aDidDrop = false; + if (event == null || event.entityLiving == null) { + return; + } + if (PlayerUtils.isRealPlayer(event.entityLiving)) { + EntityPlayer aPlayer = (EntityPlayer) event.entityLiving; + dropMeatFromPlayer(aPlayer); + } else { + for (Class c : mInternalClassKeyCache) { + if (c.isInstance(event.entityLiving)) { + aDidDrop = processDropsForMob(event.entityLiving); + } + } + } + } } diff --git a/src/main/java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java b/src/main/java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java index de3e958b2d..074c03e75f 100644 --- a/src/main/java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java +++ b/src/main/java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java @@ -1,7 +1,5 @@ package gtPlusPlus.core.handler.events; -import static gregtech.api.enums.GT_Values.MOD_ID_APC; - import advsolar.common.AdvancedSolarPanel; import cpw.mods.fml.common.Optional; import cpw.mods.fml.common.eventhandler.SubscribeEvent; @@ -23,112 +21,126 @@ import net.minecraftforge.event.entity.player.ItemTooltipEvent; public class GeneralTooltipEventHandler { - ItemStack[] mGregtechTurbines = new ItemStack[6]; - String mTurbine; - String mExtra; - - @SubscribeEvent - public void onItemTooltip(ItemTooltipEvent event){ - - - if (GTplusplus.CURRENT_LOAD_PHASE != INIT_PHASE.STARTED && GTplusplus.CURRENT_LOAD_PHASE != INIT_PHASE.SERVER_START) { - return; - } - if (event.itemStack == null) { - return; - } - if (CORE.ConfigSwitches.chanceToDropFluoriteOre > 0) { - if (BlockEventHandler.blockLimestone != null && !BlockEventHandler.blockLimestone.isEmpty()) { - for (ItemStack h : BlockEventHandler.blockLimestone) { - if (h != null && Block.getBlockFromItem(h.getItem()) == Block.getBlockFromItem(event.itemStack.getItem())) { - if (ItemUtils.getModId(h) != null && !ItemUtils.getModId(h).toLowerCase().contains("biomesoplenty")) { - event.toolTip.add("May contain Fluorite Ore"); - } - } - } - } - if (BlockEventHandler.oreLimestone != null && !BlockEventHandler.oreLimestone.isEmpty()) { - for (ItemStack h : BlockEventHandler.oreLimestone) { - if (h != null && Block.getBlockFromItem(h.getItem()) == Block.getBlockFromItem(event.itemStack.getItem())) { - if (ItemUtils.getModId(h) != null && !ItemUtils.getModId(h).toLowerCase().contains("biomesoplenty")) { - event.toolTip.add("May contain Fluorite Ore"); - } - } - } - } - } - - //Material Collector Tooltips - if (ModBlocks.blockPooCollector != null && Block.getBlockFromItem(event.itemStack.getItem()) == ModBlocks.blockPooCollector) { - //Normal - if (event.itemStack.getItemDamage() == 0) { - event.toolTip.add("Used to collect animal waste"); - event.toolTip.add("Collects in a 5x4x5 area starting at Y+1"); - event.toolTip.add("Use Hoppers/Pipes to empty"); - event.toolTip.add(EnumChatFormatting.GOLD+"Capacity: "+EnumChatFormatting.AQUA+"8000L"); - } - //Advanced - else { - event.toolTip.add("Used to collect waste (Works on more than animals)"); - event.toolTip.add("Significantly faster than the simple version"); - event.toolTip.add("Collects in a 5x4x5 area starting at Y+1"); - event.toolTip.add("Use Hoppers/Pipes to empty"); - event.toolTip.add(EnumChatFormatting.GOLD+"Capacity: "+EnumChatFormatting.AQUA+"128000L"); - } - } - - // Custom Flasks - - if (GregtechItemList.VOLUMETRIC_FLASK_8k.hasBeenSet() && event.itemStack.getItem() == GregtechItemList.VOLUMETRIC_FLASK_8k.getItem()) { - event.toolTip.add("Max Capacity: "+MathUtils.formatNumbers(8000)+"L"); - } - if (GregtechItemList.VOLUMETRIC_FLASK_32k.hasBeenSet() && event.itemStack.getItem() == GregtechItemList.VOLUMETRIC_FLASK_32k.getItem()) { - event.toolTip.add("Max Capacity: "+MathUtils.formatNumbers(32000)+"L"); - } - - if (LoadedMods.AdvancedSolarPanel) { - molecularTransformer(event); - } - - - if (CORE.ConfigSwitches.enableAnimatedTurbines) { - boolean shift = false; - try { - - if (KeyboardUtils.isShiftKeyDown()) { - shift = true; - mTurbine = "Animated Turbines can be disabled in the GT++ config"; - } - else { - mTurbine = EnumChatFormatting.ITALIC+""+EnumChatFormatting.RESET; - } - for (int t=0;t<6;t++) { - if (mGregtechTurbines[t] != null) { - if (ItemStack.areItemStacksEqual(event.itemStack, mGregtechTurbines[t])){ - event.toolTip.add(mTurbine); - if (shift) { - if (mExtra == null) { - mExtra = CORE.GT_Tooltip; - } - event.toolTip.add(mExtra); - } - } - } - else { - mGregtechTurbines[t] = (t == 0 ? ItemList.Generator_Steam_Turbine_LV.get(1) : (t == 1 ? ItemList.Generator_Steam_Turbine_MV.get(1) : (t == 2 ? ItemList.Generator_Steam_Turbine_HV.get(1) : (t == 3 ? ItemList.Generator_Gas_Turbine_LV.get(1) : (t == 4 ? ItemList.Generator_Gas_Turbine_MV.get(1) : (ItemList.Generator_Gas_Turbine_HV.get(1))))))); - } - } - } - catch (Throwable t) {} - } - - } + ItemStack[] mGregtechTurbines = new ItemStack[6]; + String mTurbine; + String mExtra; + + @SubscribeEvent + public void onItemTooltip(ItemTooltipEvent event) { + + if (GTplusplus.CURRENT_LOAD_PHASE != INIT_PHASE.STARTED + && GTplusplus.CURRENT_LOAD_PHASE != INIT_PHASE.SERVER_START) { + return; + } + if (event.itemStack == null) { + return; + } + if (CORE.ConfigSwitches.chanceToDropFluoriteOre > 0) { + if (BlockEventHandler.blockLimestone != null && !BlockEventHandler.blockLimestone.isEmpty()) { + for (ItemStack h : BlockEventHandler.blockLimestone) { + if (h != null + && Block.getBlockFromItem(h.getItem()) + == Block.getBlockFromItem(event.itemStack.getItem())) { + if (ItemUtils.getModId(h) != null + && !ItemUtils.getModId(h).toLowerCase().contains("biomesoplenty")) { + event.toolTip.add("May contain Fluorite Ore"); + } + } + } + } + if (BlockEventHandler.oreLimestone != null && !BlockEventHandler.oreLimestone.isEmpty()) { + for (ItemStack h : BlockEventHandler.oreLimestone) { + if (h != null + && Block.getBlockFromItem(h.getItem()) + == Block.getBlockFromItem(event.itemStack.getItem())) { + if (ItemUtils.getModId(h) != null + && !ItemUtils.getModId(h).toLowerCase().contains("biomesoplenty")) { + event.toolTip.add("May contain Fluorite Ore"); + } + } + } + } + } + + // Material Collector Tooltips + if (ModBlocks.blockPooCollector != null + && Block.getBlockFromItem(event.itemStack.getItem()) == ModBlocks.blockPooCollector) { + // Normal + if (event.itemStack.getItemDamage() == 0) { + event.toolTip.add("Used to collect animal waste"); + event.toolTip.add("Collects in a 5x4x5 area starting at Y+1"); + event.toolTip.add("Use Hoppers/Pipes to empty"); + event.toolTip.add(EnumChatFormatting.GOLD + "Capacity: " + EnumChatFormatting.AQUA + "8000L"); + } + // Advanced + else { + event.toolTip.add("Used to collect waste (Works on more than animals)"); + event.toolTip.add("Significantly faster than the simple version"); + event.toolTip.add("Collects in a 5x4x5 area starting at Y+1"); + event.toolTip.add("Use Hoppers/Pipes to empty"); + event.toolTip.add(EnumChatFormatting.GOLD + "Capacity: " + EnumChatFormatting.AQUA + "128000L"); + } + } + + // Custom Flasks + + if (GregtechItemList.VOLUMETRIC_FLASK_8k.hasBeenSet() + && event.itemStack.getItem() == GregtechItemList.VOLUMETRIC_FLASK_8k.getItem()) { + event.toolTip.add("Max Capacity: " + MathUtils.formatNumbers(8000) + "L"); + } + if (GregtechItemList.VOLUMETRIC_FLASK_32k.hasBeenSet() + && event.itemStack.getItem() == GregtechItemList.VOLUMETRIC_FLASK_32k.getItem()) { + event.toolTip.add("Max Capacity: " + MathUtils.formatNumbers(32000) + "L"); + } + + if (LoadedMods.AdvancedSolarPanel) { + molecularTransformer(event); + } + + if (CORE.ConfigSwitches.enableAnimatedTurbines) { + boolean shift = false; + try { + + if (KeyboardUtils.isShiftKeyDown()) { + shift = true; + mTurbine = "Animated Turbines can be disabled in the GT++ config"; + } else { + mTurbine = EnumChatFormatting.ITALIC + "" + EnumChatFormatting.RESET; + } + for (int t = 0; t < 6; t++) { + if (mGregtechTurbines[t] != null) { + if (ItemStack.areItemStacksEqual(event.itemStack, mGregtechTurbines[t])) { + event.toolTip.add(mTurbine); + if (shift) { + if (mExtra == null) { + mExtra = CORE.GT_Tooltip; + } + event.toolTip.add(mExtra); + } + } + } else { + mGregtechTurbines[t] = (t == 0 + ? ItemList.Generator_Steam_Turbine_LV.get(1) + : (t == 1 + ? ItemList.Generator_Steam_Turbine_MV.get(1) + : (t == 2 + ? ItemList.Generator_Steam_Turbine_HV.get(1) + : (t == 3 + ? ItemList.Generator_Gas_Turbine_LV.get(1) + : (t == 4 + ? ItemList.Generator_Gas_Turbine_MV.get(1) + : (ItemList.Generator_Gas_Turbine_HV.get(1))))))); + } + } + } catch (Throwable t) { + } + } + } @Optional.Method(modid = "AdvancedSolarPanel") - public static void molecularTransformer(ItemTooltipEvent event) { - if (event.itemStack.getItem() == Item.getItemFromBlock(AdvancedSolarPanel.blockMolecularTransformer)) { - event.toolTip.add(""+EnumChatFormatting.RED+"Disabled, Use the multiblock"); - } - } - + public static void molecularTransformer(ItemTooltipEvent event) { + if (event.itemStack.getItem() == Item.getItemFromBlock(AdvancedSolarPanel.blockMolecularTransformer)) { + event.toolTip.add("" + EnumChatFormatting.RED + "Disabled, Use the multiblock"); + } + } } diff --git a/src/main/java/gtPlusPlus/core/handler/events/LoginEventHandler.java b/src/main/java/gtPlusPlus/core/handler/events/LoginEventHandler.java index 1a8d87882e..c03fbd7ff6 100644 --- a/src/main/java/gtPlusPlus/core/handler/events/LoginEventHandler.java +++ b/src/main/java/gtPlusPlus/core/handler/events/LoginEventHandler.java @@ -1,128 +1,119 @@ package gtPlusPlus.core.handler.events; -import java.util.Timer; -import java.util.TimerTask; -import java.util.UUID; - import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.PlayerEvent; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; - import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.proxy.ClientProxy; -import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.core.util.player.PlayerCache; +import java.util.Timer; +import java.util.TimerTask; +import java.util.UUID; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; public class LoginEventHandler { - public String localPlayersName; - public UUID localPlayersUUID; - private EntityPlayer localPlayerRef; - - @SubscribeEvent - public void onPlayerLogin(final PlayerEvent.PlayerLoggedInEvent event) { - - this.localPlayerRef = event.player; - this.localPlayersName = event.player.getDisplayName(); - this.localPlayersUUID = event.player.getUniqueID(); - - //Set this for easier use elsewhere. - if (event.player.getEntityWorld().isRemote){ - ClientProxy.playerName = this.localPlayersName; - } - - try { - //new SegmentAnalytics(event.player); - } - catch (Throwable t){ - //SegmentAnalytics.LOG("Failed to create Analytics submission during log in process."); - } - - try { - - - if (this.localPlayerRef instanceof EntityPlayerMP){ - - //Populates player cache - if (!this.localPlayerRef.worldObj.isRemote){ - PlayerCache.appendParamChanges(this.localPlayersName, this.localPlayersUUID.toString()); - } - - - /*if (localPlayerRef.getCommandSenderName().toLowerCase().equalsIgnoreCase("ImQ009") || localPlayerRef.getCommandSenderName().toLowerCase().contains("player")){ - Utils.LOG_INFO("Spawning a new Santa Thread."); - Thread t = new Thread() { - UUID threadHandlerIDthing = localPlayersUUID; - @Override - public void run() { - while(true && Minecraft.getMinecraft().getIntegratedServer() != null) { - try { - if(localPlayerRef == null){ - localPlayerRef = Utils.getPlayerOnServerFromUUID(threadHandlerIDthing); - } - - - //ImQ009 is a legend. - if (localPlayerRef.getCommandSenderName().toLowerCase().equalsIgnoreCase("ImQ009")){ - Utils.messagePlayer(localPlayerRef, "Enjoy some complimentary Raisin Bread."); - localPlayerRef.inventory.addItemStackToInventory(UtilsItems.getSimpleStack(ModItems.itemIngotRaisinBread, MathUtils.randInt(1, 5))); - } - - - if (localPlayerRef.getCommandSenderName().toLowerCase().contains("player")){ - Utils.messagePlayer(localPlayerRef, "Enjoy some complimentary Raisin Bread."); - localPlayerRef.inventory.addItemStackToInventory(UtilsItems.getSimpleStack(ModItems.itemIngotRaisinBread, MathUtils.randInt(1, 5))); - } - Thread.sleep(1000*60*MathUtils.randInt(15, 90)); - } catch (InterruptedException ie) { - Utils.LOG_INFO("Santa Mode Disabled."); - } - } - - Utils.LOG_INFO("Thread Stopped. Handler Closed."); - - } - }; - //t.start(); - - - }*/ - - - } - } catch (final Throwable errr){ - Logger.INFO("Login Handler encountered an error."); - - } - } - - //Handles notifying the player about a version update. - public Timer ShortTimer(EntityPlayer localPlayer, final int seconds) { - Timer timer; - timer = new Timer(); - timer.schedule(new NotifyPlayer(localPlayer), seconds * 1000); - return timer; - } - - //Timer Task for notifying the player. - class NotifyPlayer extends TimerTask { - final EntityPlayer toMessage; - public NotifyPlayer(EntityPlayer localPlayer) { - toMessage = localPlayer; - } - - @Override - public void run() { - if (toMessage != null){ - if (toMessage instanceof EntityPlayerMP){ - PlayerUtils.messagePlayer(toMessage, "You're not using the latest recommended version of GT++, consider updating."); - } - } - } - } - -} \ No newline at end of file + public String localPlayersName; + public UUID localPlayersUUID; + private EntityPlayer localPlayerRef; + + @SubscribeEvent + public void onPlayerLogin(final PlayerEvent.PlayerLoggedInEvent event) { + + this.localPlayerRef = event.player; + this.localPlayersName = event.player.getDisplayName(); + this.localPlayersUUID = event.player.getUniqueID(); + + // Set this for easier use elsewhere. + if (event.player.getEntityWorld().isRemote) { + ClientProxy.playerName = this.localPlayersName; + } + + try { + // new SegmentAnalytics(event.player); + } catch (Throwable t) { + // SegmentAnalytics.LOG("Failed to create Analytics submission during log in process."); + } + + try { + + if (this.localPlayerRef instanceof EntityPlayerMP) { + + // Populates player cache + if (!this.localPlayerRef.worldObj.isRemote) { + PlayerCache.appendParamChanges(this.localPlayersName, this.localPlayersUUID.toString()); + } + + /*if (localPlayerRef.getCommandSenderName().toLowerCase().equalsIgnoreCase("ImQ009") || localPlayerRef.getCommandSenderName().toLowerCase().contains("player")){ + Utils.LOG_INFO("Spawning a new Santa Thread."); + Thread t = new Thread() { + UUID threadHandlerIDthing = localPlayersUUID; + @Override + public void run() { + while(true && Minecraft.getMinecraft().getIntegratedServer() != null) { + try { + if(localPlayerRef == null){ + localPlayerRef = Utils.getPlayerOnServerFromUUID(threadHandlerIDthing); + } + + + //ImQ009 is a legend. + if (localPlayerRef.getCommandSenderName().toLowerCase().equalsIgnoreCase("ImQ009")){ + Utils.messagePlayer(localPlayerRef, "Enjoy some complimentary Raisin Bread."); + localPlayerRef.inventory.addItemStackToInventory(UtilsItems.getSimpleStack(ModItems.itemIngotRaisinBread, MathUtils.randInt(1, 5))); + } + + + if (localPlayerRef.getCommandSenderName().toLowerCase().contains("player")){ + Utils.messagePlayer(localPlayerRef, "Enjoy some complimentary Raisin Bread."); + localPlayerRef.inventory.addItemStackToInventory(UtilsItems.getSimpleStack(ModItems.itemIngotRaisinBread, MathUtils.randInt(1, 5))); + } + Thread.sleep(1000*60*MathUtils.randInt(15, 90)); + } catch (InterruptedException ie) { + Utils.LOG_INFO("Santa Mode Disabled."); + } + } + + Utils.LOG_INFO("Thread Stopped. Handler Closed."); + + } + }; + //t.start(); + + + }*/ + + } + } catch (final Throwable errr) { + Logger.INFO("Login Handler encountered an error."); + } + } + + // Handles notifying the player about a version update. + public Timer ShortTimer(EntityPlayer localPlayer, final int seconds) { + Timer timer; + timer = new Timer(); + timer.schedule(new NotifyPlayer(localPlayer), seconds * 1000); + return timer; + } + + // Timer Task for notifying the player. + class NotifyPlayer extends TimerTask { + final EntityPlayer toMessage; + + public NotifyPlayer(EntityPlayer localPlayer) { + toMessage = localPlayer; + } + + @Override + public void run() { + if (toMessage != null) { + if (toMessage instanceof EntityPlayerMP) { + PlayerUtils.messagePlayer( + toMessage, "You're not using the latest recommended version of GT++, consider updating."); + } + } + } + } +} diff --git a/src/main/java/gtPlusPlus/core/handler/events/MissingMappingsEvent.java b/src/main/java/gtPlusPlus/core/handler/events/MissingMappingsEvent.java index 31600a36c3..e4535cb6e1 100644 --- a/src/main/java/gtPlusPlus/core/handler/events/MissingMappingsEvent.java +++ b/src/main/java/gtPlusPlus/core/handler/events/MissingMappingsEvent.java @@ -2,55 +2,50 @@ package gtPlusPlus.core.handler.events; import static gtPlusPlus.core.item.base.dusts.BaseItemDustEx.mCachedPileLinkages; -import org.apache.commons.lang3.StringUtils; - import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLMissingMappingsEvent; import cpw.mods.fml.common.event.FMLMissingMappingsEvent.MissingMapping; - -import net.minecraft.item.ItemStack; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; +import net.minecraft.item.ItemStack; +import org.apache.commons.lang3.StringUtils; public class MissingMappingsEvent { - @EventHandler - public void onMissingMapping(FMLMissingMappingsEvent event){ - for(MissingMapping mapping : event.get()) { - boolean bool1 = mapping.name.contains(CORE.MODID); - //Missing Blocks - if(mapping.type == cpw.mods.fml.common.registry.GameRegistry.Type.BLOCK && bool1) { - - //Example - //if(mapping.name.equals("PneumaticCraft:etchingAcid")) { - // mapping.remap(Fluids.etchingAcid.getBlock()); - //} - - - } - - //Missing Items - if(mapping.type == cpw.mods.fml.common.registry.GameRegistry.Type.ITEM && bool1) { - - //Example - //if(mapping.name.equals("PneumaticCraft:etchingAcidBucket")) { - // mapping.remap(Fluids.getBucket(Fluids.etchingAcid)); - //} - - if(mapping.name.contains("miscutils:itemDustTiny")) { - ItemStack stack = null; - String missingItemString = StringUtils.remove(mapping.name, "miscutils:itemDustTiny"); - missingItemString = StringUtils.prependIfMissing(missingItemString, "item.itemDust"); - if (mCachedPileLinkages.containsKey(missingItemString)) { - //stack = ItemUtils.getSimpleStack(Item.itemRegistry.) - Logger.REFLECTION("Mapping Event Found Missing Item in the Pile Linkage Cache."); - } - - //mapping.remap(stack.getItem()); - } - - } - } - } + @EventHandler + public void onMissingMapping(FMLMissingMappingsEvent event) { + for (MissingMapping mapping : event.get()) { + boolean bool1 = mapping.name.contains(CORE.MODID); + // Missing Blocks + if (mapping.type == cpw.mods.fml.common.registry.GameRegistry.Type.BLOCK && bool1) { + + // Example + // if(mapping.name.equals("PneumaticCraft:etchingAcid")) { + // mapping.remap(Fluids.etchingAcid.getBlock()); + // } + + } + + // Missing Items + if (mapping.type == cpw.mods.fml.common.registry.GameRegistry.Type.ITEM && bool1) { + + // Example + // if(mapping.name.equals("PneumaticCraft:etchingAcidBucket")) { + // mapping.remap(Fluids.getBucket(Fluids.etchingAcid)); + // } + + if (mapping.name.contains("miscutils:itemDustTiny")) { + ItemStack stack = null; + String missingItemString = StringUtils.remove(mapping.name, "miscutils:itemDustTiny"); + missingItemString = StringUtils.prependIfMissing(missingItemString, "item.itemDust"); + if (mCachedPileLinkages.containsKey(missingItemString)) { + // stack = ItemUtils.getSimpleStack(Item.itemRegistry.) + Logger.REFLECTION("Mapping Event Found Missing Item in the Pile Linkage Cache."); + } + + // mapping.remap(stack.getItem()); + } + } + } + } } diff --git a/src/main/java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java b/src/main/java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java index 956d045b3e..0c8470fa3b 100644 --- a/src/main/java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java +++ b/src/main/java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java @@ -1,80 +1,82 @@ package gtPlusPlus.core.handler.events; -import java.util.List; -import java.util.UUID; - import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.ChunkPosition; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.metatileentity.BaseMetaTileEntity; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.machines.GregtechMetaSafeBlockBase; +import java.util.List; +import java.util.UUID; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.ChunkPosition; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.world.BlockEvent.BreakEvent; import net.minecraftforge.event.world.ExplosionEvent; public class PickaxeBlockBreakEventHandler { - @SubscribeEvent - public void onBreakBlock(final BreakEvent event) { - try{ - final TileEntity entity = event.world.getTileEntity(event.x, event.y, event.z); - if (entity != null){ - if (entity instanceof BaseMetaTileEntity) { - final EntityPlayer playerInternal = event.getPlayer(); - final IMetaTileEntity X = ((BaseMetaTileEntity)entity).getMetaTileEntity(); - if(X instanceof GregtechMetaSafeBlockBase) { - final UUID ownerUUID = ((GregtechMetaSafeBlockBase)X).ownerUUID; - final UUID accessorUUID = playerInternal.getUniqueID(); - if (((GregtechMetaSafeBlockBase)X).bUnbreakable){ - if (accessorUUID == ownerUUID){ - PlayerUtils.messagePlayer(playerInternal, "Since you own this block, it has been destroyed."); - } - else { - PlayerUtils.messagePlayer(playerInternal, "Since you do not own this block, it has not been destroyed."); - event.setCanceled(true); - } - } - } - } - - } - } - catch (final NullPointerException e) { - //System.out.print("Caught a NullPointerException involving Safe Blocks. Cause: "+e.getCause()); - } - } - - @SubscribeEvent - public void onExplode(ExplosionEvent.Detonate event) { - try { - @SuppressWarnings("unchecked") - List pos = event.explosion.affectedBlockPositions; - for(int i = 0;i pos = event.explosion.affectedBlockPositions; + for (int i = 0; i < pos.size(); i++) { + ChunkPosition blockpos = (ChunkPosition) pos.get(i); + TileEntity entity = + event.world.getTileEntity(blockpos.chunkPosX, blockpos.chunkPosY, blockpos.chunkPosZ); + if (entity != null) { + if (entity instanceof BaseMetaTileEntity) { + final IMetaTileEntity X = ((BaseMetaTileEntity) entity).getMetaTileEntity(); + if (X instanceof GregtechMetaSafeBlockBase) { + pos.remove(i); + } + } + } + } + } catch (final NullPointerException e) { + } + } - @SubscribeEvent - public void onPlayerInteraction(final PlayerInteractEvent aEvent) { - if ((aEvent.entityPlayer != null) && (aEvent.entityPlayer.worldObj != null) && (aEvent.action != null) && (aEvent.world.provider != null) && !aEvent.entityPlayer.worldObj.isRemote && (aEvent.action != null) && (aEvent.action != PlayerInteractEvent.Action.RIGHT_CLICK_AIR)) { - //Utils.LOG_ERROR("Test"); - } - } + @SubscribeEvent + public void onPlayerInteraction(final PlayerInteractEvent aEvent) { + if ((aEvent.entityPlayer != null) + && (aEvent.entityPlayer.worldObj != null) + && (aEvent.action != null) + && (aEvent.world.provider != null) + && !aEvent.entityPlayer.worldObj.isRemote + && (aEvent.action != null) + && (aEvent.action != PlayerInteractEvent.Action.RIGHT_CLICK_AIR)) { + // Utils.LOG_ERROR("Test"); + } + } } diff --git a/src/main/java/gtPlusPlus/core/handler/events/PlayerSleepEventHandler.java b/src/main/java/gtPlusPlus/core/handler/events/PlayerSleepEventHandler.java index b78d80e0b2..6a3e3bb71f 100644 --- a/src/main/java/gtPlusPlus/core/handler/events/PlayerSleepEventHandler.java +++ b/src/main/java/gtPlusPlus/core/handler/events/PlayerSleepEventHandler.java @@ -1,9 +1,5 @@ package gtPlusPlus.core.handler.events; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Collection; - import cpw.mods.fml.common.eventhandler.SubscribeEvent; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.potion.GtPotionEffect; @@ -12,6 +8,9 @@ import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.preloader.DevHelper; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Collection; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; @@ -21,90 +20,87 @@ import net.minecraftforge.event.entity.player.PlayerWakeUpEvent; public class PlayerSleepEventHandler { - private static Field sEffectDuration = ReflectionUtils.getField(PotionEffect.class, DevHelper.isObfuscatedEnvironment() ? "field_76460_b" : "duration"); - private static ArrayList sPositiveEffects = new ArrayList(); - private static ArrayList sNegativeEffects = new ArrayList(); + private static Field sEffectDuration = ReflectionUtils.getField( + PotionEffect.class, DevHelper.isObfuscatedEnvironment() ? "field_76460_b" : "duration"); + private static ArrayList sPositiveEffects = new ArrayList(); + private static ArrayList sNegativeEffects = new ArrayList(); - public static void init() { - Utils.registerEvent(new PlayerSleepEventHandler()); - sPositiveEffects.add(Potion.moveSpeed); - sPositiveEffects.add(Potion.waterBreathing); - sPositiveEffects.add(Potion.resistance); - sPositiveEffects.add(Potion.regeneration); - sPositiveEffects.add(Potion.damageBoost); - sPositiveEffects.add(Potion.digSpeed); - sPositiveEffects.add(Potion.fireResistance); - sPositiveEffects.add(Potion.field_76434_w); // Health Boost - sPositiveEffects.add(Potion.field_76444_x); // Absorption - sNegativeEffects.add(Potion.blindness); - sNegativeEffects.add(Potion.confusion); - sNegativeEffects.add(Potion.digSlowdown); - sNegativeEffects.add(Potion.harm); - sNegativeEffects.add(Potion.hunger); - sNegativeEffects.add(Potion.moveSlowdown); - sNegativeEffects.add(Potion.poison); - sNegativeEffects.add(Potion.weakness); - sNegativeEffects.add(Potion.wither); - } + public static void init() { + Utils.registerEvent(new PlayerSleepEventHandler()); + sPositiveEffects.add(Potion.moveSpeed); + sPositiveEffects.add(Potion.waterBreathing); + sPositiveEffects.add(Potion.resistance); + sPositiveEffects.add(Potion.regeneration); + sPositiveEffects.add(Potion.damageBoost); + sPositiveEffects.add(Potion.digSpeed); + sPositiveEffects.add(Potion.fireResistance); + sPositiveEffects.add(Potion.field_76434_w); // Health Boost + sPositiveEffects.add(Potion.field_76444_x); // Absorption + sNegativeEffects.add(Potion.blindness); + sNegativeEffects.add(Potion.confusion); + sNegativeEffects.add(Potion.digSlowdown); + sNegativeEffects.add(Potion.harm); + sNegativeEffects.add(Potion.hunger); + sNegativeEffects.add(Potion.moveSlowdown); + sNegativeEffects.add(Potion.poison); + sNegativeEffects.add(Potion.weakness); + sNegativeEffects.add(Potion.wither); + } - @SubscribeEvent - public void sleep(PlayerSleepInBedEvent event) { - - } + @SubscribeEvent + public void sleep(PlayerSleepInBedEvent event) {} - @SubscribeEvent - public void wake(PlayerWakeUpEvent event) { - EntityPlayer aPlayer = event.entityPlayer; - if (aPlayer != null && !aPlayer.worldObj.isRemote) { - if (event.entityPlayer.getEntityWorld().getWorldTime() % 24000 != 0) { - return; - } - boolean aRemovedBad = false; - try { - Collection aActive = aPlayer.getActivePotionEffects(); - for (PotionEffect aEffect : aActive) { - for (Potion aBadPotion : sNegativeEffects) { - if (aEffect.getPotionID() == aBadPotion.getId()) { - ReflectionUtils.setField(aEffect, sEffectDuration, 1); - aRemovedBad = true; - Logger.INFO("Set duration of " + aEffect.getEffectName() + " to 1 tick"); - } - } - } - } - catch (Throwable t) { - t.printStackTrace(); - } - if (aRemovedBad) { - messagePlayer(aPlayer, "sleep.event.downsides"); - } - else { - // Try Heal - float aCurrentHP = aPlayer.getHealth(); - float aMaxHP = aPlayer.getMaxHealth(); - if (aCurrentHP < aMaxHP) { - float aDamage = aMaxHP - aCurrentHP; - float aToHeal = MathUtils.randFloat(1, aDamage); - if (aToHeal > 0) { - aPlayer.heal(aToHeal); - messagePlayer(aPlayer, (aToHeal >= aDamage / 2 ? "sleep.event.good" : "sleep.event.okay")); - } - } - // Already healed, try give a buff - else { - int aRandomBuff = MathUtils.randInt(0, sPositiveEffects.size() - 1); - Potion aPotionToApply = sPositiveEffects.get(aRandomBuff); - if (aPotionToApply != null) { - aPlayer.addPotionEffect(new GtPotionEffect(aPotionToApply.id, MathUtils.randInt(60, 180), MathUtils.randInt(0, 2))); - messagePlayer(aPlayer, "sleep.event.wellrested"); - } - } - } - } - } - - private static void messagePlayer(EntityPlayer aPlayer, String aChatKey) { - PlayerUtils.messagePlayer(aPlayer, new ChatComponentTranslation(aChatKey, new Object[0])); - } + @SubscribeEvent + public void wake(PlayerWakeUpEvent event) { + EntityPlayer aPlayer = event.entityPlayer; + if (aPlayer != null && !aPlayer.worldObj.isRemote) { + if (event.entityPlayer.getEntityWorld().getWorldTime() % 24000 != 0) { + return; + } + boolean aRemovedBad = false; + try { + Collection aActive = aPlayer.getActivePotionEffects(); + for (PotionEffect aEffect : aActive) { + for (Potion aBadPotion : sNegativeEffects) { + if (aEffect.getPotionID() == aBadPotion.getId()) { + ReflectionUtils.setField(aEffect, sEffectDuration, 1); + aRemovedBad = true; + Logger.INFO("Set duration of " + aEffect.getEffectName() + " to 1 tick"); + } + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + if (aRemovedBad) { + messagePlayer(aPlayer, "sleep.event.downsides"); + } else { + // Try Heal + float aCurrentHP = aPlayer.getHealth(); + float aMaxHP = aPlayer.getMaxHealth(); + if (aCurrentHP < aMaxHP) { + float aDamage = aMaxHP - aCurrentHP; + float aToHeal = MathUtils.randFloat(1, aDamage); + if (aToHeal > 0) { + aPlayer.heal(aToHeal); + messagePlayer(aPlayer, (aToHeal >= aDamage / 2 ? "sleep.event.good" : "sleep.event.okay")); + } + } + // Already healed, try give a buff + else { + int aRandomBuff = MathUtils.randInt(0, sPositiveEffects.size() - 1); + Potion aPotionToApply = sPositiveEffects.get(aRandomBuff); + if (aPotionToApply != null) { + aPlayer.addPotionEffect(new GtPotionEffect( + aPotionToApply.id, MathUtils.randInt(60, 180), MathUtils.randInt(0, 2))); + messagePlayer(aPlayer, "sleep.event.wellrested"); + } + } + } + } + } + private static void messagePlayer(EntityPlayer aPlayer, String aChatKey) { + PlayerUtils.messagePlayer(aPlayer, new ChatComponentTranslation(aChatKey, new Object[0])); + } } diff --git a/src/main/java/gtPlusPlus/core/handler/events/PlayerTickHandler.java b/src/main/java/gtPlusPlus/core/handler/events/PlayerTickHandler.java index dc7ccb3e72..fb64fc93cf 100644 --- a/src/main/java/gtPlusPlus/core/handler/events/PlayerTickHandler.java +++ b/src/main/java/gtPlusPlus/core/handler/events/PlayerTickHandler.java @@ -1,18 +1,14 @@ package gtPlusPlus.core.handler.events; import cpw.mods.fml.common.eventhandler.SubscribeEvent; - import net.minecraft.entity.player.EntityPlayer; public class PlayerTickHandler { - @SubscribeEvent - public void onPlayerTick(net.minecraftforge.event.entity.player.PlayerOpenContainerEvent e){ - if (e.entity instanceof EntityPlayer){ - if (e.entityPlayer.openContainer != null) { - - } + @SubscribeEvent + public void onPlayerTick(net.minecraftforge.event.entity.player.PlayerOpenContainerEvent e) { + if (e.entity instanceof EntityPlayer) { + if (e.entityPlayer.openContainer != null) {} } } - } diff --git a/src/main/java/gtPlusPlus/core/handler/events/SneakManager.java b/src/main/java/gtPlusPlus/core/handler/events/SneakManager.java index 3e51c6488a..177f04e977 100644 --- a/src/main/java/gtPlusPlus/core/handler/events/SneakManager.java +++ b/src/main/java/gtPlusPlus/core/handler/events/SneakManager.java @@ -1,131 +1,126 @@ package gtPlusPlus.core.handler.events; -import java.util.concurrent.ConcurrentHashMap; - import gtPlusPlus.api.objects.Logger; +import java.util.concurrent.ConcurrentHashMap; import net.minecraft.entity.player.EntityPlayer; public class SneakManager { - //We make this a singleton for clientside data storage. - - public static ConcurrentHashMap mPlayerCache = new ConcurrentHashMap(); - - private static void addPlayer(EntityPlayer aPlayer) { - String aKey = getKey(aPlayer); - if (!mPlayerCache.containsKey(aKey)) { - mPlayerCache.put(aKey, new SneakManager(aPlayer)); - } - } - - public static SneakManager get(EntityPlayer aPlayer) { - - String aKey = getKey(aPlayer); - if (!mPlayerCache.containsKey(aKey)) { - addPlayer(aPlayer); - } - return mPlayerCache.get(aKey); - } - - private static String getKey(EntityPlayer aPlayer) { - return ""+aPlayer.getGameProfile().getId().toString(); - } - - - public SneakManager instance; - public EntityPlayer owner; - public boolean canSprint = true; - public boolean isSneaking = true; - public boolean optionDoubleTap = true; - public boolean wasSprintDisabled = false; - public boolean mIsWearingRing = false; - - private State Sprinting = State.ON; - private State Crouching = State.OFF; - - public SneakManager(EntityPlayer aPlayer) { - owner = aPlayer; - } - - public boolean Sneaking(){ - return Crouching.getState(); - } - - public boolean Sprinting(){ - return Sprinting.getState(); - } - - public State getSneakingState(){ - return Crouching; - } - - public State getSprintingDisabledState(){ - return Sprinting; - } - - public void toggleSneaking(){ - toggleState(Crouching); - } - - public void toggleSprinting(){ - toggleState(Sprinting); - } - - private State toggleState(final State state){ - Logger.INFO("State Toggle"); - if (state == State.ON) { - return State.OFF; - } - return State.ON; - } - - private State setCrouchingStateON(){ - return Crouching = State.ON; - } - - private State setCrouchingStateOFF(){ - return Crouching = State.OFF; - } - - private State setSprintingStateON(){ - return Sprinting = State.ON; - } - - private State setSprintingStateOFF(){ - return Sprinting = State.OFF; - } - - public void putRingOn() { - mIsWearingRing = true; - setSprintingStateOFF(); - setCrouchingStateON(); - } - - public void takeRingOff() { - mIsWearingRing = false; - setSprintingStateON(); - setCrouchingStateOFF(); - } - - public boolean isWearingRing() { - return mIsWearingRing; - } - - public static enum State { - ON(true), - OFF(false); - - private final boolean STATE; - private State (final boolean State) - { - this.STATE = State; - } - - public boolean getState() { - return this.STATE; - } - - } - + // We make this a singleton for clientside data storage. + + public static ConcurrentHashMap mPlayerCache = new ConcurrentHashMap(); + + private static void addPlayer(EntityPlayer aPlayer) { + String aKey = getKey(aPlayer); + if (!mPlayerCache.containsKey(aKey)) { + mPlayerCache.put(aKey, new SneakManager(aPlayer)); + } + } + + public static SneakManager get(EntityPlayer aPlayer) { + + String aKey = getKey(aPlayer); + if (!mPlayerCache.containsKey(aKey)) { + addPlayer(aPlayer); + } + return mPlayerCache.get(aKey); + } + + private static String getKey(EntityPlayer aPlayer) { + return "" + aPlayer.getGameProfile().getId().toString(); + } + + public SneakManager instance; + public EntityPlayer owner; + public boolean canSprint = true; + public boolean isSneaking = true; + public boolean optionDoubleTap = true; + public boolean wasSprintDisabled = false; + public boolean mIsWearingRing = false; + + private State Sprinting = State.ON; + private State Crouching = State.OFF; + + public SneakManager(EntityPlayer aPlayer) { + owner = aPlayer; + } + + public boolean Sneaking() { + return Crouching.getState(); + } + + public boolean Sprinting() { + return Sprinting.getState(); + } + + public State getSneakingState() { + return Crouching; + } + + public State getSprintingDisabledState() { + return Sprinting; + } + + public void toggleSneaking() { + toggleState(Crouching); + } + + public void toggleSprinting() { + toggleState(Sprinting); + } + + private State toggleState(final State state) { + Logger.INFO("State Toggle"); + if (state == State.ON) { + return State.OFF; + } + return State.ON; + } + + private State setCrouchingStateON() { + return Crouching = State.ON; + } + + private State setCrouchingStateOFF() { + return Crouching = State.OFF; + } + + private State setSprintingStateON() { + return Sprinting = State.ON; + } + + private State setSprintingStateOFF() { + return Sprinting = State.OFF; + } + + public void putRingOn() { + mIsWearingRing = true; + setSprintingStateOFF(); + setCrouchingStateON(); + } + + public void takeRingOff() { + mIsWearingRing = false; + setSprintingStateON(); + setCrouchingStateOFF(); + } + + public boolean isWearingRing() { + return mIsWearingRing; + } + + public static enum State { + ON(true), + OFF(false); + + private final boolean STATE; + + private State(final boolean State) { + this.STATE = State; + } + + public boolean getState() { + return this.STATE; + } + } } - diff --git a/src/main/java/gtPlusPlus/core/handler/events/UnbreakableBlockManager.java b/src/main/java/gtPlusPlus/core/handler/events/UnbreakableBlockManager.java index b653c6ffb6..ddd8f78a23 100644 --- a/src/main/java/gtPlusPlus/core/handler/events/UnbreakableBlockManager.java +++ b/src/main/java/gtPlusPlus/core/handler/events/UnbreakableBlockManager.java @@ -1,138 +1,124 @@ package gtPlusPlus.core.handler.events; -import net.minecraft.block.Block; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.metatileentity.BaseMetaTileEntity; import gregtech.api.metatileentity.BaseTileEntity; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GregtechMetaSafeBlock; +import net.minecraft.block.Block; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; -public class UnbreakableBlockManager{ - - private static boolean hasRun = false; - - public final BaseMetaTileEntity getmTileEntity() { - return mTileEntity; - } - - - public final void setmTileEntity(final BaseMetaTileEntity mTileEntity/*, EntityPlayer aPlayer*/) { - UnbreakableBlockManager.mTileEntity = mTileEntity; - if (!hasRun){ - hasRun = true; - this.makeIndestructible(/*aPlayer*/); - } - else { - Logger.WARNING("Why do you run twice?"); - } - } - - - //BaseMetaTileEntity - //GregtechMetaSafeBlock - private static BaseMetaTileEntity mTileEntity = null; - - - private void makeIndestructible(/*EntityPlayer aPlayer*/){ - - - Logger.WARNING("Initializing the code to set this TE to -1 hardness and make it indestructible."); - final int X = mTileEntity.xCoord; //(GregtechMetaSafeBlock) this.mTileEntity.getXCoord(); - final int Y = mTileEntity.yCoord; - final int Z = mTileEntity.zCoord; - Logger.WARNING("Grabbing TileEntity @ [x,y,z] |"+X+"|"+Y+"|"+Z+"|"); - - try{ - final GregtechMetaSafeBlock MetaSafeBlock = ((GregtechMetaSafeBlock) UnbreakableBlockManager.mTileEntity.getMetaTileEntity()); - final TileEntity BaseMetaTileEntity = mTileEntity.getTileEntity(X, Y, Z); - //MetaSafeBlockBase. - final World TE_WORLD = MetaSafeBlock.getBaseMetaTileEntity().getWorld(); - Logger.WARNING("Checking new State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable); - final TileEntity entity = BaseMetaTileEntity; - innerInvincible(MetaSafeBlock, entity, TE_WORLD, /*aPlayer,*/ X, Y, Z); - } - catch (final NullPointerException e) { - System.out.print("Caught a NullPointerException involving Safe Blocks. Cause: "); - e.printStackTrace(); - } - } - - - private static void innerInvincible(final GregtechMetaSafeBlock MetaSafeBlock, final TileEntity entity, final World TE_WORLD, /*EntityPlayer aPlayer,*/ final int X, final int Y, final int Z){ - if (entity != null){ - Logger.WARNING("Checking new State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable); - Logger.WARNING("Grabbed TE: "+entity.toString()); - - - - - if ((entity instanceof BaseTileEntity) && !(entity instanceof BaseMetaPipeEntity)){ - final IMetaTileEntity I = ((BaseMetaTileEntity)entity).getMetaTileEntity(); - Logger.WARNING("Checking State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable); - Logger.WARNING("I Details: "+I.getMetaName()+" | "+I.getTileEntityBaseType()+" | "+I.toString()); - - - - - - if (I instanceof GregtechMetaSafeBlock){ - Logger.WARNING("Checking State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable); - - final Block ThisBlock = I.getBaseMetaTileEntity().getBlock(X, Y, Z); - Logger.WARNING("Block Details: "+ThisBlock.toString()); - - - if (((GregtechMetaSafeBlock)I).bUnbreakable){ - ThisBlock.setHardness(Integer.MAX_VALUE); - //ThisBlock.setResistance(18000000.0F); - ThisBlock.setResistance(-1); - ThisBlock.setBlockUnbreakable(); - Logger.WARNING("Changing State of Flag. Old Value="+MetaSafeBlock.bUnbreakable+" Expected Value=true"); - MetaSafeBlock.bUnbreakable = true; - //entity.markDirty(); - Logger.WARNING("Checking new State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable); - Logger.ERROR("New Indestructible Flag enabled."); - //GT_Utility.sendChatToPlayer(aPlayer, "Block is now unbreakable."); - } - - - - - else { - ThisBlock.setHardness(1); - ThisBlock.setResistance(1.0F); - Logger.WARNING("Changing State of Flag. Old Value="+MetaSafeBlock.bUnbreakable+" Expected Value=false"); - MetaSafeBlock.bUnbreakable = false; - //entity.markDirty(); - Logger.WARNING("Checking new State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable); - Logger.ERROR("New Indestructible Flag disabled."); - //GT_Utility.sendChatToPlayer(aPlayer, "Block is now breakable."); - } - - //entity.markDirty(); - - Logger.WARNING("Block Hardness: "+ThisBlock.getBlockHardness(TE_WORLD, X, Y, Z)); - Logger.WARNING("Checking State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable); - hasRun = false; - - } - else { - Logger.WARNING("I is not an instanceof MetaSafeBlockBase"); - Logger.WARNING("Checking State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable); - } - } else { - Logger.WARNING("TE is not an instanceof BaseTileEntity or may be a pipe."); - Logger.WARNING("Checking State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable); - } - }else { - Logger.WARNING("Did not grab a TE instance to make a block instance from."); - Logger.WARNING("Checking State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable); - } - } - +public class UnbreakableBlockManager { + + private static boolean hasRun = false; + + public final BaseMetaTileEntity getmTileEntity() { + return mTileEntity; + } + + public final void setmTileEntity(final BaseMetaTileEntity mTileEntity /*, EntityPlayer aPlayer*/) { + UnbreakableBlockManager.mTileEntity = mTileEntity; + if (!hasRun) { + hasRun = true; + this.makeIndestructible(/*aPlayer*/ ); + } else { + Logger.WARNING("Why do you run twice?"); + } + } + + // BaseMetaTileEntity + // GregtechMetaSafeBlock + private static BaseMetaTileEntity mTileEntity = null; + + private void makeIndestructible(/*EntityPlayer aPlayer*/ ) { + + Logger.WARNING("Initializing the code to set this TE to -1 hardness and make it indestructible."); + final int X = mTileEntity.xCoord; // (GregtechMetaSafeBlock) this.mTileEntity.getXCoord(); + final int Y = mTileEntity.yCoord; + final int Z = mTileEntity.zCoord; + Logger.WARNING("Grabbing TileEntity @ [x,y,z] |" + X + "|" + Y + "|" + Z + "|"); + + try { + final GregtechMetaSafeBlock MetaSafeBlock = + ((GregtechMetaSafeBlock) UnbreakableBlockManager.mTileEntity.getMetaTileEntity()); + final TileEntity BaseMetaTileEntity = mTileEntity.getTileEntity(X, Y, Z); + // MetaSafeBlockBase. + final World TE_WORLD = MetaSafeBlock.getBaseMetaTileEntity().getWorld(); + Logger.WARNING("Checking new State of Flag[nUnbreakable]. Value=" + MetaSafeBlock.bUnbreakable); + final TileEntity entity = BaseMetaTileEntity; + innerInvincible(MetaSafeBlock, entity, TE_WORLD, /*aPlayer,*/ X, Y, Z); + } catch (final NullPointerException e) { + System.out.print("Caught a NullPointerException involving Safe Blocks. Cause: "); + e.printStackTrace(); + } + } + + private static void innerInvincible( + final GregtechMetaSafeBlock MetaSafeBlock, + final TileEntity entity, + final World TE_WORLD, /*EntityPlayer aPlayer,*/ + final int X, + final int Y, + final int Z) { + if (entity != null) { + Logger.WARNING("Checking new State of Flag[nUnbreakable]. Value=" + MetaSafeBlock.bUnbreakable); + Logger.WARNING("Grabbed TE: " + entity.toString()); + + if ((entity instanceof BaseTileEntity) && !(entity instanceof BaseMetaPipeEntity)) { + final IMetaTileEntity I = ((BaseMetaTileEntity) entity).getMetaTileEntity(); + Logger.WARNING("Checking State of Flag[nUnbreakable]. Value=" + MetaSafeBlock.bUnbreakable); + Logger.WARNING( + "I Details: " + I.getMetaName() + " | " + I.getTileEntityBaseType() + " | " + I.toString()); + + if (I instanceof GregtechMetaSafeBlock) { + Logger.WARNING("Checking State of Flag[nUnbreakable]. Value=" + MetaSafeBlock.bUnbreakable); + + final Block ThisBlock = I.getBaseMetaTileEntity().getBlock(X, Y, Z); + Logger.WARNING("Block Details: " + ThisBlock.toString()); + + if (((GregtechMetaSafeBlock) I).bUnbreakable) { + ThisBlock.setHardness(Integer.MAX_VALUE); + // ThisBlock.setResistance(18000000.0F); + ThisBlock.setResistance(-1); + ThisBlock.setBlockUnbreakable(); + Logger.WARNING("Changing State of Flag. Old Value=" + MetaSafeBlock.bUnbreakable + + " Expected Value=true"); + MetaSafeBlock.bUnbreakable = true; + // entity.markDirty(); + Logger.WARNING("Checking new State of Flag[nUnbreakable]. Value=" + MetaSafeBlock.bUnbreakable); + Logger.ERROR("New Indestructible Flag enabled."); + // GT_Utility.sendChatToPlayer(aPlayer, "Block is now unbreakable."); + } else { + ThisBlock.setHardness(1); + ThisBlock.setResistance(1.0F); + Logger.WARNING("Changing State of Flag. Old Value=" + MetaSafeBlock.bUnbreakable + + " Expected Value=false"); + MetaSafeBlock.bUnbreakable = false; + // entity.markDirty(); + Logger.WARNING("Checking new State of Flag[nUnbreakable]. Value=" + MetaSafeBlock.bUnbreakable); + Logger.ERROR("New Indestructible Flag disabled."); + // GT_Utility.sendChatToPlayer(aPlayer, "Block is now breakable."); + } + + // entity.markDirty(); + + Logger.WARNING("Block Hardness: " + ThisBlock.getBlockHardness(TE_WORLD, X, Y, Z)); + Logger.WARNING("Checking State of Flag[nUnbreakable]. Value=" + MetaSafeBlock.bUnbreakable); + hasRun = false; + + } else { + Logger.WARNING("I is not an instanceof MetaSafeBlockBase"); + Logger.WARNING("Checking State of Flag[nUnbreakable]. Value=" + MetaSafeBlock.bUnbreakable); + } + } else { + Logger.WARNING("TE is not an instanceof BaseTileEntity or may be a pipe."); + Logger.WARNING("Checking State of Flag[nUnbreakable]. Value=" + MetaSafeBlock.bUnbreakable); + } + } else { + Logger.WARNING("Did not grab a TE instance to make a block instance from."); + Logger.WARNING("Checking State of Flag[nUnbreakable]. Value=" + MetaSafeBlock.bUnbreakable); + } + } } diff --git a/src/main/java/gtPlusPlus/core/handler/events/ZombieBackupSpawnEventHandler.java b/src/main/java/gtPlusPlus/core/handler/events/ZombieBackupSpawnEventHandler.java index 68df68aa2a..9a6a840216 100644 --- a/src/main/java/gtPlusPlus/core/handler/events/ZombieBackupSpawnEventHandler.java +++ b/src/main/java/gtPlusPlus/core/handler/events/ZombieBackupSpawnEventHandler.java @@ -1,55 +1,49 @@ package gtPlusPlus.core.handler.events; -import java.lang.reflect.Field; - -import org.apache.commons.lang3.reflect.FieldUtils; - import cpw.mods.fml.common.eventhandler.Event.Result; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; - import gtPlusPlus.api.objects.Logger; +import java.lang.reflect.Field; import net.minecraftforge.event.entity.living.ZombieEvent; +import org.apache.commons.lang3.reflect.FieldUtils; public class ZombieBackupSpawnEventHandler { - /** - * - * Do we really need this pathetic mechanic to exist when it doesn't work properly at all? - * Or , well, maybe you enjoy Zombies spawning IN YOUR FUCKING FACE?! - * - */ - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onZombieReinforcement(final ZombieEvent.SummonAidEvent event) { - try { - try { - Field mChance = FieldUtils.getDeclaredField(this.getClass(), "summonChance", true); - FieldUtils.removeFinalModifier(mChance, true); - mChance.set(this, 0); - } - catch(Throwable t){} - if (event.attacker != null){ - //SegmentHelper.getInstance().trackUser(event.attacker.getUniqueID().toString(), "Zombie Backup"); - } - Logger.WARNING("[Zombie] ZombieEvent.SummonAidEvent."); - event.setResult(Result.DENY); - } - catch(Throwable t){} - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onZombieReinforcement(final ZombieEvent event) { - try { - Logger.WARNING("[Zombie] ZombieEvent."); - if (event.entity != null){ - Logger.WARNING("Event Entity: "+event.entity.getCommandSenderName()); - } - event.setResult(Result.DENY); - } - catch(Throwable t){ - - } - } - + /** + * + * Do we really need this pathetic mechanic to exist when it doesn't work properly at all? + * Or , well, maybe you enjoy Zombies spawning IN YOUR FUCKING FACE?! + * + */ + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onZombieReinforcement(final ZombieEvent.SummonAidEvent event) { + try { + try { + Field mChance = FieldUtils.getDeclaredField(this.getClass(), "summonChance", true); + FieldUtils.removeFinalModifier(mChance, true); + mChance.set(this, 0); + } catch (Throwable t) { + } + if (event.attacker != null) { + // SegmentHelper.getInstance().trackUser(event.attacker.getUniqueID().toString(), "Zombie Backup"); + } + Logger.WARNING("[Zombie] ZombieEvent.SummonAidEvent."); + event.setResult(Result.DENY); + } catch (Throwable t) { + } + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onZombieReinforcement(final ZombieEvent event) { + try { + Logger.WARNING("[Zombie] ZombieEvent."); + if (event.entity != null) { + Logger.WARNING("Event Entity: " + event.entity.getCommandSenderName()); + } + event.setResult(Result.DENY); + } catch (Throwable t) { + + } + } } diff --git a/src/main/java/gtPlusPlus/core/handler/render/CapeHandler.java b/src/main/java/gtPlusPlus/core/handler/render/CapeHandler.java index 491d9a2aba..caf352d0de 100644 --- a/src/main/java/gtPlusPlus/core/handler/render/CapeHandler.java +++ b/src/main/java/gtPlusPlus/core/handler/render/CapeHandler.java @@ -1,9 +1,10 @@ package gtPlusPlus.core.handler.render; +import gregtech.api.enums.GT_Values; +import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.lib.CORE; import java.util.Collection; - -import org.lwjgl.opengl.GL11; - import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.entity.RenderManager; @@ -11,112 +12,100 @@ import net.minecraft.client.renderer.entity.RenderPlayer; import net.minecraft.potion.Potion; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; - -import gregtech.api.enums.GT_Values; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_Utility; - -import gtPlusPlus.core.lib.CORE; import net.minecraftforge.client.event.RenderPlayerEvent; +import org.lwjgl.opengl.GL11; public class CapeHandler extends RenderPlayer { - private final ResourceLocation[] mCapes = { - new ResourceLocation(CORE.MODID+":textures/TesterCape.png"), - new ResourceLocation(CORE.MODID+":textures/Draknyte1.png"), - new ResourceLocation("gregtech:textures/GregoriusCape.png") }; - private final Collection mCapeList; - - public CapeHandler(final Collection aCapeList) { - this.mCapeList = aCapeList; - this.setRenderManager(RenderManager.instance); - } + private final ResourceLocation[] mCapes = { + new ResourceLocation(CORE.MODID + ":textures/TesterCape.png"), + new ResourceLocation(CORE.MODID + ":textures/Draknyte1.png"), + new ResourceLocation("gregtech:textures/GregoriusCape.png") + }; + private final Collection mCapeList; - public void receiveRenderSpecialsEvent(final RenderPlayerEvent.Specials.Pre aEvent) { - final AbstractClientPlayer aPlayer = (AbstractClientPlayer) aEvent.entityPlayer; - if (GT_Utility.getFullInvisibility(aPlayer)) { - aEvent.setCanceled(true); - return; - } - final float aPartialTicks = aEvent.partialRenderTick; - if (aPlayer.isInvisible()) { - return; - } - if (GT_Utility.getPotion(aPlayer, - Integer.valueOf(Potion.invisibility.id).intValue())) { - return; - } - try { - ResourceLocation tResource = null; - if (aPlayer.getDisplayName().equalsIgnoreCase("XW3B")) { - tResource = this.mCapes[0]; - } - if (this.mCapeList.contains(aPlayer.getDisplayName().toLowerCase())) { - tResource = this.mCapes[0]; - } - if (aPlayer.getDisplayName().equalsIgnoreCase("Draknyte1")) { - tResource = this.mCapes[1]; - } - if (aPlayer.getDisplayName().equalsIgnoreCase("GregoriusT")) { - tResource = this.mCapes[2]; - } - if ((tResource != null) && (!(aPlayer.getHideCape()))) { - this.bindTexture(tResource); - GL11.glPushMatrix(); - GL11.glTranslatef(0.0F, 0.0F, 0.125F); - final double d0 = (aPlayer.field_71091_bM - + ((aPlayer.field_71094_bP - aPlayer.field_71091_bM) - * aPartialTicks)) - - (aPlayer.prevPosX + ((aPlayer.posX - aPlayer.prevPosX) - * aPartialTicks)); - final double d1 = (aPlayer.field_71096_bN - + ((aPlayer.field_71095_bQ - aPlayer.field_71096_bN) - * aPartialTicks)) - - (aPlayer.prevPosY + ((aPlayer.posY - aPlayer.prevPosY) - * aPartialTicks)); - final double d2 = (aPlayer.field_71097_bO - + ((aPlayer.field_71085_bR - aPlayer.field_71097_bO) - * aPartialTicks)) - - (aPlayer.prevPosZ + ((aPlayer.posZ - aPlayer.prevPosZ) - * aPartialTicks)); - final float f6 = aPlayer.prevRenderYawOffset - + ((aPlayer.renderYawOffset - aPlayer.prevRenderYawOffset) - * aPartialTicks); - final double d3 = MathHelper.sin((f6 * CORE.PI) / 180.0F); - final double d4 = -MathHelper.cos((f6 * CORE.PI) / 180.0F); - float f7 = (float) d1 * 10.0F; - float f8 = (float) ((d0 * d3) + (d2 * d4)) * 100.0F; - final 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; - } - final 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(); - } - } catch (final Throwable e) { - if (GT_Values.D1) { - e.printStackTrace(GT_Log.err); - } - } - } + public CapeHandler(final Collection aCapeList) { + this.mCapeList = aCapeList; + this.setRenderManager(RenderManager.instance); + } + public void receiveRenderSpecialsEvent(final RenderPlayerEvent.Specials.Pre aEvent) { + final AbstractClientPlayer aPlayer = (AbstractClientPlayer) aEvent.entityPlayer; + if (GT_Utility.getFullInvisibility(aPlayer)) { + aEvent.setCanceled(true); + return; + } + final float aPartialTicks = aEvent.partialRenderTick; + if (aPlayer.isInvisible()) { + return; + } + if (GT_Utility.getPotion( + aPlayer, Integer.valueOf(Potion.invisibility.id).intValue())) { + return; + } + try { + ResourceLocation tResource = null; + if (aPlayer.getDisplayName().equalsIgnoreCase("XW3B")) { + tResource = this.mCapes[0]; + } + if (this.mCapeList.contains(aPlayer.getDisplayName().toLowerCase())) { + tResource = this.mCapes[0]; + } + if (aPlayer.getDisplayName().equalsIgnoreCase("Draknyte1")) { + tResource = this.mCapes[1]; + } + if (aPlayer.getDisplayName().equalsIgnoreCase("GregoriusT")) { + tResource = this.mCapes[2]; + } + if ((tResource != null) && (!(aPlayer.getHideCape()))) { + this.bindTexture(tResource); + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, 0.0F, 0.125F); + final double d0 = + (aPlayer.field_71091_bM + ((aPlayer.field_71094_bP - aPlayer.field_71091_bM) * aPartialTicks)) + - (aPlayer.prevPosX + ((aPlayer.posX - aPlayer.prevPosX) * aPartialTicks)); + final double d1 = + (aPlayer.field_71096_bN + ((aPlayer.field_71095_bQ - aPlayer.field_71096_bN) * aPartialTicks)) + - (aPlayer.prevPosY + ((aPlayer.posY - aPlayer.prevPosY) * aPartialTicks)); + final double d2 = + (aPlayer.field_71097_bO + ((aPlayer.field_71085_bR - aPlayer.field_71097_bO) * aPartialTicks)) + - (aPlayer.prevPosZ + ((aPlayer.posZ - aPlayer.prevPosZ) * aPartialTicks)); + final float f6 = aPlayer.prevRenderYawOffset + + ((aPlayer.renderYawOffset - aPlayer.prevRenderYawOffset) * aPartialTicks); + final double d3 = MathHelper.sin((f6 * CORE.PI) / 180.0F); + final double d4 = -MathHelper.cos((f6 * CORE.PI) / 180.0F); + float f7 = (float) d1 * 10.0F; + float f8 = (float) ((d0 * d3) + (d2 * d4)) * 100.0F; + final 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; + } + final 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(); + } + } catch (final Throwable e) { + if (GT_Values.D1) { + e.printStackTrace(GT_Log.err); + } + } + } } diff --git a/src/main/java/gtPlusPlus/core/handler/render/FirepitModel.java b/src/main/java/gtPlusPlus/core/handler/render/FirepitModel.java index 029d961bff..82033394f7 100644 --- a/src/main/java/gtPlusPlus/core/handler/render/FirepitModel.java +++ b/src/main/java/gtPlusPlus/core/handler/render/FirepitModel.java @@ -6,116 +6,123 @@ package gtPlusPlus.core.handler.render; +import gtPlusPlus.core.lib.CORE; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; -import gtPlusPlus.core.lib.CORE; - -public class FirepitModel extends ModelBase -{ - //fields - ModelRenderer Side_A; - ModelRenderer Side_B; - ModelRenderer Side_C; - ModelRenderer Side_D; - ModelRenderer Log1; - ModelRenderer Log2; - ModelRenderer Log3; - ModelRenderer Log4; - - public FirepitModel() - { - this.textureWidth = 16; - this.textureHeight = 16; - - this.Side_A = new ModelRenderer(this, 0, 0); - this.Side_A.addBox(0F, 0F, 0F, 12, 6, 1); - this.Side_A.setRotationPoint(-6F, 18F, -6F); - this.Side_A.setTextureSize(16, 16); - this.Side_A.mirror = true; - setRotation(this.Side_A, -0.3148822F, 0F, 0F); - //Side_A.mirror = false; - - this.Side_B = new ModelRenderer(this, 0, 0); - this.Side_B.addBox(0F, 0F, 0F, 12, 6, 1); - this.Side_B.setRotationPoint(-6F, 18F, 6F); - this.Side_B.setTextureSize(16, 16); - this.Side_B.mirror = true; - setRotation(this.Side_B, -0.3148822F, (CORE.PI/2), 0F); - - this.Side_C = new ModelRenderer(this, 0, 0); - this.Side_C.addBox(0F, 0F, 0F, 12, 6, 1); - this.Side_C.setRotationPoint(6F, 18F, 6F); - this.Side_C.setTextureSize(16, 16); - this.Side_C.mirror = true; - setRotation(this.Side_C, -0.3148822F, CORE.PI, 0F); - //Side_C.mirror = false; - - this.Side_D = new ModelRenderer(this, 0, 0); - this.Side_D.addBox(0F, 0F, 0F, 12, 6, 1); - this.Side_D.setRotationPoint(6F, 18F, -6F); - this.Side_D.setTextureSize(16, 16); - this.Side_D.mirror = true; - setRotation(this.Side_D, -0.3148822F, 4.712389F, 0F); - - this.Log1 = new ModelRenderer(this, 0, 10); - this.Log1.addBox(0F, 0F, 0F, 14, 2, 2); - this.Log1.setRotationPoint(4F, 10F, -4F); - this.Log1.setTextureSize(16, 16); - this.Log1.mirror = true; - setRotation(this.Log1, 0F, 0F, (CORE.PI/2)); - - this.Log2 = new ModelRenderer(this, -2, 10); - this.Log2.addBox(0F, 0F, 0F, 14, 2, 2); - this.Log2.setRotationPoint(-4F, 10F, -4F); - this.Log2.setTextureSize(16, 16); - this.Log2.mirror = true; - setRotation(this.Log2, (CORE.PI/2), 0F, (CORE.PI/2)); - //Log2.mirror = false; - - this.Log3 = new ModelRenderer(this, 0, 10); - this.Log3.addBox(0F, 0F, 0F, 14, 2, 2); - this.Log3.setRotationPoint(-4F, 10F, 4F); - this.Log3.setTextureSize(16, 16); - this.Log3.mirror = true; - setRotation(this.Log3, CORE.PI, 0F, (CORE.PI/2)); - - this.Log4 = new ModelRenderer(this, -2, 10); - this.Log4.addBox(0F, 0F, 0F, 14, 2, 2); - this.Log4.setRotationPoint(4F, 10F, 4F); - this.Log4.setTextureSize(16, 16); - this.Log4.mirror = true; - setRotation(this.Log4, 4.712389F, 0F, (CORE.PI/2)); - //Log4.mirror = false; - } - - @Override - public void render(final Entity entity, final float f, final float f1, final float f2, final float f3, final float f4, final float f5) - { - super.render(entity, f, f1, f2, f3, f4, f5); - this.setRotationAngles(f, f1, f2, f3, f4, f5, entity); - this.Side_A.render(f5); - this.Side_B.render(f5); - this.Side_C.render(f5); - this.Side_D.render(f5); - this.Log1.render(f5); - this.Log2.render(f5); - this.Log3.render(f5); - this.Log4.render(f5); - } - - private static void setRotation(final ModelRenderer model, final float x, final float y, final float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } - - @Override - public void setRotationAngles(final float f, final float f1, final float f2, final float f3, final float f4, final float f5, final Entity entity) - { - super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); - } - +public class FirepitModel extends ModelBase { + // fields + ModelRenderer Side_A; + ModelRenderer Side_B; + ModelRenderer Side_C; + ModelRenderer Side_D; + ModelRenderer Log1; + ModelRenderer Log2; + ModelRenderer Log3; + ModelRenderer Log4; + + public FirepitModel() { + this.textureWidth = 16; + this.textureHeight = 16; + + this.Side_A = new ModelRenderer(this, 0, 0); + this.Side_A.addBox(0F, 0F, 0F, 12, 6, 1); + this.Side_A.setRotationPoint(-6F, 18F, -6F); + this.Side_A.setTextureSize(16, 16); + this.Side_A.mirror = true; + setRotation(this.Side_A, -0.3148822F, 0F, 0F); + // Side_A.mirror = false; + + this.Side_B = new ModelRenderer(this, 0, 0); + this.Side_B.addBox(0F, 0F, 0F, 12, 6, 1); + this.Side_B.setRotationPoint(-6F, 18F, 6F); + this.Side_B.setTextureSize(16, 16); + this.Side_B.mirror = true; + setRotation(this.Side_B, -0.3148822F, (CORE.PI / 2), 0F); + + this.Side_C = new ModelRenderer(this, 0, 0); + this.Side_C.addBox(0F, 0F, 0F, 12, 6, 1); + this.Side_C.setRotationPoint(6F, 18F, 6F); + this.Side_C.setTextureSize(16, 16); + this.Side_C.mirror = true; + setRotation(this.Side_C, -0.3148822F, CORE.PI, 0F); + // Side_C.mirror = false; + + this.Side_D = new ModelRenderer(this, 0, 0); + this.Side_D.addBox(0F, 0F, 0F, 12, 6, 1); + this.Side_D.setRotationPoint(6F, 18F, -6F); + this.Side_D.setTextureSize(16, 16); + this.Side_D.mirror = true; + setRotation(this.Side_D, -0.3148822F, 4.712389F, 0F); + + this.Log1 = new ModelRenderer(this, 0, 10); + this.Log1.addBox(0F, 0F, 0F, 14, 2, 2); + this.Log1.setRotationPoint(4F, 10F, -4F); + this.Log1.setTextureSize(16, 16); + this.Log1.mirror = true; + setRotation(this.Log1, 0F, 0F, (CORE.PI / 2)); + + this.Log2 = new ModelRenderer(this, -2, 10); + this.Log2.addBox(0F, 0F, 0F, 14, 2, 2); + this.Log2.setRotationPoint(-4F, 10F, -4F); + this.Log2.setTextureSize(16, 16); + this.Log2.mirror = true; + setRotation(this.Log2, (CORE.PI / 2), 0F, (CORE.PI / 2)); + // Log2.mirror = false; + + this.Log3 = new ModelRenderer(this, 0, 10); + this.Log3.addBox(0F, 0F, 0F, 14, 2, 2); + this.Log3.setRotationPoint(-4F, 10F, 4F); + this.Log3.setTextureSize(16, 16); + this.Log3.mirror = true; + setRotation(this.Log3, CORE.PI, 0F, (CORE.PI / 2)); + + this.Log4 = new ModelRenderer(this, -2, 10); + this.Log4.addBox(0F, 0F, 0F, 14, 2, 2); + this.Log4.setRotationPoint(4F, 10F, 4F); + this.Log4.setTextureSize(16, 16); + this.Log4.mirror = true; + setRotation(this.Log4, 4.712389F, 0F, (CORE.PI / 2)); + // Log4.mirror = false; + } + + @Override + public void render( + final Entity entity, + final float f, + final float f1, + final float f2, + final float f3, + final float f4, + final float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + this.setRotationAngles(f, f1, f2, f3, f4, f5, entity); + this.Side_A.render(f5); + this.Side_B.render(f5); + this.Side_C.render(f5); + this.Side_D.render(f5); + this.Log1.render(f5); + this.Log2.render(f5); + this.Log3.render(f5); + this.Log4.render(f5); + } + + private static void setRotation(final ModelRenderer model, final float x, final float y, final float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + @Override + public void setRotationAngles( + final float f, + final float f1, + final float f2, + final float f3, + final float f4, + final float f5, + final Entity entity) { + super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); + } } diff --git a/src/main/java/gtPlusPlus/core/handler/render/FirepitRender.java b/src/main/java/gtPlusPlus/core/handler/render/FirepitRender.java index 7b8d23e25b..616822ada4 100644 --- a/src/main/java/gtPlusPlus/core/handler/render/FirepitRender.java +++ b/src/main/java/gtPlusPlus/core/handler/render/FirepitRender.java @@ -1,7 +1,5 @@ package gtPlusPlus.core.handler.render; -import org.lwjgl.opengl.GL11; - import net.minecraft.block.Block; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.Tessellator; @@ -10,46 +8,49 @@ import net.minecraft.entity.Entity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; -public class FirepitRender extends TileEntitySpecialRenderer{ - ResourceLocation texture = new ResourceLocation("miscutils" + ":"+ "textures/blocks/FirePit/mossyFirepit.png"); - - private final FirepitModel model; - - public FirepitRender(){ - this.model = new FirepitModel(); - } - - private void adjustRotatePivotViaMeta(final World world, final int x, final int y, final int z) { - final int meta = world.getBlockMetadata(x, y, z); - GL11.glPushMatrix(); - GL11.glRotatef(meta * (-90), 0.0F, 0.0F, 1.0F); - GL11.glPopMatrix(); - } - - @Override - public void renderTileEntityAt(final TileEntity entity, final double x, final double y, final double z, final float i) { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.1F, (float)y + 1.0F, (float)z + 0.5F); - GL11.glRotatef(180, 0F, 0F, 1F); - - this.bindTexture(this.texture); - GL11.glPushMatrix(); - this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); - GL11.glTranslatef(1.0f, 1.0f, 1.0f); - GL11.glPopMatrix(); - GL11.glPopMatrix(); - } - - //Set the lighting stuff, so it changes it's brightness properly. - private void adjustLightFixture(final World world, final int i, final int j, final int k, final Block block) { - final Tessellator tess = Tessellator.instance; - //float brightness = block.getBlockBrightness(world, i, j, k); - //As of MC 1.7+ block.getBlockBrightness() has become block.getLightValue(): - final float brightness = block.getLightValue(world, i, j, k); - final int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0); - final int modulousModifier = skyLight % 65536; - final int divModifier = skyLight / 65536; - tess.setColorOpaque_F(brightness, brightness, brightness); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, modulousModifier, divModifier); - } +import org.lwjgl.opengl.GL11; + +public class FirepitRender extends TileEntitySpecialRenderer { + ResourceLocation texture = new ResourceLocation("miscutils" + ":" + "textures/blocks/FirePit/mossyFirepit.png"); + + private final FirepitModel model; + + public FirepitRender() { + this.model = new FirepitModel(); + } + + private void adjustRotatePivotViaMeta(final World world, final int x, final int y, final int z) { + final int meta = world.getBlockMetadata(x, y, z); + GL11.glPushMatrix(); + GL11.glRotatef(meta * (-90), 0.0F, 0.0F, 1.0F); + GL11.glPopMatrix(); + } + + @Override + public void renderTileEntityAt( + final TileEntity entity, final double x, final double y, final double z, final float i) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.1F, (float) y + 1.0F, (float) z + 0.5F); + GL11.glRotatef(180, 0F, 0F, 1F); + + this.bindTexture(this.texture); + GL11.glPushMatrix(); + this.model.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); + GL11.glTranslatef(1.0f, 1.0f, 1.0f); + GL11.glPopMatrix(); + GL11.glPopMatrix(); + } + + // Set the lighting stuff, so it changes it's brightness properly. + private void adjustLightFixture(final World world, final int i, final int j, final int k, final Block block) { + final Tessellator tess = Tessellator.instance; + // float brightness = block.getBlockBrightness(world, i, j, k); + // As of MC 1.7+ block.getBlockBrightness() has become block.getLightValue(): + final float brightness = block.getLightValue(world, i, j, k); + final int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0); + final int modulousModifier = skyLight % 65536; + final int divModifier = skyLight / 65536; + tess.setColorOpaque_F(brightness, brightness, brightness); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, modulousModifier, divModifier); + } } diff --git a/src/main/java/gtPlusPlus/core/handler/workbench/Workbench_CraftingHandler.java b/src/main/java/gtPlusPlus/core/handler/workbench/Workbench_CraftingHandler.java index d6a73512e2..d68d07c5eb 100644 --- a/src/main/java/gtPlusPlus/core/handler/workbench/Workbench_CraftingHandler.java +++ b/src/main/java/gtPlusPlus/core/handler/workbench/Workbench_CraftingHandler.java @@ -3,7 +3,6 @@ package gtPlusPlus.core.handler.workbench; import java.util.ArrayList; import java.util.HashMap; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -17,192 +16,153 @@ import net.minecraft.world.World; public class Workbench_CraftingHandler { - private static final Workbench_CraftingHandler instance = new Workbench_CraftingHandler(); - private final List recipes = new ArrayList(); - - public static final Workbench_CraftingHandler getInstance() { - return instance; - } - public Workbench_CraftingHandler() { - - //just a example recipe so you know how to add them - this.addRecipe(new ItemStack(Blocks.iron_block), new Object[] - { - "###", - "###", - "###", - Character.valueOf('#'), Items.iron_ingot - }); - - //another example Recipe, but shapeless - this.addShapelessRecipe(new ItemStack(Items.cake),new Object[]{Items.stick}); - - - } - - void addRecipe(final ItemStack par1ItemStack, final Object par2ArrayOfObj[]) - { - String s = ""; - int i = 0; - int j = 0; - int k = 0; - - if (par2ArrayOfObj[i] instanceof String[]) - { - final String as[] = (String[])par2ArrayOfObj[i++]; - - for (int l = 0; l < as.length; l++) - { - final String s2 = as[l]; - k++; - j = s2.length(); - s = (new StringBuilder()).append(s).append(s2).toString(); - } - } - else - { - while (par2ArrayOfObj[i] instanceof String) - { - final String s1 = (String)par2ArrayOfObj[i++]; - k++; - j = s1.length(); - s = (new StringBuilder()).append(s).append(s1).toString(); - } - } - - final HashMap hashmap = new HashMap(); - - for (; i < par2ArrayOfObj.length; i += 2) - { - final Character character = (Character)par2ArrayOfObj[i]; - ItemStack itemstack = null; - - if (par2ArrayOfObj[i + 1] instanceof Item) - { - itemstack = new ItemStack((Item)par2ArrayOfObj[i + 1]); - } - else if (par2ArrayOfObj[i + 1] instanceof Block) - { - itemstack = new ItemStack((Block)par2ArrayOfObj[i + 1], 1, -1); - } - else if (par2ArrayOfObj[i + 1] instanceof ItemStack) - { - itemstack = (ItemStack)par2ArrayOfObj[i + 1]; - } - - hashmap.put(character, itemstack); - } - - final ItemStack aitemstack[] = new ItemStack[j * k]; - - for (int i1 = 0; i1 < (j * k); i1++) - { - final char c = s.charAt(i1); - - if (hashmap.containsKey(Character.valueOf(c))) - { - aitemstack[i1] = hashmap.get(Character.valueOf(c)).copy(); - } - else - { - aitemstack[i1] = null; - } - } - - this.recipes.add(new ShapedRecipes(j, k, aitemstack, par1ItemStack)); - } - - public void addShapelessRecipe(final ItemStack par1ItemStack, final Object par2ArrayOfObj[]) - { - final ArrayList arraylist = new ArrayList(); - final Object aobj[] = par2ArrayOfObj; - final int i = aobj.length; - - for (int j = 0; j < i; j++) - { - final Object obj = aobj[j]; - - if (obj instanceof ItemStack) - { - arraylist.add(((ItemStack)obj).copy()); - continue; - } - - if (obj instanceof Item) - { - arraylist.add(new ItemStack((Item)obj)); - continue; - } - - if (obj instanceof Block) - { - arraylist.add(new ItemStack((Block)obj)); - } - else - { - throw new RuntimeException("Invalid shapeless recipe!"); - } - } - - this.recipes.add(new ShapelessRecipes(par1ItemStack, arraylist)); - } - - public ItemStack findMatchingRecipe(final InventoryCrafting par1InventoryCrafting, final World par2World) - { - int i = 0; - for (int j = 0; j < par1InventoryCrafting.getSizeInventory(); j++) - { - final ItemStack itemstack2 = par1InventoryCrafting.getStackInSlot(j); - - if (itemstack2 == null) - { - continue; - } - - if (i == 0) - { - } - - if (i == 1) - { - } - - i++; - } - - //TODO - Update from itemIDs - /*if (i == 2 && itemstack.itemID == itemstack1.itemID && itemstack.stackSize == 1 && itemstack1.stackSize == 1 && Item.itemsList[itemstack.itemID].isDamageable()) - { - Item item = Item.itemsList[itemstack.itemID]; - int l = item.getMaxDamage() - itemstack.getItemDamageForDisplay(); - int i1 = item.getMaxDamage() - itemstack1.getItemDamageForDisplay(); - int j1 = l + i1 + (item.getMaxDamage() * 10) / 100; - int k1 = item.getMaxDamage() - j1; - - if (k1 < 0) - { - k1 = 0; - } - - return new ItemStack(itemstack.itemID, 1, k1); - }*/ - - for (int k = 0; k < this.recipes.size(); k++) - { - final IRecipe irecipe = this.recipes.get(k); - - if (irecipe.matches(par1InventoryCrafting, par2World)) - { - return irecipe.getCraftingResult(par1InventoryCrafting); - } - } - - return null; - } - - - public List getRecipeList() - { - return this.recipes; - } -} \ No newline at end of file + private static final Workbench_CraftingHandler instance = new Workbench_CraftingHandler(); + private final List recipes = new ArrayList(); + + public static final Workbench_CraftingHandler getInstance() { + return instance; + } + + public Workbench_CraftingHandler() { + + // just a example recipe so you know how to add them + this.addRecipe( + new ItemStack(Blocks.iron_block), + new Object[] {"###", "###", "###", Character.valueOf('#'), Items.iron_ingot}); + + // another example Recipe, but shapeless + this.addShapelessRecipe(new ItemStack(Items.cake), new Object[] {Items.stick}); + } + + void addRecipe(final ItemStack par1ItemStack, final Object par2ArrayOfObj[]) { + String s = ""; + int i = 0; + int j = 0; + int k = 0; + + if (par2ArrayOfObj[i] instanceof String[]) { + final String as[] = (String[]) par2ArrayOfObj[i++]; + + for (int l = 0; l < as.length; l++) { + final String s2 = as[l]; + k++; + j = s2.length(); + s = (new StringBuilder()).append(s).append(s2).toString(); + } + } else { + while (par2ArrayOfObj[i] instanceof String) { + final String s1 = (String) par2ArrayOfObj[i++]; + k++; + j = s1.length(); + s = (new StringBuilder()).append(s).append(s1).toString(); + } + } + + final HashMap hashmap = new HashMap(); + + for (; i < par2ArrayOfObj.length; i += 2) { + final Character character = (Character) par2ArrayOfObj[i]; + ItemStack itemstack = null; + + if (par2ArrayOfObj[i + 1] instanceof Item) { + itemstack = new ItemStack((Item) par2ArrayOfObj[i + 1]); + } else if (par2ArrayOfObj[i + 1] instanceof Block) { + itemstack = new ItemStack((Block) par2ArrayOfObj[i + 1], 1, -1); + } else if (par2ArrayOfObj[i + 1] instanceof ItemStack) { + itemstack = (ItemStack) par2ArrayOfObj[i + 1]; + } + + hashmap.put(character, itemstack); + } + + final ItemStack aitemstack[] = new ItemStack[j * k]; + + for (int i1 = 0; i1 < (j * k); i1++) { + final char c = s.charAt(i1); + + if (hashmap.containsKey(Character.valueOf(c))) { + aitemstack[i1] = hashmap.get(Character.valueOf(c)).copy(); + } else { + aitemstack[i1] = null; + } + } + + this.recipes.add(new ShapedRecipes(j, k, aitemstack, par1ItemStack)); + } + + public void addShapelessRecipe(final ItemStack par1ItemStack, final Object par2ArrayOfObj[]) { + final ArrayList arraylist = new ArrayList(); + final Object aobj[] = par2ArrayOfObj; + final int i = aobj.length; + + for (int j = 0; j < i; j++) { + final Object obj = aobj[j]; + + if (obj instanceof ItemStack) { + arraylist.add(((ItemStack) obj).copy()); + continue; + } + + if (obj instanceof Item) { + arraylist.add(new ItemStack((Item) obj)); + continue; + } + + if (obj instanceof Block) { + arraylist.add(new ItemStack((Block) obj)); + } else { + throw new RuntimeException("Invalid shapeless recipe!"); + } + } + + this.recipes.add(new ShapelessRecipes(par1ItemStack, arraylist)); + } + + public ItemStack findMatchingRecipe(final InventoryCrafting par1InventoryCrafting, final World par2World) { + int i = 0; + for (int j = 0; j < par1InventoryCrafting.getSizeInventory(); j++) { + final ItemStack itemstack2 = par1InventoryCrafting.getStackInSlot(j); + + if (itemstack2 == null) { + continue; + } + + if (i == 0) {} + + if (i == 1) {} + + i++; + } + + // TODO - Update from itemIDs + /*if (i == 2 && itemstack.itemID == itemstack1.itemID && itemstack.stackSize == 1 && itemstack1.stackSize == 1 && Item.itemsList[itemstack.itemID].isDamageable()) + { + Item item = Item.itemsList[itemstack.itemID]; + int l = item.getMaxDamage() - itemstack.getItemDamageForDisplay(); + int i1 = item.getMaxDamage() - itemstack1.getItemDamageForDisplay(); + int j1 = l + i1 + (item.getMaxDamage() * 10) / 100; + int k1 = item.getMaxDamage() - j1; + + if (k1 < 0) + { + k1 = 0; + } + + return new ItemStack(itemstack.itemID, 1, k1); + }*/ + + for (int k = 0; k < this.recipes.size(); k++) { + final IRecipe irecipe = this.recipes.get(k); + + if (irecipe.matches(par1InventoryCrafting, par2World)) { + return irecipe.getCraftingResult(par1InventoryCrafting); + } + } + + return null; + } + + public List getRecipeList() { + return this.recipes; + } +} diff --git a/src/main/java/gtPlusPlus/core/handler/workbench/Workbench_RecipeSorter.java b/src/main/java/gtPlusPlus/core/handler/workbench/Workbench_RecipeSorter.java index 9d5f7d03ed..d8b25c4746 100644 --- a/src/main/java/gtPlusPlus/core/handler/workbench/Workbench_RecipeSorter.java +++ b/src/main/java/gtPlusPlus/core/handler/workbench/Workbench_RecipeSorter.java @@ -1,44 +1,35 @@ package gtPlusPlus.core.handler.workbench; import java.util.Comparator; - import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.ShapedRecipes; import net.minecraft.item.crafting.ShapelessRecipes; -public class Workbench_RecipeSorter implements Comparator -{ - final Workbench_CraftingHandler CraftingManagerCrafter; - - Workbench_RecipeSorter(final Workbench_CraftingHandler par1CraftingManager) - { - this.CraftingManagerCrafter = par1CraftingManager; - } - - public int compareRecipes(final IRecipe par1IRecipe, final IRecipe par2IRecipe) - { - if ((par1IRecipe instanceof ShapelessRecipes) && (par2IRecipe instanceof ShapedRecipes)) - { - return 1; - } - - if ((par2IRecipe instanceof ShapelessRecipes) && (par1IRecipe instanceof ShapedRecipes)) - { - return -1; - } - - if (par2IRecipe.getRecipeSize() < par1IRecipe.getRecipeSize()) - { - return -1; - } - - return par2IRecipe.getRecipeSize() <= par1IRecipe.getRecipeSize() ? 0 : 1; - } - - @Override - public int compare(final Object par1Obj, final Object par2Obj) - { - return this.compareRecipes((IRecipe)par1Obj, (IRecipe)par2Obj); - } - -} \ No newline at end of file +public class Workbench_RecipeSorter implements Comparator { + final Workbench_CraftingHandler CraftingManagerCrafter; + + Workbench_RecipeSorter(final Workbench_CraftingHandler par1CraftingManager) { + this.CraftingManagerCrafter = par1CraftingManager; + } + + public int compareRecipes(final IRecipe par1IRecipe, final IRecipe par2IRecipe) { + if ((par1IRecipe instanceof ShapelessRecipes) && (par2IRecipe instanceof ShapedRecipes)) { + return 1; + } + + if ((par2IRecipe instanceof ShapelessRecipes) && (par1IRecipe instanceof ShapedRecipes)) { + return -1; + } + + if (par2IRecipe.getRecipeSize() < par1IRecipe.getRecipeSize()) { + return -1; + } + + return par2IRecipe.getRecipeSize() <= par1IRecipe.getRecipeSize() ? 0 : 1; + } + + @Override + public int compare(final Object par1Obj, final Object par2Obj) { + return this.compareRecipes((IRecipe) par1Obj, (IRecipe) par2Obj); + } +} diff --git a/src/main/java/gtPlusPlus/core/interfaces/IGuiManager.java b/src/main/java/gtPlusPlus/core/interfaces/IGuiManager.java index 1d0ad9ed87..599ed6b59b 100644 --- a/src/main/java/gtPlusPlus/core/interfaces/IGuiManager.java +++ b/src/main/java/gtPlusPlus/core/interfaces/IGuiManager.java @@ -4,13 +4,13 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; -public abstract interface IGuiManager extends IGuiManagerMiscUtils{ +public abstract interface IGuiManager extends IGuiManagerMiscUtils { - public abstract ChunkCoordinates getCoordinates(); + public abstract ChunkCoordinates getCoordinates(); - public abstract World getWorld(); + public abstract World getWorld(); - public abstract Object getGui(EntityPlayer paramEntityPlayer, int paramInt); + public abstract Object getGui(EntityPlayer paramEntityPlayer, int paramInt); - public abstract Object getContainer(EntityPlayer paramEntityPlayer, int paramInt); + public abstract Object getContainer(EntityPlayer paramEntityPlayer, int paramInt); } diff --git a/src/main/java/gtPlusPlus/core/interfaces/IGuiManagerMiscUtils.java b/src/main/java/gtPlusPlus/core/interfaces/IGuiManagerMiscUtils.java index cf46c67a54..f5f10162f9 100644 --- a/src/main/java/gtPlusPlus/core/interfaces/IGuiManagerMiscUtils.java +++ b/src/main/java/gtPlusPlus/core/interfaces/IGuiManagerMiscUtils.java @@ -1,3 +1,3 @@ package gtPlusPlus.core.interfaces; -public abstract interface IGuiManagerMiscUtils {} \ No newline at end of file +public abstract interface IGuiManagerMiscUtils {} diff --git a/src/main/java/gtPlusPlus/core/interfaces/IItemBlueprint.java b/src/main/java/gtPlusPlus/core/interfaces/IItemBlueprint.java index 473aa827b6..2c320b5830 100644 --- a/src/main/java/gtPlusPlus/core/interfaces/IItemBlueprint.java +++ b/src/main/java/gtPlusPlus/core/interfaces/IItemBlueprint.java @@ -5,44 +5,43 @@ import net.minecraft.item.ItemStack; public interface IItemBlueprint { - /** - * The inventory size for the blueprint~ - */ - public int INV_SIZE = 9; - - /** - * Meta Compatible function to allow meta items to be blueprints - * @param stack yourMetaItem - * @return true if it is a Blueprint - */ - public boolean isBlueprint(ItemStack stack); - - /** - * Sets the blueprint for this itemstack. - * @param stack yourMetaItem - * @return true if blueprint is set successfully - */ - public boolean setBlueprint(ItemStack stack, IInventory craftingTable, ItemStack output); - - /** - * Sets the name of the recipe/blueprint - * @param String Blueprint Name - * @return N/A - */ - public void setBlueprintName(ItemStack stack, String name); - - /** - * Does this itemstack hold a blueprint? - * @param stack yourMetaItem - * @return true if is holding a Blueprint - */ - public boolean hasBlueprint(ItemStack stack); - - /** - * Gets the recipe held by the item - * @param stack yourMetaItem - * @return the blueprints contents - */ - public ItemStack[] getBlueprint(ItemStack stack); - + /** + * The inventory size for the blueprint~ + */ + public int INV_SIZE = 9; + + /** + * Meta Compatible function to allow meta items to be blueprints + * @param stack yourMetaItem + * @return true if it is a Blueprint + */ + public boolean isBlueprint(ItemStack stack); + + /** + * Sets the blueprint for this itemstack. + * @param stack yourMetaItem + * @return true if blueprint is set successfully + */ + public boolean setBlueprint(ItemStack stack, IInventory craftingTable, ItemStack output); + + /** + * Sets the name of the recipe/blueprint + * @param String Blueprint Name + * @return N/A + */ + public void setBlueprintName(ItemStack stack, String name); + + /** + * Does this itemstack hold a blueprint? + * @param stack yourMetaItem + * @return true if is holding a Blueprint + */ + public boolean hasBlueprint(ItemStack stack); + + /** + * Gets the recipe held by the item + * @param stack yourMetaItem + * @return the blueprints contents + */ + public ItemStack[] getBlueprint(ItemStack stack); } diff --git a/src/main/java/gtPlusPlus/core/inventories/BaseInventoryBackpack.java b/src/main/java/gtPlusPlus/core/inventories/BaseInventoryBackpack.java index 256fedb13c..3dce83535b 100644 --- a/src/main/java/gtPlusPlus/core/inventories/BaseInventoryBackpack.java +++ b/src/main/java/gtPlusPlus/core/inventories/BaseInventoryBackpack.java @@ -1,241 +1,214 @@ package gtPlusPlus.core.inventories; +import gtPlusPlus.core.item.base.BaseItemBackpack; import java.util.UUID; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; - -import gtPlusPlus.core.item.base.BaseItemBackpack; import net.minecraftforge.common.util.Constants; -public class BaseInventoryBackpack implements IInventory{ - - private final String name = "Inventory Item"; - - /** Provides NBT Tag Compound to reference */ - private final ItemStack invItem; - - /** Defining your inventory size this way is handy */ - public static final int INV_SIZE = 8; - - /** Inventory's size must be same as number of slots you add to the Container class */ - private final ItemStack[] inventory = new ItemStack[INV_SIZE]; - - // declaration of variable: - protected String uniqueID; - - /** - * @param itemstack - the ItemStack to which this inventory belongs - */ - public BaseInventoryBackpack(final ItemStack stack) - { - this.invItem = stack; - - /** initialize variable within the constructor: */ - this.uniqueID = ""; - - if (!stack.hasTagCompound()) - { - stack.setTagCompound(new NBTTagCompound()); - // no tag compound means the itemstack does not yet have a UUID, so assign one: - this.uniqueID = UUID.randomUUID().toString(); - } - - // Create a new NBT Tag Compound if one doesn't already exist, or you will crash - if (!stack.hasTagCompound()) { - stack.setTagCompound(new NBTTagCompound()); - } - // note that it's okay to use stack instead of invItem right there - // both reference the same memory location, so whatever you change using - // either reference will change in the other - - // Read the inventory contents from NBT - this.readFromNBT(stack.getTagCompound()); - } - @Override - public int getSizeInventory() - { - return this.inventory.length; - } - - @Override - public ItemStack getStackInSlot(final int slot) - { - return this.inventory[slot]; - } - - @Override - public ItemStack decrStackSize(final int slot, final int amount) - { - ItemStack stack = this.getStackInSlot(slot); - if(stack != null) - { - if(stack.stackSize > amount) - { - stack = stack.splitStack(amount); - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - else - { - // this method also calls markDirty, so we don't need to call it again - this.setInventorySlotContents(slot, null); - } - } - return stack; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) - { - final ItemStack stack = this.getStackInSlot(slot); - this.setInventorySlotContents(slot, null); - return stack; - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) - { - this.inventory[slot] = stack; - - if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) - { - stack.stackSize = this.getInventoryStackLimit(); - } - - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - - // 1.7.2+ renamed to getInventoryName - @Override - public String getInventoryName() - { - return this.name; - } - - // 1.7.2+ renamed to hasCustomInventoryName - @Override - public boolean hasCustomInventoryName() - { - return this.name.length() > 0; - } - - @Override - public int getInventoryStackLimit() - { - return 64; - } - - /** - * This is the method that will handle saving the inventory contents, as it is called (or should be called!) - * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also - * let you change things in your inventory without ever opening a Gui, if you want. - */ - // 1.7.2+ renamed to markDirty - @Override - public void markDirty() - { - for (int i = 0; i < this.getSizeInventory(); ++i) - { - if ((this.getStackInSlot(i) != null) && (this.getStackInSlot(i).stackSize == 0)) { - this.inventory[i] = null; - } - } - - // This line here does the work: - this.writeToNBT(this.invItem.getTagCompound()); - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) - { - return true; - } - - // 1.7.2+ renamed to openInventory(EntityPlayer player) - @Override - public void openInventory() {} - - // 1.7.2+ renamed to closeInventory(EntityPlayer player) - @Override - public void closeInventory() {} - - /** - * This method doesn't seem to do what it claims to do, as - * items can still be left-clicked and placed in the inventory - * even when this returns false - */ - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) - { - // Don't want to be able to store the inventory item within itself - // Bad things will happen, like losing your inventory - // Actually, this needs a custom Slot to work - return !(itemstack.getItem() instanceof BaseItemBackpack); - } - - /** - * A custom method to read our inventory from an ItemStack's NBT compound - */ - public void readFromNBT(final NBTTagCompound compound) - { - // Gets the custom taglist we wrote to this compound, if any - // 1.7.2+ change to compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND); - final NBTTagList items = compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND); - - if ("".equals(this.uniqueID)) - { - // try to read unique ID from NBT - this.uniqueID = compound.getString("uniqueID"); - // if it's still "", assign a new one: - if ("".equals(this.uniqueID)) - { - this.uniqueID = UUID.randomUUID().toString(); - } - } - - for (int i = 0; i < items.tagCount(); ++i) - { - // 1.7.2+ change to items.getCompoundTagAt(i) - final NBTTagCompound item = items.getCompoundTagAt(i); - final int slot = item.getInteger("Slot"); - - // Just double-checking that the saved slot index is within our inventory array bounds - if ((slot >= 0) && (slot < this.getSizeInventory())) { - this.inventory[slot] = ItemStack.loadItemStackFromNBT(item); - } - } - } - - /** - * A custom method to write our inventory to an ItemStack's NBT compound - */ - public void writeToNBT(final NBTTagCompound tagcompound) - { - // Create a new NBT Tag List to store itemstacks as NBT Tags - final NBTTagList items = new NBTTagList(); - - for (int i = 0; i < this.getSizeInventory(); ++i) - { - // Only write stacks that contain items - if (this.getStackInSlot(i) != null) - { - // Make a new NBT Tag Compound to write the itemstack and slot index to - final NBTTagCompound item = new NBTTagCompound(); - item.setInteger("Slot", i); - // Writes the itemstack in slot(i) to the Tag Compound we just made - this.getStackInSlot(i).writeToNBT(item); - - // add the tag compound to our tag list - items.appendTag(item); - } - } - tagcompound.setString("uniqueID", this.uniqueID); - // Add the TagList to the ItemStack's Tag Compound with the name "ItemInventory" - tagcompound.setTag("ItemInventory", items); - } -} \ No newline at end of file +public class BaseInventoryBackpack implements IInventory { + + private final String name = "Inventory Item"; + + /** Provides NBT Tag Compound to reference */ + private final ItemStack invItem; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 8; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private final ItemStack[] inventory = new ItemStack[INV_SIZE]; + + // declaration of variable: + protected String uniqueID; + + /** + * @param itemstack - the ItemStack to which this inventory belongs + */ + public BaseInventoryBackpack(final ItemStack stack) { + this.invItem = stack; + + /** initialize variable within the constructor: */ + this.uniqueID = ""; + + if (!stack.hasTagCompound()) { + stack.setTagCompound(new NBTTagCompound()); + // no tag compound means the itemstack does not yet have a UUID, so assign one: + this.uniqueID = UUID.randomUUID().toString(); + } + + // Create a new NBT Tag Compound if one doesn't already exist, or you will crash + if (!stack.hasTagCompound()) { + stack.setTagCompound(new NBTTagCompound()); + } + // note that it's okay to use stack instead of invItem right there + // both reference the same memory location, so whatever you change using + // either reference will change in the other + + // Read the inventory contents from NBT + this.readFromNBT(stack.getTagCompound()); + } + + @Override + public int getSizeInventory() { + return this.inventory.length; + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.inventory[slot]; + } + + @Override + public ItemStack decrStackSize(final int slot, final int amount) { + ItemStack stack = this.getStackInSlot(slot); + if (stack != null) { + if (stack.stackSize > amount) { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } else { + // this method also calls markDirty, so we don't need to call it again + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.inventory[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() { + return this.name.length() > 0; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + /** + * This is the method that will handle saving the inventory contents, as it is called (or should be called!) + * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also + * let you change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() { + for (int i = 0; i < this.getSizeInventory(); ++i) { + if ((this.getStackInSlot(i) != null) && (this.getStackInSlot(i).stackSize == 0)) { + this.inventory[i] = null; + } + } + + // This line here does the work: + this.writeToNBT(this.invItem.getTagCompound()); + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as + * items can still be left-clicked and placed in the inventory + * even when this returns false + */ + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + // Don't want to be able to store the inventory item within itself + // Bad things will happen, like losing your inventory + // Actually, this needs a custom Slot to work + return !(itemstack.getItem() instanceof BaseItemBackpack); + } + + /** + * A custom method to read our inventory from an ItemStack's NBT compound + */ + public void readFromNBT(final NBTTagCompound compound) { + // Gets the custom taglist we wrote to this compound, if any + // 1.7.2+ change to compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND); + final NBTTagList items = compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND); + + if ("".equals(this.uniqueID)) { + // try to read unique ID from NBT + this.uniqueID = compound.getString("uniqueID"); + // if it's still "", assign a new one: + if ("".equals(this.uniqueID)) { + this.uniqueID = UUID.randomUUID().toString(); + } + } + + for (int i = 0; i < items.tagCount(); ++i) { + // 1.7.2+ change to items.getCompoundTagAt(i) + final NBTTagCompound item = items.getCompoundTagAt(i); + final int slot = item.getInteger("Slot"); + + // Just double-checking that the saved slot index is within our inventory array bounds + if ((slot >= 0) && (slot < this.getSizeInventory())) { + this.inventory[slot] = ItemStack.loadItemStackFromNBT(item); + } + } + } + + /** + * A custom method to write our inventory to an ItemStack's NBT compound + */ + public void writeToNBT(final NBTTagCompound tagcompound) { + // Create a new NBT Tag List to store itemstacks as NBT Tags + final NBTTagList items = new NBTTagList(); + + for (int i = 0; i < this.getSizeInventory(); ++i) { + // Only write stacks that contain items + if (this.getStackInSlot(i) != null) { + // Make a new NBT Tag Compound to write the itemstack and slot index to + final NBTTagCompound item = new NBTTagCompound(); + item.setInteger("Slot", i); + // Writes the itemstack in slot(i) to the Tag Compound we just made + this.getStackInSlot(i).writeToNBT(item); + + // add the tag compound to our tag list + items.appendTag(item); + } + } + tagcompound.setString("uniqueID", this.uniqueID); + // Add the TagList to the ItemStack's Tag Compound with the name "ItemInventory" + tagcompound.setTag("ItemInventory", items); + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/BaseInventoryGrindle.java b/src/main/java/gtPlusPlus/core/inventories/BaseInventoryGrindle.java index 823398bd57..b402dcea20 100644 --- a/src/main/java/gtPlusPlus/core/inventories/BaseInventoryGrindle.java +++ b/src/main/java/gtPlusPlus/core/inventories/BaseInventoryGrindle.java @@ -1,224 +1,220 @@ package gtPlusPlus.core.inventories; +import gtPlusPlus.core.item.base.BaseItemBackpack; import java.util.UUID; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; - -import gtPlusPlus.core.item.base.BaseItemBackpack; import net.minecraftforge.common.util.Constants; public class BaseInventoryGrindle implements IInventory { - private final String name = "Inventory Item"; - - /** Provides NBT Tag Compound to reference */ - private final ItemStack invItem; - - /** Defining your inventory size this way is handy */ - public static final int INV_SIZE = 6; - - /** - * Inventory's size must be same as number of slots you add to the Container - * class - */ - private final ItemStack[] inventory = new ItemStack[INV_SIZE]; - - // declaration of variable: - protected String uniqueID; - - /** - * @param itemstack - * - the ItemStack to which this inventory belongs - */ - public BaseInventoryGrindle(final ItemStack stack) { - this.invItem = stack; - - /** initialize variable within the constructor: */ - this.uniqueID = ""; - - if (!stack.hasTagCompound()) { - stack.setTagCompound(new NBTTagCompound()); - // no tag compound means the itemstack does not yet have a UUID, so assign one: - this.uniqueID = UUID.randomUUID().toString(); - } - - // Create a new NBT Tag Compound if one doesn't already exist, or you will crash - if (!stack.hasTagCompound()) { - stack.setTagCompound(new NBTTagCompound()); - } - // note that it's okay to use stack instead of invItem right there - // both reference the same memory location, so whatever you change using - // either reference will change in the other - - // Read the inventory contents from NBT - this.readFromNBT(stack.getTagCompound()); - } - - @Override - public int getSizeInventory() { - return this.inventory.length; - } - - @Override - public ItemStack getStackInSlot(final int slot) { - return this.inventory[slot]; - } - - @Override - public ItemStack decrStackSize(final int slot, final int amount) { - ItemStack stack = this.getStackInSlot(slot); - if (stack != null) { - if (stack.stackSize > amount) { - stack = stack.splitStack(amount); - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } else { - // this method also calls markDirty, so we don't need to call it again - this.setInventorySlotContents(slot, null); - } - } - return stack; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) { - final ItemStack stack = this.getStackInSlot(slot); - this.setInventorySlotContents(slot, null); - return stack; - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) { - this.inventory[slot] = stack; - - if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) { - stack.stackSize = this.getInventoryStackLimit(); - } - - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - - // 1.7.2+ renamed to getInventoryName - @Override - public String getInventoryName() { - return this.name; - } - - // 1.7.2+ renamed to hasCustomInventoryName - @Override - public boolean hasCustomInventoryName() { - return this.name.length() > 0; - } - - @Override - public int getInventoryStackLimit() { - return 1; - } - - /** - * This is the method that will handle saving the inventory contents, as it is - * called (or should be called!) anytime the inventory changes. Perfect. Much - * better than using onUpdate in an Item, as this will also let you change - * things in your inventory without ever opening a Gui, if you want. - */ - // 1.7.2+ renamed to markDirty - @Override - public void markDirty() { - for (int i = 0; i < this.getSizeInventory(); ++i) { - if ((this.getStackInSlot(i) != null) && (this.getStackInSlot(i).stackSize == 0)) { - this.inventory[i] = null; - } - } - - // This line here does the work: - this.writeToNBT(this.invItem.getTagCompound()); - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) { - return true; - } - - // 1.7.2+ renamed to openInventory(EntityPlayer player) - @Override - public void openInventory() { - } - - // 1.7.2+ renamed to closeInventory(EntityPlayer player) - @Override - public void closeInventory() { - } - - /** - * This method doesn't seem to do what it claims to do, as items can still be - * left-clicked and placed in the inventory even when this returns false - */ - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { - // Don't want to be able to store the inventory item within itself - // Bad things will happen, like losing your inventory - // Actually, this needs a custom Slot to work - return !(itemstack.getItem() instanceof BaseItemBackpack); - } - - /** - * A custom method to read our inventory from an ItemStack's NBT compound - */ - public void readFromNBT(final NBTTagCompound compound) { - // Gets the custom taglist we wrote to this compound, if any - // 1.7.2+ change to compound.getTagList("ItemInventory", - // Constants.NBT.TAG_COMPOUND); - final NBTTagList items = compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND); - - if ("".equals(this.uniqueID)) { - // try to read unique ID from NBT - this.uniqueID = compound.getString("uniqueID"); - // if it's still "", assign a new one: - if ("".equals(this.uniqueID)) { - this.uniqueID = UUID.randomUUID().toString(); - } - } - - for (int i = 0; i < items.tagCount(); ++i) { - // 1.7.2+ change to items.getCompoundTagAt(i) - final NBTTagCompound item = items.getCompoundTagAt(i); - final int slot = item.getInteger("Slot"); - - // Just double-checking that the saved slot index is within our inventory array - // bounds - if ((slot >= 0) && (slot < this.getSizeInventory())) { - this.inventory[slot] = ItemStack.loadItemStackFromNBT(item); - } - } - } - - /** - * A custom method to write our inventory to an ItemStack's NBT compound - */ - public void writeToNBT(final NBTTagCompound tagcompound) { - // Create a new NBT Tag List to store itemstacks as NBT Tags - final NBTTagList items = new NBTTagList(); - - for (int i = 0; i < this.getSizeInventory(); ++i) { - // Only write stacks that contain items - if (this.getStackInSlot(i) != null) { - // Make a new NBT Tag Compound to write the itemstack and slot index to - final NBTTagCompound item = new NBTTagCompound(); - item.setInteger("Slot", i); - // Writes the itemstack in slot(i) to the Tag Compound we just made - this.getStackInSlot(i).writeToNBT(item); - - // add the tag compound to our tag list - items.appendTag(item); - } - } - tagcompound.setString("uniqueID", this.uniqueID); - // Add the TagList to the ItemStack's Tag Compound with the name "ItemInventory" - tagcompound.setTag("ItemInventory", items); - } -} \ No newline at end of file + private final String name = "Inventory Item"; + + /** Provides NBT Tag Compound to reference */ + private final ItemStack invItem; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 6; + + /** + * Inventory's size must be same as number of slots you add to the Container + * class + */ + private final ItemStack[] inventory = new ItemStack[INV_SIZE]; + + // declaration of variable: + protected String uniqueID; + + /** + * @param itemstack + * - the ItemStack to which this inventory belongs + */ + public BaseInventoryGrindle(final ItemStack stack) { + this.invItem = stack; + + /** initialize variable within the constructor: */ + this.uniqueID = ""; + + if (!stack.hasTagCompound()) { + stack.setTagCompound(new NBTTagCompound()); + // no tag compound means the itemstack does not yet have a UUID, so assign one: + this.uniqueID = UUID.randomUUID().toString(); + } + + // Create a new NBT Tag Compound if one doesn't already exist, or you will crash + if (!stack.hasTagCompound()) { + stack.setTagCompound(new NBTTagCompound()); + } + // note that it's okay to use stack instead of invItem right there + // both reference the same memory location, so whatever you change using + // either reference will change in the other + + // Read the inventory contents from NBT + this.readFromNBT(stack.getTagCompound()); + } + + @Override + public int getSizeInventory() { + return this.inventory.length; + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.inventory[slot]; + } + + @Override + public ItemStack decrStackSize(final int slot, final int amount) { + ItemStack stack = this.getStackInSlot(slot); + if (stack != null) { + if (stack.stackSize > amount) { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } else { + // this method also calls markDirty, so we don't need to call it again + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.inventory[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() { + return this.name.length() > 0; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + /** + * This is the method that will handle saving the inventory contents, as it is + * called (or should be called!) anytime the inventory changes. Perfect. Much + * better than using onUpdate in an Item, as this will also let you change + * things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() { + for (int i = 0; i < this.getSizeInventory(); ++i) { + if ((this.getStackInSlot(i) != null) && (this.getStackInSlot(i).stackSize == 0)) { + this.inventory[i] = null; + } + } + + // This line here does the work: + this.writeToNBT(this.invItem.getTagCompound()); + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as items can still be + * left-clicked and placed in the inventory even when this returns false + */ + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + // Don't want to be able to store the inventory item within itself + // Bad things will happen, like losing your inventory + // Actually, this needs a custom Slot to work + return !(itemstack.getItem() instanceof BaseItemBackpack); + } + + /** + * A custom method to read our inventory from an ItemStack's NBT compound + */ + public void readFromNBT(final NBTTagCompound compound) { + // Gets the custom taglist we wrote to this compound, if any + // 1.7.2+ change to compound.getTagList("ItemInventory", + // Constants.NBT.TAG_COMPOUND); + final NBTTagList items = compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND); + + if ("".equals(this.uniqueID)) { + // try to read unique ID from NBT + this.uniqueID = compound.getString("uniqueID"); + // if it's still "", assign a new one: + if ("".equals(this.uniqueID)) { + this.uniqueID = UUID.randomUUID().toString(); + } + } + + for (int i = 0; i < items.tagCount(); ++i) { + // 1.7.2+ change to items.getCompoundTagAt(i) + final NBTTagCompound item = items.getCompoundTagAt(i); + final int slot = item.getInteger("Slot"); + + // Just double-checking that the saved slot index is within our inventory array + // bounds + if ((slot >= 0) && (slot < this.getSizeInventory())) { + this.inventory[slot] = ItemStack.loadItemStackFromNBT(item); + } + } + } + + /** + * A custom method to write our inventory to an ItemStack's NBT compound + */ + public void writeToNBT(final NBTTagCompound tagcompound) { + // Create a new NBT Tag List to store itemstacks as NBT Tags + final NBTTagList items = new NBTTagList(); + + for (int i = 0; i < this.getSizeInventory(); ++i) { + // Only write stacks that contain items + if (this.getStackInSlot(i) != null) { + // Make a new NBT Tag Compound to write the itemstack and slot index to + final NBTTagCompound item = new NBTTagCompound(); + item.setInteger("Slot", i); + // Writes the itemstack in slot(i) to the Tag Compound we just made + this.getStackInSlot(i).writeToNBT(item); + + // add the tag compound to our tag list + items.appendTag(item); + } + } + tagcompound.setString("uniqueID", this.uniqueID); + // Add the TagList to the ItemStack's Tag Compound with the name "ItemInventory" + tagcompound.setTag("ItemInventory", items); + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/InventoryCircuitProgrammer.java b/src/main/java/gtPlusPlus/core/inventories/InventoryCircuitProgrammer.java index da45b5a988..0512dd4b15 100644 --- a/src/main/java/gtPlusPlus/core/inventories/InventoryCircuitProgrammer.java +++ b/src/main/java/gtPlusPlus/core/inventories/InventoryCircuitProgrammer.java @@ -7,167 +7,150 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -public class InventoryCircuitProgrammer implements IInventory{ - - private final String name = "Circuit Programmer"; - - /** Defining your inventory size this way is handy */ - public static final int INV_SIZE = 26; - - /** Inventory's size must be same as number of slots you add to the Container class */ - private ItemStack[] inventory = new ItemStack[INV_SIZE]; - - public void readFromNBT(final NBTTagCompound nbt){ - final NBTTagList list = nbt.getTagList("Items", 10); - this.inventory = new ItemStack[INV_SIZE]; - for(int i = 0;i= 0) && (slot < INV_SIZE)){ - //Utils.LOG_INFO("Trying to read NBT data from inventory."); - this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); - } - } - } - - public void writeToNBT(final NBTTagCompound nbt){ - final NBTTagList list = new NBTTagList(); - for(int i = 0;i amount) - { - stack = stack.splitStack(amount); - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - else - { - // this method also calls markDirty, so we don't need to call it again - this.setInventorySlotContents(slot, null); - } - } - return stack; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) - { - final ItemStack stack = this.getStackInSlot(slot); - this.setInventorySlotContents(slot, null); - return stack; - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) - { - this.inventory[slot] = stack; - - if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) - { - stack.stackSize = this.getInventoryStackLimit(); - } - - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - - // 1.7.2+ renamed to getInventoryName - @Override - public String getInventoryName() - { - return this.name; - } - - // 1.7.2+ renamed to hasCustomInventoryName - @Override - public boolean hasCustomInventoryName() - { - return this.name.length() > 0; - } - - @Override - public int getInventoryStackLimit() - { - return 64; - } - - /** - * This is the method that will handle saving the inventory contents, as it is called (or should be called!) - * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also - * let you change things in your inventory without ever opening a Gui, if you want. - */ - // 1.7.2+ renamed to markDirty - @Override - public void markDirty() - { - for (int i = 0; i < this.getSizeInventory(); ++i) - { - final ItemStack temp = this.getStackInSlot(i); - if (temp != null){ - //Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); - } - - if ((temp != null) && (temp.stackSize == 0)) { - this.inventory[i] = null; - } - } - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) - { - return true; - } - - // 1.7.2+ renamed to openInventory(EntityPlayer player) - @Override - public void openInventory() {} - - // 1.7.2+ renamed to closeInventory(EntityPlayer player) - @Override - public void closeInventory() {} - - /** - * This method doesn't seem to do what it claims to do, as - * items can still be left-clicked and placed in the inventory - * even when this returns false - */ - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { - return SlotIntegratedCircuit.isItemValidForSlot(itemstack); - } - -} \ No newline at end of file +public class InventoryCircuitProgrammer implements IInventory { + + private final String name = "Circuit Programmer"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 26; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + public void readFromNBT(final NBTTagCompound nbt) { + final NBTTagList list = nbt.getTagList("Items", 10); + this.inventory = new ItemStack[INV_SIZE]; + for (int i = 0; i < list.tagCount(); i++) { + final NBTTagCompound data = list.getCompoundTagAt(i); + final int slot = data.getInteger("Slot"); + if ((slot >= 0) && (slot < INV_SIZE)) { + // Utils.LOG_INFO("Trying to read NBT data from inventory."); + this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(final NBTTagCompound nbt) { + final NBTTagList list = new NBTTagList(); + for (int i = 0; i < INV_SIZE; i++) { + final ItemStack stack = this.inventory[i]; + if (stack != null) { + // Utils.LOG_INFO("Trying to write NBT data to inventory."); + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + nbt.setTag("Items", list); + } + + @Override + public int getSizeInventory() { + return this.inventory.length; + } + + public ItemStack[] getInventory() { + return this.inventory; + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.inventory[slot]; + } + + @Override + public ItemStack decrStackSize(final int slot, final int amount) { + ItemStack stack = this.getStackInSlot(slot); + if (stack != null) { + if (stack.stackSize > amount) { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } else { + // this method also calls markDirty, so we don't need to call it again + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.inventory[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() { + return this.name.length() > 0; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + /** + * This is the method that will handle saving the inventory contents, as it is called (or should be called!) + * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also + * let you change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() { + for (int i = 0; i < this.getSizeInventory(); ++i) { + final ItemStack temp = this.getStackInSlot(i); + if (temp != null) { + // Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); + } + + if ((temp != null) && (temp.stackSize == 0)) { + this.inventory[i] = null; + } + } + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as + * items can still be left-clicked and placed in the inventory + * even when this returns false + */ + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + return SlotIntegratedCircuit.isItemValidForSlot(itemstack); + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/InventoryFishTrap.java b/src/main/java/gtPlusPlus/core/inventories/InventoryFishTrap.java index 429ff517c1..2bf1a390b1 100644 --- a/src/main/java/gtPlusPlus/core/inventories/InventoryFishTrap.java +++ b/src/main/java/gtPlusPlus/core/inventories/InventoryFishTrap.java @@ -6,171 +6,153 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -public class InventoryFishTrap implements IInventory{ - - private final String name = "Fishtrap"; - - /** Defining your inventory size this way is handy */ - public static final int INV_SIZE = 15; - - /** Inventory's size must be same as number of slots you add to the Container class */ - private ItemStack[] inventory = new ItemStack[INV_SIZE]; - - public void readFromNBT(final NBTTagCompound nbt){ - final NBTTagList list = nbt.getTagList("Items", 10); - this.inventory = new ItemStack[INV_SIZE]; - for(int i = 0;i= 0) && (slot < INV_SIZE)){ - //Utils.LOG_INFO("Trying to read NBT data from inventory."); - this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); - } - } - } - - public void writeToNBT(final NBTTagCompound nbt){ - final NBTTagList list = new NBTTagList(); - for(int i = 0;i amount) - { - stack = stack.splitStack(amount); - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - else - { - // this method also calls markDirty, so we don't need to call it again - this.setInventorySlotContents(slot, null); - } - } - return stack; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) - { - final ItemStack stack = this.getStackInSlot(slot); - this.setInventorySlotContents(slot, null); - return stack; - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) - { - this.inventory[slot] = stack; - - if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) - { - stack.stackSize = this.getInventoryStackLimit(); - } - - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - - // 1.7.2+ renamed to getInventoryName - @Override - public String getInventoryName() - { - return this.name; - } - - // 1.7.2+ renamed to hasCustomInventoryName - @Override - public boolean hasCustomInventoryName() - { - return this.name.length() > 0; - } - - @Override - public int getInventoryStackLimit() - { - return 64; - } - - /** - * This is the method that will handle saving the inventory contents, as it is called (or should be called!) - * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also - * let you change things in your inventory without ever opening a Gui, if you want. - */ - // 1.7.2+ renamed to markDirty - @Override - public void markDirty() - { - for (int i = 0; i < this.getSizeInventory(); ++i) - { - final ItemStack temp = this.getStackInSlot(i); - if (temp != null){ - //Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); - } - - if ((temp != null) && (temp.stackSize == 0)) { - this.inventory[i] = null; - } - } - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) - { - return true; - } - - // 1.7.2+ renamed to openInventory(EntityPlayer player) - @Override - public void openInventory() {} - - // 1.7.2+ renamed to closeInventory(EntityPlayer player) - @Override - public void closeInventory() {} - - /** - * This method doesn't seem to do what it claims to do, as - * items can still be left-clicked and placed in the inventory - * even when this returns false - */ - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) - { - // Don't want to be able to store the inventory item within itself - // Bad things will happen, like losing your inventory - // Actually, this needs a custom Slot to work - return true; - } - -} \ No newline at end of file +public class InventoryFishTrap implements IInventory { + + private final String name = "Fishtrap"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 15; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + public void readFromNBT(final NBTTagCompound nbt) { + final NBTTagList list = nbt.getTagList("Items", 10); + this.inventory = new ItemStack[INV_SIZE]; + for (int i = 0; i < list.tagCount(); i++) { + final NBTTagCompound data = list.getCompoundTagAt(i); + final int slot = data.getInteger("Slot"); + if ((slot >= 0) && (slot < INV_SIZE)) { + // Utils.LOG_INFO("Trying to read NBT data from inventory."); + this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(final NBTTagCompound nbt) { + final NBTTagList list = new NBTTagList(); + for (int i = 0; i < INV_SIZE; i++) { + final ItemStack stack = this.inventory[i]; + if (stack != null) { + // Utils.LOG_INFO("Trying to write NBT data to inventory."); + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + nbt.setTag("Items", list); + } + + @Override + public int getSizeInventory() { + return this.inventory.length; + } + + public ItemStack[] getInventory() { + return this.inventory; + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.inventory[slot]; + } + + @Override + public ItemStack decrStackSize(final int slot, final int amount) { + ItemStack stack = this.getStackInSlot(slot); + if (stack != null) { + if (stack.stackSize > amount) { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } else { + // this method also calls markDirty, so we don't need to call it again + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.inventory[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() { + return this.name.length() > 0; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + /** + * This is the method that will handle saving the inventory contents, as it is called (or should be called!) + * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also + * let you change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() { + for (int i = 0; i < this.getSizeInventory(); ++i) { + final ItemStack temp = this.getStackInSlot(i); + if (temp != null) { + // Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); + } + + if ((temp != null) && (temp.stackSize == 0)) { + this.inventory[i] = null; + } + } + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as + * items can still be left-clicked and placed in the inventory + * even when this returns false + */ + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + // Don't want to be able to store the inventory item within itself + // Bad things will happen, like losing your inventory + // Actually, this needs a custom Slot to work + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/InventoryHeliumGenerator.java b/src/main/java/gtPlusPlus/core/inventories/InventoryHeliumGenerator.java index 0288aa4d29..8ea78647ab 100644 --- a/src/main/java/gtPlusPlus/core/inventories/InventoryHeliumGenerator.java +++ b/src/main/java/gtPlusPlus/core/inventories/InventoryHeliumGenerator.java @@ -6,171 +6,153 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -public class InventoryHeliumGenerator implements IInventory{ - - private final String name = "Helium"; - - /** Defining your inventory size this way is handy */ - public static final int INV_SIZE = 19; - - /** Inventory's size must be same as number of slots you add to the Container class */ - private ItemStack[] inventory = new ItemStack[INV_SIZE]; - - public void readFromNBT(final NBTTagCompound nbt){ - final NBTTagList list = nbt.getTagList("Items", 10); - this.inventory = new ItemStack[INV_SIZE]; - for(int i = 0;i= 0) && (slot < INV_SIZE)){ - //Utils.LOG_INFO("Trying to read NBT data from inventory."); - this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); - } - } - } - - public void writeToNBT(final NBTTagCompound nbt){ - final NBTTagList list = new NBTTagList(); - for(int i = 0;i amount) - { - stack = stack.splitStack(amount); - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - else - { - // this method also calls markDirty, so we don't need to call it again - this.setInventorySlotContents(slot, null); - } - } - return stack; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) - { - final ItemStack stack = this.getStackInSlot(slot); - this.setInventorySlotContents(slot, null); - return stack; - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) - { - this.inventory[slot] = stack; - - if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) - { - stack.stackSize = this.getInventoryStackLimit(); - } - - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - - // 1.7.2+ renamed to getInventoryName - @Override - public String getInventoryName() - { - return this.name; - } - - // 1.7.2+ renamed to hasCustomInventoryName - @Override - public boolean hasCustomInventoryName() - { - return this.name.length() > 0; - } - - @Override - public int getInventoryStackLimit() - { - return 64; - } - - /** - * This is the method that will handle saving the inventory contents, as it is called (or should be called!) - * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also - * let you change things in your inventory without ever opening a Gui, if you want. - */ - // 1.7.2+ renamed to markDirty - @Override - public void markDirty() - { - for (int i = 0; i < this.getSizeInventory(); ++i) - { - final ItemStack temp = this.getStackInSlot(i); - if (temp != null){ - //Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); - } - - if ((temp != null) && (temp.stackSize == 0)) { - this.inventory[i] = null; - } - } - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) - { - return true; - } - - // 1.7.2+ renamed to openInventory(EntityPlayer player) - @Override - public void openInventory() {} - - // 1.7.2+ renamed to closeInventory(EntityPlayer player) - @Override - public void closeInventory() {} - - /** - * This method doesn't seem to do what it claims to do, as - * items can still be left-clicked and placed in the inventory - * even when this returns false - */ - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) - { - // Don't want to be able to store the inventory item within itself - // Bad things will happen, like losing your inventory - // Actually, this needs a custom Slot to work - return true; - } - -} \ No newline at end of file +public class InventoryHeliumGenerator implements IInventory { + + private final String name = "Helium"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 19; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + public void readFromNBT(final NBTTagCompound nbt) { + final NBTTagList list = nbt.getTagList("Items", 10); + this.inventory = new ItemStack[INV_SIZE]; + for (int i = 0; i < list.tagCount(); i++) { + final NBTTagCompound data = list.getCompoundTagAt(i); + final int slot = data.getInteger("Slot"); + if ((slot >= 0) && (slot < INV_SIZE)) { + // Utils.LOG_INFO("Trying to read NBT data from inventory."); + this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(final NBTTagCompound nbt) { + final NBTTagList list = new NBTTagList(); + for (int i = 0; i < INV_SIZE; i++) { + final ItemStack stack = this.inventory[i]; + if (stack != null) { + // Utils.LOG_INFO("Trying to write NBT data to inventory."); + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + nbt.setTag("Items", list); + } + + @Override + public int getSizeInventory() { + return this.inventory.length; + } + + public ItemStack[] getInventory() { + return this.inventory; + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.inventory[slot]; + } + + @Override + public ItemStack decrStackSize(final int slot, final int amount) { + ItemStack stack = this.getStackInSlot(slot); + if (stack != null) { + if (stack.stackSize > amount) { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } else { + // this method also calls markDirty, so we don't need to call it again + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.inventory[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() { + return this.name.length() > 0; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + /** + * This is the method that will handle saving the inventory contents, as it is called (or should be called!) + * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also + * let you change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() { + for (int i = 0; i < this.getSizeInventory(); ++i) { + final ItemStack temp = this.getStackInSlot(i); + if (temp != null) { + // Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); + } + + if ((temp != null) && (temp.stackSize == 0)) { + this.inventory[i] = null; + } + } + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as + * items can still be left-clicked and placed in the inventory + * even when this returns false + */ + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + // Don't want to be able to store the inventory item within itself + // Bad things will happen, like losing your inventory + // Actually, this needs a custom Slot to work + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/InventoryPestKiller.java b/src/main/java/gtPlusPlus/core/inventories/InventoryPestKiller.java index 1c5d98f7d2..b1852480c4 100644 --- a/src/main/java/gtPlusPlus/core/inventories/InventoryPestKiller.java +++ b/src/main/java/gtPlusPlus/core/inventories/InventoryPestKiller.java @@ -6,171 +6,153 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -public class InventoryPestKiller implements IInventory{ - - private final String name = "Pest Killer"; - - /** Defining your inventory size this way is handy */ - public static final int INV_SIZE = 3; - - /** Inventory's size must be same as number of slots you add to the Container class */ - private ItemStack[] inventory = new ItemStack[INV_SIZE]; - - public void readFromNBT(final NBTTagCompound nbt){ - final NBTTagList list = nbt.getTagList("Items", 10); - this.inventory = new ItemStack[INV_SIZE]; - for(int i = 0;i= 0) && (slot < INV_SIZE)){ - //Utils.LOG_INFO("Trying to read NBT data from inventory."); - this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); - } - } - } - - public void writeToNBT(final NBTTagCompound nbt){ - final NBTTagList list = new NBTTagList(); - for(int i = 0;i amount) - { - stack = stack.splitStack(amount); - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - else - { - // this method also calls markDirty, so we don't need to call it again - this.setInventorySlotContents(slot, null); - } - } - return stack; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) - { - final ItemStack stack = this.getStackInSlot(slot); - this.setInventorySlotContents(slot, null); - return stack; - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) - { - this.inventory[slot] = stack; - - if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) - { - stack.stackSize = this.getInventoryStackLimit(); - } - - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - - // 1.7.2+ renamed to getInventoryName - @Override - public String getInventoryName() - { - return this.name; - } - - // 1.7.2+ renamed to hasCustomInventoryName - @Override - public boolean hasCustomInventoryName() - { - return this.name.length() > 0; - } - - @Override - public int getInventoryStackLimit() - { - return 64; - } - - /** - * This is the method that will handle saving the inventory contents, as it is called (or should be called!) - * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also - * let you change things in your inventory without ever opening a Gui, if you want. - */ - // 1.7.2+ renamed to markDirty - @Override - public void markDirty() - { - for (int i = 0; i < this.getSizeInventory(); ++i) - { - final ItemStack temp = this.getStackInSlot(i); - if (temp != null){ - //Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); - } - - if ((temp != null) && (temp.stackSize == 0)) { - this.inventory[i] = null; - } - } - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) - { - return true; - } - - // 1.7.2+ renamed to openInventory(EntityPlayer player) - @Override - public void openInventory() {} - - // 1.7.2+ renamed to closeInventory(EntityPlayer player) - @Override - public void closeInventory() {} - - /** - * This method doesn't seem to do what it claims to do, as - * items can still be left-clicked and placed in the inventory - * even when this returns false - */ - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) - { - // Don't want to be able to store the inventory item within itself - // Bad things will happen, like losing your inventory - // Actually, this needs a custom Slot to work - return true; - } - -} \ No newline at end of file +public class InventoryPestKiller implements IInventory { + + private final String name = "Pest Killer"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 3; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + public void readFromNBT(final NBTTagCompound nbt) { + final NBTTagList list = nbt.getTagList("Items", 10); + this.inventory = new ItemStack[INV_SIZE]; + for (int i = 0; i < list.tagCount(); i++) { + final NBTTagCompound data = list.getCompoundTagAt(i); + final int slot = data.getInteger("Slot"); + if ((slot >= 0) && (slot < INV_SIZE)) { + // Utils.LOG_INFO("Trying to read NBT data from inventory."); + this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(final NBTTagCompound nbt) { + final NBTTagList list = new NBTTagList(); + for (int i = 0; i < INV_SIZE; i++) { + final ItemStack stack = this.inventory[i]; + if (stack != null) { + // Utils.LOG_INFO("Trying to write NBT data to inventory."); + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + nbt.setTag("Items", list); + } + + @Override + public int getSizeInventory() { + return this.inventory.length; + } + + public ItemStack[] getInventory() { + return this.inventory; + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.inventory[slot]; + } + + @Override + public ItemStack decrStackSize(final int slot, final int amount) { + ItemStack stack = this.getStackInSlot(slot); + if (stack != null) { + if (stack.stackSize > amount) { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } else { + // this method also calls markDirty, so we don't need to call it again + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.inventory[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() { + return this.name.length() > 0; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + /** + * This is the method that will handle saving the inventory contents, as it is called (or should be called!) + * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also + * let you change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() { + for (int i = 0; i < this.getSizeInventory(); ++i) { + final ItemStack temp = this.getStackInSlot(i); + if (temp != null) { + // Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); + } + + if ((temp != null) && (temp.stackSize == 0)) { + this.inventory[i] = null; + } + } + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as + * items can still be left-clicked and placed in the inventory + * even when this returns false + */ + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + // Don't want to be able to store the inventory item within itself + // Bad things will happen, like losing your inventory + // Actually, this needs a custom Slot to work + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/InventoryWorkbenchChest.java b/src/main/java/gtPlusPlus/core/inventories/InventoryWorkbenchChest.java index 3ea5675ba2..dbcf75603a 100644 --- a/src/main/java/gtPlusPlus/core/inventories/InventoryWorkbenchChest.java +++ b/src/main/java/gtPlusPlus/core/inventories/InventoryWorkbenchChest.java @@ -6,183 +6,156 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -public class InventoryWorkbenchChest implements IInventory{ - - private final String name = "Inventory Chest"; - - /** Defining your inventory size this way is handy */ - public static final int INV_SIZE = 16; - - /** Inventory's size must be same as number of slots you add to the Container class */ - private ItemStack[] inventory = new ItemStack[INV_SIZE]; - - /** - * @param itemstack - the ItemStack to which this inventory belongs - */ - public InventoryWorkbenchChest() - { - - } - - public void readFromNBT(final NBTTagCompound nbt) - { - final NBTTagList list = nbt.getTagList("Items", 10); - this.inventory = new ItemStack[INV_SIZE]; - for(int i = 0;i= 0) && (slot < INV_SIZE)) - { - this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); - } - } - } - - public void writeToNBT(final NBTTagCompound nbt) - { - final NBTTagList list = new NBTTagList(); - for(int i = 0;i amount) - { - stack = stack.splitStack(amount); - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - else - { - // this method also calls markDirty, so we don't need to call it again - this.setInventorySlotContents(slot, null); - } - } - return stack; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) - { - final ItemStack stack = this.getStackInSlot(slot); - this.setInventorySlotContents(slot, null); - return stack; - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) - { - this.inventory[slot] = stack; - - if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) - { - stack.stackSize = this.getInventoryStackLimit(); - } - - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - - // 1.7.2+ renamed to getInventoryName - @Override - public String getInventoryName() - { - return this.name; - } - - // 1.7.2+ renamed to hasCustomInventoryName - @Override - public boolean hasCustomInventoryName() - { - return this.name.length() > 0; - } - - @Override - public int getInventoryStackLimit() - { - return 64; - } - - /** - * This is the method that will handle saving the inventory contents, as it is called (or should be called!) - * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also - * let you change things in your inventory without ever opening a Gui, if you want. - */ - // 1.7.2+ renamed to markDirty - @Override - public void markDirty() - { - for (int i = 0; i < this.getSizeInventory(); ++i) - { - final ItemStack temp = this.getStackInSlot(i); - if (temp != null){ - //Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); - } - - if ((temp != null) && (temp.stackSize == 0)) { - this.inventory[i] = null; - } - } - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) - { - return true; - } - - // 1.7.2+ renamed to openInventory(EntityPlayer player) - @Override - public void openInventory() {} - - // 1.7.2+ renamed to closeInventory(EntityPlayer player) - @Override - public void closeInventory() {} - - /** - * This method doesn't seem to do what it claims to do, as - * items can still be left-clicked and placed in the inventory - * even when this returns false - */ - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) - { - // Don't want to be able to store the inventory item within itself - // Bad things will happen, like losing your inventory - // Actually, this needs a custom Slot to work - return true; - } - -} \ No newline at end of file +public class InventoryWorkbenchChest implements IInventory { + + private final String name = "Inventory Chest"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 16; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + /** + * @param itemstack - the ItemStack to which this inventory belongs + */ + public InventoryWorkbenchChest() {} + + public void readFromNBT(final NBTTagCompound nbt) { + final NBTTagList list = nbt.getTagList("Items", 10); + this.inventory = new ItemStack[INV_SIZE]; + for (int i = 0; i < list.tagCount(); i++) { + final NBTTagCompound data = list.getCompoundTagAt(i); + final int slot = data.getInteger("Slot"); + if ((slot >= 0) && (slot < INV_SIZE)) { + this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(final NBTTagCompound nbt) { + final NBTTagList list = new NBTTagList(); + for (int i = 0; i < INV_SIZE; i++) { + final ItemStack stack = this.inventory[i]; + if (stack != null) { + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + nbt.setTag("Items", list); + } + + @Override + public int getSizeInventory() { + return this.inventory.length; + } + + public ItemStack[] getInventory() { + return this.inventory; + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.inventory[slot]; + } + + @Override + public ItemStack decrStackSize(final int slot, final int amount) { + ItemStack stack = this.getStackInSlot(slot); + if (stack != null) { + if (stack.stackSize > amount) { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } else { + // this method also calls markDirty, so we don't need to call it again + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.inventory[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() { + return this.name.length() > 0; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + /** + * This is the method that will handle saving the inventory contents, as it is called (or should be called!) + * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also + * let you change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() { + for (int i = 0; i < this.getSizeInventory(); ++i) { + final ItemStack temp = this.getStackInSlot(i); + if (temp != null) { + // Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); + } + + if ((temp != null) && (temp.stackSize == 0)) { + this.inventory[i] = null; + } + } + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as + * items can still be left-clicked and placed in the inventory + * even when this returns false + */ + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + // Don't want to be able to store the inventory item within itself + // Bad things will happen, like losing your inventory + // Actually, this needs a custom Slot to work + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/InventoryWorkbenchCrafting.java b/src/main/java/gtPlusPlus/core/inventories/InventoryWorkbenchCrafting.java index f49540b5e2..82cd532e92 100644 --- a/src/main/java/gtPlusPlus/core/inventories/InventoryWorkbenchCrafting.java +++ b/src/main/java/gtPlusPlus/core/inventories/InventoryWorkbenchCrafting.java @@ -8,194 +8,171 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -public class InventoryWorkbenchCrafting implements IInventory{ - - private final String name = "Inventory Crafting"; - - /** Defining your inventory size this way is handy */ - public static final int INV_SIZE = 9; - - /** Inventory's size must be same as number of slots you add to the Container class */ - private ItemStack[] inventory = new ItemStack[INV_SIZE]; - public final InventoryCrafting craftMatrix; - public final Container parentContainer; - - public InventoryCrafting getCrafting(){ - return this.craftMatrix; - } - - /** - * @param itemstack - the ItemStack to which this inventory belongs - */ - public InventoryWorkbenchCrafting(final Container containerR) - { - this.parentContainer = containerR; - this.craftMatrix = new InventoryCrafting(this.parentContainer, 3, 3); - } - - private ItemStack[] getArrayOfCraftingItems(){ - final ItemStack[] array = new ItemStack[9]; - for (int i=0; i= 0) && (slot < INV_SIZE)) - { - this.getInventory()[slot] = ItemStack.loadItemStackFromNBT(data); - } - } - } - - public void writeToNBT(final NBTTagCompound nbt) - { - final NBTTagList list = new NBTTagList(); - for(int i = 0;i amount) - { - stack = stack.splitStack(amount); - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - else - { - // this method also calls markDirty, so we don't need to call it again - this.setInventorySlotContents(slot, null); - } - } - return stack; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) - { - final ItemStack stack = this.getStackInSlot(slot); - this.setInventorySlotContents(slot, null); - return stack; - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) - { - this.getInventory()[slot] = stack; - - if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) - { - stack.stackSize = this.getInventoryStackLimit(); - } - - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - - // 1.7.2+ renamed to getInventoryName - @Override - public String getInventoryName() - { - return this.name; - } - - // 1.7.2+ renamed to hasCustomInventoryName - @Override - public boolean hasCustomInventoryName() - { - return this.name.length() > 0; - } - - @Override - public int getInventoryStackLimit() - { - return 64; - } - - /** - * This is the method that will handle saving the inventory contents, as it is called (or should be called!) - * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also - * let you change things in your inventory without ever opening a Gui, if you want. - */ - // 1.7.2+ renamed to markDirty - @Override - public void markDirty() - { - for (int i = 0; i < this.getSizeInventory(); ++i) - { - if ((this.getStackInSlot(i) != null) && (this.getStackInSlot(i).stackSize == 0)) { - this.getInventory()[i] = null; - } - } - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) - { - return true; - } - - // 1.7.2+ renamed to openInventory(EntityPlayer player) - @Override - public void openInventory() {} - - // 1.7.2+ renamed to closeInventory(EntityPlayer player) - @Override - public void closeInventory() {} - - /** - * This method doesn't seem to do what it claims to do, as - * items can still be left-clicked and placed in the inventory - * even when this returns false - */ - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) - { - // Don't want to be able to store the inventory item within itself - // Bad things will happen, like losing your inventory - // Actually, this needs a custom Slot to work - return true; - } -} \ No newline at end of file +public class InventoryWorkbenchCrafting implements IInventory { + + private final String name = "Inventory Crafting"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 9; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + public final InventoryCrafting craftMatrix; + public final Container parentContainer; + + public InventoryCrafting getCrafting() { + return this.craftMatrix; + } + + /** + * @param itemstack - the ItemStack to which this inventory belongs + */ + public InventoryWorkbenchCrafting(final Container containerR) { + this.parentContainer = containerR; + this.craftMatrix = new InventoryCrafting(this.parentContainer, 3, 3); + } + + private ItemStack[] getArrayOfCraftingItems() { + final ItemStack[] array = new ItemStack[9]; + for (int i = 0; i < this.craftMatrix.getSizeInventory(); i++) { + if (this.craftMatrix.getStackInSlot(i) != null) { + array[i] = this.craftMatrix.getStackInSlot(i); + } + } + return array; + } + + public void readFromNBT(final NBTTagCompound nbt) { + final NBTTagList list = nbt.getTagList("Items", 10); + this.inventory = new ItemStack[INV_SIZE]; + for (int i = 0; i < list.tagCount(); i++) { + final NBTTagCompound data = list.getCompoundTagAt(i); + final int slot = data.getInteger("Slot"); + if ((slot >= 0) && (slot < INV_SIZE)) { + this.getInventory()[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(final NBTTagCompound nbt) { + final NBTTagList list = new NBTTagList(); + for (int i = 0; i < INV_SIZE; i++) { + final ItemStack stack = this.getInventory()[i]; + if (stack != null) { + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + nbt.setTag("Items", list); + } + + @Override + public int getSizeInventory() { + return this.getInventory().length; + } + + public ItemStack[] getInventory() { + return this.getArrayOfCraftingItems(); + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.getInventory()[slot]; + } + + @Override + public ItemStack decrStackSize(final int slot, final int amount) { + ItemStack stack = this.getStackInSlot(slot); + if (stack != null) { + if (stack.stackSize > amount) { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } else { + // this method also calls markDirty, so we don't need to call it again + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.getInventory()[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() { + return this.name.length() > 0; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + /** + * This is the method that will handle saving the inventory contents, as it is called (or should be called!) + * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also + * let you change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() { + for (int i = 0; i < this.getSizeInventory(); ++i) { + if ((this.getStackInSlot(i) != null) && (this.getStackInSlot(i).stackSize == 0)) { + this.getInventory()[i] = null; + } + } + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as + * items can still be left-clicked and placed in the inventory + * even when this returns false + */ + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + // Don't want to be able to store the inventory item within itself + // Bad things will happen, like losing your inventory + // Actually, this needs a custom Slot to work + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/InventoryWorkbenchHoloCrafting.java b/src/main/java/gtPlusPlus/core/inventories/InventoryWorkbenchHoloCrafting.java index 432a425a9b..724c0fab99 100644 --- a/src/main/java/gtPlusPlus/core/inventories/InventoryWorkbenchHoloCrafting.java +++ b/src/main/java/gtPlusPlus/core/inventories/InventoryWorkbenchHoloCrafting.java @@ -4,161 +4,139 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; -public class InventoryWorkbenchHoloCrafting implements IInventory{ - - private final String name = "Inventory Crafting"; - - /** Defining your inventory size this way is handy */ - public static final int INV_SIZE = 9; - - /** Inventory's size must be same as number of slots you add to the Container class */ - private final ItemStack[] inventory = new ItemStack[INV_SIZE]; - - /** - * @param itemstack - the ItemStack to which this inventory belongs - */ - public InventoryWorkbenchHoloCrafting() - { - - } - - /*public void readFromNBT(NBTTagCompound nbt) - { - NBTTagList list = nbt.getTagList("Items", 10); - inventory = new ItemStack[INV_SIZE]; - for(int i = 0;i= 0 && slot < INV_SIZE) - { - inventory[slot] = ItemStack.loadItemStackFromNBT(data); - } - } - } - - public void writeToNBT(NBTTagCompound nbt) - { - NBTTagList list = new NBTTagList(); - for(int i = 0;i amount) - { - stack = stack.splitStack(amount); - this.markDirty(); - } - else - { - this.setInventorySlotContents(slot, null); - } - } - return stack; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) - { - final ItemStack stack = this.getStackInSlot(slot); - this.setInventorySlotContents(slot, null); - return stack; - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) - { - this.inventory[slot] = stack; - if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) - { - stack.stackSize = this.getInventoryStackLimit(); - } - this.markDirty(); - } - - @Override - public String getInventoryName() - { - return this.name; - } - - @Override - public boolean hasCustomInventoryName() - { - return this.name.length() > 0; - } - - @Override - public int getInventoryStackLimit() - { - return 64; - } - - @Override - public void markDirty() - { - for (int i = 0; i < this.getSizeInventory(); ++i) - { - final ItemStack temp = this.getStackInSlot(i); - if (temp != null){ - //Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); - } - - if ((temp != null) && (temp.stackSize == 0)) { - this.inventory[i] = null; - } - } - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) - { - return true; - } - - @Override - public void openInventory() {} - - @Override - public void closeInventory() {} - - - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) - { - return true; - } - -} \ No newline at end of file +public class InventoryWorkbenchHoloCrafting implements IInventory { + + private final String name = "Inventory Crafting"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 9; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private final ItemStack[] inventory = new ItemStack[INV_SIZE]; + + /** + * @param itemstack - the ItemStack to which this inventory belongs + */ + public InventoryWorkbenchHoloCrafting() {} + + /*public void readFromNBT(NBTTagCompound nbt) + { + NBTTagList list = nbt.getTagList("Items", 10); + inventory = new ItemStack[INV_SIZE]; + for(int i = 0;i= 0 && slot < INV_SIZE) + { + inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(NBTTagCompound nbt) + { + NBTTagList list = new NBTTagList(); + for(int i = 0;i amount) { + stack = stack.splitStack(amount); + this.markDirty(); + } else { + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.inventory[slot] = stack; + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) { + stack.stackSize = this.getInventoryStackLimit(); + } + this.markDirty(); + } + + @Override + public String getInventoryName() { + return this.name; + } + + @Override + public boolean hasCustomInventoryName() { + return this.name.length() > 0; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + @Override + public void markDirty() { + for (int i = 0; i < this.getSizeInventory(); ++i) { + final ItemStack temp = this.getStackInSlot(i); + if (temp != null) { + // Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); + } + + if ((temp != null) && (temp.stackSize == 0)) { + this.inventory[i] = null; + } + } + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return true; + } + + @Override + public void openInventory() {} + + @Override + public void closeInventory() {} + + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/InventoryWorkbenchHoloSlots.java b/src/main/java/gtPlusPlus/core/inventories/InventoryWorkbenchHoloSlots.java index 1966e8fdca..d038a3d9c1 100644 --- a/src/main/java/gtPlusPlus/core/inventories/InventoryWorkbenchHoloSlots.java +++ b/src/main/java/gtPlusPlus/core/inventories/InventoryWorkbenchHoloSlots.java @@ -1,5 +1,6 @@ package gtPlusPlus.core.inventories; +import gtPlusPlus.api.objects.Logger; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCraftResult; @@ -7,237 +8,210 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -import gtPlusPlus.api.objects.Logger; - -public class InventoryWorkbenchHoloSlots implements IInventory{ - - private final String name = "Inventory Holo"; - - //Output Slot - public IInventory craftResult = new InventoryCraftResult(); - - /** Defining your inventory size this way is handy */ - public static final int INV_SIZE = 6; - - /** Inventory's size must be same as number of slots you add to the Container class */ - private ItemStack[] inventory = new ItemStack[INV_SIZE]; - - /** - * @param itemstack - the ItemStack to which this inventory belongs - */ - public InventoryWorkbenchHoloSlots() - { - - } - - public void readFromNBT(final NBTTagCompound nbt) - { - final NBTTagList list = nbt.getTagList("Items", 10); - this.inventory = new ItemStack[INV_SIZE]; - for(int i = 0;i= 1) && (slot < INV_SIZE)) - { - this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); - } - } - } - - public void writeToNBT(final NBTTagCompound nbt) - { - final NBTTagList list = new NBTTagList(); - for(int i = 0;i this.getInventoryStackLimit())) - { - stack.stackSize = this.getInventoryStackLimit(); - } - - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - - // 1.7.2+ renamed to getInventoryName - @Override - public String getInventoryName() - { - return this.name; - } - - // 1.7.2+ renamed to hasCustomInventoryName - @Override - public boolean hasCustomInventoryName() - { - return this.name.length() > 0; - } - - @Override - public int getInventoryStackLimit() - { - return 1; - } - - /** - * This is the method that will handle saving the inventory contents, as it is called (or should be called!) - * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also - * let you change things in your inventory without ever opening a Gui, if you want. - */ - // 1.7.2+ renamed to markDirty - @Override - public void markDirty() - { - for (int i = 0; i < this.getSizeInventory(); ++i) - { - if ((this.getStackInSlot(i) != null) && (this.getStackInSlot(i).stackSize == 0)) { - this.inventory[i] = null; - } - } - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) - { - return true; - } - - // 1.7.2+ renamed to openInventory(EntityPlayer player) - @Override - public void openInventory() {} - - // 1.7.2+ renamed to closeInventory(EntityPlayer player) - @Override - public void closeInventory() {} - - /** - * This method doesn't seem to do what it claims to do, as - * items can still be left-clicked and placed in the inventory - * even when this returns false - */ - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) - { - return false; - } - - /** A list of one item containing the result of the crafting formula */ - private final ItemStack[] stackResult = new ItemStack[1]; - - /** - * Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a - * new stack. - */ - /*@Override - public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) - { - ItemStack stack = getStackInSlot(0); - if (this.stackResult[0] != null) - { - ItemStack itemstack = this.stackResult[0]; - this.stackResult[0] = null; - return itemstack; - } - if(stack != null) - { - if(stack.stackSize > p_70298_2_) - { - stack = stack.splitStack(p_70298_2_); - // Don't forget this line or your inventory will not be saved! - markDirty(); - } - else - { - // this method also calls markDirty, so we don't need to call it again - setInventorySlotContents(p_70298_1_, null); - } - } - return stack; - }*/ - @Override - public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) - { - if (this.getStackInSlot(0) != null){ - Logger.INFO("getStackInSlot(0) contains "+this.getStackInSlot(0).getDisplayName()); - if (this.stackResult[0] == null){ - Logger.INFO("this.stackResult[0] == null"); - this.stackResult[0] = this.getStackInSlot(0); - } - else if (this.stackResult[0] != null){ - Logger.INFO("this.stackResult[0] != null"); - if (this.stackResult[0].getDisplayName().toLowerCase().equals(this.getStackInSlot(0).getDisplayName().toLowerCase())){ - Logger.INFO("Items are the same?"); - } - else { - Logger.INFO("Items are not the same."); - } - } - } - - if (this.stackResult[0] != null) - { - Logger.INFO("this.stackResult[0] != null - Really never should be though. - Returning "+this.stackResult[0].getDisplayName()); - final ItemStack itemstack = this.stackResult[0]; - this.stackResult[0] = null; - return itemstack; - } - return null; - } - - /** - * When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem - - * like when you close a workbench GUI. - */ - @Override - public ItemStack getStackInSlotOnClosing(final int p_70304_1_) - { - if (this.stackResult[0] != null) - { - final ItemStack itemstack = this.stackResult[0]; - this.stackResult[0] = null; - return itemstack; - } - return null; - } - +public class InventoryWorkbenchHoloSlots implements IInventory { + + private final String name = "Inventory Holo"; + + // Output Slot + public IInventory craftResult = new InventoryCraftResult(); + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 6; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + /** + * @param itemstack - the ItemStack to which this inventory belongs + */ + public InventoryWorkbenchHoloSlots() {} + + public void readFromNBT(final NBTTagCompound nbt) { + final NBTTagList list = nbt.getTagList("Items", 10); + this.inventory = new ItemStack[INV_SIZE]; + for (int i = 0; i < list.tagCount(); i++) { + final NBTTagCompound data = list.getCompoundTagAt(i); + final int slot = data.getInteger("Slot"); + if ((slot >= 1) && (slot < INV_SIZE)) { + this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(final NBTTagCompound nbt) { + final NBTTagList list = new NBTTagList(); + for (int i = 0; i < INV_SIZE; i++) { + final ItemStack stack = this.inventory[i]; + if ((stack != null) && (i != 0)) { + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + nbt.setTag("Items", list); + } + + @Override + public int getSizeInventory() { + return this.inventory.length; + } + + public ItemStack[] getInventory() { + return this.inventory; + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.inventory[slot]; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.inventory[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() { + return this.name.length() > 0; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + /** + * This is the method that will handle saving the inventory contents, as it is called (or should be called!) + * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also + * let you change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() { + for (int i = 0; i < this.getSizeInventory(); ++i) { + if ((this.getStackInSlot(i) != null) && (this.getStackInSlot(i).stackSize == 0)) { + this.inventory[i] = null; + } + } + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as + * items can still be left-clicked and placed in the inventory + * even when this returns false + */ + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + return false; + } + + /** A list of one item containing the result of the crafting formula */ + private final ItemStack[] stackResult = new ItemStack[1]; + + /** + * Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a + * new stack. + */ + /*@Override + public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) + { + ItemStack stack = getStackInSlot(0); + if (this.stackResult[0] != null) + { + ItemStack itemstack = this.stackResult[0]; + this.stackResult[0] = null; + return itemstack; + } + if(stack != null) + { + if(stack.stackSize > p_70298_2_) + { + stack = stack.splitStack(p_70298_2_); + // Don't forget this line or your inventory will not be saved! + markDirty(); + } + else + { + // this method also calls markDirty, so we don't need to call it again + setInventorySlotContents(p_70298_1_, null); + } + } + return stack; + }*/ + @Override + public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) { + if (this.getStackInSlot(0) != null) { + Logger.INFO("getStackInSlot(0) contains " + this.getStackInSlot(0).getDisplayName()); + if (this.stackResult[0] == null) { + Logger.INFO("this.stackResult[0] == null"); + this.stackResult[0] = this.getStackInSlot(0); + } else if (this.stackResult[0] != null) { + Logger.INFO("this.stackResult[0] != null"); + if (this.stackResult[0] + .getDisplayName() + .toLowerCase() + .equals(this.getStackInSlot(0).getDisplayName().toLowerCase())) { + Logger.INFO("Items are the same?"); + } else { + Logger.INFO("Items are not the same."); + } + } + } + + if (this.stackResult[0] != null) { + Logger.INFO("this.stackResult[0] != null - Really never should be though. - Returning " + + this.stackResult[0].getDisplayName()); + final ItemStack itemstack = this.stackResult[0]; + this.stackResult[0] = null; + return itemstack; + } + return null; + } + + /** + * When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem - + * like when you close a workbench GUI. + */ + @Override + public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { + if (this.stackResult[0] != null) { + final ItemStack itemstack = this.stackResult[0]; + this.stackResult[0] = null; + return itemstack; + } + return null; + } } - - -//Default Behaviour +// Default Behaviour /*@Override public ItemStack decrStackSize(int slot, int amount) { @@ -258,7 +232,7 @@ public ItemStack decrStackSize(int slot, int amount) return stack; }*/ -//Default Behaviour +// Default Behaviour /*@Override public ItemStack getStackInSlotOnClosing(int slot) { @@ -266,4 +240,3 @@ public ItemStack getStackInSlotOnClosing(int slot) setInventorySlotContents(slot, null); return stack; }*/ - diff --git a/src/main/java/gtPlusPlus/core/inventories/InventoryWorkbenchTools.java b/src/main/java/gtPlusPlus/core/inventories/InventoryWorkbenchTools.java index 6543f6e9ea..406f2fd703 100644 --- a/src/main/java/gtPlusPlus/core/inventories/InventoryWorkbenchTools.java +++ b/src/main/java/gtPlusPlus/core/inventories/InventoryWorkbenchTools.java @@ -1,188 +1,160 @@ package gtPlusPlus.core.inventories; +import gregtech.api.items.GT_MetaGenerated_Tool; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -import gregtech.api.items.GT_MetaGenerated_Tool; - -public class InventoryWorkbenchTools implements IInventory{ - - private final String name = "Inventory Tools"; - - /** Defining your inventory size this way is handy */ - public static final int INV_SIZE = 5; - - /** Inventory's size must be same as number of slots you add to the Container class */ - private ItemStack[] inventory = new ItemStack[INV_SIZE]; - - /** - * @param itemstack - the ItemStack to which this inventory belongs - */ - public InventoryWorkbenchTools() - { - - } - - public void readFromNBT(final NBTTagCompound nbt) - { - final NBTTagList list = nbt.getTagList("Items", 10); - this.inventory = new ItemStack[INV_SIZE]; - for(int i = 0;i= 0) && (slot < INV_SIZE)) - { - this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); - } - } - } - - public void writeToNBT(final NBTTagCompound nbt) - { - final NBTTagList list = new NBTTagList(); - for(int i = 0;i amount) - { - stack = stack.splitStack(amount); - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - else - { - // this method also calls markDirty, so we don't need to call it again - this.setInventorySlotContents(slot, null); - } - } - return stack; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) - { - final ItemStack stack = this.getStackInSlot(slot); - this.setInventorySlotContents(slot, null); - return stack; - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) - { - this.inventory[slot] = stack; - - if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) - { - stack.stackSize = this.getInventoryStackLimit(); - } - - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - - // 1.7.2+ renamed to getInventoryName - @Override - public String getInventoryName() - { - return this.name; - } - - // 1.7.2+ renamed to hasCustomInventoryName - @Override - public boolean hasCustomInventoryName() - { - return this.name.length() > 0; - } - - @Override - public int getInventoryStackLimit() - { - return 1; - } - - /** - * This is the method that will handle saving the inventory contents, as it is called (or should be called!) - * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also - * let you change things in your inventory without ever opening a Gui, if you want. - */ - // 1.7.2+ renamed to markDirty - @Override - public void markDirty() - { - for (int i = 0; i < this.getSizeInventory(); ++i) - { - if ((this.getStackInSlot(i) != null) && (this.getStackInSlot(i).stackSize == 0)) { - this.inventory[i] = null; - } - } - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) - { - return true; - } - - // 1.7.2+ renamed to openInventory(EntityPlayer player) - @Override - public void openInventory() {} - - // 1.7.2+ renamed to closeInventory(EntityPlayer player) - @Override - public void closeInventory() {} - - /** - * This method doesn't seem to do what it claims to do, as - * items can still be left-clicked and placed in the inventory - * even when this returns false - */ - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) - { - // Don't want to be able to store the inventory item within itself - // Bad things will happen, like losing your inventory - // Actually, this needs a custom Slot to work - if (itemstack.getItem() instanceof GT_MetaGenerated_Tool){ - return true; - } - return false; - } - -} \ No newline at end of file +public class InventoryWorkbenchTools implements IInventory { + + private final String name = "Inventory Tools"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 5; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + /** + * @param itemstack - the ItemStack to which this inventory belongs + */ + public InventoryWorkbenchTools() {} + + public void readFromNBT(final NBTTagCompound nbt) { + final NBTTagList list = nbt.getTagList("Items", 10); + this.inventory = new ItemStack[INV_SIZE]; + for (int i = 0; i < list.tagCount(); i++) { + final NBTTagCompound data = list.getCompoundTagAt(i); + final int slot = data.getInteger("Slot"); + if ((slot >= 0) && (slot < INV_SIZE)) { + this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(final NBTTagCompound nbt) { + final NBTTagList list = new NBTTagList(); + for (int i = 0; i < INV_SIZE; i++) { + final ItemStack stack = this.inventory[i]; + if (stack != null) { + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + nbt.setTag("Items", list); + } + + @Override + public int getSizeInventory() { + return this.inventory.length; + } + + public ItemStack[] getInventory() { + return this.inventory; + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.inventory[slot]; + } + + @Override + public ItemStack decrStackSize(final int slot, final int amount) { + ItemStack stack = this.getStackInSlot(slot); + if (stack != null) { + if (stack.stackSize > amount) { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } else { + // this method also calls markDirty, so we don't need to call it again + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.inventory[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() { + return this.name.length() > 0; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + /** + * This is the method that will handle saving the inventory contents, as it is called (or should be called!) + * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also + * let you change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() { + for (int i = 0; i < this.getSizeInventory(); ++i) { + if ((this.getStackInSlot(i) != null) && (this.getStackInSlot(i).stackSize == 0)) { + this.inventory[i] = null; + } + } + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as + * items can still be left-clicked and placed in the inventory + * even when this returns false + */ + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + // Don't want to be able to store the inventory item within itself + // Bad things will happen, like losing your inventory + // Actually, this needs a custom Slot to work + if (itemstack.getItem() instanceof GT_MetaGenerated_Tool) { + return true; + } + return false; + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/InventoryWorkbenchToolsElectric.java b/src/main/java/gtPlusPlus/core/inventories/InventoryWorkbenchToolsElectric.java index 29bf306b08..facf5fee3a 100644 --- a/src/main/java/gtPlusPlus/core/inventories/InventoryWorkbenchToolsElectric.java +++ b/src/main/java/gtPlusPlus/core/inventories/InventoryWorkbenchToolsElectric.java @@ -1,5 +1,8 @@ package gtPlusPlus.core.inventories; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gtPlusPlus.core.slots.SlotGtToolElectric; +import ic2.api.item.IElectricItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; @@ -7,187 +10,156 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -import gregtech.api.items.GT_MetaGenerated_Tool; - -import gtPlusPlus.core.slots.SlotGtToolElectric; -import ic2.api.item.IElectricItem; - -public class InventoryWorkbenchToolsElectric implements IInventory{ - - private final String name = "Inventory Tools"; - - /** Defining your inventory size this way is handy */ - public static final int INV_SIZE = 5; - - /** Inventory's size must be same as number of slots you add to the Container class */ - private ItemStack[] inventory = new ItemStack[INV_SIZE]; - private final Slot[] toolSlots = new SlotGtToolElectric[INV_SIZE]; //TODO - - /** - * @param itemstack - the ItemStack to which this inventory belongs - */ - public InventoryWorkbenchToolsElectric() - { - - } - - public void readFromNBT(final NBTTagCompound nbt) - { - final NBTTagList list = nbt.getTagList("Items", 10); - this.inventory = new ItemStack[INV_SIZE]; - for(int i = 0;i= 0) && (slot < INV_SIZE)) - { - this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); - } - } - } - - public void writeToNBT(final NBTTagCompound nbt) - { - final NBTTagList list = new NBTTagList(); - for(int i = 0;i amount) - { - stack = stack.splitStack(amount); - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - else - { - // this method also calls markDirty, so we don't need to call it again - this.setInventorySlotContents(slot, null); - } - } - return stack; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) - { - final ItemStack stack = this.getStackInSlot(slot); - this.setInventorySlotContents(slot, null); - return stack; - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) - { - this.inventory[slot] = stack; - - if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) - { - stack.stackSize = this.getInventoryStackLimit(); - } - - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - - // 1.7.2+ renamed to getInventoryName - @Override - public String getInventoryName() - { - return this.name; - } - - // 1.7.2+ renamed to hasCustomInventoryName - @Override - public boolean hasCustomInventoryName() - { - return this.name.length() > 0; - } - - @Override - public int getInventoryStackLimit() - { - return 1; - } - - /** - * This is the method that will handle saving the inventory contents, as it is called (or should be called!) - * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also - * let you change things in your inventory without ever opening a Gui, if you want. - */ - // 1.7.2+ renamed to markDirty - @Override - public void markDirty() - { - for (int i = 0; i < this.getSizeInventory(); ++i) - { - if ((this.getStackInSlot(i) != null) && (this.getStackInSlot(i).stackSize == 0)) { - this.inventory[i] = null; - } - } - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) - { - return true; - } - - // 1.7.2+ renamed to openInventory(EntityPlayer player) - @Override - public void openInventory() {} - - // 1.7.2+ renamed to closeInventory(EntityPlayer player) - @Override - public void closeInventory() {} - - /** - * This method doesn't seem to do what it claims to do, as - * items can still be left-clicked and placed in the inventory - * even when this returns false - */ - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) - { - // Don't want to be able to store the inventory item within itself - // Bad things will happen, like losing your inventory - // Actually, this needs a custom Slot to work - if ((itemstack.getItem() instanceof GT_MetaGenerated_Tool) || (itemstack.getItem() instanceof IElectricItem)){ - return true; - } - return false; - } - -} \ No newline at end of file +public class InventoryWorkbenchToolsElectric implements IInventory { + + private final String name = "Inventory Tools"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 5; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + private final Slot[] toolSlots = new SlotGtToolElectric[INV_SIZE]; // TODO + + /** + * @param itemstack - the ItemStack to which this inventory belongs + */ + public InventoryWorkbenchToolsElectric() {} + + public void readFromNBT(final NBTTagCompound nbt) { + final NBTTagList list = nbt.getTagList("Items", 10); + this.inventory = new ItemStack[INV_SIZE]; + for (int i = 0; i < list.tagCount(); i++) { + final NBTTagCompound data = list.getCompoundTagAt(i); + final int slot = data.getInteger("Slot"); + if ((slot >= 0) && (slot < INV_SIZE)) { + this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(final NBTTagCompound nbt) { + final NBTTagList list = new NBTTagList(); + for (int i = 0; i < INV_SIZE; i++) { + final ItemStack stack = this.inventory[i]; + if (stack != null) { + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + nbt.setTag("Items", list); + } + + @Override + public int getSizeInventory() { + return this.inventory.length; + } + + public ItemStack[] getInventory() { + return this.inventory; + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.inventory[slot]; + } + + @Override + public ItemStack decrStackSize(final int slot, final int amount) { + ItemStack stack = this.getStackInSlot(slot); + if (stack != null) { + if (stack.stackSize > amount) { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } else { + // this method also calls markDirty, so we don't need to call it again + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.inventory[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() { + return this.name.length() > 0; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + /** + * This is the method that will handle saving the inventory contents, as it is called (or should be called!) + * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also + * let you change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() { + for (int i = 0; i < this.getSizeInventory(); ++i) { + if ((this.getStackInSlot(i) != null) && (this.getStackInSlot(i).stackSize == 0)) { + this.inventory[i] = null; + } + } + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as + * items can still be left-clicked and placed in the inventory + * even when this returns false + */ + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + // Don't want to be able to store the inventory item within itself + // Bad things will happen, like losing your inventory + // Actually, this needs a custom Slot to work + if ((itemstack.getItem() instanceof GT_MetaGenerated_Tool) || (itemstack.getItem() instanceof IElectricItem)) { + return true; + } + return false; + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/Inventory_DecayablesChest.java b/src/main/java/gtPlusPlus/core/inventories/Inventory_DecayablesChest.java index 666f4aac53..03a547898d 100644 --- a/src/main/java/gtPlusPlus/core/inventories/Inventory_DecayablesChest.java +++ b/src/main/java/gtPlusPlus/core/inventories/Inventory_DecayablesChest.java @@ -6,171 +6,153 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -public class Inventory_DecayablesChest implements IInventory{ - - private final String name = "DecayablesChest"; - - /** Defining your inventory size this way is handy */ - public static final int INV_SIZE = 15; - - /** Inventory's size must be same as number of slots you add to the Container class */ - private ItemStack[] inventory = new ItemStack[INV_SIZE]; - - public void readFromNBT(final NBTTagCompound nbt){ - final NBTTagList list = nbt.getTagList("Items", 10); - this.inventory = new ItemStack[INV_SIZE]; - for(int i = 0;i= 0) && (slot < INV_SIZE)){ - //Utils.LOG_INFO("Trying to read NBT data from inventory."); - this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); - } - } - } - - public void writeToNBT(final NBTTagCompound nbt){ - final NBTTagList list = new NBTTagList(); - for(int i = 0;i amount) - { - stack = stack.splitStack(amount); - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - else - { - // this method also calls markDirty, so we don't need to call it again - this.setInventorySlotContents(slot, null); - } - } - return stack; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) - { - final ItemStack stack = this.getStackInSlot(slot); - this.setInventorySlotContents(slot, null); - return stack; - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) - { - this.inventory[slot] = stack; - - if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) - { - stack.stackSize = this.getInventoryStackLimit(); - } - - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - - // 1.7.2+ renamed to getInventoryName - @Override - public String getInventoryName() - { - return this.name; - } - - // 1.7.2+ renamed to hasCustomInventoryName - @Override - public boolean hasCustomInventoryName() - { - return this.name.length() > 0; - } - - @Override - public int getInventoryStackLimit() - { - return 64; - } - - /** - * This is the method that will handle saving the inventory contents, as it is called (or should be called!) - * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also - * let you change things in your inventory without ever opening a Gui, if you want. - */ - // 1.7.2+ renamed to markDirty - @Override - public void markDirty() - { - for (int i = 0; i < this.getSizeInventory(); ++i) - { - final ItemStack temp = this.getStackInSlot(i); - if (temp != null){ - //Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); - } - - if ((temp != null) && (temp.stackSize == 0)) { - this.inventory[i] = null; - } - } - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) - { - return true; - } - - // 1.7.2+ renamed to openInventory(EntityPlayer player) - @Override - public void openInventory() {} - - // 1.7.2+ renamed to closeInventory(EntityPlayer player) - @Override - public void closeInventory() {} - - /** - * This method doesn't seem to do what it claims to do, as - * items can still be left-clicked and placed in the inventory - * even when this returns false - */ - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) - { - // Don't want to be able to store the inventory item within itself - // Bad things will happen, like losing your inventory - // Actually, this needs a custom Slot to work - return true; - } - -} \ No newline at end of file +public class Inventory_DecayablesChest implements IInventory { + + private final String name = "DecayablesChest"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 15; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + public void readFromNBT(final NBTTagCompound nbt) { + final NBTTagList list = nbt.getTagList("Items", 10); + this.inventory = new ItemStack[INV_SIZE]; + for (int i = 0; i < list.tagCount(); i++) { + final NBTTagCompound data = list.getCompoundTagAt(i); + final int slot = data.getInteger("Slot"); + if ((slot >= 0) && (slot < INV_SIZE)) { + // Utils.LOG_INFO("Trying to read NBT data from inventory."); + this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(final NBTTagCompound nbt) { + final NBTTagList list = new NBTTagList(); + for (int i = 0; i < INV_SIZE; i++) { + final ItemStack stack = this.inventory[i]; + if (stack != null) { + // Utils.LOG_INFO("Trying to write NBT data to inventory."); + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + nbt.setTag("Items", list); + } + + @Override + public int getSizeInventory() { + return this.inventory.length; + } + + public ItemStack[] getInventory() { + return this.inventory; + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.inventory[slot]; + } + + @Override + public ItemStack decrStackSize(final int slot, final int amount) { + ItemStack stack = this.getStackInSlot(slot); + if (stack != null) { + if (stack.stackSize > amount) { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } else { + // this method also calls markDirty, so we don't need to call it again + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.inventory[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() { + return this.name.length() > 0; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + /** + * This is the method that will handle saving the inventory contents, as it is called (or should be called!) + * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also + * let you change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() { + for (int i = 0; i < this.getSizeInventory(); ++i) { + final ItemStack temp = this.getStackInSlot(i); + if (temp != null) { + // Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); + } + + if ((temp != null) && (temp.stackSize == 0)) { + this.inventory[i] = null; + } + } + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as + * items can still be left-clicked and placed in the inventory + * even when this returns false + */ + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + // Don't want to be able to store the inventory item within itself + // Bad things will happen, like losing your inventory + // Actually, this needs a custom Slot to work + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/Inventory_EggBox.java b/src/main/java/gtPlusPlus/core/inventories/Inventory_EggBox.java index 334afc3300..46e0ffd9b4 100644 --- a/src/main/java/gtPlusPlus/core/inventories/Inventory_EggBox.java +++ b/src/main/java/gtPlusPlus/core/inventories/Inventory_EggBox.java @@ -6,171 +6,153 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -public class Inventory_EggBox implements IInventory{ - - private final String name = "EggBox"; - - /** Defining your inventory size this way is handy */ - public static final int INV_SIZE = 15; - - /** Inventory's size must be same as number of slots you add to the Container class */ - private ItemStack[] inventory = new ItemStack[INV_SIZE]; - - public void readFromNBT(final NBTTagCompound nbt){ - final NBTTagList list = nbt.getTagList("Items", 10); - this.inventory = new ItemStack[INV_SIZE]; - for(int i = 0;i= 0) && (slot < INV_SIZE)){ - //Utils.LOG_INFO("Trying to read NBT data from inventory."); - this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); - } - } - } - - public void writeToNBT(final NBTTagCompound nbt){ - final NBTTagList list = new NBTTagList(); - for(int i = 0;i amount) - { - stack = stack.splitStack(amount); - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - else - { - // this method also calls markDirty, so we don't need to call it again - this.setInventorySlotContents(slot, null); - } - } - return stack; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) - { - final ItemStack stack = this.getStackInSlot(slot); - this.setInventorySlotContents(slot, null); - return stack; - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) - { - this.inventory[slot] = stack; - - if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) - { - stack.stackSize = this.getInventoryStackLimit(); - } - - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - - // 1.7.2+ renamed to getInventoryName - @Override - public String getInventoryName() - { - return this.name; - } - - // 1.7.2+ renamed to hasCustomInventoryName - @Override - public boolean hasCustomInventoryName() - { - return this.name.length() > 0; - } - - @Override - public int getInventoryStackLimit() - { - return 64; - } - - /** - * This is the method that will handle saving the inventory contents, as it is called (or should be called!) - * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also - * let you change things in your inventory without ever opening a Gui, if you want. - */ - // 1.7.2+ renamed to markDirty - @Override - public void markDirty() - { - for (int i = 0; i < this.getSizeInventory(); ++i) - { - final ItemStack temp = this.getStackInSlot(i); - if (temp != null){ - //Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); - } - - if ((temp != null) && (temp.stackSize == 0)) { - this.inventory[i] = null; - } - } - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) - { - return true; - } - - // 1.7.2+ renamed to openInventory(EntityPlayer player) - @Override - public void openInventory() {} - - // 1.7.2+ renamed to closeInventory(EntityPlayer player) - @Override - public void closeInventory() {} - - /** - * This method doesn't seem to do what it claims to do, as - * items can still be left-clicked and placed in the inventory - * even when this returns false - */ - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) - { - // Don't want to be able to store the inventory item within itself - // Bad things will happen, like losing your inventory - // Actually, this needs a custom Slot to work - return true; - } - -} \ No newline at end of file +public class Inventory_EggBox implements IInventory { + + private final String name = "EggBox"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 15; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + public void readFromNBT(final NBTTagCompound nbt) { + final NBTTagList list = nbt.getTagList("Items", 10); + this.inventory = new ItemStack[INV_SIZE]; + for (int i = 0; i < list.tagCount(); i++) { + final NBTTagCompound data = list.getCompoundTagAt(i); + final int slot = data.getInteger("Slot"); + if ((slot >= 0) && (slot < INV_SIZE)) { + // Utils.LOG_INFO("Trying to read NBT data from inventory."); + this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(final NBTTagCompound nbt) { + final NBTTagList list = new NBTTagList(); + for (int i = 0; i < INV_SIZE; i++) { + final ItemStack stack = this.inventory[i]; + if (stack != null) { + // Utils.LOG_INFO("Trying to write NBT data to inventory."); + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + nbt.setTag("Items", list); + } + + @Override + public int getSizeInventory() { + return this.inventory.length; + } + + public ItemStack[] getInventory() { + return this.inventory; + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.inventory[slot]; + } + + @Override + public ItemStack decrStackSize(final int slot, final int amount) { + ItemStack stack = this.getStackInSlot(slot); + if (stack != null) { + if (stack.stackSize > amount) { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } else { + // this method also calls markDirty, so we don't need to call it again + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.inventory[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() { + return this.name.length() > 0; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + /** + * This is the method that will handle saving the inventory contents, as it is called (or should be called!) + * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also + * let you change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() { + for (int i = 0; i < this.getSizeInventory(); ++i) { + final ItemStack temp = this.getStackInSlot(i); + if (temp != null) { + // Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); + } + + if ((temp != null) && (temp.stackSize == 0)) { + this.inventory[i] = null; + } + } + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as + * items can still be left-clicked and placed in the inventory + * even when this returns false + */ + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + // Don't want to be able to store the inventory item within itself + // Bad things will happen, like losing your inventory + // Actually, this needs a custom Slot to work + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/Inventory_RoundRobinator.java b/src/main/java/gtPlusPlus/core/inventories/Inventory_RoundRobinator.java index a47f250c39..58ca8eff3b 100644 --- a/src/main/java/gtPlusPlus/core/inventories/Inventory_RoundRobinator.java +++ b/src/main/java/gtPlusPlus/core/inventories/Inventory_RoundRobinator.java @@ -6,167 +6,150 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -public class Inventory_RoundRobinator implements IInventory{ - - private final String name = "Round Robinator"; - - /** Defining your inventory size this way is handy */ - public static final int INV_SIZE = 4; - - /** Inventory's size must be same as number of slots you add to the Container class */ - private ItemStack[] inventory = new ItemStack[INV_SIZE]; - - public void readFromNBT(final NBTTagCompound nbt){ - final NBTTagList list = nbt.getTagList("Items", 10); - this.inventory = new ItemStack[INV_SIZE]; - for(int i = 0;i= 0) && (slot < INV_SIZE)){ - //Utils.LOG_INFO("Trying to read NBT data from inventory."); - this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); - } - } - } - - public void writeToNBT(final NBTTagCompound nbt){ - final NBTTagList list = new NBTTagList(); - for(int i = 0;i amount) - { - stack = stack.splitStack(amount); - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - else - { - // this method also calls markDirty, so we don't need to call it again - this.setInventorySlotContents(slot, null); - } - } - return stack; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) - { - final ItemStack stack = this.getStackInSlot(slot); - this.setInventorySlotContents(slot, null); - return stack; - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) - { - this.inventory[slot] = stack; - - if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) - { - stack.stackSize = this.getInventoryStackLimit(); - } - - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - - // 1.7.2+ renamed to getInventoryName - @Override - public String getInventoryName() - { - return this.name; - } - - // 1.7.2+ renamed to hasCustomInventoryName - @Override - public boolean hasCustomInventoryName() - { - return this.name.length() > 0; - } - - @Override - public int getInventoryStackLimit() - { - return 64; - } - - /** - * This is the method that will handle saving the inventory contents, as it is called (or should be called!) - * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also - * let you change things in your inventory without ever opening a Gui, if you want. - */ - // 1.7.2+ renamed to markDirty - @Override - public void markDirty() - { - for (int i = 0; i < this.getSizeInventory(); ++i) - { - final ItemStack temp = this.getStackInSlot(i); - if (temp != null){ - //Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); - } - - if ((temp != null) && (temp.stackSize == 0)) { - this.inventory[i] = null; - } - } - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) - { - return true; - } - - // 1.7.2+ renamed to openInventory(EntityPlayer player) - @Override - public void openInventory() {} - - // 1.7.2+ renamed to closeInventory(EntityPlayer player) - @Override - public void closeInventory() {} - - /** - * This method doesn't seem to do what it claims to do, as - * items can still be left-clicked and placed in the inventory - * even when this returns false - */ - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { - return true; - } - -} \ No newline at end of file +public class Inventory_RoundRobinator implements IInventory { + + private final String name = "Round Robinator"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 4; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + public void readFromNBT(final NBTTagCompound nbt) { + final NBTTagList list = nbt.getTagList("Items", 10); + this.inventory = new ItemStack[INV_SIZE]; + for (int i = 0; i < list.tagCount(); i++) { + final NBTTagCompound data = list.getCompoundTagAt(i); + final int slot = data.getInteger("Slot"); + if ((slot >= 0) && (slot < INV_SIZE)) { + // Utils.LOG_INFO("Trying to read NBT data from inventory."); + this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(final NBTTagCompound nbt) { + final NBTTagList list = new NBTTagList(); + for (int i = 0; i < INV_SIZE; i++) { + final ItemStack stack = this.inventory[i]; + if (stack != null) { + // Utils.LOG_INFO("Trying to write NBT data to inventory."); + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + nbt.setTag("Items", list); + } + + @Override + public int getSizeInventory() { + return this.inventory.length; + } + + public ItemStack[] getInventory() { + return this.inventory; + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.inventory[slot]; + } + + @Override + public ItemStack decrStackSize(final int slot, final int amount) { + ItemStack stack = this.getStackInSlot(slot); + if (stack != null) { + if (stack.stackSize > amount) { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } else { + // this method also calls markDirty, so we don't need to call it again + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.inventory[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() { + return this.name.length() > 0; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + /** + * This is the method that will handle saving the inventory contents, as it is called (or should be called!) + * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also + * let you change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() { + for (int i = 0; i < this.getSizeInventory(); ++i) { + final ItemStack temp = this.getStackInSlot(i); + if (temp != null) { + // Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); + } + + if ((temp != null) && (temp.stackSize == 0)) { + this.inventory[i] = null; + } + } + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as + * items can still be left-clicked and placed in the inventory + * even when this returns false + */ + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/Inventory_SuperJukebox.java b/src/main/java/gtPlusPlus/core/inventories/Inventory_SuperJukebox.java index 681c67a988..8bccfaed2d 100644 --- a/src/main/java/gtPlusPlus/core/inventories/Inventory_SuperJukebox.java +++ b/src/main/java/gtPlusPlus/core/inventories/Inventory_SuperJukebox.java @@ -6,167 +6,150 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -public class Inventory_SuperJukebox implements IInventory{ - - private final String name = "Sir Mixalot"; - - /** Defining your inventory size this way is handy */ - public static final int INV_SIZE = 21; - - /** Inventory's size must be same as number of slots you add to the Container class */ - private ItemStack[] inventory = new ItemStack[INV_SIZE]; - - public void readFromNBT(final NBTTagCompound nbt){ - final NBTTagList list = nbt.getTagList("Items", 10); - this.inventory = new ItemStack[INV_SIZE]; - for(int i = 0;i= 0) && (slot < INV_SIZE)){ - //Utils.LOG_INFO("Trying to read NBT data from inventory."); - this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); - } - } - } - - public void writeToNBT(final NBTTagCompound nbt){ - final NBTTagList list = new NBTTagList(); - for(int i = 0;i amount) - { - stack = stack.splitStack(amount); - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - else - { - // this method also calls markDirty, so we don't need to call it again - this.setInventorySlotContents(slot, null); - } - } - return stack; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) - { - final ItemStack stack = this.getStackInSlot(slot); - this.setInventorySlotContents(slot, null); - return stack; - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) - { - this.inventory[slot] = stack; - - if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) - { - stack.stackSize = this.getInventoryStackLimit(); - } - - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - - // 1.7.2+ renamed to getInventoryName - @Override - public String getInventoryName() - { - return this.name; - } - - // 1.7.2+ renamed to hasCustomInventoryName - @Override - public boolean hasCustomInventoryName() - { - return this.name.length() > 0; - } - - @Override - public int getInventoryStackLimit() - { - return 1; - } - - /** - * This is the method that will handle saving the inventory contents, as it is called (or should be called!) - * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also - * let you change things in your inventory without ever opening a Gui, if you want. - */ - // 1.7.2+ renamed to markDirty - @Override - public void markDirty() - { - for (int i = 0; i < this.getSizeInventory(); ++i) - { - final ItemStack temp = this.getStackInSlot(i); - if (temp != null){ - //Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); - } - - if ((temp != null) && (temp.stackSize == 0)) { - this.inventory[i] = null; - } - } - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) - { - return true; - } - - // 1.7.2+ renamed to openInventory(EntityPlayer player) - @Override - public void openInventory() {} - - // 1.7.2+ renamed to closeInventory(EntityPlayer player) - @Override - public void closeInventory() {} - - /** - * This method doesn't seem to do what it claims to do, as - * items can still be left-clicked and placed in the inventory - * even when this returns false - */ - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { - return true; - } - -} \ No newline at end of file +public class Inventory_SuperJukebox implements IInventory { + + private final String name = "Sir Mixalot"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 21; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + public void readFromNBT(final NBTTagCompound nbt) { + final NBTTagList list = nbt.getTagList("Items", 10); + this.inventory = new ItemStack[INV_SIZE]; + for (int i = 0; i < list.tagCount(); i++) { + final NBTTagCompound data = list.getCompoundTagAt(i); + final int slot = data.getInteger("Slot"); + if ((slot >= 0) && (slot < INV_SIZE)) { + // Utils.LOG_INFO("Trying to read NBT data from inventory."); + this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(final NBTTagCompound nbt) { + final NBTTagList list = new NBTTagList(); + for (int i = 0; i < INV_SIZE; i++) { + final ItemStack stack = this.inventory[i]; + if (stack != null) { + // Utils.LOG_INFO("Trying to write NBT data to inventory."); + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + nbt.setTag("Items", list); + } + + @Override + public int getSizeInventory() { + return this.inventory.length; + } + + public ItemStack[] getInventory() { + return this.inventory; + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.inventory[slot]; + } + + @Override + public ItemStack decrStackSize(final int slot, final int amount) { + ItemStack stack = this.getStackInSlot(slot); + if (stack != null) { + if (stack.stackSize > amount) { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } else { + // this method also calls markDirty, so we don't need to call it again + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.inventory[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() { + return this.name.length() > 0; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + /** + * This is the method that will handle saving the inventory contents, as it is called (or should be called!) + * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also + * let you change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() { + for (int i = 0; i < this.getSizeInventory(); ++i) { + final ItemStack temp = this.getStackInSlot(i); + if (temp != null) { + // Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); + } + + if ((temp != null) && (temp.stackSize == 0)) { + this.inventory[i] = null; + } + } + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as + * items can still be left-clicked and placed in the inventory + * even when this returns false + */ + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/Inventory_VolumetricFlaskSetter.java b/src/main/java/gtPlusPlus/core/inventories/Inventory_VolumetricFlaskSetter.java index e2dc91a413..b703e1bfaa 100644 --- a/src/main/java/gtPlusPlus/core/inventories/Inventory_VolumetricFlaskSetter.java +++ b/src/main/java/gtPlusPlus/core/inventories/Inventory_VolumetricFlaskSetter.java @@ -7,167 +7,150 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -public class Inventory_VolumetricFlaskSetter implements IInventory{ - - private final String name = "Volumetric Flask Setter"; - - /** Defining your inventory size this way is handy */ - public static final int INV_SIZE = 9; - - /** Inventory's size must be same as number of slots you add to the Container class */ - private ItemStack[] inventory = new ItemStack[INV_SIZE]; - - public void readFromNBT(final NBTTagCompound nbt){ - final NBTTagList list = nbt.getTagList("Items", 10); - this.inventory = new ItemStack[INV_SIZE]; - for(int i = 0;i= 0) && (slot < INV_SIZE)){ - //Utils.LOG_INFO("Trying to read NBT data from inventory."); - this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); - } - } - } - - public void writeToNBT(final NBTTagCompound nbt){ - final NBTTagList list = new NBTTagList(); - for(int i = 0;i amount) - { - stack = stack.splitStack(amount); - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - else - { - // this method also calls markDirty, so we don't need to call it again - this.setInventorySlotContents(slot, null); - } - } - return stack; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) - { - final ItemStack stack = this.getStackInSlot(slot); - this.setInventorySlotContents(slot, null); - return stack; - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) - { - this.inventory[slot] = stack; - - if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) - { - stack.stackSize = this.getInventoryStackLimit(); - } - - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - - // 1.7.2+ renamed to getInventoryName - @Override - public String getInventoryName() - { - return this.name; - } - - // 1.7.2+ renamed to hasCustomInventoryName - @Override - public boolean hasCustomInventoryName() - { - return this.name.length() > 0; - } - - @Override - public int getInventoryStackLimit() - { - return 16; - } - - /** - * This is the method that will handle saving the inventory contents, as it is called (or should be called!) - * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also - * let you change things in your inventory without ever opening a Gui, if you want. - */ - // 1.7.2+ renamed to markDirty - @Override - public void markDirty() - { - for (int i = 0; i < this.getSizeInventory(); ++i) - { - final ItemStack temp = this.getStackInSlot(i); - if (temp != null){ - //Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); - } - - if ((temp != null) && (temp.stackSize == 0)) { - this.inventory[i] = null; - } - } - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) - { - return true; - } - - // 1.7.2+ renamed to openInventory(EntityPlayer player) - @Override - public void openInventory() {} - - // 1.7.2+ renamed to closeInventory(EntityPlayer player) - @Override - public void closeInventory() {} - - /** - * This method doesn't seem to do what it claims to do, as - * items can still be left-clicked and placed in the inventory - * even when this returns false - */ - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { - return VolumetricFlaskHelper.isVolumetricFlask(itemstack); - } - -} \ No newline at end of file +public class Inventory_VolumetricFlaskSetter implements IInventory { + + private final String name = "Volumetric Flask Setter"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 9; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + public void readFromNBT(final NBTTagCompound nbt) { + final NBTTagList list = nbt.getTagList("Items", 10); + this.inventory = new ItemStack[INV_SIZE]; + for (int i = 0; i < list.tagCount(); i++) { + final NBTTagCompound data = list.getCompoundTagAt(i); + final int slot = data.getInteger("Slot"); + if ((slot >= 0) && (slot < INV_SIZE)) { + // Utils.LOG_INFO("Trying to read NBT data from inventory."); + this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(final NBTTagCompound nbt) { + final NBTTagList list = new NBTTagList(); + for (int i = 0; i < INV_SIZE; i++) { + final ItemStack stack = this.inventory[i]; + if (stack != null) { + // Utils.LOG_INFO("Trying to write NBT data to inventory."); + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + nbt.setTag("Items", list); + } + + @Override + public int getSizeInventory() { + return this.inventory.length; + } + + public ItemStack[] getInventory() { + return this.inventory; + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.inventory[slot]; + } + + @Override + public ItemStack decrStackSize(final int slot, final int amount) { + ItemStack stack = this.getStackInSlot(slot); + if (stack != null) { + if (stack.stackSize > amount) { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } else { + // this method also calls markDirty, so we don't need to call it again + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.inventory[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() { + return this.name.length() > 0; + } + + @Override + public int getInventoryStackLimit() { + return 16; + } + + /** + * This is the method that will handle saving the inventory contents, as it is called (or should be called!) + * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also + * let you change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() { + for (int i = 0; i < this.getSizeInventory(); ++i) { + final ItemStack temp = this.getStackInSlot(i); + if (temp != null) { + // Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); + } + + if ((temp != null) && (temp.stackSize == 0)) { + this.inventory[i] = null; + } + } + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as + * items can still be left-clicked and placed in the inventory + * even when this returns false + */ + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + return VolumetricFlaskHelper.isVolumetricFlask(itemstack); + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/box/LunchBoxInventory.java b/src/main/java/gtPlusPlus/core/inventories/box/LunchBoxInventory.java index 03350a3c18..e5cbf352a1 100644 --- a/src/main/java/gtPlusPlus/core/inventories/box/LunchBoxInventory.java +++ b/src/main/java/gtPlusPlus/core/inventories/box/LunchBoxInventory.java @@ -5,11 +5,12 @@ import gtPlusPlus.core.slots.SlotLunchBox; import net.minecraft.item.ItemStack; public class LunchBoxInventory extends CustomBoxInventory { - public LunchBoxInventory(ItemStack stack) { - super(stack, "Lunch Box", gtPlusPlus.core.item.tool.misc.box.AutoLunchBox.SLOTS); - } - @Override - public boolean isItemValidForSlot(int slot, ItemStack itemstack) { - return SlotLunchBox.isItemValid_STATIC(itemstack); - } + public LunchBoxInventory(ItemStack stack) { + super(stack, "Lunch Box", gtPlusPlus.core.item.tool.misc.box.AutoLunchBox.SLOTS); + } + + @Override + public boolean isItemValidForSlot(int slot, ItemStack itemstack) { + return SlotLunchBox.isItemValid_STATIC(itemstack); + } } diff --git a/src/main/java/gtPlusPlus/core/inventories/box/MagicBagInventory.java b/src/main/java/gtPlusPlus/core/inventories/box/MagicBagInventory.java index 56b1835113..8e0f8c4c54 100644 --- a/src/main/java/gtPlusPlus/core/inventories/box/MagicBagInventory.java +++ b/src/main/java/gtPlusPlus/core/inventories/box/MagicBagInventory.java @@ -5,11 +5,12 @@ import gtPlusPlus.core.slots.SlotMagicToolBag; import net.minecraft.item.ItemStack; public class MagicBagInventory extends CustomBoxInventory { - public MagicBagInventory(ItemStack stack) { - super(stack, "Mystic Bag", gtPlusPlus.core.item.tool.misc.box.MagicToolBag.SLOTS); - } - @Override - public boolean isItemValidForSlot(int slot, ItemStack itemstack) { - return SlotMagicToolBag.isItemValid_STATIC(itemstack); - } + public MagicBagInventory(ItemStack stack) { + super(stack, "Mystic Bag", gtPlusPlus.core.item.tool.misc.box.MagicToolBag.SLOTS); + } + + @Override + public boolean isItemValidForSlot(int slot, ItemStack itemstack) { + return SlotMagicToolBag.isItemValid_STATIC(itemstack); + } } diff --git a/src/main/java/gtPlusPlus/core/inventories/box/ToolBoxInventory.java b/src/main/java/gtPlusPlus/core/inventories/box/ToolBoxInventory.java index 30893aeb4b..48c5e9af47 100644 --- a/src/main/java/gtPlusPlus/core/inventories/box/ToolBoxInventory.java +++ b/src/main/java/gtPlusPlus/core/inventories/box/ToolBoxInventory.java @@ -6,11 +6,12 @@ import gtPlusPlus.core.slots.SlotToolBox; import net.minecraft.item.ItemStack; public class ToolBoxInventory extends CustomBoxInventory { - public ToolBoxInventory(ItemStack stack) { - super(stack, "Tool Box", UniversalToolBox.SLOTS); - } - @Override - public boolean isItemValidForSlot(int slot, ItemStack itemstack) { - return SlotToolBox.isItemValid_STATIC(itemstack); - } + public ToolBoxInventory(ItemStack stack) { + super(stack, "Tool Box", UniversalToolBox.SLOTS); + } + + @Override + public boolean isItemValidForSlot(int slot, ItemStack itemstack) { + return SlotToolBox.isItemValid_STATIC(itemstack); + } } diff --git a/src/main/java/gtPlusPlus/core/inventories/modulartable/InventoryModularMain.java b/src/main/java/gtPlusPlus/core/inventories/modulartable/InventoryModularMain.java index 825a9a8851..7ae022d967 100644 --- a/src/main/java/gtPlusPlus/core/inventories/modulartable/InventoryModularMain.java +++ b/src/main/java/gtPlusPlus/core/inventories/modulartable/InventoryModularMain.java @@ -1,202 +1,175 @@ package gtPlusPlus.core.inventories.modulartable; +import gtPlusPlus.core.tileentities.machines.TileEntityModularityTable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -import gtPlusPlus.core.tileentities.machines.TileEntityModularityTable; - -public class InventoryModularMain implements IInventory{ - - private final String name = "Inventory Grid"; - - /** Defining your inventory size this way is handy */ - public static final int INV_SIZE = 9; - - /** Inventory's size must be same as number of slots you add to the Container class */ - private ItemStack[] inventory = new ItemStack[INV_SIZE]; - - /** - * @param itemstack - the ItemStack to which this inventory belongs - */ - public InventoryModularMain() - { - - } - - public void readFromNBT(final NBTTagCompound nbt) - { - final NBTTagList list = nbt.getTagList("Items", 10); - this.inventory = new ItemStack[INV_SIZE]; - for(int i = 0;i= 0) && (slot < INV_SIZE)) - { - this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); - } - } - } - - public void writeToNBT(final NBTTagCompound nbt) - { - final NBTTagList list = new NBTTagList(); - for(int i = 0;i= this.inventory.length){ - //Utils.LOG_INFO("Returning invalid slot item."); - return null; - } - return this.inventory[slot]; - } catch (Throwable t){ - t.printStackTrace(); - return null; - } - } - - @Override - public ItemStack decrStackSize(final int slot, final int amount) - { - ItemStack stack = this.getStackInSlot(slot); - if(stack != null) - { - if(stack.stackSize > amount) - { - stack = stack.splitStack(amount); - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - else - { - // this method also calls markDirty, so we don't need to call it again - this.setInventorySlotContents(slot, null); - } - } - return stack; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) - { - final ItemStack stack = this.getStackInSlot(slot); - this.setInventorySlotContents(slot, null); - return stack; - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) - { - if (slot >= this.inventory.length){ - return; - } - this.inventory[slot] = stack; - - if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) - { - stack.stackSize = this.getInventoryStackLimit(); - } - - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - - // 1.7.2+ renamed to getInventoryName - @Override - public String getInventoryName() - { - return this.name; - } - - // 1.7.2+ renamed to hasCustomInventoryName - @Override - public boolean hasCustomInventoryName() - { - return this.name.length() > 0; - } - - @Override - public int getInventoryStackLimit() - { - return 64; - } - - /** - * This is the method that will handle saving the inventory contents, as it is called (or should be called!) - * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also - * let you change things in your inventory without ever opening a Gui, if you want. - */ - // 1.7.2+ renamed to markDirty - @Override - public void markDirty() - { - for (int i = 0; i < this.getSizeInventory(); ++i) - { - final ItemStack temp = this.getStackInSlot(i); - if (temp != null){ - //Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); - } - - if ((temp != null) && (temp.stackSize == 0)) { - this.inventory[i] = null; - } - } - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) - { - return true; - } - - // 1.7.2+ renamed to openInventory(EntityPlayer player) - @Override - public void openInventory() {} - - // 1.7.2+ renamed to closeInventory(EntityPlayer player) - @Override - public void closeInventory() {} - - /** - * This method doesn't seem to do what it claims to do, as - * items can still be left-clicked and placed in the inventory - * even when this returns false - */ - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack){ - // Don't want to be able to store the inventory item within itself - // Bad things will happen, like losing your inventory - // Actually, this needs a custom Slot to work - return TileEntityModularityTable.isValidUpgrade(itemstack); - } - -} \ No newline at end of file +public class InventoryModularMain implements IInventory { + + private final String name = "Inventory Grid"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 9; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + /** + * @param itemstack - the ItemStack to which this inventory belongs + */ + public InventoryModularMain() {} + + public void readFromNBT(final NBTTagCompound nbt) { + final NBTTagList list = nbt.getTagList("Items", 10); + this.inventory = new ItemStack[INV_SIZE]; + for (int i = 0; i < list.tagCount(); i++) { + final NBTTagCompound data = list.getCompoundTagAt(i); + final int slot = data.getInteger("Slot"); + if ((slot >= 0) && (slot < INV_SIZE)) { + this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(final NBTTagCompound nbt) { + final NBTTagList list = new NBTTagList(); + for (int i = 0; i < INV_SIZE; i++) { + final ItemStack stack = this.inventory[i]; + if (stack != null) { + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + nbt.setTag("Items", list); + } + + @Override + public int getSizeInventory() { + return this.inventory.length; + } + + public ItemStack[] getInventory() { + return this.inventory; + } + + @Override + public ItemStack getStackInSlot(final int slot) { + // Utils.LOG_INFO("getStackInSlot["+slot+"]"); + try { + if (slot >= this.inventory.length) { + // Utils.LOG_INFO("Returning invalid slot item."); + return null; + } + return this.inventory[slot]; + } catch (Throwable t) { + t.printStackTrace(); + return null; + } + } + + @Override + public ItemStack decrStackSize(final int slot, final int amount) { + ItemStack stack = this.getStackInSlot(slot); + if (stack != null) { + if (stack.stackSize > amount) { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } else { + // this method also calls markDirty, so we don't need to call it again + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + if (slot >= this.inventory.length) { + return; + } + this.inventory[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() { + return this.name.length() > 0; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + /** + * This is the method that will handle saving the inventory contents, as it is called (or should be called!) + * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also + * let you change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() { + for (int i = 0; i < this.getSizeInventory(); ++i) { + final ItemStack temp = this.getStackInSlot(i); + if (temp != null) { + // Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); + } + + if ((temp != null) && (temp.stackSize == 0)) { + this.inventory[i] = null; + } + } + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as + * items can still be left-clicked and placed in the inventory + * even when this returns false + */ + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + // Don't want to be able to store the inventory item within itself + // Bad things will happen, like losing your inventory + // Actually, this needs a custom Slot to work + return TileEntityModularityTable.isValidUpgrade(itemstack); + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/modulartable/InventoryModularOutput.java b/src/main/java/gtPlusPlus/core/inventories/modulartable/InventoryModularOutput.java index d3c59ee2a4..ebbf7f8d80 100644 --- a/src/main/java/gtPlusPlus/core/inventories/modulartable/InventoryModularOutput.java +++ b/src/main/java/gtPlusPlus/core/inventories/modulartable/InventoryModularOutput.java @@ -1,192 +1,187 @@ package gtPlusPlus.core.inventories.modulartable; +import gtPlusPlus.core.tileentities.machines.TileEntityModularityTable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -import gtPlusPlus.core.tileentities.machines.TileEntityModularityTable; - public class InventoryModularOutput implements IInventory { - private final String name = "Inventory Output"; - - /** Defining your inventory size this way is handy */ - public static final int INV_SIZE = 3; - private int mRecpeTime = -1; - - /** - * Inventory's size must be same as number of slots you add to the Container - * class - */ - private ItemStack[] inventory = new ItemStack[INV_SIZE]; - - /** - * @param itemstack - * - the ItemStack to which this inventory belongs - */ - public InventoryModularOutput() { - - } - - public void readFromNBT(final NBTTagCompound nbt) { - if (this.mRecpeTime > -1) { - nbt.setInteger("mRecipeTime", this.mRecpeTime); - } - final NBTTagList list = nbt.getTagList("Items", 10); - this.inventory = new ItemStack[INV_SIZE]; - for (int i = 0; i < list.tagCount(); i++) { - final NBTTagCompound data = list.getCompoundTagAt(i); - final int slot = data.getInteger("Slot"); - if ((slot >= 0) && (slot < INV_SIZE)) { - this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); - } - } - } - - public void writeToNBT(final NBTTagCompound nbt) { - final NBTTagList list = new NBTTagList(); - if (nbt.hasKey("mRecipeTime")) { - this.mRecpeTime = nbt.getInteger("mRecipeTime"); - } - for (int i = 0; i < INV_SIZE; i++) { - final ItemStack stack = this.inventory[i]; - if (stack != null) { - final NBTTagCompound data = new NBTTagCompound(); - stack.writeToNBT(data); - data.setInteger("Slot", i); - list.appendTag(data); - } - } - nbt.setTag("Items", list); - } - - public int setRecipeTime(int mTime) { - return (this.mRecpeTime = mTime); - } - - public int getRecipeTime() { - return this.mRecpeTime; - } - - @Override - public int getSizeInventory() { - return this.inventory.length; - } - - public ItemStack[] getInventory() { - return this.inventory; - } - - @Override - public ItemStack getStackInSlot(final int slot) { - return this.inventory[slot]; - } - - @Override - public ItemStack decrStackSize(final int slot, final int amount) { - ItemStack stack = this.getStackInSlot(slot); - if (stack != null) { - if (stack.stackSize > amount) { - stack = stack.splitStack(amount); - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } else { - // this method also calls markDirty, so we don't need to call it - // again - this.setInventorySlotContents(slot, null); - } - } - return stack; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) { - final ItemStack stack = this.getStackInSlot(slot); - this.setInventorySlotContents(slot, null); - return stack; - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) { - this.inventory[slot] = stack; - - if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) { - stack.stackSize = this.getInventoryStackLimit(); - } - - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - - // 1.7.2+ renamed to getInventoryName - @Override - public String getInventoryName() { - return this.name; - } - - // 1.7.2+ renamed to hasCustomInventoryName - @Override - public boolean hasCustomInventoryName() { - return this.name.length() > 0; - } - - @Override - public int getInventoryStackLimit() { - return 64; - } - - /** - * This is the method that will handle saving the inventory contents, as it - * is called (or should be called!) anytime the inventory changes. Perfect. - * Much better than using onUpdate in an Item, as this will also let you - * change things in your inventory without ever opening a Gui, if you want. - */ - // 1.7.2+ renamed to markDirty - @Override - public void markDirty() { - for (int i = 0; i < this.getSizeInventory(); ++i) { - final ItemStack temp = this.getStackInSlot(i); - if (temp != null) { - // Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" - // x"+temp.stackSize); - } - - if ((temp != null) && (temp.stackSize == 0)) { - this.inventory[i] = null; - } - } - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) { - return true; - } - - // 1.7.2+ renamed to openInventory(EntityPlayer player) - @Override - public void openInventory() { - } - - // 1.7.2+ renamed to closeInventory(EntityPlayer player) - @Override - public void closeInventory() { - } - - /** - * This method doesn't seem to do what it claims to do, as items can still - * be left-clicked and placed in the inventory even when this returns false - */ - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { - // Don't want to be able to store the inventory item within itself - // Bad things will happen, like losing your inventory - // Actually, this needs a custom Slot to work - if (slot == 0){ - return TileEntityModularityTable.isValidUpgrade(itemstack); - } - return TileEntityModularityTable.isValidModularPiece(itemstack); - } - -} \ No newline at end of file + private final String name = "Inventory Output"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 3; + + private int mRecpeTime = -1; + + /** + * Inventory's size must be same as number of slots you add to the Container + * class + */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + /** + * @param itemstack + * - the ItemStack to which this inventory belongs + */ + public InventoryModularOutput() {} + + public void readFromNBT(final NBTTagCompound nbt) { + if (this.mRecpeTime > -1) { + nbt.setInteger("mRecipeTime", this.mRecpeTime); + } + final NBTTagList list = nbt.getTagList("Items", 10); + this.inventory = new ItemStack[INV_SIZE]; + for (int i = 0; i < list.tagCount(); i++) { + final NBTTagCompound data = list.getCompoundTagAt(i); + final int slot = data.getInteger("Slot"); + if ((slot >= 0) && (slot < INV_SIZE)) { + this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(final NBTTagCompound nbt) { + final NBTTagList list = new NBTTagList(); + if (nbt.hasKey("mRecipeTime")) { + this.mRecpeTime = nbt.getInteger("mRecipeTime"); + } + for (int i = 0; i < INV_SIZE; i++) { + final ItemStack stack = this.inventory[i]; + if (stack != null) { + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + nbt.setTag("Items", list); + } + + public int setRecipeTime(int mTime) { + return (this.mRecpeTime = mTime); + } + + public int getRecipeTime() { + return this.mRecpeTime; + } + + @Override + public int getSizeInventory() { + return this.inventory.length; + } + + public ItemStack[] getInventory() { + return this.inventory; + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.inventory[slot]; + } + + @Override + public ItemStack decrStackSize(final int slot, final int amount) { + ItemStack stack = this.getStackInSlot(slot); + if (stack != null) { + if (stack.stackSize > amount) { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } else { + // this method also calls markDirty, so we don't need to call it + // again + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.inventory[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() { + return this.name.length() > 0; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + /** + * This is the method that will handle saving the inventory contents, as it + * is called (or should be called!) anytime the inventory changes. Perfect. + * Much better than using onUpdate in an Item, as this will also let you + * change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() { + for (int i = 0; i < this.getSizeInventory(); ++i) { + final ItemStack temp = this.getStackInSlot(i); + if (temp != null) { + // Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" + // x"+temp.stackSize); + } + + if ((temp != null) && (temp.stackSize == 0)) { + this.inventory[i] = null; + } + } + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as items can still + * be left-clicked and placed in the inventory even when this returns false + */ + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + // Don't want to be able to store the inventory item within itself + // Bad things will happen, like losing your inventory + // Actually, this needs a custom Slot to work + if (slot == 0) { + return TileEntityModularityTable.isValidUpgrade(itemstack); + } + return TileEntityModularityTable.isValidModularPiece(itemstack); + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/projecttable/InventoryProjectMain.java b/src/main/java/gtPlusPlus/core/inventories/projecttable/InventoryProjectMain.java index 2d91869027..2855800e12 100644 --- a/src/main/java/gtPlusPlus/core/inventories/projecttable/InventoryProjectMain.java +++ b/src/main/java/gtPlusPlus/core/inventories/projecttable/InventoryProjectMain.java @@ -6,196 +6,169 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -public class InventoryProjectMain implements IInventory{ - - private final String name = "Inventory Grid"; - - /** Defining your inventory size this way is handy */ - public static final int INV_SIZE = 9; - - /** Inventory's size must be same as number of slots you add to the Container class */ - private ItemStack[] inventory = new ItemStack[INV_SIZE]; - - /** - * @param itemstack - the ItemStack to which this inventory belongs - */ - public InventoryProjectMain() - { - - } - - public void readFromNBT(final NBTTagCompound nbt) - { - final NBTTagList list = nbt.getTagList("Items", 10); - this.inventory = new ItemStack[INV_SIZE]; - for(int i = 0;i= 0) && (slot < INV_SIZE)) - { - this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); - } - } - } - - public void writeToNBT(final NBTTagCompound nbt) - { - final NBTTagList list = new NBTTagList(); - for(int i = 0;i= this.inventory.length){ - //Utils.LOG_INFO("Returning invalid slot item."); - return null; - } - return this.inventory[slot]; - } catch (Throwable t){ - t.printStackTrace(); - return null; - } - } - - @Override - public ItemStack decrStackSize(final int slot, final int amount) - { - ItemStack stack = this.getStackInSlot(slot); - if(stack != null) - { - if(stack.stackSize > amount) - { - stack = stack.splitStack(amount); - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - else - { - // this method also calls markDirty, so we don't need to call it again - this.setInventorySlotContents(slot, null); - } - } - return stack; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) - { - final ItemStack stack = this.getStackInSlot(slot); - this.setInventorySlotContents(slot, null); - return stack; - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) - { - if (slot >= this.inventory.length){ - return; - } - this.inventory[slot] = stack; - - if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) - { - stack.stackSize = this.getInventoryStackLimit(); - } - - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - - // 1.7.2+ renamed to getInventoryName - @Override - public String getInventoryName() - { - return this.name; - } - - // 1.7.2+ renamed to hasCustomInventoryName - @Override - public boolean hasCustomInventoryName() - { - return this.name.length() > 0; - } - - @Override - public int getInventoryStackLimit() - { - return 64; - } - - /** - * This is the method that will handle saving the inventory contents, as it is called (or should be called!) - * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also - * let you change things in your inventory without ever opening a Gui, if you want. - */ - // 1.7.2+ renamed to markDirty - @Override - public void markDirty() - { - for (int i = 0; i < this.getSizeInventory(); ++i) - { - final ItemStack temp = this.getStackInSlot(i); - if (temp != null){ - //Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); - } - - if ((temp != null) && (temp.stackSize == 0)) { - this.inventory[i] = null; - } - } - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) - { - return true; - } - - // 1.7.2+ renamed to openInventory(EntityPlayer player) - @Override - public void openInventory() {} - - // 1.7.2+ renamed to closeInventory(EntityPlayer player) - @Override - public void closeInventory() {} - - /** - * This method doesn't seem to do what it claims to do, as - * items can still be left-clicked and placed in the inventory - * even when this returns false - */ - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) - { - // Don't want to be able to store the inventory item within itself - // Bad things will happen, like losing your inventory - // Actually, this needs a custom Slot to work - return true; - } - -} \ No newline at end of file +public class InventoryProjectMain implements IInventory { + + private final String name = "Inventory Grid"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 9; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + /** + * @param itemstack - the ItemStack to which this inventory belongs + */ + public InventoryProjectMain() {} + + public void readFromNBT(final NBTTagCompound nbt) { + final NBTTagList list = nbt.getTagList("Items", 10); + this.inventory = new ItemStack[INV_SIZE]; + for (int i = 0; i < list.tagCount(); i++) { + final NBTTagCompound data = list.getCompoundTagAt(i); + final int slot = data.getInteger("Slot"); + if ((slot >= 0) && (slot < INV_SIZE)) { + this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(final NBTTagCompound nbt) { + final NBTTagList list = new NBTTagList(); + for (int i = 0; i < INV_SIZE; i++) { + final ItemStack stack = this.inventory[i]; + if (stack != null) { + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + nbt.setTag("Items", list); + } + + @Override + public int getSizeInventory() { + return this.inventory.length; + } + + public ItemStack[] getInventory() { + return this.inventory; + } + + @Override + public ItemStack getStackInSlot(final int slot) { + // Utils.LOG_INFO("getStackInSlot["+slot+"]"); + try { + if (slot >= this.inventory.length) { + // Utils.LOG_INFO("Returning invalid slot item."); + return null; + } + return this.inventory[slot]; + } catch (Throwable t) { + t.printStackTrace(); + return null; + } + } + + @Override + public ItemStack decrStackSize(final int slot, final int amount) { + ItemStack stack = this.getStackInSlot(slot); + if (stack != null) { + if (stack.stackSize > amount) { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } else { + // this method also calls markDirty, so we don't need to call it again + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + if (slot >= this.inventory.length) { + return; + } + this.inventory[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() { + return this.name.length() > 0; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + /** + * This is the method that will handle saving the inventory contents, as it is called (or should be called!) + * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also + * let you change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() { + for (int i = 0; i < this.getSizeInventory(); ++i) { + final ItemStack temp = this.getStackInSlot(i); + if (temp != null) { + // Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); + } + + if ((temp != null) && (temp.stackSize == 0)) { + this.inventory[i] = null; + } + } + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as + * items can still be left-clicked and placed in the inventory + * even when this returns false + */ + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + // Don't want to be able to store the inventory item within itself + // Bad things will happen, like losing your inventory + // Actually, this needs a custom Slot to work + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/projecttable/InventoryProjectOutput.java b/src/main/java/gtPlusPlus/core/inventories/projecttable/InventoryProjectOutput.java index 41ddd06ef1..6547e4524c 100644 --- a/src/main/java/gtPlusPlus/core/inventories/projecttable/InventoryProjectOutput.java +++ b/src/main/java/gtPlusPlus/core/inventories/projecttable/InventoryProjectOutput.java @@ -6,183 +6,156 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -public class InventoryProjectOutput implements IInventory{ - - private final String name = "Inventory Output"; - - /** Defining your inventory size this way is handy */ - public static final int INV_SIZE = 2; - - /** Inventory's size must be same as number of slots you add to the Container class */ - private ItemStack[] inventory = new ItemStack[INV_SIZE]; - - /** - * @param itemstack - the ItemStack to which this inventory belongs - */ - public InventoryProjectOutput() - { - - } - - public void readFromNBT(final NBTTagCompound nbt) - { - final NBTTagList list = nbt.getTagList("Items", 10); - this.inventory = new ItemStack[INV_SIZE]; - for(int i = 0;i= 0) && (slot < INV_SIZE)) - { - this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); - } - } - } - - public void writeToNBT(final NBTTagCompound nbt) - { - final NBTTagList list = new NBTTagList(); - for(int i = 0;i amount) - { - stack = stack.splitStack(amount); - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - else - { - // this method also calls markDirty, so we don't need to call it again - this.setInventorySlotContents(slot, null); - } - } - return stack; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) - { - final ItemStack stack = this.getStackInSlot(slot); - this.setInventorySlotContents(slot, null); - return stack; - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) - { - this.inventory[slot] = stack; - - if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) - { - stack.stackSize = this.getInventoryStackLimit(); - } - - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - - // 1.7.2+ renamed to getInventoryName - @Override - public String getInventoryName() - { - return this.name; - } - - // 1.7.2+ renamed to hasCustomInventoryName - @Override - public boolean hasCustomInventoryName() - { - return this.name.length() > 0; - } - - @Override - public int getInventoryStackLimit() - { - return 64; - } - - /** - * This is the method that will handle saving the inventory contents, as it is called (or should be called!) - * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also - * let you change things in your inventory without ever opening a Gui, if you want. - */ - // 1.7.2+ renamed to markDirty - @Override - public void markDirty() - { - for (int i = 0; i < this.getSizeInventory(); ++i) - { - final ItemStack temp = this.getStackInSlot(i); - if (temp != null){ - //Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); - } - - if ((temp != null) && (temp.stackSize == 0)) { - this.inventory[i] = null; - } - } - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) - { - return true; - } - - // 1.7.2+ renamed to openInventory(EntityPlayer player) - @Override - public void openInventory() {} - - // 1.7.2+ renamed to closeInventory(EntityPlayer player) - @Override - public void closeInventory() {} - - /** - * This method doesn't seem to do what it claims to do, as - * items can still be left-clicked and placed in the inventory - * even when this returns false - */ - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) - { - // Don't want to be able to store the inventory item within itself - // Bad things will happen, like losing your inventory - // Actually, this needs a custom Slot to work - return true; - } - -} \ No newline at end of file +public class InventoryProjectOutput implements IInventory { + + private final String name = "Inventory Output"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 2; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + /** + * @param itemstack - the ItemStack to which this inventory belongs + */ + public InventoryProjectOutput() {} + + public void readFromNBT(final NBTTagCompound nbt) { + final NBTTagList list = nbt.getTagList("Items", 10); + this.inventory = new ItemStack[INV_SIZE]; + for (int i = 0; i < list.tagCount(); i++) { + final NBTTagCompound data = list.getCompoundTagAt(i); + final int slot = data.getInteger("Slot"); + if ((slot >= 0) && (slot < INV_SIZE)) { + this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(final NBTTagCompound nbt) { + final NBTTagList list = new NBTTagList(); + for (int i = 0; i < INV_SIZE; i++) { + final ItemStack stack = this.inventory[i]; + if (stack != null) { + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + nbt.setTag("Items", list); + } + + @Override + public int getSizeInventory() { + return this.inventory.length; + } + + public ItemStack[] getInventory() { + return this.inventory; + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.inventory[slot]; + } + + @Override + public ItemStack decrStackSize(final int slot, final int amount) { + ItemStack stack = this.getStackInSlot(slot); + if (stack != null) { + if (stack.stackSize > amount) { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } else { + // this method also calls markDirty, so we don't need to call it again + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.inventory[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() { + return this.name.length() > 0; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + /** + * This is the method that will handle saving the inventory contents, as it is called (or should be called!) + * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also + * let you change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() { + for (int i = 0; i < this.getSizeInventory(); ++i) { + final ItemStack temp = this.getStackInSlot(i); + if (temp != null) { + // Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); + } + + if ((temp != null) && (temp.stackSize == 0)) { + this.inventory[i] = null; + } + } + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as + * items can still be left-clicked and placed in the inventory + * even when this returns false + */ + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + // Don't want to be able to store the inventory item within itself + // Bad things will happen, like losing your inventory + // Actually, this needs a custom Slot to work + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/tradetable/InventoryTradeMain.java b/src/main/java/gtPlusPlus/core/inventories/tradetable/InventoryTradeMain.java index aa7e8b1866..a5ce516f09 100644 --- a/src/main/java/gtPlusPlus/core/inventories/tradetable/InventoryTradeMain.java +++ b/src/main/java/gtPlusPlus/core/inventories/tradetable/InventoryTradeMain.java @@ -6,196 +6,169 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -public class InventoryTradeMain implements IInventory{ - - private final String name = "Inventory Grid"; - - /** Defining your inventory size this way is handy */ - public static final int INV_SIZE = 9; - - /** Inventory's size must be same as number of slots you add to the Container class */ - private ItemStack[] inventory = new ItemStack[INV_SIZE]; - - /** - * @param itemstack - the ItemStack to which this inventory belongs - */ - public InventoryTradeMain() - { - - } - - public void readFromNBT(final NBTTagCompound nbt) - { - final NBTTagList list = nbt.getTagList("Items", 10); - this.inventory = new ItemStack[INV_SIZE]; - for(int i = 0;i= 0) && (slot < INV_SIZE)) - { - this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); - } - } - } - - public void writeToNBT(final NBTTagCompound nbt) - { - final NBTTagList list = new NBTTagList(); - for(int i = 0;i= this.inventory.length){ - //Utils.LOG_INFO("Returning invalid slot item."); - return null; - } - return this.inventory[slot]; - } catch (Throwable t){ - t.printStackTrace(); - return null; - } - } - - @Override - public ItemStack decrStackSize(final int slot, final int amount) - { - ItemStack stack = this.getStackInSlot(slot); - if(stack != null) - { - if(stack.stackSize > amount) - { - stack = stack.splitStack(amount); - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - else - { - // this method also calls markDirty, so we don't need to call it again - this.setInventorySlotContents(slot, null); - } - } - return stack; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) - { - final ItemStack stack = this.getStackInSlot(slot); - this.setInventorySlotContents(slot, null); - return stack; - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) - { - if (slot >= this.inventory.length){ - return; - } - this.inventory[slot] = stack; - - if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) - { - stack.stackSize = this.getInventoryStackLimit(); - } - - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - - // 1.7.2+ renamed to getInventoryName - @Override - public String getInventoryName() - { - return this.name; - } - - // 1.7.2+ renamed to hasCustomInventoryName - @Override - public boolean hasCustomInventoryName() - { - return this.name.length() > 0; - } - - @Override - public int getInventoryStackLimit() - { - return 64; - } - - /** - * This is the method that will handle saving the inventory contents, as it is called (or should be called!) - * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also - * let you change things in your inventory without ever opening a Gui, if you want. - */ - // 1.7.2+ renamed to markDirty - @Override - public void markDirty() - { - for (int i = 0; i < this.getSizeInventory(); ++i) - { - final ItemStack temp = this.getStackInSlot(i); - if (temp != null){ - //Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); - } - - if ((temp != null) && (temp.stackSize == 0)) { - this.inventory[i] = null; - } - } - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) - { - return true; - } - - // 1.7.2+ renamed to openInventory(EntityPlayer player) - @Override - public void openInventory() {} - - // 1.7.2+ renamed to closeInventory(EntityPlayer player) - @Override - public void closeInventory() {} - - /** - * This method doesn't seem to do what it claims to do, as - * items can still be left-clicked and placed in the inventory - * even when this returns false - */ - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) - { - // Don't want to be able to store the inventory item within itself - // Bad things will happen, like losing your inventory - // Actually, this needs a custom Slot to work - return true; - } - -} \ No newline at end of file +public class InventoryTradeMain implements IInventory { + + private final String name = "Inventory Grid"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 9; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + /** + * @param itemstack - the ItemStack to which this inventory belongs + */ + public InventoryTradeMain() {} + + public void readFromNBT(final NBTTagCompound nbt) { + final NBTTagList list = nbt.getTagList("Items", 10); + this.inventory = new ItemStack[INV_SIZE]; + for (int i = 0; i < list.tagCount(); i++) { + final NBTTagCompound data = list.getCompoundTagAt(i); + final int slot = data.getInteger("Slot"); + if ((slot >= 0) && (slot < INV_SIZE)) { + this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(final NBTTagCompound nbt) { + final NBTTagList list = new NBTTagList(); + for (int i = 0; i < INV_SIZE; i++) { + final ItemStack stack = this.inventory[i]; + if (stack != null) { + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + nbt.setTag("Items", list); + } + + @Override + public int getSizeInventory() { + return this.inventory.length; + } + + public ItemStack[] getInventory() { + return this.inventory; + } + + @Override + public ItemStack getStackInSlot(final int slot) { + // Utils.LOG_INFO("getStackInSlot["+slot+"]"); + try { + if (slot >= this.inventory.length) { + // Utils.LOG_INFO("Returning invalid slot item."); + return null; + } + return this.inventory[slot]; + } catch (Throwable t) { + t.printStackTrace(); + return null; + } + } + + @Override + public ItemStack decrStackSize(final int slot, final int amount) { + ItemStack stack = this.getStackInSlot(slot); + if (stack != null) { + if (stack.stackSize > amount) { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } else { + // this method also calls markDirty, so we don't need to call it again + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + if (slot >= this.inventory.length) { + return; + } + this.inventory[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() { + return this.name.length() > 0; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + /** + * This is the method that will handle saving the inventory contents, as it is called (or should be called!) + * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also + * let you change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() { + for (int i = 0; i < this.getSizeInventory(); ++i) { + final ItemStack temp = this.getStackInSlot(i); + if (temp != null) { + // Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); + } + + if ((temp != null) && (temp.stackSize == 0)) { + this.inventory[i] = null; + } + } + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as + * items can still be left-clicked and placed in the inventory + * even when this returns false + */ + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + // Don't want to be able to store the inventory item within itself + // Bad things will happen, like losing your inventory + // Actually, this needs a custom Slot to work + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/inventories/tradetable/InventoryTradeOutput.java b/src/main/java/gtPlusPlus/core/inventories/tradetable/InventoryTradeOutput.java index fb4329e11a..db22c99503 100644 --- a/src/main/java/gtPlusPlus/core/inventories/tradetable/InventoryTradeOutput.java +++ b/src/main/java/gtPlusPlus/core/inventories/tradetable/InventoryTradeOutput.java @@ -6,183 +6,156 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -public class InventoryTradeOutput implements IInventory{ - - private final String name = "Inventory Output"; - - /** Defining your inventory size this way is handy */ - public static final int INV_SIZE = 2; - - /** Inventory's size must be same as number of slots you add to the Container class */ - private ItemStack[] inventory = new ItemStack[INV_SIZE]; - - /** - * @param itemstack - the ItemStack to which this inventory belongs - */ - public InventoryTradeOutput() - { - - } - - public void readFromNBT(final NBTTagCompound nbt) - { - final NBTTagList list = nbt.getTagList("Items", 10); - this.inventory = new ItemStack[INV_SIZE]; - for(int i = 0;i= 0) && (slot < INV_SIZE)) - { - this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); - } - } - } - - public void writeToNBT(final NBTTagCompound nbt) - { - final NBTTagList list = new NBTTagList(); - for(int i = 0;i amount) - { - stack = stack.splitStack(amount); - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - else - { - // this method also calls markDirty, so we don't need to call it again - this.setInventorySlotContents(slot, null); - } - } - return stack; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) - { - final ItemStack stack = this.getStackInSlot(slot); - this.setInventorySlotContents(slot, null); - return stack; - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) - { - this.inventory[slot] = stack; - - if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) - { - stack.stackSize = this.getInventoryStackLimit(); - } - - // Don't forget this line or your inventory will not be saved! - this.markDirty(); - } - - // 1.7.2+ renamed to getInventoryName - @Override - public String getInventoryName() - { - return this.name; - } - - // 1.7.2+ renamed to hasCustomInventoryName - @Override - public boolean hasCustomInventoryName() - { - return this.name.length() > 0; - } - - @Override - public int getInventoryStackLimit() - { - return 64; - } - - /** - * This is the method that will handle saving the inventory contents, as it is called (or should be called!) - * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also - * let you change things in your inventory without ever opening a Gui, if you want. - */ - // 1.7.2+ renamed to markDirty - @Override - public void markDirty() - { - for (int i = 0; i < this.getSizeInventory(); ++i) - { - final ItemStack temp = this.getStackInSlot(i); - if (temp != null){ - //Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); - } - - if ((temp != null) && (temp.stackSize == 0)) { - this.inventory[i] = null; - } - } - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) - { - return true; - } - - // 1.7.2+ renamed to openInventory(EntityPlayer player) - @Override - public void openInventory() {} - - // 1.7.2+ renamed to closeInventory(EntityPlayer player) - @Override - public void closeInventory() {} - - /** - * This method doesn't seem to do what it claims to do, as - * items can still be left-clicked and placed in the inventory - * even when this returns false - */ - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) - { - // Don't want to be able to store the inventory item within itself - // Bad things will happen, like losing your inventory - // Actually, this needs a custom Slot to work - return true; - } - -} \ No newline at end of file +public class InventoryTradeOutput implements IInventory { + + private final String name = "Inventory Output"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 2; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + /** + * @param itemstack - the ItemStack to which this inventory belongs + */ + public InventoryTradeOutput() {} + + public void readFromNBT(final NBTTagCompound nbt) { + final NBTTagList list = nbt.getTagList("Items", 10); + this.inventory = new ItemStack[INV_SIZE]; + for (int i = 0; i < list.tagCount(); i++) { + final NBTTagCompound data = list.getCompoundTagAt(i); + final int slot = data.getInteger("Slot"); + if ((slot >= 0) && (slot < INV_SIZE)) { + this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(final NBTTagCompound nbt) { + final NBTTagList list = new NBTTagList(); + for (int i = 0; i < INV_SIZE; i++) { + final ItemStack stack = this.inventory[i]; + if (stack != null) { + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + nbt.setTag("Items", list); + } + + @Override + public int getSizeInventory() { + return this.inventory.length; + } + + public ItemStack[] getInventory() { + return this.inventory; + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.inventory[slot]; + } + + @Override + public ItemStack decrStackSize(final int slot, final int amount) { + ItemStack stack = this.getStackInSlot(slot); + if (stack != null) { + if (stack.stackSize > amount) { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } else { + // this method also calls markDirty, so we don't need to call it again + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.inventory[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() { + return this.name.length() > 0; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + /** + * This is the method that will handle saving the inventory contents, as it is called (or should be called!) + * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also + * let you change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() { + for (int i = 0; i < this.getSizeInventory(); ++i) { + final ItemStack temp = this.getStackInSlot(i); + if (temp != null) { + // Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); + } + + if ((temp != null) && (temp.stackSize == 0)) { + this.inventory[i] = null; + } + } + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as + * items can still be left-clicked and placed in the inventory + * even when this returns false + */ + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + // Don't want to be able to store the inventory item within itself + // Bad things will happen, like losing your inventory + // Actually, this needs a custom Slot to work + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/ModItems.java b/src/main/java/gtPlusPlus/core/item/ModItems.java index 6854a045a6..d120252bcb 100644 --- a/src/main/java/gtPlusPlus/core/item/ModItems.java +++ b/src/main/java/gtPlusPlus/core/item/ModItems.java @@ -1,4 +1,5 @@ package gtPlusPlus.core.item; + import static gtPlusPlus.core.creative.AddToCreativeTab.*; import static gtPlusPlus.core.lib.CORE.LOAD_ALL_CONTENT; @@ -61,1209 +62,1490 @@ import net.minecraft.item.Item.ToolMaterial; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.fluids.*; -public final class ModItems { - - - public static ToolMaterial STABALLOY = EnumHelper.addToolMaterial("Staballoy", 3, 2500, 7, 1.0F, 18); - - public static Item ZZZ_Empty; - public static Item AAA_Broken; - - - public static Item itemAlkalusDisk; - public static Item itemDebugShapeSpawner; - public static ItemCustomSpawnEgg itemCustomSpawnEgg; - - //EnderIO - public static Item itemPlateSoularium; - public static Item itemPlateRedstoneAlloy; - public static Item itemPlateElectricalSteel; - public static Item itemPlatePulsatingIron; - public static Item itemPlateEnergeticAlloy; - public static Item itemPlateVibrantAlloy; - public static Item itemPlateConductiveIron; - public static Item itemPlateDarkSteel; - public static Item itemDustSoularium; - public static Item itemDustRedstoneAlloy; - public static Item itemDustElectricalSteel; - public static Item itemDustPulsatingIron; - public static Item itemDustEnergeticAlloy; - public static Item itemDustVibrantAlloy; - public static Item itemDustConductiveIron; - //Big Reactors - public static Item itemPlateBlutonium; - public static Item itemPlateCyanite; - public static Item itemPlateLudicrite; - //Thaumcraft - public static Item itemPlateVoidMetal; - //Pneumaticraft - public static Item itemPlateCompressedIron; - //SimplyJetpacks - public static Item itemPlateEnrichedSoularium; - //rfTools - public static Item itemPlateDimensionShard; - //Staballoy - public static Item itemStaballoyPickaxe; - public static Item itemStaballoyAxe; - //Tools - public static Item itemSandstoneHammer; - //Machine Related - public static Item itemBufferCore0; - //Material related - public static Item itemStickyRubber; - public static Item itemIngotBatteryAlloy; - public static Item itemPlateBatteryAlloy; - public static Item itemHeliumBlob; - public static Item itemHydrogenBlob; - public static Item itemPLACEHOLDER_Circuit; - - public static Item FuelRod_Empty; - public static Item FuelRod_Thorium; - public static Item FuelRod_Uranium; - public static Item FuelRod_Plutonium; - - public static Item itemBedLocator_Base; - public static Item itemBaseItemWithCharge; - - public static Item itemIngotRaisinBread; - public static Item itemHotIngotRaisinBread; - - public static ItemFood itemFoodRaisinToast; - public static BaseItemHotFood itemHotFoodRaisinToast; - public static BaseItemFood itemFoodCurriedSausages; - public static BaseItemHotFood itemHotFoodCurriedSausages; - - public static Item RfEuBattery; - public static Item itemPersonalCloakingDevice; - public static Item itemPersonalCloakingDeviceCharged; - public static Item itemPersonalHealingDevice; - public static Item itemPersonalFireProofDevice; - public static Item itemSlowBuildingRing; - - public static MultiPickaxeBase MP_GTMATERIAL; - public static MultiSpadeBase MS_GTMATERIAL; - - public static ItemStack FluidCell; - - public static BaseItemBackpack backpack_Red; - public static BaseItemBackpack backpack_Green; - public static BaseItemBackpack backpack_Blue; - public static BaseItemBackpack backpack_Yellow; - public static BaseItemBackpack backpack_Purple; - public static BaseItemBackpack backpack_Cyan; - public static BaseItemBackpack backpack_Maroon; - public static BaseItemBackpack backpack_Olive; - public static BaseItemBackpack backpack_DarkGreen; - public static BaseItemBackpack backpack_DarkPurple; - public static BaseItemBackpack backpack_Teal; - public static BaseItemBackpack backpack_Navy; - public static BaseItemBackpack backpack_Silver; - public static BaseItemBackpack backpack_Gray; - public static BaseItemBackpack backpack_Black; - public static BaseItemBackpack backpack_White; - - public static ItemBlueprint itemBlueprintBase; - - public static Item dustLithiumCarbonate; - public static Item dustLithiumHydroxide; - public static Item dustLithiumPeroxide; - public static Item dustLithiumFluoride; - - public static Item dustUranium232; - public static Item dustUraniumTetraFluoride; - public static Item dustUraniumHexaFluoride; - - public static Item dustBerylliumFluoride; - - public static Item dustQuicklime; - public static Item dustCalciumHydroxide; - public static Item dustCalciumCarbonate; - public static Item dustLi2CO3CaOH2; - public static Item dustLi2BeF4; - - public static Item dustTumbagaMix; - - public static Item dustAer; - public static Item dustIgnis; - public static Item dustTerra; - public static Item dustAqua; - - public static Item cellHydrogenChlorideMix; - - public static BaseEuItem metaItem2; - - public static Item shardAer; - public static Item shardIgnis; - public static Item shardTerra; - public static Item shardAqua; - - //Tc Compat for energy crystal recipes - public static Item shardDull; - - //Lighter - public static Item itemBasicFireMaker; - - //Zirconium - public static Item itemZirconiumChlorideCinterPellet; - public static Item dustZrCl4; - public static Item dustCookedZrCl4; - public static Item dustZrF4; - - public static Item dustNaBF4NaF; - public static Item dustLiFBeF2ZrF4UF4; - public static Item dustLiFBeF2ZrF4U235; - public static Item dustLiFBeF2ThF4UF4; - - public static Item dustCalciumSulfate; - - public static Item dustFertUN18; - public static Item dustFertUN32; - - //public static Fluid fluidFLiBeSalt; - //public static Fluid fluidFLiBeSaltBurnt; - - public static Fluid fluidLftrCore1; - public static Fluid fluidLftrCore2; - public static Fluid fluidLftrCore3; - public static Fluid fluidLftrCore4; - public static Fluid fluidLftrBlanket1; - public static Fluid fluidLftrBlanket2; - public static Fluid fluidLftrBlanket3; - public static Fluid fluidNuclearWaste; - - - //Possibly missing base items that GT may be missing. - - public static Item itemSmallWroughtIronGear; - public static Item itemPlateRawMeat; - public static Item itemPlateClay; - public static Item itemPlateLithium; - public static Item itemPlateEuropium; - public static Item itemPlateVanadium; - public static Item itemDoublePlateClay; - public static Item itemDoublePlateEuropium; - public static Item itemFoilUranium235; - public static Item itemDustIndium; - public static BlockBaseModular blockRawMeat; - - public static Item itemBoilerChassis; - public static Item itemDehydratorCoilWire; - public static Item itemDehydratorCoil; - - public static Item itemLavaFilter; - public static Item itemAirFilter; - public static Item itemCoalCoke; - public static Item itemCactusCharcoal; - public static Item itemSugarCharcoal; - public static Item itemCactusCoke; - public static Item itemSugarCoke; - - public static Item itemCircuitLFTR; - public static Item itemBasicTurbine; - - public static Item itemDebugAreaClear; - - public static Item itemGemShards; - public static Item itemHalfCompleteCasings; - - public static Item itemSulfuricPotion; - public static Item itemHydrofluoricPotion; - - public static Item itemModularBauble; - public static Item itemCustomBook; - - public static Item itemGrindleTablet; - public static Item itemRope; - public static Item itemFiber; - public static Item itemDragonJar; - - //Unstable Elements & Related Content - public static Item dustNeptunium238; - public static Item dustDecayedRadium226; - public static Item dustRadium226; - public static Item dustProtactinium233; - - public static ItemGiantEgg itemBigEgg; - - public static GregtechPump toolGregtechPump; - - public static ItemGenericToken itemGenericToken; +public final class ModItems { - public static Item itemControlCore; + public static ToolMaterial STABALLOY = EnumHelper.addToolMaterial("Staballoy", 3, 2500, 7, 1.0F, 18); + + public static Item ZZZ_Empty; + public static Item AAA_Broken; + + public static Item itemAlkalusDisk; + public static Item itemDebugShapeSpawner; + public static ItemCustomSpawnEgg itemCustomSpawnEgg; + + // EnderIO + public static Item itemPlateSoularium; + public static Item itemPlateRedstoneAlloy; + public static Item itemPlateElectricalSteel; + public static Item itemPlatePulsatingIron; + public static Item itemPlateEnergeticAlloy; + public static Item itemPlateVibrantAlloy; + public static Item itemPlateConductiveIron; + public static Item itemPlateDarkSteel; + public static Item itemDustSoularium; + public static Item itemDustRedstoneAlloy; + public static Item itemDustElectricalSteel; + public static Item itemDustPulsatingIron; + public static Item itemDustEnergeticAlloy; + public static Item itemDustVibrantAlloy; + public static Item itemDustConductiveIron; + // Big Reactors + public static Item itemPlateBlutonium; + public static Item itemPlateCyanite; + public static Item itemPlateLudicrite; + // Thaumcraft + public static Item itemPlateVoidMetal; + // Pneumaticraft + public static Item itemPlateCompressedIron; + // SimplyJetpacks + public static Item itemPlateEnrichedSoularium; + // rfTools + public static Item itemPlateDimensionShard; + // Staballoy + public static Item itemStaballoyPickaxe; + public static Item itemStaballoyAxe; + // Tools + public static Item itemSandstoneHammer; + // Machine Related + public static Item itemBufferCore0; + // Material related + public static Item itemStickyRubber; + public static Item itemIngotBatteryAlloy; + public static Item itemPlateBatteryAlloy; + public static Item itemHeliumBlob; + public static Item itemHydrogenBlob; + public static Item itemPLACEHOLDER_Circuit; + + public static Item FuelRod_Empty; + public static Item FuelRod_Thorium; + public static Item FuelRod_Uranium; + public static Item FuelRod_Plutonium; + + public static Item itemBedLocator_Base; + public static Item itemBaseItemWithCharge; + + public static Item itemIngotRaisinBread; + public static Item itemHotIngotRaisinBread; + + public static ItemFood itemFoodRaisinToast; + public static BaseItemHotFood itemHotFoodRaisinToast; + public static BaseItemFood itemFoodCurriedSausages; + public static BaseItemHotFood itemHotFoodCurriedSausages; + + public static Item RfEuBattery; + public static Item itemPersonalCloakingDevice; + public static Item itemPersonalCloakingDeviceCharged; + public static Item itemPersonalHealingDevice; + public static Item itemPersonalFireProofDevice; + public static Item itemSlowBuildingRing; + + public static MultiPickaxeBase MP_GTMATERIAL; + public static MultiSpadeBase MS_GTMATERIAL; + + public static ItemStack FluidCell; + + public static BaseItemBackpack backpack_Red; + public static BaseItemBackpack backpack_Green; + public static BaseItemBackpack backpack_Blue; + public static BaseItemBackpack backpack_Yellow; + public static BaseItemBackpack backpack_Purple; + public static BaseItemBackpack backpack_Cyan; + public static BaseItemBackpack backpack_Maroon; + public static BaseItemBackpack backpack_Olive; + public static BaseItemBackpack backpack_DarkGreen; + public static BaseItemBackpack backpack_DarkPurple; + public static BaseItemBackpack backpack_Teal; + public static BaseItemBackpack backpack_Navy; + public static BaseItemBackpack backpack_Silver; + public static BaseItemBackpack backpack_Gray; + public static BaseItemBackpack backpack_Black; + public static BaseItemBackpack backpack_White; + + public static ItemBlueprint itemBlueprintBase; + + public static Item dustLithiumCarbonate; + public static Item dustLithiumHydroxide; + public static Item dustLithiumPeroxide; + public static Item dustLithiumFluoride; + + public static Item dustUranium232; + public static Item dustUraniumTetraFluoride; + public static Item dustUraniumHexaFluoride; + + public static Item dustBerylliumFluoride; + + public static Item dustQuicklime; + public static Item dustCalciumHydroxide; + public static Item dustCalciumCarbonate; + public static Item dustLi2CO3CaOH2; + public static Item dustLi2BeF4; + + public static Item dustTumbagaMix; + + public static Item dustAer; + public static Item dustIgnis; + public static Item dustTerra; + public static Item dustAqua; + + public static Item cellHydrogenChlorideMix; + + public static BaseEuItem metaItem2; + + public static Item shardAer; + public static Item shardIgnis; + public static Item shardTerra; + public static Item shardAqua; + + // Tc Compat for energy crystal recipes + public static Item shardDull; + + // Lighter + public static Item itemBasicFireMaker; + + // Zirconium + public static Item itemZirconiumChlorideCinterPellet; + public static Item dustZrCl4; + public static Item dustCookedZrCl4; + public static Item dustZrF4; + + public static Item dustNaBF4NaF; + public static Item dustLiFBeF2ZrF4UF4; + public static Item dustLiFBeF2ZrF4U235; + public static Item dustLiFBeF2ThF4UF4; + + public static Item dustCalciumSulfate; + + public static Item dustFertUN18; + public static Item dustFertUN32; + + // public static Fluid fluidFLiBeSalt; + // public static Fluid fluidFLiBeSaltBurnt; + + public static Fluid fluidLftrCore1; + public static Fluid fluidLftrCore2; + public static Fluid fluidLftrCore3; + public static Fluid fluidLftrCore4; + public static Fluid fluidLftrBlanket1; + public static Fluid fluidLftrBlanket2; + public static Fluid fluidLftrBlanket3; + public static Fluid fluidNuclearWaste; + + // Possibly missing base items that GT may be missing. + + public static Item itemSmallWroughtIronGear; + public static Item itemPlateRawMeat; + public static Item itemPlateClay; + public static Item itemPlateLithium; + public static Item itemPlateEuropium; + public static Item itemPlateVanadium; + public static Item itemDoublePlateClay; + public static Item itemDoublePlateEuropium; + public static Item itemFoilUranium235; + public static Item itemDustIndium; + public static BlockBaseModular blockRawMeat; - public static Item itemSunnariumBit; + public static Item itemBoilerChassis; + public static Item itemDehydratorCoilWire; + public static Item itemDehydratorCoil; - public static ItemStack itemHotTitaniumIngot; + public static Item itemLavaFilter; + public static Item itemAirFilter; - public static Fluid fluidZrF4; - public static Fluid fluidFertBasic; - public static Fluid fluidFertUN32; - public static Fluid fluidFertUN18; + public static Item itemCoalCoke; + public static Item itemCactusCharcoal; + public static Item itemSugarCharcoal; + public static Item itemCactusCoke; + public static Item itemSugarCoke; - public static Item boxTools; - public static Item boxFood; - public static Item boxMagic; + public static Item itemCircuitLFTR; + public static Item itemBasicTurbine; - public static DustDecayable dustMolybdenum99; - public static DustDecayable dustTechnetium99; - public static DustDecayable dustTechnetium99M; + public static Item itemDebugAreaClear; - public static IonParticles itemIonParticleBase; - public static StandardBaseParticles itemStandarParticleBase; - - public static BatteryPackBaseBauble itemChargePack_Low_1; - public static BatteryPackBaseBauble itemChargePack_Low_2; - public static BatteryPackBaseBauble itemChargePack_Low_3; - public static BatteryPackBaseBauble itemChargePack_Low_4; - public static BatteryPackBaseBauble itemChargePack_Low_5; - public static BatteryPackBaseBauble itemChargePack_High_1; - public static BatteryPackBaseBauble itemChargePack_High_2; - public static BatteryPackBaseBauble itemChargePack_High_3; - public static BatteryPackBaseBauble itemChargePack_High_4; - - public static DebugScanner itemDebugScanner; - - public static ItemDummyResearch itemDummyResearch; - - public static CoreItem itemBombCasing; - public static CoreItem itemBombUnf; - public static CoreItem itemDetCable; - public static ItemThrowableBomb itemBomb; + public static Item itemGemShards; + public static Item itemHalfCompleteCasings; - public static MonsterKillerBaseBauble itemAmuletMonsterKiller_Zombie; - public static MonsterKillerBaseBauble itemAmuletMonsterKiller_Skeleton; - public static MonsterKillerBaseBauble itemAmuletMonsterKiller_Spider; - public static MonsterKillerBaseBauble itemAmuletMonsterKiller_Creeper; - public static MonsterKillerBaseBauble itemAmuletMonsterKiller_Enderman; + public static Item itemSulfuricPotion; + public static Item itemHydrofluoricPotion; - public static MonsterKillerBaseBauble itemAmuletMonsterKiller_Nether; - public static MonsterKillerBaseBauble itemAmuletMonsterKiller_Infernal; + public static Item itemModularBauble; + public static Item itemCustomBook; - public static CoreItem itemExquisiteIndustrialDiamond; + public static Item itemGrindleTablet; + public static Item itemRope; + public static Item itemFiber; + public static Item itemDragonJar; + + // Unstable Elements & Related Content + public static Item dustNeptunium238; + public static Item dustDecayedRadium226; + public static Item dustRadium226; + public static Item dustProtactinium233; - public static BaseItemMetaFood itemMetaFood; + public static ItemGiantEgg itemBigEgg; - public static ItemMagicFeather itemMagicFeather; + public static GregtechPump toolGregtechPump; - static { - Logger.INFO("Items!"); - //Default item used when recipes fail, handy for debugging. Let's make sure they exist when this class is called upon. - AAA_Broken = new BaseItemIngot_OLD("AAA_Broken", "Errors - Tell Alkalus", Utils.rgbtoHexValue(128, 128, 128), 0); - ZZZ_Empty = new ItemEmpty(); - } - - public static final void init(){ - - itemDebugScanner = new DebugScanner(); - itemMagicFeather = new ItemMagicFeather(); - - itemAlkalusDisk = new BaseItemDamageable("itemAlkalusDisk", AddToCreativeTab.tabMisc, 1, 0, "Unknown Use", EnumRarity.rare, EnumChatFormatting.AQUA, false, null); - itemBigEgg = new ItemGiantEgg(); - itemGenericToken = new ItemGenericToken(); - itemDummyResearch = new ItemDummyResearch(); - itemCustomSpawnEgg = new ItemCustomSpawnEgg(); - - //Debug Loading - if (CORE_Preloader.DEBUG_MODE){ - DEBUG_INIT.registerItems(); - } - - itemDebugAreaClear = new ItemAreaClear(); - - //Register meta item, because we need them for everything. - MetaGeneratedGregtechItems.INSTANCE.generateMetaItems(); - - //Some Simple forms of materials - itemStickyRubber = new Item().setUnlocalizedName("itemStickyRubber").setCreativeTab(tabMachines).setTextureName(CORE.MODID + ":itemStickyRubber"); - GameRegistry.registerItem(itemStickyRubber, "itemStickyRubber"); - GT_OreDictUnificator.registerOre("ingotRubber", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemStickyRubber", 1)); - - //Register Hydrogen Blobs first, so we can replace old helium blobs. - itemHydrogenBlob = new CoreItem("itemHydrogenBlob", "Mysterious Hydrogen Blob", tabMisc).setTextureName(CORE.MODID + ":itemHeliumBlob"); - //Register Old Helium Blob, this will be replaced when held by a player. - itemHeliumBlob = new CoreItem("itemHeliumBlob", tabMisc, ItemUtils.getSimpleStack(itemHydrogenBlob)).setTextureName(CORE.MODID + ":itemHydrogenBlob"); - - //Register this neato device, for making some fires. - itemBasicFireMaker = new ItemBasicFirestarter(); - - //Register Rope - itemFiber = new CoreItem("itemFiber", "Plant Fiber", tabMisc); - itemRope = new CoreItem("itemRope", "Rope", tabMisc); - - //Load Wearable Items - WearableLoader.run(); - - //Make some backpacks - //Primary colours - backpack_Red = new BaseItemBackpack("backpackRed", Utils.rgbtoHexValue(200, 0, 0)); - backpack_Green = new BaseItemBackpack("backpackGreen", Utils.rgbtoHexValue(0, 200, 0)); - backpack_Blue = new BaseItemBackpack("backpackBlue", Utils.rgbtoHexValue(0, 0, 200)); - //Secondary Colours - backpack_Yellow = new BaseItemBackpack("backpackYellow", Utils.rgbtoHexValue(200, 200, 0)); - backpack_Purple = new BaseItemBackpack("backpackPurple", Utils.rgbtoHexValue(200, 0, 200)); - backpack_Cyan = new BaseItemBackpack("backpackCyan", Utils.rgbtoHexValue(0, 200, 200)); - //Tertiary Colours - backpack_Maroon = new BaseItemBackpack("backpackMaroon", Utils.rgbtoHexValue(128, 0, 0)); - backpack_Olive = new BaseItemBackpack("backpackOlive", Utils.rgbtoHexValue(128, 128, 0)); - backpack_DarkGreen = new BaseItemBackpack("backpackDarkGreen", Utils.rgbtoHexValue(0, 128, 0)); - backpack_DarkPurple = new BaseItemBackpack("backpackDarkPurple", Utils.rgbtoHexValue(128, 0, 128)); - backpack_Teal = new BaseItemBackpack("backpackTeal", Utils.rgbtoHexValue(0, 128, 128)); - backpack_Navy = new BaseItemBackpack("backpackNavy", Utils.rgbtoHexValue(0, 0, 128)); - //Shades - backpack_Silver = new BaseItemBackpack("backpackSilver", Utils.rgbtoHexValue(192, 192, 192)); - backpack_Gray = new BaseItemBackpack("backpackGray", Utils.rgbtoHexValue(128, 128, 128)); - backpack_Black = new BaseItemBackpack("backpackBlack", Utils.rgbtoHexValue(20, 20, 20)); - backpack_White = new BaseItemBackpack("backpackWhite", Utils.rgbtoHexValue(240, 240, 240)); - - - //Load Custom Box/bags - boxTools = new UniversalToolBox("Tool Box"); - boxFood = new AutoLunchBox("Eatotron-9000"); - boxMagic = new MagicToolBag("Mystic Bag"); - - itemBlueprintBase = new ItemBlueprint("itemBlueprint"); - - itemGemShards = new ItemGemShards("itemGemShards", "Gem Shards", AddToCreativeTab.tabMisc, 32, 0, "They glitter in the light", EnumRarity.rare, EnumChatFormatting.GRAY, false, Utils.rgbtoHexValue(182, 114, 18)).setTextureName(CORE.MODID + ":itemHeliumBlob"); - itemHalfCompleteCasings = new ItemHalfCompleteCasings("itemHalfCompleteCasings", AddToCreativeTab.tabMisc, 32, 0, "This isn't quite finished yet.", EnumRarity.common, EnumChatFormatting.GRAY, false, Utils.rgbtoHexValue(255, 255, 255)).setTextureName("gregtech" + ":" + "gt.metaitem.01/" + "761"); - itemSulfuricPotion = new ItemSulfuricAcidPotion("itemSulfuricPotion", "Throwable Vial of Sulfuric Acid", "Burn your foes alive!").setTextureName(CORE.MODID + ":itemSulfuricAcidPotion"); - itemHydrofluoricPotion = new ItemHydrofluoricAcidPotion("itemHydrofluoricPotion", "Throwable Vial of Hydrofluoric Acid", "They won't see this coming, nor anything after!").setTextureName(CORE.MODID + ":itemPotion"); - //Start meta Item Generation - ItemsFoods.load(); - - - try{ - - registerCustomMaterialComponents(); - - //Elements generate first so they can be used in compounds. - //Missing Elements - MaterialGenerator.generate(ELEMENT.getInstance().SELENIUM); //LFTR byproduct - MaterialGenerator.generate(ELEMENT.getInstance().BROMINE); - MaterialGenerator.generate(ELEMENT.getInstance().KRYPTON); //LFTR byproduct - MaterialGenerator.generate(ELEMENT.getInstance().STRONTIUM); - MaterialGenerator.generate(ELEMENT.getInstance().ZIRCONIUM); - MaterialGenerator.generate(ELEMENT.getInstance().RUTHENIUM); - MaterialGenerator.generate(ELEMENT.getInstance().IODINE); //LFTR byproduct - MaterialGenerator.generate(ELEMENT.getInstance().HAFNIUM); - MaterialGenerator.generate(ELEMENT.getInstance().DYSPROSIUM); - MaterialGenerator.generate(ELEMENT.getInstance().ERBIUM); - MaterialGenerator.generate(ELEMENT.getInstance().PRASEODYMIUM); - MaterialGenerator.generate(ELEMENT.getInstance().TELLURIUM); //LFTR byproduct - MaterialGenerator.generate(ELEMENT.getInstance().RHODIUM); - MaterialGenerator.generate(ELEMENT.getInstance().RHENIUM); - MaterialGenerator.generate(ELEMENT.getInstance().THALLIUM); - - //RADIOACTIVE ELEMENTS - MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().TECHNETIUM, false); //LFTR byproduct - MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().POLONIUM, false); - MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().ASTATINE, false); - //MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().RADON, false); - MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().FRANCIUM, false); - MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().RADIUM, false); - MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().PROMETHIUM, false); - MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().ACTINIUM, false); - MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().PROTACTINIUM, false); - MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().NEPTUNIUM, false); //LFTR byproduct - MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().CURIUM, false); - MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().BERKELIUM, false); - MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().CALIFORNIUM, false); - MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().EINSTEINIUM, false); - MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().FERMIUM, false); - - - //Nuclear Isotopes - - //Lithium-7 is used as a part of the molten lithium fluoride in molten salt reactors: liquid-fluoride nuclear reactors. - //The large neutron-absorption cross-section of lithium-6 (about 940 barns[5]) as compared with the very small - //neutron cross-section of lithium-7 (about 45 millibarns) makes high separation of lithium-7 from natural lithium a - //strong requirement for the possible use in lithium fluoride reactors. - MaterialGenerator.generate(ELEMENT.getInstance().LITHIUM7, false); - //Thorium-232 is the most stable isotope of Thorium, purified for nuclear fuel use in this case. - MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().THORIUM232); - //Production of 233U (through the neutron irradiation of 232Th) invariably produces small amounts of 232U as an impurity - //because of parasitic (n,2n) reactions on uranium-233 itself, or on protactinium-233, or on thorium-232: - MaterialGenerator.generate(ELEMENT.getInstance().URANIUM232); - //Uranium-233 is a fissile isotope of uranium that is bred from thorium-232 as part of the thorium fuel cycle. - MaterialGenerator.generate(ELEMENT.getInstance().URANIUM233); - //Plutonium-238 is a very powerful alpha emitter. This makes the plutonium-238 isotope suitable for usage in radioisotope thermoelectric generators (RTGs) - //and radioisotope heater units - one gram of plutonium-238 generates approximately 0.5 W of thermal power. - MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().PLUTONIUM238, false); - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustPlutonium239", 1) == null || Utils.getGregtechVersionAsInt() < 50931) { - MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().PLUTONIUM239, false); - } - - //RTG Fuel Materials - MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().STRONTIUM90, false); - MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().POLONIUM210, false); - MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().AMERICIUM241, false); - - if (!CORE.GTNH) { - MaterialGenerator.generateOreMaterialWithAllExcessComponents(ELEMENT.getInstance().TRINIUM); - } - - //Custom Materials that will have standalone refinery processes - MaterialGenerator.generate(ELEMENT.STANDALONE.ADVANCED_NITINOL, false); - MaterialGenerator.generate(ELEMENT.STANDALONE.ASTRAL_TITANIUM); - MaterialGenerator.generate(ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN); - MaterialGenerator.generate(ELEMENT.STANDALONE.HYPOGEN); - MaterialGenerator.generate(ELEMENT.STANDALONE.CHRONOMATIC_GLASS); - MaterialGenerator.generate(ELEMENT.STANDALONE.FORCE); - - //Custom Materials that are from Runescape - MaterialGenerator.generate(ELEMENT.STANDALONE.BLACK_METAL); - MaterialGenerator.generate(ELEMENT.STANDALONE.WHITE_METAL); - MaterialGenerator.generateOreMaterialWithAllExcessComponents(ELEMENT.STANDALONE.GRANITE); - MaterialGenerator.generateOreMaterialWithAllExcessComponents(ELEMENT.STANDALONE.RUNITE); - MaterialGenerator.generate(ELEMENT.STANDALONE.DRAGON_METAL, false); - - MISC_MATERIALS.run(); - - - //Carbides - Tungsten Carbide exists in .09 so don't generate it. - Should still come before alloys though - if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ - MaterialGenerator.generate(ALLOY.TUNGSTEN_CARBIDE); - } - MaterialGenerator.generate(ALLOY.SILICON_CARBIDE); - MaterialGenerator.generate(ALLOY.ZIRCONIUM_CARBIDE); - MaterialGenerator.generate(ALLOY.TANTALUM_CARBIDE); - MaterialGenerator.generate(ALLOY.NIOBIUM_CARBIDE); - MaterialGenerator.generate(ALLOY.TUNGSTEN_TITANIUM_CARBIDE); - - //LFTR Fuel components - //MaterialGenerator.generate(MISC_MATERIALS.HYDROXIDE); //LFTR fuel component - //MaterialGenerator.generate(MISC_MATERIALS.AMMONIA); //LFTR fuel component - //MaterialGenerator.generate(MISC_MATERIALS.AMMONIUM); //LFTR fuel component - MaterialGenerator.generateNuclearDusts(FLUORIDES.AMMONIUM_BIFLUORIDE); //LFTR fuel component - MaterialGenerator.generateNuclearDusts(FLUORIDES.BERYLLIUM_HYDROXIDE); //LFTR fuel component - MaterialGenerator.generateNuclearDusts(FLUORIDES.AMMONIUM_TETRAFLUOROBERYLLATE); //LFTR fuel component - - //Generate Fluorides - MaterialGenerator.generateNuclearDusts(FLUORIDES.BERYLLIUM_FLUORIDE); - MaterialGenerator.generateNuclearDusts(FLUORIDES.LITHIUM_FLUORIDE); - MaterialGenerator.generateNuclearDusts(FLUORIDES.THORIUM_TETRAFLUORIDE); - MaterialGenerator.generateNuclearDusts(FLUORIDES.THORIUM_HEXAFLUORIDE); - MaterialGenerator.generateNuclearDusts(FLUORIDES.URANIUM_TETRAFLUORIDE, false); - MaterialGenerator.generateNuclearDusts(FLUORIDES.URANIUM_HEXAFLUORIDE, false); - MaterialGenerator.generateNuclearDusts(FLUORIDES.ZIRCONIUM_TETRAFLUORIDE); - //LFTR Fluoride outputs - MaterialGenerator.generateNuclearDusts(FLUORIDES.NEPTUNIUM_HEXAFLUORIDE); - MaterialGenerator.generateNuclearDusts(FLUORIDES.TECHNETIUM_HEXAFLUORIDE); - MaterialGenerator.generateNuclearDusts(FLUORIDES.SELENIUM_HEXAFLUORIDE); - - //Generate Reactor Fuel Salts - MaterialGenerator.generateNuclearDusts(NUCLIDE.LiFBeF2ZrF4U235); - MaterialGenerator.generateNuclearDusts(NUCLIDE.LiFBeF2ZrF4UF4); - MaterialGenerator.generateNuclearDusts(NUCLIDE.LiFBeF2ThF4UF4); - //MaterialGenerator.generateNuclearMaterial(NUCLIDE.Li2BeF4, false); - - //Generate some Alloys - - //Misc Alloys - MaterialGenerator.generate(ALLOY.ENERGYCRYSTAL); - MaterialGenerator.generate(ALLOY.BLOODSTEEL); - - MaterialGenerator.generate(ALLOY.ZERON_100); - //Tumbaga was the name given by Spaniards to a non-specific alloy of gold and copper - MaterialGenerator.generate(ALLOY.TUMBAGA); - //Potin is traditionally an alloy of bronze, tin and lead, with varying quantities of each possible - MaterialGenerator.generate(ALLOY.POTIN); - - //Staballoy & Tantalloy - MaterialGenerator.generate(ALLOY.STABALLOY); - MaterialGenerator.generate(ALLOY.TANTALLOY_60); - MaterialGenerator.generate(ALLOY.TANTALLOY_61); - - //Inconel - MaterialGenerator.generate(ALLOY.INCONEL_625); - MaterialGenerator.generate(ALLOY.INCONEL_690); - MaterialGenerator.generate(ALLOY.INCONEL_792); - - - //Steels - MaterialGenerator.generateDusts(ALLOY.EGLIN_STEEL_BASE); - MaterialGenerator.generate(ALLOY.EGLIN_STEEL); - MaterialGenerator.generate(ALLOY.MARAGING250); - MaterialGenerator.generate(ALLOY.MARAGING300); - MaterialGenerator.generate(ALLOY.MARAGING350); - MaterialGenerator.generate(ALLOY.AQUATIC_STEEL); - - MaterialGenerator.generate(ALLOY.NITINOL_60, true, false); - - //Composite Alloys - MaterialGenerator.generate(ALLOY.STELLITE); - MaterialGenerator.generate(ALLOY.TALONITE); - - //Hastelloy - MaterialGenerator.generate(ALLOY.HASTELLOY_W); - MaterialGenerator.generate(ALLOY.HASTELLOY_X); - MaterialGenerator.generate(ALLOY.HASTELLOY_C276); - MaterialGenerator.generate(ALLOY.HASTELLOY_N); - - //Incoloy - MaterialGenerator.generate(ALLOY.INCOLOY_020); - MaterialGenerator.generate(ALLOY.INCOLOY_DS); - MaterialGenerator.generate(ALLOY.INCOLOY_MA956); - - //Leagrisium - MaterialGenerator.generate(ALLOY.LEAGRISIUM); - - //Super Conductor - MaterialGenerator.generate(ALLOY.HG1223, false, false); - - //Generate Fictional Materials - if (!CORE.GTNH) { - MaterialGenerator.generate(ELEMENT.getInstance().TRINIUM, false); - MaterialGenerator.generate(ELEMENT.getInstance().TRINIUM_REFINED, false); - } - MaterialGenerator.generate(ALLOY.TRINIUM_TITANIUM); - MaterialGenerator.generate(ALLOY.TRINIUM_NAQUADAH, false); - MaterialGenerator.generate(ALLOY.TRINIUM_NAQUADAH_CARBON); - MaterialGenerator.generate(ALLOY.TRINIUM_REINFORCED_STEEL); - - //Top Tier Alloys - MaterialGenerator.generate(ALLOY.HELICOPTER); - MaterialGenerator.generate(ALLOY.LAFIUM); - MaterialGenerator.generate(ALLOY.CINOBITE); - MaterialGenerator.generate(ALLOY.PIKYONIUM); - MaterialGenerator.generate(ALLOY.ABYSSAL); - MaterialGenerator.generate(ALLOY.LAURENIUM); - MaterialGenerator.generate(ALLOY.BOTMIUM); - MaterialGenerator.generate(ALLOY.HS188A); - - - MaterialGenerator.generate(ALLOY.TITANSTEEL); - MaterialGenerator.generate(ALLOY.ARCANITE); - MaterialGenerator.generate(ALLOY.OCTIRON); - - MaterialGenerator.generate(ALLOY.BABBIT_ALLOY, false); - MaterialGenerator.generate(ALLOY.BLACK_TITANIUM, false); - MaterialGenerator.generate(ALLOY.INDALLOY_140, false, false); - - // High Level Bioplastic - MaterialGenerator.generate(ELEMENT.STANDALONE.RHUGNOR, false, false); - - - - - - - - - //Must be the final Alloy to Generate - MaterialGenerator.generate(ALLOY.QUANTUM); - - //Ores - MaterialGenerator.generateOreMaterial(FLUORIDES.FLUORITE); - MaterialGenerator.generateOreMaterial(ALLOY.KOBOLDITE); - GTplusplus_Everglades.GenerateOreMaterials(); - - // formula override - ALLOY.TUNGSTEN_TITANIUM_CARBIDE.vChemicalFormula = StringUtils.subscript("(CW)7Ti3"); - ALLOY.TITANSTEEL.vChemicalFormula = StringUtils.subscript("((CW)7Ti3)3???"); - - // Werkstoff bridge - ELEMENT.getInstance().ZIRCONIUM.setWerkstoffID((short) 3); - ELEMENT.getInstance().THORIUM232.setWerkstoffID((short) 30); - ELEMENT.getInstance().RUTHENIUM.setWerkstoffID((short) 64); - ELEMENT.getInstance().HAFNIUM.setWerkstoffID((short) 11000); - ELEMENT.getInstance().IODINE.setWerkstoffID((short) 11012); - - - } catch (final Throwable r){ - Logger.INFO("Failed to Generated a Material. "+r.getMessage()); - //Utils.LOG_INFO("Failed to Generated a Material. "+r.getCause().getMessage()); - //Utils.LOG_INFO("Failed to Generated a Material. "+r.getStackTrace()[0].getMethodName()); - //Utils.LOG_INFO("Failed to Generated a Material. "+r.getStackTrace()[1].getMethodName()); - r.printStackTrace(); - //System.exit(1); - } - - //TC Style Shards, for use in making energy crystal mix. - //A dull shard, able to be infused with an element. - shardDull = new BaseItemTCShard("Drained", Utils.rgbtoHexValue(75, 75, 75), "Can be infused to create a magical shard.", "Obtained from Mining Stone/SandStone, Chopping Logs or Shovelling Dirt."); - - //Generates four elemental shards when TC is not installed. - if (!LoadedMods.Thaumcraft){ - shardAer = new BaseItemTCShard("Aer", Utils.rgbtoHexValue(225, 225, 5)); - shardIgnis = new BaseItemTCShard("Ignis", Utils.rgbtoHexValue(255, 5, 5)); - shardTerra = new BaseItemTCShard("Terra", Utils.rgbtoHexValue(5, 255, 5)); - shardAqua = new BaseItemTCShard("Aqua", Utils.rgbtoHexValue(5, 5, 255)); - } - else { - shardAer = ItemUtils.getItemStackWithMeta(LoadedMods.Thaumcraft, "Thaumcraft:ItemShard", "Air Shard", 0, 1).getItem(); - shardIgnis = ItemUtils.getItemStackWithMeta(LoadedMods.Thaumcraft, "Thaumcraft:ItemShard", "Fire Shard", 1, 1).getItem(); - shardAqua = ItemUtils.getItemStackWithMeta(LoadedMods.Thaumcraft, "Thaumcraft:ItemShard", "Warer Shard", 2, 1).getItem(); - shardTerra = ItemUtils.getItemStackWithMeta(LoadedMods.Thaumcraft, "Thaumcraft:ItemShard", "Earth Shard", 3, 1).getItem(); - } - //Generates a set of four special dusts to be used in my recipes. - dustAer = ItemUtils.generateSpecialUseDusts(ELEMENT.getInstance().AER, true)[0]; - dustIgnis = ItemUtils.generateSpecialUseDusts(ELEMENT.getInstance().IGNIS, true)[0]; - dustTerra = ItemUtils.generateSpecialUseDusts(ELEMENT.getInstance().TERRA, true)[0]; - dustAqua = ItemUtils.generateSpecialUseDusts(ELEMENT.getInstance().AQUA, true)[0]; - - ItemUtils.generateSpecialUseDusts(MISC_MATERIALS.WOODS_GLASS, false); - cellHydrogenChlorideMix = new BaseItemCell("hydrogenchloridemix", "Hydrogen Chloride Mix", MISC_MATERIALS.HYDROGEN_CHLORIDE.getRGB()); - - //Nuclear Fuel Dusts - dustLithiumCarbonate = ItemUtils.generateSpecialUseDusts("LithiumCarbonate", "Lithium Carbonate", "Li2CO3", Utils.rgbtoHexValue(240, 240, 240))[0]; //https://en.wikipedia.org/wiki/Lithium_carbonate - dustLithiumPeroxide = ItemUtils.generateSpecialUseDusts("LithiumPeroxide", "Lithium Peroxide", "Li2O2", Utils.rgbtoHexValue(250, 250, 250))[0]; //https://en.wikipedia.org/wiki/Lithium_peroxide - dustLithiumHydroxide = ItemUtils.generateSpecialUseDusts("LithiumHydroxide", "Lithium Hydroxide", "LiOH", Utils.rgbtoHexValue(250, 250, 250))[0]; //https://en.wikipedia.org/wiki/Lithium_hydroxide - - if (!ItemUtils.checkForInvalidItems(ItemUtils.getItemStackOfAmountFromOreDict("dustQuicklime", 1)) && !LoadedMods.IHL){ - dustQuicklime = ItemUtils.generateSpecialUseDusts("Quicklime", "Quicklime", "CaO", Utils.rgbtoHexValue(255, 255, 175))[0]; //https://en.wikipedia.org/wiki/Calcium_oxide - } - dustCalciumHydroxide = ItemUtils.generateSpecialUseDusts("CalciumHydroxide", "Hydrated Lime", "Ca(OH)2", Utils.rgbtoHexValue(255, 255, 255))[0]; //https://en.wikipedia.org/wiki/Calcium_hydroxide - dustCalciumCarbonate = ItemUtils.generateSpecialUseDusts("CalciumCarbonate", "Calcium Carbonate", "CaCO3", Utils.rgbtoHexValue(255, 255, 255))[0]; //https://en.wikipedia.org/wiki/Calcium_carbonate - if ((ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustGypsum", 1) == null) || (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustCalciumSulfate", 1) == null)){ - dustCalciumSulfate = ItemUtils.generateSpecialUseDusts("Gypsum", "Calcium Sulfate (Gypsum)", "CaSO4", Utils.rgbtoHexValue(255, 255, 255))[0]; //https://en.wikipedia.org/wiki/Calcium_sulfate - GT_OreDictUnificator.registerOre("dustCalciumSulfate", ItemUtils.getSimpleStack(dustCalciumSulfate)); - } - else { - GT_OreDictUnificator.registerOre("dustCalciumSulfate", ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustGypsum", 1)); - } - dustLi2CO3CaOH2 = ItemUtils.generateSpecialUseDusts("Li2CO3CaOH2", "Li2CO3 + Ca(OH)2 Compound", "Li2CO3CaOH2", Utils.rgbtoHexValue(255, 255, 255))[0]; //https://en.wikipedia.org/wiki/Calcium_carbonate - MaterialUtils.generateSpecialDustAndAssignToAMaterial(FLUORIDES.SODIUM_FLUORIDE, false); - //FLiBe Fuel Compounds - dustLi2BeF4 = ItemUtils.generateSpecialUseDusts("Li2BeF4", "Lithium Tetrafluoroberyllate Fuel Compound", "Li2BeF4", Utils.rgbtoHexValue(255, 255, 255))[0]; //https://en.wikipedia.org/wiki/FLiBe - Material.registerComponentForMaterial(NUCLIDE.Li2BeF4, OrePrefixes.dust, ItemUtils.getSimpleStack(dustLi2BeF4)); - //fluidFLiBeSalt = ("Li2BeF4", "Li2BeF4", 7430, new short[]{255, 255, 255, 100}, 0); - //fluidFLiBeSalt = FluidUtils.addGTFluidNoPrefix("Li2BeF4", "Lithium Tetrafluoroberyllate", new short[]{255, 255, 255, 100}, 0, 743, null, CI.emptyCells(1), 1000, true); - //fluidFLiBeSaltBurnt = FluidUtils.addGTFluidNoPrefix("Li2BeF2UF4", "Li2BeF2UF4", new short[]{50, 255, 50, 100}, 0, 743, null, CI.emptyCells(1), 1000, true); - - // LFTR Core Fluid Processing - //fluidLftrCore1 = FluidUtils.addGTFluidNoPrefix("LiBeF2UF4FP", "LiBeF2UF4FP", new short[]{110, 255, 110, 100}, 0, 800, null, CI.emptyCells(1), 1000, true); - //fluidLftrCore2 = FluidUtils.addGTFluidNoPrefix("UF6F2FP", "UF6F2FP", new short[]{150, 255, 150, 100}, 0, 800, null, CI.emptyCells(1), 1000, true); - //fluidLftrCore3 = FluidUtils.addGTFluidNoPrefix("LiFBeF2", "LiFBeF2", new short[]{100, 255, 50, 100}, 0, 800, null, CI.emptyCells(1), 1000, true); - //fluidLftrCore4 = FluidUtils.addGTFluidNoPrefix("LiFBeF2UF4", "LiFBeF2UF4", new short[]{50, 255, 100, 100}, 0, 800, null, CI.emptyCells(1), 1000, true); - // LFTR Blanket Fluid Processing - //fluidLftrBlanket1 = FluidUtils.addGTFluidNoPrefix("LiFThF4", "LiFThF4", new short[]{50, 150, 255, 50}, 0, 500, null, CI.emptyCells(1), 1000, true); - //fluidLftrBlanket2 = FluidUtils.addGTFluidNoPrefix("LiFBeF2ThF4", "LiFBeF2ThF4", new short[]{100, 150, 100, 100}, 0, 500, null, CI.emptyCells(1), 1000, true); - //fluidLftrBlanket3 = FluidUtils.addGTFluidNoPrefix("UF6F2", "UF6F2", new short[]{10, 150, 10, 100}, 0, 500, null, CI.emptyCells(1), 1000, true); - fluidNuclearWaste = FluidUtils.addGTFluidNoPrefix("nuclear.waste", "Nuclear Waste", new short[]{10, 250, 10, 100}, 0, 1000, null, CI.emptyCells(1), 1000, true); - - - //LFTR Control Circuit - itemCircuitLFTR = new CoreItem("itemCircuitLFTR", ""+EnumChatFormatting.GREEN+"Control Circuit", AddToCreativeTab.tabMisc, 1, 0, new String[] {"Keeps Multiblocks Stable"}, EnumRarity.epic, EnumChatFormatting.DARK_GREEN, false, null); - - if (CORE.ConfigSwitches.enableMachine_Pollution) { - itemBasicTurbine = new ItemBasicScrubberTurbine(); - } - - //Zirconium - //Cinter Pellet. - itemZirconiumChlorideCinterPellet = new CoreItem("itemZirconiumPellet", "Zirconium Pellet ["+StringUtils.subscript("ZrCl4")+"]", tabMisc).setTextureName(CORE.MODID + ":itemShard"); - GT_OreDictUnificator.registerOre("pelletZirconium", new ItemStack(itemZirconiumChlorideCinterPellet)); - //Zirconium Chloride - dustZrCl4 = ItemUtils.generateSpecialUseDusts("ZrCl4", "ZrCl4", "ZrCl4", Utils.rgbtoHexValue(180, 180, 180))[0]; //http://www.iaea.org/inis/collection/NCLCollectionStore/_Public/39/036/39036750.pdf - dustCookedZrCl4 = ItemUtils.generateSpecialUseDusts("CookedZrCl4", "Cooked ZrCl4", "ZrCl4", Utils.rgbtoHexValue(180, 180, 180))[0]; //http://www.iaea.org/inis/collection/NCLCollectionStore/_Public/39/036/39036750.pdf - - //Zirconium Tetrafluoride - /*GT_OreDictUnificator.registerOre("cellZrF4", ItemUtils.getItemStackOfAmountFromOreDict("cellZirconiumTetrafluoride", 1)); - GT_OreDictUnificator.registerOre("dustZrF4", ItemUtils.getItemStackOfAmountFromOreDict("dustZirconiumTetrafluoride", 1));*/ - //GT_OreDictUnificator.registerOre("cellZrF4", ItemUtils.getItemStackOfAmountFromOreDict("cellZirconiumTetrafluoride", 1)); - //GT_OreDictUnificator.registerOre("dustZrF4", ItemUtils.getItemStackOfAmountFromOreDict("dustZirconiumTetrafluoride", 1)); - fluidZrF4 = FluidUtils.generateFluidNoPrefix("ZirconiumTetrafluoride", "Zirconium Tetrafluoride", 500, new short[]{170, 170, 140, 100}); //https://en.wikipedia.org/wiki/Zirconium_tetrafluoride - FLUORIDES.ZIRCONIUM_TETRAFLUORIDE.setFluid(fluidZrF4); - - //Coolant Salt - //NaBF4 - NaF - 621C - //dustNaBF4NaF = ItemUtils.generateSpecialUseDusts("NaBF4NaF", "NaBF4NaF", Utils.rgbtoHexValue(45, 45, 90))[0]; //https://en.wikipedia.org/wiki/Zirconium_tetrafluoride - - - //Load Tree Farmer - if (CORE.ConfigSwitches.enableMultiblock_TreeFarmer){ //https://en.wikipedia.org/wiki/UAN - dustFertUN18 = ItemUtils.generateSpecialUseDusts("UN18Fertiliser", "UN-18 Fertiliser", Utils.rgbtoHexValue(60, 155, 60))[0]; - dustFertUN32 = ItemUtils.generateSpecialUseDusts("UN32Fertiliser", "UN-32 Fertiliser", Utils.rgbtoHexValue(55, 190, 55))[0]; - - ItemStack temp1 = null; - ItemStack temp2 = null; - - if (LoadedMods.IndustrialCraft2){ - temp1 = ItemUtils.getCorrectStacktype("IC2:itemFertilizer", 1); - } - if (LoadedMods.Forestry){ - temp2 = ItemUtils.getCorrectStacktype("Forestry:fertilizerCompound", 1); - } - if (temp1 != null){ - fluidFertBasic = FluidUtils.generateFluidNonMolten("Fertiliser", "Fertiliser", 32, new short[]{45, 170, 45, 100}, temp1, null, true); - GT_Values.RA.addFluidExtractionRecipe(temp2, null, new FluidStack(fluidFertBasic, 36), 10000, 5, 16); - } - fluidFertUN32 = FluidUtils.generateFluidNonMolten("UN32Fertiliser", "UN-32 Fertiliser", 24, new short[]{55, 190, 55, 100}, null, null, true); - fluidFertUN18 = FluidUtils.generateFluidNonMolten("UN18Fertiliser", "UN-18 Fertiliser", 22, new short[]{60, 155, 60, 100}, null, null, true); - - /*GT_Values.RA.addMixerRecipe( - arg0, //Item In - arg1, - arg2, - arg3, - arg4, //Fluid in - arg5, //Fluid Out - arg6, //Item out - arg7, //Eu - arg8); //Time - */ - - } - - //Juice - FluidUtils.generateFluidNonMolten("RaisinJuice", "Raisin Juice", 2, new short[]{51, 0, 51, 100}, ItemUtils.getItemStackOfAmountFromOreDictNoBroken("foodRaisins", 1), ItemUtils.getItemStackOfAmountFromOreDictNoBroken("fruitRaisins", 1), 50, true); - - - //Test items - metaItem2 = new BaseEuItem(); - metaItem2.registerItem(0, EnumChatFormatting.BLACK+"Test Item 0", 0, 0, "I am 0."); - metaItem2.registerItem(1, EnumChatFormatting.GREEN+"Test Item 1", 1006346000, 1, "I Hold EU 1.", 500); - metaItem2.registerItem(2, EnumChatFormatting.GOLD+"Test Item 2", 1004630000, 2, "I Hold EU 2.", 8000); - metaItem2.registerItem(3, "Test Item 3", 1000765000, 4, "I Hold EU 3.", 32000); - metaItem2.registerItem(4, "Whirlygig", 1043644000, (short) 5, "Spin me right round.", EnumRarity.rare, EnumChatFormatting.DARK_GREEN, true); - metaItem2.registerItem(5, "Whirlygig 2", 2124867000, (short) 7, "Spin me right round.", EnumRarity.uncommon, EnumChatFormatting.RED, true); - - toolGregtechPump = new GregtechPump(); - toolGregtechPump.registerPumpType(0, "Simple Hand Pump", 0, 0); - toolGregtechPump.registerPumpType(1, "Advanced Hand Pump", 32000, 1); - toolGregtechPump.registerPumpType(2, "Super Hand Pump", 128000, 2); - toolGregtechPump.registerPumpType(3, "Ultimate Hand Pump", 512000, 3); - - //Create Multi-tools - //ItemsMultiTools.load(); - - //Xp Fluids - Dev - if (!FluidRegistry.isFluidRegistered("mobessence")){ - FluidUtils.generateFluidNoPrefix("mobessence", "mobessence", 0, new short[]{125, 175, 125, 100}); - } - if (!FluidRegistry.isFluidRegistered("xpjuice")){ - FluidUtils.generateFluidNoPrefix("xpjuice", "xpjuice", 0, new short[]{50, 150, 50, 100}); - } - - //Industrial Diamonds - itemExquisiteIndustrialDiamond = new CoreItem("IndustrialDiamondExquisite", "High Quality Industrial Diamond", tabMisc); - ItemStack tempStack = itemExquisiteIndustrialDiamond.getStack(); - ItemUtils.addItemToOreDictionary(tempStack, "gemDiamond"); - ItemUtils.addItemToOreDictionary(tempStack, "craftingIndustrialDiamond"); - ItemUtils.addItemToOreDictionary(tempStack, "gemExquisiteDiamond"); - ItemUtils.addItemToOreDictionary(tempStack, "craftingExquisiteIndustrialDiamond"); - - - /* - * Decayable Materials - */ - - dustNeptunium238 = new DustDecayable("dustNeptunium238", Utils.rgbtoHexValue(175, 240, 75), 50640, new String[] {""+StringUtils.superscript("238Np"), "Result: Plutonium 238 ("+StringUtils.superscript("238Pu")+")"}, ELEMENT.getInstance().PLUTONIUM238.getDust(1).getItem(), 5); - dustDecayedRadium226 = ItemUtils.generateSpecialUseDusts("DecayedRadium226", "Decayed Radium-226", "Contains Radon ("+StringUtils.superscript("222Rn")+")", ELEMENT.getInstance().RADIUM.getRgbAsHex())[0]; - dustRadium226 = new DustDecayable("dustRadium226", ELEMENT.getInstance().RADIUM.getRgbAsHex(), 90000, new String[] {""+StringUtils.superscript("226Ra"), "Result: Radon ("+StringUtils.superscript("222Rn")+")"}, ItemUtils.getSimpleStack(dustDecayedRadium226).getItem(), 5); - dustProtactinium233 = new DustDecayable("dustProtactinium233", ELEMENT.getInstance().PROTACTINIUM.getRgbAsHex(), 32000, new String[] {""+StringUtils.superscript("233Pa"), "Result: Uranium 233("+StringUtils.superscript("233U")+")"}, ELEMENT.getInstance().URANIUM233.getDust(1).getItem(), 6); - dustTechnetium99 = new DustDecayable("dustTechnetium99", ELEMENT.getInstance().TECHNETIUM.getRgbAsHex(), 164500, new String[] {""+StringUtils.superscript("99Mo"), "Result: Ruthenium 99("+StringUtils.superscript("99Ru")+")"}, ELEMENT.getInstance().RUTHENIUM.getDust(1).getItem(), 4); - dustTechnetium99M = new DustDecayable("dustTechnetium99M", ELEMENT.getInstance().TECHNETIUM.getRgbAsHex(), 8570, new String[] {""+StringUtils.superscript("99ᵐTc"), "Result: Technicium 99 ("+StringUtils.superscript("99Tc")+")"}, dustTechnetium99, 4); - dustMolybdenum99 = new DustDecayable("dustMolybdenum99", ELEMENT.getInstance().MOLYBDENUM.getRgbAsHex(), 16450, new String[] {""+StringUtils.superscript("99Mo"), "Result: Technicium 99ᵐ ("+StringUtils.superscript("99ᵐTc")+")"}, dustTechnetium99M, 4); - - itemIonParticleBase = new IonParticles(); - itemStandarParticleBase = new StandardBaseParticles(); - - if (Meta_GT_Proxy.sDoesVolumetricFlaskExist) { - Item a8kFlask = VolumetricFlaskHelper.generateNewFlask("Volumetric_Flask_8k", "Large Volumetric Flask", 8000); - Item a64kFlask = VolumetricFlaskHelper.generateNewFlask("Volumetric_Flask_32k", "Gigantic Volumetric Flask", 32000); - GregtechItemList.VOLUMETRIC_FLASK_8k.set(a8kFlask); - GregtechItemList.VOLUMETRIC_FLASK_32k.set(a64kFlask); - } - - itemBoilerChassis = new ItemBoilerChassis(); - itemDehydratorCoilWire = new ItemDehydratorCoilWire(); - itemDehydratorCoil = new ItemDehydratorCoil(); - - itemAirFilter = new ItemAirFilter(); - itemLavaFilter = new ItemLavaFilter(); - - itemGrindleTablet = new BaseItemGrindle(); - itemDragonJar = new ItemEntityCatcher(); - - itemControlCore = new ItemControlCore(); - - itemSunnariumBit = new ItemSunnariumBit(); - - //Chemistry - new CoalTar(); - new RocketFuels(); - - //Nuclear Processing - new NuclearChem(); - - //Farm Animal Fun - new AgriculturalChem(); - - //General Chemistry - new GenericChem(); - - // Milled Ore Processing - new MilledOreProcessing(); - - //Bombs - itemBombCasing = new CoreItem("itemBombCasing", "Bomb Casing", tabMisc); - itemBombCasing.setTextureName(CORE.MODID + ":bomb_casing"); - itemBombUnf = new CoreItem("itemBombUnf", "Bomb (unf)", tabMisc); - itemBombUnf.setTextureName(CORE.MODID + ":bomb_casing"); - itemDetCable = new CoreItem("itemDetCable", "Det. Cable", tabMisc); - itemDetCable.setTextureName("string"); - itemBomb = new ItemThrowableBomb(); - - //Only used for debugging. - /*if (CORE.DEVENV) { - new ConnectedBlockFinder(); - }*/ - - //Misc Items - @SuppressWarnings("unused") - Item tI; - tI = new BaseItemMisc("Chilly", new short[]{0,64,196}, 32, MiscTypes.POTION, new String[]{"It's Blue"}); - tI = new BaseItemMisc("4000DC's", new short[]{180,100,30}, 1, MiscTypes.BIGKEY, new String[]{"It opens things."}); - tI = new BaseItemMisc("Dull", new short[]{64,64,64}, 64, MiscTypes.GEM, null); - tI = new BaseItemMisc("Forest", new short[]{130,164,96}, 64, MiscTypes.MUSHROOM, new String[]{"You Found this on the ground.", "Definitely not sure if it's worth eating."}); - - //Baubles - if (LoadedMods.Baubles){ - tI = new HealthBoostBauble(); - itemModularBauble = new ModularBauble(); - } - - //EnderIO Resources - if ((LoadedMods.EnderIO || LOAD_ALL_CONTENT)){ - Logger.INFO("EnderIO Found - Loading Resources."); - //Enderio Dusts - itemDustSoularium = ItemUtils.generateSpecialUseDusts("Soularium", "Soularium", MaterialEIO.SOULARIUM.vChemicalFormula, MaterialEIO.SOULARIUM.getRgbAsHex())[0]; - itemDustRedstoneAlloy = ItemUtils.generateSpecialUseDusts("RedstoneAlloy", "Redstone Alloy", MaterialEIO.REDSTONE_ALLOY.vChemicalFormula, MaterialEIO.REDSTONE_ALLOY.getRgbAsHex())[0]; - itemDustElectricalSteel = ItemUtils.generateSpecialUseDusts("ElectricalSteel", "Electrical Steel", MaterialEIO.ELECTRICAL_STEEL.vChemicalFormula, MaterialEIO.ELECTRICAL_STEEL.getRgbAsHex())[0]; - itemDustPulsatingIron = ItemUtils.generateSpecialUseDusts("PulsatingIron", "Pulsating Iron", MaterialEIO.PULSATING_IRON.vChemicalFormula, MaterialEIO.PULSATING_IRON.getRgbAsHex())[0]; - itemDustEnergeticAlloy = ItemUtils.generateSpecialUseDusts("EnergeticAlloy", "Energetic Alloy", MaterialEIO.ENERGETIC_ALLOY.vChemicalFormula, MaterialEIO.ENERGETIC_ALLOY.getRgbAsHex())[0]; - itemDustVibrantAlloy = ItemUtils.generateSpecialUseDusts("VibrantAlloy", "Vibrant Alloy", MaterialEIO.VIBRANT_ALLOY.vChemicalFormula, MaterialEIO.VIBRANT_ALLOY.getRgbAsHex())[0]; - itemDustConductiveIron = ItemUtils.generateSpecialUseDusts("ConductiveIron", "Conductive Iron", MaterialEIO.CONDUCTIVE_IRON.vChemicalFormula, MaterialEIO.CONDUCTIVE_IRON.getRgbAsHex())[0]; - - //EnderIO Plates - itemPlateSoularium = ItemUtils.generateSpecialUsePlate("Soularium", "Soularium", MaterialEIO.SOULARIUM.vChemicalFormula, MaterialEIO.SOULARIUM.getRgbAsHex(), 0); - itemPlateRedstoneAlloy = ItemUtils.generateSpecialUsePlate("RedstoneAlloy", "Redstone Alloy", MaterialEIO.REDSTONE_ALLOY.vChemicalFormula, MaterialEIO.REDSTONE_ALLOY.getRgbAsHex(), 0); - itemPlateElectricalSteel = ItemUtils.generateSpecialUsePlate("ElectricalSteel", "Electrical Steel", MaterialEIO.ELECTRICAL_STEEL.vChemicalFormula, MaterialEIO.ELECTRICAL_STEEL.getRgbAsHex(), 0); - itemPlatePulsatingIron = ItemUtils.generateSpecialUsePlate("PhasedIron", "Phased Iron", MaterialEIO.PULSATING_IRON.vChemicalFormula, MaterialEIO.PULSATING_IRON.getRgbAsHex(), 0); - itemPlateEnergeticAlloy = ItemUtils.generateSpecialUsePlate("EnergeticAlloy", "Energetic Alloy", MaterialEIO.ENERGETIC_ALLOY.vChemicalFormula, MaterialEIO.ENERGETIC_ALLOY.getRgbAsHex(), 0); - itemPlateVibrantAlloy = ItemUtils.generateSpecialUsePlate("VibrantAlloy", "Vibrant Alloy", MaterialEIO.VIBRANT_ALLOY.vChemicalFormula, MaterialEIO.VIBRANT_ALLOY.getRgbAsHex(), 0); - itemPlateConductiveIron = ItemUtils.generateSpecialUsePlate("ConductiveIron", "Conductive Iron", MaterialEIO.CONDUCTIVE_IRON.vChemicalFormula, MaterialEIO.CONDUCTIVE_IRON.getRgbAsHex(), 0); - - //Register dumb naming conventions - Who chose fucking phased Iron/Gold? - GT_OreDictUnificator.registerOre("dustPhasedGold", ItemUtils.getSimpleStack(itemDustVibrantAlloy)); - GT_OreDictUnificator.registerOre("platePhasedGold", ItemUtils.getSimpleStack(itemPlateVibrantAlloy)); - GT_OreDictUnificator.registerOre("dustPhasedIron", ItemUtils.getSimpleStack(itemDustPulsatingIron)); - GT_OreDictUnificator.registerOre("platePhasedIron", ItemUtils.getSimpleStack(itemPlatePulsatingIron)); - GT_OreDictUnificator.registerOre("blockVibrantAlloy", ItemUtils.getItemStackOfAmountFromOreDict("blockPhasedGold", 1)); - - CORE.RA.addFluidExtractionRecipe(MaterialEIO.REDSTONE_ALLOY.getPlate(1), MaterialEIO.REDSTONE_ALLOY.getFluidStack(144), 16, 4*9); - CORE.RA.addFluidExtractionRecipe(MaterialEIO.REDSTONE_ALLOY.getIngot(1), MaterialEIO.REDSTONE_ALLOY.getFluidStack(144), 16, 4*9); - CORE.RA.addFluidExtractionRecipe(MaterialEIO.REDSTONE_ALLOY.getNugget(1), MaterialEIO.REDSTONE_ALLOY.getFluidStack(16), 16, 4); - CORE.RA.addFluidExtractionRecipe(MaterialEIO.REDSTONE_ALLOY.getBlock(1), MaterialEIO.REDSTONE_ALLOY.getFluidStack(1294), 16, 4*9*9); - - } - else { - /*Logger.WARNING("EnderIO not Found - Generating our own Resources."); - MaterialGenerator.generate(MaterialEIO.CONDUCTIVE_IRON); - MaterialGenerator.generate(MaterialEIO.PULSATING_IRON); - MaterialGenerator.generate(MaterialEIO.REDSTONE_ALLOY); - MaterialGenerator.generate(MaterialEIO.SOULARIUM); - MaterialGenerator.generate(MaterialEIO.ELECTRICAL_STEEL); - MaterialGenerator.generate(MaterialEIO.ENERGETIC_ALLOY); - MaterialGenerator.generate(MaterialEIO.VIBRANT_ALLOY); */ - } - - //Big Reactors - if (LoadedMods.Big_Reactors|| LOAD_ALL_CONTENT){ - Logger.INFO("BigReactors Found - Loading Resources."); - //Item Init - itemPlateBlutonium = ItemUtils.generateSpecialUsePlate("Blutonium", "Blutonium", new short[]{0, 0, 255}, 0); - itemPlateCyanite = ItemUtils.generateSpecialUsePlate("Cyanite", "Cyanite", new short[]{0, 191, 255}, 0); - itemPlateLudicrite = ItemUtils.generateSpecialUsePlate("Ludicrite", "Ludicrite", new short[]{167, 5, 179}, 0); - } - else { - Logger.WARNING("BigReactors not Found - Skipping Resources."); - } - - //Thaumcraft - if ((LoadedMods.Thaumcraft|| LOAD_ALL_CONTENT) && !CORE.GTNH){ - Logger.INFO("Thaumcraft Found - Loading Resources."); - //Item Init - try { - ItemUtils.getItemForOreDict("Thaumcraft:ItemResource", "ingotVoidMetal", "Void Metal Ingot", 16); - itemPlateVoidMetal = ItemUtils.generateSpecialUsePlate("Void", "Void", new short[]{82, 17, 82}, 0); - GT_OreDictUnificator.registerOre("plateVoidMetal", new ItemStack(ModItems.itemPlateVoidMetal)); - } catch (final NullPointerException e){} - - } - else { - Logger.WARNING("Thaumcraft not Found - Skipping Resources."); - } - - //Pneumaticraft - if (LoadedMods.PneumaticCraft|| LOAD_ALL_CONTENT){ - Logger.INFO("PneumaticCraft Found - Loading Resources."); - //Item Init - itemPlateCompressedIron = ItemUtils.generateSpecialUsePlate("CompressedIron", "Compressed Iron", new short[]{128, 128, 128}, 0); - } - else { - Logger.WARNING("PneumaticCraft not Found - Skipping Resources."); - } - - //Simply Jetpacks - if (LoadedMods.Simply_Jetpacks|| LOAD_ALL_CONTENT){ - Logger.INFO("SimplyJetpacks Found - Loading Resources."); - //Item Init - itemPlateEnrichedSoularium = new RarityUncommon().setUnlocalizedName("itemPlateEnrichedSoularium").setCreativeTab(AddToCreativeTab.tabMisc).setTextureName(CORE.MODID + ":itemPlateSoularium"); - //Registry - GameRegistry.registerItem(itemPlateEnrichedSoularium, "itemPlateEnrichedSoularium"); - } - else { - Logger.WARNING("SimplyJetpacks not Found - Skipping Resources."); - } - - //rfTools - if (LoadedMods.RFTools|| LOAD_ALL_CONTENT){ - Logger.INFO("rfTools Found - Loading Resources."); - //Item Init - itemPlateDimensionShard = ItemUtils.generateSpecialUsePlate("DimensionShard", "Dimensional Shard", new short[]{170, 230, 230}, 0); - } - else { - Logger.WARNING("rfTools not Found - Skipping Resources."); - } - - //IC2 Exp - if (LoadedMods.IndustrialCraft2|| LOAD_ALL_CONTENT){ - Logger.INFO("IndustrialCraft2 Found - Loading Resources."); - - //Baubles Mod Test - try { - final Class baublesTest = ReflectionUtils.getClass("baubles.api.IBauble"); - if (baublesTest != null){ - COMPAT_Baubles.run(); - } - else { - Logger.INFO("Baubles Not Found - Skipping Resources."); - } - } catch(final Throwable T){ - Logger.INFO("Baubles Not Found - Skipping Resources."); - } - } - else { - Logger.WARNING("IndustrialCraft2 not Found - Skipping Resources."); - } - - - //Special Item Handling Case - if (ConfigSwitches.enableAlternativeBatteryAlloy) { - //ModItems.itemIngotBatteryAlloy = new BaseItemIngot("itemIngotBatteryAlloy", "Battery Alloy", new short[]{35, 228, 141}, 0); TODO - ModItems.itemPlateBatteryAlloy = ItemUtils.generateSpecialUsePlate("BatteryAlloy", "Battery Alloy", new short[]{35, 228, 141}, 0); - - } - - - //UtilsItems.generateSpawnEgg("ic2", "boatcarbon", Utils.generateSingularRandomHexValue(), Utils.generateSingularRandomHexValue()); - - HANDLER_COFH.initItems(); - - /* - * Misc Items - */ - - //Staballoy Equipment - itemStaballoyPickaxe = new StaballoyPickaxe("itemStaballoyPickaxe", STABALLOY).setCreativeTab(AddToCreativeTab.tabTools); - GameRegistry.registerItem(itemStaballoyPickaxe, itemStaballoyPickaxe.getUnlocalizedName()); - itemStaballoyAxe = new StaballoyAxe("itemStaballoyAxe", STABALLOY).setCreativeTab(AddToCreativeTab.tabTools); - GameRegistry.registerItem(itemStaballoyAxe, itemStaballoyAxe.getUnlocalizedName()); - - //Sandstone Hammer - itemSandstoneHammer = new SandstoneHammer("itemSandstoneHammer").setCreativeTab(AddToCreativeTab.tabTools); - GameRegistry.registerItem(itemSandstoneHammer, itemSandstoneHammer.getUnlocalizedName()); - - //Buffer Cores! - Item itemBufferCore; - for(int i=1; i<=10; i++){ - //Utils.LOG_INFO(""+i); - itemBufferCore = new BufferCore("itemBufferCore", i).setCreativeTab(AddToCreativeTab.tabMachines); - GameRegistry.registerItem(itemBufferCore, itemBufferCore.getUnlocalizedName()); - //System.out.println("Buffer Core registration count is: "+i); - } - - itemPLACEHOLDER_Circuit = new Item().setUnlocalizedName("itemPLACEHOLDER_Circuit").setTextureName(CORE.MODID + ":itemPLACEHOLDER_Circuit"); - GameRegistry.registerItem(itemPLACEHOLDER_Circuit, "itemPLACEHOLDER_Circuit"); - - //ItemBlockGtFrameBox = new ItemBlockGtFrameBox(ModBlocks.blockGtFrameSet1); - //GameRegistry.registerItem(ItemBlockGtFrameBox, "itemGtFrameBoxSet1"); - - itemCustomBook = new ItemBaseBook(); - registerCustomTokens(); - } - - public static void registerCustomTokens() { - itemGenericToken.register(0, "BitCoin", 16, "Can be used on the dark web"); - itemGenericToken.register(1, "Hand Pump Trade Token I", 1, "Craft into a Tier I Hand pump"); - itemGenericToken.register(2, "Hand Pump Trade Token II", 1, "Craft into a Tier II Hand pump"); - itemGenericToken.register(3, "Hand Pump Trade Token III", 1, "Craft into a Tier III Hand pump"); - itemGenericToken.register(4, "Hand Pump Trade Token IV", 1, "Craft into a Tier IV Hand pump"); - } - - public static void registerCustomMaterialComponents() { - //Custom GT++ Crafting Components - - /** - * Try generate dusts for missing rare earth materials if they don't exist - */ - - if (!ItemUtils.checkForInvalidItems(ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustGadolinium", 1))){ - ItemUtils.generateSpecialUseDusts("Gadolinium", "Gadolinium", Materials.Gadolinium.mElement.name(), Utils.rgbtoHexValue(226, 172, 9)); - } - if (!ItemUtils.checkForInvalidItems(ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustYtterbium", 1))){ - ItemUtils.generateSpecialUseDusts("Ytterbium", "Ytterbium", Materials.Ytterbium.mElement.name(), Utils.rgbtoHexValue(Materials.Yttrium.mRGBa[0]-60, Materials.Yttrium.mRGBa[1]-60, Materials.Yttrium.mRGBa[2]-60)); - } - if (!ItemUtils.checkForInvalidItems(ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustSamarium", 1))){ - ItemUtils.generateSpecialUseDusts("Samarium", "Samarium", Materials.Samarium.mElement.name(), Utils.rgbtoHexValue(161, 168, 114)); - } - if (!ItemUtils.checkForInvalidItems(ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustLanthanum", 1))){ - ItemUtils.generateSpecialUseDusts("Lanthanum", "Lanthanum", Materials.Lanthanum.mElement.name(), Utils.rgbtoHexValue(106, 127, 163)); - } - if (!ItemUtils.checkForInvalidItems(ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustGermanium", 1))){ - ItemUtils.generateSpecialUseDusts("Germanium", "Germanium", "Ge", ELEMENT.getInstance().GERMANIUM.getRgbAsHex()); - } - - //Just an unusual plate needed for some black magic. - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateClay", 1) == null){ - itemPlateClay = new BaseItemPlate(NONMATERIAL.CLAY); - } - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateDoubleClay", 1) == null){ - itemDoublePlateClay = new BaseItemPlateDouble(NONMATERIAL.CLAY); - } - - //Need this for Mutagenic Frames - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("foilUranium235", 1) == null){ - itemFoilUranium235 = new BaseItemFoil(ELEMENT.getInstance().URANIUM235); - } - - //A small gear needed for wizardry. - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("gearGtSmallWroughtIron", 1) == null){ - itemSmallWroughtIronGear = new BaseItemSmallGear(NONMATERIAL.WROUGHT_IRON); - } - //Krypton Processing - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("ingotHotTitanium", 1) == null){ - itemHotTitaniumIngot = ItemUtils.getSimpleStack(new BaseItemIngot(ELEMENT.getInstance().TITANIUM, ComponentTypes.HOTINGOT)); - } - else { - itemHotTitaniumIngot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("ingotHotTitanium", 1); - } - - //Need this for Laurenium - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustIndium", 1) == null){ - itemDustIndium = new BaseItemDust(ELEMENT.getInstance().INDIUM); - } - - //Springs - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SPRING, ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SPRING, ELEMENT.STANDALONE.WHITE_METAL); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SPRING, ALLOY.NITINOL_60); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SPRING, ALLOY.AQUATIC_STEEL); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SPRING, ALLOY.EGLIN_STEEL); - - //Small Springs - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SMALLSPRING, ALLOY.MARAGING250); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SMALLSPRING, ALLOY.NICHROME); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SMALLSPRING, ALLOY.STABALLOY); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SMALLSPRING, ALLOY.STEEL_BLACK); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SMALLSPRING, ALLOY.BLACK_TITANIUM); - - //Fine Wire - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ELEMENT.STANDALONE.WHITE_METAL); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ELEMENT.getInstance().PALLADIUM); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ELEMENT.getInstance().ZIRCONIUM); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ALLOY.LEAGRISIUM); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ALLOY.BABBIT_ALLOY); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ALLOY.KOBOLDITE); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ALLOY.HG1223); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ALLOY.QUANTUM); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ELEMENT.STANDALONE.HYPOGEN); - - //Foil - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.BLACK_TITANIUM); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.BOTMIUM); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.TITANSTEEL); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.NITINOL_60); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.QUANTUM); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.LAURENIUM); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ELEMENT.STANDALONE.HYPOGEN); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ELEMENT.STANDALONE.ASTRAL_TITANIUM); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ELEMENT.STANDALONE.RHUGNOR); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ELEMENT.STANDALONE.WHITE_METAL); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ELEMENT.STANDALONE.ADVANCED_NITINOL); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.PIKYONIUM); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.CINOBITE); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.LAFIUM); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.TRINIUM_REINFORCED_STEEL); - - //Dense Plates - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.POTIN); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.AQUATIC_STEEL); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.BRONZE); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.OSMIRIDIUM); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.QUANTUM); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.STEEL_BLACK); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.STAINLESS_STEEL); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.EGLIN_STEEL); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.MARAGING300); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.TALONITE); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ELEMENT.STANDALONE.HYPOGEN); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ELEMENT.STANDALONE.RHUGNOR); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ELEMENT.STANDALONE.ADVANCED_NITINOL); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ELEMENT.STANDALONE.ASTRAL_TITANIUM); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ELEMENT.STANDALONE.WHITE_METAL); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ELEMENT.STANDALONE.BLACK_METAL); - MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ELEMENT.STANDALONE.GRANITE); - - - - - //Special Sillyness - if (true) { - - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateSodium", 1) == null){ - new BaseItemPlate(ELEMENT.getInstance().SODIUM); - } - - Material meatRaw = NONMATERIAL.MEAT; - // A plate of Meat. - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateMeatRaw", 1) == null){ - itemPlateRawMeat = new BaseItemPlate(meatRaw); - ItemUtils.registerFuel(ItemUtils.getSimpleStack(itemPlateRawMeat), 100); - } - // A Block of Meat. - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("blockMeatRaw", 1) == null){ - blockRawMeat = new BlockBaseModular(meatRaw, BlockTypes.STANDARD); - ItemUtils.registerFuel(ItemUtils.getSimpleStack(blockRawMeat), 900); - } - } - - - // A plate of Vanadium. - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateVanadium", 1) == null){ - itemPlateVanadium = new BaseItemPlate(ELEMENT.getInstance().VANADIUM); - } - - //A plate of Lithium. - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateLithium", 1) == null){ - itemPlateLithium = new BaseItemPlate(ELEMENT.getInstance().LITHIUM); - } - - //A plate of Europium. - if ((ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateEuropium", 1) == null) && CORE.ConfigSwitches.enableCustom_Pipes){ - itemPlateEuropium = new BaseItemPlate(ELEMENT.getInstance().EUROPIUM); - } - if ((ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateDoubleEuropium", 1) == null) && CORE.ConfigSwitches.enableCustom_Pipes){ - itemDoublePlateEuropium = new BaseItemPlateDouble(ELEMENT.getInstance().EUROPIUM); - } - - //Tumbaga Mix (For Simple Crafting) - dustTumbagaMix = ItemUtils.generateSpecialUseDusts("MixTumbaga", "Tumbaga Mix", "Au2Cu", Utils.rgbtoHexValue(255, 150, 80))[0]; - - } + public static ItemGenericToken itemGenericToken; + + public static Item itemControlCore; + + public static Item itemSunnariumBit; + + public static ItemStack itemHotTitaniumIngot; + + public static Fluid fluidZrF4; + public static Fluid fluidFertBasic; + public static Fluid fluidFertUN32; + public static Fluid fluidFertUN18; + + public static Item boxTools; + public static Item boxFood; + public static Item boxMagic; + + public static DustDecayable dustMolybdenum99; + public static DustDecayable dustTechnetium99; + public static DustDecayable dustTechnetium99M; + + public static IonParticles itemIonParticleBase; + public static StandardBaseParticles itemStandarParticleBase; + + public static BatteryPackBaseBauble itemChargePack_Low_1; + public static BatteryPackBaseBauble itemChargePack_Low_2; + public static BatteryPackBaseBauble itemChargePack_Low_3; + public static BatteryPackBaseBauble itemChargePack_Low_4; + public static BatteryPackBaseBauble itemChargePack_Low_5; + public static BatteryPackBaseBauble itemChargePack_High_1; + public static BatteryPackBaseBauble itemChargePack_High_2; + public static BatteryPackBaseBauble itemChargePack_High_3; + public static BatteryPackBaseBauble itemChargePack_High_4; + + public static DebugScanner itemDebugScanner; + + public static ItemDummyResearch itemDummyResearch; + + public static CoreItem itemBombCasing; + public static CoreItem itemBombUnf; + public static CoreItem itemDetCable; + public static ItemThrowableBomb itemBomb; + + public static MonsterKillerBaseBauble itemAmuletMonsterKiller_Zombie; + public static MonsterKillerBaseBauble itemAmuletMonsterKiller_Skeleton; + public static MonsterKillerBaseBauble itemAmuletMonsterKiller_Spider; + public static MonsterKillerBaseBauble itemAmuletMonsterKiller_Creeper; + public static MonsterKillerBaseBauble itemAmuletMonsterKiller_Enderman; + + public static MonsterKillerBaseBauble itemAmuletMonsterKiller_Nether; + public static MonsterKillerBaseBauble itemAmuletMonsterKiller_Infernal; + + public static CoreItem itemExquisiteIndustrialDiamond; + + public static BaseItemMetaFood itemMetaFood; + + public static ItemMagicFeather itemMagicFeather; + + static { + Logger.INFO("Items!"); + // Default item used when recipes fail, handy for debugging. Let's make sure they exist when this class is + // called upon. + AAA_Broken = + new BaseItemIngot_OLD("AAA_Broken", "Errors - Tell Alkalus", Utils.rgbtoHexValue(128, 128, 128), 0); + ZZZ_Empty = new ItemEmpty(); + } + + public static final void init() { + + itemDebugScanner = new DebugScanner(); + itemMagicFeather = new ItemMagicFeather(); + + itemAlkalusDisk = new BaseItemDamageable( + "itemAlkalusDisk", + AddToCreativeTab.tabMisc, + 1, + 0, + "Unknown Use", + EnumRarity.rare, + EnumChatFormatting.AQUA, + false, + null); + itemBigEgg = new ItemGiantEgg(); + itemGenericToken = new ItemGenericToken(); + itemDummyResearch = new ItemDummyResearch(); + itemCustomSpawnEgg = new ItemCustomSpawnEgg(); + + // Debug Loading + if (CORE_Preloader.DEBUG_MODE) { + DEBUG_INIT.registerItems(); + } + + itemDebugAreaClear = new ItemAreaClear(); + + // Register meta item, because we need them for everything. + MetaGeneratedGregtechItems.INSTANCE.generateMetaItems(); + + // Some Simple forms of materials + itemStickyRubber = new Item() + .setUnlocalizedName("itemStickyRubber") + .setCreativeTab(tabMachines) + .setTextureName(CORE.MODID + ":itemStickyRubber"); + GameRegistry.registerItem(itemStickyRubber, "itemStickyRubber"); + GT_OreDictUnificator.registerOre( + "ingotRubber", ItemUtils.getItemStackFromFQRN(CORE.MODID + ":itemStickyRubber", 1)); + + // Register Hydrogen Blobs first, so we can replace old helium blobs. + itemHydrogenBlob = new CoreItem("itemHydrogenBlob", "Mysterious Hydrogen Blob", tabMisc) + .setTextureName(CORE.MODID + ":itemHeliumBlob"); + // Register Old Helium Blob, this will be replaced when held by a player. + itemHeliumBlob = new CoreItem("itemHeliumBlob", tabMisc, ItemUtils.getSimpleStack(itemHydrogenBlob)) + .setTextureName(CORE.MODID + ":itemHydrogenBlob"); + + // Register this neato device, for making some fires. + itemBasicFireMaker = new ItemBasicFirestarter(); + + // Register Rope + itemFiber = new CoreItem("itemFiber", "Plant Fiber", tabMisc); + itemRope = new CoreItem("itemRope", "Rope", tabMisc); + + // Load Wearable Items + WearableLoader.run(); + + // Make some backpacks + // Primary colours + backpack_Red = new BaseItemBackpack("backpackRed", Utils.rgbtoHexValue(200, 0, 0)); + backpack_Green = new BaseItemBackpack("backpackGreen", Utils.rgbtoHexValue(0, 200, 0)); + backpack_Blue = new BaseItemBackpack("backpackBlue", Utils.rgbtoHexValue(0, 0, 200)); + // Secondary Colours + backpack_Yellow = new BaseItemBackpack("backpackYellow", Utils.rgbtoHexValue(200, 200, 0)); + backpack_Purple = new BaseItemBackpack("backpackPurple", Utils.rgbtoHexValue(200, 0, 200)); + backpack_Cyan = new BaseItemBackpack("backpackCyan", Utils.rgbtoHexValue(0, 200, 200)); + // Tertiary Colours + backpack_Maroon = new BaseItemBackpack("backpackMaroon", Utils.rgbtoHexValue(128, 0, 0)); + backpack_Olive = new BaseItemBackpack("backpackOlive", Utils.rgbtoHexValue(128, 128, 0)); + backpack_DarkGreen = new BaseItemBackpack("backpackDarkGreen", Utils.rgbtoHexValue(0, 128, 0)); + backpack_DarkPurple = new BaseItemBackpack("backpackDarkPurple", Utils.rgbtoHexValue(128, 0, 128)); + backpack_Teal = new BaseItemBackpack("backpackTeal", Utils.rgbtoHexValue(0, 128, 128)); + backpack_Navy = new BaseItemBackpack("backpackNavy", Utils.rgbtoHexValue(0, 0, 128)); + // Shades + backpack_Silver = new BaseItemBackpack("backpackSilver", Utils.rgbtoHexValue(192, 192, 192)); + backpack_Gray = new BaseItemBackpack("backpackGray", Utils.rgbtoHexValue(128, 128, 128)); + backpack_Black = new BaseItemBackpack("backpackBlack", Utils.rgbtoHexValue(20, 20, 20)); + backpack_White = new BaseItemBackpack("backpackWhite", Utils.rgbtoHexValue(240, 240, 240)); + + // Load Custom Box/bags + boxTools = new UniversalToolBox("Tool Box"); + boxFood = new AutoLunchBox("Eatotron-9000"); + boxMagic = new MagicToolBag("Mystic Bag"); + + itemBlueprintBase = new ItemBlueprint("itemBlueprint"); + + itemGemShards = new ItemGemShards( + "itemGemShards", + "Gem Shards", + AddToCreativeTab.tabMisc, + 32, + 0, + "They glitter in the light", + EnumRarity.rare, + EnumChatFormatting.GRAY, + false, + Utils.rgbtoHexValue(182, 114, 18)) + .setTextureName(CORE.MODID + ":itemHeliumBlob"); + itemHalfCompleteCasings = new ItemHalfCompleteCasings( + "itemHalfCompleteCasings", + AddToCreativeTab.tabMisc, + 32, + 0, + "This isn't quite finished yet.", + EnumRarity.common, + EnumChatFormatting.GRAY, + false, + Utils.rgbtoHexValue(255, 255, 255)) + .setTextureName("gregtech" + ":" + "gt.metaitem.01/" + "761"); + itemSulfuricPotion = new ItemSulfuricAcidPotion( + "itemSulfuricPotion", "Throwable Vial of Sulfuric Acid", "Burn your foes alive!") + .setTextureName(CORE.MODID + ":itemSulfuricAcidPotion"); + itemHydrofluoricPotion = new ItemHydrofluoricAcidPotion( + "itemHydrofluoricPotion", + "Throwable Vial of Hydrofluoric Acid", + "They won't see this coming, nor anything after!") + .setTextureName(CORE.MODID + ":itemPotion"); + // Start meta Item Generation + ItemsFoods.load(); + + try { + + registerCustomMaterialComponents(); + + // Elements generate first so they can be used in compounds. + // Missing Elements + MaterialGenerator.generate(ELEMENT.getInstance().SELENIUM); // LFTR byproduct + MaterialGenerator.generate(ELEMENT.getInstance().BROMINE); + MaterialGenerator.generate(ELEMENT.getInstance().KRYPTON); // LFTR byproduct + MaterialGenerator.generate(ELEMENT.getInstance().STRONTIUM); + MaterialGenerator.generate(ELEMENT.getInstance().ZIRCONIUM); + MaterialGenerator.generate(ELEMENT.getInstance().RUTHENIUM); + MaterialGenerator.generate(ELEMENT.getInstance().IODINE); // LFTR byproduct + MaterialGenerator.generate(ELEMENT.getInstance().HAFNIUM); + MaterialGenerator.generate(ELEMENT.getInstance().DYSPROSIUM); + MaterialGenerator.generate(ELEMENT.getInstance().ERBIUM); + MaterialGenerator.generate(ELEMENT.getInstance().PRASEODYMIUM); + MaterialGenerator.generate(ELEMENT.getInstance().TELLURIUM); // LFTR byproduct + MaterialGenerator.generate(ELEMENT.getInstance().RHODIUM); + MaterialGenerator.generate(ELEMENT.getInstance().RHENIUM); + MaterialGenerator.generate(ELEMENT.getInstance().THALLIUM); + + // RADIOACTIVE ELEMENTS + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().TECHNETIUM, false); // LFTR byproduct + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().POLONIUM, false); + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().ASTATINE, false); + // MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().RADON, false); + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().FRANCIUM, false); + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().RADIUM, false); + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().PROMETHIUM, false); + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().ACTINIUM, false); + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().PROTACTINIUM, false); + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().NEPTUNIUM, false); // LFTR byproduct + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().CURIUM, false); + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().BERKELIUM, false); + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().CALIFORNIUM, false); + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().EINSTEINIUM, false); + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().FERMIUM, false); + + // Nuclear Isotopes + + // Lithium-7 is used as a part of the molten lithium fluoride in molten salt reactors: liquid-fluoride + // nuclear reactors. + // The large neutron-absorption cross-section of lithium-6 (about 940 barns[5]) as compared with the very + // small + // neutron cross-section of lithium-7 (about 45 millibarns) makes high separation of lithium-7 from natural + // lithium a + // strong requirement for the possible use in lithium fluoride reactors. + MaterialGenerator.generate(ELEMENT.getInstance().LITHIUM7, false); + // Thorium-232 is the most stable isotope of Thorium, purified for nuclear fuel use in this case. + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().THORIUM232); + // Production of 233U (through the neutron irradiation of 232Th) invariably produces small amounts of 232U + // as an impurity + // because of parasitic (n,2n) reactions on uranium-233 itself, or on protactinium-233, or on thorium-232: + MaterialGenerator.generate(ELEMENT.getInstance().URANIUM232); + // Uranium-233 is a fissile isotope of uranium that is bred from thorium-232 as part of the thorium fuel + // cycle. + MaterialGenerator.generate(ELEMENT.getInstance().URANIUM233); + // Plutonium-238 is a very powerful alpha emitter. This makes the plutonium-238 isotope suitable for usage + // in radioisotope thermoelectric generators (RTGs) + // and radioisotope heater units - one gram of plutonium-238 generates approximately 0.5 W of thermal power. + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().PLUTONIUM238, false); + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustPlutonium239", 1) == null + || Utils.getGregtechVersionAsInt() < 50931) { + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().PLUTONIUM239, false); + } + + // RTG Fuel Materials + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().STRONTIUM90, false); + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().POLONIUM210, false); + MaterialGenerator.generateNuclearMaterial(ELEMENT.getInstance().AMERICIUM241, false); + + if (!CORE.GTNH) { + MaterialGenerator.generateOreMaterialWithAllExcessComponents(ELEMENT.getInstance().TRINIUM); + } + + // Custom Materials that will have standalone refinery processes + MaterialGenerator.generate(ELEMENT.STANDALONE.ADVANCED_NITINOL, false); + MaterialGenerator.generate(ELEMENT.STANDALONE.ASTRAL_TITANIUM); + MaterialGenerator.generate(ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN); + MaterialGenerator.generate(ELEMENT.STANDALONE.HYPOGEN); + MaterialGenerator.generate(ELEMENT.STANDALONE.CHRONOMATIC_GLASS); + MaterialGenerator.generate(ELEMENT.STANDALONE.FORCE); + + // Custom Materials that are from Runescape + MaterialGenerator.generate(ELEMENT.STANDALONE.BLACK_METAL); + MaterialGenerator.generate(ELEMENT.STANDALONE.WHITE_METAL); + MaterialGenerator.generateOreMaterialWithAllExcessComponents(ELEMENT.STANDALONE.GRANITE); + MaterialGenerator.generateOreMaterialWithAllExcessComponents(ELEMENT.STANDALONE.RUNITE); + MaterialGenerator.generate(ELEMENT.STANDALONE.DRAGON_METAL, false); + + MISC_MATERIALS.run(); + + // Carbides - Tungsten Carbide exists in .09 so don't generate it. - Should still come before alloys though + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + MaterialGenerator.generate(ALLOY.TUNGSTEN_CARBIDE); + } + MaterialGenerator.generate(ALLOY.SILICON_CARBIDE); + MaterialGenerator.generate(ALLOY.ZIRCONIUM_CARBIDE); + MaterialGenerator.generate(ALLOY.TANTALUM_CARBIDE); + MaterialGenerator.generate(ALLOY.NIOBIUM_CARBIDE); + MaterialGenerator.generate(ALLOY.TUNGSTEN_TITANIUM_CARBIDE); + + // LFTR Fuel components + // MaterialGenerator.generate(MISC_MATERIALS.HYDROXIDE); //LFTR fuel component + // MaterialGenerator.generate(MISC_MATERIALS.AMMONIA); //LFTR fuel component + // MaterialGenerator.generate(MISC_MATERIALS.AMMONIUM); //LFTR fuel component + MaterialGenerator.generateNuclearDusts(FLUORIDES.AMMONIUM_BIFLUORIDE); // LFTR fuel component + MaterialGenerator.generateNuclearDusts(FLUORIDES.BERYLLIUM_HYDROXIDE); // LFTR fuel component + MaterialGenerator.generateNuclearDusts(FLUORIDES.AMMONIUM_TETRAFLUOROBERYLLATE); // LFTR fuel component + + // Generate Fluorides + MaterialGenerator.generateNuclearDusts(FLUORIDES.BERYLLIUM_FLUORIDE); + MaterialGenerator.generateNuclearDusts(FLUORIDES.LITHIUM_FLUORIDE); + MaterialGenerator.generateNuclearDusts(FLUORIDES.THORIUM_TETRAFLUORIDE); + MaterialGenerator.generateNuclearDusts(FLUORIDES.THORIUM_HEXAFLUORIDE); + MaterialGenerator.generateNuclearDusts(FLUORIDES.URANIUM_TETRAFLUORIDE, false); + MaterialGenerator.generateNuclearDusts(FLUORIDES.URANIUM_HEXAFLUORIDE, false); + MaterialGenerator.generateNuclearDusts(FLUORIDES.ZIRCONIUM_TETRAFLUORIDE); + // LFTR Fluoride outputs + MaterialGenerator.generateNuclearDusts(FLUORIDES.NEPTUNIUM_HEXAFLUORIDE); + MaterialGenerator.generateNuclearDusts(FLUORIDES.TECHNETIUM_HEXAFLUORIDE); + MaterialGenerator.generateNuclearDusts(FLUORIDES.SELENIUM_HEXAFLUORIDE); + + // Generate Reactor Fuel Salts + MaterialGenerator.generateNuclearDusts(NUCLIDE.LiFBeF2ZrF4U235); + MaterialGenerator.generateNuclearDusts(NUCLIDE.LiFBeF2ZrF4UF4); + MaterialGenerator.generateNuclearDusts(NUCLIDE.LiFBeF2ThF4UF4); + // MaterialGenerator.generateNuclearMaterial(NUCLIDE.Li2BeF4, false); + + // Generate some Alloys + + // Misc Alloys + MaterialGenerator.generate(ALLOY.ENERGYCRYSTAL); + MaterialGenerator.generate(ALLOY.BLOODSTEEL); + + MaterialGenerator.generate(ALLOY.ZERON_100); + // Tumbaga was the name given by Spaniards to a non-specific alloy of gold and copper + MaterialGenerator.generate(ALLOY.TUMBAGA); + // Potin is traditionally an alloy of bronze, tin and lead, with varying quantities of each possible + MaterialGenerator.generate(ALLOY.POTIN); + + // Staballoy & Tantalloy + MaterialGenerator.generate(ALLOY.STABALLOY); + MaterialGenerator.generate(ALLOY.TANTALLOY_60); + MaterialGenerator.generate(ALLOY.TANTALLOY_61); + + // Inconel + MaterialGenerator.generate(ALLOY.INCONEL_625); + MaterialGenerator.generate(ALLOY.INCONEL_690); + MaterialGenerator.generate(ALLOY.INCONEL_792); + + // Steels + MaterialGenerator.generateDusts(ALLOY.EGLIN_STEEL_BASE); + MaterialGenerator.generate(ALLOY.EGLIN_STEEL); + MaterialGenerator.generate(ALLOY.MARAGING250); + MaterialGenerator.generate(ALLOY.MARAGING300); + MaterialGenerator.generate(ALLOY.MARAGING350); + MaterialGenerator.generate(ALLOY.AQUATIC_STEEL); + + MaterialGenerator.generate(ALLOY.NITINOL_60, true, false); + + // Composite Alloys + MaterialGenerator.generate(ALLOY.STELLITE); + MaterialGenerator.generate(ALLOY.TALONITE); + + // Hastelloy + MaterialGenerator.generate(ALLOY.HASTELLOY_W); + MaterialGenerator.generate(ALLOY.HASTELLOY_X); + MaterialGenerator.generate(ALLOY.HASTELLOY_C276); + MaterialGenerator.generate(ALLOY.HASTELLOY_N); + + // Incoloy + MaterialGenerator.generate(ALLOY.INCOLOY_020); + MaterialGenerator.generate(ALLOY.INCOLOY_DS); + MaterialGenerator.generate(ALLOY.INCOLOY_MA956); + + // Leagrisium + MaterialGenerator.generate(ALLOY.LEAGRISIUM); + + // Super Conductor + MaterialGenerator.generate(ALLOY.HG1223, false, false); + + // Generate Fictional Materials + if (!CORE.GTNH) { + MaterialGenerator.generate(ELEMENT.getInstance().TRINIUM, false); + MaterialGenerator.generate(ELEMENT.getInstance().TRINIUM_REFINED, false); + } + MaterialGenerator.generate(ALLOY.TRINIUM_TITANIUM); + MaterialGenerator.generate(ALLOY.TRINIUM_NAQUADAH, false); + MaterialGenerator.generate(ALLOY.TRINIUM_NAQUADAH_CARBON); + MaterialGenerator.generate(ALLOY.TRINIUM_REINFORCED_STEEL); + + // Top Tier Alloys + MaterialGenerator.generate(ALLOY.HELICOPTER); + MaterialGenerator.generate(ALLOY.LAFIUM); + MaterialGenerator.generate(ALLOY.CINOBITE); + MaterialGenerator.generate(ALLOY.PIKYONIUM); + MaterialGenerator.generate(ALLOY.ABYSSAL); + MaterialGenerator.generate(ALLOY.LAURENIUM); + MaterialGenerator.generate(ALLOY.BOTMIUM); + MaterialGenerator.generate(ALLOY.HS188A); + + MaterialGenerator.generate(ALLOY.TITANSTEEL); + MaterialGenerator.generate(ALLOY.ARCANITE); + MaterialGenerator.generate(ALLOY.OCTIRON); + + MaterialGenerator.generate(ALLOY.BABBIT_ALLOY, false); + MaterialGenerator.generate(ALLOY.BLACK_TITANIUM, false); + MaterialGenerator.generate(ALLOY.INDALLOY_140, false, false); + + // High Level Bioplastic + MaterialGenerator.generate(ELEMENT.STANDALONE.RHUGNOR, false, false); + + // Must be the final Alloy to Generate + MaterialGenerator.generate(ALLOY.QUANTUM); + + // Ores + MaterialGenerator.generateOreMaterial(FLUORIDES.FLUORITE); + MaterialGenerator.generateOreMaterial(ALLOY.KOBOLDITE); + GTplusplus_Everglades.GenerateOreMaterials(); + + // formula override + ALLOY.TUNGSTEN_TITANIUM_CARBIDE.vChemicalFormula = StringUtils.subscript("(CW)7Ti3"); + ALLOY.TITANSTEEL.vChemicalFormula = StringUtils.subscript("((CW)7Ti3)3???"); + + // Werkstoff bridge + ELEMENT.getInstance().ZIRCONIUM.setWerkstoffID((short) 3); + ELEMENT.getInstance().THORIUM232.setWerkstoffID((short) 30); + ELEMENT.getInstance().RUTHENIUM.setWerkstoffID((short) 64); + ELEMENT.getInstance().HAFNIUM.setWerkstoffID((short) 11000); + ELEMENT.getInstance().IODINE.setWerkstoffID((short) 11012); + + } catch (final Throwable r) { + Logger.INFO("Failed to Generated a Material. " + r.getMessage()); + // Utils.LOG_INFO("Failed to Generated a Material. "+r.getCause().getMessage()); + // Utils.LOG_INFO("Failed to Generated a Material. "+r.getStackTrace()[0].getMethodName()); + // Utils.LOG_INFO("Failed to Generated a Material. "+r.getStackTrace()[1].getMethodName()); + r.printStackTrace(); + // System.exit(1); + } + + // TC Style Shards, for use in making energy crystal mix. + // A dull shard, able to be infused with an element. + shardDull = new BaseItemTCShard( + "Drained", + Utils.rgbtoHexValue(75, 75, 75), + "Can be infused to create a magical shard.", + "Obtained from Mining Stone/SandStone, Chopping Logs or Shovelling Dirt."); + + // Generates four elemental shards when TC is not installed. + if (!LoadedMods.Thaumcraft) { + shardAer = new BaseItemTCShard("Aer", Utils.rgbtoHexValue(225, 225, 5)); + shardIgnis = new BaseItemTCShard("Ignis", Utils.rgbtoHexValue(255, 5, 5)); + shardTerra = new BaseItemTCShard("Terra", Utils.rgbtoHexValue(5, 255, 5)); + shardAqua = new BaseItemTCShard("Aqua", Utils.rgbtoHexValue(5, 5, 255)); + } else { + shardAer = ItemUtils.getItemStackWithMeta(LoadedMods.Thaumcraft, "Thaumcraft:ItemShard", "Air Shard", 0, 1) + .getItem(); + shardIgnis = ItemUtils.getItemStackWithMeta( + LoadedMods.Thaumcraft, "Thaumcraft:ItemShard", "Fire Shard", 1, 1) + .getItem(); + shardAqua = ItemUtils.getItemStackWithMeta( + LoadedMods.Thaumcraft, "Thaumcraft:ItemShard", "Warer Shard", 2, 1) + .getItem(); + shardTerra = ItemUtils.getItemStackWithMeta( + LoadedMods.Thaumcraft, "Thaumcraft:ItemShard", "Earth Shard", 3, 1) + .getItem(); + } + // Generates a set of four special dusts to be used in my recipes. + dustAer = ItemUtils.generateSpecialUseDusts(ELEMENT.getInstance().AER, true)[0]; + dustIgnis = ItemUtils.generateSpecialUseDusts(ELEMENT.getInstance().IGNIS, true)[0]; + dustTerra = ItemUtils.generateSpecialUseDusts(ELEMENT.getInstance().TERRA, true)[0]; + dustAqua = ItemUtils.generateSpecialUseDusts(ELEMENT.getInstance().AQUA, true)[0]; + + ItemUtils.generateSpecialUseDusts(MISC_MATERIALS.WOODS_GLASS, false); + cellHydrogenChlorideMix = new BaseItemCell( + "hydrogenchloridemix", "Hydrogen Chloride Mix", MISC_MATERIALS.HYDROGEN_CHLORIDE.getRGB()); + + // Nuclear Fuel Dusts + dustLithiumCarbonate = ItemUtils.generateSpecialUseDusts( + "LithiumCarbonate", "Lithium Carbonate", "Li2CO3", Utils.rgbtoHexValue(240, 240, 240))[ + 0]; // https://en.wikipedia.org/wiki/Lithium_carbonate + dustLithiumPeroxide = ItemUtils.generateSpecialUseDusts( + "LithiumPeroxide", "Lithium Peroxide", "Li2O2", Utils.rgbtoHexValue(250, 250, 250))[ + 0]; // https://en.wikipedia.org/wiki/Lithium_peroxide + dustLithiumHydroxide = ItemUtils.generateSpecialUseDusts( + "LithiumHydroxide", "Lithium Hydroxide", "LiOH", Utils.rgbtoHexValue(250, 250, 250))[ + 0]; // https://en.wikipedia.org/wiki/Lithium_hydroxide + + if (!ItemUtils.checkForInvalidItems(ItemUtils.getItemStackOfAmountFromOreDict("dustQuicklime", 1)) + && !LoadedMods.IHL) { + dustQuicklime = ItemUtils.generateSpecialUseDusts( + "Quicklime", "Quicklime", "CaO", Utils.rgbtoHexValue(255, 255, 175))[ + 0]; // https://en.wikipedia.org/wiki/Calcium_oxide + } + dustCalciumHydroxide = ItemUtils.generateSpecialUseDusts( + "CalciumHydroxide", "Hydrated Lime", "Ca(OH)2", Utils.rgbtoHexValue(255, 255, 255))[ + 0]; // https://en.wikipedia.org/wiki/Calcium_hydroxide + dustCalciumCarbonate = ItemUtils.generateSpecialUseDusts( + "CalciumCarbonate", "Calcium Carbonate", "CaCO3", Utils.rgbtoHexValue(255, 255, 255))[ + 0]; // https://en.wikipedia.org/wiki/Calcium_carbonate + if ((ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustGypsum", 1) == null) + || (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustCalciumSulfate", 1) == null)) { + dustCalciumSulfate = ItemUtils.generateSpecialUseDusts( + "Gypsum", "Calcium Sulfate (Gypsum)", "CaSO4", Utils.rgbtoHexValue(255, 255, 255))[ + 0]; // https://en.wikipedia.org/wiki/Calcium_sulfate + GT_OreDictUnificator.registerOre("dustCalciumSulfate", ItemUtils.getSimpleStack(dustCalciumSulfate)); + } else { + GT_OreDictUnificator.registerOre( + "dustCalciumSulfate", ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustGypsum", 1)); + } + dustLi2CO3CaOH2 = ItemUtils.generateSpecialUseDusts( + "Li2CO3CaOH2", "Li2CO3 + Ca(OH)2 Compound", "Li2CO3CaOH2", Utils.rgbtoHexValue(255, 255, 255))[ + 0]; // https://en.wikipedia.org/wiki/Calcium_carbonate + MaterialUtils.generateSpecialDustAndAssignToAMaterial(FLUORIDES.SODIUM_FLUORIDE, false); + // FLiBe Fuel Compounds + dustLi2BeF4 = ItemUtils.generateSpecialUseDusts( + "Li2BeF4", "Lithium Tetrafluoroberyllate Fuel Compound", "Li2BeF4", Utils.rgbtoHexValue(255, 255, 255))[ + 0]; // https://en.wikipedia.org/wiki/FLiBe + Material.registerComponentForMaterial(NUCLIDE.Li2BeF4, OrePrefixes.dust, ItemUtils.getSimpleStack(dustLi2BeF4)); + // fluidFLiBeSalt = ("Li2BeF4", "Li2BeF4", 7430, new short[]{255, 255, 255, 100}, 0); + // fluidFLiBeSalt = FluidUtils.addGTFluidNoPrefix("Li2BeF4", "Lithium Tetrafluoroberyllate", new short[]{255, + // 255, 255, 100}, 0, 743, null, CI.emptyCells(1), 1000, true); + // fluidFLiBeSaltBurnt = FluidUtils.addGTFluidNoPrefix("Li2BeF2UF4", "Li2BeF2UF4", new short[]{50, 255, 50, + // 100}, 0, 743, null, CI.emptyCells(1), 1000, true); + + // LFTR Core Fluid Processing + // fluidLftrCore1 = FluidUtils.addGTFluidNoPrefix("LiBeF2UF4FP", "LiBeF2UF4FP", new short[]{110, 255, 110, 100}, + // 0, 800, null, CI.emptyCells(1), 1000, true); + // fluidLftrCore2 = FluidUtils.addGTFluidNoPrefix("UF6F2FP", "UF6F2FP", new short[]{150, 255, 150, 100}, 0, 800, + // null, CI.emptyCells(1), 1000, true); + // fluidLftrCore3 = FluidUtils.addGTFluidNoPrefix("LiFBeF2", "LiFBeF2", new short[]{100, 255, 50, 100}, 0, 800, + // null, CI.emptyCells(1), 1000, true); + // fluidLftrCore4 = FluidUtils.addGTFluidNoPrefix("LiFBeF2UF4", "LiFBeF2UF4", new short[]{50, 255, 100, 100}, 0, + // 800, null, CI.emptyCells(1), 1000, true); + // LFTR Blanket Fluid Processing + // fluidLftrBlanket1 = FluidUtils.addGTFluidNoPrefix("LiFThF4", "LiFThF4", new short[]{50, 150, 255, 50}, 0, + // 500, null, CI.emptyCells(1), 1000, true); + // fluidLftrBlanket2 = FluidUtils.addGTFluidNoPrefix("LiFBeF2ThF4", "LiFBeF2ThF4", new short[]{100, 150, 100, + // 100}, 0, 500, null, CI.emptyCells(1), 1000, true); + // fluidLftrBlanket3 = FluidUtils.addGTFluidNoPrefix("UF6F2", "UF6F2", new short[]{10, 150, 10, 100}, 0, 500, + // null, CI.emptyCells(1), 1000, true); + fluidNuclearWaste = FluidUtils.addGTFluidNoPrefix( + "nuclear.waste", + "Nuclear Waste", + new short[] {10, 250, 10, 100}, + 0, + 1000, + null, + CI.emptyCells(1), + 1000, + true); + + // LFTR Control Circuit + itemCircuitLFTR = new CoreItem( + "itemCircuitLFTR", + "" + EnumChatFormatting.GREEN + "Control Circuit", + AddToCreativeTab.tabMisc, + 1, + 0, + new String[] {"Keeps Multiblocks Stable"}, + EnumRarity.epic, + EnumChatFormatting.DARK_GREEN, + false, + null); + + if (CORE.ConfigSwitches.enableMachine_Pollution) { + itemBasicTurbine = new ItemBasicScrubberTurbine(); + } + + // Zirconium + // Cinter Pellet. + itemZirconiumChlorideCinterPellet = new CoreItem( + "itemZirconiumPellet", "Zirconium Pellet [" + StringUtils.subscript("ZrCl4") + "]", tabMisc) + .setTextureName(CORE.MODID + ":itemShard"); + GT_OreDictUnificator.registerOre("pelletZirconium", new ItemStack(itemZirconiumChlorideCinterPellet)); + // Zirconium Chloride + dustZrCl4 = ItemUtils.generateSpecialUseDusts("ZrCl4", "ZrCl4", "ZrCl4", Utils.rgbtoHexValue(180, 180, 180))[ + 0]; // http://www.iaea.org/inis/collection/NCLCollectionStore/_Public/39/036/39036750.pdf + dustCookedZrCl4 = ItemUtils.generateSpecialUseDusts( + "CookedZrCl4", "Cooked ZrCl4", "ZrCl4", Utils.rgbtoHexValue(180, 180, 180))[ + 0]; // http://www.iaea.org/inis/collection/NCLCollectionStore/_Public/39/036/39036750.pdf + + // Zirconium Tetrafluoride + /*GT_OreDictUnificator.registerOre("cellZrF4", ItemUtils.getItemStackOfAmountFromOreDict("cellZirconiumTetrafluoride", 1)); + GT_OreDictUnificator.registerOre("dustZrF4", ItemUtils.getItemStackOfAmountFromOreDict("dustZirconiumTetrafluoride", 1));*/ + // GT_OreDictUnificator.registerOre("cellZrF4", + // ItemUtils.getItemStackOfAmountFromOreDict("cellZirconiumTetrafluoride", 1)); + // GT_OreDictUnificator.registerOre("dustZrF4", + // ItemUtils.getItemStackOfAmountFromOreDict("dustZirconiumTetrafluoride", 1)); + fluidZrF4 = FluidUtils.generateFluidNoPrefix( + "ZirconiumTetrafluoride", "Zirconium Tetrafluoride", 500, new short[] {170, 170, 140, 100 + }); // https://en.wikipedia.org/wiki/Zirconium_tetrafluoride + FLUORIDES.ZIRCONIUM_TETRAFLUORIDE.setFluid(fluidZrF4); + + // Coolant Salt + // NaBF4 - NaF - 621C + // dustNaBF4NaF = ItemUtils.generateSpecialUseDusts("NaBF4NaF", "NaBF4NaF", Utils.rgbtoHexValue(45, 45, 90))[0]; + // //https://en.wikipedia.org/wiki/Zirconium_tetrafluoride + + // Load Tree Farmer + if (CORE.ConfigSwitches.enableMultiblock_TreeFarmer) { // https://en.wikipedia.org/wiki/UAN + dustFertUN18 = ItemUtils.generateSpecialUseDusts( + "UN18Fertiliser", "UN-18 Fertiliser", Utils.rgbtoHexValue(60, 155, 60))[0]; + dustFertUN32 = ItemUtils.generateSpecialUseDusts( + "UN32Fertiliser", "UN-32 Fertiliser", Utils.rgbtoHexValue(55, 190, 55))[0]; + + ItemStack temp1 = null; + ItemStack temp2 = null; + + if (LoadedMods.IndustrialCraft2) { + temp1 = ItemUtils.getCorrectStacktype("IC2:itemFertilizer", 1); + } + if (LoadedMods.Forestry) { + temp2 = ItemUtils.getCorrectStacktype("Forestry:fertilizerCompound", 1); + } + if (temp1 != null) { + fluidFertBasic = FluidUtils.generateFluidNonMolten( + "Fertiliser", "Fertiliser", 32, new short[] {45, 170, 45, 100}, temp1, null, true); + GT_Values.RA.addFluidExtractionRecipe(temp2, null, new FluidStack(fluidFertBasic, 36), 10000, 5, 16); + } + fluidFertUN32 = FluidUtils.generateFluidNonMolten( + "UN32Fertiliser", "UN-32 Fertiliser", 24, new short[] {55, 190, 55, 100}, null, null, true); + fluidFertUN18 = FluidUtils.generateFluidNonMolten( + "UN18Fertiliser", "UN-18 Fertiliser", 22, new short[] {60, 155, 60, 100}, null, null, true); + + /*GT_Values.RA.addMixerRecipe( + arg0, //Item In + arg1, + arg2, + arg3, + arg4, //Fluid in + arg5, //Fluid Out + arg6, //Item out + arg7, //Eu + arg8); //Time + */ + + } + + // Juice + FluidUtils.generateFluidNonMolten( + "RaisinJuice", + "Raisin Juice", + 2, + new short[] {51, 0, 51, 100}, + ItemUtils.getItemStackOfAmountFromOreDictNoBroken("foodRaisins", 1), + ItemUtils.getItemStackOfAmountFromOreDictNoBroken("fruitRaisins", 1), + 50, + true); + + // Test items + metaItem2 = new BaseEuItem(); + metaItem2.registerItem(0, EnumChatFormatting.BLACK + "Test Item 0", 0, 0, "I am 0."); + metaItem2.registerItem(1, EnumChatFormatting.GREEN + "Test Item 1", 1006346000, 1, "I Hold EU 1.", 500); + metaItem2.registerItem(2, EnumChatFormatting.GOLD + "Test Item 2", 1004630000, 2, "I Hold EU 2.", 8000); + metaItem2.registerItem(3, "Test Item 3", 1000765000, 4, "I Hold EU 3.", 32000); + metaItem2.registerItem( + 4, + "Whirlygig", + 1043644000, + (short) 5, + "Spin me right round.", + EnumRarity.rare, + EnumChatFormatting.DARK_GREEN, + true); + metaItem2.registerItem( + 5, + "Whirlygig 2", + 2124867000, + (short) 7, + "Spin me right round.", + EnumRarity.uncommon, + EnumChatFormatting.RED, + true); + + toolGregtechPump = new GregtechPump(); + toolGregtechPump.registerPumpType(0, "Simple Hand Pump", 0, 0); + toolGregtechPump.registerPumpType(1, "Advanced Hand Pump", 32000, 1); + toolGregtechPump.registerPumpType(2, "Super Hand Pump", 128000, 2); + toolGregtechPump.registerPumpType(3, "Ultimate Hand Pump", 512000, 3); + + // Create Multi-tools + // ItemsMultiTools.load(); + + // Xp Fluids - Dev + if (!FluidRegistry.isFluidRegistered("mobessence")) { + FluidUtils.generateFluidNoPrefix("mobessence", "mobessence", 0, new short[] {125, 175, 125, 100}); + } + if (!FluidRegistry.isFluidRegistered("xpjuice")) { + FluidUtils.generateFluidNoPrefix("xpjuice", "xpjuice", 0, new short[] {50, 150, 50, 100}); + } + + // Industrial Diamonds + itemExquisiteIndustrialDiamond = + new CoreItem("IndustrialDiamondExquisite", "High Quality Industrial Diamond", tabMisc); + ItemStack tempStack = itemExquisiteIndustrialDiamond.getStack(); + ItemUtils.addItemToOreDictionary(tempStack, "gemDiamond"); + ItemUtils.addItemToOreDictionary(tempStack, "craftingIndustrialDiamond"); + ItemUtils.addItemToOreDictionary(tempStack, "gemExquisiteDiamond"); + ItemUtils.addItemToOreDictionary(tempStack, "craftingExquisiteIndustrialDiamond"); + + /* + * Decayable Materials + */ + + dustNeptunium238 = new DustDecayable( + "dustNeptunium238", + Utils.rgbtoHexValue(175, 240, 75), + 50640, + new String[] { + "" + StringUtils.superscript("238Np"), + "Result: Plutonium 238 (" + StringUtils.superscript("238Pu") + ")" + }, + ELEMENT.getInstance().PLUTONIUM238.getDust(1).getItem(), + 5); + dustDecayedRadium226 = ItemUtils.generateSpecialUseDusts( + "DecayedRadium226", + "Decayed Radium-226", + "Contains Radon (" + StringUtils.superscript("222Rn") + ")", + ELEMENT.getInstance().RADIUM.getRgbAsHex())[0]; + dustRadium226 = new DustDecayable( + "dustRadium226", + ELEMENT.getInstance().RADIUM.getRgbAsHex(), + 90000, + new String[] { + "" + StringUtils.superscript("226Ra"), "Result: Radon (" + StringUtils.superscript("222Rn") + ")" + }, + ItemUtils.getSimpleStack(dustDecayedRadium226).getItem(), + 5); + dustProtactinium233 = new DustDecayable( + "dustProtactinium233", + ELEMENT.getInstance().PROTACTINIUM.getRgbAsHex(), + 32000, + new String[] { + "" + StringUtils.superscript("233Pa"), + "Result: Uranium 233(" + StringUtils.superscript("233U") + ")" + }, + ELEMENT.getInstance().URANIUM233.getDust(1).getItem(), + 6); + dustTechnetium99 = new DustDecayable( + "dustTechnetium99", + ELEMENT.getInstance().TECHNETIUM.getRgbAsHex(), + 164500, + new String[] { + "" + StringUtils.superscript("99Mo"), + "Result: Ruthenium 99(" + StringUtils.superscript("99Ru") + ")" + }, + ELEMENT.getInstance().RUTHENIUM.getDust(1).getItem(), + 4); + dustTechnetium99M = new DustDecayable( + "dustTechnetium99M", + ELEMENT.getInstance().TECHNETIUM.getRgbAsHex(), + 8570, + new String[] { + "" + StringUtils.superscript("99ᵐTc"), + "Result: Technicium 99 (" + StringUtils.superscript("99Tc") + ")" + }, + dustTechnetium99, + 4); + dustMolybdenum99 = new DustDecayable( + "dustMolybdenum99", + ELEMENT.getInstance().MOLYBDENUM.getRgbAsHex(), + 16450, + new String[] { + "" + StringUtils.superscript("99Mo"), + "Result: Technicium 99ᵐ (" + StringUtils.superscript("99ᵐTc") + ")" + }, + dustTechnetium99M, + 4); + + itemIonParticleBase = new IonParticles(); + itemStandarParticleBase = new StandardBaseParticles(); + + if (Meta_GT_Proxy.sDoesVolumetricFlaskExist) { + Item a8kFlask = + VolumetricFlaskHelper.generateNewFlask("Volumetric_Flask_8k", "Large Volumetric Flask", 8000); + Item a64kFlask = + VolumetricFlaskHelper.generateNewFlask("Volumetric_Flask_32k", "Gigantic Volumetric Flask", 32000); + GregtechItemList.VOLUMETRIC_FLASK_8k.set(a8kFlask); + GregtechItemList.VOLUMETRIC_FLASK_32k.set(a64kFlask); + } + + itemBoilerChassis = new ItemBoilerChassis(); + itemDehydratorCoilWire = new ItemDehydratorCoilWire(); + itemDehydratorCoil = new ItemDehydratorCoil(); + + itemAirFilter = new ItemAirFilter(); + itemLavaFilter = new ItemLavaFilter(); + + itemGrindleTablet = new BaseItemGrindle(); + itemDragonJar = new ItemEntityCatcher(); + + itemControlCore = new ItemControlCore(); + + itemSunnariumBit = new ItemSunnariumBit(); + + // Chemistry + new CoalTar(); + new RocketFuels(); + + // Nuclear Processing + new NuclearChem(); + + // Farm Animal Fun + new AgriculturalChem(); + + // General Chemistry + new GenericChem(); + + // Milled Ore Processing + new MilledOreProcessing(); + + // Bombs + itemBombCasing = new CoreItem("itemBombCasing", "Bomb Casing", tabMisc); + itemBombCasing.setTextureName(CORE.MODID + ":bomb_casing"); + itemBombUnf = new CoreItem("itemBombUnf", "Bomb (unf)", tabMisc); + itemBombUnf.setTextureName(CORE.MODID + ":bomb_casing"); + itemDetCable = new CoreItem("itemDetCable", "Det. Cable", tabMisc); + itemDetCable.setTextureName("string"); + itemBomb = new ItemThrowableBomb(); + + // Only used for debugging. + /*if (CORE.DEVENV) { + new ConnectedBlockFinder(); + }*/ + + // Misc Items + @SuppressWarnings("unused") + Item tI; + tI = new BaseItemMisc("Chilly", new short[] {0, 64, 196}, 32, MiscTypes.POTION, new String[] {"It's Blue"}); + tI = new BaseItemMisc( + "4000DC's", new short[] {180, 100, 30}, 1, MiscTypes.BIGKEY, new String[] {"It opens things."}); + tI = new BaseItemMisc("Dull", new short[] {64, 64, 64}, 64, MiscTypes.GEM, null); + tI = new BaseItemMisc("Forest", new short[] {130, 164, 96}, 64, MiscTypes.MUSHROOM, new String[] { + "You Found this on the ground.", "Definitely not sure if it's worth eating." + }); + + // Baubles + if (LoadedMods.Baubles) { + tI = new HealthBoostBauble(); + itemModularBauble = new ModularBauble(); + } + + // EnderIO Resources + if ((LoadedMods.EnderIO || LOAD_ALL_CONTENT)) { + Logger.INFO("EnderIO Found - Loading Resources."); + // Enderio Dusts + itemDustSoularium = ItemUtils.generateSpecialUseDusts( + "Soularium", + "Soularium", + MaterialEIO.SOULARIUM.vChemicalFormula, + MaterialEIO.SOULARIUM.getRgbAsHex())[0]; + itemDustRedstoneAlloy = ItemUtils.generateSpecialUseDusts( + "RedstoneAlloy", + "Redstone Alloy", + MaterialEIO.REDSTONE_ALLOY.vChemicalFormula, + MaterialEIO.REDSTONE_ALLOY.getRgbAsHex())[0]; + itemDustElectricalSteel = ItemUtils.generateSpecialUseDusts( + "ElectricalSteel", + "Electrical Steel", + MaterialEIO.ELECTRICAL_STEEL.vChemicalFormula, + MaterialEIO.ELECTRICAL_STEEL.getRgbAsHex())[0]; + itemDustPulsatingIron = ItemUtils.generateSpecialUseDusts( + "PulsatingIron", + "Pulsating Iron", + MaterialEIO.PULSATING_IRON.vChemicalFormula, + MaterialEIO.PULSATING_IRON.getRgbAsHex())[0]; + itemDustEnergeticAlloy = ItemUtils.generateSpecialUseDusts( + "EnergeticAlloy", + "Energetic Alloy", + MaterialEIO.ENERGETIC_ALLOY.vChemicalFormula, + MaterialEIO.ENERGETIC_ALLOY.getRgbAsHex())[0]; + itemDustVibrantAlloy = ItemUtils.generateSpecialUseDusts( + "VibrantAlloy", + "Vibrant Alloy", + MaterialEIO.VIBRANT_ALLOY.vChemicalFormula, + MaterialEIO.VIBRANT_ALLOY.getRgbAsHex())[0]; + itemDustConductiveIron = ItemUtils.generateSpecialUseDusts( + "ConductiveIron", + "Conductive Iron", + MaterialEIO.CONDUCTIVE_IRON.vChemicalFormula, + MaterialEIO.CONDUCTIVE_IRON.getRgbAsHex())[0]; + + // EnderIO Plates + itemPlateSoularium = ItemUtils.generateSpecialUsePlate( + "Soularium", + "Soularium", + MaterialEIO.SOULARIUM.vChemicalFormula, + MaterialEIO.SOULARIUM.getRgbAsHex(), + 0); + itemPlateRedstoneAlloy = ItemUtils.generateSpecialUsePlate( + "RedstoneAlloy", + "Redstone Alloy", + MaterialEIO.REDSTONE_ALLOY.vChemicalFormula, + MaterialEIO.REDSTONE_ALLOY.getRgbAsHex(), + 0); + itemPlateElectricalSteel = ItemUtils.generateSpecialUsePlate( + "ElectricalSteel", + "Electrical Steel", + MaterialEIO.ELECTRICAL_STEEL.vChemicalFormula, + MaterialEIO.ELECTRICAL_STEEL.getRgbAsHex(), + 0); + itemPlatePulsatingIron = ItemUtils.generateSpecialUsePlate( + "PhasedIron", + "Phased Iron", + MaterialEIO.PULSATING_IRON.vChemicalFormula, + MaterialEIO.PULSATING_IRON.getRgbAsHex(), + 0); + itemPlateEnergeticAlloy = ItemUtils.generateSpecialUsePlate( + "EnergeticAlloy", + "Energetic Alloy", + MaterialEIO.ENERGETIC_ALLOY.vChemicalFormula, + MaterialEIO.ENERGETIC_ALLOY.getRgbAsHex(), + 0); + itemPlateVibrantAlloy = ItemUtils.generateSpecialUsePlate( + "VibrantAlloy", + "Vibrant Alloy", + MaterialEIO.VIBRANT_ALLOY.vChemicalFormula, + MaterialEIO.VIBRANT_ALLOY.getRgbAsHex(), + 0); + itemPlateConductiveIron = ItemUtils.generateSpecialUsePlate( + "ConductiveIron", + "Conductive Iron", + MaterialEIO.CONDUCTIVE_IRON.vChemicalFormula, + MaterialEIO.CONDUCTIVE_IRON.getRgbAsHex(), + 0); + + // Register dumb naming conventions - Who chose fucking phased Iron/Gold? + GT_OreDictUnificator.registerOre("dustPhasedGold", ItemUtils.getSimpleStack(itemDustVibrantAlloy)); + GT_OreDictUnificator.registerOre("platePhasedGold", ItemUtils.getSimpleStack(itemPlateVibrantAlloy)); + GT_OreDictUnificator.registerOre("dustPhasedIron", ItemUtils.getSimpleStack(itemDustPulsatingIron)); + GT_OreDictUnificator.registerOre("platePhasedIron", ItemUtils.getSimpleStack(itemPlatePulsatingIron)); + GT_OreDictUnificator.registerOre( + "blockVibrantAlloy", ItemUtils.getItemStackOfAmountFromOreDict("blockPhasedGold", 1)); + + CORE.RA.addFluidExtractionRecipe( + MaterialEIO.REDSTONE_ALLOY.getPlate(1), MaterialEIO.REDSTONE_ALLOY.getFluidStack(144), 16, 4 * 9); + CORE.RA.addFluidExtractionRecipe( + MaterialEIO.REDSTONE_ALLOY.getIngot(1), MaterialEIO.REDSTONE_ALLOY.getFluidStack(144), 16, 4 * 9); + CORE.RA.addFluidExtractionRecipe( + MaterialEIO.REDSTONE_ALLOY.getNugget(1), MaterialEIO.REDSTONE_ALLOY.getFluidStack(16), 16, 4); + CORE.RA.addFluidExtractionRecipe( + MaterialEIO.REDSTONE_ALLOY.getBlock(1), + MaterialEIO.REDSTONE_ALLOY.getFluidStack(1294), + 16, + 4 * 9 * 9); + + } else { + /*Logger.WARNING("EnderIO not Found - Generating our own Resources."); + MaterialGenerator.generate(MaterialEIO.CONDUCTIVE_IRON); + MaterialGenerator.generate(MaterialEIO.PULSATING_IRON); + MaterialGenerator.generate(MaterialEIO.REDSTONE_ALLOY); + MaterialGenerator.generate(MaterialEIO.SOULARIUM); + MaterialGenerator.generate(MaterialEIO.ELECTRICAL_STEEL); + MaterialGenerator.generate(MaterialEIO.ENERGETIC_ALLOY); + MaterialGenerator.generate(MaterialEIO.VIBRANT_ALLOY); */ + } + + // Big Reactors + if (LoadedMods.Big_Reactors || LOAD_ALL_CONTENT) { + Logger.INFO("BigReactors Found - Loading Resources."); + // Item Init + itemPlateBlutonium = + ItemUtils.generateSpecialUsePlate("Blutonium", "Blutonium", new short[] {0, 0, 255}, 0); + itemPlateCyanite = ItemUtils.generateSpecialUsePlate("Cyanite", "Cyanite", new short[] {0, 191, 255}, 0); + itemPlateLudicrite = + ItemUtils.generateSpecialUsePlate("Ludicrite", "Ludicrite", new short[] {167, 5, 179}, 0); + } else { + Logger.WARNING("BigReactors not Found - Skipping Resources."); + } + + // Thaumcraft + if ((LoadedMods.Thaumcraft || LOAD_ALL_CONTENT) && !CORE.GTNH) { + Logger.INFO("Thaumcraft Found - Loading Resources."); + // Item Init + try { + ItemUtils.getItemForOreDict("Thaumcraft:ItemResource", "ingotVoidMetal", "Void Metal Ingot", 16); + itemPlateVoidMetal = ItemUtils.generateSpecialUsePlate("Void", "Void", new short[] {82, 17, 82}, 0); + GT_OreDictUnificator.registerOre("plateVoidMetal", new ItemStack(ModItems.itemPlateVoidMetal)); + } catch (final NullPointerException e) { + } + + } else { + Logger.WARNING("Thaumcraft not Found - Skipping Resources."); + } + + // Pneumaticraft + if (LoadedMods.PneumaticCraft || LOAD_ALL_CONTENT) { + Logger.INFO("PneumaticCraft Found - Loading Resources."); + // Item Init + itemPlateCompressedIron = ItemUtils.generateSpecialUsePlate( + "CompressedIron", "Compressed Iron", new short[] {128, 128, 128}, 0); + } else { + Logger.WARNING("PneumaticCraft not Found - Skipping Resources."); + } + + // Simply Jetpacks + if (LoadedMods.Simply_Jetpacks || LOAD_ALL_CONTENT) { + Logger.INFO("SimplyJetpacks Found - Loading Resources."); + // Item Init + itemPlateEnrichedSoularium = new RarityUncommon() + .setUnlocalizedName("itemPlateEnrichedSoularium") + .setCreativeTab(AddToCreativeTab.tabMisc) + .setTextureName(CORE.MODID + ":itemPlateSoularium"); + // Registry + GameRegistry.registerItem(itemPlateEnrichedSoularium, "itemPlateEnrichedSoularium"); + } else { + Logger.WARNING("SimplyJetpacks not Found - Skipping Resources."); + } + + // rfTools + if (LoadedMods.RFTools || LOAD_ALL_CONTENT) { + Logger.INFO("rfTools Found - Loading Resources."); + // Item Init + itemPlateDimensionShard = ItemUtils.generateSpecialUsePlate( + "DimensionShard", "Dimensional Shard", new short[] {170, 230, 230}, 0); + } else { + Logger.WARNING("rfTools not Found - Skipping Resources."); + } + + // IC2 Exp + if (LoadedMods.IndustrialCraft2 || LOAD_ALL_CONTENT) { + Logger.INFO("IndustrialCraft2 Found - Loading Resources."); + + // Baubles Mod Test + try { + final Class baublesTest = ReflectionUtils.getClass("baubles.api.IBauble"); + if (baublesTest != null) { + COMPAT_Baubles.run(); + } else { + Logger.INFO("Baubles Not Found - Skipping Resources."); + } + } catch (final Throwable T) { + Logger.INFO("Baubles Not Found - Skipping Resources."); + } + } else { + Logger.WARNING("IndustrialCraft2 not Found - Skipping Resources."); + } + + // Special Item Handling Case + if (ConfigSwitches.enableAlternativeBatteryAlloy) { + // ModItems.itemIngotBatteryAlloy = new BaseItemIngot("itemIngotBatteryAlloy", "Battery Alloy", new + // short[]{35, 228, 141}, 0); TODO + ModItems.itemPlateBatteryAlloy = + ItemUtils.generateSpecialUsePlate("BatteryAlloy", "Battery Alloy", new short[] {35, 228, 141}, 0); + } + + // UtilsItems.generateSpawnEgg("ic2", "boatcarbon", Utils.generateSingularRandomHexValue(), + // Utils.generateSingularRandomHexValue()); + + HANDLER_COFH.initItems(); + + /* + * Misc Items + */ + + // Staballoy Equipment + itemStaballoyPickaxe = + new StaballoyPickaxe("itemStaballoyPickaxe", STABALLOY).setCreativeTab(AddToCreativeTab.tabTools); + GameRegistry.registerItem(itemStaballoyPickaxe, itemStaballoyPickaxe.getUnlocalizedName()); + itemStaballoyAxe = new StaballoyAxe("itemStaballoyAxe", STABALLOY).setCreativeTab(AddToCreativeTab.tabTools); + GameRegistry.registerItem(itemStaballoyAxe, itemStaballoyAxe.getUnlocalizedName()); + + // Sandstone Hammer + itemSandstoneHammer = new SandstoneHammer("itemSandstoneHammer").setCreativeTab(AddToCreativeTab.tabTools); + GameRegistry.registerItem(itemSandstoneHammer, itemSandstoneHammer.getUnlocalizedName()); + + // Buffer Cores! + Item itemBufferCore; + for (int i = 1; i <= 10; i++) { + // Utils.LOG_INFO(""+i); + itemBufferCore = new BufferCore("itemBufferCore", i).setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerItem(itemBufferCore, itemBufferCore.getUnlocalizedName()); + // System.out.println("Buffer Core registration count is: "+i); + } + + itemPLACEHOLDER_Circuit = new Item() + .setUnlocalizedName("itemPLACEHOLDER_Circuit") + .setTextureName(CORE.MODID + ":itemPLACEHOLDER_Circuit"); + GameRegistry.registerItem(itemPLACEHOLDER_Circuit, "itemPLACEHOLDER_Circuit"); + + // ItemBlockGtFrameBox = new ItemBlockGtFrameBox(ModBlocks.blockGtFrameSet1); + // GameRegistry.registerItem(ItemBlockGtFrameBox, "itemGtFrameBoxSet1"); + + itemCustomBook = new ItemBaseBook(); + registerCustomTokens(); + } + + public static void registerCustomTokens() { + itemGenericToken.register(0, "BitCoin", 16, "Can be used on the dark web"); + itemGenericToken.register(1, "Hand Pump Trade Token I", 1, "Craft into a Tier I Hand pump"); + itemGenericToken.register(2, "Hand Pump Trade Token II", 1, "Craft into a Tier II Hand pump"); + itemGenericToken.register(3, "Hand Pump Trade Token III", 1, "Craft into a Tier III Hand pump"); + itemGenericToken.register(4, "Hand Pump Trade Token IV", 1, "Craft into a Tier IV Hand pump"); + } + + public static void registerCustomMaterialComponents() { + // Custom GT++ Crafting Components + + /** + * Try generate dusts for missing rare earth materials if they don't exist + */ + if (!ItemUtils.checkForInvalidItems(ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustGadolinium", 1))) { + ItemUtils.generateSpecialUseDusts( + "Gadolinium", "Gadolinium", Materials.Gadolinium.mElement.name(), Utils.rgbtoHexValue(226, 172, 9)); + } + if (!ItemUtils.checkForInvalidItems(ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustYtterbium", 1))) { + ItemUtils.generateSpecialUseDusts( + "Ytterbium", + "Ytterbium", + Materials.Ytterbium.mElement.name(), + Utils.rgbtoHexValue( + Materials.Yttrium.mRGBa[0] - 60, + Materials.Yttrium.mRGBa[1] - 60, + Materials.Yttrium.mRGBa[2] - 60)); + } + if (!ItemUtils.checkForInvalidItems(ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustSamarium", 1))) { + ItemUtils.generateSpecialUseDusts( + "Samarium", "Samarium", Materials.Samarium.mElement.name(), Utils.rgbtoHexValue(161, 168, 114)); + } + if (!ItemUtils.checkForInvalidItems(ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustLanthanum", 1))) { + ItemUtils.generateSpecialUseDusts( + "Lanthanum", "Lanthanum", Materials.Lanthanum.mElement.name(), Utils.rgbtoHexValue(106, 127, 163)); + } + if (!ItemUtils.checkForInvalidItems(ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustGermanium", 1))) { + ItemUtils.generateSpecialUseDusts( + "Germanium", + "Germanium", + "Ge", + ELEMENT.getInstance().GERMANIUM.getRgbAsHex()); + } + + // Just an unusual plate needed for some black magic. + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateClay", 1) == null) { + itemPlateClay = new BaseItemPlate(NONMATERIAL.CLAY); + } + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateDoubleClay", 1) == null) { + itemDoublePlateClay = new BaseItemPlateDouble(NONMATERIAL.CLAY); + } + + // Need this for Mutagenic Frames + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("foilUranium235", 1) == null) { + itemFoilUranium235 = new BaseItemFoil(ELEMENT.getInstance().URANIUM235); + } + + // A small gear needed for wizardry. + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("gearGtSmallWroughtIron", 1) == null) { + itemSmallWroughtIronGear = new BaseItemSmallGear(NONMATERIAL.WROUGHT_IRON); + } + // Krypton Processing + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("ingotHotTitanium", 1) == null) { + itemHotTitaniumIngot = ItemUtils.getSimpleStack( + new BaseItemIngot(ELEMENT.getInstance().TITANIUM, ComponentTypes.HOTINGOT)); + } else { + itemHotTitaniumIngot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("ingotHotTitanium", 1); + } + + // Need this for Laurenium + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustIndium", 1) == null) { + itemDustIndium = new BaseItemDust(ELEMENT.getInstance().INDIUM); + } + + // Springs + MaterialUtils.generateComponentAndAssignToAMaterial( + ComponentTypes.SPRING, ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SPRING, ELEMENT.STANDALONE.WHITE_METAL); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SPRING, ALLOY.NITINOL_60); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SPRING, ALLOY.AQUATIC_STEEL); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SPRING, ALLOY.EGLIN_STEEL); + + // Small Springs + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SMALLSPRING, ALLOY.MARAGING250); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SMALLSPRING, ALLOY.NICHROME); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SMALLSPRING, ALLOY.STABALLOY); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SMALLSPRING, ALLOY.STEEL_BLACK); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SMALLSPRING, ALLOY.BLACK_TITANIUM); + + // Fine Wire + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ELEMENT.STANDALONE.WHITE_METAL); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ELEMENT.getInstance().PALLADIUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ELEMENT.getInstance().ZIRCONIUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ALLOY.LEAGRISIUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ALLOY.BABBIT_ALLOY); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ALLOY.KOBOLDITE); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ALLOY.HG1223); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ALLOY.QUANTUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ELEMENT.STANDALONE.HYPOGEN); + + // Foil + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.BLACK_TITANIUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.BOTMIUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.TITANSTEEL); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.NITINOL_60); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.QUANTUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.LAURENIUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ELEMENT.STANDALONE.HYPOGEN); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ELEMENT.STANDALONE.ASTRAL_TITANIUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ELEMENT.STANDALONE.RHUGNOR); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ELEMENT.STANDALONE.WHITE_METAL); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ELEMENT.STANDALONE.ADVANCED_NITINOL); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.PIKYONIUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.CINOBITE); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.LAFIUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FOIL, ALLOY.TRINIUM_REINFORCED_STEEL); + + // Dense Plates + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.POTIN); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.AQUATIC_STEEL); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.BRONZE); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.OSMIRIDIUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.QUANTUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.STEEL_BLACK); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.STAINLESS_STEEL); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.EGLIN_STEEL); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.MARAGING300); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.TALONITE); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ELEMENT.STANDALONE.HYPOGEN); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ELEMENT.STANDALONE.RHUGNOR); + MaterialUtils.generateComponentAndAssignToAMaterial( + ComponentTypes.PLATEHEAVY, ELEMENT.STANDALONE.ADVANCED_NITINOL); + MaterialUtils.generateComponentAndAssignToAMaterial( + ComponentTypes.PLATEHEAVY, ELEMENT.STANDALONE.ASTRAL_TITANIUM); + MaterialUtils.generateComponentAndAssignToAMaterial( + ComponentTypes.PLATEHEAVY, ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ELEMENT.STANDALONE.WHITE_METAL); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ELEMENT.STANDALONE.BLACK_METAL); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ELEMENT.STANDALONE.GRANITE); + + // Special Sillyness + if (true) { + + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateSodium", 1) == null) { + new BaseItemPlate(ELEMENT.getInstance().SODIUM); + } + + Material meatRaw = NONMATERIAL.MEAT; + // A plate of Meat. + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateMeatRaw", 1) == null) { + itemPlateRawMeat = new BaseItemPlate(meatRaw); + ItemUtils.registerFuel(ItemUtils.getSimpleStack(itemPlateRawMeat), 100); + } + // A Block of Meat. + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("blockMeatRaw", 1) == null) { + blockRawMeat = new BlockBaseModular(meatRaw, BlockTypes.STANDARD); + ItemUtils.registerFuel(ItemUtils.getSimpleStack(blockRawMeat), 900); + } + } + + // A plate of Vanadium. + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateVanadium", 1) == null) { + itemPlateVanadium = new BaseItemPlate(ELEMENT.getInstance().VANADIUM); + } + + // A plate of Lithium. + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateLithium", 1) == null) { + itemPlateLithium = new BaseItemPlate(ELEMENT.getInstance().LITHIUM); + } + + // A plate of Europium. + if ((ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateEuropium", 1) == null) + && CORE.ConfigSwitches.enableCustom_Pipes) { + itemPlateEuropium = new BaseItemPlate(ELEMENT.getInstance().EUROPIUM); + } + if ((ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateDoubleEuropium", 1) == null) + && CORE.ConfigSwitches.enableCustom_Pipes) { + itemDoublePlateEuropium = new BaseItemPlateDouble(ELEMENT.getInstance().EUROPIUM); + } + + // Tumbaga Mix (For Simple Crafting) + dustTumbagaMix = ItemUtils.generateSpecialUseDusts( + "MixTumbaga", "Tumbaga Mix", "Au2Cu", Utils.rgbtoHexValue(255, 150, 80))[0]; + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/BaseEuItem.java b/src/main/java/gtPlusPlus/core/item/base/BaseEuItem.java index b4988136c0..a1bd29aa65 100644 --- a/src/main/java/gtPlusPlus/core/item/base/BaseEuItem.java +++ b/src/main/java/gtPlusPlus/core/item/base/BaseEuItem.java @@ -2,24 +2,9 @@ package gtPlusPlus.core.item.base; import static gregtech.api.enums.GT_Values.*; -import java.util.*; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.IIcon; - import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.enums.SubTag; @@ -28,555 +13,649 @@ import gregtech.api.interfaces.IItemBehaviour; import gregtech.api.interfaces.IItemContainer; import gregtech.api.objects.ItemData; import gregtech.api.util.*; - import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import ic2.api.item.*; +import java.util.*; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; public class BaseEuItem extends Item implements ISpecialElectricItem, IElectricItemManager { - /* ---------- CONSTRUCTOR AND MEMBER VARIABLES ---------- */ - private final HashMap>> mItemBehaviors = new HashMap<>(); - public final short mOffset, mItemAmount; - public final BitSet mEnabledItems; - public final BitSet mVisibleItems; - public final IIcon[][] mIconList; - /** The unlocalized name of this item. */ - private String unlocalizedName; - - private final ArrayList> rarity = new ArrayList<>(); - private final ArrayList> descColour = new ArrayList<>(); - private final ArrayList> itemName = new ArrayList<>(); - private final ArrayList> itemDescription = new ArrayList<>(); - private final ArrayList> hasEffect = new ArrayList<>(); - - public final HashMap mElectricStats = new HashMap<>(); - public final HashMap mBurnValues = new HashMap<>(); - - public BaseEuItem() { - this("MU-metaitem.02", AddToCreativeTab.tabOther, (short) 1000, (short) 31766); - } - - public BaseEuItem(final String unlocalizedName, final CreativeTabs creativeTab, final short aOffset, final short aItemAmount) { - this.mEnabledItems = new BitSet(aItemAmount); - this.mVisibleItems = new BitSet(aItemAmount); - this.mOffset = (short) Math.min(32766, aOffset); - this.mItemAmount = (short) Math.min(aItemAmount, 32766 - this.mOffset); - this.mIconList = new IIcon[aItemAmount][1]; - this.setHasSubtypes(true); - this.setMaxDamage(0); - this.setUnlocalizedName(unlocalizedName); - this.setCreativeTab(creativeTab); - this.setMaxStackSize(1); - GameRegistry.registerItem(this, unlocalizedName); - } - - - public void registerItem(final int id, final String localizedName, final long euStorage, final int tier, final String description) { - this.registerItem(id, localizedName, euStorage, (short) tier, description, EnumRarity.common, EnumChatFormatting.GRAY, false); - } - - public void registerItem(final int id, final String localizedName, final long euStorage, final int tier, final String description, final int burnTime) { - this.registerItem(id, localizedName, euStorage, (short) tier, description, EnumRarity.common, EnumChatFormatting.GRAY, false); - this.setBurnValue(id, burnTime); - } - - - public void registerItem(final int id, final String localizedName, final long euStorage, final short tier, final String description, final EnumRarity regRarity, final EnumChatFormatting colour, final boolean Effect) { - this.addItem(id, localizedName, EnumChatFormatting.YELLOW+"Electric", new Object[]{}); - this.setElectricStats(this.mOffset + id, euStorage, GT_Values.V[tier], tier, -3L, true); - this.rarity.add(new Pair<>(id, regRarity)); - this.itemName.add(new Pair<>(id, localizedName)); - this.itemDescription.add(new Pair<>(id, description)); - this.descColour.add(new Pair<>(id, colour)); - this.hasEffect.add(new Pair<>(id, Effect)); - } - - @Override - @SideOnly(Side.CLIENT) - public EnumRarity getRarity(final ItemStack par1ItemStack){ - if (this.rarity.get(par1ItemStack.getItemDamage()-this.mOffset) != null) { - return this.rarity.get(par1ItemStack.getItemDamage()-this.mOffset).getValue(); - } - return EnumRarity.common; - } - - @Override - public boolean hasEffect(final ItemStack par1ItemStack){ - if (this.hasEffect.get(par1ItemStack.getItemDamage()-this.mOffset) != null) { - return this.hasEffect.get(par1ItemStack.getItemDamage()-this.mOffset).getValue(); - } - return false; - } - - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(final ItemStack aStack, final EntityPlayer aPlayer, List aList, final boolean aF3_H) { - //aList.add("Meta: "+(aStack.getItemDamage()-mOffset)); - if ((this.descColour.get(aStack.getItemDamage()-this.mOffset) != null) && (this.itemDescription.get(aStack.getItemDamage()-this.mOffset) != null)) { - aList.add(this.descColour.get(aStack.getItemDamage()-this.mOffset).getValue()+this.itemDescription.get(aStack.getItemDamage()-this.mOffset).getValue()); - } - final String tKey = this.getUnlocalizedName(aStack) + ".tooltip", tString = GT_LanguageManager.getTranslation(tKey); - if (GT_Utility.isStringValid(tString) && !tKey.equals(tString)) { - aList.add(tString); - } - final Long[] tStats = this.getElectricStats(aStack); - if (tStats != null) { - if (tStats[3] > 0) { - aList.add(EnumChatFormatting.AQUA + "Contains " + GT_Utility.formatNumbers(tStats[3]) + " EU Tier: " + (tStats[2] >= 0 ? tStats[2] : 0) + EnumChatFormatting.GRAY); - } else { - final long tCharge = this.getRealCharge(aStack); - if ((tStats[3] == -2) && (tCharge <= 0)) { - aList.add(EnumChatFormatting.AQUA + "Empty. You should recycle it properly." + EnumChatFormatting.GRAY); - } else { - aList.add(EnumChatFormatting.AQUA + "" + GT_Utility.formatNumbers(tCharge) + " / " + GT_Utility.formatNumbers(Math.abs(tStats[0])) + " EU - Voltage: " + V[(int) (tStats[2] >= 0 ? tStats[2] < V.length ? tStats[2] : V.length - 1 : 1)] + EnumChatFormatting.GRAY); - } - } - } - final ArrayList> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); - if (tList != null) { - for (final IItemBehaviour tBehavior : tList) { - aList = tBehavior.getAdditionalToolTips(this, aList, aStack); - } - } - } - - - @Override - public final Item getChargedItem(final ItemStack itemStack) { - return this; - } - - @Override - public final Item getEmptyItem(final ItemStack itemStack) { - return this; - } - - @Override - public final double getMaxCharge(final ItemStack aStack) { - final Long[] tStats = this.getElectricStats(aStack); - if (tStats == null) { - return 0; - } - return Math.abs(tStats[0]); - } - - @Override - public final double getTransferLimit(final ItemStack aStack) { - final Long[] tStats = this.getElectricStats(aStack); - if (tStats == null) { - return 0; - } - return Math.max(tStats[1], tStats[3]); - } - - @Override - public final int getTier(final ItemStack aStack) { - final Long[] tStats = this.getElectricStats(aStack); - return (int) (tStats == null ? Integer.MAX_VALUE : tStats[2]); - } - - @Override - public final double charge(final ItemStack aStack, final double aCharge, final int aTier, final boolean aIgnoreTransferLimit, final boolean aSimulate) { - final Long[] tStats = this.getElectricStats(aStack); - if ((tStats == null) || (tStats[2] > aTier) || !((tStats[3] == -1) || (tStats[3] == -3) || ((tStats[3] < 0) && (aCharge == Integer.MAX_VALUE))) || (aStack.stackSize != 1)) { - return 0; - } - final long tChargeBefore = this.getRealCharge(aStack), tNewCharge = aCharge == Integer.MAX_VALUE ? Long.MAX_VALUE : Math.min(Math.abs(tStats[0]), tChargeBefore + (aIgnoreTransferLimit ? (long) aCharge : Math.min(tStats[1], (long) aCharge))); - if (!aSimulate) { - this.setCharge(aStack, tNewCharge); - } - return tNewCharge - tChargeBefore; - } - - @Override - public final double discharge(final ItemStack aStack, final double aCharge, final int aTier, final boolean aIgnoreTransferLimit, final boolean aBatteryAlike, final boolean aSimulate) { - final Long[] tStats = this.getElectricStats(aStack); - if ((tStats == null) || (tStats[2] > aTier)) { - return 0; - } - if (aBatteryAlike && !this.canProvideEnergy(aStack)) { - return 0; - } - if (tStats[3] > 0) { - if ((aCharge < tStats[3]) || (aStack.stackSize < 1)) { - return 0; - } - if (!aSimulate) { - aStack.stackSize--; - } - return tStats[3]; - } - final long tChargeBefore = this.getRealCharge(aStack), tNewCharge = Math.max(0, tChargeBefore - (aIgnoreTransferLimit ? (long) aCharge : Math.min(tStats[1], (long) aCharge))); - if (!aSimulate) { - this.setCharge(aStack, tNewCharge); - } - return tChargeBefore - tNewCharge; - } - - @Override - public final double getCharge(final ItemStack aStack) { - return this.getRealCharge(aStack); - } - - @Override - public final boolean canUse(final ItemStack aStack, final double aAmount) { - return this.getRealCharge(aStack) >= aAmount; - } - - @Override - public final boolean use(final ItemStack aStack, final double aAmount, final EntityLivingBase aPlayer) { - this.chargeFromArmor(aStack, aPlayer); - if ((aPlayer instanceof EntityPlayer) && ((EntityPlayer) aPlayer).capabilities.isCreativeMode) { - return true; - } - final double tTransfer = this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, true); - if (tTransfer == aAmount) { - this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, false); - this.chargeFromArmor(aStack, aPlayer); - return true; - } - this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, false); - this.chargeFromArmor(aStack, aPlayer); - return false; - } - - @Override - public final boolean canProvideEnergy(final ItemStack aStack) { - final Long[] tStats = this.getElectricStats(aStack); - if (tStats == null) { - return false; - } - return (tStats[3] > 0) || ((aStack.stackSize == 1) && ((tStats[3] == -2) || (tStats[3] == -3))); - } - - @Override - public final void chargeFromArmor(final ItemStack aStack, final EntityLivingBase aPlayer) { - if ((aPlayer == null) || aPlayer.worldObj.isRemote) { - return; - } - for (int i = 1; i < 5; i++) { - final ItemStack tArmor = aPlayer.getEquipmentInSlot(i); - if (GT_ModHandler.isElectricItem(tArmor)) { - final IElectricItem tArmorItem = (IElectricItem) tArmor.getItem(); - if (tArmorItem.canProvideEnergy(tArmor) && (tArmorItem.getTier(tArmor) >= this.getTier(aStack))) { - final double tCharge = ElectricItem.manager.discharge(tArmor, this.charge(aStack, Integer.MAX_VALUE - 1, Integer.MAX_VALUE, true, true), Integer.MAX_VALUE, true, true, false); - if (tCharge > 0) { - this.charge(aStack, tCharge, Integer.MAX_VALUE, true, false); - if (aPlayer instanceof EntityPlayer) { - final Container tContainer = ((EntityPlayer) aPlayer).openContainer; - if (tContainer != null) { - tContainer.detectAndSendChanges(); - } - } - } - } - } - } - } - - public final long getRealCharge(final ItemStack aStack) { - final Long[] tStats = this.getElectricStats(aStack); - if (tStats == null) { - return 0; - } - if (tStats[3] > 0) { - return (int) (long) tStats[3]; - } - final NBTTagCompound tNBT = aStack.getTagCompound(); - return tNBT == null ? 0 : tNBT.getLong("GT.ItemCharge"); - } - - public final boolean setCharge(final ItemStack aStack, long aCharge) { - final Long[] tStats = this.getElectricStats(aStack); - if ((tStats == null) || (tStats[3] > 0)) { - return false; - } - NBTTagCompound tNBT = aStack.getTagCompound(); - if (tNBT == null) { - tNBT = new NBTTagCompound(); - } - tNBT.removeTag("GT.ItemCharge"); - aCharge = Math.min(tStats[0] < 0 ? Math.abs(tStats[0] / 2) : aCharge, Math.abs(tStats[0])); - if (aCharge > 0) { - aStack.setItemDamage(this.getChargedMetaData(aStack)); - tNBT.setLong("GT.ItemCharge", aCharge); - } else { - aStack.setItemDamage(this.getEmptyMetaData(aStack)); - } - if (tNBT.hasNoTags()) { - aStack.setTagCompound(null); - } else { - aStack.setTagCompound(tNBT); - } - this.isItemStackUsable(aStack); - return true; - } - - public short getChargedMetaData(final ItemStack aStack) { - return (short) aStack.getItemDamage(); - } - - public short getEmptyMetaData(final ItemStack aStack) { - return (short) aStack.getItemDamage(); - } - - - public boolean isItemStackUsable(final ItemStack aStack) { - final ArrayList> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); - if (tList != null) { - for (final IItemBehaviour tBehavior : tList) { - if (!tBehavior.isItemStackUsable(this, aStack)) { - return false; - } - } - } - return true; - } - - @Override - public final String getToolTip(final ItemStack aStack) { - return null; - } // This has its own ToolTip Handler, no need to let the IC2 Handler screw us up at this Point - - @Override - public final IElectricItemManager getManager(final ItemStack aStack) { - return this; - } // We are our own Manager - - /** - * Sets the Furnace Burn Value for the Item. - * - * @param aMetaValue the Meta Value of the Item you want to set it to. [0 - 32765] - * @param aValue 200 = 1 Burn Process = 500 EU, max = 32767 (that is 81917.5 EU) - * @return the Item itself for convenience in constructing. - */ - public final BaseEuItem setBurnValue(final int aMetaValue, final int aValue) { - if ((aMetaValue < 0) || (aValue < 0)) { - return this; - } - if (aValue == 0) { - this.mBurnValues.remove((short) aMetaValue); - } else { - this.mBurnValues.put((short) aMetaValue, aValue > Short.MAX_VALUE ? Short.MAX_VALUE : (short) aValue); - } - return this; - } - - /** - * @param aMetaValue the Meta Value of the Item you want to set it to. [0 - 32765] - * @param aMaxCharge Maximum Charge. (if this is == 0 it will remove the Electric Behavior) - * @param aTransferLimit Transfer Limit. - * @param aTier The electric Tier. - * @param aSpecialData If this Item has a Fixed Charge, like a SingleUse Battery (if > 0). - * Use -1 if you want to make this Battery chargeable (the use and canUse Functions will still discharge if you just use this) - * Use -2 if you want to make this Battery dischargeable. - * Use -3 if you want to make this Battery charge/discharge-able. - * @return the Item itself for convenience in constructing. - */ - public final BaseEuItem setElectricStats(final int aMetaValue, final long aMaxCharge, final long aTransferLimit, final long aTier, final long aSpecialData, final boolean aUseAnimations) { - if (aMetaValue < 0) { - return this; - } - if (aMaxCharge == 0) { - this.mElectricStats.remove((short) aMetaValue); - } else { - this.mElectricStats.put((short) aMetaValue, new Long[]{aMaxCharge, Math.max(0, aTransferLimit), Math.max(-1, aTier), aSpecialData}); - } - return this; - } - - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - @SideOnly(Side.CLIENT) - public void getSubItems(final Item var1, final CreativeTabs aCreativeTab, final List aList) { - for (int i = 0, j = this.mEnabledItems.length(); i < j; i++) { - if (this.mVisibleItems.get(i) || (D1 && this.mEnabledItems.get(i))) { - final Long[] tStats = this.mElectricStats.get((short) (this.mOffset + i)); - if ((tStats != null) && (tStats[3] < 0)) { - final ItemStack tStack = new ItemStack(this, 1, this.mOffset + i); - this.setCharge(tStack, Math.abs(tStats[0])); - this.isItemStackUsable(tStack); - aList.add(tStack); - } - if ((tStats == null) || (tStats[3] != -2)) { - final ItemStack tStack = new ItemStack(this, 1, this.mOffset + i); - this.isItemStackUsable(tStack); - aList.add(tStack); - } - } - } - } - - @Override - @SideOnly(Side.CLIENT) - public final void registerIcons(final IIconRegister aIconRegister) { - for (short i = 0, j = (short) this.mEnabledItems.length(); i < j; i++) { - if (this.mEnabledItems.get(i)) { - for (byte k = 1; k < this.mIconList[i].length; k++) { - this.mIconList[i][k] = aIconRegister.registerIcon(CORE.MODID+":" + (this.getUnlocalizedName() + "/" + i + "/" + k)); - } - this.mIconList[i][0] = aIconRegister.registerIcon(CORE.MODID+":" + (this.getUnlocalizedName() + "/" + i)); - } - } - } - - - @Override - public final IIcon getIconFromDamage(final int aMetaData) { - if (aMetaData < 0) { - return null; - } - return (aMetaData - this.mOffset) < this.mIconList.length ? this.mIconList[aMetaData - this.mOffset][0] : null; - } - - /** - * Sets the unlocalized name of this item to the string passed as the parameter" - */ - @Override - public Item setUnlocalizedName(final String p_77655_1_){ - this.unlocalizedName = p_77655_1_; - super.setUnlocalizedName(p_77655_1_); - return this; - } - - /** - * Returns the unlocalized name of this item. - */ - @Override - public String getUnlocalizedName() - { - return this.unlocalizedName; - } - - public final Long[] getElectricStats(final ItemStack aStack) { - return this.mElectricStats.get((short) aStack.getItemDamage()); - } - - @Override - public int getItemEnchantability() { - return 0; - } - - @Override - public boolean isBookEnchantable(final ItemStack aStack, final ItemStack aBook) { - return false; - } - - @Override - public boolean getIsRepairable(final ItemStack aStack, final ItemStack aMaterial) { - return false; - } - - - /** - * Adds a special Item Behaviour to the Item. - *

- * Note: the boolean Behaviours sometimes won't be executed if another boolean Behaviour returned true before. - * - * @param aMetaValue the Meta Value of the Item you want to add it to. [0 - 32765] - * @param aBehavior the Click Behavior you want to add. - * @return the Item itself for convenience in constructing. - */ - public final BaseEuItem addItemBehavior(final int aMetaValue, final IItemBehaviour aBehavior) { - if ((aMetaValue < 0) || (aMetaValue >= 32766) || (aBehavior == null)) { - return this; - } - ArrayList> tList = this.mItemBehaviors.get((short) aMetaValue); - if (tList == null) { - tList = new ArrayList<>(1); - this.mItemBehaviors.put((short) aMetaValue, tList); - } - tList.add(aBehavior); - return this; - } - - /** - * This adds a Custom Item to the ending Range. - * - * @param aID The Id of the assigned Item [0 - mItemAmount] (The MetaData gets auto-shifted by +mOffset) - * @param aEnglish The Default Localized Name of the created Item - * @param aToolTip The Default ToolTip of the created Item, you can also insert null for having no ToolTip - * @param aFoodBehavior The Food Value of this Item. Can be null aswell. Just a convenience thing. - * @param aRandomData The OreDict Names you want to give the Item. Also used for TC Aspects and some other things. - * @return An ItemStack containing the newly created Item. - */ - @SuppressWarnings("unchecked") - public final ItemStack addItem(final int aID, final String aEnglish, String aToolTip, final Object... aRandomData) { - if (aToolTip == null) { - aToolTip = ""; - } - if ((aID >= 0) && (aID < this.mItemAmount)) { - final ItemStack rStack = new ItemStack(this, 1, this.mOffset + aID); - this.mEnabledItems.set(aID); - this.mVisibleItems.set(aID); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(rStack) + ".name", aEnglish); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(rStack) + ".tooltip", aToolTip); - final List tAspects = new ArrayList<>(); - // Important Stuff to do first - for (final Object tRandomData : aRandomData) { - if (tRandomData instanceof SubTag) { - if (tRandomData == SubTag.INVISIBLE) { - this.mVisibleItems.set(aID, false); - continue; - } - if (tRandomData == SubTag.NO_UNIFICATION) { - GT_OreDictUnificator.addToBlacklist(rStack); - continue; - } - } - } - // now check for the rest - for (final Object tRandomData : aRandomData) { - if (tRandomData != null) { - boolean tUseOreDict = true; - if (tRandomData instanceof IItemBehaviour) { - this.addItemBehavior(this.mOffset + aID, (IItemBehaviour) tRandomData); - tUseOreDict = false; - } - if (tRandomData instanceof IItemContainer) { - ((IItemContainer) tRandomData).set(rStack); - tUseOreDict = false; - } - if (tRandomData instanceof SubTag) { - continue; - } - if (tRandomData instanceof TC_AspectStack) { - ((TC_AspectStack) tRandomData).addToAspectList(tAspects); - continue; - } - if (tRandomData instanceof ItemData) { - if (GT_Utility.isStringValid(tRandomData)) { - GT_OreDictUnificator.registerOre(tRandomData, rStack); - } else { - GT_OreDictUnificator.addItemData(rStack, (ItemData) tRandomData); - } - continue; - } - if (tUseOreDict) { - GT_OreDictUnificator.registerOre(tRandomData, rStack); - continue; - } - } - } - if (GregTech_API.sThaumcraftCompat != null) { - GregTech_API.sThaumcraftCompat.registerThaumcraftAspectsToItem(rStack, tAspects, false); - } - return rStack; - } - return null; - } - - @Override - public String getItemStackDisplayName(final ItemStack par1ItemStack) { - int keyValue = (par1ItemStack.getItemDamage() - this.mOffset); - if (keyValue < 0 || keyValue > 3) { - keyValue = 0; - } - return this.itemName.get(keyValue).getValue(); - } - + /* ---------- CONSTRUCTOR AND MEMBER VARIABLES ---------- */ + private final HashMap>> mItemBehaviors = new HashMap<>(); + public final short mOffset, mItemAmount; + public final BitSet mEnabledItems; + public final BitSet mVisibleItems; + public final IIcon[][] mIconList; + /** The unlocalized name of this item. */ + private String unlocalizedName; + + private final ArrayList> rarity = new ArrayList<>(); + private final ArrayList> descColour = new ArrayList<>(); + private final ArrayList> itemName = new ArrayList<>(); + private final ArrayList> itemDescription = new ArrayList<>(); + private final ArrayList> hasEffect = new ArrayList<>(); + + public final HashMap mElectricStats = new HashMap<>(); + public final HashMap mBurnValues = new HashMap<>(); + + public BaseEuItem() { + this("MU-metaitem.02", AddToCreativeTab.tabOther, (short) 1000, (short) 31766); + } + + public BaseEuItem( + final String unlocalizedName, + final CreativeTabs creativeTab, + final short aOffset, + final short aItemAmount) { + this.mEnabledItems = new BitSet(aItemAmount); + this.mVisibleItems = new BitSet(aItemAmount); + this.mOffset = (short) Math.min(32766, aOffset); + this.mItemAmount = (short) Math.min(aItemAmount, 32766 - this.mOffset); + this.mIconList = new IIcon[aItemAmount][1]; + this.setHasSubtypes(true); + this.setMaxDamage(0); + this.setUnlocalizedName(unlocalizedName); + this.setCreativeTab(creativeTab); + this.setMaxStackSize(1); + GameRegistry.registerItem(this, unlocalizedName); + } + + public void registerItem( + final int id, final String localizedName, final long euStorage, final int tier, final String description) { + this.registerItem( + id, + localizedName, + euStorage, + (short) tier, + description, + EnumRarity.common, + EnumChatFormatting.GRAY, + false); + } + + public void registerItem( + final int id, + final String localizedName, + final long euStorage, + final int tier, + final String description, + final int burnTime) { + this.registerItem( + id, + localizedName, + euStorage, + (short) tier, + description, + EnumRarity.common, + EnumChatFormatting.GRAY, + false); + this.setBurnValue(id, burnTime); + } + + public void registerItem( + final int id, + final String localizedName, + final long euStorage, + final short tier, + final String description, + final EnumRarity regRarity, + final EnumChatFormatting colour, + final boolean Effect) { + this.addItem(id, localizedName, EnumChatFormatting.YELLOW + "Electric", new Object[] {}); + this.setElectricStats(this.mOffset + id, euStorage, GT_Values.V[tier], tier, -3L, true); + this.rarity.add(new Pair<>(id, regRarity)); + this.itemName.add(new Pair<>(id, localizedName)); + this.itemDescription.add(new Pair<>(id, description)); + this.descColour.add(new Pair<>(id, colour)); + this.hasEffect.add(new Pair<>(id, Effect)); + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(final ItemStack par1ItemStack) { + if (this.rarity.get(par1ItemStack.getItemDamage() - this.mOffset) != null) { + return this.rarity.get(par1ItemStack.getItemDamage() - this.mOffset).getValue(); + } + return EnumRarity.common; + } + + @Override + public boolean hasEffect(final ItemStack par1ItemStack) { + if (this.hasEffect.get(par1ItemStack.getItemDamage() - this.mOffset) != null) { + return this.hasEffect + .get(par1ItemStack.getItemDamage() - this.mOffset) + .getValue(); + } + return false; + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public void addInformation(final ItemStack aStack, final EntityPlayer aPlayer, List aList, final boolean aF3_H) { + // aList.add("Meta: "+(aStack.getItemDamage()-mOffset)); + if ((this.descColour.get(aStack.getItemDamage() - this.mOffset) != null) + && (this.itemDescription.get(aStack.getItemDamage() - this.mOffset) != null)) { + aList.add(this.descColour.get(aStack.getItemDamage() - this.mOffset).getValue() + + this.itemDescription + .get(aStack.getItemDamage() - this.mOffset) + .getValue()); + } + final String tKey = this.getUnlocalizedName(aStack) + ".tooltip", + tString = GT_LanguageManager.getTranslation(tKey); + if (GT_Utility.isStringValid(tString) && !tKey.equals(tString)) { + aList.add(tString); + } + final Long[] tStats = this.getElectricStats(aStack); + if (tStats != null) { + if (tStats[3] > 0) { + aList.add(EnumChatFormatting.AQUA + "Contains " + GT_Utility.formatNumbers(tStats[3]) + " EU Tier: " + + (tStats[2] >= 0 ? tStats[2] : 0) + EnumChatFormatting.GRAY); + } else { + final long tCharge = this.getRealCharge(aStack); + if ((tStats[3] == -2) && (tCharge <= 0)) { + aList.add(EnumChatFormatting.AQUA + "Empty. You should recycle it properly." + + EnumChatFormatting.GRAY); + } else { + aList.add(EnumChatFormatting.AQUA + "" + GT_Utility.formatNumbers(tCharge) + " / " + + GT_Utility.formatNumbers(Math.abs(tStats[0])) + " EU - Voltage: " + + V[(int) (tStats[2] >= 0 ? tStats[2] < V.length ? tStats[2] : V.length - 1 : 1)] + + EnumChatFormatting.GRAY); + } + } + } + final ArrayList> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); + if (tList != null) { + for (final IItemBehaviour tBehavior : tList) { + aList = tBehavior.getAdditionalToolTips(this, aList, aStack); + } + } + } + + @Override + public final Item getChargedItem(final ItemStack itemStack) { + return this; + } + + @Override + public final Item getEmptyItem(final ItemStack itemStack) { + return this; + } + + @Override + public final double getMaxCharge(final ItemStack aStack) { + final Long[] tStats = this.getElectricStats(aStack); + if (tStats == null) { + return 0; + } + return Math.abs(tStats[0]); + } + + @Override + public final double getTransferLimit(final ItemStack aStack) { + final Long[] tStats = this.getElectricStats(aStack); + if (tStats == null) { + return 0; + } + return Math.max(tStats[1], tStats[3]); + } + + @Override + public final int getTier(final ItemStack aStack) { + final Long[] tStats = this.getElectricStats(aStack); + return (int) (tStats == null ? Integer.MAX_VALUE : tStats[2]); + } + + @Override + public final double charge( + final ItemStack aStack, + final double aCharge, + final int aTier, + final boolean aIgnoreTransferLimit, + final boolean aSimulate) { + final Long[] tStats = this.getElectricStats(aStack); + if ((tStats == null) + || (tStats[2] > aTier) + || !((tStats[3] == -1) || (tStats[3] == -3) || ((tStats[3] < 0) && (aCharge == Integer.MAX_VALUE))) + || (aStack.stackSize != 1)) { + return 0; + } + final long tChargeBefore = this.getRealCharge(aStack), + tNewCharge = + aCharge == Integer.MAX_VALUE + ? Long.MAX_VALUE + : Math.min( + Math.abs(tStats[0]), + tChargeBefore + + (aIgnoreTransferLimit + ? (long) aCharge + : Math.min(tStats[1], (long) aCharge))); + if (!aSimulate) { + this.setCharge(aStack, tNewCharge); + } + return tNewCharge - tChargeBefore; + } + + @Override + public final double discharge( + final ItemStack aStack, + final double aCharge, + final int aTier, + final boolean aIgnoreTransferLimit, + final boolean aBatteryAlike, + final boolean aSimulate) { + final Long[] tStats = this.getElectricStats(aStack); + if ((tStats == null) || (tStats[2] > aTier)) { + return 0; + } + if (aBatteryAlike && !this.canProvideEnergy(aStack)) { + return 0; + } + if (tStats[3] > 0) { + if ((aCharge < tStats[3]) || (aStack.stackSize < 1)) { + return 0; + } + if (!aSimulate) { + aStack.stackSize--; + } + return tStats[3]; + } + final long tChargeBefore = this.getRealCharge(aStack), + tNewCharge = + Math.max( + 0, + tChargeBefore + - (aIgnoreTransferLimit + ? (long) aCharge + : Math.min(tStats[1], (long) aCharge))); + if (!aSimulate) { + this.setCharge(aStack, tNewCharge); + } + return tChargeBefore - tNewCharge; + } + + @Override + public final double getCharge(final ItemStack aStack) { + return this.getRealCharge(aStack); + } + + @Override + public final boolean canUse(final ItemStack aStack, final double aAmount) { + return this.getRealCharge(aStack) >= aAmount; + } + + @Override + public final boolean use(final ItemStack aStack, final double aAmount, final EntityLivingBase aPlayer) { + this.chargeFromArmor(aStack, aPlayer); + if ((aPlayer instanceof EntityPlayer) && ((EntityPlayer) aPlayer).capabilities.isCreativeMode) { + return true; + } + final double tTransfer = this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, true); + if (tTransfer == aAmount) { + this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, false); + this.chargeFromArmor(aStack, aPlayer); + return true; + } + this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, false); + this.chargeFromArmor(aStack, aPlayer); + return false; + } + + @Override + public final boolean canProvideEnergy(final ItemStack aStack) { + final Long[] tStats = this.getElectricStats(aStack); + if (tStats == null) { + return false; + } + return (tStats[3] > 0) || ((aStack.stackSize == 1) && ((tStats[3] == -2) || (tStats[3] == -3))); + } + + @Override + public final void chargeFromArmor(final ItemStack aStack, final EntityLivingBase aPlayer) { + if ((aPlayer == null) || aPlayer.worldObj.isRemote) { + return; + } + for (int i = 1; i < 5; i++) { + final ItemStack tArmor = aPlayer.getEquipmentInSlot(i); + if (GT_ModHandler.isElectricItem(tArmor)) { + final IElectricItem tArmorItem = (IElectricItem) tArmor.getItem(); + if (tArmorItem.canProvideEnergy(tArmor) && (tArmorItem.getTier(tArmor) >= this.getTier(aStack))) { + final double tCharge = ElectricItem.manager.discharge( + tArmor, + this.charge(aStack, Integer.MAX_VALUE - 1, Integer.MAX_VALUE, true, true), + Integer.MAX_VALUE, + true, + true, + false); + if (tCharge > 0) { + this.charge(aStack, tCharge, Integer.MAX_VALUE, true, false); + if (aPlayer instanceof EntityPlayer) { + final Container tContainer = ((EntityPlayer) aPlayer).openContainer; + if (tContainer != null) { + tContainer.detectAndSendChanges(); + } + } + } + } + } + } + } + + public final long getRealCharge(final ItemStack aStack) { + final Long[] tStats = this.getElectricStats(aStack); + if (tStats == null) { + return 0; + } + if (tStats[3] > 0) { + return (int) (long) tStats[3]; + } + final NBTTagCompound tNBT = aStack.getTagCompound(); + return tNBT == null ? 0 : tNBT.getLong("GT.ItemCharge"); + } + + public final boolean setCharge(final ItemStack aStack, long aCharge) { + final Long[] tStats = this.getElectricStats(aStack); + if ((tStats == null) || (tStats[3] > 0)) { + return false; + } + NBTTagCompound tNBT = aStack.getTagCompound(); + if (tNBT == null) { + tNBT = new NBTTagCompound(); + } + tNBT.removeTag("GT.ItemCharge"); + aCharge = Math.min(tStats[0] < 0 ? Math.abs(tStats[0] / 2) : aCharge, Math.abs(tStats[0])); + if (aCharge > 0) { + aStack.setItemDamage(this.getChargedMetaData(aStack)); + tNBT.setLong("GT.ItemCharge", aCharge); + } else { + aStack.setItemDamage(this.getEmptyMetaData(aStack)); + } + if (tNBT.hasNoTags()) { + aStack.setTagCompound(null); + } else { + aStack.setTagCompound(tNBT); + } + this.isItemStackUsable(aStack); + return true; + } + + public short getChargedMetaData(final ItemStack aStack) { + return (short) aStack.getItemDamage(); + } + + public short getEmptyMetaData(final ItemStack aStack) { + return (short) aStack.getItemDamage(); + } + + public boolean isItemStackUsable(final ItemStack aStack) { + final ArrayList> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); + if (tList != null) { + for (final IItemBehaviour tBehavior : tList) { + if (!tBehavior.isItemStackUsable(this, aStack)) { + return false; + } + } + } + return true; + } + + @Override + public final String getToolTip(final ItemStack aStack) { + return null; + } // This has its own ToolTip Handler, no need to let the IC2 Handler screw us up at this Point + + @Override + public final IElectricItemManager getManager(final ItemStack aStack) { + return this; + } // We are our own Manager + + /** + * Sets the Furnace Burn Value for the Item. + * + * @param aMetaValue the Meta Value of the Item you want to set it to. [0 - 32765] + * @param aValue 200 = 1 Burn Process = 500 EU, max = 32767 (that is 81917.5 EU) + * @return the Item itself for convenience in constructing. + */ + public final BaseEuItem setBurnValue(final int aMetaValue, final int aValue) { + if ((aMetaValue < 0) || (aValue < 0)) { + return this; + } + if (aValue == 0) { + this.mBurnValues.remove((short) aMetaValue); + } else { + this.mBurnValues.put((short) aMetaValue, aValue > Short.MAX_VALUE ? Short.MAX_VALUE : (short) aValue); + } + return this; + } + + /** + * @param aMetaValue the Meta Value of the Item you want to set it to. [0 - 32765] + * @param aMaxCharge Maximum Charge. (if this is == 0 it will remove the Electric Behavior) + * @param aTransferLimit Transfer Limit. + * @param aTier The electric Tier. + * @param aSpecialData If this Item has a Fixed Charge, like a SingleUse Battery (if > 0). + * Use -1 if you want to make this Battery chargeable (the use and canUse Functions will still discharge if you just use this) + * Use -2 if you want to make this Battery dischargeable. + * Use -3 if you want to make this Battery charge/discharge-able. + * @return the Item itself for convenience in constructing. + */ + public final BaseEuItem setElectricStats( + final int aMetaValue, + final long aMaxCharge, + final long aTransferLimit, + final long aTier, + final long aSpecialData, + final boolean aUseAnimations) { + if (aMetaValue < 0) { + return this; + } + if (aMaxCharge == 0) { + this.mElectricStats.remove((short) aMetaValue); + } else { + this.mElectricStats.put( + (short) aMetaValue, + new Long[] {aMaxCharge, Math.max(0, aTransferLimit), Math.max(-1, aTier), aSpecialData}); + } + return this; + } + + @SuppressWarnings({"rawtypes", "unchecked"}) + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(final Item var1, final CreativeTabs aCreativeTab, final List aList) { + for (int i = 0, j = this.mEnabledItems.length(); i < j; i++) { + if (this.mVisibleItems.get(i) || (D1 && this.mEnabledItems.get(i))) { + final Long[] tStats = this.mElectricStats.get((short) (this.mOffset + i)); + if ((tStats != null) && (tStats[3] < 0)) { + final ItemStack tStack = new ItemStack(this, 1, this.mOffset + i); + this.setCharge(tStack, Math.abs(tStats[0])); + this.isItemStackUsable(tStack); + aList.add(tStack); + } + if ((tStats == null) || (tStats[3] != -2)) { + final ItemStack tStack = new ItemStack(this, 1, this.mOffset + i); + this.isItemStackUsable(tStack); + aList.add(tStack); + } + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public final void registerIcons(final IIconRegister aIconRegister) { + for (short i = 0, j = (short) this.mEnabledItems.length(); i < j; i++) { + if (this.mEnabledItems.get(i)) { + for (byte k = 1; k < this.mIconList[i].length; k++) { + this.mIconList[i][k] = aIconRegister.registerIcon( + CORE.MODID + ":" + (this.getUnlocalizedName() + "/" + i + "/" + k)); + } + this.mIconList[i][0] = + aIconRegister.registerIcon(CORE.MODID + ":" + (this.getUnlocalizedName() + "/" + i)); + } + } + } + + @Override + public final IIcon getIconFromDamage(final int aMetaData) { + if (aMetaData < 0) { + return null; + } + return (aMetaData - this.mOffset) < this.mIconList.length ? this.mIconList[aMetaData - this.mOffset][0] : null; + } + + /** + * Sets the unlocalized name of this item to the string passed as the parameter" + */ + @Override + public Item setUnlocalizedName(final String p_77655_1_) { + this.unlocalizedName = p_77655_1_; + super.setUnlocalizedName(p_77655_1_); + return this; + } + + /** + * Returns the unlocalized name of this item. + */ + @Override + public String getUnlocalizedName() { + return this.unlocalizedName; + } + + public final Long[] getElectricStats(final ItemStack aStack) { + return this.mElectricStats.get((short) aStack.getItemDamage()); + } + + @Override + public int getItemEnchantability() { + return 0; + } + + @Override + public boolean isBookEnchantable(final ItemStack aStack, final ItemStack aBook) { + return false; + } + + @Override + public boolean getIsRepairable(final ItemStack aStack, final ItemStack aMaterial) { + return false; + } + + /** + * Adds a special Item Behaviour to the Item. + *

+ * Note: the boolean Behaviours sometimes won't be executed if another boolean Behaviour returned true before. + * + * @param aMetaValue the Meta Value of the Item you want to add it to. [0 - 32765] + * @param aBehavior the Click Behavior you want to add. + * @return the Item itself for convenience in constructing. + */ + public final BaseEuItem addItemBehavior(final int aMetaValue, final IItemBehaviour aBehavior) { + if ((aMetaValue < 0) || (aMetaValue >= 32766) || (aBehavior == null)) { + return this; + } + ArrayList> tList = this.mItemBehaviors.get((short) aMetaValue); + if (tList == null) { + tList = new ArrayList<>(1); + this.mItemBehaviors.put((short) aMetaValue, tList); + } + tList.add(aBehavior); + return this; + } + + /** + * This adds a Custom Item to the ending Range. + * + * @param aID The Id of the assigned Item [0 - mItemAmount] (The MetaData gets auto-shifted by +mOffset) + * @param aEnglish The Default Localized Name of the created Item + * @param aToolTip The Default ToolTip of the created Item, you can also insert null for having no ToolTip + * @param aFoodBehavior The Food Value of this Item. Can be null aswell. Just a convenience thing. + * @param aRandomData The OreDict Names you want to give the Item. Also used for TC Aspects and some other things. + * @return An ItemStack containing the newly created Item. + */ + @SuppressWarnings("unchecked") + public final ItemStack addItem(final int aID, final String aEnglish, String aToolTip, final Object... aRandomData) { + if (aToolTip == null) { + aToolTip = ""; + } + if ((aID >= 0) && (aID < this.mItemAmount)) { + final ItemStack rStack = new ItemStack(this, 1, this.mOffset + aID); + this.mEnabledItems.set(aID); + this.mVisibleItems.set(aID); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(rStack) + ".name", aEnglish); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(rStack) + ".tooltip", aToolTip); + final List tAspects = new ArrayList<>(); + // Important Stuff to do first + for (final Object tRandomData : aRandomData) { + if (tRandomData instanceof SubTag) { + if (tRandomData == SubTag.INVISIBLE) { + this.mVisibleItems.set(aID, false); + continue; + } + if (tRandomData == SubTag.NO_UNIFICATION) { + GT_OreDictUnificator.addToBlacklist(rStack); + continue; + } + } + } + // now check for the rest + for (final Object tRandomData : aRandomData) { + if (tRandomData != null) { + boolean tUseOreDict = true; + if (tRandomData instanceof IItemBehaviour) { + this.addItemBehavior(this.mOffset + aID, (IItemBehaviour) tRandomData); + tUseOreDict = false; + } + if (tRandomData instanceof IItemContainer) { + ((IItemContainer) tRandomData).set(rStack); + tUseOreDict = false; + } + if (tRandomData instanceof SubTag) { + continue; + } + if (tRandomData instanceof TC_AspectStack) { + ((TC_AspectStack) tRandomData).addToAspectList(tAspects); + continue; + } + if (tRandomData instanceof ItemData) { + if (GT_Utility.isStringValid(tRandomData)) { + GT_OreDictUnificator.registerOre(tRandomData, rStack); + } else { + GT_OreDictUnificator.addItemData(rStack, (ItemData) tRandomData); + } + continue; + } + if (tUseOreDict) { + GT_OreDictUnificator.registerOre(tRandomData, rStack); + continue; + } + } + } + if (GregTech_API.sThaumcraftCompat != null) { + GregTech_API.sThaumcraftCompat.registerThaumcraftAspectsToItem(rStack, tAspects, false); + } + return rStack; + } + return null; + } + + @Override + public String getItemStackDisplayName(final ItemStack par1ItemStack) { + int keyValue = (par1ItemStack.getItemDamage() - this.mOffset); + if (keyValue < 0 || keyValue > 3) { + keyValue = 0; + } + return this.itemName.get(keyValue).getValue(); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/BaseItemBackpack.java b/src/main/java/gtPlusPlus/core/item/base/BaseItemBackpack.java index 246620344a..6e1d2e97e9 100644 --- a/src/main/java/gtPlusPlus/core/item/base/BaseItemBackpack.java +++ b/src/main/java/gtPlusPlus/core/item/base/BaseItemBackpack.java @@ -3,90 +3,83 @@ package gtPlusPlus.core.item.base; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - import gregtech.api.util.GT_OreDictUnificator; - import gtPlusPlus.GTplusplus; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.handler.GuiHandler; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; -public class BaseItemBackpack extends Item{ - - protected final int colourValue; - protected final String unlocalName; - - - public BaseItemBackpack(final String unlocalizedName, final int colour){ - this.unlocalName = unlocalizedName; - this.setUnlocalizedName(unlocalizedName); - this.setTextureName(CORE.MODID + ":" + "itemBackpack"); - this.colourValue = colour; - GameRegistry.registerItem(this, unlocalizedName); - GT_OreDictUnificator.registerOre("storageBackpack", ItemUtils.getSimpleStack(this)); - this.setMaxStackSize(1); - this.setCreativeTab(AddToCreativeTab.tabOther); - } - - // Without this method, your inventory will NOT work!!! - @Override - public int getMaxItemUseDuration(final ItemStack stack) { - return 1; // return any value greater than zero - } - - @Override - public ItemStack onItemRightClick(final ItemStack itemstack, final World world, final EntityPlayer player) - { - if (!world.isRemote) - { - // If player not sneaking, open the inventory gui - if (!player.isSneaking()) { - player.openGui(GTplusplus.instance, GuiHandler.GUI3, world, 0, 0, 0); - } - - // Otherwise, stealthily place some diamonds in there for a nice surprise next time you open it up :) - else { - // Utils.LOG_INFO("Player is Sneaking, giving them sneaky diamonds."); - // new BaseInventoryBackpack(player.getHeldItem()).setInventorySlotContents(0, new ItemStack(Items.diamond,4)); - } - } - - return itemstack; - } - - @Override - public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { - if (this.colourValue == 0){ - return MathUtils.generateSingularRandomHexValue(); - } - return this.colourValue; - - } - - @Override - public String getItemStackDisplayName(final ItemStack p_77653_1_) { - //Name Formatting. - String temp = this.unlocalName.replace("backpack", ""); - //Lets find the colour. - if (temp.toLowerCase().contains("dark")){ - temp = this.unlocalName.substring(12, this.unlocalName.length()); - temp = "Dark "+ temp; - } - return (temp+" Backpack"); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(final IIconRegister iconRegister) - { - this.itemIcon = iconRegister.registerIcon(CORE.MODID + ":" + "itemBackpack"); - } +public class BaseItemBackpack extends Item { + + protected final int colourValue; + protected final String unlocalName; + + public BaseItemBackpack(final String unlocalizedName, final int colour) { + this.unlocalName = unlocalizedName; + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + "itemBackpack"); + this.colourValue = colour; + GameRegistry.registerItem(this, unlocalizedName); + GT_OreDictUnificator.registerOre("storageBackpack", ItemUtils.getSimpleStack(this)); + this.setMaxStackSize(1); + this.setCreativeTab(AddToCreativeTab.tabOther); + } + + // Without this method, your inventory will NOT work!!! + @Override + public int getMaxItemUseDuration(final ItemStack stack) { + return 1; // return any value greater than zero + } + + @Override + public ItemStack onItemRightClick(final ItemStack itemstack, final World world, final EntityPlayer player) { + if (!world.isRemote) { + // If player not sneaking, open the inventory gui + if (!player.isSneaking()) { + player.openGui(GTplusplus.instance, GuiHandler.GUI3, world, 0, 0, 0); + } + + // Otherwise, stealthily place some diamonds in there for a nice surprise next time you open it up :) + else { + // Utils.LOG_INFO("Player is Sneaking, giving them sneaky diamonds."); + // new BaseInventoryBackpack(player.getHeldItem()).setInventorySlotContents(0, new + // ItemStack(Items.diamond,4)); + } + } + + return itemstack; + } + + @Override + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + if (this.colourValue == 0) { + return MathUtils.generateSingularRandomHexValue(); + } + return this.colourValue; + } + + @Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + // Name Formatting. + String temp = this.unlocalName.replace("backpack", ""); + // Lets find the colour. + if (temp.toLowerCase().contains("dark")) { + temp = this.unlocalName.substring(12, this.unlocalName.length()); + temp = "Dark " + temp; + } + return (temp + " Backpack"); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(final IIconRegister iconRegister) { + this.itemIcon = iconRegister.registerIcon(CORE.MODID + ":" + "itemBackpack"); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/BaseItemBrain.java b/src/main/java/gtPlusPlus/core/item/base/BaseItemBrain.java index 73ed4afb42..fcb11ec31a 100644 --- a/src/main/java/gtPlusPlus/core/item/base/BaseItemBrain.java +++ b/src/main/java/gtPlusPlus/core/item/base/BaseItemBrain.java @@ -1,10 +1,8 @@ package gtPlusPlus.core.item.base; -import java.util.List; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import java.util.List; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -13,97 +11,86 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; /* - * - * - Key Point: You can access the NBT compound data from the Item class (in those methods that pass an ItemStack), but the NBT compound can only be set on an ItemStack. - - The steps to add NBT data to an ItemStack: - Create or otherwise get an ItemStack of the desired item - Create an NBTTagCompound and fill it with the appropriate data - Call ItemStack#setTagCompound() method to set it. +* +* + Key Point: You can access the NBT compound data from the Item class (in those methods that pass an ItemStack), but the NBT compound can only be set on an ItemStack. - * - */ +The steps to add NBT data to an ItemStack: + Create or otherwise get an ItemStack of the desired item + Create an NBTTagCompound and fill it with the appropriate data + Call ItemStack#setTagCompound() method to set it. -public class BaseItemBrain extends Item{ - // This is an array of all the types I am going to be adding. - String[] brainTypes = { "dead", "preserved", "fresh", "tasty" }; +* +*/ - // This method allows us to have different language translation keys for - // each item we add. - @Override - public String getUnlocalizedName(final ItemStack stack) - { - // This makes sure that the stack has a tag compound. This is how data - // is stored on items. - if (stack.hasTagCompound()) - { - // This is the object holding all of the item data. - final NBTTagCompound itemData = stack.getTagCompound(); - // This checks to see if the item has data stored under the - // brainType key. - if (itemData.hasKey("brainType")) - { - // This retrieves data from the brainType key and uses it in - // the return value - return "item." + itemData.getString("brainType"); - } - } - // This will be used if the item is obtained without nbt data on it. - return "item.nullBrain"; - } +public class BaseItemBrain extends Item { + // This is an array of all the types I am going to be adding. + String[] brainTypes = {"dead", "preserved", "fresh", "tasty"}; + // This method allows us to have different language translation keys for + // each item we add. + @Override + public String getUnlocalizedName(final ItemStack stack) { + // This makes sure that the stack has a tag compound. This is how data + // is stored on items. + if (stack.hasTagCompound()) { + // This is the object holding all of the item data. + final NBTTagCompound itemData = stack.getTagCompound(); + // This checks to see if the item has data stored under the + // brainType key. + if (itemData.hasKey("brainType")) { + // This retrieves data from the brainType key and uses it in + // the return value + return "item." + itemData.getString("brainType"); + } + } + // This will be used if the item is obtained without nbt data on it. + return "item.nullBrain"; + } - // This is a fun method which allows us to run some code when our item is - // shown in a creative tab. I am going to use it to add all the brain - // types. - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - @SideOnly(Side.CLIENT) - public void getSubItems(final Item item, final CreativeTabs tab, final List itemList) - { - // This creates a loop with a counter. It will go through once for - // every listing in brainTypes, and gives us a number associated - // with each listing. - for (int pos = 0; pos < this.brainTypes.length; pos++) - { - // This creates a new ItemStack instance. The item parameter - // supplied is this item. - final ItemStack brainStack = new ItemStack(item); - // By default, a new ItemStack does not have any nbt compound data. - // We need to give it some. - brainStack.setTagCompound(new NBTTagCompound()); - // Now we set the type of the item, brainType is the key, and - // brainTypes[pos] is grabbing a - // entry from the brainTypes array. - brainStack.getTagCompound().setString("brainType", - this.brainTypes[pos]); - // And this adds it to the itemList, which is a list of all items - // in the creative tab. - itemList.add(brainStack); - } - } + // This is a fun method which allows us to run some code when our item is + // shown in a creative tab. I am going to use it to add all the brain + // types. + @SuppressWarnings({"rawtypes", "unchecked"}) + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(final Item item, final CreativeTabs tab, final List itemList) { + // This creates a loop with a counter. It will go through once for + // every listing in brainTypes, and gives us a number associated + // with each listing. + for (int pos = 0; pos < this.brainTypes.length; pos++) { + // This creates a new ItemStack instance. The item parameter + // supplied is this item. + final ItemStack brainStack = new ItemStack(item); + // By default, a new ItemStack does not have any nbt compound data. + // We need to give it some. + brainStack.setTagCompound(new NBTTagCompound()); + // Now we set the type of the item, brainType is the key, and + // brainTypes[pos] is grabbing a + // entry from the brainTypes array. + brainStack.getTagCompound().setString("brainType", this.brainTypes[pos]); + // And this adds it to the itemList, which is a list of all items + // in the creative tab. + itemList.add(brainStack); + } + } - // This code will allow us to tell the items apart in game. You can change - @SuppressWarnings({ "rawtypes", "unchecked" }) - // texture based on nbt data, but I won't be covering that. - @Override - @SideOnly(Side.CLIENT) - public void addInformation(final ItemStack stack, final EntityPlayer player, final List tooltip, final boolean isAdvanced){ - if ( stack.hasTagCompound() - && stack.getTagCompound().hasKey("brainType")) - { - // StatCollector is a class which allows us to handle string - // language translation. This requires that you fill out the - // translation in you language class. - tooltip.add(StatCollector.translateToLocal("tooltip.yourmod." - + stack.getTagCompound().getString("brainType") + ".desc")); - } - else // If the brain does not have valid tag data, a default message - { - tooltip.add(StatCollector.translateToLocal( - "tooltip.yourmod.nullbrain.desc")); - } - } + // This code will allow us to tell the items apart in game. You can change + @SuppressWarnings({"rawtypes", "unchecked"}) + // texture based on nbt data, but I won't be covering that. + @Override + @SideOnly(Side.CLIENT) + public void addInformation( + final ItemStack stack, final EntityPlayer player, final List tooltip, final boolean isAdvanced) { + if (stack.hasTagCompound() && stack.getTagCompound().hasKey("brainType")) { + // StatCollector is a class which allows us to handle string + // language translation. This requires that you fill out the + // translation in you language class. + tooltip.add(StatCollector.translateToLocal( + "tooltip.yourmod." + stack.getTagCompound().getString("brainType") + ".desc")); + } else // If the brain does not have valid tag data, a default message + { + tooltip.add(StatCollector.translateToLocal("tooltip.yourmod.nullbrain.desc")); + } + } } - diff --git a/src/main/java/gtPlusPlus/core/item/base/BaseItemBurnable.java b/src/main/java/gtPlusPlus/core/item/base/BaseItemBurnable.java index a5db714822..9b24aa32d9 100644 --- a/src/main/java/gtPlusPlus/core/item/base/BaseItemBurnable.java +++ b/src/main/java/gtPlusPlus/core/item/base/BaseItemBurnable.java @@ -1,44 +1,49 @@ package gtPlusPlus.core.item.base; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.ItemStack; - import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.ItemStack; public class BaseItemBurnable extends CoreItem { - - protected final int meta; - - public BaseItemBurnable(String unlocalizedName, String displayName, CreativeTabs creativeTab, - int stackSize, int maxDmg, String description, String oredictName, int burnTime, int meta) { - super(unlocalizedName, creativeTab, stackSize, maxDmg, description); - this.itemName = displayName; - this.meta = meta; - if (oredictName != null && !oredictName.equals("")){ - registerOrdictionary(oredictName); - } - registerFuel(burnTime); - - } - - public void registerFuel(int burn){ - CORE.burnables.add(new Pair(burn, ItemUtils.getSimpleStack(this, 1))); - } - - public final void registerOrdictionary(String name){ - ItemUtils.addItemToOreDictionary(ItemUtils.getSimpleStack(this), name); - } - - @Override - public int getDamage(ItemStack stack) { - return this.meta; - } - - @Override - public boolean showDurabilityBar(ItemStack stack) { - return false; - } + protected final int meta; + + public BaseItemBurnable( + String unlocalizedName, + String displayName, + CreativeTabs creativeTab, + int stackSize, + int maxDmg, + String description, + String oredictName, + int burnTime, + int meta) { + super(unlocalizedName, creativeTab, stackSize, maxDmg, description); + this.itemName = displayName; + this.meta = meta; + if (oredictName != null && !oredictName.equals("")) { + registerOrdictionary(oredictName); + } + registerFuel(burnTime); + } + + public void registerFuel(int burn) { + CORE.burnables.add(new Pair(burn, ItemUtils.getSimpleStack(this, 1))); + } + + public final void registerOrdictionary(String name) { + ItemUtils.addItemToOreDictionary(ItemUtils.getSimpleStack(this), name); + } + + @Override + public int getDamage(ItemStack stack) { + return this.meta; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/BaseItemColourable.java b/src/main/java/gtPlusPlus/core/item/base/BaseItemColourable.java index ca7041617d..94c231be9b 100644 --- a/src/main/java/gtPlusPlus/core/item/base/BaseItemColourable.java +++ b/src/main/java/gtPlusPlus/core/item/base/BaseItemColourable.java @@ -1,11 +1,10 @@ package gtPlusPlus.core.item.base; -import java.util.List; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.core.lib.CORE; +import java.util.List; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; @@ -13,86 +12,100 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; -import gtPlusPlus.core.lib.CORE; +public class BaseItemColourable extends Item { -public class BaseItemColourable extends Item -{ + private final EnumRarity rarity; + private final EnumChatFormatting descColour; + private final String itemDescription; + protected String itemName; + private final boolean hasEffect; + public final int componentColour; - private final EnumRarity rarity; - private final EnumChatFormatting descColour; - private final String itemDescription; - protected String itemName; - private final boolean hasEffect; - public final int componentColour; + @Override + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + return this.componentColour; + } - @Override - public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { - return this.componentColour; - } - - //5 - /* - * Name, Tab, Stack, Dmg, Description, Rarity, Text Colour, Effect - */ - public BaseItemColourable(final String unlocalizedName, final CreativeTabs creativeTab, final int stackSize, final int maxDmg, final String description, final EnumRarity regRarity, final EnumChatFormatting colour, final boolean Effect, int rgb) - { - this.setUnlocalizedName(unlocalizedName); - this.setTextureName(CORE.MODID + ":" + unlocalizedName); - this.setCreativeTab(creativeTab); - this.setMaxStackSize(stackSize); - this.setMaxDamage(maxDmg); - this.setHasSubtypes(true); - this.rarity = regRarity; - this.itemDescription = description; - this.descColour = colour; - this.hasEffect = Effect; - this.componentColour = rgb; - GameRegistry.registerItem(this, unlocalizedName); - } + // 5 + /* + * Name, Tab, Stack, Dmg, Description, Rarity, Text Colour, Effect + */ + public BaseItemColourable( + final String unlocalizedName, + final CreativeTabs creativeTab, + final int stackSize, + final int maxDmg, + final String description, + final EnumRarity regRarity, + final EnumChatFormatting colour, + final boolean Effect, + int rgb) { + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setCreativeTab(creativeTab); + this.setMaxStackSize(stackSize); + this.setMaxDamage(maxDmg); + this.setHasSubtypes(true); + this.rarity = regRarity; + this.itemDescription = description; + this.descColour = colour; + this.hasEffect = Effect; + this.componentColour = rgb; + GameRegistry.registerItem(this, unlocalizedName); + } - //6 - /* - * Name, Tab, Stack, Dmg, Description, Rarity, Text Colour, Effect - */ - public BaseItemColourable(final String unlocalizedName, final String displayName, final CreativeTabs creativeTab, final int stackSize, final int maxDmg, final String description, final EnumRarity regRarity, final EnumChatFormatting colour, final boolean Effect, int rgb) - { - this.setUnlocalizedName(unlocalizedName); - this.itemName = displayName; - this.setTextureName(CORE.MODID + ":" + unlocalizedName); - this.setCreativeTab(creativeTab); - this.setMaxStackSize(stackSize); - this.setMaxDamage(maxDmg); - this.rarity = regRarity; - this.itemDescription = description; - this.descColour = colour; - this.hasEffect = Effect; - this.componentColour = rgb; - GameRegistry.registerItem(this, unlocalizedName); - } + // 6 + /* + * Name, Tab, Stack, Dmg, Description, Rarity, Text Colour, Effect + */ + public BaseItemColourable( + final String unlocalizedName, + final String displayName, + final CreativeTabs creativeTab, + final int stackSize, + final int maxDmg, + final String description, + final EnumRarity regRarity, + final EnumChatFormatting colour, + final boolean Effect, + int rgb) { + this.setUnlocalizedName(unlocalizedName); + this.itemName = displayName; + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setCreativeTab(creativeTab); + this.setMaxStackSize(stackSize); + this.setMaxDamage(maxDmg); + this.rarity = regRarity; + this.itemDescription = description; + this.descColour = colour; + this.hasEffect = Effect; + this.componentColour = rgb; + GameRegistry.registerItem(this, unlocalizedName); + } - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - list.add(this.descColour+this.itemDescription); - //super.addInformation(stack, aPlayer, list, bool); - } + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add(this.descColour + this.itemDescription); + // super.addInformation(stack, aPlayer, list, bool); + } - @Override - @SideOnly(Side.CLIENT) - public EnumRarity getRarity(final ItemStack par1ItemStack){ - return this.rarity; - } + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(final ItemStack par1ItemStack) { + return this.rarity; + } - @Override - public boolean hasEffect(final ItemStack par1ItemStack){ - return this.hasEffect; - } + @Override + public boolean hasEffect(final ItemStack par1ItemStack) { + return this.hasEffect; + } - @Override - public String getItemStackDisplayName(final ItemStack tItem) { - if ((this.itemName == null) || this.itemName.equals("")) { - return super.getItemStackDisplayName(tItem); - } - return this.itemName; - } -} \ No newline at end of file + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + if ((this.itemName == null) || this.itemName.equals("")) { + return super.getItemStackDisplayName(tItem); + } + return this.itemName; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/BaseItemComponent.java b/src/main/java/gtPlusPlus/core/item/base/BaseItemComponent.java index 9590ec2848..8f513e9001 100644 --- a/src/main/java/gtPlusPlus/core/item/base/BaseItemComponent.java +++ b/src/main/java/gtPlusPlus/core/item/base/BaseItemComponent.java @@ -1,29 +1,26 @@ package gtPlusPlus.core.item.base; -import java.util.*; - 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.OrePrefixes; import gregtech.api.enums.TextureSet; -import gregtech.api.util.GT_LanguageManager; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_OreDictUnificator; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.Material; -import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.data.StringUtils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.EntityUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.sys.KeyboardUtils; +import java.util.*; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -33,1024 +30,1025 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; import net.minecraft.world.World; -public class BaseItemComponent extends Item{ - - private final static Class mTextureSetPreload; - - static { - mTextureSetPreload = TextureSet.class; - } - - public final Material componentMaterial; - public final String materialName; - public final String unlocalName; - public final ComponentTypes componentType; - public final int componentColour; - public Object extraData; - - protected IIcon base; - protected IIcon overlay; - - public BaseItemComponent(final Material material, final ComponentTypes componentType) { - this.componentMaterial = material; - this.unlocalName = "item"+componentType.COMPONENT_NAME+material.getUnlocalizedName(); - this.materialName = material.getLocalizedName(); - this.componentType = componentType; - this.setCreativeTab(AddToCreativeTab.tabMisc); - this.setUnlocalizedName(this.unlocalName); - this.setMaxStackSize(64); - //this.setTextureName(this.getCorrectTextures()); - this.componentColour = material.getRgbAsHex(); - GameRegistry.registerItem(this, this.unlocalName); - - //if (componentType != ComponentTypes.DUST) - - GT_OreDictUnificator.registerOre(componentType.getOreDictName()+material.getUnlocalizedName(), ItemUtils.getSimpleStack(this)); - if (componentType == ComponentTypes.GEAR) { - GT_OreDictUnificator.registerOre("gear"+material.getUnlocalizedName(), ItemUtils.getSimpleStack(this)); - } - if (LoadedMods.Thaumcraft) { - //ThaumcraftUtils.addAspectToItem(ItemUtils.getSimpleStack(this), TC_Aspect_Wrapper.generate(TC_Aspects.METALLUM.mAspect), 1); - if (componentMaterial.isRadioactive) { - //ThaumcraftUtils.addAspectToItem(ItemUtils.getSimpleStack(this), TC_Aspect_Wrapper.generate(TC_Aspects.RADIO.mAspect), componentMaterial.vRadiationLevel); - } - } - registerComponent(); - } - - //For Cell Generation - public BaseItemComponent(final String unlocalName, final String localName, final short[] RGBA) { - - // Handles .'s from fluid internal names. - String aFormattedNameForFluids; - if (unlocalName.contains(".")) { - aFormattedNameForFluids = StringUtils.splitAndUppercase(unlocalName, "."); - } - else { - aFormattedNameForFluids = unlocalName; - } - Material aTempMaterial = Material.mMaterialCache.get(localName.toLowerCase()); - Logger.INFO("Attempted to get "+localName+" cell material from cache. Valid? "+(aTempMaterial != null)); - this.componentMaterial = aTempMaterial; - this.unlocalName = "itemCell"+aFormattedNameForFluids; - this.materialName = localName; - this.componentType = ComponentTypes.CELL; - this.setCreativeTab(AddToCreativeTab.tabMisc); - this.setUnlocalizedName(aFormattedNameForFluids); - this.setMaxStackSize(64); - this.componentColour = MathUtils.getRgbAsHex(RGBA); - this.extraData = RGBA; - - this.setTextureName(CORE.MODID + ":" + "item"+ComponentTypes.CELL.COMPONENT_NAME); - GameRegistry.registerItem(this, aFormattedNameForFluids); - GT_OreDictUnificator.registerOre(ComponentTypes.CELL.getOreDictName()+Utils.sanitizeStringKeepBrackets(localName), ItemUtils.getSimpleStack(this)); - registerComponent(); - } - - public boolean registerComponent() { - if (this.componentMaterial == null) { - return false; - } - //Register Component - Map aMap = Material.mComponentMap.get(componentMaterial.getUnlocalizedName()); - if (aMap == null) { - aMap = new HashMap(); - } - String aKey = componentType.getGtOrePrefix().name(); - ItemStack x = aMap.get(aKey); - if (x == null) { - aMap.put(aKey, ItemUtils.getSimpleStack(this)); - Logger.MATERIALS("Registering a material component. Item: ["+componentMaterial.getUnlocalizedName()+"] Map: ["+aKey+"]"); - Material.mComponentMap.put(componentMaterial.getUnlocalizedName(), aMap); - if (componentType == ComponentTypes.PLATE) { - GregTech_API.registerCover(componentMaterial.getPlate(1), new GT_RenderedTexture(componentMaterial.getTextureSet().mTextures[71], componentMaterial.getRGBA(), false), null); - } - else if (componentType == ComponentTypes.PLATEDOUBLE) { - GregTech_API.registerCover(componentMaterial.getPlateDouble(1), new GT_RenderedTexture(componentMaterial.getTextureSet().mTextures[72], componentMaterial.getRGBA(), false), null); - } - return true; - } - else { - //Bad - Logger.MATERIALS("Tried to double register a material component. "); - return false; - } - } - - public String getCorrectTextures(){ - if (!CORE.ConfigSwitches.useGregtechTextures){ - return CORE.MODID + ":" + "item"+this.componentType.COMPONENT_NAME; - } - String metType = "9j4852jyo3rjmh3owlhw9oe"; - if (this.componentMaterial != null) { - TextureSet u = this.componentMaterial.getTextureSet(); - if (u != null) { - metType = u.mSetName; - } - } - metType = (metType.equals("9j4852jyo3rjmh3owlhw9oe") ? "METALLIC" : metType); - return "gregtech" + ":" + "materialicons/"+metType+"/" + this.componentType.getOreDictName(); - - - - //return "gregtech" + ":" + "materialicons/"+metType+"/" + this.componentType.COMPONENT_NAME.toLowerCase(); - } - - /*@Override - public String getItemStackDisplayName(final ItemStack p_77653_1_) { - - if (this.componentType == ComponentTypes.SMALLGEAR){ - return "Small " + this.materialName+" Gear"; - } - - if (this.componentMaterial != null) { - return (this.componentMaterial.getLocalizedName()+this.componentType.DISPLAY_NAME); - } - return this.materialName+" Cell"; - }*/ - - public final String getMaterialName() { - return this.materialName; - } - - @Override - public String getItemStackDisplayName(ItemStack stack) { - if (componentMaterial == null) { - String aFormattedLangName = componentType.getName(); - if (!aFormattedLangName.startsWith(" ")) { - if (aFormattedLangName.contains("@")) { - String[] aSplit = aFormattedLangName.split("@"); - aFormattedLangName = aSplit[0] + " " + getMaterialName() + " " + aSplit[1]; - } - } - if (aFormattedLangName.equals(componentType.getName())) { - aFormattedLangName = getMaterialName() + aFormattedLangName; - } - return GT_LanguageManager.addStringLocalization(unlocalName, aFormattedLangName); - } - String aFormattedLangName = componentType.getName(); - if (!aFormattedLangName.startsWith(" ")) { - if (aFormattedLangName.contains("@")) { - String[] aSplit = aFormattedLangName.split("@"); - aFormattedLangName = aSplit[0] + " " + componentMaterial.getLocalizedName() + " " + aSplit[1]; - } - } - if (aFormattedLangName.equals(componentType.getName())) { - aFormattedLangName = componentMaterial.getLocalizedName() + aFormattedLangName; - } - return GT_LanguageManager.addStringLocalization(unlocalName, aFormattedLangName); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public final void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - - try { - - - if (this.componentMaterial == null){ - if (this.materialName != null){ - //list.add(Utils.sanitizeStringKeepBrackets(materialName)); - } - } - - if ((this.materialName != null) && (this.materialName != "") && !this.materialName.equals("") && (this.componentMaterial != null)){ - - - if (this.componentMaterial != null){ - if (!this.componentMaterial.vChemicalFormula.contains("?")) { - list.add(Utils.sanitizeStringKeepBrackets(this.componentMaterial.vChemicalFormula)); - } - else if (this.componentMaterial.vChemicalFormula.contains("?")) { - String temp = componentMaterial.vChemicalFormula; - temp = temp.replace(" ", ""); - temp = temp.replace("-", ""); - temp = temp.replace("_", ""); - temp = temp.replace("!", ""); - temp = temp.replace("@", ""); - temp = temp.replace("#", ""); - temp = temp.replace(" ", ""); - list.add(temp); - } - - if (this.componentMaterial.isRadioactive){ - list.add(CORE.GT_Tooltip_Radioactive); - } - - if (this.componentType == ComponentTypes.INGOT || this.componentType == ComponentTypes.HOTINGOT){ - if ((this.materialName != null) && (this.materialName != "") && !this.materialName.equals("") && this.unlocalName.toLowerCase().contains("hot")){ - list.add(EnumChatFormatting.GRAY+"Warning: "+EnumChatFormatting.RED+"Very hot! "+EnumChatFormatting.GRAY+" Avoid direct handling.."); - } - } - } - else { - String aChemicalFormula = Material.sChemicalFormula.get(materialName.toLowerCase()); - if (aChemicalFormula != null && aChemicalFormula.length() > 0) { - list.add(Utils.sanitizeStringKeepBrackets(aChemicalFormula)); - } - } - - //Hidden Tooltip - if (KeyboardUtils.isCtrlKeyDown()) { - if (this.componentMaterial != null) { - String type = this.componentMaterial.getTextureSet().mSetName; - String output = type.substring(0, 1).toUpperCase() + type.substring(1); - list.add(EnumChatFormatting.GRAY+"Material Type: "+output+"."); - list.add(EnumChatFormatting.GRAY+"Material State: "+this.componentMaterial.getState().name()+"."); - list.add(EnumChatFormatting.GRAY+"Radioactivity Level: "+this.componentMaterial.vRadiationLevel+"."); - } - } - else { - list.add(EnumChatFormatting.DARK_GRAY+"Hold Ctrl to show additional info."); - } - - } - } - catch (Throwable t) {} - - super.addInformation(stack, aPlayer, list, bool); - } - - @SuppressWarnings("unchecked") - @Override - public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, final boolean p_77663_5_) { - if (this.componentMaterial != null){ - if (entityHolding instanceof EntityPlayer){ - if (!((EntityPlayer) entityHolding).capabilities.isCreativeMode){ - EntityUtils.applyRadiationDamageToEntity(iStack.stackSize, this.componentMaterial.vRadiationLevel, world, entityHolding); - } - } - } - - if (extraData != null) { - if (componentMaterial != null && componentMaterial.getRGBA()[3] > 1) { - if (((Map) extraData).get(9999) == null) { - ((Map) extraData).put(9999, new Short[] {0}); - } - Short aCurrentFrame = ((Map) extraData).get(9999)[0]; - short fC = (short) (aCurrentFrame >= Short.MAX_VALUE ? 0 : aCurrentFrame+1); - ((Map) extraData).put((int) 9999, new Short[] {(short) (fC), 0}); - ((Map) extraData).put((int) 9998, new Short[] {aCurrentFrame, 0}); - - } - } - } - - - /** - * - * Handle Custom Rendering - * - */ - - @Override - @SideOnly(Side.CLIENT) - public boolean requiresMultipleRenderPasses(){ - return (CORE.ConfigSwitches.useGregtechTextures ? true : false); - } - - @SuppressWarnings("unchecked") - @Override - public int getColorFromItemStack(final ItemStack stack, final int renderPass) { - - - if (this.componentType == ComponentTypes.CELL || this.componentType == ComponentTypes.PLASMACELL) { - if (renderPass == 0 && !CORE.ConfigSwitches.useGregtechTextures){ - return Utils.rgbtoHexValue(255, 255, 255); - } - if (renderPass == 1 && CORE.ConfigSwitches.useGregtechTextures){ - return Utils.rgbtoHexValue(255, 255, 255); - } - } - if (this.componentType == ComponentTypes.PLATEHEAVY) { - - } - - - - try { - if (this.componentMaterial == null) { - if (extraData != null) { - if (short.class.isInstance(extraData)){ - short[] abc = (short[]) extraData; - return Utils.rgbtoHexValue(abc[0], abc[1], abc[2]); - } - } - return this.componentColour; - } - - if (this.componentMaterial.getRGBA()[3] <= 1) { - return this.componentColour; - } - else { - - //Mild Glow Effect - if (this.componentMaterial.getRGBA()[3] == 2) { - if (extraData == null) { - extraData = new HashMap(); - ((Map) extraData).put((int) Short.MAX_VALUE, new Short[] {0}); - ((Map) extraData).put((int) Short.MAX_VALUE-1, new Short[] {0}); - short[] er = this.componentMaterial.getRGBA(); - short value = 0; - Short[] ht = new Short[] {er[0], er[1], er[2]}; - int aMaxCycles = 200; - for (int y = 0; y < aMaxCycles; y++) { - if (y < (50)) { - value = 1; - } - else if (y < (100)) { - value = 0; - } - else if (y < (150)) { - value = -1; - } - else { - value = 0; - } - short r = (short) Math.max(Math.min(255, (ht[0] + value)), 0); - short g = (short) Math.max(Math.min(255, (ht[1] + value)), 0); - short b = (short) Math.max(Math.min(255, (ht[2] + value)), 0); - Short[] qq = new Short[] {(short) Math.min(255, r), (short) Math.min(255, g), (short) Math.min(255, b)}; - ht = qq; - ((Map) extraData).put(y, qq); - } - ((Map) extraData).put((int) Short.MAX_VALUE-2, new Short[] {(short) (((Map) extraData).size()-1)}); - } - if (extraData != null) { - - Short aCurrentFrame = ((Map) extraData).get((int) Short.MAX_VALUE)[0]; - Short aSize = (short) (((Map) extraData).size() - 3); - short nextFrame = (short) ((aCurrentFrame < aSize) ? (aCurrentFrame+1) : 0); - Short[] aCurrentFrameRGB = ((Map) extraData).get(aCurrentFrame < aSize ? (int) aCurrentFrame : 0); - ((Map) extraData).put((int) Short.MAX_VALUE, new Short[] {nextFrame}); - return Utils.rgbtoHexValue(aCurrentFrameRGB[0], aCurrentFrameRGB[1], aCurrentFrameRGB[2]); - } - } - - //Rainbow Hue Cycle - else if (this.componentMaterial.getRGBA()[3] == 3) { - if (extraData == null) { - extraData = new HashMap(); - ((Map) extraData).put((int) Short.MAX_VALUE, new Short[] {0}); - ((Map) extraData).put((int) Short.MAX_VALUE-1, new Short[] {0}); - int aSlot = 0; - - //Let's say you're starting with green: - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 0}); - //Slowly start adding in some red to get to yellow: - ((Map) extraData).put(aSlot++, new Short[] { 51, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); - //Then, take out the green to get to red: - ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); - //Now, add blue to get to purple: - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); - //Then, remove red to get to blue: - ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 51, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 0, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 0, 255}); - //Add the green back in to get to cyan: - ((Map) extraData).put(aSlot++, new Short[] { 0, 51, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 51, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 51, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 51, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 51, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 51, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 51, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 51, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 51, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 51, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 51, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 51, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 51, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 51, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 51, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 51, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 51, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 51, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 102, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 102, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 102, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 102, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 102, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 102, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 102, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 102, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 102, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 102, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 102, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 102, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 102, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 102, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 102, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 102, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 102, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 102, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 153, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 153, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 153, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 153, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 153, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 153, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 153, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 153, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 153, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 153, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 153, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 153, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 153, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 153, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 153, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 153, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 153, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 153, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 204, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 204, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 204, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 204, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 204, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 204, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 204, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 204, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 204, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 204, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 204, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 204, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 204, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 204, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 204, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 204, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 204, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 204, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 255}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 255}); - //And finally remove the blue to get back to green: - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 204}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 204}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 204}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 204}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 204}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 204}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 204}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 204}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 204}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 204}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 204}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 204}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 204}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 204}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 204}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 204}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 204}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 204}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 153}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 153}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 153}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 153}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 153}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 153}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 153}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 153}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 153}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 153}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 153}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 153}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 153}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 153}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 153}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 153}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 153}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 153}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 102}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 102}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 102}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 102}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 102}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 102}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 102}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 102}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 102}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 102}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 102}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 102}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 102}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 102}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 102}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 102}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 102}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 102}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 51}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 51}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 51}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 51}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 51}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 51}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 51}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 51}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 51}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 51}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 51}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 51}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 51}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 51}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 51}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 51}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 51}); - ((Map) extraData).put(aSlot++, new Short[] { 0, 255, 51}); - ((Map) extraData).put((int) Short.MAX_VALUE-2, new Short[] {(short) (((Map) extraData).size()-1)}); - - - } - if (extraData != null) { - Short aCurrentFrame = ((Map) extraData).get((int) Short.MAX_VALUE)[0]; - Short aSize = (short) (((Map) extraData).size() - 3); - short nextFrame = (short) ((aCurrentFrame < aSize) ? (aCurrentFrame+1) : 0); - Short[] aCurrentFrameRGB = ((Map) extraData).get(aCurrentFrame < aSize ? (int) aCurrentFrame : 0); - ((Map) extraData).put((int) Short.MAX_VALUE, new Short[] {nextFrame}); - return Utils.rgbtoHexValue(aCurrentFrameRGB[0], aCurrentFrameRGB[1], aCurrentFrameRGB[2]); - } - } - } - - - } - catch (Throwable t) { - - } - return this.componentColour; - - - - - - } - - @Override - public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) { - if (CORE.ConfigSwitches.useGregtechTextures) { - if(pass == 0) { - return this.base; - } - return this.overlay; - } - return this.base; - } - - @Override - public void registerIcons(final IIconRegister i) { - - if (CORE.ConfigSwitches.useGregtechTextures){ - this.base = i.registerIcon(getCorrectTextures()); - this.overlay = i.registerIcon(getCorrectTextures() + "_OVERLAY"); - } - else { - this.base = i.registerIcon(getCorrectTextures()); - //this.overlay = i.registerIcon(getCorrectTextures() + "_OVERLAY"); - } - } - - - - - public static enum ComponentTypes { - DUST("Dust", " Dust", "dust", OrePrefixes.dust), - DUSTSMALL("DustSmall", "Small Pile of@Dust", "dustSmall", OrePrefixes.dustSmall), - DUSTTINY("DustTiny", "Tiny Pile of@Dust", "dustTiny", OrePrefixes.dustTiny), - INGOT("Ingot", " Ingot", "ingot", OrePrefixes.ingot), - HOTINGOT("HotIngot", "Hot@Ingot", "ingotHot", OrePrefixes.ingotHot), - PLATE("Plate", " Plate", "plate", OrePrefixes.plate), - PLATEDOUBLE("PlateDouble", " Double Plate", "plateDouble", OrePrefixes.plateDouble), - ROD("Rod", " Rod", "stick", OrePrefixes.stick), - RODLONG("RodLong", " Long Rod", "stickLong", OrePrefixes.stickLong), - GEAR("Gear", " Gear", "gearGt", OrePrefixes.gearGt), - SMALLGEAR("SmallGear", " Gear", "gearGtSmall", OrePrefixes.gearGtSmall), //TODO - SCREW("Screw", " Screw", "screw", OrePrefixes.screw), - BOLT("Bolt", " Bolt", "bolt", OrePrefixes.bolt), - ROTOR("Rotor", " Rotor", "rotor", OrePrefixes.rotor), - RING("Ring", " Ring", "ring", OrePrefixes.ring), - FOIL("Foil", " Foil", "foil", OrePrefixes.foil), - PLASMACELL("CellPlasma", " Plasma Cell", "cellPlasma", OrePrefixes.cellPlasma), - CELL("Cell", " Cell", "cell", OrePrefixes.cell), - NUGGET("Nugget", " Nugget", "nugget", OrePrefixes.nugget), - PLATEHEAVY("HeavyPlate", "Heavy@Plate", "plateHeavy", OrePrefixes.plateDense), - SPRING("Spring", " Spring", "spring", OrePrefixes.spring), - SMALLSPRING("SmallSpring", "Small@Spring", "springSmall", OrePrefixes.springSmall), - FINEWIRE("FineWire", "Fine@Wire", "wireFine", OrePrefixes.wireFine),; - - private String COMPONENT_NAME; - private String DISPLAY_NAME; - private String OREDICT_NAME; - private OrePrefixes a_GT_EQUAL; - private ComponentTypes (final String LocalName, final String DisplayName, final String OreDictName, final OrePrefixes aPrefix){ - this.COMPONENT_NAME = LocalName; - this.DISPLAY_NAME = DisplayName; - this.OREDICT_NAME = OreDictName; - this.a_GT_EQUAL = aPrefix; - } - - public String getComponent(){ - return this.COMPONENT_NAME; - } - - public String getName(){ - return this.DISPLAY_NAME; - } - - public String getOreDictName(){ - return this.OREDICT_NAME; - } - - public OrePrefixes getGtOrePrefix() { - return this.a_GT_EQUAL; - } - - } - +public class BaseItemComponent extends Item { + + private static final Class mTextureSetPreload; + + static { + mTextureSetPreload = TextureSet.class; + } + + public final Material componentMaterial; + public final String materialName; + public final String unlocalName; + public final ComponentTypes componentType; + public final int componentColour; + public Object extraData; + + protected IIcon base; + protected IIcon overlay; + + public BaseItemComponent(final Material material, final ComponentTypes componentType) { + this.componentMaterial = material; + this.unlocalName = "item" + componentType.COMPONENT_NAME + material.getUnlocalizedName(); + this.materialName = material.getLocalizedName(); + this.componentType = componentType; + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(this.unlocalName); + this.setMaxStackSize(64); + // this.setTextureName(this.getCorrectTextures()); + this.componentColour = material.getRgbAsHex(); + GameRegistry.registerItem(this, this.unlocalName); + + // if (componentType != ComponentTypes.DUST) + + GT_OreDictUnificator.registerOre( + componentType.getOreDictName() + material.getUnlocalizedName(), ItemUtils.getSimpleStack(this)); + if (componentType == ComponentTypes.GEAR) { + GT_OreDictUnificator.registerOre("gear" + material.getUnlocalizedName(), ItemUtils.getSimpleStack(this)); + } + if (LoadedMods.Thaumcraft) { + // ThaumcraftUtils.addAspectToItem(ItemUtils.getSimpleStack(this), + // TC_Aspect_Wrapper.generate(TC_Aspects.METALLUM.mAspect), 1); + if (componentMaterial.isRadioactive) { + // ThaumcraftUtils.addAspectToItem(ItemUtils.getSimpleStack(this), + // TC_Aspect_Wrapper.generate(TC_Aspects.RADIO.mAspect), componentMaterial.vRadiationLevel); + } + } + registerComponent(); + } + + // For Cell Generation + public BaseItemComponent(final String unlocalName, final String localName, final short[] RGBA) { + + // Handles .'s from fluid internal names. + String aFormattedNameForFluids; + if (unlocalName.contains(".")) { + aFormattedNameForFluids = StringUtils.splitAndUppercase(unlocalName, "."); + } else { + aFormattedNameForFluids = unlocalName; + } + Material aTempMaterial = Material.mMaterialCache.get(localName.toLowerCase()); + Logger.INFO("Attempted to get " + localName + " cell material from cache. Valid? " + (aTempMaterial != null)); + this.componentMaterial = aTempMaterial; + this.unlocalName = "itemCell" + aFormattedNameForFluids; + this.materialName = localName; + this.componentType = ComponentTypes.CELL; + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(aFormattedNameForFluids); + this.setMaxStackSize(64); + this.componentColour = MathUtils.getRgbAsHex(RGBA); + this.extraData = RGBA; + + this.setTextureName(CORE.MODID + ":" + "item" + ComponentTypes.CELL.COMPONENT_NAME); + GameRegistry.registerItem(this, aFormattedNameForFluids); + GT_OreDictUnificator.registerOre( + ComponentTypes.CELL.getOreDictName() + Utils.sanitizeStringKeepBrackets(localName), + ItemUtils.getSimpleStack(this)); + registerComponent(); + } + + public boolean registerComponent() { + if (this.componentMaterial == null) { + return false; + } + // Register Component + Map aMap = Material.mComponentMap.get(componentMaterial.getUnlocalizedName()); + if (aMap == null) { + aMap = new HashMap(); + } + String aKey = componentType.getGtOrePrefix().name(); + ItemStack x = aMap.get(aKey); + if (x == null) { + aMap.put(aKey, ItemUtils.getSimpleStack(this)); + Logger.MATERIALS("Registering a material component. Item: [" + componentMaterial.getUnlocalizedName() + + "] Map: [" + aKey + "]"); + Material.mComponentMap.put(componentMaterial.getUnlocalizedName(), aMap); + if (componentType == ComponentTypes.PLATE) { + GregTech_API.registerCover( + componentMaterial.getPlate(1), + new GT_RenderedTexture( + componentMaterial.getTextureSet().mTextures[71], componentMaterial.getRGBA(), false), + null); + } else if (componentType == ComponentTypes.PLATEDOUBLE) { + GregTech_API.registerCover( + componentMaterial.getPlateDouble(1), + new GT_RenderedTexture( + componentMaterial.getTextureSet().mTextures[72], componentMaterial.getRGBA(), false), + null); + } + return true; + } else { + // Bad + Logger.MATERIALS("Tried to double register a material component. "); + return false; + } + } + + public String getCorrectTextures() { + if (!CORE.ConfigSwitches.useGregtechTextures) { + return CORE.MODID + ":" + "item" + this.componentType.COMPONENT_NAME; + } + String metType = "9j4852jyo3rjmh3owlhw9oe"; + if (this.componentMaterial != null) { + TextureSet u = this.componentMaterial.getTextureSet(); + if (u != null) { + metType = u.mSetName; + } + } + metType = (metType.equals("9j4852jyo3rjmh3owlhw9oe") ? "METALLIC" : metType); + return "gregtech" + ":" + "materialicons/" + metType + "/" + this.componentType.getOreDictName(); + + // return "gregtech" + ":" + "materialicons/"+metType+"/" + this.componentType.COMPONENT_NAME.toLowerCase(); + } + + /*@Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + + if (this.componentType == ComponentTypes.SMALLGEAR){ + return "Small " + this.materialName+" Gear"; + } + + if (this.componentMaterial != null) { + return (this.componentMaterial.getLocalizedName()+this.componentType.DISPLAY_NAME); + } + return this.materialName+" Cell"; + }*/ + + public final String getMaterialName() { + return this.materialName; + } + + @Override + public String getItemStackDisplayName(ItemStack stack) { + if (componentMaterial == null) { + String aFormattedLangName = componentType.getName(); + if (!aFormattedLangName.startsWith(" ")) { + if (aFormattedLangName.contains("@")) { + String[] aSplit = aFormattedLangName.split("@"); + aFormattedLangName = aSplit[0] + " " + getMaterialName() + " " + aSplit[1]; + } + } + if (aFormattedLangName.equals(componentType.getName())) { + aFormattedLangName = getMaterialName() + aFormattedLangName; + } + return GT_LanguageManager.addStringLocalization(unlocalName, aFormattedLangName); + } + String aFormattedLangName = componentType.getName(); + if (!aFormattedLangName.startsWith(" ")) { + if (aFormattedLangName.contains("@")) { + String[] aSplit = aFormattedLangName.split("@"); + aFormattedLangName = aSplit[0] + " " + componentMaterial.getLocalizedName() + " " + aSplit[1]; + } + } + if (aFormattedLangName.equals(componentType.getName())) { + aFormattedLangName = componentMaterial.getLocalizedName() + aFormattedLangName; + } + return GT_LanguageManager.addStringLocalization(unlocalName, aFormattedLangName); + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public final void addInformation( + final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + + try { + + if (this.componentMaterial == null) { + if (this.materialName != null) { + // list.add(Utils.sanitizeStringKeepBrackets(materialName)); + } + } + + if ((this.materialName != null) + && (this.materialName != "") + && !this.materialName.equals("") + && (this.componentMaterial != null)) { + + if (this.componentMaterial != null) { + if (!this.componentMaterial.vChemicalFormula.contains("?")) { + list.add(Utils.sanitizeStringKeepBrackets(this.componentMaterial.vChemicalFormula)); + } else if (this.componentMaterial.vChemicalFormula.contains("?")) { + String temp = componentMaterial.vChemicalFormula; + temp = temp.replace(" ", ""); + temp = temp.replace("-", ""); + temp = temp.replace("_", ""); + temp = temp.replace("!", ""); + temp = temp.replace("@", ""); + temp = temp.replace("#", ""); + temp = temp.replace(" ", ""); + list.add(temp); + } + + if (this.componentMaterial.isRadioactive) { + list.add(CORE.GT_Tooltip_Radioactive); + } + + if (this.componentType == ComponentTypes.INGOT || this.componentType == ComponentTypes.HOTINGOT) { + if ((this.materialName != null) + && (this.materialName != "") + && !this.materialName.equals("") + && this.unlocalName.toLowerCase().contains("hot")) { + list.add(EnumChatFormatting.GRAY + "Warning: " + EnumChatFormatting.RED + "Very hot! " + + EnumChatFormatting.GRAY + " Avoid direct handling.."); + } + } + } else { + String aChemicalFormula = Material.sChemicalFormula.get(materialName.toLowerCase()); + if (aChemicalFormula != null && aChemicalFormula.length() > 0) { + list.add(Utils.sanitizeStringKeepBrackets(aChemicalFormula)); + } + } + + // Hidden Tooltip + if (KeyboardUtils.isCtrlKeyDown()) { + if (this.componentMaterial != null) { + String type = this.componentMaterial.getTextureSet().mSetName; + String output = type.substring(0, 1).toUpperCase() + type.substring(1); + list.add(EnumChatFormatting.GRAY + "Material Type: " + output + "."); + list.add(EnumChatFormatting.GRAY + "Material State: " + + this.componentMaterial.getState().name() + "."); + list.add(EnumChatFormatting.GRAY + "Radioactivity Level: " + + this.componentMaterial.vRadiationLevel + "."); + } + } else { + list.add(EnumChatFormatting.DARK_GRAY + "Hold Ctrl to show additional info."); + } + } + } catch (Throwable t) { + } + + super.addInformation(stack, aPlayer, list, bool); + } + + @SuppressWarnings("unchecked") + @Override + public void onUpdate( + final ItemStack iStack, + final World world, + final Entity entityHolding, + final int p_77663_4_, + final boolean p_77663_5_) { + if (this.componentMaterial != null) { + if (entityHolding instanceof EntityPlayer) { + if (!((EntityPlayer) entityHolding).capabilities.isCreativeMode) { + EntityUtils.applyRadiationDamageToEntity( + iStack.stackSize, this.componentMaterial.vRadiationLevel, world, entityHolding); + } + } + } + + if (extraData != null) { + if (componentMaterial != null && componentMaterial.getRGBA()[3] > 1) { + if (((Map) extraData).get(9999) == null) { + ((Map) extraData).put(9999, new Short[] {0}); + } + Short aCurrentFrame = ((Map) extraData).get(9999)[0]; + short fC = (short) (aCurrentFrame >= Short.MAX_VALUE ? 0 : aCurrentFrame + 1); + ((Map) extraData).put((int) 9999, new Short[] {(short) (fC), 0}); + ((Map) extraData).put((int) 9998, new Short[] {aCurrentFrame, 0}); + } + } + } + + /** + * + * Handle Custom Rendering + * + */ + @Override + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses() { + return (CORE.ConfigSwitches.useGregtechTextures ? true : false); + } + + @SuppressWarnings("unchecked") + @Override + public int getColorFromItemStack(final ItemStack stack, final int renderPass) { + + if (this.componentType == ComponentTypes.CELL || this.componentType == ComponentTypes.PLASMACELL) { + if (renderPass == 0 && !CORE.ConfigSwitches.useGregtechTextures) { + return Utils.rgbtoHexValue(255, 255, 255); + } + if (renderPass == 1 && CORE.ConfigSwitches.useGregtechTextures) { + return Utils.rgbtoHexValue(255, 255, 255); + } + } + if (this.componentType == ComponentTypes.PLATEHEAVY) {} + + try { + if (this.componentMaterial == null) { + if (extraData != null) { + if (short.class.isInstance(extraData)) { + short[] abc = (short[]) extraData; + return Utils.rgbtoHexValue(abc[0], abc[1], abc[2]); + } + } + return this.componentColour; + } + + if (this.componentMaterial.getRGBA()[3] <= 1) { + return this.componentColour; + } else { + + // Mild Glow Effect + if (this.componentMaterial.getRGBA()[3] == 2) { + if (extraData == null) { + extraData = new HashMap(); + ((Map) extraData).put((int) Short.MAX_VALUE, new Short[] {0}); + ((Map) extraData).put((int) Short.MAX_VALUE - 1, new Short[] {0}); + short[] er = this.componentMaterial.getRGBA(); + short value = 0; + Short[] ht = new Short[] {er[0], er[1], er[2]}; + int aMaxCycles = 200; + for (int y = 0; y < aMaxCycles; y++) { + if (y < (50)) { + value = 1; + } else if (y < (100)) { + value = 0; + } else if (y < (150)) { + value = -1; + } else { + value = 0; + } + short r = (short) Math.max(Math.min(255, (ht[0] + value)), 0); + short g = (short) Math.max(Math.min(255, (ht[1] + value)), 0); + short b = (short) Math.max(Math.min(255, (ht[2] + value)), 0); + Short[] qq = new Short[] { + (short) Math.min(255, r), (short) Math.min(255, g), (short) Math.min(255, b) + }; + ht = qq; + ((Map) extraData).put(y, qq); + } + ((Map) extraData).put((int) Short.MAX_VALUE - 2, new Short[] { + (short) (((Map) extraData).size() - 1) + }); + } + if (extraData != null) { + + Short aCurrentFrame = ((Map) extraData).get((int) Short.MAX_VALUE)[0]; + Short aSize = (short) (((Map) extraData).size() - 3); + short nextFrame = (short) ((aCurrentFrame < aSize) ? (aCurrentFrame + 1) : 0); + Short[] aCurrentFrameRGB = ((Map) extraData) + .get(aCurrentFrame < aSize ? (int) aCurrentFrame : 0); + ((Map) extraData).put((int) Short.MAX_VALUE, new Short[] {nextFrame}); + return Utils.rgbtoHexValue(aCurrentFrameRGB[0], aCurrentFrameRGB[1], aCurrentFrameRGB[2]); + } + } + + // Rainbow Hue Cycle + else if (this.componentMaterial.getRGBA()[3] == 3) { + if (extraData == null) { + extraData = new HashMap(); + ((Map) extraData).put((int) Short.MAX_VALUE, new Short[] {0}); + ((Map) extraData).put((int) Short.MAX_VALUE - 1, new Short[] {0}); + int aSlot = 0; + + // Let's say you're starting with green: + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 0}); + // Slowly start adding in some red to get to yellow: + ((Map) extraData).put(aSlot++, new Short[] {51, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {51, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {51, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {51, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {51, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {51, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {51, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {51, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {51, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {51, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {51, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {51, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {51, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {51, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {51, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {51, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {51, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {51, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {102, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {153, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {204, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 255, 0}); + // Then, take out the green to get to red: + ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 204, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 153, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 102, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 51, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 0}); + // Now, add blue to get to purple: + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 51}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 102}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 153}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 204}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {255, 0, 255}); + // Then, remove red to get to blue: + ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {204, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {153, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {102, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {51, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {51, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {51, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {51, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {51, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {51, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {51, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {51, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {51, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {51, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {51, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {51, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {51, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {51, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {51, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {51, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {51, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {51, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 0, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 0, 255}); + // Add the green back in to get to cyan: + ((Map) extraData).put(aSlot++, new Short[] {0, 51, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 51, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 51, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 51, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 51, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 51, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 51, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 51, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 51, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 51, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 51, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 51, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 51, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 51, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 51, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 51, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 51, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 51, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 102, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 102, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 102, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 102, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 102, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 102, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 102, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 102, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 102, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 102, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 102, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 102, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 102, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 102, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 102, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 102, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 102, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 102, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 153, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 153, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 153, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 153, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 153, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 153, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 153, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 153, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 153, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 153, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 153, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 153, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 153, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 153, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 153, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 153, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 153, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 153, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 204, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 204, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 204, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 204, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 204, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 204, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 204, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 204, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 204, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 204, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 204, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 204, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 204, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 204, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 204, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 204, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 204, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 204, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 255}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 255}); + // And finally remove the blue to get back to green: + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 204}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 204}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 204}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 204}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 204}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 204}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 204}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 204}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 204}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 204}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 204}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 204}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 204}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 204}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 204}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 204}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 204}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 204}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 153}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 153}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 153}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 153}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 153}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 153}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 153}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 153}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 153}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 153}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 153}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 153}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 153}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 153}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 153}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 153}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 153}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 153}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 102}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 102}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 102}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 102}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 102}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 102}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 102}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 102}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 102}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 102}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 102}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 102}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 102}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 102}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 102}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 102}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 102}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 102}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 51}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 51}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 51}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 51}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 51}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 51}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 51}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 51}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 51}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 51}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 51}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 51}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 51}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 51}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 51}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 51}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 51}); + ((Map) extraData).put(aSlot++, new Short[] {0, 255, 51}); + ((Map) extraData).put((int) Short.MAX_VALUE - 2, new Short[] { + (short) (((Map) extraData).size() - 1) + }); + } + if (extraData != null) { + Short aCurrentFrame = ((Map) extraData).get((int) Short.MAX_VALUE)[0]; + Short aSize = (short) (((Map) extraData).size() - 3); + short nextFrame = (short) ((aCurrentFrame < aSize) ? (aCurrentFrame + 1) : 0); + Short[] aCurrentFrameRGB = ((Map) extraData) + .get(aCurrentFrame < aSize ? (int) aCurrentFrame : 0); + ((Map) extraData).put((int) Short.MAX_VALUE, new Short[] {nextFrame}); + return Utils.rgbtoHexValue(aCurrentFrameRGB[0], aCurrentFrameRGB[1], aCurrentFrameRGB[2]); + } + } + } + + } catch (Throwable t) { + + } + return this.componentColour; + } + + @Override + public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) { + if (CORE.ConfigSwitches.useGregtechTextures) { + if (pass == 0) { + return this.base; + } + return this.overlay; + } + return this.base; + } + + @Override + public void registerIcons(final IIconRegister i) { + + if (CORE.ConfigSwitches.useGregtechTextures) { + this.base = i.registerIcon(getCorrectTextures()); + this.overlay = i.registerIcon(getCorrectTextures() + "_OVERLAY"); + } else { + this.base = i.registerIcon(getCorrectTextures()); + // this.overlay = i.registerIcon(getCorrectTextures() + "_OVERLAY"); + } + } + + public static enum ComponentTypes { + DUST("Dust", " Dust", "dust", OrePrefixes.dust), + DUSTSMALL("DustSmall", "Small Pile of@Dust", "dustSmall", OrePrefixes.dustSmall), + DUSTTINY("DustTiny", "Tiny Pile of@Dust", "dustTiny", OrePrefixes.dustTiny), + INGOT("Ingot", " Ingot", "ingot", OrePrefixes.ingot), + HOTINGOT("HotIngot", "Hot@Ingot", "ingotHot", OrePrefixes.ingotHot), + PLATE("Plate", " Plate", "plate", OrePrefixes.plate), + PLATEDOUBLE("PlateDouble", " Double Plate", "plateDouble", OrePrefixes.plateDouble), + ROD("Rod", " Rod", "stick", OrePrefixes.stick), + RODLONG("RodLong", " Long Rod", "stickLong", OrePrefixes.stickLong), + GEAR("Gear", " Gear", "gearGt", OrePrefixes.gearGt), + SMALLGEAR("SmallGear", " Gear", "gearGtSmall", OrePrefixes.gearGtSmall), // TODO + SCREW("Screw", " Screw", "screw", OrePrefixes.screw), + BOLT("Bolt", " Bolt", "bolt", OrePrefixes.bolt), + ROTOR("Rotor", " Rotor", "rotor", OrePrefixes.rotor), + RING("Ring", " Ring", "ring", OrePrefixes.ring), + FOIL("Foil", " Foil", "foil", OrePrefixes.foil), + PLASMACELL("CellPlasma", " Plasma Cell", "cellPlasma", OrePrefixes.cellPlasma), + CELL("Cell", " Cell", "cell", OrePrefixes.cell), + NUGGET("Nugget", " Nugget", "nugget", OrePrefixes.nugget), + PLATEHEAVY("HeavyPlate", "Heavy@Plate", "plateHeavy", OrePrefixes.plateDense), + SPRING("Spring", " Spring", "spring", OrePrefixes.spring), + SMALLSPRING("SmallSpring", "Small@Spring", "springSmall", OrePrefixes.springSmall), + FINEWIRE("FineWire", "Fine@Wire", "wireFine", OrePrefixes.wireFine), + ; + + private String COMPONENT_NAME; + private String DISPLAY_NAME; + private String OREDICT_NAME; + private OrePrefixes a_GT_EQUAL; + + private ComponentTypes( + final String LocalName, final String DisplayName, final String OreDictName, final OrePrefixes aPrefix) { + this.COMPONENT_NAME = LocalName; + this.DISPLAY_NAME = DisplayName; + this.OREDICT_NAME = OreDictName; + this.a_GT_EQUAL = aPrefix; + } + + public String getComponent() { + return this.COMPONENT_NAME; + } + + public String getName() { + return this.DISPLAY_NAME; + } + + public String getOreDictName() { + return this.OREDICT_NAME; + } + + public OrePrefixes getGtOrePrefix() { + return this.a_GT_EQUAL; + } + } } - - diff --git a/src/main/java/gtPlusPlus/core/item/base/BaseItemDamageable.java b/src/main/java/gtPlusPlus/core/item/base/BaseItemDamageable.java index 4209ec0a59..d244d28967 100644 --- a/src/main/java/gtPlusPlus/core/item/base/BaseItemDamageable.java +++ b/src/main/java/gtPlusPlus/core/item/base/BaseItemDamageable.java @@ -1,11 +1,11 @@ package gtPlusPlus.core.item.base; -import java.util.List; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import java.util.List; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; @@ -14,188 +14,186 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; - public class BaseItemDamageable extends Item { - private final EnumRarity rarity; - private final String itemDescription; - protected String itemName; - private final boolean hasEffect; - - public BaseItemDamageable(final String unlocalizedName, final CreativeTabs creativeTab, final int stackSize, final int maxDmg, final String description, final EnumRarity regRarity, final EnumChatFormatting colour, final boolean Effect, final ItemStack OverrideItem) - { - this.setUnlocalizedName(unlocalizedName); - this.setTextureName(CORE.MODID + ":" + unlocalizedName); - this.setCreativeTab(creativeTab); - this.setMaxStackSize(1); - this.setMaxDamage(251); - this.setNoRepair(); - this.rarity = regRarity; - this.itemDescription = description; - this.hasEffect = Effect; - GameRegistry.registerItem(this, unlocalizedName); - } - - public String getItemDescription(){ - return this.itemDescription; - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - int dmg = (int) getItemDamage(stack); - if (dmg <= 3){ - list.add(EnumChatFormatting.GRAY+this.itemDescription); - } - if (dmg > 3 && dmg <= 25){ - list.add(EnumChatFormatting.GRAY+"You have discovered that smashing this against valuable stones has some function.."); - } - else if (dmg > 0){ - int maxDamage = 250; - list.add(EnumChatFormatting.GRAY+""+(maxDamage-getItemDamage(stack))+"/"+maxDamage+" gems remaining."); - } - } - - @Override - @SideOnly(Side.CLIENT) - public EnumRarity getRarity(final ItemStack par1ItemStack){ - int dmg = (int) getItemDamage(par1ItemStack); - if (dmg > 200){ - return EnumRarity.epic; - } - return this.rarity; - } - - @Override - public boolean hasEffect(final ItemStack par1ItemStack){ - int dmg = (int) getItemDamage(par1ItemStack); - if (dmg > 200){ - return true; - } - return this.hasEffect; - } - - @Override - public String getItemStackDisplayName(final ItemStack tItem) { - if ((this.itemName == null) || this.itemName.equals("")) { - return super.getItemStackDisplayName(tItem); - } - return this.itemName; - } - - private static boolean createNBT(ItemStack rStack){ - final NBTTagCompound tagMain = new NBTTagCompound(); - final NBTTagCompound tagNBT = new NBTTagCompound(); - tagNBT.setLong("Value", 0); - tagMain.setTag("Damage", tagNBT); - rStack.setTagCompound(tagMain); - return true; - } - - public static final long getItemDamage(final ItemStack aStack) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("Damage"); - if (aNBT != null) { - return aNBT.getLong("Value"); - } - } - else { - createNBT(aStack); - } - return 0L; - } - - public static final boolean setItemDamage(final ItemStack aStack, final long aDamage) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("Damage"); - if (aNBT != null) { - aNBT.setLong("Value", aDamage); - return true; - } - } - else { - createNBT(aStack); - } - return false; - } - - @Override - public double getDurabilityForDisplay(ItemStack stack) { - if (stack.getTagCompound() == null){ - createNBT(stack); - } - double currentDamage = getItemDamage(stack); - double durabilitypercent = currentDamage / 100; - double inverse = (100-durabilitypercent); - return durabilitypercent; - } - - @Override - public boolean showDurabilityBar(ItemStack stack) { - int dmg = (int) getItemDamage(stack); - if (dmg <= 20){ - return false; - } - else { - return true; - } - } - - public static ItemStack damageItem(ItemStack item){ - if (item != null){ - long currentUse = BaseItemDamageable.getItemDamage(item); - if (currentUse >= 0 && currentUse <= 250){ - BaseItemDamageable.setItemDamage(item, currentUse+1); - return item; - } - else { - return item; - } - } - return null; - } - - @Override - public boolean doesContainerItemLeaveCraftingGrid(ItemStack stack) { - Logger.INFO("Does Leave Table? "+stack.getDisplayName()); - return true; - } - - @Override - public boolean getShareTag() { - return true; - } - - @Override - public boolean hasContainerItem() { - return true; - } - - @Override - public boolean hasContainerItem(ItemStack stack) { - Logger.INFO("hasContainerItem? "+stack.getDisplayName()); - return true; - } - - @Override - public ItemStack getContainerItem(ItemStack itemStack) { - ItemStack stack = itemStack.copy(); - //stack.setItemDamage(stack.getItemDamage() + 1); - damageItem(stack); - stack.stackSize = 1; - return stack; - } - - @Override - public int getDamage(ItemStack stack) { - return (int) getItemDamage(stack); - } - + private final EnumRarity rarity; + private final String itemDescription; + protected String itemName; + private final boolean hasEffect; + + public BaseItemDamageable( + final String unlocalizedName, + final CreativeTabs creativeTab, + final int stackSize, + final int maxDmg, + final String description, + final EnumRarity regRarity, + final EnumChatFormatting colour, + final boolean Effect, + final ItemStack OverrideItem) { + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setCreativeTab(creativeTab); + this.setMaxStackSize(1); + this.setMaxDamage(251); + this.setNoRepair(); + this.rarity = regRarity; + this.itemDescription = description; + this.hasEffect = Effect; + GameRegistry.registerItem(this, unlocalizedName); + } + + public String getItemDescription() { + return this.itemDescription; + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + int dmg = (int) getItemDamage(stack); + if (dmg <= 3) { + list.add(EnumChatFormatting.GRAY + this.itemDescription); + } + if (dmg > 3 && dmg <= 25) { + list.add(EnumChatFormatting.GRAY + + "You have discovered that smashing this against valuable stones has some function.."); + } else if (dmg > 0) { + int maxDamage = 250; + list.add(EnumChatFormatting.GRAY + "" + (maxDamage - getItemDamage(stack)) + "/" + maxDamage + + " gems remaining."); + } + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(final ItemStack par1ItemStack) { + int dmg = (int) getItemDamage(par1ItemStack); + if (dmg > 200) { + return EnumRarity.epic; + } + return this.rarity; + } + + @Override + public boolean hasEffect(final ItemStack par1ItemStack) { + int dmg = (int) getItemDamage(par1ItemStack); + if (dmg > 200) { + return true; + } + return this.hasEffect; + } + + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + if ((this.itemName == null) || this.itemName.equals("")) { + return super.getItemStackDisplayName(tItem); + } + return this.itemName; + } + + private static boolean createNBT(ItemStack rStack) { + final NBTTagCompound tagMain = new NBTTagCompound(); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setLong("Value", 0); + tagMain.setTag("Damage", tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public static final long getItemDamage(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("Damage"); + if (aNBT != null) { + return aNBT.getLong("Value"); + } + } else { + createNBT(aStack); + } + return 0L; + } + + public static final boolean setItemDamage(final ItemStack aStack, final long aDamage) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("Damage"); + if (aNBT != null) { + aNBT.setLong("Value", aDamage); + return true; + } + } else { + createNBT(aStack); + } + return false; + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + if (stack.getTagCompound() == null) { + createNBT(stack); + } + double currentDamage = getItemDamage(stack); + double durabilitypercent = currentDamage / 100; + double inverse = (100 - durabilitypercent); + return durabilitypercent; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + int dmg = (int) getItemDamage(stack); + if (dmg <= 20) { + return false; + } else { + return true; + } + } + + public static ItemStack damageItem(ItemStack item) { + if (item != null) { + long currentUse = BaseItemDamageable.getItemDamage(item); + if (currentUse >= 0 && currentUse <= 250) { + BaseItemDamageable.setItemDamage(item, currentUse + 1); + return item; + } else { + return item; + } + } + return null; + } + + @Override + public boolean doesContainerItemLeaveCraftingGrid(ItemStack stack) { + Logger.INFO("Does Leave Table? " + stack.getDisplayName()); + return true; + } + + @Override + public boolean getShareTag() { + return true; + } + + @Override + public boolean hasContainerItem() { + return true; + } + + @Override + public boolean hasContainerItem(ItemStack stack) { + Logger.INFO("hasContainerItem? " + stack.getDisplayName()); + return true; + } + + @Override + public ItemStack getContainerItem(ItemStack itemStack) { + ItemStack stack = itemStack.copy(); + // stack.setItemDamage(stack.getItemDamage() + 1); + damageItem(stack); + stack.stackSize = 1; + return stack; + } + + @Override + public int getDamage(ItemStack stack) { + return (int) getItemDamage(stack); + } } - - - diff --git a/src/main/java/gtPlusPlus/core/item/base/BaseItemGeneric.java b/src/main/java/gtPlusPlus/core/item/base/BaseItemGeneric.java index 970d5ec0c8..65ed54f520 100644 --- a/src/main/java/gtPlusPlus/core/item/base/BaseItemGeneric.java +++ b/src/main/java/gtPlusPlus/core/item/base/BaseItemGeneric.java @@ -1,28 +1,24 @@ package gtPlusPlus.core.item.base; +import gtPlusPlus.core.lib.CORE; import java.util.List; - import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import gtPlusPlus.core.lib.CORE; - -public class BaseItemGeneric extends Item -{ - public BaseItemGeneric(final String unlocalizedName, final CreativeTabs c, final int stackSize, final int maxDmg) - { - this.setUnlocalizedName(CORE.MODID + "_" + unlocalizedName); - this.setTextureName(CORE.MODID + ":" + unlocalizedName); - this.setCreativeTab(c); - this.setMaxStackSize(stackSize); - this.setMaxDamage(maxDmg); - } +public class BaseItemGeneric extends Item { + public BaseItemGeneric(final String unlocalizedName, final CreativeTabs c, final int stackSize, final int maxDmg) { + this.setUnlocalizedName(CORE.MODID + "_" + unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setCreativeTab(c); + this.setMaxStackSize(stackSize); + this.setMaxDamage(maxDmg); + } - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - super.addInformation(stack, aPlayer, list, bool); - } -} \ No newline at end of file + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + super.addInformation(stack, aPlayer, list, bool); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/BaseItemLoot.java b/src/main/java/gtPlusPlus/core/item/base/BaseItemLoot.java index 3d9ff9fa48..23783d69f7 100644 --- a/src/main/java/gtPlusPlus/core/item/base/BaseItemLoot.java +++ b/src/main/java/gtPlusPlus/core/item/base/BaseItemLoot.java @@ -1,109 +1,104 @@ package gtPlusPlus.core.item.base; +import gregtech.api.enums.Materials; +import gtPlusPlus.api.enums.Quality; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.ItemUtils; import java.util.List; - import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import gregtech.api.enums.Materials; - -import gtPlusPlus.api.enums.Quality; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.minecraft.ItemUtils; - -public class BaseItemLoot extends Item{ - - private final String materialName; - private final String unlocalName; - private final LootTypes lootTypes; - private Quality lootQuality; - private final Materials lootMaterial; - - public BaseItemLoot(final LootTypes lootType, final Materials material) { - this.lootTypes = lootType; - this.lootMaterial = material; - this.materialName = material.mDefaultLocalName; - this.unlocalName = "item"+lootType.LOOT_TYPE+this.materialName; - this.setUnlocalizedName(this.unlocalName); - this.setMaxStackSize(1); - this.setTextureName(CORE.MODID + ":" + "item"+lootType.LOOT_TYPE); - } - - public ItemStack generateLootStack(){ - this.lootQuality = Quality.getRandomQuality(); - return ItemUtils.getSimpleStack(this, 1); - } - - @Override - public String getItemStackDisplayName(final ItemStack p_77653_1_) { - return (this.materialName+this.lootTypes.DISPLAY_SUFFIX); - } - - public final String getMaterialName() { - return this.materialName; - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - list.add(this.lootQuality.getQuality()); - - /*if (componentMaterial.isRadioactive){ - list.add(CORE.GT_Tooltip_Radioactive); - }*/ - - super.addInformation(stack, aPlayer, list, bool); - } - - - @Override - public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { - final short[] temp = this.lootMaterial.mRGBa; - return Utils.rgbtoHexValue(temp[0], temp[1], temp[2]); - } - - @Override - public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, final boolean p_77663_5_) { - //EntityUtils.applyRadiationDamageToEntity(lootQuality.vRadioationLevel, world, entityHolding); - } - - - - - - - - - public static enum LootTypes { - Sword("Sword", " Longsword", "sword"), - Shortsword("Sword", " Short Blade", "blade"), - Helmet("Helmet", " Medium Helm", "helmet"), - Chestplate("Platebody", " Chestplate", "platebody"), - Leggings("Platelegs", " Platelegs", "platelegs"), - Boots("Boots", " Boots", "boots"); - private String LOOT_TYPE; - private String DISPLAY_SUFFIX; - private String OREDICT_NAME; - private LootTypes (final String LocalName, final String DisplayName, final String OreDictName){ - this.LOOT_TYPE = LocalName; - this.DISPLAY_SUFFIX = DisplayName; - this.OREDICT_NAME = OreDictName; - } - public String getLootType(){ - return this.LOOT_TYPE; - } - public String getName(){ - return this.DISPLAY_SUFFIX; - } - public String getOreDictName(){ - return this.OREDICT_NAME; - } - } - +public class BaseItemLoot extends Item { + + private final String materialName; + private final String unlocalName; + private final LootTypes lootTypes; + private Quality lootQuality; + private final Materials lootMaterial; + + public BaseItemLoot(final LootTypes lootType, final Materials material) { + this.lootTypes = lootType; + this.lootMaterial = material; + this.materialName = material.mDefaultLocalName; + this.unlocalName = "item" + lootType.LOOT_TYPE + this.materialName; + this.setUnlocalizedName(this.unlocalName); + this.setMaxStackSize(1); + this.setTextureName(CORE.MODID + ":" + "item" + lootType.LOOT_TYPE); + } + + public ItemStack generateLootStack() { + this.lootQuality = Quality.getRandomQuality(); + return ItemUtils.getSimpleStack(this, 1); + } + + @Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + return (this.materialName + this.lootTypes.DISPLAY_SUFFIX); + } + + public final String getMaterialName() { + return this.materialName; + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add(this.lootQuality.getQuality()); + + /*if (componentMaterial.isRadioactive){ + list.add(CORE.GT_Tooltip_Radioactive); + }*/ + + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + final short[] temp = this.lootMaterial.mRGBa; + return Utils.rgbtoHexValue(temp[0], temp[1], temp[2]); + } + + @Override + public void onUpdate( + final ItemStack iStack, + final World world, + final Entity entityHolding, + final int p_77663_4_, + final boolean p_77663_5_) { + // EntityUtils.applyRadiationDamageToEntity(lootQuality.vRadioationLevel, world, entityHolding); + } + + public static enum LootTypes { + Sword("Sword", " Longsword", "sword"), + Shortsword("Sword", " Short Blade", "blade"), + Helmet("Helmet", " Medium Helm", "helmet"), + Chestplate("Platebody", " Chestplate", "platebody"), + Leggings("Platelegs", " Platelegs", "platelegs"), + Boots("Boots", " Boots", "boots"); + private String LOOT_TYPE; + private String DISPLAY_SUFFIX; + private String OREDICT_NAME; + + private LootTypes(final String LocalName, final String DisplayName, final String OreDictName) { + this.LOOT_TYPE = LocalName; + this.DISPLAY_SUFFIX = DisplayName; + this.OREDICT_NAME = OreDictName; + } + + public String getLootType() { + return this.LOOT_TYPE; + } + + public String getName() { + return this.DISPLAY_SUFFIX; + } + + public String getOreDictName() { + return this.OREDICT_NAME; + } + } } - - diff --git a/src/main/java/gtPlusPlus/core/item/base/BaseItemTCShard.java b/src/main/java/gtPlusPlus/core/item/base/BaseItemTCShard.java index 4f0db3e2ec..1022061db5 100644 --- a/src/main/java/gtPlusPlus/core/item/base/BaseItemTCShard.java +++ b/src/main/java/gtPlusPlus/core/item/base/BaseItemTCShard.java @@ -1,9 +1,12 @@ package gtPlusPlus.core.item.base; -import java.util.List; - import cpw.mods.fml.common.registry.GameRegistry; - +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import java.util.List; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -11,72 +14,64 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; -import gregtech.api.util.GT_OreDictUnificator; - -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.minecraft.ItemUtils; - -public class BaseItemTCShard extends Item{ - - public final String unlocalName; - public final String displayName; - public final String descriptionString; - public final String descriptionString2; - public final int itemColour; - - public BaseItemTCShard(final String DisplayName, final int colour) { - this(DisplayName, colour, ""); - } - - public BaseItemTCShard(final String DisplayName, final int colour, final String Description) { - this(DisplayName, colour, "", Description); - } - - public BaseItemTCShard(final String DisplayName, final int colour, final String Description, final String Description2) { - this.unlocalName = "item"+Utils.sanitizeString(DisplayName); - this.displayName = DisplayName; - this.itemColour = colour; - this.descriptionString = Description; - this.descriptionString2 = Description2; - this.setCreativeTab(AddToCreativeTab.tabMisc); - this.setUnlocalizedName(this.unlocalName); - this.setMaxStackSize(64); - this.setTextureName(CORE.MODID + ":" + "itemShard"); - GameRegistry.registerItem(this, this.unlocalName); - GT_OreDictUnificator.registerOre("shard"+DisplayName, ItemUtils.getSimpleStack(this)); - GT_OreDictUnificator.registerOre("gemInfused"+DisplayName, ItemUtils.getSimpleStack(this)); - } - - @Override - public String getItemStackDisplayName(final ItemStack p_77653_1_) { - return (this.displayName+" Shard"); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - if ((this.descriptionString != "") || !this.descriptionString.equals("")){ - list.add(EnumChatFormatting.GRAY+this.descriptionString); - } - if ((this.descriptionString2 != "") || !this.descriptionString2.equals("")){ - list.add(EnumChatFormatting.GRAY+this.descriptionString2); - } - } - - - @Override - public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { - return this.itemColour; - } - - @Override - public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, final boolean p_77663_5_) { - - } - - +public class BaseItemTCShard extends Item { + + public final String unlocalName; + public final String displayName; + public final String descriptionString; + public final String descriptionString2; + public final int itemColour; + + public BaseItemTCShard(final String DisplayName, final int colour) { + this(DisplayName, colour, ""); + } + + public BaseItemTCShard(final String DisplayName, final int colour, final String Description) { + this(DisplayName, colour, "", Description); + } + + public BaseItemTCShard( + final String DisplayName, final int colour, final String Description, final String Description2) { + this.unlocalName = "item" + Utils.sanitizeString(DisplayName); + this.displayName = DisplayName; + this.itemColour = colour; + this.descriptionString = Description; + this.descriptionString2 = Description2; + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(this.unlocalName); + this.setMaxStackSize(64); + this.setTextureName(CORE.MODID + ":" + "itemShard"); + GameRegistry.registerItem(this, this.unlocalName); + GT_OreDictUnificator.registerOre("shard" + DisplayName, ItemUtils.getSimpleStack(this)); + GT_OreDictUnificator.registerOre("gemInfused" + DisplayName, ItemUtils.getSimpleStack(this)); + } + + @Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + return (this.displayName + " Shard"); + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + if ((this.descriptionString != "") || !this.descriptionString.equals("")) { + list.add(EnumChatFormatting.GRAY + this.descriptionString); + } + if ((this.descriptionString2 != "") || !this.descriptionString2.equals("")) { + list.add(EnumChatFormatting.GRAY + this.descriptionString2); + } + } + + @Override + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + return this.itemColour; + } + + @Override + public void onUpdate( + final ItemStack iStack, + final World world, + final Entity entityHolding, + final int p_77663_4_, + final boolean p_77663_5_) {} } - - diff --git a/src/main/java/gtPlusPlus/core/item/base/BaseItemTickable.java b/src/main/java/gtPlusPlus/core/item/base/BaseItemTickable.java index eb066024e0..03c580a9c3 100644 --- a/src/main/java/gtPlusPlus/core/item/base/BaseItemTickable.java +++ b/src/main/java/gtPlusPlus/core/item/base/BaseItemTickable.java @@ -1,10 +1,12 @@ package gtPlusPlus.core.item.base; -import java.util.List; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -14,328 +16,323 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; import net.minecraft.world.World; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; public class BaseItemTickable extends CoreItem { - public final String[] descriptionString; - public final int itemColour; - public final int maxTicks; - public final boolean twoRenderPasses; - public final boolean ticksInContainers; - - public IIcon[] mIcon = new IIcon[2]; - - public BaseItemTickable(boolean twoPass, final String unlocalName, final int colour, final int maxTicks) { - this(false, twoPass, unlocalName, colour, maxTicks, new String[] {}); - } - - public BaseItemTickable(boolean containerTick, boolean twoPass, final String unlocalName, final int colour, final int maxTicks) { - this(containerTick, twoPass, unlocalName, colour, maxTicks, new String[] {}); - } - - public BaseItemTickable(boolean containerTick, boolean twoPass, final String unlocalName, final int colour, final int maxTicks, final String[] Description) { - super(unlocalName, AddToCreativeTab.tabMisc, 1, 999999999, Description, EnumRarity.epic, EnumChatFormatting.DARK_RED, true, null); - this.itemColour = colour; - this.descriptionString = Description; - this.maxTicks = maxTicks; - this.twoRenderPasses = twoPass; - this.ticksInContainers = containerTick; - this.maxStackSize = 1; - //setGregtechItemList(); - } - - @Override - public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, final boolean p_77663_5_) { - if (world == null || iStack == null) { - return; - } - if (world.isRemote) { - return; - } - - - boolean active = isTicking(world, iStack); - if (active) { - tickItemTag(world, iStack); - } - - } - - /*private final boolean setGregtechItemList() { - ItemList.Component_LavaFilter.set(this); - return ItemList.Component_LavaFilter.get(1) != null ? true : false; - }*/ - - /** - * - * Handle Custom Rendering - * - */ - - @Override - @SideOnly(Side.CLIENT) - public boolean requiresMultipleRenderPasses(){ - return this.twoRenderPasses; - } - - @Override - public int getColorFromItemStack(final ItemStack stack, final int renderPass) { - if (renderPass == 1 && this.twoRenderPasses){ - return Utils.rgbtoHexValue(255, 255, 255); - } - return this.itemColour; - } - - @Override - public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) { - if (this.twoRenderPasses) { - if(pass == 0) { - return this.mIcon[0]; - } - return this.mIcon[1]; - } - return this.mIcon[0]; - } - - @Override - public void registerIcons(final IIconRegister i) { - - if (this.twoRenderPasses){ - this.mIcon[0] = i.registerIcon(CORE.MODID + ":" + this.getUnlocalizedName()); - this.mIcon[1] = i.registerIcon(CORE.MODID + ":" + this.getUnlocalizedName() + "_OVERLAY"); - } - else { - this.mIcon[0] = i.registerIcon(CORE.MODID + ":" + this.getUnlocalizedName()); - //this.overlay = i.registerIcon(getCorrectTextures() + "_OVERLAY"); - } - } - - protected int getMaxTicks(ItemStack aStack) { - return maxTicks; - } - - protected boolean createNBT(World world, ItemStack rStack){ - final NBTTagCompound tagMain = new NBTTagCompound(); - final NBTTagCompound tagNBT = new NBTTagCompound(); - tagNBT.setLong("Tick", 0); - tagNBT.setLong("maxTick", getMaxTicks(rStack)); - tagNBT.setBoolean("isActive", true); - - //Try set world time - if (world != null) { - //tagNBT.setLong("CreationDate", world.getTotalWorldTime()); - } - - tagMain.setTag("TickableItem", tagNBT); - rStack.setTagCompound(tagMain); - Logger.INFO("Created Tickable NBT data."); - return true; - } - - public final long getTicks(World world, final ItemStack aStack) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("TickableItem"); - if (aNBT != null) { - return aNBT.getLong("Tick"); - } - } - else { - createNBT(world, aStack); - } - return 0L; - } - - public final boolean setTicks(World world, final ItemStack aStack, final long aDamage) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("TickableItem"); - if (aNBT != null) { - aNBT.setLong("Tick", aDamage); - return true; - } - } - else { - createNBT(world, aStack); - } - return false; - } - - public final boolean isTicking(World world, final ItemStack aStack) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("TickableItem"); - if (aNBT != null) { - return aNBT.getBoolean("isActive"); - } - } - else { - return createNBT(world, aStack); - } - return true; - } - - public final boolean setTicking(World world, final ItemStack aStack, final boolean active) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("TickableItem"); - if (aNBT != null) { - aNBT.setBoolean("isActive", active); - return true; - } - } - else { - createNBT(world, aStack); - } - return false; - } - - public final boolean getTicksInContainer(World world, final ItemStack aStack) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("TickableItem"); - if (aNBT != null) { - return aNBT.getBoolean("ticksInContainer"); - } - } - else { - createNBT(world, aStack); - } - return false; - } - - public final boolean setTicksInContainer(World world, final ItemStack aStack, final boolean active) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("TickableItem"); - if (aNBT != null) { - aNBT.setBoolean("ticksInContainer", active); - return true; - } - } - else { - createNBT(world, aStack); - } - return false; - } - - public final long getDifferenceInWorldTimeToCreationTime(World world, final ItemStack aStack) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("TickableItem"); - if (aNBT != null) { - return (world.getTotalWorldTime() - aNBT.getLong("CreationDate")); - } - } - else { - createNBT(world, aStack); - } - return 0L; - } - - public final boolean setItemStackCreationTime(final ItemStack aStack, World world) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("TickableItem"); - if (aNBT != null) { - aNBT.setLong("CreationDate", world.getTotalWorldTime()); - return true; - } - } - else { - createNBT(world, aStack); - } - return false; - } - - public final boolean tickItemTag(World world, ItemStack aStack) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - if (aNBT.hasKey("TickableItem")) { - aNBT = aNBT.getCompoundTag("TickableItem"); - //Done Ticking - if (getMaxTicks(aStack)-getTicks(world, aStack) <= 0) { - setTicking(world, aStack, false); - return false; - } - if (isTicking(world, aStack)) { - if (aNBT != null) { - aNBT.setLong("Tick", getTicks(world, aStack)+1); - return true; - } - else { - return false; - } - } - else { - return false; - } - } - } - return createNBT(world, aStack); - } - - @Override - public double getDurabilityForDisplay(ItemStack stack) { - if (stack.getTagCompound() == null){ - //createNBT(null, stack); - return 0; - } - double currentDamage = getTicks(null, stack); - double durabilitypercent = currentDamage / getMaxTicks(stack); - return durabilitypercent; - } - - @SuppressWarnings("unchecked") - @Override - public void addInformation(ItemStack stack, EntityPlayer player, @SuppressWarnings("rawtypes") List list, boolean bool) { - World world = player.getEntityWorld(); - if (this.descriptionString.length > 0) { - list.add(EnumChatFormatting.GRAY+this.descriptionString[0]); - } - long maxTicks = getMaxTicks(stack); - long ticks = 0; - if (stack.hasTagCompound()) { - ticks = getTicks(world, stack); - } - EnumChatFormatting durability = EnumChatFormatting.GRAY; - if (maxTicks-ticks > (maxTicks*0.8)){ - durability = EnumChatFormatting.GRAY; - } - else if (maxTicks-ticks > (maxTicks*0.6)){ - durability = EnumChatFormatting.GREEN; - } - else if (maxTicks-ticks > (maxTicks*0.4)){ - durability = EnumChatFormatting.YELLOW; - } - else if (maxTicks-ticks > (maxTicks*0.2)){ - durability = EnumChatFormatting.GOLD; - } - else if (maxTicks-ticks > 0){ - durability = EnumChatFormatting.RED; - } - list.add(durability+""+((maxTicks-ticks)/20)+EnumChatFormatting.GRAY+" seconds until decay"); - - if (this.descriptionString.length > 1) { - for (int h=1;h 0) { + list.add(EnumChatFormatting.GRAY + this.descriptionString[0]); + } + long maxTicks = getMaxTicks(stack); + long ticks = 0; + if (stack.hasTagCompound()) { + ticks = getTicks(world, stack); + } + EnumChatFormatting durability = EnumChatFormatting.GRAY; + if (maxTicks - ticks > (maxTicks * 0.8)) { + durability = EnumChatFormatting.GRAY; + } else if (maxTicks - ticks > (maxTicks * 0.6)) { + durability = EnumChatFormatting.GREEN; + } else if (maxTicks - ticks > (maxTicks * 0.4)) { + durability = EnumChatFormatting.YELLOW; + } else if (maxTicks - ticks > (maxTicks * 0.2)) { + durability = EnumChatFormatting.GOLD; + } else if (maxTicks - ticks > 0) { + durability = EnumChatFormatting.RED; + } + list.add(durability + "" + ((maxTicks - ticks) / 20) + EnumChatFormatting.GRAY + " seconds until decay"); + + if (this.descriptionString.length > 1) { + for (int h = 1; h < this.descriptionString.length; h++) { + list.add(EnumChatFormatting.GRAY + this.descriptionString[h]); + } + } + + // super.addInformation(stack, player, list, bool); + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } } - - diff --git a/src/main/java/gtPlusPlus/core/item/base/BaseItemWithCharge.java b/src/main/java/gtPlusPlus/core/item/base/BaseItemWithCharge.java index d81112e0c6..5c9bf62455 100644 --- a/src/main/java/gtPlusPlus/core/item/base/BaseItemWithCharge.java +++ b/src/main/java/gtPlusPlus/core/item/base/BaseItemWithCharge.java @@ -1,7 +1,8 @@ package gtPlusPlus.core.item.base; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; import java.util.List; - import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -10,67 +11,63 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; - -public class BaseItemWithCharge extends Item{ - - public int int_Charge = 0; - public int int_Max_Charge = 0; - - public BaseItemWithCharge(final String unlocalizedName, final int constructor_Charge, final int constructor_Max_Charge) { - this.setUnlocalizedName(unlocalizedName); - this.setTextureName(CORE.MODID + ":" + unlocalizedName); - this.setMaxStackSize(1); - this.setCreativeTab(AddToCreativeTab.tabMachines); - this.int_Charge = constructor_Charge; - this.int_Max_Charge = constructor_Max_Charge; - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - int NBT_Charge = this.int_Charge; - int NBT_Max_Charge = this.int_Max_Charge; - if (stack.stackTagCompound != null) { - NBT_Charge = stack.stackTagCompound.getInteger("charge_Current"); - NBT_Max_Charge = stack.stackTagCompound.getInteger("charge_Max"); - final String tempX = String.valueOf(NBT_Charge); - final String tempY = String.valueOf(NBT_Max_Charge); - final String formattedX = EnumChatFormatting.RED+tempX+EnumChatFormatting.GRAY; - final String formattedY = EnumChatFormatting.DARK_RED+tempY+EnumChatFormatting.GRAY; - list.add(EnumChatFormatting.GRAY+"Charge:"+formattedX+"/"+formattedY+"."); - super.addInformation(stack, aPlayer, list, bool); - } - } - - //Ticking and NBT Handling - /* Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and - * update it's contents. - * - * public int fuelRemaining = 0; - public int maximumFuel = 0; - public String fuelType = ""; - public float heat = 0; - public float maxHeat = 5000; - * - */ - @Override - public void onCreated(final ItemStack itemStack, final World world, final EntityPlayer player) { - - } +public class BaseItemWithCharge extends Item { - @Override - public void onUpdate(final ItemStack itemStack, final World par2World, final Entity par3Entity, final int par4, final boolean par5) { + public int int_Charge = 0; + public int int_Max_Charge = 0; - } + public BaseItemWithCharge( + final String unlocalizedName, final int constructor_Charge, final int constructor_Max_Charge) { + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setMaxStackSize(1); + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.int_Charge = constructor_Charge; + this.int_Max_Charge = constructor_Max_Charge; + } - @Override - public ItemStack onItemRightClick(final ItemStack itemStack, final World world, final EntityPlayer par3Entity) { - itemStack.stackTagCompound = new NBTTagCompound(); - return super.onItemRightClick(itemStack, world, par3Entity); - } + @SuppressWarnings({"rawtypes", "unchecked"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + int NBT_Charge = this.int_Charge; + int NBT_Max_Charge = this.int_Max_Charge; + if (stack.stackTagCompound != null) { + NBT_Charge = stack.stackTagCompound.getInteger("charge_Current"); + NBT_Max_Charge = stack.stackTagCompound.getInteger("charge_Max"); + final String tempX = String.valueOf(NBT_Charge); + final String tempY = String.valueOf(NBT_Max_Charge); + final String formattedX = EnumChatFormatting.RED + tempX + EnumChatFormatting.GRAY; + final String formattedY = EnumChatFormatting.DARK_RED + tempY + EnumChatFormatting.GRAY; + list.add(EnumChatFormatting.GRAY + "Charge:" + formattedX + "/" + formattedY + "."); + super.addInformation(stack, aPlayer, list, bool); + } + } + // Ticking and NBT Handling + /* Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and + * update it's contents. + * + * public int fuelRemaining = 0; + public int maximumFuel = 0; + public String fuelType = ""; + public float heat = 0; + public float maxHeat = 5000; + * + */ + @Override + public void onCreated(final ItemStack itemStack, final World world, final EntityPlayer player) {} + @Override + public void onUpdate( + final ItemStack itemStack, + final World par2World, + final Entity par3Entity, + final int par4, + final boolean par5) {} + @Override + public ItemStack onItemRightClick(final ItemStack itemStack, final World world, final EntityPlayer par3Entity) { + itemStack.stackTagCompound = new NBTTagCompound(); + return super.onItemRightClick(itemStack, world, par3Entity); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/BaseItemWithDamageValue.java b/src/main/java/gtPlusPlus/core/item/base/BaseItemWithDamageValue.java index 14597ae876..383fdefaee 100644 --- a/src/main/java/gtPlusPlus/core/item/base/BaseItemWithDamageValue.java +++ b/src/main/java/gtPlusPlus/core/item/base/BaseItemWithDamageValue.java @@ -1,27 +1,27 @@ package gtPlusPlus.core.item.base; +import gtPlusPlus.core.lib.CORE; import java.util.List; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import gtPlusPlus.core.lib.CORE; +public class BaseItemWithDamageValue extends Item { + public BaseItemWithDamageValue(final String unlocalizedName) { + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setMaxStackSize(1); + this.setMaxDamage(100); + } + + @Override + public void setDamage(final ItemStack stack, final int damage) { + super.setDamage(stack, damage); + } -public class BaseItemWithDamageValue extends Item{ - public BaseItemWithDamageValue(final String unlocalizedName) { - this.setUnlocalizedName(unlocalizedName); - this.setTextureName(CORE.MODID + ":" + unlocalizedName); - this.setMaxStackSize(1); - this.setMaxDamage(100); - } - @Override - public void setDamage(final ItemStack stack, final int damage) { - super.setDamage(stack, damage); - } - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - super.addInformation(stack, aPlayer, list, bool); - } -} \ No newline at end of file + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + super.addInformation(stack, aPlayer, list, bool); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/BasicSpawnEgg.java b/src/main/java/gtPlusPlus/core/item/base/BasicSpawnEgg.java index 57d42d721e..5e8b7964b8 100644 --- a/src/main/java/gtPlusPlus/core/item/base/BasicSpawnEgg.java +++ b/src/main/java/gtPlusPlus/core/item/base/BasicSpawnEgg.java @@ -1,11 +1,10 @@ package gtPlusPlus.core.item.base; - -import java.util.List; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.creative.AddToCreativeTab; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.block.BlockLiquid; import net.minecraft.client.renderer.texture.IIconRegister; @@ -18,237 +17,222 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.*; import net.minecraft.world.World; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.creative.AddToCreativeTab; - - - -public class BasicSpawnEgg extends ItemMonsterPlacer -{ - @SideOnly(Side.CLIENT) - private IIcon theIcon; - protected int colorBase = 0x000000; - protected int colorSpots = 0xFFFFFF; - protected String entityMODID = ""; - protected String entityToSpawnName = ""; - protected String entityToSpawnNameFull = ""; - protected EntityLiving entityToSpawn = null; - - public BasicSpawnEgg(){ - super(); - } - - public BasicSpawnEgg(final String MODID, final String parEntityToSpawnName, final int parPrimaryColor, final int parSecondaryColor){ - this.setHasSubtypes(false); - this.maxStackSize = 64; - this.setCreativeTab(AddToCreativeTab.tabOther); - this.setEntityToSpawnName(parEntityToSpawnName); - this.colorBase = parPrimaryColor; - this.colorSpots = parSecondaryColor; - this.entityMODID = MODID; - - // DEBUG - Logger.WARNING("Spawn egg constructor for "+this.entityToSpawnName); - } - - /** - * Callback for item usage. If the item does something special on right clicking, - - * he will have one of those. Return - * True if something happen and false if it don't. This is for ITEMS, not BLOCKS - */ - @Override - public boolean onItemUse(final ItemStack par1ItemStack, final EntityPlayer par2EntityPlayer, final World par3World, int par4, int par5, int par6, final int par7, final float par8, final float par9, final float par10){ - if (par3World.isRemote) - { - return true; - } - final Block block = par3World.getBlock(par4, par5, par6); - par4 += Facing.offsetsXForSide[par7]; - par5 += Facing.offsetsYForSide[par7]; - par6 += Facing.offsetsZForSide[par7]; - double d0 = 0.0D; - - if ((par7 == 1) && (block.getRenderType() == 11)) - { - d0 = 0.5D; - } - - final Entity entity = this.spawnEntity(par3World, par4 + 0.5D, par5 + d0, par6 + 0.5D); - - if (entity != null) - { - if ((entity instanceof EntityLivingBase) && par1ItemStack.hasDisplayName()) - { - ((EntityLiving)entity).setCustomNameTag(par1ItemStack.getDisplayName()); - } - - if (!par2EntityPlayer.capabilities.isCreativeMode) - { - --par1ItemStack.stackSize; - } - } - - return true; - } - - /** - * Called whenever this item is equipped and the right mouse button is pressed. - - *Args: itemStack, world, entityPlayer - */ - @Override - public ItemStack onItemRightClick(final ItemStack par1ItemStack, final World par2World, final EntityPlayer par3EntityPlayer){ - if (par2World.isRemote) - { - return par1ItemStack; - } - final MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true); - - if (movingobjectposition == null) - { - return par1ItemStack; - } - if (movingobjectposition.typeOfHit == MovingObjectPosition - - .MovingObjectType.BLOCK) - - { - final int i = movingobjectposition.blockX; - final int j = movingobjectposition.blockY; - final int k = movingobjectposition.blockZ; - - if (!par2World.canMineBlock(par3EntityPlayer, i, j, k)) - { - return par1ItemStack; - } - - if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, par1ItemStack)) - { - return par1ItemStack; - } - - if (par2World.getBlock(i, j, k) instanceof BlockLiquid) - { - final Entity entity = this.spawnEntity(par2World, i, j, k); - - if (entity != null) - { - if ((entity instanceof EntityLivingBase) && par1ItemStack.hasDisplayName()) - { - ((EntityLiving)entity).setCustomNameTag(par1ItemStack.getDisplayName()); - } - - if (!par3EntityPlayer.capabilities.isCreativeMode) - { - --par1ItemStack.stackSize; - } - } - } - } - - return par1ItemStack; - } - - /** - * Spawns the creature specified by the egg's type in the location specified by - - * the last three parameters. - * Parameters: world, entityID, x, y, z. - */ - public Entity spawnEntity(final World parWorld, final double parX, final double parY, final double parZ){ - - if (!parWorld.isRemote) // never spawn entity on client side - { - this.entityToSpawnNameFull = this.entityMODID+"."+this.entityToSpawnName; - if (EntityList.stringToClassMapping.containsKey(this.entityToSpawnNameFull)) - { - this.entityToSpawn = (EntityLiving) EntityList - - .createEntityByName(this.entityToSpawnNameFull, parWorld); - this.entityToSpawn.setLocationAndAngles(parX, parY, parZ, - - MathHelper.wrapAngleTo180_float(parWorld.rand.nextFloat() - - * 360.0F), 0.0F); - parWorld.spawnEntityInWorld(this.entityToSpawn); - this.entityToSpawn.onSpawnWithEgg((IEntityLivingData)null); - this.entityToSpawn.playLivingSound(); - } - else - { - //DEBUG - Logger.WARNING("Entity not found "+this.entityToSpawnName); - } - } - - return this.entityToSpawn; - } - - - /** - * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) - */ - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - @SideOnly(Side.CLIENT) - public void getSubItems(final Item parItem, final CreativeTabs parTab, final List parList){ - parList.add(new ItemStack(parItem, 1, 0)); - } - - @Override - @SideOnly(Side.CLIENT) - public int getColorFromItemStack(final ItemStack par1ItemStack, final int parColorType){ - return (parColorType == 0) ? this.colorBase : this.colorSpots; - } - - @Override - @SideOnly(Side.CLIENT) - public boolean requiresMultipleRenderPasses(){ - return true; - } - - @Override - // Doing this override means that there is no localization for language - // unless you specifically check for localization here and convert - public String getItemStackDisplayName(final ItemStack par1ItemStack){ - return "Spawn "+this.entityToSpawnName; - } - - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(final IIconRegister par1IconRegister){ - super.registerIcons(par1IconRegister); - this.theIcon = par1IconRegister.registerIcon(this.getIconString() + "_overlay"); - } - - /** - * Gets an icon index based on an item's damage value and the given render pass - */ - @Override - @SideOnly(Side.CLIENT) - public IIcon getIconFromDamageForRenderPass(final int parDamageVal, final int parRenderPass){ - return parRenderPass > 0 ? this.theIcon : super.getIconFromDamageForRenderPass(parDamageVal, parRenderPass); - } - - public void setColors(final int parColorBase, final int parColorSpots){ - this.colorBase = parColorBase; - this.colorSpots = parColorSpots; - } - - public int getColorBase(){ - return this.colorBase; - } - - public int getColorSpots(){ - return this.colorSpots; - } - - public final void setEntityToSpawnName(final String parEntityToSpawnName){ - this.entityToSpawnName = parEntityToSpawnName; - this.entityToSpawnNameFull = this.entityMODID+"."+this.entityToSpawnName; - } - +public class BasicSpawnEgg extends ItemMonsterPlacer { + @SideOnly(Side.CLIENT) + private IIcon theIcon; + + protected int colorBase = 0x000000; + protected int colorSpots = 0xFFFFFF; + protected String entityMODID = ""; + protected String entityToSpawnName = ""; + protected String entityToSpawnNameFull = ""; + protected EntityLiving entityToSpawn = null; + + public BasicSpawnEgg() { + super(); + } + + public BasicSpawnEgg( + final String MODID, + final String parEntityToSpawnName, + final int parPrimaryColor, + final int parSecondaryColor) { + this.setHasSubtypes(false); + this.maxStackSize = 64; + this.setCreativeTab(AddToCreativeTab.tabOther); + this.setEntityToSpawnName(parEntityToSpawnName); + this.colorBase = parPrimaryColor; + this.colorSpots = parSecondaryColor; + this.entityMODID = MODID; + + // DEBUG + Logger.WARNING("Spawn egg constructor for " + this.entityToSpawnName); + } + + /** + * Callback for item usage. If the item does something special on right clicking, + * + * he will have one of those. Return + * True if something happen and false if it don't. This is for ITEMS, not BLOCKS + */ + @Override + public boolean onItemUse( + final ItemStack par1ItemStack, + final EntityPlayer par2EntityPlayer, + final World par3World, + int par4, + int par5, + int par6, + final int par7, + final float par8, + final float par9, + final float par10) { + if (par3World.isRemote) { + return true; + } + final Block block = par3World.getBlock(par4, par5, par6); + par4 += Facing.offsetsXForSide[par7]; + par5 += Facing.offsetsYForSide[par7]; + par6 += Facing.offsetsZForSide[par7]; + double d0 = 0.0D; + + if ((par7 == 1) && (block.getRenderType() == 11)) { + d0 = 0.5D; + } + + final Entity entity = this.spawnEntity(par3World, par4 + 0.5D, par5 + d0, par6 + 0.5D); + + if (entity != null) { + if ((entity instanceof EntityLivingBase) && par1ItemStack.hasDisplayName()) { + ((EntityLiving) entity).setCustomNameTag(par1ItemStack.getDisplayName()); + } + + if (!par2EntityPlayer.capabilities.isCreativeMode) { + --par1ItemStack.stackSize; + } + } + + return true; + } + + /** + * Called whenever this item is equipped and the right mouse button is pressed. + * + *Args: itemStack, world, entityPlayer + */ + @Override + public ItemStack onItemRightClick( + final ItemStack par1ItemStack, final World par2World, final EntityPlayer par3EntityPlayer) { + if (par2World.isRemote) { + return par1ItemStack; + } + final MovingObjectPosition movingobjectposition = + this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true); + + if (movingobjectposition == null) { + return par1ItemStack; + } + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + + final int i = movingobjectposition.blockX; + final int j = movingobjectposition.blockY; + final int k = movingobjectposition.blockZ; + + if (!par2World.canMineBlock(par3EntityPlayer, i, j, k)) { + return par1ItemStack; + } + + if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, par1ItemStack)) { + return par1ItemStack; + } + + if (par2World.getBlock(i, j, k) instanceof BlockLiquid) { + final Entity entity = this.spawnEntity(par2World, i, j, k); + + if (entity != null) { + if ((entity instanceof EntityLivingBase) && par1ItemStack.hasDisplayName()) { + ((EntityLiving) entity).setCustomNameTag(par1ItemStack.getDisplayName()); + } + + if (!par3EntityPlayer.capabilities.isCreativeMode) { + --par1ItemStack.stackSize; + } + } + } + } + + return par1ItemStack; + } + + /** + * Spawns the creature specified by the egg's type in the location specified by + * + * the last three parameters. + * Parameters: world, entityID, x, y, z. + */ + public Entity spawnEntity(final World parWorld, final double parX, final double parY, final double parZ) { + + if (!parWorld.isRemote) // never spawn entity on client side + { + this.entityToSpawnNameFull = this.entityMODID + "." + this.entityToSpawnName; + if (EntityList.stringToClassMapping.containsKey(this.entityToSpawnNameFull)) { + this.entityToSpawn = (EntityLiving) EntityList.createEntityByName(this.entityToSpawnNameFull, parWorld); + + this.entityToSpawn.setLocationAndAngles( + parX, parY, parZ, MathHelper.wrapAngleTo180_float(parWorld.rand.nextFloat() * 360.0F), 0.0F); + + parWorld.spawnEntityInWorld(this.entityToSpawn); + this.entityToSpawn.onSpawnWithEgg((IEntityLivingData) null); + this.entityToSpawn.playLivingSound(); + } else { + // DEBUG + Logger.WARNING("Entity not found " + this.entityToSpawnName); + } + } + + return this.entityToSpawn; + } + + /** + * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) + */ + @SuppressWarnings({"rawtypes", "unchecked"}) + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(final Item parItem, final CreativeTabs parTab, final List parList) { + parList.add(new ItemStack(parItem, 1, 0)); + } + + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(final ItemStack par1ItemStack, final int parColorType) { + return (parColorType == 0) ? this.colorBase : this.colorSpots; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + // Doing this override means that there is no localization for language + // unless you specifically check for localization here and convert + public String getItemStackDisplayName(final ItemStack par1ItemStack) { + return "Spawn " + this.entityToSpawnName; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(final IIconRegister par1IconRegister) { + super.registerIcons(par1IconRegister); + this.theIcon = par1IconRegister.registerIcon(this.getIconString() + "_overlay"); + } + + /** + * Gets an icon index based on an item's damage value and the given render pass + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamageForRenderPass(final int parDamageVal, final int parRenderPass) { + return parRenderPass > 0 ? this.theIcon : super.getIconFromDamageForRenderPass(parDamageVal, parRenderPass); + } + + public void setColors(final int parColorBase, final int parColorSpots) { + this.colorBase = parColorBase; + this.colorSpots = parColorSpots; + } + + public int getColorBase() { + return this.colorBase; + } + + public int getColorSpots() { + return this.colorSpots; + } + + public final void setEntityToSpawnName(final String parEntityToSpawnName) { + this.entityToSpawnName = parEntityToSpawnName; + this.entityToSpawnNameFull = this.entityMODID + "." + this.entityToSpawnName; + } } - diff --git a/src/main/java/gtPlusPlus/core/item/base/CoreItem.java b/src/main/java/gtPlusPlus/core/item/base/CoreItem.java index fbd04eb30b..790b086ab3 100644 --- a/src/main/java/gtPlusPlus/core/item/base/CoreItem.java +++ b/src/main/java/gtPlusPlus/core/item/base/CoreItem.java @@ -1,11 +1,12 @@ package gtPlusPlus.core.item.base; -import java.util.List; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import java.util.List; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -15,223 +16,313 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.ItemUtils; +public class CoreItem extends Item { + + private final EnumRarity rarity; + private final EnumChatFormatting descColour; + private final String[] itemDescription; + protected String itemName; + private final boolean hasEffect; + + // Replace Item - What does this item turn into when held. + private final ItemStack turnsInto; + + // 0 + /* + * Name, Tab - 64 Stack, 0 Dmg + */ + public CoreItem(final String unlocalizedName, final CreativeTabs creativeTab) { + this(unlocalizedName, creativeTab, 64, 0); // Calls 3 + } + + // 0 + /* + * Name, Tab - 64 Stack, 0 Dmg + */ + public CoreItem(final String unlocalizedName, final String displayName, final CreativeTabs creativeTab) { + this(unlocalizedName, creativeTab, 64, 0); // Calls 3 + this.itemName = displayName; + } + + // 0.1 + /* + * Name, Tab - 64 Stack, 0 Dmg + */ + public CoreItem(final String unlocalizedName, final CreativeTabs creativeTab, final ItemStack OverrideItem) { + this( + unlocalizedName, + creativeTab, + 64, + 0, + new String[] { + "This item will be replaced by another when held by a player, it is old and should not be used in recipes." + }, + EnumRarity.uncommon, + EnumChatFormatting.UNDERLINE, + false, + OverrideItem); // Calls 5 + } + // 0.1 + /* + * Name, Tab - 64 Stack, 0 Dmg + */ + public CoreItem( + final String unlocalizedName, + final String displayName, + final CreativeTabs creativeTab, + final ItemStack OverrideItem) { + this( + unlocalizedName, + creativeTab, + 64, + 0, + new String[] { + "This item will be replaced by another when held by a player, it is old and should not be used in recipes." + }, + EnumRarity.uncommon, + EnumChatFormatting.UNDERLINE, + false, + OverrideItem); // Calls 5 + this.itemName = displayName; + } + + // 1 + /* + * Name, Tab, Stack - 0 Dmg + */ + public CoreItem(final String unlocalizedName, final CreativeTabs creativeTab, final int stackSize) { + this(unlocalizedName, creativeTab, stackSize, 0); // Calls 3 + } + // 2 + /* + * Name, Tab, Stack, Description - 0 Dmg + */ + public CoreItem( + final String unlocalizedName, + final CreativeTabs creativeTab, + final int stackSize, + final String[] description) { + this(unlocalizedName, creativeTab, stackSize, 0, description); // Calls 4 + } + // 3 + /* + * Name, Tab, Stack, Dmg - Description + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab, int stackSize, String string) { + this(unlocalizedName, creativeTab, stackSize, new String[] {string}); + } + + public CoreItem( + final String unlocalizedName, final CreativeTabs creativeTab, final int stackSize, final int maxDmg) { + this(unlocalizedName, creativeTab, stackSize, maxDmg, new String[] {}); // Calls 4 + } + // 4 //Not Rare + basic tooltip + /* + * Name, Tab, Stack, Dmg, Description + */ + public CoreItem(String unlocalizedName, CreativeTabs creativeTab, int stackSize, int maxDmg, String string) { + this(unlocalizedName, creativeTab, stackSize, maxDmg, new String[] {string}); + } + + public CoreItem( + final String unlocalizedName, + final CreativeTabs creativeTab, + final int stackSize, + final int maxDmg, + final String[] description) { + this( + unlocalizedName, + creativeTab, + stackSize, + maxDmg, + description, + EnumRarity.common, + EnumChatFormatting.GRAY, + false, + null); // Calls 4.5 + } + // 4.5 + /* + * Name, Tab, Stack, Dmg, Description, Text Colour - Common + */ + public CoreItem( + final String unlocalizedName, + final CreativeTabs creativeTab, + final int stackSize, + final int maxDmg, + final String[] description, + final EnumChatFormatting colour) { + this( + unlocalizedName, + creativeTab, + stackSize, + maxDmg, + description, + EnumRarity.common, + colour, + false, + null); // Calls 5 + } + + // 4.75 + /* + * Name, Tab, Stack, Dmg, Description, Rarity - Gray text + */ + public CoreItem( + String unlocalizedName, + CreativeTabs creativeTab, + int stackSize, + int maxDmg, + String string, + EnumRarity uncommon) { + this(unlocalizedName, creativeTab, stackSize, maxDmg, new String[] {string}, uncommon); + } + + public CoreItem( + final String unlocalizedName, + final CreativeTabs creativeTab, + final int stackSize, + final int maxDmg, + final String[] description, + final EnumRarity rarity) { + this( + unlocalizedName, + creativeTab, + stackSize, + maxDmg, + description, + rarity, + EnumChatFormatting.GRAY, + false, + null); // Calls 5 + } + + // 5 + /* + * Name, Tab, Stack, Dmg, Description, Rarity, Text Colour, Effect + */ + public CoreItem( + final String unlocalizedName, + final CreativeTabs creativeTab, + final int stackSize, + final int maxDmg, + final String[] description, + final EnumRarity regRarity, + final EnumChatFormatting colour, + final boolean Effect, + final ItemStack OverrideItem) { + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setCreativeTab(creativeTab); + this.setMaxStackSize(stackSize); + this.setMaxDamage(maxDmg); + this.rarity = regRarity; + this.itemDescription = description; + this.descColour = colour != null ? colour : EnumChatFormatting.RESET; + this.hasEffect = Effect; + this.turnsInto = OverrideItem; + GameRegistry.registerItem(this, unlocalizedName); + } + + // 6 + /* + * Name, Tab, Stack, Dmg, Description, Rarity, Text Colour, Effect + */ + public CoreItem( + final String unlocalizedName, + final String displayName, + final CreativeTabs creativeTab, + final int stackSize, + final int maxDmg, + final String[] description, + final EnumRarity regRarity, + final EnumChatFormatting colour, + final boolean Effect, + final ItemStack OverrideItem) { + this.setUnlocalizedName(unlocalizedName); + this.itemName = displayName; + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setCreativeTab(creativeTab); + this.setMaxStackSize(stackSize); + this.setMaxDamage(maxDmg); + this.rarity = regRarity; + this.itemDescription = description; + this.descColour = colour != null ? colour : EnumChatFormatting.RESET; + this.hasEffect = Effect; + this.turnsInto = OverrideItem; + GameRegistry.registerItem(this, unlocalizedName); + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + if (this.itemDescription.length > 0) { + for (int u = 0; u < this.itemDescription.length; u++) { + list.add(this.descColour + this.itemDescription[u]); + } + } + // list.add(this.descColour+this.itemDescription); + // super.addInformation(stack, aPlayer, list, bool); + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(final ItemStack par1ItemStack) { + return this.rarity; + } + + @Override + public boolean hasEffect(final ItemStack par1ItemStack) { + return this.hasEffect; + } + + @Override + public void onUpdate( + final ItemStack iStack, + final World world, + final Entity entityHolding, + final int p_77663_4_, + final boolean p_77663_5_) { + if (this.turnsInto != null) { + if (entityHolding instanceof EntityPlayer) { + + Logger.INFO("Replacing " + iStack.getDisplayName() + " with " + this.turnsInto.getDisplayName() + "."); + final ItemStack tempTransform = this.turnsInto; + if (iStack.stackSize == 64) { + tempTransform.stackSize = 64; + ((EntityPlayer) entityHolding).inventory.addItemStackToInventory((tempTransform)); + for (int l = 0; l < 64; l++) { + ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); + } + + } else { + tempTransform.stackSize = 1; + ((EntityPlayer) entityHolding).inventory.addItemStackToInventory((tempTransform)); + ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); + } + } + } + } + + @Override + public boolean isDamageable() { + return false; + } + + @Override + public boolean isRepairable() { + return false; + } + + public ItemStack getStack() { + return ItemUtils.getSimpleStack(this); + } -public class CoreItem extends Item -{ - - private final EnumRarity rarity; - private final EnumChatFormatting descColour; - private final String[] itemDescription; - protected String itemName; - private final boolean hasEffect; - - //Replace Item - What does this item turn into when held. - private final ItemStack turnsInto; - - //0 - /* - * Name, Tab - 64 Stack, 0 Dmg - */ - public CoreItem(final String unlocalizedName, final CreativeTabs creativeTab) - { - this(unlocalizedName, creativeTab, 64, 0); //Calls 3 - } - - //0 - /* - * Name, Tab - 64 Stack, 0 Dmg - */ - public CoreItem(final String unlocalizedName, final String displayName, final CreativeTabs creativeTab) - { - this(unlocalizedName, creativeTab, 64, 0); //Calls 3 - this.itemName = displayName; - } - - //0.1 - /* - * Name, Tab - 64 Stack, 0 Dmg - */ - public CoreItem(final String unlocalizedName, final CreativeTabs creativeTab, final ItemStack OverrideItem) - { - this(unlocalizedName, creativeTab, 64, 0, new String[] {"This item will be replaced by another when held by a player, it is old and should not be used in recipes."}, EnumRarity.uncommon, EnumChatFormatting.UNDERLINE, false, OverrideItem); //Calls 5 - } - //0.1 - /* - * Name, Tab - 64 Stack, 0 Dmg - */ - public CoreItem(final String unlocalizedName, final String displayName, final CreativeTabs creativeTab, final ItemStack OverrideItem) - { - this(unlocalizedName, creativeTab, 64, 0, new String[] {"This item will be replaced by another when held by a player, it is old and should not be used in recipes."}, EnumRarity.uncommon, EnumChatFormatting.UNDERLINE, false, OverrideItem); //Calls 5 - this.itemName = displayName; - } - - //1 - /* - * Name, Tab, Stack - 0 Dmg - */ - public CoreItem(final String unlocalizedName, final CreativeTabs creativeTab, final int stackSize) - { - this(unlocalizedName, creativeTab, stackSize, 0); //Calls 3 - } - //2 - /* - * Name, Tab, Stack, Description - 0 Dmg - */ - public CoreItem(final String unlocalizedName, final CreativeTabs creativeTab, final int stackSize, final String[] description) - { - this(unlocalizedName, creativeTab, stackSize, 0, description); //Calls 4 - } - //3 - /* - * Name, Tab, Stack, Dmg - Description - */ - public CoreItem(String unlocalizedName, CreativeTabs creativeTab, int stackSize, String string) { - this(unlocalizedName, creativeTab, stackSize, new String[] {string}); - } - public CoreItem(final String unlocalizedName, final CreativeTabs creativeTab, final int stackSize, final int maxDmg) - { - this(unlocalizedName, creativeTab, stackSize, maxDmg, new String[] {}); //Calls 4 - } - //4 //Not Rare + basic tooltip - /* - * Name, Tab, Stack, Dmg, Description - */ - public CoreItem(String unlocalizedName, CreativeTabs creativeTab, int stackSize, int maxDmg, String string) { - this(unlocalizedName, creativeTab, stackSize, maxDmg, new String[] {string}); - } - public CoreItem(final String unlocalizedName, final CreativeTabs creativeTab, final int stackSize, final int maxDmg, final String[] description) - { - this(unlocalizedName, creativeTab, stackSize, maxDmg, description, EnumRarity.common, EnumChatFormatting.GRAY, false, null); //Calls 4.5 - } - //4.5 - /* - * Name, Tab, Stack, Dmg, Description, Text Colour - Common - */ - public CoreItem(final String unlocalizedName, final CreativeTabs creativeTab, final int stackSize, final int maxDmg, final String[] description, final EnumChatFormatting colour) - { - this(unlocalizedName, creativeTab, stackSize, maxDmg, description, EnumRarity.common, colour, false, null); //Calls 5 - } - - //4.75 - /* - * Name, Tab, Stack, Dmg, Description, Rarity - Gray text - */ - public CoreItem(String unlocalizedName, CreativeTabs creativeTab, int stackSize, int maxDmg, String string, EnumRarity uncommon) { - this(unlocalizedName, creativeTab, stackSize, maxDmg, new String[] {string}, uncommon); - } - public CoreItem(final String unlocalizedName, final CreativeTabs creativeTab, final int stackSize, final int maxDmg, final String[] description, final EnumRarity rarity) - { - this(unlocalizedName, creativeTab, stackSize, maxDmg, description, rarity, EnumChatFormatting.GRAY, false, null); //Calls 5 - } - - //5 - /* - * Name, Tab, Stack, Dmg, Description, Rarity, Text Colour, Effect - */ - public CoreItem(final String unlocalizedName, final CreativeTabs creativeTab, final int stackSize, final int maxDmg, final String[] description, final EnumRarity regRarity, final EnumChatFormatting colour, final boolean Effect, final ItemStack OverrideItem) - { - this.setUnlocalizedName(unlocalizedName); - this.setTextureName(CORE.MODID + ":" + unlocalizedName); - this.setCreativeTab(creativeTab); - this.setMaxStackSize(stackSize); - this.setMaxDamage(maxDmg); - this.rarity = regRarity; - this.itemDescription = description; - this.descColour = colour != null ? colour : EnumChatFormatting.RESET; - this.hasEffect = Effect; - this.turnsInto = OverrideItem; - GameRegistry.registerItem(this, unlocalizedName); - } - - //6 - /* - * Name, Tab, Stack, Dmg, Description, Rarity, Text Colour, Effect - */ - public CoreItem(final String unlocalizedName, final String displayName, final CreativeTabs creativeTab, final int stackSize, final int maxDmg, final String[] description, final EnumRarity regRarity, final EnumChatFormatting colour, final boolean Effect, final ItemStack OverrideItem) - { - this.setUnlocalizedName(unlocalizedName); - this.itemName = displayName; - this.setTextureName(CORE.MODID + ":" + unlocalizedName); - this.setCreativeTab(creativeTab); - this.setMaxStackSize(stackSize); - this.setMaxDamage(maxDmg); - this.rarity = regRarity; - this.itemDescription = description; - this.descColour = colour != null ? colour : EnumChatFormatting.RESET; - this.hasEffect = Effect; - this.turnsInto = OverrideItem; - GameRegistry.registerItem(this, unlocalizedName); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - if (this.itemDescription.length > 0) { - for (int u=0;u= this.tickCounterMax){ - entityHolding.attackEntityFrom(DamageSource.onFire, 2); - this.tickCounter = 0; - } - } - } - super.onUpdate(iStack, world, entityHolding, p_77663_4_, p_77663_5_); - } + @Override + public String getItemStackDisplayName(final ItemStack cell) { + return this.materialName + " Plasma Cell"; + } + @Override + public void onUpdate( + final ItemStack iStack, + final World world, + final Entity entityHolding, + final int p_77663_4_, + final boolean p_77663_5_) { + if (this.componentMaterial != null) { + if (!world.isRemote) { + if (this.tickCounter < this.tickCounterMax) { + this.tickCounter++; + } else if (this.tickCounter >= this.tickCounterMax) { + entityHolding.attackEntityFrom(DamageSource.onFire, 2); + this.tickCounter = 0; + } + } + } + super.onUpdate(iStack, world, entityHolding, p_77663_4_, p_77663_5_); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java b/src/main/java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java index 9022f864cb..f392d0e6af 100644 --- a/src/main/java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java +++ b/src/main/java/gtPlusPlus/core/item/base/dusts/BaseItemDust.java @@ -5,141 +5,136 @@ import gtPlusPlus.core.material.Material; public class BaseItemDust extends BaseItemComponent { - private BaseItemComponent[] mSizedDusts = new BaseItemComponent[2]; - - public BaseItemDust(Material aMat) { - this(aMat, true); - } - - public BaseItemDust(Material aMat, boolean generateSmallDusts) { - super(aMat, ComponentTypes.DUST); - if (generateSmallDusts) { - mSizedDusts[0] = new BaseItemComponent(aMat, ComponentTypes.DUSTSMALL); - mSizedDusts[1] = new BaseItemComponent(aMat, ComponentTypes.DUSTTINY); - } - } - - public BaseItemDust(DustState aState, Material aMat) { - super(aMat, ComponentTypes.DUST); - if (aState.generatesSmallDust()) { - mSizedDusts[0] = new BaseItemComponent(aMat, ComponentTypes.DUSTSMALL); - } - if (aState.generatesTinyDust()) { - mSizedDusts[1] = new BaseItemComponent(aMat, ComponentTypes.DUSTTINY); - } - } - - private BaseItemDust(String unlocalizedName, String materialName, Material matInfo, int colour, String pileSize, int tier, boolean addRecipes) { - super(matInfo, ComponentTypes.DUST); - } - - public static class DustState { - static final int NORMAL = (1); - static final int SMALL = (10); - static final int TINY = (100); - final int MIXTURE; - final boolean[] doesThings = new boolean[3]; - - public DustState (boolean genDust, boolean genSmallDust, boolean genDustTiny){ - int aTotal = 0; - if (genDust) { - aTotal += NORMAL; - doesThings[0] = true; - } - else { - doesThings[0] = false; - } - if (genSmallDust) { - aTotal += SMALL; - doesThings[1] = true; - } - else { - doesThings[1] = false; - } - if (genDustTiny) { - aTotal += TINY; - doesThings[2] = true; - } - else { - doesThings[2] = false; - } - MIXTURE = aTotal; - } - - public boolean generatesDust() { - return doesThings[0]; - } - public boolean generatesSmallDust() { - return doesThings[1]; - } - public boolean generatesTinyDust() { - return doesThings[2]; - } - - private DustState(int amount) { - - if (amount == 1) { - doesThings[0] = true; - doesThings[1] = false; - doesThings[2] = false; - - } - else if (amount == 10) { - doesThings[0] = false; - doesThings[1] = true; - doesThings[2] = false; - } - else if (amount == 100) { - doesThings[0] = false; - doesThings[1] = false; - doesThings[2] = true; - - } - else if (amount == 11) { - doesThings[0] = true; - doesThings[1] = true; - doesThings[2] = false; - - } - else if (amount == 101) { - doesThings[0] = true; - doesThings[1] = false; - doesThings[2] = true; - - } - else if (amount == 110) { - doesThings[0] = false; - doesThings[1] = true; - doesThings[2] = true; - - } - else if (amount == 111) { - doesThings[0] = true; - doesThings[1] = true; - doesThings[2] = true; - } - else { - doesThings[0] = false; - doesThings[1] = false; - doesThings[2] = false; - } - MIXTURE = amount; - } - - public DustState get(int a) { - if (a == 1) { - return new DustState(NORMAL); - } - else if (a == 10) { - return new DustState(SMALL); - } - else if (a == 100) { - return new DustState(TINY); - } - else { - return new DustState(MIXTURE); - } - } - } + private BaseItemComponent[] mSizedDusts = new BaseItemComponent[2]; + public BaseItemDust(Material aMat) { + this(aMat, true); + } + + public BaseItemDust(Material aMat, boolean generateSmallDusts) { + super(aMat, ComponentTypes.DUST); + if (generateSmallDusts) { + mSizedDusts[0] = new BaseItemComponent(aMat, ComponentTypes.DUSTSMALL); + mSizedDusts[1] = new BaseItemComponent(aMat, ComponentTypes.DUSTTINY); + } + } + + public BaseItemDust(DustState aState, Material aMat) { + super(aMat, ComponentTypes.DUST); + if (aState.generatesSmallDust()) { + mSizedDusts[0] = new BaseItemComponent(aMat, ComponentTypes.DUSTSMALL); + } + if (aState.generatesTinyDust()) { + mSizedDusts[1] = new BaseItemComponent(aMat, ComponentTypes.DUSTTINY); + } + } + + private BaseItemDust( + String unlocalizedName, + String materialName, + Material matInfo, + int colour, + String pileSize, + int tier, + boolean addRecipes) { + super(matInfo, ComponentTypes.DUST); + } + + public static class DustState { + static final int NORMAL = (1); + static final int SMALL = (10); + static final int TINY = (100); + final int MIXTURE; + final boolean[] doesThings = new boolean[3]; + + public DustState(boolean genDust, boolean genSmallDust, boolean genDustTiny) { + int aTotal = 0; + if (genDust) { + aTotal += NORMAL; + doesThings[0] = true; + } else { + doesThings[0] = false; + } + if (genSmallDust) { + aTotal += SMALL; + doesThings[1] = true; + } else { + doesThings[1] = false; + } + if (genDustTiny) { + aTotal += TINY; + doesThings[2] = true; + } else { + doesThings[2] = false; + } + MIXTURE = aTotal; + } + + public boolean generatesDust() { + return doesThings[0]; + } + + public boolean generatesSmallDust() { + return doesThings[1]; + } + + public boolean generatesTinyDust() { + return doesThings[2]; + } + + private DustState(int amount) { + + if (amount == 1) { + doesThings[0] = true; + doesThings[1] = false; + doesThings[2] = false; + + } else if (amount == 10) { + doesThings[0] = false; + doesThings[1] = true; + doesThings[2] = false; + } else if (amount == 100) { + doesThings[0] = false; + doesThings[1] = false; + doesThings[2] = true; + + } else if (amount == 11) { + doesThings[0] = true; + doesThings[1] = true; + doesThings[2] = false; + + } else if (amount == 101) { + doesThings[0] = true; + doesThings[1] = false; + doesThings[2] = true; + + } else if (amount == 110) { + doesThings[0] = false; + doesThings[1] = true; + doesThings[2] = true; + + } else if (amount == 111) { + doesThings[0] = true; + doesThings[1] = true; + doesThings[2] = true; + } else { + doesThings[0] = false; + doesThings[1] = false; + doesThings[2] = false; + } + MIXTURE = amount; + } + + public DustState get(int a) { + if (a == 1) { + return new DustState(NORMAL); + } else if (a == 10) { + return new DustState(SMALL); + } else if (a == 100) { + return new DustState(TINY); + } else { + return new DustState(MIXTURE); + } + } + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/dusts/BaseItemDustAbstract.java b/src/main/java/gtPlusPlus/core/item/base/dusts/BaseItemDustAbstract.java index 8ee871e9c4..beca8dc873 100644 --- a/src/main/java/gtPlusPlus/core/item/base/dusts/BaseItemDustAbstract.java +++ b/src/main/java/gtPlusPlus/core/item/base/dusts/BaseItemDustAbstract.java @@ -1,44 +1,40 @@ package gtPlusPlus.core.item.base.dusts; -import java.util.List; - import cpw.mods.fml.common.registry.GameRegistry; - +import gtPlusPlus.core.lib.CORE; +import java.util.List; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import gtPlusPlus.core.lib.CORE; - -public abstract class BaseItemDustAbstract extends Item{ - - protected int colour = 0; - protected String materialName; - protected String pileType; - - public BaseItemDustAbstract(final String unlocalizedName, final String materialName, final int colour, final String pileSize) { - this.setUnlocalizedName(unlocalizedName); - this.setMaxStackSize(64); - if (pileSize.equalsIgnoreCase("dust")){ - this.setTextureName(CORE.MODID + ":" + "dust"); - } - else{ - this.setTextureName(CORE.MODID + ":" + "dust"+pileSize); - } - this.setMaxStackSize(64); - this.colour = colour; - this.materialName = materialName; - this.setUnlocalizedName(unlocalizedName); - GameRegistry.registerItem(this, unlocalizedName); - } - - @SuppressWarnings("rawtypes") - @Override - public abstract void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool); - - public abstract String getMaterialName(); - - @Override - public abstract int getColorFromItemStack(ItemStack stack, int hex); - +public abstract class BaseItemDustAbstract extends Item { + + protected int colour = 0; + protected String materialName; + protected String pileType; + + public BaseItemDustAbstract( + final String unlocalizedName, final String materialName, final int colour, final String pileSize) { + this.setUnlocalizedName(unlocalizedName); + this.setMaxStackSize(64); + if (pileSize.equalsIgnoreCase("dust")) { + this.setTextureName(CORE.MODID + ":" + "dust"); + } else { + this.setTextureName(CORE.MODID + ":" + "dust" + pileSize); + } + this.setMaxStackSize(64); + this.colour = colour; + this.materialName = materialName; + this.setUnlocalizedName(unlocalizedName); + GameRegistry.registerItem(this, unlocalizedName); + } + + @SuppressWarnings("rawtypes") + @Override + public abstract void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool); + + public abstract String getMaterialName(); + + @Override + public abstract int getColorFromItemStack(ItemStack stack, int hex); } diff --git a/src/main/java/gtPlusPlus/core/item/base/dusts/BaseItemDustEx.java b/src/main/java/gtPlusPlus/core/item/base/dusts/BaseItemDustEx.java index 0757177e58..c6d9cfdc71 100644 --- a/src/main/java/gtPlusPlus/core/item/base/dusts/BaseItemDustEx.java +++ b/src/main/java/gtPlusPlus/core/item/base/dusts/BaseItemDustEx.java @@ -1,126 +1,119 @@ package gtPlusPlus.core.item.base.dusts; -import java.util.*; - -import org.apache.commons.lang3.StringUtils; - -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; - import gregtech.api.enums.TextureSet; import gregtech.api.util.GT_OreDictUnificator; - -import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.minecraft.ItemUtils; +import java.util.*; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import org.apache.commons.lang3.StringUtils; -public class BaseItemDustEx extends BaseItemComponent{ +public class BaseItemDustEx extends BaseItemComponent { - public static Map mCachedPileLinkages = new HashMap(); - - protected IIcon[] baseAr = new IIcon[3]; - protected IIcon[] overlayAr = new IIcon[3]; - public final static ComponentTypes[] componentTypeAr = new ComponentTypes[] {ComponentTypes.DUST, ComponentTypes.DUSTSMALL, ComponentTypes.DUSTTINY}; + public static Map mCachedPileLinkages = new HashMap(); - public BaseItemDustEx(final Material material) { - super(material, componentTypeAr[0]); - //OreDict this beauty - GT_OreDictUnificator.registerOre(componentTypeAr[0].getOreDictName()+material.getUnlocalizedName(), ItemUtils.simpleMetaStack(this, 0, 1)); - GT_OreDictUnificator.registerOre(componentTypeAr[1].getOreDictName()+material.getUnlocalizedName(), ItemUtils.simpleMetaStack(this, 0, 1)); - GT_OreDictUnificator.registerOre(componentTypeAr[2].getOreDictName()+material.getUnlocalizedName(), ItemUtils.simpleMetaStack(this, 0, 1)); - bakeRegistry(); - } - - private void bakeRegistry() { - String unlocalName = getUnlocalizedName(); - if (unlocalName.contains("item.")) { - unlocalName = StringUtils.remove(unlocalName, "item."); - } - if (unlocalName.contains("itemDust")) { - unlocalName = StringUtils.remove(unlocalName, "itemDust"); - } - mCachedPileLinkages.put(this.getUnlocalizedName(), "itemDust"+unlocalName); - mCachedPileLinkages.put(this.getUnlocalizedName(), "itemDustSmall"+unlocalName); - mCachedPileLinkages.put(this.getUnlocalizedName(), "itemDustTiny"+unlocalName); - } + protected IIcon[] baseAr = new IIcon[3]; + protected IIcon[] overlayAr = new IIcon[3]; + public static final ComponentTypes[] componentTypeAr = + new ComponentTypes[] {ComponentTypes.DUST, ComponentTypes.DUSTSMALL, ComponentTypes.DUSTTINY}; - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < 3; i ++) { - list.add(new ItemStack(item, 1, i)); - } - } + public BaseItemDustEx(final Material material) { + super(material, componentTypeAr[0]); + // OreDict this beauty + GT_OreDictUnificator.registerOre( + componentTypeAr[0].getOreDictName() + material.getUnlocalizedName(), + ItemUtils.simpleMetaStack(this, 0, 1)); + GT_OreDictUnificator.registerOre( + componentTypeAr[1].getOreDictName() + material.getUnlocalizedName(), + ItemUtils.simpleMetaStack(this, 0, 1)); + GT_OreDictUnificator.registerOre( + componentTypeAr[2].getOreDictName() + material.getUnlocalizedName(), + ItemUtils.simpleMetaStack(this, 0, 1)); + bakeRegistry(); + } - @Override - public IIcon getIconFromDamageForRenderPass(int meta, int pass) { - if (CORE.ConfigSwitches.useGregtechTextures) { - if (meta == 0) { - if (pass == 0) { - return this.baseAr[0]; - } - else { - return this.overlayAr[0]; - } - } - else if (meta == 1) { - if (pass == 0) { - return this.baseAr[1]; - } - else { - return this.overlayAr[1]; - } - } - else { - if (pass == 0) { - return this.baseAr[2]; - } - else { - return this.overlayAr[2]; - } - } - } - else { - return this.baseAr[meta]; - } - } + private void bakeRegistry() { + String unlocalName = getUnlocalizedName(); + if (unlocalName.contains("item.")) { + unlocalName = StringUtils.remove(unlocalName, "item."); + } + if (unlocalName.contains("itemDust")) { + unlocalName = StringUtils.remove(unlocalName, "itemDust"); + } + mCachedPileLinkages.put(this.getUnlocalizedName(), "itemDust" + unlocalName); + mCachedPileLinkages.put(this.getUnlocalizedName(), "itemDustSmall" + unlocalName); + mCachedPileLinkages.put(this.getUnlocalizedName(), "itemDustTiny" + unlocalName); + } - @Override - public void registerIcons(final IIconRegister i) { - if (CORE.ConfigSwitches.useGregtechTextures){ - this.baseAr[0] = i.registerIcon(getCorrectTextures()); - this.overlayAr[0] = i.registerIcon(getCorrectTextures() + "_OVERLAY"); - this.baseAr[1] = i.registerIcon(getCorrectTextures()+"Small"); - this.overlayAr[1] = i.registerIcon(getCorrectTextures() + "Small_OVERLAY"); - this.baseAr[2] = i.registerIcon(getCorrectTextures()+"Tiny"); - this.overlayAr[2] = i.registerIcon(getCorrectTextures() + "Tiny_OVERLAY"); - } - else { - this.baseAr[0] = i.registerIcon(getCorrectTextures()); - this.baseAr[1] = i.registerIcon(getCorrectTextures()+"Small"); - this.baseAr[2] = i.registerIcon(getCorrectTextures()+"Tiny"); - } - } + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 3; i++) { + list.add(new ItemStack(item, 1, i)); + } + } - @Override - public String getCorrectTextures(){ - if (!CORE.ConfigSwitches.useGregtechTextures){ - return CORE.MODID + ":" + "item"+this.componentType.getComponent(); - } - String metType = "9j4852jyo3rjmh3owlhw9oe"; - if (this.componentMaterial != null) { - TextureSet u = this.componentMaterial.getTextureSet(); - if (u != null) { - metType = u.mSetName; - } - } - metType = (metType.equals("9j4852jyo3rjmh3owlhw9oe") ? "METALLIC" : metType); - return "gregtech" + ":" + "materialicons/"+metType+"/" + this.componentType.getOreDictName(); - } + @Override + public IIcon getIconFromDamageForRenderPass(int meta, int pass) { + if (CORE.ConfigSwitches.useGregtechTextures) { + if (meta == 0) { + if (pass == 0) { + return this.baseAr[0]; + } else { + return this.overlayAr[0]; + } + } else if (meta == 1) { + if (pass == 0) { + return this.baseAr[1]; + } else { + return this.overlayAr[1]; + } + } else { + if (pass == 0) { + return this.baseAr[2]; + } else { + return this.overlayAr[2]; + } + } + } else { + return this.baseAr[meta]; + } + } + @Override + public void registerIcons(final IIconRegister i) { + if (CORE.ConfigSwitches.useGregtechTextures) { + this.baseAr[0] = i.registerIcon(getCorrectTextures()); + this.overlayAr[0] = i.registerIcon(getCorrectTextures() + "_OVERLAY"); + this.baseAr[1] = i.registerIcon(getCorrectTextures() + "Small"); + this.overlayAr[1] = i.registerIcon(getCorrectTextures() + "Small_OVERLAY"); + this.baseAr[2] = i.registerIcon(getCorrectTextures() + "Tiny"); + this.overlayAr[2] = i.registerIcon(getCorrectTextures() + "Tiny_OVERLAY"); + } else { + this.baseAr[0] = i.registerIcon(getCorrectTextures()); + this.baseAr[1] = i.registerIcon(getCorrectTextures() + "Small"); + this.baseAr[2] = i.registerIcon(getCorrectTextures() + "Tiny"); + } + } + @Override + public String getCorrectTextures() { + if (!CORE.ConfigSwitches.useGregtechTextures) { + return CORE.MODID + ":" + "item" + this.componentType.getComponent(); + } + String metType = "9j4852jyo3rjmh3owlhw9oe"; + if (this.componentMaterial != null) { + TextureSet u = this.componentMaterial.getTextureSet(); + if (u != null) { + metType = u.mSetName; + } + } + metType = (metType.equals("9j4852jyo3rjmh3owlhw9oe") ? "METALLIC" : metType); + return "gregtech" + ":" + "materialicons/" + metType + "/" + this.componentType.getOreDictName(); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java b/src/main/java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java index e4fa06c58e..8554844e50 100644 --- a/src/main/java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java +++ b/src/main/java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java @@ -2,161 +2,155 @@ package gtPlusPlus.core.item.base.dusts; import static gtPlusPlus.core.creative.AddToCreativeTab.tabMisc; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import cpw.mods.fml.common.registry.GameRegistry; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_OreDictUnificator; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.data.StringUtils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; -public class BaseItemDustUnique extends Item{ - - protected final int colour; - protected final int sRadiation; - protected final String materialName; - protected final String name; - protected final String chemicalNotation; - - public BaseItemDustUnique(final String unlocalizedName, final String materialName, final int colour, final String pileSize) { - this(unlocalizedName, materialName, "NullFormula", colour, pileSize); - } - - public BaseItemDustUnique(final String unlocalizedName, final String materialName, final String mChemicalFormula, final int colour, final String pileSize) { - this.setUnlocalizedName(unlocalizedName); - this.setMaxStackSize(64); - this.setTextureName(this.getCorrectTexture(pileSize)); - this.setCreativeTab(tabMisc); - this.colour = colour; - this.materialName = materialName; - if (mChemicalFormula == null || mChemicalFormula.equals("") || mChemicalFormula.equals("NullFormula")){ - this.chemicalNotation = StringUtils.subscript(materialName); - } - else { - this.chemicalNotation = StringUtils.subscript(mChemicalFormula); - } - this.sRadiation = ItemUtils.getRadioactivityLevel(materialName); - GameRegistry.registerItem(this, unlocalizedName); - - if (this.getUnlocalizedName().contains("DustTiny")){ - this.name = "Tiny Pile of "+this.materialName+ " Dust"; - } - else if (this.getUnlocalizedName().contains("DustSmall")){ - this.name = "Small Pile of "+this.materialName+ " Dust"; - } - else { - this.name = this.materialName+ " Dust"; - } - - String temp = ""; - Logger.WARNING("Unlocalized name for OreDict nameGen: "+this.getUnlocalizedName()); - if (this.getUnlocalizedName().contains("item.")){ - temp = this.getUnlocalizedName().replace("item.", ""); - Logger.WARNING("Generating OreDict Name: "+temp); - } - else { - temp = this.getUnlocalizedName(); - } - if (temp.contains("DustTiny")){ - temp = temp.replace("itemD", "d"); - Logger.WARNING("Generating OreDict Name: "+temp); - } - else if (temp.contains("DustSmall")){ - temp = temp.replace("itemD", "d"); - Logger.WARNING("Generating OreDict Name: "+temp); - } - else { - temp = temp.replace("itemD", "d"); - Logger.WARNING("Generating OreDict Name: "+temp); - } - if ((temp != null) && !temp.equals("")){ - GT_OreDictUnificator.registerOre(temp, ItemUtils.getSimpleStack(this)); - } - registerComponent(); - } - - public boolean registerComponent() { - if (this.materialName == null) { - return false; - } - String aName = materialName; - //Register Component - Map aMap = Material.mComponentMap.get(aName); - if (aMap == null) { - aMap = new HashMap(); - } - String aKey = OrePrefixes.dust.name(); - ItemStack x = aMap.get(aKey); - if (x == null) { - aMap.put(aKey, ItemUtils.getSimpleStack(this)); - Logger.MATERIALS("Registering a material component. Item: ["+aName+"] Map: ["+aKey+"]"); - Material.mComponentMap.put(aName, aMap); - return true; - } - else { - //Bad - Logger.MATERIALS("Tried to double register a material component. "); - return false; - } - } - - @Override - public String getItemStackDisplayName(final ItemStack iStack) { - return this.name; - } - - private String getCorrectTexture(final String pileSize){ - if (!CORE.ConfigSwitches.useGregtechTextures){ - if ((pileSize.equals("dust")) || (pileSize.equals("Dust"))){ - this.setTextureName(CORE.MODID + ":" + "dust");} - else{ - this.setTextureName(CORE.MODID + ":" + "dust"+pileSize); - } - } - if (pileSize.toLowerCase().contains("small")){ - return "gregtech" + ":" + "materialicons/SHINY/dustSmall"; - } - else if (pileSize.toLowerCase().contains("tiny")){ - return "gregtech" + ":" + "materialicons/SHINY/dustTiny"; - } - return "gregtech" + ":" + "materialicons/SHINY/dust"; - } - - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - if (this.sRadiation > 0){ - list.add(CORE.GT_Tooltip_Radioactive); - } - if (this.chemicalNotation.length() > 0 && !chemicalNotation.equals("") && !chemicalNotation.equals("NullFormula")){ - list.add(this.chemicalNotation); - } - super.addInformation(stack, aPlayer, list, bool); - } - - public final String getMaterialName() { - return StringUtils.subscript(this.materialName); - } - - @Override - public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { - if (this.colour == 0){ - return MathUtils.generateSingularRandomHexValue(); - } - return this.colour; - - } - +public class BaseItemDustUnique extends Item { + + protected final int colour; + protected final int sRadiation; + protected final String materialName; + protected final String name; + protected final String chemicalNotation; + + public BaseItemDustUnique( + final String unlocalizedName, final String materialName, final int colour, final String pileSize) { + this(unlocalizedName, materialName, "NullFormula", colour, pileSize); + } + + public BaseItemDustUnique( + final String unlocalizedName, + final String materialName, + final String mChemicalFormula, + final int colour, + final String pileSize) { + this.setUnlocalizedName(unlocalizedName); + this.setMaxStackSize(64); + this.setTextureName(this.getCorrectTexture(pileSize)); + this.setCreativeTab(tabMisc); + this.colour = colour; + this.materialName = materialName; + if (mChemicalFormula == null || mChemicalFormula.equals("") || mChemicalFormula.equals("NullFormula")) { + this.chemicalNotation = StringUtils.subscript(materialName); + } else { + this.chemicalNotation = StringUtils.subscript(mChemicalFormula); + } + this.sRadiation = ItemUtils.getRadioactivityLevel(materialName); + GameRegistry.registerItem(this, unlocalizedName); + + if (this.getUnlocalizedName().contains("DustTiny")) { + this.name = "Tiny Pile of " + this.materialName + " Dust"; + } else if (this.getUnlocalizedName().contains("DustSmall")) { + this.name = "Small Pile of " + this.materialName + " Dust"; + } else { + this.name = this.materialName + " Dust"; + } + + String temp = ""; + Logger.WARNING("Unlocalized name for OreDict nameGen: " + this.getUnlocalizedName()); + if (this.getUnlocalizedName().contains("item.")) { + temp = this.getUnlocalizedName().replace("item.", ""); + Logger.WARNING("Generating OreDict Name: " + temp); + } else { + temp = this.getUnlocalizedName(); + } + if (temp.contains("DustTiny")) { + temp = temp.replace("itemD", "d"); + Logger.WARNING("Generating OreDict Name: " + temp); + } else if (temp.contains("DustSmall")) { + temp = temp.replace("itemD", "d"); + Logger.WARNING("Generating OreDict Name: " + temp); + } else { + temp = temp.replace("itemD", "d"); + Logger.WARNING("Generating OreDict Name: " + temp); + } + if ((temp != null) && !temp.equals("")) { + GT_OreDictUnificator.registerOre(temp, ItemUtils.getSimpleStack(this)); + } + registerComponent(); + } + + public boolean registerComponent() { + if (this.materialName == null) { + return false; + } + String aName = materialName; + // Register Component + Map aMap = Material.mComponentMap.get(aName); + if (aMap == null) { + aMap = new HashMap(); + } + String aKey = OrePrefixes.dust.name(); + ItemStack x = aMap.get(aKey); + if (x == null) { + aMap.put(aKey, ItemUtils.getSimpleStack(this)); + Logger.MATERIALS("Registering a material component. Item: [" + aName + "] Map: [" + aKey + "]"); + Material.mComponentMap.put(aName, aMap); + return true; + } else { + // Bad + Logger.MATERIALS("Tried to double register a material component. "); + return false; + } + } + + @Override + public String getItemStackDisplayName(final ItemStack iStack) { + return this.name; + } + + private String getCorrectTexture(final String pileSize) { + if (!CORE.ConfigSwitches.useGregtechTextures) { + if ((pileSize.equals("dust")) || (pileSize.equals("Dust"))) { + this.setTextureName(CORE.MODID + ":" + "dust"); + } else { + this.setTextureName(CORE.MODID + ":" + "dust" + pileSize); + } + } + if (pileSize.toLowerCase().contains("small")) { + return "gregtech" + ":" + "materialicons/SHINY/dustSmall"; + } else if (pileSize.toLowerCase().contains("tiny")) { + return "gregtech" + ":" + "materialicons/SHINY/dustTiny"; + } + return "gregtech" + ":" + "materialicons/SHINY/dust"; + } + + @SuppressWarnings({"rawtypes", "unchecked"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + if (this.sRadiation > 0) { + list.add(CORE.GT_Tooltip_Radioactive); + } + if (this.chemicalNotation.length() > 0 + && !chemicalNotation.equals("") + && !chemicalNotation.equals("NullFormula")) { + list.add(this.chemicalNotation); + } + super.addInformation(stack, aPlayer, list, bool); + } + + public final String getMaterialName() { + return StringUtils.subscript(this.materialName); + } + + @Override + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + if (this.colour == 0) { + return MathUtils.generateSingularRandomHexValue(); + } + return this.colour; + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/dusts/decimal/BaseItemCentidust.java b/src/main/java/gtPlusPlus/core/item/base/dusts/decimal/BaseItemCentidust.java index c6aff85da1..d84519d792 100644 --- a/src/main/java/gtPlusPlus/core/item/base/dusts/decimal/BaseItemCentidust.java +++ b/src/main/java/gtPlusPlus/core/item/base/dusts/decimal/BaseItemCentidust.java @@ -1,58 +1,54 @@ package gtPlusPlus.core.item.base.dusts.decimal; -import java.util.List; - import cpw.mods.fml.common.registry.GameRegistry; - +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; +import java.util.List; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.material.Material; - -public class BaseItemCentidust extends Item{ - - final Material dustMaterial; - final String materialName; - final String unlocalName; - - public BaseItemCentidust(final Material material) { - this.dustMaterial = material; - this.unlocalName = "itemCentidust"+material.getUnlocalizedName(); - this.materialName = material.getLocalizedName(); - this.setCreativeTab(AddToCreativeTab.tabMisc); - this.setUnlocalizedName(this.unlocalName); - this.setMaxStackSize(10); - this.setTextureName(CORE.MODID + ":" + "itemCentidust"); //TODO - GameRegistry.registerItem(this, this.unlocalName); - //GT_OreDictUnificator.registerOre(unlocalName.replace("itemR", "r"), UtilsItems.getSimpleStack(this)); //TODO - } - - @Override - public String getItemStackDisplayName(final ItemStack p_77653_1_) { - - return (this.materialName+ " Centidust"); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - if ((this.materialName != null) && (this.materialName != "") && !this.materialName.equals("")){ - list.add(EnumChatFormatting.GRAY+"1% of a " + this.materialName + " dust pile."); - } - super.addInformation(stack, aPlayer, list, bool); - } - - public final String getMaterialName() { - return this.materialName; - } - - @Override - public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { - return this.dustMaterial.getRgbAsHex(); - } - +public class BaseItemCentidust extends Item { + + final Material dustMaterial; + final String materialName; + final String unlocalName; + + public BaseItemCentidust(final Material material) { + this.dustMaterial = material; + this.unlocalName = "itemCentidust" + material.getUnlocalizedName(); + this.materialName = material.getLocalizedName(); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(this.unlocalName); + this.setMaxStackSize(10); + this.setTextureName(CORE.MODID + ":" + "itemCentidust"); // TODO + GameRegistry.registerItem(this, this.unlocalName); + // GT_OreDictUnificator.registerOre(unlocalName.replace("itemR", "r"), UtilsItems.getSimpleStack(this)); //TODO + } + + @Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + + return (this.materialName + " Centidust"); + } + + @SuppressWarnings({"rawtypes", "unchecked"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + if ((this.materialName != null) && (this.materialName != "") && !this.materialName.equals("")) { + list.add(EnumChatFormatting.GRAY + "1% of a " + this.materialName + " dust pile."); + } + super.addInformation(stack, aPlayer, list, bool); + } + + public final String getMaterialName() { + return this.materialName; + } + + @Override + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + return this.dustMaterial.getRgbAsHex(); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/dusts/decimal/BaseItemDecidust.java b/src/main/java/gtPlusPlus/core/item/base/dusts/decimal/BaseItemDecidust.java index 2d1b4a8d27..b49e9d3288 100644 --- a/src/main/java/gtPlusPlus/core/item/base/dusts/decimal/BaseItemDecidust.java +++ b/src/main/java/gtPlusPlus/core/item/base/dusts/decimal/BaseItemDecidust.java @@ -1,58 +1,54 @@ package gtPlusPlus.core.item.base.dusts.decimal; -import java.util.List; - import cpw.mods.fml.common.registry.GameRegistry; - +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; +import java.util.List; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.material.Material; - -public class BaseItemDecidust extends Item{ - - final Material dustMaterial; - final String materialName; - final String unlocalName; - - public BaseItemDecidust(final Material material) { - this.dustMaterial = material; - this.unlocalName = "itemDecidust"+material.getUnlocalizedName(); - this.materialName = material.getLocalizedName(); - this.setCreativeTab(AddToCreativeTab.tabMisc); - this.setUnlocalizedName(this.unlocalName); - this.setMaxStackSize(10); - this.setTextureName(CORE.MODID + ":" + "itemDecidust"); //TODO - GameRegistry.registerItem(this, this.unlocalName); - //GT_OreDictUnificator.registerOre(unlocalName.replace("itemR", "r"), UtilsItems.getSimpleStack(this)); //TODO - } - - @Override - public String getItemStackDisplayName(final ItemStack p_77653_1_) { - - return (this.materialName+ " Decidust"); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - if ((this.materialName != null) && (this.materialName != "") && !this.materialName.equals("")){ - list.add(EnumChatFormatting.GRAY+"10% of a " + this.materialName + " dust pile."); - } - super.addInformation(stack, aPlayer, list, bool); - } - - public final String getMaterialName() { - return this.materialName; - } - - @Override - public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { - return this.dustMaterial.getRgbAsHex(); - } - +public class BaseItemDecidust extends Item { + + final Material dustMaterial; + final String materialName; + final String unlocalName; + + public BaseItemDecidust(final Material material) { + this.dustMaterial = material; + this.unlocalName = "itemDecidust" + material.getUnlocalizedName(); + this.materialName = material.getLocalizedName(); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(this.unlocalName); + this.setMaxStackSize(10); + this.setTextureName(CORE.MODID + ":" + "itemDecidust"); // TODO + GameRegistry.registerItem(this, this.unlocalName); + // GT_OreDictUnificator.registerOre(unlocalName.replace("itemR", "r"), UtilsItems.getSimpleStack(this)); //TODO + } + + @Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + + return (this.materialName + " Decidust"); + } + + @SuppressWarnings({"rawtypes", "unchecked"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + if ((this.materialName != null) && (this.materialName != "") && !this.materialName.equals("")) { + list.add(EnumChatFormatting.GRAY + "10% of a " + this.materialName + " dust pile."); + } + super.addInformation(stack, aPlayer, list, bool); + } + + public final String getMaterialName() { + return this.materialName; + } + + @Override + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + return this.dustMaterial.getRgbAsHex(); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/foil/BaseItemFoil.java b/src/main/java/gtPlusPlus/core/item/base/foil/BaseItemFoil.java index 3e2816bf52..9b55461cfd 100644 --- a/src/main/java/gtPlusPlus/core/item/base/foil/BaseItemFoil.java +++ b/src/main/java/gtPlusPlus/core/item/base/foil/BaseItemFoil.java @@ -3,9 +3,9 @@ package gtPlusPlus.core.item.base.foil; import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.material.Material; -public class BaseItemFoil extends BaseItemComponent{ +public class BaseItemFoil extends BaseItemComponent { - public BaseItemFoil(final Material material) { - super(material, BaseItemComponent.ComponentTypes.FOIL); - } + public BaseItemFoil(final Material material) { + super(material, BaseItemComponent.ComponentTypes.FOIL); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/foods/BaseItemFood.java b/src/main/java/gtPlusPlus/core/item/base/foods/BaseItemFood.java index 54aa90c03f..d96e3c8565 100644 --- a/src/main/java/gtPlusPlus/core/item/base/foods/BaseItemFood.java +++ b/src/main/java/gtPlusPlus/core/item/base/foods/BaseItemFood.java @@ -1,50 +1,53 @@ package gtPlusPlus.core.item.base.foods; import cpw.mods.fml.common.registry.GameRegistry; - +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; - public class BaseItemFood extends ItemFood { - private final PotionEffect[] effects; - protected String localName; - - public BaseItemFood(final String unlocalizedName, final String localizedName, final int healAmount, final float saturationModifier, final boolean wolvesFavorite, final PotionEffect... effects) { - super(healAmount, saturationModifier, wolvesFavorite); - this.setUnlocalizedName(unlocalizedName); - this.setTextureName(CORE.MODID + ":" + unlocalizedName.replace("Hot", "")); - this.setCreativeTab(AddToCreativeTab.tabMisc); - this.effects = effects; - this.localName = localizedName; - GameRegistry.registerItem(this, unlocalizedName); - } - - @Override - protected void onFoodEaten(final ItemStack stack, final World world, final EntityPlayer player) { - super.onFoodEaten(stack, world, player); - - for (int i = 0; i < this.effects.length; i ++) { - if (!world.isRemote && (this.effects[i] != null) && (this.effects[i].getPotionID() > 0)) { - player.addPotionEffect(new PotionEffect(this.effects[i].getPotionID(), - this.effects[i].getDuration(), this.effects[i].getAmplifier(), - this.effects[i].getIsAmbient() - ) - ); - } - } - } - - @Override - public String getItemStackDisplayName(final ItemStack p_77653_1_) { - - return ("A Serving of "+this.localName); - } - -} \ No newline at end of file + private final PotionEffect[] effects; + protected String localName; + + public BaseItemFood( + final String unlocalizedName, + final String localizedName, + final int healAmount, + final float saturationModifier, + final boolean wolvesFavorite, + final PotionEffect... effects) { + super(healAmount, saturationModifier, wolvesFavorite); + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName.replace("Hot", "")); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.effects = effects; + this.localName = localizedName; + GameRegistry.registerItem(this, unlocalizedName); + } + + @Override + protected void onFoodEaten(final ItemStack stack, final World world, final EntityPlayer player) { + super.onFoodEaten(stack, world, player); + + for (int i = 0; i < this.effects.length; i++) { + if (!world.isRemote && (this.effects[i] != null) && (this.effects[i].getPotionID() > 0)) { + player.addPotionEffect(new PotionEffect( + this.effects[i].getPotionID(), + this.effects[i].getDuration(), + this.effects[i].getAmplifier(), + this.effects[i].getIsAmbient())); + } + } + } + + @Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + + return ("A Serving of " + this.localName); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/foods/BaseItemHotFood.java b/src/main/java/gtPlusPlus/core/item/base/foods/BaseItemHotFood.java index 528b9593e6..4fef548705 100644 --- a/src/main/java/gtPlusPlus/core/item/base/foods/BaseItemHotFood.java +++ b/src/main/java/gtPlusPlus/core/item/base/foods/BaseItemHotFood.java @@ -1,7 +1,10 @@ package gtPlusPlus.core.item.base.foods; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; import java.util.List; - import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -10,71 +13,77 @@ import net.minecraft.util.DamageSource; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.ItemUtils; - -public class BaseItemHotFood extends BaseItemFood{ - - protected String materialName; - protected String unlocalName; - protected int cooldownTime; - protected Item output; - - public BaseItemHotFood(final String unlocalizedName, final int healAmount, final float healSaturation, final String foodName, final int timeToCoolInSeconds, final Item cooledFood) { - super(unlocalizedName, "Hot "+foodName, healAmount, healSaturation, false); - this.unlocalName = unlocalizedName; - this.cooldownTime = timeToCoolInSeconds * 20; - this.materialName = foodName; - this.output = cooledFood; - this.setMaxStackSize(1); - } - - @Override - public ItemStack onEaten(final ItemStack iStack, final World world, final EntityPlayer player) { - return super.onEaten(iStack, world, player); - } +public class BaseItemHotFood extends BaseItemFood { - @Override - public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, final boolean p_77663_5_) { - //Utils.LOG_INFO("Item Damage: "+iStack.getItemDamage()+" Max Damage: "+iStack.getMaxDamage()); - if (!world.isRemote){ - if(iStack.getItemDamage() == this.cooldownTime) { - if (entityHolding instanceof EntityPlayer){ - Logger.INFO("Foods Done."); - ((EntityPlayer) entityHolding).inventory.addItemStackToInventory(ItemUtils.getSimpleStack(this.output)); - ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); - } - }else if(iStack.getItemDamage() < this.cooldownTime){ - iStack.setItemDamage(iStack.getItemDamage() + 1); - } - if(MathUtils.divideXintoY(iStack.getItemDamage(), 150)){ - entityHolding.attackEntityFrom(DamageSource.onFire, 1); - } + protected String materialName; + protected String unlocalName; + protected int cooldownTime; + protected Item output; + public BaseItemHotFood( + final String unlocalizedName, + final int healAmount, + final float healSaturation, + final String foodName, + final int timeToCoolInSeconds, + final Item cooledFood) { + super(unlocalizedName, "Hot " + foodName, healAmount, healSaturation, false); + this.unlocalName = unlocalizedName; + this.cooldownTime = timeToCoolInSeconds * 20; + this.materialName = foodName; + this.output = cooledFood; + this.setMaxStackSize(1); + } - } - super.onUpdate(iStack, world, entityHolding, p_77663_4_, p_77663_5_); - } + @Override + public ItemStack onEaten(final ItemStack iStack, final World world, final EntityPlayer player) { + return super.onEaten(iStack, world, player); + } - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - if ((this.materialName != null) && (this.materialName != "") && !this.materialName.equals("")){ - list.add(EnumChatFormatting.GRAY+"Warning: "+EnumChatFormatting.RED+"Very hot!"+EnumChatFormatting.GRAY+" Avoid direct handling.."); - list.add(EnumChatFormatting.GRAY+"This food has "+((this.cooldownTime-stack.getItemDamage())/20)+" seconds left, until it is cool."); - } - super.addInformation(stack, aPlayer, list, bool); - } + @Override + public void onUpdate( + final ItemStack iStack, + final World world, + final Entity entityHolding, + final int p_77663_4_, + final boolean p_77663_5_) { + // Utils.LOG_INFO("Item Damage: "+iStack.getItemDamage()+" Max Damage: "+iStack.getMaxDamage()); + if (!world.isRemote) { + if (iStack.getItemDamage() == this.cooldownTime) { + if (entityHolding instanceof EntityPlayer) { + Logger.INFO("Foods Done."); + ((EntityPlayer) entityHolding) + .inventory.addItemStackToInventory(ItemUtils.getSimpleStack(this.output)); + ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); + } + } else if (iStack.getItemDamage() < this.cooldownTime) { + iStack.setItemDamage(iStack.getItemDamage() + 1); + } + if (MathUtils.divideXintoY(iStack.getItemDamage(), 150)) { + entityHolding.attackEntityFrom(DamageSource.onFire, 1); + } + } + super.onUpdate(iStack, world, entityHolding, p_77663_4_, p_77663_5_); + } - public final String getMaterialName() { - return this.materialName; - } + @SuppressWarnings({"rawtypes", "unchecked"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + if ((this.materialName != null) && (this.materialName != "") && !this.materialName.equals("")) { + list.add(EnumChatFormatting.GRAY + "Warning: " + EnumChatFormatting.RED + "Very hot!" + + EnumChatFormatting.GRAY + " Avoid direct handling.."); + list.add(EnumChatFormatting.GRAY + "This food has " + ((this.cooldownTime - stack.getItemDamage()) / 20) + + " seconds left, until it is cool."); + } + super.addInformation(stack, aPlayer, list, bool); + } - @Override - public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { - return Utils.rgbtoHexValue(230, 96, 96); + public final String getMaterialName() { + return this.materialName; + } - } + @Override + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + return Utils.rgbtoHexValue(230, 96, 96); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/gears/BaseItemGear.java b/src/main/java/gtPlusPlus/core/item/base/gears/BaseItemGear.java index b72ea5db15..d759c7f116 100644 --- a/src/main/java/gtPlusPlus/core/item/base/gears/BaseItemGear.java +++ b/src/main/java/gtPlusPlus/core/item/base/gears/BaseItemGear.java @@ -3,9 +3,9 @@ package gtPlusPlus.core.item.base.gears; import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.material.Material; -public class BaseItemGear extends BaseItemComponent{ +public class BaseItemGear extends BaseItemComponent { - public BaseItemGear(final Material material) { - super(material, BaseItemComponent.ComponentTypes.GEAR); - } + public BaseItemGear(final Material material) { + super(material, BaseItemComponent.ComponentTypes.GEAR); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/gears/BaseItemSmallGear.java b/src/main/java/gtPlusPlus/core/item/base/gears/BaseItemSmallGear.java index 5435c692c6..ddfdbd7534 100644 --- a/src/main/java/gtPlusPlus/core/item/base/gears/BaseItemSmallGear.java +++ b/src/main/java/gtPlusPlus/core/item/base/gears/BaseItemSmallGear.java @@ -3,9 +3,9 @@ package gtPlusPlus.core.item.base.gears; import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.material.Material; -public class BaseItemSmallGear extends BaseItemComponent{ +public class BaseItemSmallGear extends BaseItemComponent { - public BaseItemSmallGear(final Material material) { - super(material, BaseItemComponent.ComponentTypes.SMALLGEAR); - } + public BaseItemSmallGear(final Material material) { + super(material, BaseItemComponent.ComponentTypes.SMALLGEAR); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/ingots/BaseItemIngot.java b/src/main/java/gtPlusPlus/core/item/base/ingots/BaseItemIngot.java index ea96e2914c..fc2748ec23 100644 --- a/src/main/java/gtPlusPlus/core/item/base/ingots/BaseItemIngot.java +++ b/src/main/java/gtPlusPlus/core/item/base/ingots/BaseItemIngot.java @@ -3,19 +3,18 @@ package gtPlusPlus.core.item.base.ingots; import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.material.Material; -public class BaseItemIngot extends BaseItemComponent{ +public class BaseItemIngot extends BaseItemComponent { - protected final String materialName; - protected final String unlocalName; + protected final String materialName; + protected final String unlocalName; - public BaseItemIngot(final Material material) { - this(material, ComponentTypes.INGOT); - } - - public BaseItemIngot(final Material material, final ComponentTypes type) { - super(material, type); - this.materialName = material.getLocalizedName(); - this.unlocalName = material.getUnlocalizedName(); - } + public BaseItemIngot(final Material material) { + this(material, ComponentTypes.INGOT); + } + public BaseItemIngot(final Material material, final ComponentTypes type) { + super(material, type); + this.materialName = material.getLocalizedName(); + this.unlocalName = material.getUnlocalizedName(); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/ingots/BaseItemIngotHot.java b/src/main/java/gtPlusPlus/core/item/base/ingots/BaseItemIngotHot.java index c19fecd924..ad1e682e3e 100644 --- a/src/main/java/gtPlusPlus/core/item/base/ingots/BaseItemIngotHot.java +++ b/src/main/java/gtPlusPlus/core/item/base/ingots/BaseItemIngotHot.java @@ -2,18 +2,6 @@ package gtPlusPlus.core.item.base.ingots; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.DamageSource; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; -import gregtech.api.GregTech_API; -import gregtech.api.enums.GT_Values; -import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.lib.CORE; @@ -21,90 +9,101 @@ import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.EntityUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; -public class BaseItemIngotHot extends BaseItemIngot{ - - private final ItemStack outputIngot; - private int tickCounter = 0; - private final int tickCounterMax = 200; - private final int mTier; - - private IIcon base; - private IIcon overlay; - - public BaseItemIngotHot(final Material material) { - super(material, ComponentTypes.HOTINGOT); - this.setTextureName(CORE.MODID + ":" + "itemIngotHot"); - this.outputIngot = material.getIngot(1); - this.mTier = material.vTier; - this.generateRecipe(); - } - - @Override - public String getItemStackDisplayName(final ItemStack p_77653_1_) { - return super.getItemStackDisplayName(p_77653_1_); - //return ("Hot "+this.materialName+ " Ingot"); - } - - @Override - public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { - return Utils.rgbtoHexValue(225, 225, 225); - } - - private void generateRecipe(){ - Logger.WARNING("Adding Vacuum Freezer recipe for a Hot Ingot of "+this.materialName+"."); - CORE.RA.addVacuumFreezerRecipe(ItemUtils.getSimpleStack(this), this.outputIngot.copy(), (int) Math.max(this.componentMaterial.getMass() * 3L, 1L), this.componentMaterial.vVoltageMultiplier); - } - - @Override - public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, final boolean p_77663_5_) { - if (this.componentMaterial != null){ - if (entityHolding != null && entityHolding instanceof EntityPlayer){ - if (!((EntityPlayer) entityHolding).capabilities.isCreativeMode){ - EntityUtils.applyHeatDamageToEntity(1, world, entityHolding); - } - } - } - super.onUpdate(iStack, world, entityHolding, p_77663_4_, p_77663_5_); - } - - @Override - @SideOnly(Side.CLIENT) - public boolean requiresMultipleRenderPasses(){ - if (CORE.ConfigSwitches.useGregtechTextures){ - return true; - } - else { - return false; - } - } - - @Override - public void registerIcons(final IIconRegister i) { - - if (CORE.ConfigSwitches.useGregtechTextures){ - this.base = i.registerIcon("gregtech" + ":" + "materialicons/METALLIC/" + "ingotHot"); - this.overlay = i.registerIcon("gregtech" + ":" + "materialicons/METALLIC/" + "ingotHot_OVERLAY"); - } - else { - this.base = i.registerIcon(CORE.MODID + ":" + "item"+BaseItemComponent.ComponentTypes.HOTINGOT.getComponent()); - //this.overlay = i.registerIcon(CORE.MODID + ":" + "item"+BaseItemComponent.ComponentTypes.HOTINGOT.getComponent()+"_Overlay"); - } - //this.overlay = cellMaterial.getFluid(1000).getFluid().get - } - - @Override - public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) { - if(pass == 0 && CORE.ConfigSwitches.useGregtechTextures) { - return this.base; - } - else if(pass == 1 && CORE.ConfigSwitches.useGregtechTextures) { - return this.overlay; - } - else { - return this.overlay; - } - } - - +public class BaseItemIngotHot extends BaseItemIngot { + + private final ItemStack outputIngot; + private int tickCounter = 0; + private final int tickCounterMax = 200; + private final int mTier; + + private IIcon base; + private IIcon overlay; + + public BaseItemIngotHot(final Material material) { + super(material, ComponentTypes.HOTINGOT); + this.setTextureName(CORE.MODID + ":" + "itemIngotHot"); + this.outputIngot = material.getIngot(1); + this.mTier = material.vTier; + this.generateRecipe(); + } + + @Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + return super.getItemStackDisplayName(p_77653_1_); + // return ("Hot "+this.materialName+ " Ingot"); + } + + @Override + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + return Utils.rgbtoHexValue(225, 225, 225); + } + + private void generateRecipe() { + Logger.WARNING("Adding Vacuum Freezer recipe for a Hot Ingot of " + this.materialName + "."); + CORE.RA.addVacuumFreezerRecipe( + ItemUtils.getSimpleStack(this), + this.outputIngot.copy(), + (int) Math.max(this.componentMaterial.getMass() * 3L, 1L), + this.componentMaterial.vVoltageMultiplier); + } + + @Override + public void onUpdate( + final ItemStack iStack, + final World world, + final Entity entityHolding, + final int p_77663_4_, + final boolean p_77663_5_) { + if (this.componentMaterial != null) { + if (entityHolding != null && entityHolding instanceof EntityPlayer) { + if (!((EntityPlayer) entityHolding).capabilities.isCreativeMode) { + EntityUtils.applyHeatDamageToEntity(1, world, entityHolding); + } + } + } + super.onUpdate(iStack, world, entityHolding, p_77663_4_, p_77663_5_); + } + + @Override + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses() { + if (CORE.ConfigSwitches.useGregtechTextures) { + return true; + } else { + return false; + } + } + + @Override + public void registerIcons(final IIconRegister i) { + + if (CORE.ConfigSwitches.useGregtechTextures) { + this.base = i.registerIcon("gregtech" + ":" + "materialicons/METALLIC/" + "ingotHot"); + this.overlay = i.registerIcon("gregtech" + ":" + "materialicons/METALLIC/" + "ingotHot_OVERLAY"); + } else { + this.base = i.registerIcon( + CORE.MODID + ":" + "item" + BaseItemComponent.ComponentTypes.HOTINGOT.getComponent()); + // this.overlay = i.registerIcon(CORE.MODID + ":" + + // "item"+BaseItemComponent.ComponentTypes.HOTINGOT.getComponent()+"_Overlay"); + } + // this.overlay = cellMaterial.getFluid(1000).getFluid().get + } + + @Override + public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) { + if (pass == 0 && CORE.ConfigSwitches.useGregtechTextures) { + return this.base; + } else if (pass == 1 && CORE.ConfigSwitches.useGregtechTextures) { + return this.overlay; + } else { + return this.overlay; + } + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/ingots/BaseItemIngot_OLD.java b/src/main/java/gtPlusPlus/core/item/base/ingots/BaseItemIngot_OLD.java index 6ad323333f..eb6b4f03b2 100644 --- a/src/main/java/gtPlusPlus/core/item/base/ingots/BaseItemIngot_OLD.java +++ b/src/main/java/gtPlusPlus/core/item/base/ingots/BaseItemIngot_OLD.java @@ -1,101 +1,98 @@ package gtPlusPlus.core.item.base.ingots; import cpw.mods.fml.common.registry.GameRegistry; - -import net.minecraft.entity.Entity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.EntityUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.entity.Entity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; -public class BaseItemIngot_OLD extends Item{ - - protected int colour; - protected String materialName; - protected String unlocalName; - - public BaseItemIngot_OLD(final String unlocalizedName, final String materialName, final int colour, final int sRadioactivity) { - this.setUnlocalizedName(unlocalizedName); - this.setCreativeTab(AddToCreativeTab.tabMisc); - this.unlocalName = unlocalizedName; - this.setMaxStackSize(64); - this.setTextureName(CORE.MODID + ":" + "itemIngot"); - this.colour = colour; - this.materialName = materialName; - this.sRadiation = sRadioactivity; - GameRegistry.registerItem(this, unlocalizedName); - String temp = ""; - if (this.unlocalName.contains("itemIngot")){ - temp = this.unlocalName.replace("itemI", "i"); - } - else if (this.unlocalName.contains("itemHotIngot")){ - temp = this.unlocalName.replace("itemHotIngot", "ingotHot"); - } - if ((temp != null) && !temp.equals("")){ - GT_OreDictUnificator.registerOre(temp, ItemUtils.getSimpleStack(this)); - } - //this.generateCompressorRecipe(); - } - - @Override - public String getItemStackDisplayName(final ItemStack p_77653_1_) { - - return (this.materialName+ " Ingot"); - } - - public final String getMaterialName() { - return this.materialName; - } - - @Override - public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { - if (this.colour == 0){ - return MathUtils.generateSingularRandomHexValue(); - } - return this.colour; - - } - - private void generateCompressorRecipe(){ - if (this.unlocalName.contains("itemIngot")){ - final ItemStack tempStack = ItemUtils.getSimpleStack(this, 9); - ItemStack tempOutput = null; - String temp = this.getUnlocalizedName().replace("item.itemIngot", "block"); - Logger.WARNING("Unlocalized name for OreDict nameGen: "+this.getUnlocalizedName()); - if (this.getUnlocalizedName().contains("item.")){ - temp = this.getUnlocalizedName().replace("item.", ""); - Logger.WARNING("Generating OreDict Name: "+temp); - } - temp = temp.replace("itemIngot", "block"); - Logger.WARNING("Generating OreDict Name: "+temp); - if ((temp != null) && !temp.equals("")){ - tempOutput = ItemUtils.getItemStackOfAmountFromOreDict(temp, 1); - if (tempOutput != null){ - GT_ModHandler.addCompressionRecipe(tempStack, tempOutput); - } - - } - } - else if (this.unlocalName.contains("itemHotIngot")){ - return; - } - - - } - - - protected final int sRadiation; - @Override - public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, final boolean p_77663_5_) { - EntityUtils.applyRadiationDamageToEntity(iStack.stackSize, this.sRadiation, world, entityHolding); - } +public class BaseItemIngot_OLD extends Item { + + protected int colour; + protected String materialName; + protected String unlocalName; + + public BaseItemIngot_OLD( + final String unlocalizedName, final String materialName, final int colour, final int sRadioactivity) { + this.setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.unlocalName = unlocalizedName; + this.setMaxStackSize(64); + this.setTextureName(CORE.MODID + ":" + "itemIngot"); + this.colour = colour; + this.materialName = materialName; + this.sRadiation = sRadioactivity; + GameRegistry.registerItem(this, unlocalizedName); + String temp = ""; + if (this.unlocalName.contains("itemIngot")) { + temp = this.unlocalName.replace("itemI", "i"); + } else if (this.unlocalName.contains("itemHotIngot")) { + temp = this.unlocalName.replace("itemHotIngot", "ingotHot"); + } + if ((temp != null) && !temp.equals("")) { + GT_OreDictUnificator.registerOre(temp, ItemUtils.getSimpleStack(this)); + } + // this.generateCompressorRecipe(); + } + + @Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + + return (this.materialName + " Ingot"); + } + + public final String getMaterialName() { + return this.materialName; + } + + @Override + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + if (this.colour == 0) { + return MathUtils.generateSingularRandomHexValue(); + } + return this.colour; + } + + private void generateCompressorRecipe() { + if (this.unlocalName.contains("itemIngot")) { + final ItemStack tempStack = ItemUtils.getSimpleStack(this, 9); + ItemStack tempOutput = null; + String temp = this.getUnlocalizedName().replace("item.itemIngot", "block"); + Logger.WARNING("Unlocalized name for OreDict nameGen: " + this.getUnlocalizedName()); + if (this.getUnlocalizedName().contains("item.")) { + temp = this.getUnlocalizedName().replace("item.", ""); + Logger.WARNING("Generating OreDict Name: " + temp); + } + temp = temp.replace("itemIngot", "block"); + Logger.WARNING("Generating OreDict Name: " + temp); + if ((temp != null) && !temp.equals("")) { + tempOutput = ItemUtils.getItemStackOfAmountFromOreDict(temp, 1); + if (tempOutput != null) { + GT_ModHandler.addCompressionRecipe(tempStack, tempOutput); + } + } + } else if (this.unlocalName.contains("itemHotIngot")) { + return; + } + } + + protected final int sRadiation; + + @Override + public void onUpdate( + final ItemStack iStack, + final World world, + final Entity entityHolding, + final int p_77663_4_, + final boolean p_77663_5_) { + EntityUtils.applyRadiationDamageToEntity(iStack.stackSize, this.sRadiation, world, entityHolding); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/itemblock/FluidItemBlock.java b/src/main/java/gtPlusPlus/core/item/base/itemblock/FluidItemBlock.java index 96b5425437..d053fde9a8 100644 --- a/src/main/java/gtPlusPlus/core/item/base/itemblock/FluidItemBlock.java +++ b/src/main/java/gtPlusPlus/core/item/base/itemblock/FluidItemBlock.java @@ -1,61 +1,70 @@ package gtPlusPlus.core.item.base.itemblock; +import gtPlusPlus.core.fluids.BlockFluidBase; +import gtPlusPlus.core.util.math.MathUtils; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -import gtPlusPlus.core.fluids.BlockFluidBase; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.material.Material; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.ItemUtils; - -public class FluidItemBlock extends ItemBlock{ - - protected final int blockColour; - final BlockFluidBase baseBlock; - String name; - - public FluidItemBlock(final Block block) { - super(block); - this.baseBlock = (BlockFluidBase) block; - this.blockColour = this.baseBlock.getRenderColor(1); - this.name = this.baseBlock.getLocalizedName().replace("tile", "").replace("fluid", "").replace("name", "").replace("block", "").replace(".", ""); - //GT_OreDictUnificator.registerOre("frameGt"+block.getUnlocalizedName().replace("tile.", "").replace("tile.BlockGtFrame", "").replace("-", "").replace("_", "").replace(" ", "").replace("FrameBox", ""), UtilsItems.getSimpleStack(this)); - } - - public int getRenderColor(final int aMeta) { - return this.blockColour; - } - - @Override - public String getItemStackDisplayName(final ItemStack iStack) { - /*if (this.thisFluid != null){ - this.name = "Molten "+this.thisFluid.getLocalizedName(); - return this.name; - }*/ - this.name = "Molten "+this.baseBlock.getLocalizedName().replace("tile", "").replace("fluid", "").replace("name", "").replace("block", "").replace(".", ""); - return this.name; - } - - @Override - public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { - if (this.blockColour == 0){ - return MathUtils.generateSingularRandomHexValue(); - } - return this.blockColour; - } - - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - /*list.add("Temperature: "+MathUtils.celsiusToKelvin(this.thisFluid.getMeltingPointC())+"K"); - if (this.sRadiation > 0){ - list.add(CORE.GT_Tooltip_Radioactive); - }*/ - super.addInformation(stack, aPlayer, list, bool); - } +public class FluidItemBlock extends ItemBlock { + + protected final int blockColour; + final BlockFluidBase baseBlock; + String name; + + public FluidItemBlock(final Block block) { + super(block); + this.baseBlock = (BlockFluidBase) block; + this.blockColour = this.baseBlock.getRenderColor(1); + this.name = this.baseBlock + .getLocalizedName() + .replace("tile", "") + .replace("fluid", "") + .replace("name", "") + .replace("block", "") + .replace(".", ""); + // GT_OreDictUnificator.registerOre("frameGt"+block.getUnlocalizedName().replace("tile.", + // "").replace("tile.BlockGtFrame", "").replace("-", "").replace("_", "").replace(" ", "").replace("FrameBox", + // ""), UtilsItems.getSimpleStack(this)); + } + + public int getRenderColor(final int aMeta) { + return this.blockColour; + } + + @Override + public String getItemStackDisplayName(final ItemStack iStack) { + /*if (this.thisFluid != null){ + this.name = "Molten "+this.thisFluid.getLocalizedName(); + return this.name; + }*/ + this.name = "Molten " + + this.baseBlock + .getLocalizedName() + .replace("tile", "") + .replace("fluid", "") + .replace("name", "") + .replace("block", "") + .replace(".", ""); + return this.name; + } + + @Override + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + if (this.blockColour == 0) { + return MathUtils.generateSingularRandomHexValue(); + } + return this.blockColour; + } + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + /*list.add("Temperature: "+MathUtils.celsiusToKelvin(this.thisFluid.getMeltingPointC())+"K"); + if (this.sRadiation > 0){ + list.add(CORE.GT_Tooltip_Radioactive); + }*/ + super.addInformation(stack, aPlayer, list, bool); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java index 14344c1817..ab54fce01c 100644 --- a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java +++ b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java @@ -1,71 +1,57 @@ package gtPlusPlus.core.item.base.itemblock; +import gtPlusPlus.api.interfaces.ITileTooltip; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -import gtPlusPlus.api.interfaces.ITileTooltip; - public class ItemBlockBasicTile extends ItemBlock { - private final int mID; - - public ItemBlockBasicTile(final Block block) { - super(block); - this.mID = ((ITileTooltip) block).getTooltipID(); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - if (this.mID == 0) { // Fish trap - list.add("This trap catches fish faster if surrounded by more water blocks"); - list.add("Can also be placed beside upto 4 other fish traps"); - list.add("Requires at least two faces touching water"); - list.add("1/1000 chance to produce triple loot."); - } - else if (this.mID == 1) { // Modularity - list.add("Used to construct modular armour & bauble upgrades.."); - } - else if (this.mID == 2) { // Trade - list.add("Allows for SMP trade-o-mat type trading."); - } - else if (this.mID == 3) { // Project - list.add("Scan any crafting recipe in this to mass fabricate them in the Autocrafter.."); - } - else if (this.mID == 4) { // Circuit Table - list.add("Easy Circuit Configuration"); - list.add("Change default setting with a Screwdriver"); - list.add("Default is used to select slot for auto-insertion"); - } - else if (this.mID == 5) { // Decayables Chest - list.add("Chest which holds radioactive materials"); - list.add("Items which decay will tick while inside"); - list.add("Place with right click"); - } - else if (this.mID == 6) { // Butterfly Killer - list.add("Kills Forestry Butterflies, Bats and other pests"); - list.add("Use either Formaldehyde or Hydrogen cyanide"); - list.add("Be weary of your neighbours"); - } - else if (this.mID == 7) { // Egg Box - list.add("A box for holding big eggs"); - } - else if (this.mID == 8){ // Volumetric Flask Setter - list.add("Easy Flask Configuration"); - list.add("Configure default input slot with a screwdriver"); - } - else if (this.mID == 9){ - - } - - else { - list.add("Bad Tooltip ID - " + mID); - } - super.addInformation(stack, aPlayer, list, bool); - } - + private final int mID; + + public ItemBlockBasicTile(final Block block) { + super(block); + this.mID = ((ITileTooltip) block).getTooltipID(); + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + if (this.mID == 0) { // Fish trap + list.add("This trap catches fish faster if surrounded by more water blocks"); + list.add("Can also be placed beside upto 4 other fish traps"); + list.add("Requires at least two faces touching water"); + list.add("1/1000 chance to produce triple loot."); + } else if (this.mID == 1) { // Modularity + list.add("Used to construct modular armour & bauble upgrades.."); + } else if (this.mID == 2) { // Trade + list.add("Allows for SMP trade-o-mat type trading."); + } else if (this.mID == 3) { // Project + list.add("Scan any crafting recipe in this to mass fabricate them in the Autocrafter.."); + } else if (this.mID == 4) { // Circuit Table + list.add("Easy Circuit Configuration"); + list.add("Change default setting with a Screwdriver"); + list.add("Default is used to select slot for auto-insertion"); + } else if (this.mID == 5) { // Decayables Chest + list.add("Chest which holds radioactive materials"); + list.add("Items which decay will tick while inside"); + list.add("Place with right click"); + } else if (this.mID == 6) { // Butterfly Killer + list.add("Kills Forestry Butterflies, Bats and other pests"); + list.add("Use either Formaldehyde or Hydrogen cyanide"); + list.add("Be weary of your neighbours"); + } else if (this.mID == 7) { // Egg Box + list.add("A box for holding big eggs"); + } else if (this.mID == 8) { // Volumetric Flask Setter + list.add("Easy Flask Configuration"); + list.add("Configure default input slot with a screwdriver"); + } else if (this.mID == 9) { + + } else { + list.add("Bad Tooltip ID - " + mID); + } + super.addInformation(stack, aPlayer, list, bool); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockDoor.java b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockDoor.java index 2aba494d6e..5afe1585ea 100644 --- a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockDoor.java +++ b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockDoor.java @@ -1,9 +1,8 @@ package gtPlusPlus.core.item.base.itemblock; -import java.util.List; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; @@ -13,88 +12,106 @@ import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class ItemBlockDoor extends ItemBlock { - @SideOnly(Side.CLIENT) - private IIcon field_150938_b; - - public ItemBlockDoor(Block p_i45328_1_) { - super(p_i45328_1_); - } - - /** - * Callback for item usage. If the item does something special on right - * clicking, he will have one of those. Return True if something happen and - * false if it don't. This is for ITEMS, not BLOCKS - */ - @Override - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, - int par5, int par6, int par7, float par8, float par9, float par10) { - if (par7 != 1) { - return false; - } else { - ++par5; - Block block; - - block = field_150939_a; - - if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) - && par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack)) { - if (!block.canPlaceBlockAt(par3World, par4, par5, par6)) { - return false; - } else { - int i1 = MathHelper.floor_double( - (double) ((par2EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3; - byte b0 = 0; - byte b1 = 0; - - if (i1 == 0) { - b1 = 1; - } - - if (i1 == 1) { - b0 = -1; - } - - if (i1 == 2) { - b1 = -1; - } - - if (i1 == 3) { - b0 = 1; - } - - int i2 = (par3World.getBlock(par4 - b0, par5, par6 - b1).isNormalCube() ? 1 : 0) - + (par3World.getBlock(par4 - b0, par5 + 1, par6 - b1).isNormalCube() ? 1 : 0); - int j1 = (par3World.getBlock(par4 + b0, par5, par6 + b1).isNormalCube() ? 1 : 0) - + (par3World.getBlock(par4 + b0, par5 + 1, par6 + b1).isNormalCube() ? 1 : 0); - boolean flag = par3World.getBlock(par4 - b0, par5, par6 - b1) == block - || par3World.getBlock(par4 - b0, par5 + 1, par6 - b1) == block; - boolean flag1 = par3World.getBlock(par4 + b0, par5, par6 + b1) == block - || par3World.getBlock(par4 + b0, par5 + 1, par6 + b1) == block; - boolean flag2 = false; - - if (flag && !flag1) { - flag2 = true; - } else if (j1 > i2) { - flag2 = true; - } - - par3World.setBlock(par4, par5, par6, block, i1, 2); - par3World.setBlock(par4, par5 + 1, par6, block, 8 | (flag2 ? 1 : 0), 2); - par3World.notifyBlocksOfNeighborChange(par4, par5, par6, block); - par3World.notifyBlocksOfNeighborChange(par4, par5 + 1, par6, block); - - --par1ItemStack.stackSize; - return true; - } - } else { - return false; - } - } - } - - @Override - public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List p_77624_3_, boolean p_77624_4_) { - p_77624_3_.add("This is a block, you can place it by right clicking"); - super.addInformation(p_77624_1_, p_77624_2_, p_77624_3_, p_77624_4_); - } -} \ No newline at end of file + @SideOnly(Side.CLIENT) + private IIcon field_150938_b; + + public ItemBlockDoor(Block p_i45328_1_) { + super(p_i45328_1_); + } + + /** + * Callback for item usage. If the item does something special on right + * clicking, he will have one of those. Return True if something happen and + * false if it don't. This is for ITEMS, not BLOCKS + */ + @Override + public boolean onItemUse( + ItemStack par1ItemStack, + EntityPlayer par2EntityPlayer, + World par3World, + int par4, + int par5, + int par6, + int par7, + float par8, + float par9, + float par10) { + if (par7 != 1) { + return false; + } else { + ++par5; + Block block; + + block = field_150939_a; + + if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) + && par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack)) { + if (!block.canPlaceBlockAt(par3World, par4, par5, par6)) { + return false; + } else { + int i1 = MathHelper.floor_double( + (double) ((par2EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) + & 3; + byte b0 = 0; + byte b1 = 0; + + if (i1 == 0) { + b1 = 1; + } + + if (i1 == 1) { + b0 = -1; + } + + if (i1 == 2) { + b1 = -1; + } + + if (i1 == 3) { + b0 = 1; + } + + int i2 = (par3World.getBlock(par4 - b0, par5, par6 - b1).isNormalCube() ? 1 : 0) + + (par3World + .getBlock(par4 - b0, par5 + 1, par6 - b1) + .isNormalCube() + ? 1 + : 0); + int j1 = (par3World.getBlock(par4 + b0, par5, par6 + b1).isNormalCube() ? 1 : 0) + + (par3World + .getBlock(par4 + b0, par5 + 1, par6 + b1) + .isNormalCube() + ? 1 + : 0); + boolean flag = par3World.getBlock(par4 - b0, par5, par6 - b1) == block + || par3World.getBlock(par4 - b0, par5 + 1, par6 - b1) == block; + boolean flag1 = par3World.getBlock(par4 + b0, par5, par6 + b1) == block + || par3World.getBlock(par4 + b0, par5 + 1, par6 + b1) == block; + boolean flag2 = false; + + if (flag && !flag1) { + flag2 = true; + } else if (j1 > i2) { + flag2 = true; + } + + par3World.setBlock(par4, par5, par6, block, i1, 2); + par3World.setBlock(par4, par5 + 1, par6, block, 8 | (flag2 ? 1 : 0), 2); + par3World.notifyBlocksOfNeighborChange(par4, par5, par6, block); + par3World.notifyBlocksOfNeighborChange(par4, par5 + 1, par6, block); + + --par1ItemStack.stackSize; + return true; + } + } else { + return false; + } + } + } + + @Override + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List p_77624_3_, boolean p_77624_4_) { + p_77624_3_.add("This is a block, you can place it by right clicking"); + super.addInformation(p_77624_1_, p_77624_2_, p_77624_3_, p_77624_4_); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java index ac6740f268..5c307a6900 100644 --- a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java +++ b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java @@ -1,41 +1,38 @@ package gtPlusPlus.core.item.base.itemblock; +import gtPlusPlus.core.block.general.BlockTankXpConverter; +import gtPlusPlus.core.creative.AddToCreativeTab; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; -import gtPlusPlus.core.block.general.BlockTankXpConverter; -import gtPlusPlus.core.creative.AddToCreativeTab; - public class ItemBlockEntityBase extends ItemBlock { - public ItemBlockEntityBase(final Block block) { - super(block); - this.setMaxDamage(0); - //this.setHasSubtypes(true); - this.setCreativeTab(AddToCreativeTab.tabMachines); - } - - @Override - public int getColorFromItemStack(final ItemStack p_82790_1_, final int p_82790_2_) { - return super.getColorFromItemStack(p_82790_1_, p_82790_2_); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public final void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - if (Block.getBlockFromItem(stack.getItem()) instanceof BlockTankXpConverter){ - /*list.add(EnumChatFormatting.GRAY+"Can convert Liquid Xp to Mob Essence and back."); - list.add(EnumChatFormatting.GRAY+"Right click with a Screwdriver to change mode."); - list.add(EnumChatFormatting.GRAY+"Shift+Right click to view tank information.");*/ - list.add(EnumChatFormatting.GRAY+"Currently disabled, Use a GT Brewery instead. (New Recipes Added!)"); - } - super.addInformation(stack, aPlayer, list, bool); - } - - -} \ No newline at end of file + public ItemBlockEntityBase(final Block block) { + super(block); + this.setMaxDamage(0); + // this.setHasSubtypes(true); + this.setCreativeTab(AddToCreativeTab.tabMachines); + } + + @Override + public int getColorFromItemStack(final ItemStack p_82790_1_, final int p_82790_2_) { + return super.getColorFromItemStack(p_82790_1_, p_82790_2_); + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public final void addInformation( + final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + if (Block.getBlockFromItem(stack.getItem()) instanceof BlockTankXpConverter) { + /*list.add(EnumChatFormatting.GRAY+"Can convert Liquid Xp to Mob Essence and back."); + list.add(EnumChatFormatting.GRAY+"Right click with a Screwdriver to change mode."); + list.add(EnumChatFormatting.GRAY+"Shift+Right click to view tank information.");*/ + list.add(EnumChatFormatting.GRAY + "Currently disabled, Use a GT Brewery instead. (New Recipes Added!)"); + } + super.addInformation(stack, aPlayer, list, bool); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtBlock.java b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtBlock.java index af6f036942..aa4f26b473 100644 --- a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtBlock.java +++ b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtBlock.java @@ -1,11 +1,6 @@ package gtPlusPlus.core.item.base.itemblock; -import java.util.HashMap; -import java.util.List; - -import gregtech.api.util.GT_LanguageManager; import gtPlusPlus.core.block.base.BasicBlock.BlockTypes; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.base.BlockBaseModular; import gtPlusPlus.core.block.base.BlockBaseOre; import gtPlusPlus.core.lib.CORE; @@ -13,6 +8,8 @@ import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.MaterialStack; import gtPlusPlus.core.util.minecraft.EntityUtils; import gtPlusPlus.core.util.sys.KeyboardUtils; +import java.util.HashMap; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -23,170 +20,168 @@ import net.minecraft.world.World; public class ItemBlockGtBlock extends ItemBlock { - public static HashMap sNameCache = new HashMap(); - - protected final int blockColour; - private int sRadiation; - - private Material mMaterial; - protected BlockTypes thisBlockType; - - private final Block thisBlock; - private boolean isOre = false; - private boolean isModular = false; - - public ItemBlockGtBlock(final Block block) { - super(block); - this.thisBlock = block; - if (block instanceof BlockBaseOre) { - this.isOre = true; - } else if (block instanceof BlockBaseModular) { - this.isModular = true; - } - final BlockBaseModular baseBlock = (BlockBaseModular) block; - if (isModular) { - this.blockColour = baseBlock.getRenderColor(0); - } else if (isOre) { - this.blockColour = block.getBlockColor(); - } else { - this.blockColour = block.getBlockColor(); - } - - if (block instanceof BlockBaseModular){ - BlockBaseModular g = (BlockBaseModular) block; - this.mMaterial = g.getMaterialEx(); - this.thisBlockType = g.thisBlock; - } - else { - this.mMaterial = null; - this.thisBlockType = BlockTypes.STANDARD; - } - - } - - public int getBlockTypeMeta() { - if (this.thisBlockType.equals(BlockTypes.STANDARD)) { - return 0; - } - else if (this.thisBlockType.equals(BlockTypes.FRAME)) { - return 1; - } - else if (this.thisBlockType.equals(BlockTypes.ORE)) { - return 2; - } - return 0; - } - - public String getUnlocalizedBlockName() { - return "block."+mMaterial.getUnlocalizedName()+"."+this.thisBlockType.name().toLowerCase(); - } - - public String GetProperName() { - String tempIngot = sNameCache.get(getUnlocalizedBlockName()); - if (tempIngot == null) { - tempIngot = "BAD.UNLOCAL.NAME"; - } - return tempIngot; - } - - @Override - public String getItemStackDisplayName(ItemStack stack) { - return this.thisBlock.getLocalizedName(); - //Logger.INFO("Unlocal Name: "+this.getUnlocalizedName()); - //String aFormattedLangName = GetProperName(); - //return GT_LanguageManager.addStringLocalization("block."+mMaterial.getUnlocalizedName()+"."+this.thisBlockType.name().toLowerCase()+".name", aFormattedLangName); - } - - public int getRenderColor(final int aMeta) { - return this.blockColour; - } - - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - - if (this.mMaterial != null) { - list.add(this.mMaterial.vChemicalFormula); - } else { - - try { - BlockBaseModular g = (BlockBaseModular) thisBlock; - this.mMaterial = g.getMaterialEx(); - } - catch (Throwable t) { - - } - - - //list.add("Material is Null."); - } - - if (this.isOre) { - if (KeyboardUtils.isCtrlKeyDown()) { - Block b = Block.getBlockFromItem(stack.getItem()); - if (b != null) { - - String aTool = b.getHarvestTool(stack.getItemDamage()); - int aMiningLevel1 = b.getHarvestLevel(stack.getItemDamage()); - - if (this.mMaterial != null) { - list.add("Mining Level: " + Math.min(Math.max(aMiningLevel1, 0), 5)); - list.add("Contains: "); - if (mMaterial.getComposites().isEmpty()) { - list.add("- " + mMaterial.getLocalizedName()); - } else { - for (MaterialStack m : mMaterial.getComposites()) { - list.add("- " + m.getStackMaterial().getLocalizedName() + " x" + m.getPartsPerOneHundred()); - } - } - } - } - } else { - list.add(EnumChatFormatting.DARK_GRAY + "Hold Ctrl to show additional info."); - } - } - else { - Block b = Block.getBlockFromItem(stack.getItem()); - if (b != null) { - String aTool = b.getHarvestTool(stack.getItemDamage()); - int aMiningLevel1 = b.getHarvestLevel(stack.getItemDamage()); - list.add("Mining Level: " + Math.min(Math.max(aMiningLevel1, 0), 5)); - } - } - - if (this.mMaterial != null) { - if (this.mMaterial.vRadiationLevel > 0) { - list.add(CORE.GT_Tooltip_Radioactive); - } - } - - super.addInformation(stack, aPlayer, list, bool); - } - - @Override - public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, - final boolean p_77663_5_) { - - if (!isModular && !isOre) { - mMaterial = null; - } else { - if (this.mMaterial == null) { - Block b = Block.getBlockFromItem(iStack.getItem()); - if (isOre) { - mMaterial = ((BlockBaseOre) b).getMaterialEx(); - } else { - mMaterial = ((BlockBaseModular) b).getMaterialEx(); - } - if (mMaterial != null) { - this.sRadiation = mMaterial.vRadiationLevel; - } else { - this.sRadiation = 0; - } - } - if (this.sRadiation > 0) { - EntityUtils.applyRadiationDamageToEntity(iStack.stackSize, this.sRadiation, world, entityHolding); - } - } - - } - + public static HashMap sNameCache = new HashMap(); + + protected final int blockColour; + private int sRadiation; + + private Material mMaterial; + protected BlockTypes thisBlockType; + + private final Block thisBlock; + private boolean isOre = false; + private boolean isModular = false; + + public ItemBlockGtBlock(final Block block) { + super(block); + this.thisBlock = block; + if (block instanceof BlockBaseOre) { + this.isOre = true; + } else if (block instanceof BlockBaseModular) { + this.isModular = true; + } + final BlockBaseModular baseBlock = (BlockBaseModular) block; + if (isModular) { + this.blockColour = baseBlock.getRenderColor(0); + } else if (isOre) { + this.blockColour = block.getBlockColor(); + } else { + this.blockColour = block.getBlockColor(); + } + + if (block instanceof BlockBaseModular) { + BlockBaseModular g = (BlockBaseModular) block; + this.mMaterial = g.getMaterialEx(); + this.thisBlockType = g.thisBlock; + } else { + this.mMaterial = null; + this.thisBlockType = BlockTypes.STANDARD; + } + } + + public int getBlockTypeMeta() { + if (this.thisBlockType.equals(BlockTypes.STANDARD)) { + return 0; + } else if (this.thisBlockType.equals(BlockTypes.FRAME)) { + return 1; + } else if (this.thisBlockType.equals(BlockTypes.ORE)) { + return 2; + } + return 0; + } + + public String getUnlocalizedBlockName() { + return "block." + mMaterial.getUnlocalizedName() + "." + + this.thisBlockType.name().toLowerCase(); + } + + public String GetProperName() { + String tempIngot = sNameCache.get(getUnlocalizedBlockName()); + if (tempIngot == null) { + tempIngot = "BAD.UNLOCAL.NAME"; + } + return tempIngot; + } + + @Override + public String getItemStackDisplayName(ItemStack stack) { + return this.thisBlock.getLocalizedName(); + // Logger.INFO("Unlocal Name: "+this.getUnlocalizedName()); + // String aFormattedLangName = GetProperName(); + // return + // GT_LanguageManager.addStringLocalization("block."+mMaterial.getUnlocalizedName()+"."+this.thisBlockType.name().toLowerCase()+".name", aFormattedLangName); + } + + public int getRenderColor(final int aMeta) { + return this.blockColour; + } + + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + + if (this.mMaterial != null) { + list.add(this.mMaterial.vChemicalFormula); + } else { + + try { + BlockBaseModular g = (BlockBaseModular) thisBlock; + this.mMaterial = g.getMaterialEx(); + } catch (Throwable t) { + + } + + // list.add("Material is Null."); + } + + if (this.isOre) { + if (KeyboardUtils.isCtrlKeyDown()) { + Block b = Block.getBlockFromItem(stack.getItem()); + if (b != null) { + + String aTool = b.getHarvestTool(stack.getItemDamage()); + int aMiningLevel1 = b.getHarvestLevel(stack.getItemDamage()); + + if (this.mMaterial != null) { + list.add("Mining Level: " + Math.min(Math.max(aMiningLevel1, 0), 5)); + list.add("Contains: "); + if (mMaterial.getComposites().isEmpty()) { + list.add("- " + mMaterial.getLocalizedName()); + } else { + for (MaterialStack m : mMaterial.getComposites()) { + list.add("- " + m.getStackMaterial().getLocalizedName() + " x" + + m.getPartsPerOneHundred()); + } + } + } + } + } else { + list.add(EnumChatFormatting.DARK_GRAY + "Hold Ctrl to show additional info."); + } + } else { + Block b = Block.getBlockFromItem(stack.getItem()); + if (b != null) { + String aTool = b.getHarvestTool(stack.getItemDamage()); + int aMiningLevel1 = b.getHarvestLevel(stack.getItemDamage()); + list.add("Mining Level: " + Math.min(Math.max(aMiningLevel1, 0), 5)); + } + } + + if (this.mMaterial != null) { + if (this.mMaterial.vRadiationLevel > 0) { + list.add(CORE.GT_Tooltip_Radioactive); + } + } + + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public void onUpdate( + final ItemStack iStack, + final World world, + final Entity entityHolding, + final int p_77663_4_, + final boolean p_77663_5_) { + + if (!isModular && !isOre) { + mMaterial = null; + } else { + if (this.mMaterial == null) { + Block b = Block.getBlockFromItem(iStack.getItem()); + if (isOre) { + mMaterial = ((BlockBaseOre) b).getMaterialEx(); + } else { + mMaterial = ((BlockBaseModular) b).getMaterialEx(); + } + if (mMaterial != null) { + this.sRadiation = mMaterial.vRadiationLevel; + } else { + this.sRadiation = 0; + } + } + if (this.sRadiation > 0) { + EntityUtils.applyRadiationDamageToEntity(iStack.stackSize, this.sRadiation, world, entityHolding); + } + } + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtFrameBox.java b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtFrameBox.java index 0dd125bf7b..81bc47daa3 100644 --- a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtFrameBox.java +++ b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtFrameBox.java @@ -1,5 +1,12 @@ package gtPlusPlus.core.item.base.itemblock; +import gtPlusPlus.core.block.base.BlockBaseModular; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.MaterialStack; +import gtPlusPlus.core.util.minecraft.EntityUtils; +import gtPlusPlus.core.util.sys.KeyboardUtils; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -8,87 +15,79 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; -import java.util.List; - -import gtPlusPlus.core.block.base.BlockBaseModular; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.material.Material; -import gtPlusPlus.core.material.MaterialStack; -import gtPlusPlus.core.util.minecraft.EntityUtils; -import gtPlusPlus.core.util.sys.KeyboardUtils; - -public class ItemBlockGtFrameBox extends ItemBlock{ - - protected int blockColour; - private Material mMaterial; - private int sRadiation; +public class ItemBlockGtFrameBox extends ItemBlock { - public ItemBlockGtFrameBox(final Block block) { - super(block); - final BlockBaseModular baseBlock = (BlockBaseModular) block; - this.blockColour = baseBlock.getRenderColor(1); - + protected int blockColour; + private Material mMaterial; + private int sRadiation; + public ItemBlockGtFrameBox(final Block block) { + super(block); + final BlockBaseModular baseBlock = (BlockBaseModular) block; + this.blockColour = baseBlock.getRenderColor(1); - if (block instanceof BlockBaseModular){ - BlockBaseModular g = (BlockBaseModular) block; - this.mMaterial = g.getMaterialEx(); - sRadiation = mMaterial.vRadiationLevel; - } - else { - this.mMaterial = null; - sRadiation = 0; - } - - //GT_OreDictUnificator.registerOre("frameGt"+block.getUnlocalizedName().replace("tile.", "").replace("tile.BlockGtFrame", "").replace("-", "").replace("_", "").replace(" ", "").replace("FrameBox", ""), ItemUtils.getSimpleStack(this)); - } + if (block instanceof BlockBaseModular) { + BlockBaseModular g = (BlockBaseModular) block; + this.mMaterial = g.getMaterialEx(); + sRadiation = mMaterial.vRadiationLevel; + } else { + this.mMaterial = null; + sRadiation = 0; + } - public int getRenderColor(final int aMeta) { - return this.blockColour; - } + // GT_OreDictUnificator.registerOre("frameGt"+block.getUnlocalizedName().replace("tile.", + // "").replace("tile.BlockGtFrame", "").replace("-", "").replace("_", "").replace(" ", "").replace("FrameBox", + // ""), ItemUtils.getSimpleStack(this)); + } - @SuppressWarnings("unchecked") - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - if (this.mMaterial != null) { - list.add(this.mMaterial.vChemicalFormula); - if (this.mMaterial.vRadiationLevel > 0) { - list.add(CORE.GT_Tooltip_Radioactive); - } - } else { - list.add("Material is Null."); - } - if (KeyboardUtils.isCtrlKeyDown()) { - Block b = Block.getBlockFromItem(stack.getItem()); - if (b != null) { - String aTool = b.getHarvestTool(stack.getItemDamage()); - int aMiningLevel1 = b.getHarvestLevel(stack.getItemDamage()); - list.add("Mining Level: " + Math.min(Math.max(aMiningLevel1, 0), 5)); - if (this.mMaterial != null) { - list.add("Contains: "); - if (mMaterial.getComposites().isEmpty()) { - list.add("- " + mMaterial.getLocalizedName()); - } else { - for (MaterialStack m : mMaterial.getComposites()) { - list.add("- " + m.getStackMaterial().getLocalizedName() + " x" + m.getPartsPerOneHundred()); - } - } - } - } - } else { - list.add(EnumChatFormatting.DARK_GRAY + "Hold Ctrl to show additional info."); - } - super.addInformation(stack, aPlayer, list, bool); - } + public int getRenderColor(final int aMeta) { + return this.blockColour; + } - @Override - public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, - final boolean p_77663_5_) { + @SuppressWarnings("unchecked") + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + if (this.mMaterial != null) { + list.add(this.mMaterial.vChemicalFormula); + if (this.mMaterial.vRadiationLevel > 0) { + list.add(CORE.GT_Tooltip_Radioactive); + } + } else { + list.add("Material is Null."); + } + if (KeyboardUtils.isCtrlKeyDown()) { + Block b = Block.getBlockFromItem(stack.getItem()); + if (b != null) { + String aTool = b.getHarvestTool(stack.getItemDamage()); + int aMiningLevel1 = b.getHarvestLevel(stack.getItemDamage()); + list.add("Mining Level: " + Math.min(Math.max(aMiningLevel1, 0), 5)); + if (this.mMaterial != null) { + list.add("Contains: "); + if (mMaterial.getComposites().isEmpty()) { + list.add("- " + mMaterial.getLocalizedName()); + } else { + for (MaterialStack m : mMaterial.getComposites()) { + list.add("- " + m.getStackMaterial().getLocalizedName() + " x" + m.getPartsPerOneHundred()); + } + } + } + } + } else { + list.add(EnumChatFormatting.DARK_GRAY + "Hold Ctrl to show additional info."); + } + super.addInformation(stack, aPlayer, list, bool); + } - if (this.sRadiation > 0) { - EntityUtils.applyRadiationDamageToEntity(iStack.stackSize, this.sRadiation, world, entityHolding); - } - } - + @Override + public void onUpdate( + final ItemStack iStack, + final World world, + final Entity entityHolding, + final int p_77663_4_, + final boolean p_77663_5_) { + if (this.sRadiation > 0) { + EntityUtils.applyRadiationDamageToEntity(iStack.stackSize, this.sRadiation, world, entityHolding); + } + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java index b26ac67225..dd2307d834 100644 --- a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java +++ b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java @@ -1,114 +1,109 @@ package gtPlusPlus.core.item.base.itemblock; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.api.interfaces.ITileTooltip; import gtPlusPlus.api.objects.data.AutoMap; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlockWithMetadata; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -public class ItemBlockMeta extends ItemBlockWithMetadata -{ - private final Block mBlock; - private HashMap> aTooltips = new LinkedHashMap>(); +public class ItemBlockMeta extends ItemBlockWithMetadata { + private final Block mBlock; + private HashMap> aTooltips = new LinkedHashMap>(); - public ItemBlockMeta(final Block aBlock) - { - super(aBlock, aBlock); - this.mBlock = aBlock; - this.setMaxDamage(0); - this.setHasSubtypes(true); - if (aBlock instanceof ITileTooltip) { - ITileTooltip aTooltip = (ITileTooltip) aBlock; - //aTooltips.put(aTooltip.getTooltipID(), aTooltip.getTooltipMap()); - } - } - + public ItemBlockMeta(final Block aBlock) { + super(aBlock, aBlock); + this.mBlock = aBlock; + this.setMaxDamage(0); + this.setHasSubtypes(true); + if (aBlock instanceof ITileTooltip) { + ITileTooltip aTooltip = (ITileTooltip) aBlock; + // aTooltips.put(aTooltip.getTooltipID(), aTooltip.getTooltipMap()); + } + } - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - Block aThis = Block.getBlockFromItem(stack.getItem()); - if (aThis != null) { - if (!aTooltips.isEmpty()) { - AutoMap h = aTooltips.get(stack.getItemDamage()); - if (h != null && !h.isEmpty()) { - for (String s : h) { - list.add(s); - } - } - } - } - super.addInformation(stack, aPlayer, list, bool); - } + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + Block aThis = Block.getBlockFromItem(stack.getItem()); + if (aThis != null) { + if (!aTooltips.isEmpty()) { + AutoMap h = aTooltips.get(stack.getItemDamage()); + if (h != null && !h.isEmpty()) { + for (String s : h) { + list.add(s); + } + } + } + } + super.addInformation(stack, aPlayer, list, bool); + } - /** - * Gets an icon index based on an item's damage value - */ - @Override - @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(final int p_77617_1_) - { - return this.mBlock.getIcon(2, p_77617_1_); - } + /** + * Gets an icon index based on an item's damage value + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(final int p_77617_1_) { + return this.mBlock.getIcon(2, p_77617_1_); + } - /** - * Returns the metadata of the block which this Item (ItemBlock) can place - */ - @Override - public int getMetadata(final int p_77647_1_) - { - return p_77647_1_; - } + /** + * Returns the metadata of the block which this Item (ItemBlock) can place + */ + @Override + public int getMetadata(final int p_77647_1_) { + return p_77647_1_; + } - @Override - public String getUnlocalizedName(final ItemStack stack) { - return this.getUnlocalizedName() + "." + stack.getItemDamage(); - } + @Override + public String getUnlocalizedName(final ItemStack stack) { + return this.getUnlocalizedName() + "." + stack.getItemDamage(); + } - @Override - public boolean isDamageable() { - return false; - } + @Override + public boolean isDamageable() { + return false; + } - @Override - public int getItemEnchantability() { - return 0; - } + @Override + public int getItemEnchantability() { + return 0; + } - @Override - public boolean getIsRepairable(ItemStack p_82789_1_, ItemStack p_82789_2_) { - return false; - } + @Override + public boolean getIsRepairable(ItemStack p_82789_1_, ItemStack p_82789_2_) { + return false; + } - @Override - public boolean isBookEnchantable(ItemStack stack, ItemStack book) { - return false; - } + @Override + public boolean isBookEnchantable(ItemStack stack, ItemStack book) { + return false; + } - @Override - public int getDisplayDamage(ItemStack stack) { - return 0; - } + @Override + public int getDisplayDamage(ItemStack stack) { + return 0; + } - @Override - public boolean showDurabilityBar(ItemStack stack) { - return false; - } + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } - @Override - public double getDurabilityForDisplay(ItemStack stack) { - return 0; - } + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 0; + } - @Override - public int getItemEnchantability(ItemStack stack) { - return 0; - } -} \ No newline at end of file + @Override + public int getItemEnchantability(ItemStack stack) { + return 0; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockNBT.java b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockNBT.java index 99367c5ef5..fbaa9be8a3 100644 --- a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockNBT.java +++ b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockNBT.java @@ -1,7 +1,11 @@ package gtPlusPlus.core.item.base.itemblock; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.interfaces.ITileTooltip; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.tileentities.base.TileEntityBase; +import gtPlusPlus.core.util.minecraft.PlayerUtils; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -11,94 +15,90 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -import gregtech.api.util.GT_Utility; - -import gtPlusPlus.api.interfaces.ITileTooltip; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.tileentities.base.TileEntityBase; -import gtPlusPlus.core.util.minecraft.PlayerUtils; - public class ItemBlockNBT extends ItemBlock { - - protected final int mID; - - public ItemBlockNBT(final Block block) { - super(block); - this.mID = ((ITileTooltip) block).getTooltipID(); - } - - - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - - //if () - - - - if (this.mID == 0){ //blockDarkWorldPortalFrame - list.add("Assembled in the same shape as the Nether Portal."); - } - } - - - - @Override - public void onCreated(ItemStack item, World world, EntityPlayer player) { - addNBT(player, item); - super.onCreated(item, world, player); - } - - @Override - public void onUpdate(ItemStack item, World world, Entity entity, int p_77663_4_, boolean p_77663_5_) { - if (entity instanceof EntityPlayerMP) { - EntityPlayerMP mPlayer = (EntityPlayerMP) entity; - - NBTTagCompound rNBT = item.getTagCompound(); - rNBT = ((rNBT == null) ? new NBTTagCompound() : rNBT); - if (!rNBT.hasKey("mOwner")){ - addNBT(mPlayer, item); - } - } - super.onUpdate(item, world, entity, p_77663_4_, p_77663_5_); - } - - private void addNBT(EntityPlayer player, ItemStack item) { - NBTTagCompound rNBT = item.getTagCompound(); - rNBT = ((rNBT == null) ? new NBTTagCompound() : rNBT); - if (player != null) { - boolean mOP = PlayerUtils.isPlayerOP(player); - rNBT.setString("mOwner", player.getDisplayName()); - rNBT.setString("mUUID", ""+player.getUniqueID()); - rNBT.setBoolean("mOP", mOP); - } - else if (player == null) { - rNBT.setString("mOwner", "fakeplayer"); - rNBT.setString("mUUID", "00000000"); - rNBT.setBoolean("mOP", false); - } - GT_Utility.ItemNBT.setNBT(item, rNBT); - } - - @Override - public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int side, - float hitX, float hitY, float hitZ, int aMeta) { - if (!(aWorld.setBlock(aX, aY, aZ, this.field_150939_a, 0, 3))) { - return false; - } - if (aWorld.getBlock(aX, aY, aZ) == this.field_150939_a) { - this.field_150939_a.onBlockPlacedBy(aWorld, aX, aY, aZ, aPlayer, aStack); - this.field_150939_a.onPostBlockPlaced(aWorld, aX, aY, aZ, aMeta); - } - TileEntityBase tTileEntity = (TileEntityBase) aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity != null && aPlayer != null) { - if (tTileEntity.isServerSide()){ - Logger.INFO("Setting Tile Entity information"); - NBTTagCompound aNBT = GT_Utility.ItemNBT.getNBT(aStack); - tTileEntity.setOwnerInformation(aNBT.getString("mOwner"), aNBT.getString("mUUID"), aNBT.getBoolean("mOP")); - } - } - return true; - } - -} \ No newline at end of file + protected final int mID; + + public ItemBlockNBT(final Block block) { + super(block); + this.mID = ((ITileTooltip) block).getTooltipID(); + } + + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + + // if () + + if (this.mID == 0) { // blockDarkWorldPortalFrame + list.add("Assembled in the same shape as the Nether Portal."); + } + } + + @Override + public void onCreated(ItemStack item, World world, EntityPlayer player) { + addNBT(player, item); + super.onCreated(item, world, player); + } + + @Override + public void onUpdate(ItemStack item, World world, Entity entity, int p_77663_4_, boolean p_77663_5_) { + if (entity instanceof EntityPlayerMP) { + EntityPlayerMP mPlayer = (EntityPlayerMP) entity; + + NBTTagCompound rNBT = item.getTagCompound(); + rNBT = ((rNBT == null) ? new NBTTagCompound() : rNBT); + if (!rNBT.hasKey("mOwner")) { + addNBT(mPlayer, item); + } + } + super.onUpdate(item, world, entity, p_77663_4_, p_77663_5_); + } + + private void addNBT(EntityPlayer player, ItemStack item) { + NBTTagCompound rNBT = item.getTagCompound(); + rNBT = ((rNBT == null) ? new NBTTagCompound() : rNBT); + if (player != null) { + boolean mOP = PlayerUtils.isPlayerOP(player); + rNBT.setString("mOwner", player.getDisplayName()); + rNBT.setString("mUUID", "" + player.getUniqueID()); + rNBT.setBoolean("mOP", mOP); + } else if (player == null) { + rNBT.setString("mOwner", "fakeplayer"); + rNBT.setString("mUUID", "00000000"); + rNBT.setBoolean("mOP", false); + } + GT_Utility.ItemNBT.setNBT(item, rNBT); + } + + @Override + public boolean placeBlockAt( + ItemStack aStack, + EntityPlayer aPlayer, + World aWorld, + int aX, + int aY, + int aZ, + int side, + float hitX, + float hitY, + float hitZ, + int aMeta) { + if (!(aWorld.setBlock(aX, aY, aZ, this.field_150939_a, 0, 3))) { + return false; + } + if (aWorld.getBlock(aX, aY, aZ) == this.field_150939_a) { + this.field_150939_a.onBlockPlacedBy(aWorld, aX, aY, aZ, aPlayer, aStack); + this.field_150939_a.onPostBlockPlaced(aWorld, aX, aY, aZ, aMeta); + } + TileEntityBase tTileEntity = (TileEntityBase) aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity != null && aPlayer != null) { + if (tTileEntity.isServerSide()) { + Logger.INFO("Setting Tile Entity information"); + NBTTagCompound aNBT = GT_Utility.ItemNBT.getNBT(aStack); + tTileEntity.setOwnerInformation( + aNBT.getString("mOwner"), aNBT.getString("mUUID"), aNBT.getBoolean("mOP")); + } + } + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockOre.java b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockOre.java index e4079521d4..cc5bcf1222 100644 --- a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockOre.java +++ b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockOre.java @@ -1,16 +1,5 @@ package gtPlusPlus.core.item.base.itemblock; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import net.minecraft.block.Block; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.world.World; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.block.base.BlockBaseOre; import gtPlusPlus.core.lib.CORE; @@ -21,141 +10,149 @@ import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.EntityUtils; import gtPlusPlus.core.util.sys.KeyboardUtils; import gtPlusPlus.everglades.gen.gt.WorldGen_GT_Ore_Layer; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; -public class ItemBlockOre extends ItemBlock{ - - private final BlockBaseOre mThisOre; - private final Material mThisMaterial; - private final int mThisRadiation; - private final int mThisColour; - - public ItemBlockOre(final Block block) { - super(block); - if (block instanceof BlockBaseOre){ - this.mThisOre = (BlockBaseOre) block; - this.mThisMaterial = this.mThisOre.getMaterialEx(); - this.mThisRadiation = this.mThisMaterial.vRadiationLevel; - this.mThisColour = this.mThisMaterial.getRgbAsHex(); - } - else { - this.mThisOre = null; - this.mThisMaterial = null; - this.mThisRadiation = 0; - this.mThisColour = Utils.rgbtoHexValue(255, 255, 255); - } - } - - public int getRenderColor(final int aMeta) { - return this.mThisColour; - } - - private static Map> mMapOreBlockItemToDimName = new LinkedHashMap>(); - private static boolean mInitOres_Everglades = false; - private AutoMap mDimsForThisOre = new AutoMap(); - - - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - - if (!mInitOres_Everglades) { - for (WorldGen_GT_Ore_Layer f : gtPlusPlus.everglades.gen.gt.WorldGen_Ores.validOreveins.values()) { - Material[] m2 = new Material[] {f.mPrimary, f.mSecondary, f.mBetween, f.mSporadic}; - for (Material m1 : m2) { - AutoMap aMap = mMapOreBlockItemToDimName.get(m1.getUnlocalizedName().toLowerCase()); - if (aMap == null) { - aMap = new AutoMap(); - } - String aDimName = "Everglades"; - if (!aMap.containsValue(aDimName)) { - aMap.put(aDimName); - } - mMapOreBlockItemToDimName.put(m1.getUnlocalizedName().toLowerCase(), aMap); - } - } - mInitOres_Everglades = true; - } - - - if (this.mThisMaterial != null){ - list.add(this.mThisMaterial.vChemicalFormula); - } - - //Radioactive? - if (this.mThisRadiation > 0){ - list.add(CORE.GT_Tooltip_Radioactive); - } - - /** - * Tooltip Handler for Ores - */ - if (this.mThisMaterial == FLUORIDES.FLUORITE){ - list.add("Mined from Sandstone with a 1/"+(CORE.ConfigSwitches.chanceToDropFluoriteOre*20)+" chance, or Limestone with a 1/"+(CORE.ConfigSwitches.chanceToDropFluoriteOre)+" chance."); - } - - if (this.mThisMaterial != null) { - list.add("Ore contains: "); - if (mThisMaterial.getComposites().isEmpty()) { - list.add("- "+mThisMaterial.getLocalizedName()); - } - else { - for (MaterialStack m : mThisMaterial.getComposites()) { - list.add("- "+m.getStackMaterial().getLocalizedName()+" x"+m.getPartsPerOneHundred()); - } - } - } - - if (KeyboardUtils.isCtrlKeyDown()) { - - Block b = Block.getBlockFromItem(stack.getItem()); - if (b != null) { - String aTool = b.getHarvestTool(stack.getItemDamage()); - int aMiningLevel1 = b.getHarvestLevel(stack.getItemDamage()); - if (aMiningLevel1 != 0) { - list.add("Mining Level: "+Math.min(Math.max(aMiningLevel1, 0), 5)); - } - } - - if (mDimsForThisOre.isEmpty()) { - AutoMap A = mMapOreBlockItemToDimName.get(this.mThisMaterial.getUnlocalizedName().toLowerCase()); - if (A != null) { - mDimsForThisOre = A; - } - } - - list.add("Found: "); - if (!mDimsForThisOre.isEmpty()) { - for (String m : mDimsForThisOre) { - list.add("- "+m); - } - } - else { - list.add("- Unknown"); - } - - } - else { - list.add(EnumChatFormatting.DARK_GRAY+"Hold Ctrl to show additional info."); - } - - - - - - - super.addInformation(stack, aPlayer, list, bool); - } - - @Override - public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, final boolean p_77663_5_) { - if (this.mThisMaterial != null){ - if (this.mThisRadiation > 0){ - if (entityHolding instanceof EntityPlayer){ - if (!((EntityPlayer) entityHolding).capabilities.isCreativeMode){ - EntityUtils.applyRadiationDamageToEntity(iStack.stackSize, this.mThisMaterial.vRadiationLevel, world, entityHolding); - } - } - } - } - } - +public class ItemBlockOre extends ItemBlock { + + private final BlockBaseOre mThisOre; + private final Material mThisMaterial; + private final int mThisRadiation; + private final int mThisColour; + + public ItemBlockOre(final Block block) { + super(block); + if (block instanceof BlockBaseOre) { + this.mThisOre = (BlockBaseOre) block; + this.mThisMaterial = this.mThisOre.getMaterialEx(); + this.mThisRadiation = this.mThisMaterial.vRadiationLevel; + this.mThisColour = this.mThisMaterial.getRgbAsHex(); + } else { + this.mThisOre = null; + this.mThisMaterial = null; + this.mThisRadiation = 0; + this.mThisColour = Utils.rgbtoHexValue(255, 255, 255); + } + } + + public int getRenderColor(final int aMeta) { + return this.mThisColour; + } + + private static Map> mMapOreBlockItemToDimName = + new LinkedHashMap>(); + private static boolean mInitOres_Everglades = false; + private AutoMap mDimsForThisOre = new AutoMap(); + + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + + if (!mInitOres_Everglades) { + for (WorldGen_GT_Ore_Layer f : gtPlusPlus.everglades.gen.gt.WorldGen_Ores.validOreveins.values()) { + Material[] m2 = new Material[] {f.mPrimary, f.mSecondary, f.mBetween, f.mSporadic}; + for (Material m1 : m2) { + AutoMap aMap = mMapOreBlockItemToDimName.get( + m1.getUnlocalizedName().toLowerCase()); + if (aMap == null) { + aMap = new AutoMap(); + } + String aDimName = "Everglades"; + if (!aMap.containsValue(aDimName)) { + aMap.put(aDimName); + } + mMapOreBlockItemToDimName.put(m1.getUnlocalizedName().toLowerCase(), aMap); + } + } + mInitOres_Everglades = true; + } + + if (this.mThisMaterial != null) { + list.add(this.mThisMaterial.vChemicalFormula); + } + + // Radioactive? + if (this.mThisRadiation > 0) { + list.add(CORE.GT_Tooltip_Radioactive); + } + + /** + * Tooltip Handler for Ores + */ + if (this.mThisMaterial == FLUORIDES.FLUORITE) { + list.add("Mined from Sandstone with a 1/" + (CORE.ConfigSwitches.chanceToDropFluoriteOre * 20) + + " chance, or Limestone with a 1/" + (CORE.ConfigSwitches.chanceToDropFluoriteOre) + " chance."); + } + + if (this.mThisMaterial != null) { + list.add("Ore contains: "); + if (mThisMaterial.getComposites().isEmpty()) { + list.add("- " + mThisMaterial.getLocalizedName()); + } else { + for (MaterialStack m : mThisMaterial.getComposites()) { + list.add("- " + m.getStackMaterial().getLocalizedName() + " x" + m.getPartsPerOneHundred()); + } + } + } + + if (KeyboardUtils.isCtrlKeyDown()) { + + Block b = Block.getBlockFromItem(stack.getItem()); + if (b != null) { + String aTool = b.getHarvestTool(stack.getItemDamage()); + int aMiningLevel1 = b.getHarvestLevel(stack.getItemDamage()); + if (aMiningLevel1 != 0) { + list.add("Mining Level: " + Math.min(Math.max(aMiningLevel1, 0), 5)); + } + } + + if (mDimsForThisOre.isEmpty()) { + AutoMap A = mMapOreBlockItemToDimName.get( + this.mThisMaterial.getUnlocalizedName().toLowerCase()); + if (A != null) { + mDimsForThisOre = A; + } + } + + list.add("Found: "); + if (!mDimsForThisOre.isEmpty()) { + for (String m : mDimsForThisOre) { + list.add("- " + m); + } + } else { + list.add("- Unknown"); + } + + } else { + list.add(EnumChatFormatting.DARK_GRAY + "Hold Ctrl to show additional info."); + } + + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public void onUpdate( + final ItemStack iStack, + final World world, + final Entity entityHolding, + final int p_77663_4_, + final boolean p_77663_5_) { + if (this.mThisMaterial != null) { + if (this.mThisRadiation > 0) { + if (entityHolding instanceof EntityPlayer) { + if (!((EntityPlayer) entityHolding).capabilities.isCreativeMode) { + EntityUtils.applyRadiationDamageToEntity( + iStack.stackSize, this.mThisMaterial.vRadiationLevel, world, entityHolding); + } + } + } + } + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockRoundRobinator.java b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockRoundRobinator.java index 7a4222ed0f..4818a3cff6 100644 --- a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockRoundRobinator.java +++ b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockRoundRobinator.java @@ -1,115 +1,107 @@ package gtPlusPlus.core.item.base.itemblock; -import java.util.List; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlockWithMetadata; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -public class ItemBlockRoundRobinator extends ItemBlockWithMetadata -{ - private final Block mBlock; - - public ItemBlockRoundRobinator(final Block aBlock){ - super(aBlock, aBlock); - this.mBlock = aBlock; - } - - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - list.add("Attempts to output items evenly on all four horizontal planes"); - if (stack.getItemDamage() == 0) { - list.add("1 Item per enabled side every 400 ticks"); - } - else if (stack.getItemDamage() == 1) { - list.add("1 Item per enabled side every 100 ticks"); - } - else if (stack.getItemDamage() == 2) { - list.add("1 Item per enabled side every 20 ticks"); - } - else if (stack.getItemDamage() == 3) { - list.add("1 Item per enabled side every 10 ticks"); - } - else if (stack.getItemDamage() == 4) { - list.add("1 Item per enabled side every tick"); - } - list.add("Top and bottom do not pull, so you must push items in"); - list.add("Sides can also be disabled with a screwdriver"); - list.add("Shift+RMB with empty hand to view inventory contents"); - super.addInformation(stack, aPlayer, list, bool); - } - - /** - * Gets an icon index based on an item's damage value - */ - @Override - @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(final int p_77617_1_) - { - return this.mBlock.getIcon(0, p_77617_1_); - } - - /** - * Returns the metadata of the block which this Item (ItemBlock) can place - */ - @Override - public int getMetadata(final int p_77647_1_) - { - return p_77647_1_; - } - - @Override - public String getUnlocalizedName(final ItemStack stack) { - return this.getUnlocalizedName() + "." + stack.getItemDamage(); - } - - @Override - public boolean isDamageable() { - return false; - } - - @Override - public int getItemEnchantability() { - return 0; - } - - @Override - public boolean getIsRepairable(ItemStack p_82789_1_, ItemStack p_82789_2_) { - return false; - } - - @Override - public boolean isBookEnchantable(ItemStack stack, ItemStack book) { - return false; - } - - @Override - public int getDisplayDamage(ItemStack stack) { - return 0; - } - - @Override - public boolean showDurabilityBar(ItemStack stack) { - return false; - } - - @Override - public double getDurabilityForDisplay(ItemStack stack) { - return 0; - } - - @Override - public int getItemEnchantability(ItemStack stack) { - return 0; - } - - @Override - public boolean getHasSubtypes() { - return true; - } -} \ No newline at end of file +public class ItemBlockRoundRobinator extends ItemBlockWithMetadata { + private final Block mBlock; + + public ItemBlockRoundRobinator(final Block aBlock) { + super(aBlock, aBlock); + this.mBlock = aBlock; + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add("Attempts to output items evenly on all four horizontal planes"); + if (stack.getItemDamage() == 0) { + list.add("1 Item per enabled side every 400 ticks"); + } else if (stack.getItemDamage() == 1) { + list.add("1 Item per enabled side every 100 ticks"); + } else if (stack.getItemDamage() == 2) { + list.add("1 Item per enabled side every 20 ticks"); + } else if (stack.getItemDamage() == 3) { + list.add("1 Item per enabled side every 10 ticks"); + } else if (stack.getItemDamage() == 4) { + list.add("1 Item per enabled side every tick"); + } + list.add("Top and bottom do not pull, so you must push items in"); + list.add("Sides can also be disabled with a screwdriver"); + list.add("Shift+RMB with empty hand to view inventory contents"); + super.addInformation(stack, aPlayer, list, bool); + } + + /** + * Gets an icon index based on an item's damage value + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(final int p_77617_1_) { + return this.mBlock.getIcon(0, p_77617_1_); + } + + /** + * Returns the metadata of the block which this Item (ItemBlock) can place + */ + @Override + public int getMetadata(final int p_77647_1_) { + return p_77647_1_; + } + + @Override + public String getUnlocalizedName(final ItemStack stack) { + return this.getUnlocalizedName() + "." + stack.getItemDamage(); + } + + @Override + public boolean isDamageable() { + return false; + } + + @Override + public int getItemEnchantability() { + return 0; + } + + @Override + public boolean getIsRepairable(ItemStack p_82789_1_, ItemStack p_82789_2_) { + return false; + } + + @Override + public boolean isBookEnchantable(ItemStack stack, ItemStack book) { + return false; + } + + @Override + public int getDisplayDamage(ItemStack stack) { + return 0; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 0; + } + + @Override + public int getItemEnchantability(ItemStack stack) { + return 0; + } + + @Override + public boolean getHasSubtypes() { + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockSpawner.java b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockSpawner.java index 53c9cdb193..6313bf8373 100644 --- a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockSpawner.java +++ b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockSpawner.java @@ -1,39 +1,38 @@ package gtPlusPlus.core.item.base.itemblock; -import java.util.List; - import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration; import gtPlusPlus.plugin.villagers.tile.TileEntityGenericSpawner; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; -public class ItemBlockSpawner extends ItemBlockMeta{ - - private final Block mBlock; - - public ItemBlockSpawner(Block aBlock) { - super(aBlock); - mBlock = aBlock; - } +public class ItemBlockSpawner extends ItemBlockMeta { + + private final Block mBlock; - @Override - public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aBool) { - if (mBlock != null) { - int x = this.getMetadata(aStack.getItemDamage()); - if (x >= 0) { - try { - EntityRegistration x1 = EntityRegistry.instance().lookupModSpawn(TileEntityGenericSpawner.mSpawners.get(x), false); - if (x1 != null) { - aList.add(EnumChatFormatting.RED+x1.getEntityName()); - } - } - catch (Throwable t) {} - } - } - super.addInformation(aStack, aPlayer, aList, aBool); - } + public ItemBlockSpawner(Block aBlock) { + super(aBlock); + mBlock = aBlock; + } + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aBool) { + if (mBlock != null) { + int x = this.getMetadata(aStack.getItemDamage()); + if (x >= 0) { + try { + EntityRegistration x1 = + EntityRegistry.instance().lookupModSpawn(TileEntityGenericSpawner.mSpawners.get(x), false); + if (x1 != null) { + aList.add(EnumChatFormatting.RED + x1.getEntityName()); + } + } catch (Throwable t) { + } + } + } + super.addInformation(aStack, aPlayer, aList, aBool); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/misc/BaseItemMisc.java b/src/main/java/gtPlusPlus/core/item/base/misc/BaseItemMisc.java index 25070ad817..a96df2212c 100644 --- a/src/main/java/gtPlusPlus/core/item/base/misc/BaseItemMisc.java +++ b/src/main/java/gtPlusPlus/core/item/base/misc/BaseItemMisc.java @@ -1,11 +1,15 @@ package gtPlusPlus.core.item.base.misc; -import java.util.List; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -15,160 +19,142 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; import net.minecraft.world.World; -import gregtech.api.util.GT_OreDictUnificator; - -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.lib.LoadedMods; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.minecraft.ItemUtils; - -public class BaseItemMisc extends Item{ - - public final String displayName; - public final String unlocalName; - public final MiscTypes miscType; - public final Object componentColour; - public final String[] description; - - public BaseItemMisc( - final String displayName, - final short[] RGB, - final int maxStackSize, - final MiscTypes miscType, - String[] description) { - - //Set-up the Misc Generic Item - this.displayName = displayName; - String unlocalName = Utils.sanitizeString(displayName); - this.unlocalName = "item"+miscType.TYPE+unlocalName; - this.miscType = miscType; - this.setCreativeTab(AddToCreativeTab.tabMisc); - this.setUnlocalizedName(this.unlocalName); - this.setMaxStackSize(maxStackSize); - //this.setTextureName(this.getCorrectTextures()); - if (RGB != null){ - this.componentColour = Utils.rgbtoHexValue(RGB[0], RGB[1], RGB[2]); - } - else { - this.componentColour = null; - } - this.description = description; - GameRegistry.registerItem(this, this.unlocalName); - GT_OreDictUnificator.registerOre(miscType.getOreDictPrefix()+unlocalName, ItemUtils.getSimpleStack(this)); - } - - @Override - public String getItemStackDisplayName(final ItemStack p_77653_1_) { - return this.displayName+miscType.DISPLAY_NAME_SUFFIX; - } - - private String getCorrectTextures(){ - return CORE.MODID + ":" + "item"+this.miscType.TYPE; - } - - @Override - @SideOnly(Side.CLIENT) - public boolean requiresMultipleRenderPasses() { - return this.miscType == MiscTypes.DROP; - } - - @Override - public int getRenderPasses(int meta) { - return (this.miscType == MiscTypes.DROP) ? 2 : 1; - } - - @SideOnly(Side.CLIENT) - private IIcon secondIcon; - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) { - if (this.miscType == MiscTypes.DROP && LoadedMods.Forestry){ - this.itemIcon = par1IconRegister.registerIcon("forestry:honeyDrop.0"); - this.secondIcon = par1IconRegister.registerIcon("forestry:honeyDrop.1"); - } - else { - this.itemIcon = par1IconRegister.registerIcon(getCorrectTextures()); - } - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return (pass == 0) ? itemIcon : secondIcon; - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public final void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - if (this.description != null){ //Incase I don't add one - if (this.description.length > 0){ //Incase I somehow add a blank one - for (int x=0;x 0) { // Incase I somehow add a blank one + for (int x = 0; x < this.description.length; x++) { + list.add(EnumChatFormatting.GRAY + description[x]); + } + } + } + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + // Returns default colour if a custom one is not set. + if (this.componentColour == null) { + return 16777215; + } else { + return (int) this.componentColour; + } + } + + @Override + public void onUpdate( + final ItemStack iStack, + final World world, + final Entity entityHolding, + final int p_77663_4_, + final boolean p_77663_5_) { + // Nothing Fancy here yet. + } + + public static enum MiscTypes { + POTION("Potion", " Potion", "potion"), + KEY("Key", " Key", "key"), + BIGKEY("KeyBig", " Big Key", "bosskey"), + BOTTLE("Bottle", " Bottle", "bottle"), + GEM("Gem", " Gemstone", "gem"), + DROP("Droplet", " Droplet", "droplet"), + MUSHROOM("Mushroom", " Mushroom", "mushroom"); + + private String TYPE; + private String DISPLAY_NAME_SUFFIX; + private String OREDICT_PREFIX; + + private MiscTypes(final String LocalName, final String DisplayNameSuffix, final String OreDictPrefix) { + this.TYPE = LocalName; + this.DISPLAY_NAME_SUFFIX = DisplayNameSuffix; + this.OREDICT_PREFIX = OreDictPrefix; + } + + public String getType() { + return this.TYPE; + } + + public String getName() { + return this.DISPLAY_NAME_SUFFIX; + } + + public String getOreDictPrefix() { + return this.OREDICT_PREFIX; + } + } } - - diff --git a/src/main/java/gtPlusPlus/core/item/base/misc/BaseItemParticle.java b/src/main/java/gtPlusPlus/core/item/base/misc/BaseItemParticle.java index b7bbc84757..2b26bf0db8 100644 --- a/src/main/java/gtPlusPlus/core/item/base/misc/BaseItemParticle.java +++ b/src/main/java/gtPlusPlus/core/item/base/misc/BaseItemParticle.java @@ -1,12 +1,11 @@ package gtPlusPlus.core.item.base.misc; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.item.base.CoreItem; import gtPlusPlus.core.lib.CORE; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; @@ -14,44 +13,51 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; public abstract class BaseItemParticle extends CoreItem { - - protected static final Map aColourMap = new LinkedHashMap (); - private final int aMaxCount; - - public BaseItemParticle(String aType, int aCount, EnumRarity aRarity) { - super("particle"+aType, aType, AddToCreativeTab.tabOther, 64, 0, new String[] {}, aRarity, EnumChatFormatting.DARK_AQUA, false, null); - this.setTextureName(CORE.MODID + ":" + "science/Atom"); - aMaxCount = aCount; - this.setHasSubtypes(true); - - } - - @Override - public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { - return aColourMap.get(stack.getItemDamage()); - } - - public int getColorFromParentClass(ItemStack stack, int aaa) { - return super.getColorFromItemStack(stack, aaa); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < aMaxCount; i ++) { - list.add(new ItemStack(item, 1, i)); - } - } - - - @Override - public final String getItemStackDisplayName(final ItemStack tItem) { - String aReturnValue = super.getItemStackDisplayName(tItem); - String[] a2 = getAffixes(); - aReturnValue = (a2[0] + aReturnValue + a2[1]); - return aReturnValue; - } - - public abstract String[] getAffixes(); - + + protected static final Map aColourMap = new LinkedHashMap(); + private final int aMaxCount; + + public BaseItemParticle(String aType, int aCount, EnumRarity aRarity) { + super( + "particle" + aType, + aType, + AddToCreativeTab.tabOther, + 64, + 0, + new String[] {}, + aRarity, + EnumChatFormatting.DARK_AQUA, + false, + null); + this.setTextureName(CORE.MODID + ":" + "science/Atom"); + aMaxCount = aCount; + this.setHasSubtypes(true); + } + + @Override + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + return aColourMap.get(stack.getItemDamage()); + } + + public int getColorFromParentClass(ItemStack stack, int aaa) { + return super.getColorFromItemStack(stack, aaa); + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < aMaxCount; i++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + public final String getItemStackDisplayName(final ItemStack tItem) { + String aReturnValue = super.getItemStackDisplayName(tItem); + String[] a2 = getAffixes(); + aReturnValue = (a2[0] + aReturnValue + a2[1]); + return aReturnValue; + } + + public abstract String[] getAffixes(); } diff --git a/src/main/java/gtPlusPlus/core/item/base/nugget/BaseItemNugget.java b/src/main/java/gtPlusPlus/core/item/base/nugget/BaseItemNugget.java index 1644856bf8..b0537f022f 100644 --- a/src/main/java/gtPlusPlus/core/item/base/nugget/BaseItemNugget.java +++ b/src/main/java/gtPlusPlus/core/item/base/nugget/BaseItemNugget.java @@ -3,10 +3,9 @@ package gtPlusPlus.core.item.base.nugget; import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.material.Material; -public class BaseItemNugget extends BaseItemComponent{ +public class BaseItemNugget extends BaseItemComponent { - public BaseItemNugget(final Material material) { - super(material, BaseItemComponent.ComponentTypes.NUGGET); - } - + public BaseItemNugget(final Material material) { + super(material, BaseItemComponent.ComponentTypes.NUGGET); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemCentrifugedCrushedOre.java b/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemCentrifugedCrushedOre.java index 73a13f568d..9a72f62040 100644 --- a/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemCentrifugedCrushedOre.java +++ b/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemCentrifugedCrushedOre.java @@ -2,9 +2,9 @@ package gtPlusPlus.core.item.base.ore; import gtPlusPlus.core.material.Material; -public class BaseItemCentrifugedCrushedOre extends BaseOreComponent{ +public class BaseItemCentrifugedCrushedOre extends BaseOreComponent { - public BaseItemCentrifugedCrushedOre(final Material material) { - super(material, BaseOreComponent.ComponentTypes.CRUSHEDCENTRIFUGED); - } + public BaseItemCentrifugedCrushedOre(final Material material) { + super(material, BaseOreComponent.ComponentTypes.CRUSHEDCENTRIFUGED); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemCrushedOre.java b/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemCrushedOre.java index f2ca40334f..e9588f9f96 100644 --- a/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemCrushedOre.java +++ b/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemCrushedOre.java @@ -2,9 +2,9 @@ package gtPlusPlus.core.item.base.ore; import gtPlusPlus.core.material.Material; -public class BaseItemCrushedOre extends BaseOreComponent{ +public class BaseItemCrushedOre extends BaseOreComponent { - public BaseItemCrushedOre(final Material material) { - super(material, BaseOreComponent.ComponentTypes.CRUSHED); - } + public BaseItemCrushedOre(final Material material) { + super(material, BaseOreComponent.ComponentTypes.CRUSHED); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemImpureDust.java b/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemImpureDust.java index 45dc4f4402..f80e392703 100644 --- a/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemImpureDust.java +++ b/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemImpureDust.java @@ -2,9 +2,9 @@ package gtPlusPlus.core.item.base.ore; import gtPlusPlus.core.material.Material; -public class BaseItemImpureDust extends BaseOreComponent{ +public class BaseItemImpureDust extends BaseOreComponent { - public BaseItemImpureDust(final Material material) { - super(material, BaseOreComponent.ComponentTypes.DUSTIMPURE); - } + public BaseItemImpureDust(final Material material) { + super(material, BaseOreComponent.ComponentTypes.DUSTIMPURE); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemMilledOre.java b/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemMilledOre.java index 4edf4ae75d..5d395aacb1 100644 --- a/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemMilledOre.java +++ b/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemMilledOre.java @@ -6,20 +6,18 @@ import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.minecraft.MaterialUtils; import net.minecraft.item.Item; -public class BaseItemMilledOre extends BaseOreComponent{ +public class BaseItemMilledOre extends BaseOreComponent { - public BaseItemMilledOre(final Material material, int aMaterialEU) { - super(material, BaseOreComponent.ComponentTypes.MILLED); - CORE.RA.addMillingRecipe(material, aMaterialEU); - } + public BaseItemMilledOre(final Material material, int aMaterialEU) { + super(material, BaseOreComponent.ComponentTypes.MILLED); + CORE.RA.addMillingRecipe(material, aMaterialEU); + } - public static Item generate(Materials aMat, int aMaterialEU) { - return generate(MaterialUtils.generateMaterialFromGtENUM(aMat), aMaterialEU); - } - - public static Item generate(Material aMat, int aMaterialEU) { - return new BaseItemMilledOre(aMat, aMaterialEU); - } - - + public static Item generate(Materials aMat, int aMaterialEU) { + return generate(MaterialUtils.generateMaterialFromGtENUM(aMat), aMaterialEU); + } + + public static Item generate(Material aMat, int aMaterialEU) { + return new BaseItemMilledOre(aMat, aMaterialEU); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemPurifiedCrushedOre.java b/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemPurifiedCrushedOre.java index 3f2a1c23e6..744b204d43 100644 --- a/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemPurifiedCrushedOre.java +++ b/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemPurifiedCrushedOre.java @@ -2,9 +2,9 @@ package gtPlusPlus.core.item.base.ore; import gtPlusPlus.core.material.Material; -public class BaseItemPurifiedCrushedOre extends BaseOreComponent{ +public class BaseItemPurifiedCrushedOre extends BaseOreComponent { - public BaseItemPurifiedCrushedOre(final Material material) { - super(material, BaseOreComponent.ComponentTypes.CRUSHEDPURIFIED); - } + public BaseItemPurifiedCrushedOre(final Material material) { + super(material, BaseOreComponent.ComponentTypes.CRUSHEDPURIFIED); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemPurifiedDust.java b/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemPurifiedDust.java index 0c9816fb56..4b94b98e64 100644 --- a/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemPurifiedDust.java +++ b/src/main/java/gtPlusPlus/core/item/base/ore/BaseItemPurifiedDust.java @@ -2,9 +2,9 @@ package gtPlusPlus.core.item.base.ore; import gtPlusPlus.core.material.Material; -public class BaseItemPurifiedDust extends BaseOreComponent{ +public class BaseItemPurifiedDust extends BaseOreComponent { - public BaseItemPurifiedDust(final Material material) { - super(material, BaseOreComponent.ComponentTypes.DUSTPURE); - } + public BaseItemPurifiedDust(final Material material) { + super(material, BaseOreComponent.ComponentTypes.DUSTPURE); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java b/src/main/java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java index 2cb23b3f97..48d8498380 100644 --- a/src/main/java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java +++ b/src/main/java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java @@ -1,9 +1,5 @@ package gtPlusPlus.core.item.base.ore; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -18,6 +14,9 @@ import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.EntityUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.gregtech.api.enums.CustomOrePrefix; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -26,254 +25,248 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.World; -public class BaseOreComponent extends Item{ - - @SideOnly(Side.CLIENT) - private IIcon base; - @SideOnly(Side.CLIENT) - private IIcon overlay; - - public final Material componentMaterial; - public final String materialName; - public final String unlocalName; - public final ComponentTypes componentType; - public final int componentColour; - public Object extraData; - - public BaseOreComponent(final Material material, final ComponentTypes componentType) { - this.componentMaterial = material; - this.unlocalName = componentType.COMPONENT_NAME+material.getUnlocalizedName(); - this.materialName = material.getLocalizedName(); - this.componentType = componentType; - this.setCreativeTab(AddToCreativeTab.tabMisc); - this.setUnlocalizedName(this.unlocalName); - this.setMaxStackSize(64); - this.componentColour = material.getRgbAsHex(); - GameRegistry.registerItem(this, this.unlocalName); - registerComponent(); - GT_OreDictUnificator.registerOre(componentType.getComponent()+material.getUnlocalizedName(), ItemUtils.getSimpleStack(this)); - if (LoadedMods.Thaumcraft) { - //ThaumcraftUtils.addAspectToItem(ItemUtils.getSimpleStack(this), TC_Aspect_Wrapper.generate(TC_Aspects.METALLUM.mAspect), 1); - if (componentMaterial.isRadioactive) { - //ThaumcraftUtils.addAspectToItem(ItemUtils.getSimpleStack(this), TC_Aspect_Wrapper.generate(TC_Aspects.RADIO.mAspect), componentMaterial.vRadiationLevel); - } - } - - } - - public boolean registerComponent() { - Logger.MATERIALS("Attempting to register "+this.getUnlocalizedName()+"."); - if (this.componentMaterial == null) { - Logger.MATERIALS("Tried to register "+this.getUnlocalizedName()+" but the material was null."); - return false; - } - //Register Component - Map aMap = Material.mComponentMap.get(componentMaterial.getUnlocalizedName()); - if (aMap == null) { - aMap = new HashMap(); - } - String aKey = "Invalid"; - if (componentType == ComponentTypes.CRUSHED) { - aKey = OrePrefixes.crushed.name(); - } - else if (componentType == ComponentTypes.CRUSHEDCENTRIFUGED) { - aKey = OrePrefixes.crushedCentrifuged.name(); - } - else if (componentType == ComponentTypes.CRUSHEDPURIFIED) { - aKey = OrePrefixes.crushedPurified.name(); - } - else if (componentType == ComponentTypes.DUST) { - aKey = OrePrefixes.dust.name(); - } - else if (componentType == ComponentTypes.DUSTIMPURE) { - aKey = OrePrefixes.dustImpure.name(); - } - else if (componentType == ComponentTypes.DUSTPURE) { - aKey = OrePrefixes.dustPure.name(); - } - else if (componentType == ComponentTypes.MILLED) { - aKey = CustomOrePrefix.milled.get().name(); - } - - ItemStack x = aMap.get(aKey); - if (x == null) { - aMap.put(aKey, ItemUtils.getSimpleStack(this)); - Logger.MATERIALS("Registering a material component. Item: ["+componentMaterial.getUnlocalizedName()+"] Map: ["+aKey+"]"); - Material.mComponentMap.put(componentMaterial.getUnlocalizedName(), aMap); - return true; - } - else { - //Bad - Logger.MATERIALS("Tried to double register a material component. "); - return false; - } - } - - /*@Override - public String getItemStackDisplayName(final ItemStack p_77653_1_) { - return (this.componentType.getPrefix()+this.componentMaterial.getLocalizedName()+this.componentType.DISPLAY_NAME); - }*/ - - public final String getMaterialName() { - return this.materialName; - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public final void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - if (this.materialName != null && !this.materialName.equals("")){ - if (this.componentMaterial != null){ - if (!this.componentMaterial.vChemicalFormula.contains("?")) { - list.add(Utils.sanitizeStringKeepBrackets(this.componentMaterial.vChemicalFormula)); - } - else if (this.componentMaterial.vChemicalFormula.contains("?")) { - String temp = componentMaterial.vChemicalFormula; - temp = temp.replace(" ", ""); - temp = temp.replace("-", ""); - temp = temp.replace("_", ""); - temp = temp.replace("!", ""); - temp = temp.replace("@", ""); - temp = temp.replace("#", ""); - temp = temp.replace(" ", ""); - list.add(temp); - } - if (this.componentMaterial.isRadioactive){ - list.add(CORE.GT_Tooltip_Radioactive+" | Level: "+this.componentMaterial.vRadiationLevel); - } - } - else { - String aChemicalFormula = Material.sChemicalFormula.get(materialName.toLowerCase()); - if (aChemicalFormula != null && aChemicalFormula.length() > 0) { - list.add(Utils.sanitizeStringKeepBrackets(aChemicalFormula)); - } - } - } - super.addInformation(stack, aPlayer, list, bool); - } - - @Override - public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, final boolean p_77663_5_) { - if (this.componentMaterial != null){ - if (entityHolding instanceof EntityPlayer){ - if (!((EntityPlayer) entityHolding).capabilities.isCreativeMode){ - EntityUtils.applyRadiationDamageToEntity(iStack.stackSize, this.componentMaterial.vRadiationLevel, world, entityHolding); - } - } - } - } - - - - /** - * Rendering Related - * @author Alkalus - * - */ - - @Override - @SideOnly(Side.CLIENT) - public boolean requiresMultipleRenderPasses(){ - if (this.componentType.hasOverlay()){ - return true; - } - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(final IIconRegister par1IconRegister){ - if (this.componentType == ComponentTypes.MILLED) { - this.base = par1IconRegister.registerIcon(CORE.MODID + ":" + "processing/MilledOre/milled"); - if (this.componentType.hasOverlay()){ - this.overlay = par1IconRegister.registerIcon(CORE.MODID + ":" + "processing/MilledOre/milled_OVERLAY"); - } - } - else if (CORE.ConfigSwitches.useGregtechTextures){ - //Logger.MATERIALS(this.componentType.getPrefix()+this.componentMaterial.getLocalizedName()+this.componentType.DISPLAY_NAME+" is using `"+"gregtech" + ":" + "materialicons/METALLIC/" + this.componentType.COMPONENT_NAME+"' as the layer 0 texture path."); - this.base = par1IconRegister.registerIcon("gregtech" + ":" + "materialicons/METALLIC/" + this.componentType.COMPONENT_NAME); - if (this.componentType.hasOverlay()){ - //Logger.MATERIALS(this.componentType.getPrefix()+this.componentMaterial.getLocalizedName()+this.componentType.DISPLAY_NAME+" is using `"+"gregtech" + ":" + "materialicons/METALLIC/" + this.componentType.COMPONENT_NAME+"_OVERLAY"+"' as the layer 1 texture path."); - this.overlay = par1IconRegister.registerIcon("gregtech" + ":" + "materialicons/METALLIC/" + this.componentType.COMPONENT_NAME+"_OVERLAY"); - } - } - else { - this.base = par1IconRegister.registerIcon(CORE.MODID + ":" + "item"+this.componentType.getComponent()); - if (this.componentType.hasOverlay()){ - this.overlay = par1IconRegister.registerIcon(CORE.MODID + ":" + "item"+this.componentType.getComponent()+"_Overlay"); - } - } - } - - @Override - public int getColorFromItemStack(final ItemStack stack, final int renderPass) { - if (this.componentType == ComponentTypes.MILLED) { - if (renderPass == 1){ - return Utils.rgbtoHexValue(230, 230, 230); - } - return this.componentColour; - } - else { - if (renderPass == 0 && !CORE.ConfigSwitches.useGregtechTextures){ - return this.componentColour; - } - if (renderPass == 1 && CORE.ConfigSwitches.useGregtechTextures){ - return Utils.rgbtoHexValue(230, 230, 230); - } - return this.componentColour; - } - } - - - @Override - public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) { - if(pass == 0) { - return this.base; - } - return this.overlay; - } - - - - - public static enum ComponentTypes { - DUST("dust", "", " Dust", true), - DUSTIMPURE("dustImpure", "Impure ", " Dust", true), - DUSTPURE("dustPure", "Purified ", " Dust", true), - CRUSHED("crushed", "Crushed ", " Ore", true), - CRUSHEDCENTRIFUGED("crushedCentrifuged", "Centrifuged Crushed "," Ore", true), - CRUSHEDPURIFIED("crushedPurified", "Purified Crushed ", " Ore", true), - MILLED("milled", "Milled ", " Ore", true); - - private String COMPONENT_NAME; - private String PREFIX; - private String DISPLAY_NAME; - private boolean HAS_OVERLAY; - private ComponentTypes (final String LocalName, final String prefix, final String DisplayName, final boolean overlay){ - this.COMPONENT_NAME = LocalName; - this.PREFIX = prefix; - this.DISPLAY_NAME = DisplayName; - this.HAS_OVERLAY = overlay; - // dust + Dirty, Impure, Pure, Refined - // crushed + centrifuged, purified - } - - public String getComponent(){ - return this.COMPONENT_NAME; - } - - public String getName(){ - return this.DISPLAY_NAME; - } - - public boolean hasOverlay(){ - return this.HAS_OVERLAY; - } - - public String getPrefix(){ - return this.PREFIX; - } - } - +public class BaseOreComponent extends Item { + + @SideOnly(Side.CLIENT) + private IIcon base; + + @SideOnly(Side.CLIENT) + private IIcon overlay; + + public final Material componentMaterial; + public final String materialName; + public final String unlocalName; + public final ComponentTypes componentType; + public final int componentColour; + public Object extraData; + + public BaseOreComponent(final Material material, final ComponentTypes componentType) { + this.componentMaterial = material; + this.unlocalName = componentType.COMPONENT_NAME + material.getUnlocalizedName(); + this.materialName = material.getLocalizedName(); + this.componentType = componentType; + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(this.unlocalName); + this.setMaxStackSize(64); + this.componentColour = material.getRgbAsHex(); + GameRegistry.registerItem(this, this.unlocalName); + registerComponent(); + GT_OreDictUnificator.registerOre( + componentType.getComponent() + material.getUnlocalizedName(), ItemUtils.getSimpleStack(this)); + if (LoadedMods.Thaumcraft) { + // ThaumcraftUtils.addAspectToItem(ItemUtils.getSimpleStack(this), + // TC_Aspect_Wrapper.generate(TC_Aspects.METALLUM.mAspect), 1); + if (componentMaterial.isRadioactive) { + // ThaumcraftUtils.addAspectToItem(ItemUtils.getSimpleStack(this), + // TC_Aspect_Wrapper.generate(TC_Aspects.RADIO.mAspect), componentMaterial.vRadiationLevel); + } + } + } + + public boolean registerComponent() { + Logger.MATERIALS("Attempting to register " + this.getUnlocalizedName() + "."); + if (this.componentMaterial == null) { + Logger.MATERIALS("Tried to register " + this.getUnlocalizedName() + " but the material was null."); + return false; + } + // Register Component + Map aMap = Material.mComponentMap.get(componentMaterial.getUnlocalizedName()); + if (aMap == null) { + aMap = new HashMap(); + } + String aKey = "Invalid"; + if (componentType == ComponentTypes.CRUSHED) { + aKey = OrePrefixes.crushed.name(); + } else if (componentType == ComponentTypes.CRUSHEDCENTRIFUGED) { + aKey = OrePrefixes.crushedCentrifuged.name(); + } else if (componentType == ComponentTypes.CRUSHEDPURIFIED) { + aKey = OrePrefixes.crushedPurified.name(); + } else if (componentType == ComponentTypes.DUST) { + aKey = OrePrefixes.dust.name(); + } else if (componentType == ComponentTypes.DUSTIMPURE) { + aKey = OrePrefixes.dustImpure.name(); + } else if (componentType == ComponentTypes.DUSTPURE) { + aKey = OrePrefixes.dustPure.name(); + } else if (componentType == ComponentTypes.MILLED) { + aKey = CustomOrePrefix.milled.get().name(); + } + + ItemStack x = aMap.get(aKey); + if (x == null) { + aMap.put(aKey, ItemUtils.getSimpleStack(this)); + Logger.MATERIALS("Registering a material component. Item: [" + componentMaterial.getUnlocalizedName() + + "] Map: [" + aKey + "]"); + Material.mComponentMap.put(componentMaterial.getUnlocalizedName(), aMap); + return true; + } else { + // Bad + Logger.MATERIALS("Tried to double register a material component. "); + return false; + } + } + + /*@Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + return (this.componentType.getPrefix()+this.componentMaterial.getLocalizedName()+this.componentType.DISPLAY_NAME); + }*/ + + public final String getMaterialName() { + return this.materialName; + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public final void addInformation( + final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + if (this.materialName != null && !this.materialName.equals("")) { + if (this.componentMaterial != null) { + if (!this.componentMaterial.vChemicalFormula.contains("?")) { + list.add(Utils.sanitizeStringKeepBrackets(this.componentMaterial.vChemicalFormula)); + } else if (this.componentMaterial.vChemicalFormula.contains("?")) { + String temp = componentMaterial.vChemicalFormula; + temp = temp.replace(" ", ""); + temp = temp.replace("-", ""); + temp = temp.replace("_", ""); + temp = temp.replace("!", ""); + temp = temp.replace("@", ""); + temp = temp.replace("#", ""); + temp = temp.replace(" ", ""); + list.add(temp); + } + if (this.componentMaterial.isRadioactive) { + list.add(CORE.GT_Tooltip_Radioactive + " | Level: " + this.componentMaterial.vRadiationLevel); + } + } else { + String aChemicalFormula = Material.sChemicalFormula.get(materialName.toLowerCase()); + if (aChemicalFormula != null && aChemicalFormula.length() > 0) { + list.add(Utils.sanitizeStringKeepBrackets(aChemicalFormula)); + } + } + } + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public void onUpdate( + final ItemStack iStack, + final World world, + final Entity entityHolding, + final int p_77663_4_, + final boolean p_77663_5_) { + if (this.componentMaterial != null) { + if (entityHolding instanceof EntityPlayer) { + if (!((EntityPlayer) entityHolding).capabilities.isCreativeMode) { + EntityUtils.applyRadiationDamageToEntity( + iStack.stackSize, this.componentMaterial.vRadiationLevel, world, entityHolding); + } + } + } + } + + /** + * Rendering Related + * @author Alkalus + * + */ + @Override + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses() { + if (this.componentType.hasOverlay()) { + return true; + } + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(final IIconRegister par1IconRegister) { + if (this.componentType == ComponentTypes.MILLED) { + this.base = par1IconRegister.registerIcon(CORE.MODID + ":" + "processing/MilledOre/milled"); + if (this.componentType.hasOverlay()) { + this.overlay = par1IconRegister.registerIcon(CORE.MODID + ":" + "processing/MilledOre/milled_OVERLAY"); + } + } else if (CORE.ConfigSwitches.useGregtechTextures) { + // Logger.MATERIALS(this.componentType.getPrefix()+this.componentMaterial.getLocalizedName()+this.componentType.DISPLAY_NAME+" is using `"+"gregtech" + ":" + "materialicons/METALLIC/" + this.componentType.COMPONENT_NAME+"' as the layer 0 texture path."); + this.base = par1IconRegister.registerIcon( + "gregtech" + ":" + "materialicons/METALLIC/" + this.componentType.COMPONENT_NAME); + if (this.componentType.hasOverlay()) { + // Logger.MATERIALS(this.componentType.getPrefix()+this.componentMaterial.getLocalizedName()+this.componentType.DISPLAY_NAME+" is using `"+"gregtech" + ":" + "materialicons/METALLIC/" + this.componentType.COMPONENT_NAME+"_OVERLAY"+"' as the layer 1 texture path."); + this.overlay = par1IconRegister.registerIcon( + "gregtech" + ":" + "materialicons/METALLIC/" + this.componentType.COMPONENT_NAME + "_OVERLAY"); + } + } else { + this.base = par1IconRegister.registerIcon(CORE.MODID + ":" + "item" + this.componentType.getComponent()); + if (this.componentType.hasOverlay()) { + this.overlay = par1IconRegister.registerIcon( + CORE.MODID + ":" + "item" + this.componentType.getComponent() + "_Overlay"); + } + } + } + + @Override + public int getColorFromItemStack(final ItemStack stack, final int renderPass) { + if (this.componentType == ComponentTypes.MILLED) { + if (renderPass == 1) { + return Utils.rgbtoHexValue(230, 230, 230); + } + return this.componentColour; + } else { + if (renderPass == 0 && !CORE.ConfigSwitches.useGregtechTextures) { + return this.componentColour; + } + if (renderPass == 1 && CORE.ConfigSwitches.useGregtechTextures) { + return Utils.rgbtoHexValue(230, 230, 230); + } + return this.componentColour; + } + } + + @Override + public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) { + if (pass == 0) { + return this.base; + } + return this.overlay; + } + + public static enum ComponentTypes { + DUST("dust", "", " Dust", true), + DUSTIMPURE("dustImpure", "Impure ", " Dust", true), + DUSTPURE("dustPure", "Purified ", " Dust", true), + CRUSHED("crushed", "Crushed ", " Ore", true), + CRUSHEDCENTRIFUGED("crushedCentrifuged", "Centrifuged Crushed ", " Ore", true), + CRUSHEDPURIFIED("crushedPurified", "Purified Crushed ", " Ore", true), + MILLED("milled", "Milled ", " Ore", true); + + private String COMPONENT_NAME; + private String PREFIX; + private String DISPLAY_NAME; + private boolean HAS_OVERLAY; + + private ComponentTypes( + final String LocalName, final String prefix, final String DisplayName, final boolean overlay) { + this.COMPONENT_NAME = LocalName; + this.PREFIX = prefix; + this.DISPLAY_NAME = DisplayName; + this.HAS_OVERLAY = overlay; + // dust + Dirty, Impure, Pure, Refined + // crushed + centrifuged, purified + } + + public String getComponent() { + return this.COMPONENT_NAME; + } + + public String getName() { + return this.DISPLAY_NAME; + } + + public boolean hasOverlay() { + return this.HAS_OVERLAY; + } + + public String getPrefix() { + return this.PREFIX; + } + } } - - diff --git a/src/main/java/gtPlusPlus/core/item/base/plates/BaseItemPlate.java b/src/main/java/gtPlusPlus/core/item/base/plates/BaseItemPlate.java index a810b22c70..7737409209 100644 --- a/src/main/java/gtPlusPlus/core/item/base/plates/BaseItemPlate.java +++ b/src/main/java/gtPlusPlus/core/item/base/plates/BaseItemPlate.java @@ -5,14 +5,20 @@ import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.util.minecraft.MaterialUtils; -public class BaseItemPlate extends BaseItemComponent{ +public class BaseItemPlate extends BaseItemComponent { - public BaseItemPlate(final Material material) { - super(material, BaseItemComponent.ComponentTypes.PLATE); - } - - public BaseItemPlate(final String unlocalizedName, final String materialName, final MaterialState state, final short[] colour, final int tier, final int sRadioactivity) { - this(MaterialUtils.generateQuickMaterial(materialName, state, new short[]{colour[0], colour[1], colour[2], 0}, sRadioactivity)); - } + public BaseItemPlate(final Material material) { + super(material, BaseItemComponent.ComponentTypes.PLATE); + } + public BaseItemPlate( + final String unlocalizedName, + final String materialName, + final MaterialState state, + final short[] colour, + final int tier, + final int sRadioactivity) { + this(MaterialUtils.generateQuickMaterial( + materialName, state, new short[] {colour[0], colour[1], colour[2], 0}, sRadioactivity)); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/plates/BaseItemPlateDouble.java b/src/main/java/gtPlusPlus/core/item/base/plates/BaseItemPlateDouble.java index 31f86e8ffa..3d3ebaa76d 100644 --- a/src/main/java/gtPlusPlus/core/item/base/plates/BaseItemPlateDouble.java +++ b/src/main/java/gtPlusPlus/core/item/base/plates/BaseItemPlateDouble.java @@ -1,20 +1,18 @@ package gtPlusPlus.core.item.base.plates; -import net.minecraft.item.ItemStack; - import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.material.Material; +import net.minecraft.item.ItemStack; -public class BaseItemPlateDouble extends BaseItemComponent{ +public class BaseItemPlateDouble extends BaseItemComponent { - public BaseItemPlateDouble(final Material material) { - super(material, BaseItemComponent.ComponentTypes.PLATEDOUBLE); - this.setMaxStackSize(32); - } + public BaseItemPlateDouble(final Material material) { + super(material, BaseItemComponent.ComponentTypes.PLATEDOUBLE); + this.setMaxStackSize(32); + } - @Override - public String getItemStackDisplayName(final ItemStack p_77653_1_) { - return ("Double "+this.materialName+ " Plate"); - } - + @Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + return ("Double " + this.materialName + " Plate"); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/plates/BaseItemPlateHeavy.java b/src/main/java/gtPlusPlus/core/item/base/plates/BaseItemPlateHeavy.java index c9072b0d82..79e898cc6a 100644 --- a/src/main/java/gtPlusPlus/core/item/base/plates/BaseItemPlateHeavy.java +++ b/src/main/java/gtPlusPlus/core/item/base/plates/BaseItemPlateHeavy.java @@ -8,40 +8,38 @@ import gtPlusPlus.core.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; -public class BaseItemPlateHeavy extends BaseItemComponent{ - - final static ComponentTypes HEAVY = ComponentTypes.PLATEHEAVY; - - public BaseItemPlateHeavy(final Material material) { - super(material, HEAVY); - } - - @Override - public String getCorrectTextures(){ - return CORE.MODID + ":" + "itemHeavyPlate"; - } - - @Override - @SideOnly(Side.CLIENT) - public boolean requiresMultipleRenderPasses(){ - return true; - } - - @Override - public void registerIcons(final IIconRegister i) { - this.base = i.registerIcon(CORE.MODID + ":" + "itemHeavyPlate"); - this.overlay = i.registerIcon(CORE.MODID + ":" + "itemHeavyPlate_Overlay"); - } - - @Override - public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) { - - if (pass == 0) { - return this.base; - } - else { - return this.overlay; - } - - } +public class BaseItemPlateHeavy extends BaseItemComponent { + + static final ComponentTypes HEAVY = ComponentTypes.PLATEHEAVY; + + public BaseItemPlateHeavy(final Material material) { + super(material, HEAVY); + } + + @Override + public String getCorrectTextures() { + return CORE.MODID + ":" + "itemHeavyPlate"; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + public void registerIcons(final IIconRegister i) { + this.base = i.registerIcon(CORE.MODID + ":" + "itemHeavyPlate"); + this.overlay = i.registerIcon(CORE.MODID + ":" + "itemHeavyPlate_Overlay"); + } + + @Override + public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) { + + if (pass == 0) { + return this.base; + } else { + return this.overlay; + } + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/plates/BaseItemPlate_OLD.java b/src/main/java/gtPlusPlus/core/item/base/plates/BaseItemPlate_OLD.java index ec3f449b0a..87fb769525 100644 --- a/src/main/java/gtPlusPlus/core/item/base/plates/BaseItemPlate_OLD.java +++ b/src/main/java/gtPlusPlus/core/item/base/plates/BaseItemPlate_OLD.java @@ -1,95 +1,100 @@ package gtPlusPlus.core.item.base.plates; -import java.util.List; - import cpw.mods.fml.common.registry.GameRegistry; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - import gregtech.api.util.GT_OreDictUnificator; - import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.data.StringUtils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.EntityUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import java.util.List; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class BaseItemPlate_OLD extends Item { + + protected final int colour; + protected final int sRadiation; + protected final String materialName; + protected final String unlocalName; + protected final String chemicalNotation; -public class BaseItemPlate_OLD extends Item{ + public BaseItemPlate_OLD( + final String unlocalizedName, final String materialName, final int colour, final int sRadioactivity) { + this(unlocalizedName, materialName, "NullFormula", colour, sRadioactivity); + } - protected final int colour; - protected final int sRadiation; - protected final String materialName; - protected final String unlocalName; - protected final String chemicalNotation; + public BaseItemPlate_OLD( + final String unlocalizedName, + final String materialName, + final String mChemicalFormula, + final int colour, + final int sRadioactivity) { + this.setUnlocalizedName("itemPlate" + unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.unlocalName = "itemPlate" + unlocalizedName; + this.setMaxStackSize(64); + this.setTextureName(CORE.MODID + ":" + "itemPlate"); + this.setMaxStackSize(64); + this.colour = colour; + this.materialName = materialName; + if (mChemicalFormula.equals("") || mChemicalFormula.equals("NullFormula")) { + this.chemicalNotation = StringUtils.subscript(materialName); + } else { + this.chemicalNotation = StringUtils.subscript(mChemicalFormula); + } + this.sRadiation = sRadioactivity; + GameRegistry.registerItem(this, "itemPlate" + unlocalizedName); + String temp; + if (this.unlocalName.toLowerCase().contains("itemplate")) { + temp = this.unlocalName.replace("itemP", "p"); + if ((temp != null) && !temp.equals("")) { + GT_OreDictUnificator.registerOre(temp, ItemUtils.getSimpleStack(this)); + } + } + } - public BaseItemPlate_OLD(final String unlocalizedName, final String materialName, final int colour, final int sRadioactivity) { - this(unlocalizedName, materialName, "NullFormula", colour, sRadioactivity); - } - - public BaseItemPlate_OLD(final String unlocalizedName, final String materialName, final String mChemicalFormula, final int colour, final int sRadioactivity) { - this.setUnlocalizedName("itemPlate"+unlocalizedName); - this.setCreativeTab(AddToCreativeTab.tabMisc); - this.unlocalName = "itemPlate"+unlocalizedName; - this.setMaxStackSize(64); - this.setTextureName(CORE.MODID + ":" + "itemPlate"); - this.setMaxStackSize(64); - this.colour = colour; - this.materialName = materialName; - if (mChemicalFormula.equals("") || mChemicalFormula.equals("NullFormula")){ - this.chemicalNotation = StringUtils.subscript(materialName); - } - else { - this.chemicalNotation = StringUtils.subscript(mChemicalFormula); - } - this.sRadiation = sRadioactivity; - GameRegistry.registerItem(this, "itemPlate"+unlocalizedName); - String temp; - if (this.unlocalName.toLowerCase().contains("itemplate")){ - temp = this.unlocalName.replace("itemP", "p"); - if ((temp != null) && !temp.equals("")){ - GT_OreDictUnificator.registerOre(temp, ItemUtils.getSimpleStack(this)); - } - } - } + @Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { - @Override - public String getItemStackDisplayName(final ItemStack p_77653_1_) { + return (this.materialName + " plate"); + } - return (this.materialName+ " plate"); - } + public final String getMaterialName() { + return this.materialName; + } - public final String getMaterialName() { - return this.materialName; - } + @Override + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + if (this.colour == 0) { + return MathUtils.generateSingularRandomHexValue(); + } + return this.colour; + } - @Override - public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { - if (this.colour == 0){ - return MathUtils.generateSingularRandomHexValue(); - } - return this.colour; + @Override + public void onUpdate( + final ItemStack iStack, + final World world, + final Entity entityHolding, + final int p_77663_4_, + final boolean p_77663_5_) { + EntityUtils.applyRadiationDamageToEntity(iStack.stackSize, this.sRadiation, world, entityHolding); + } - } - - @Override - public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, final boolean p_77663_5_) { - EntityUtils.applyRadiationDamageToEntity(iStack.stackSize, this.sRadiation, world, entityHolding); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - if (this.sRadiation > 0){ - list.add(CORE.GT_Tooltip_Radioactive); - } - if (StringUtils.containsSuperOrSubScript(this.chemicalNotation)){ - list.add(this.chemicalNotation); - } - super.addInformation(stack, aPlayer, list, bool); - } + @SuppressWarnings({"rawtypes", "unchecked"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + if (this.sRadiation > 0) { + list.add(CORE.GT_Tooltip_Radioactive); + } + if (StringUtils.containsSuperOrSubScript(this.chemicalNotation)) { + list.add(this.chemicalNotation); + } + super.addInformation(stack, aPlayer, list, bool); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/rings/BaseItemRing.java b/src/main/java/gtPlusPlus/core/item/base/rings/BaseItemRing.java index c83ae94af1..d25ea02d52 100644 --- a/src/main/java/gtPlusPlus/core/item/base/rings/BaseItemRing.java +++ b/src/main/java/gtPlusPlus/core/item/base/rings/BaseItemRing.java @@ -3,10 +3,9 @@ package gtPlusPlus.core.item.base.rings; import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.material.Material; -public class BaseItemRing extends BaseItemComponent{ +public class BaseItemRing extends BaseItemComponent { - public BaseItemRing(final Material material) { - super(material, BaseItemComponent.ComponentTypes.RING); - } - + public BaseItemRing(final Material material) { + super(material, BaseItemComponent.ComponentTypes.RING); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/rods/BaseItemRod.java b/src/main/java/gtPlusPlus/core/item/base/rods/BaseItemRod.java index f77f846d34..9a9998d63a 100644 --- a/src/main/java/gtPlusPlus/core/item/base/rods/BaseItemRod.java +++ b/src/main/java/gtPlusPlus/core/item/base/rods/BaseItemRod.java @@ -3,10 +3,9 @@ package gtPlusPlus.core.item.base.rods; import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.material.Material; -public class BaseItemRod extends BaseItemComponent{ - - public BaseItemRod(final Material material) { - super(material, BaseItemComponent.ComponentTypes.ROD); - } +public class BaseItemRod extends BaseItemComponent { + public BaseItemRod(final Material material) { + super(material, BaseItemComponent.ComponentTypes.ROD); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/rods/BaseItemRodLong.java b/src/main/java/gtPlusPlus/core/item/base/rods/BaseItemRodLong.java index 215012817d..097d6ddd39 100644 --- a/src/main/java/gtPlusPlus/core/item/base/rods/BaseItemRodLong.java +++ b/src/main/java/gtPlusPlus/core/item/base/rods/BaseItemRodLong.java @@ -4,15 +4,14 @@ import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.material.Material; import net.minecraft.item.ItemStack; -public class BaseItemRodLong extends BaseItemComponent{ +public class BaseItemRodLong extends BaseItemComponent { - public BaseItemRodLong(final Material material) { - super(material, BaseItemComponent.ComponentTypes.RODLONG); - } - - @Override - public String getItemStackDisplayName(final ItemStack p_77653_1_) { - return ("Long "+this.materialName+ " Rod"); - } + public BaseItemRodLong(final Material material) { + super(material, BaseItemComponent.ComponentTypes.RODLONG); + } + @Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + return ("Long " + this.materialName + " Rod"); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/rotors/BaseItemRotor.java b/src/main/java/gtPlusPlus/core/item/base/rotors/BaseItemRotor.java index 6960e89e89..c2fae0fc8b 100644 --- a/src/main/java/gtPlusPlus/core/item/base/rotors/BaseItemRotor.java +++ b/src/main/java/gtPlusPlus/core/item/base/rotors/BaseItemRotor.java @@ -3,9 +3,9 @@ package gtPlusPlus.core.item.base.rotors; import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.material.Material; -public class BaseItemRotor extends BaseItemComponent{ +public class BaseItemRotor extends BaseItemComponent { - public BaseItemRotor(final Material material) { - super(material, BaseItemComponent.ComponentTypes.ROTOR); - } + public BaseItemRotor(final Material material) { + super(material, BaseItemComponent.ComponentTypes.ROTOR); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/screws/BaseItemScrew.java b/src/main/java/gtPlusPlus/core/item/base/screws/BaseItemScrew.java index dbd817215a..7f0ba8c504 100644 --- a/src/main/java/gtPlusPlus/core/item/base/screws/BaseItemScrew.java +++ b/src/main/java/gtPlusPlus/core/item/base/screws/BaseItemScrew.java @@ -3,10 +3,9 @@ package gtPlusPlus.core.item.base.screws; import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.material.Material; -public class BaseItemScrew extends BaseItemComponent{ - - public BaseItemScrew(final Material material) { - super(material, BaseItemComponent.ComponentTypes.SCREW); - } +public class BaseItemScrew extends BaseItemComponent { + public BaseItemScrew(final Material material) { + super(material, BaseItemComponent.ComponentTypes.SCREW); + } } diff --git a/src/main/java/gtPlusPlus/core/item/base/wire/BaseItemFineWire.java b/src/main/java/gtPlusPlus/core/item/base/wire/BaseItemFineWire.java index 846c282af3..3e2cee49a9 100644 --- a/src/main/java/gtPlusPlus/core/item/base/wire/BaseItemFineWire.java +++ b/src/main/java/gtPlusPlus/core/item/base/wire/BaseItemFineWire.java @@ -3,10 +3,9 @@ package gtPlusPlus.core.item.base.wire; import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.material.Material; -public class BaseItemFineWire extends BaseItemComponent{ - - public BaseItemFineWire(final Material material) { - super(material, BaseItemComponent.ComponentTypes.FINEWIRE); - } +public class BaseItemFineWire extends BaseItemComponent { + public BaseItemFineWire(final Material material) { + super(material, BaseItemComponent.ComponentTypes.FINEWIRE); + } } diff --git a/src/main/java/gtPlusPlus/core/item/bauble/BaseBauble.java b/src/main/java/gtPlusPlus/core/item/bauble/BaseBauble.java index fdd148b97b..842b012e07 100644 --- a/src/main/java/gtPlusPlus/core/item/bauble/BaseBauble.java +++ b/src/main/java/gtPlusPlus/core/item/bauble/BaseBauble.java @@ -1,16 +1,21 @@ package gtPlusPlus.core.item.bauble; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - +import baubles.api.BaubleType; +import baubles.api.IBauble; +import baubles.common.container.InventoryBaubles; +import baubles.common.lib.PlayerHandler; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; - import cpw.mods.fml.common.Optional; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.registry.GameRegistry; - +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.ModularArmourUtils.BT; +import gtPlusPlus.core.util.minecraft.NBTUtils; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; @@ -18,173 +23,164 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraft.world.World; - -import baubles.api.BaubleType; -import baubles.api.IBauble; -import baubles.common.container.InventoryBaubles; -import baubles.common.lib.PlayerHandler; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.minecraft.ModularArmourUtils.BT; -import gtPlusPlus.core.util.minecraft.NBTUtils; import net.minecraftforge.event.entity.living.LivingAttackEvent; -@Optional.InterfaceList(value = { @Optional.Interface(iface = "baubles.api.IBauble", modid = "Baubles"), - @Optional.Interface(iface = "baubles.api.BaubleType", modid = "Baubles") }) +@Optional.InterfaceList( + value = { + @Optional.Interface(iface = "baubles.api.IBauble", modid = "Baubles"), + @Optional.Interface(iface = "baubles.api.BaubleType", modid = "Baubles") + }) public class BaseBauble extends Item implements IBauble { - /** - * Implementation suggestions taken from Botania. - */ - - private BaubleType mThisBauble; - private final String mDisplayName; - private List damageNegations = new ArrayList(); - Multimap attributes = HashMultimap.create(); - - public BaseBauble(BaubleType type, String displayName) { - this.mThisBauble = type; - this.mDisplayName = displayName; - Utils.registerEvent(this); - this.setMaxStackSize(1); - this.setCreativeTab(AddToCreativeTab.tabMisc); - this.setUnlocalizedName(Utils.sanitizeString(displayName.toLowerCase())); - GameRegistry.registerItem(this, getUnlocalizedName()); - } - - public BaseBauble(BaubleType type, String unlocalName, int register) { - this.mThisBauble = type; - this.mDisplayName = ""; - Utils.registerEvent(this); - this.setMaxStackSize(1); - this.setCreativeTab(AddToCreativeTab.tabMisc); - } - - @Override - public String getItemStackDisplayName(final ItemStack tItem) { - if (this.mDisplayName == null || this.mDisplayName.length() < 1) { - return super.getItemStackDisplayName(tItem).replaceAll(".name", ""); - } - return this.mDisplayName; - } - - @SubscribeEvent - public void onPlayerAttacked(LivingAttackEvent event) { - if (event.entityLiving instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) event.entityLiving; - if (getCorrectBauble(player) != null && damageNegations.contains(event.source.damageType)) - event.setCanceled(true); - } - } - - public boolean addDamageNegation(DamageSource damageSource) { - return addDamageNegation(damageSource, null); - } - - public boolean addDamageNegation(DamageSource damageSource, ItemStack aStack) { - return damageNegations.add(damageSource.damageType); - } - - public void clearDamageNegation() { - damageNegations.clear(); - } - - @Override - public boolean canEquip(ItemStack arg0, EntityLivingBase arg1) { - return EntityPlayer.class.isInstance(arg1) ? true : false; - } - - @Override - public boolean canUnequip(ItemStack arg0, EntityLivingBase arg1) { - return EntityPlayer.class.isInstance(arg1) ? true : false; - } - - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return mThisBauble; - } - - public boolean SetBaubleType(BT arg0) { - return SetBaubleType(arg0.getType()); - } - - public boolean SetBaubleType(BaubleType arg0) { - BaubleType temp = this.mThisBauble; - this.mThisBauble = arg0; - if (this.mThisBauble != temp) { - return true; - } - return false; - } - - @Override - public void onEquipped(ItemStack stack, EntityLivingBase entity) { - if (entity != null && EntityPlayer.class.isInstance(entity)) { - onEquippedOrLoadedIntoWorld(stack, entity); - setPlayerHashcode(stack, entity.hashCode()); - } - } - - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - if (getPlayerHashcode(stack) != player.hashCode()) { - onEquippedOrLoadedIntoWorld(stack, player); - setPlayerHashcode(stack, player.hashCode()); - } - } - - public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) { - attributes.clear(); - fillModifiers(attributes, stack); - player.getAttributeMap().applyAttributeModifiers(attributes); - } - - @Override - public void onUnequipped(ItemStack stack, EntityLivingBase player) { - attributes.clear(); - fillModifiers(attributes, stack); - player.getAttributeMap().removeAttributeModifiers(attributes); - } - - void fillModifiers(Multimap attributes, ItemStack stack) { - - } - - public ItemStack getCorrectBauble(EntityPlayer player) { - InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player); - ItemStack stack1 = baubles.getStackInSlot(1); - ItemStack stack2 = baubles.getStackInSlot(2); - return isCorrectBauble(stack1) ? stack1 : isCorrectBauble(stack2) ? stack2 : null; - } - - private boolean isCorrectBauble(ItemStack stack) { - return stack != null && (stack.getItem() == this); - } - - @Override - public int getEntityLifespan(ItemStack itemStack, World world) { - return Integer.MAX_VALUE; - } - - public static UUID getBaubleUUID(ItemStack stack) { - long most = NBTUtils.getLong(stack, "baubleUUIDMost"); - if (most == 0) { - UUID uuid = UUID.randomUUID(); - NBTUtils.setLong(stack, "baubleUUIDMost", uuid.getMostSignificantBits()); - NBTUtils.setLong(stack, "baubleUUIDLeast", uuid.getLeastSignificantBits()); - return getBaubleUUID(stack); - } - - long least = NBTUtils.getLong(stack, "baubleUUIDLeast"); - return new UUID(most, least); - } - - public static int getPlayerHashcode(ItemStack stack) { - return NBTUtils.getInteger(stack, "mPlayerHashcode"); - } - - public static void setPlayerHashcode(ItemStack stack, int hash) { - NBTUtils.setInteger(stack, "mPlayerHashcode", hash); - } - + /** + * Implementation suggestions taken from Botania. + */ + private BaubleType mThisBauble; + + private final String mDisplayName; + private List damageNegations = new ArrayList(); + Multimap attributes = HashMultimap.create(); + + public BaseBauble(BaubleType type, String displayName) { + this.mThisBauble = type; + this.mDisplayName = displayName; + Utils.registerEvent(this); + this.setMaxStackSize(1); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setUnlocalizedName(Utils.sanitizeString(displayName.toLowerCase())); + GameRegistry.registerItem(this, getUnlocalizedName()); + } + + public BaseBauble(BaubleType type, String unlocalName, int register) { + this.mThisBauble = type; + this.mDisplayName = ""; + Utils.registerEvent(this); + this.setMaxStackSize(1); + this.setCreativeTab(AddToCreativeTab.tabMisc); + } + + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + if (this.mDisplayName == null || this.mDisplayName.length() < 1) { + return super.getItemStackDisplayName(tItem).replaceAll(".name", ""); + } + return this.mDisplayName; + } + + @SubscribeEvent + public void onPlayerAttacked(LivingAttackEvent event) { + if (event.entityLiving instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) event.entityLiving; + if (getCorrectBauble(player) != null && damageNegations.contains(event.source.damageType)) + event.setCanceled(true); + } + } + + public boolean addDamageNegation(DamageSource damageSource) { + return addDamageNegation(damageSource, null); + } + + public boolean addDamageNegation(DamageSource damageSource, ItemStack aStack) { + return damageNegations.add(damageSource.damageType); + } + + public void clearDamageNegation() { + damageNegations.clear(); + } + + @Override + public boolean canEquip(ItemStack arg0, EntityLivingBase arg1) { + return EntityPlayer.class.isInstance(arg1) ? true : false; + } + + @Override + public boolean canUnequip(ItemStack arg0, EntityLivingBase arg1) { + return EntityPlayer.class.isInstance(arg1) ? true : false; + } + + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return mThisBauble; + } + + public boolean SetBaubleType(BT arg0) { + return SetBaubleType(arg0.getType()); + } + + public boolean SetBaubleType(BaubleType arg0) { + BaubleType temp = this.mThisBauble; + this.mThisBauble = arg0; + if (this.mThisBauble != temp) { + return true; + } + return false; + } + + @Override + public void onEquipped(ItemStack stack, EntityLivingBase entity) { + if (entity != null && EntityPlayer.class.isInstance(entity)) { + onEquippedOrLoadedIntoWorld(stack, entity); + setPlayerHashcode(stack, entity.hashCode()); + } + } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + if (getPlayerHashcode(stack) != player.hashCode()) { + onEquippedOrLoadedIntoWorld(stack, player); + setPlayerHashcode(stack, player.hashCode()); + } + } + + public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) { + attributes.clear(); + fillModifiers(attributes, stack); + player.getAttributeMap().applyAttributeModifiers(attributes); + } + + @Override + public void onUnequipped(ItemStack stack, EntityLivingBase player) { + attributes.clear(); + fillModifiers(attributes, stack); + player.getAttributeMap().removeAttributeModifiers(attributes); + } + + void fillModifiers(Multimap attributes, ItemStack stack) {} + + public ItemStack getCorrectBauble(EntityPlayer player) { + InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player); + ItemStack stack1 = baubles.getStackInSlot(1); + ItemStack stack2 = baubles.getStackInSlot(2); + return isCorrectBauble(stack1) ? stack1 : isCorrectBauble(stack2) ? stack2 : null; + } + + private boolean isCorrectBauble(ItemStack stack) { + return stack != null && (stack.getItem() == this); + } + + @Override + public int getEntityLifespan(ItemStack itemStack, World world) { + return Integer.MAX_VALUE; + } + + public static UUID getBaubleUUID(ItemStack stack) { + long most = NBTUtils.getLong(stack, "baubleUUIDMost"); + if (most == 0) { + UUID uuid = UUID.randomUUID(); + NBTUtils.setLong(stack, "baubleUUIDMost", uuid.getMostSignificantBits()); + NBTUtils.setLong(stack, "baubleUUIDLeast", uuid.getLeastSignificantBits()); + return getBaubleUUID(stack); + } + + long least = NBTUtils.getLong(stack, "baubleUUIDLeast"); + return new UUID(most, least); + } + + public static int getPlayerHashcode(ItemStack stack) { + return NBTUtils.getInteger(stack, "mPlayerHashcode"); + } + + public static void setPlayerHashcode(ItemStack stack, int hash) { + NBTUtils.setInteger(stack, "mPlayerHashcode", hash); + } } diff --git a/src/main/java/gtPlusPlus/core/item/bauble/BatteryPackBaseBauble.java b/src/main/java/gtPlusPlus/core/item/bauble/BatteryPackBaseBauble.java index 70de4603e7..c682c4a237 100644 --- a/src/main/java/gtPlusPlus/core/item/bauble/BatteryPackBaseBauble.java +++ b/src/main/java/gtPlusPlus/core/item/bauble/BatteryPackBaseBauble.java @@ -1,7 +1,5 @@ package gtPlusPlus.core.item.bauble; -import java.util.List; - import baubles.api.BaubleType; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; @@ -13,6 +11,7 @@ import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.common.helpers.ChargingHelper; import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; +import java.util.List; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -26,234 +25,228 @@ import net.minecraft.world.World; public class BatteryPackBaseBauble extends ElectricBaseBauble { - - public BatteryPackBaseBauble(int tier) { - super(BaubleType.BELT, tier, GT_Values.V[tier] * 20 * 300, "GTPP.BattPack.0" + tier + ".name"); - String aUnlocalName = "GTPP.BattPack.0" + tier + ".name"; - this.setCreativeTab(AddToCreativeTab.tabMachines); - if (GameRegistry.findItem(CORE.MODID, aUnlocalName) == null) { - GameRegistry.registerItem(this, aUnlocalName); - } - } - - @SideOnly(Side.CLIENT) - @Override - public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { - ItemStack itemStack = new ItemStack(this, 1); - ItemStack charged; - if (this.getEmptyItem(itemStack) == this) { - charged = new ItemStack(this, 1); - ElectricItem.manager.charge(charged, 0.0D, Integer.MAX_VALUE, true, false); - itemList.add(charged); - } - if (this.getChargedItem(itemStack) == this) { - charged = new ItemStack(this, 1); - ElectricItem.manager.charge(charged, Double.POSITIVE_INFINITY, Integer.MAX_VALUE, true, false); - itemList.add(charged); - } - - } - - @Override - public void onUpdate(final ItemStack itemStack, final World worldObj, final Entity player, final int p_77663_4_, - final boolean p_77663_5_) { - super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); - } - - @Override - public boolean canProvideEnergy(final ItemStack itemStack) { - double aItemCharge = ElectricItem.manager.getCharge(itemStack); - return aItemCharge > 0; - } - - @Override - public String getItemStackDisplayName(final ItemStack p_77653_1_) { - return (EnumChatFormatting.BLUE + super.getItemStackDisplayName(p_77653_1_) + EnumChatFormatting.GRAY); - } - - @Override - public boolean showDurabilityBar(final ItemStack stack) { - return true; - } - - public int secondsLeft(final ItemStack stack) { - double r = 0; - r = this.getCharge(stack) / (10000 * 20); - return (int) MathUtils.decimalRounding(r); - } - - @SuppressWarnings("unchecked") - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - list.add(""); - String aString1 = StatCollector.translateToLocal("GTPP.battpack.tooltip.1"); - String aString2 = StatCollector.translateToLocal("GTPP.battpack.tooltip.2"); - String aString3 = StatCollector.translateToLocal("GTPP.battpack.tooltip.3"); - String aString4 = StatCollector.translateToLocal("GTPP.battpack.tooltip.4"); - - String aEU = StatCollector.translateToLocal("GTPP.info.eu"); - String aEUT = aEU+"/t"; - - list.add(EnumChatFormatting.GREEN + aString1 + EnumChatFormatting.GRAY); - list.add(EnumChatFormatting.GREEN + aString2+" " + (int) getTransferLimit(stack) + aEUT +" "+ aString3 + EnumChatFormatting.GRAY); - list.add(EnumChatFormatting.GREEN + aString4 + EnumChatFormatting.GRAY); - super.addInformation(stack, aPlayer, list, bool); - } - - @Override - public String getToolTip(final ItemStack stack) { - return ElectricItem.manager.getToolTip(stack); - } - - @Override - public boolean canEquip(final ItemStack arg0, final EntityLivingBase arg1) { - return true; - } - - @Override - public boolean canUnequip(final ItemStack arg0, final EntityLivingBase arg1) { - return true; - } - - @Override // TODO - public void onEquipped(final ItemStack arg0, final EntityLivingBase arg1) { - - } - - @Override // TODO - public void onUnequipped(final ItemStack arg0, final EntityLivingBase arg1) { - - } - - @Override // TODO - public void onWornTick(final ItemStack aBaubleStack, final EntityLivingBase aPlayer) { - if (!aPlayer.worldObj.isRemote) { - - try { - - if (this.getCharge(aBaubleStack) >= getTransferLimit(aBaubleStack)) { - // Try Iterate Armour Slots of Player - if (aPlayer instanceof EntityPlayer) { - - // amour - for (final ItemStack aInvStack : ((EntityPlayer) aPlayer).inventory.armorInventory) { - if (aInvStack != null) { - if (aInvStack == aBaubleStack) { - continue; - } - if (ChargingHelper.isItemValid(aInvStack)) { - double aTransferRate = 0; - final IElectricItem electricItem = (IElectricItem) aInvStack.getItem(); - if (electricItem != null) { - aTransferRate = electricItem.getTransferLimit(aInvStack); - double aItemCharge = ElectricItem.manager.getCharge(aInvStack); - if (aItemCharge >= 0 && aItemCharge != electricItem.getMaxCharge(aInvStack)) { - if (aItemCharge <= (electricItem.getMaxCharge(aInvStack) - aTransferRate)) { - if (ElectricItem.manager.getCharge(aBaubleStack) >= aTransferRate) { - if (ElectricItem.manager.getCharge(aInvStack) <= (electricItem.getMaxCharge(aInvStack) - aTransferRate)) { - double d = ElectricItem.manager.charge(aInvStack, aTransferRate * 16, mTier, false, true); - if (d > 0) { - d = ElectricItem.manager.charge(aInvStack, aTransferRate * 16, mTier, false, false); - ElectricItem.manager.discharge(aBaubleStack, d, mTier, false, true, false); - //Logger.INFO("Charging " + aInvStack.getDisplayName() + " | " + d + " | "+electricItem.getMaxCharge(aInvStack)); - } - } - else { - //Logger.INFO("5"); - } - } - else { - //Logger.INFO("4"); - } - } - else { - //Logger.INFO("3"); - } - - } - else { - //Logger.INFO("1"); - } - } - - } - } - if (this.getCharge(aBaubleStack) > 0) { - continue; - } else { - break; - } - } - - // Hotbar Slots - int aSlotCounter = 0; - for (final ItemStack aInvStack : ((EntityPlayer) aPlayer).inventory.mainInventory) { - if (aSlotCounter > (InventoryPlayer.getHotbarSize() - 1)) { - break; - } - aSlotCounter++; - if (aInvStack != null) { - if (aInvStack == aBaubleStack) { - continue; - } - if (ChargingHelper.isItemValid(aInvStack)) { - double aTransferRate = 0; - final IElectricItem electricItem = (IElectricItem) aInvStack.getItem(); - if (electricItem != null) { - aTransferRate = electricItem.getTransferLimit(aInvStack); - double aItemCharge = ElectricItem.manager.getCharge(aInvStack); - if (aItemCharge >= 0 && aItemCharge != electricItem.getMaxCharge(aInvStack)) { - if (aItemCharge <= (electricItem.getMaxCharge(aInvStack) - aTransferRate)) { - if (ElectricItem.manager.getCharge(aBaubleStack) >= aTransferRate) { - if (ElectricItem.manager.getCharge(aInvStack) <= (electricItem.getMaxCharge(aInvStack) - aTransferRate)) { - double d = ElectricItem.manager.charge(aInvStack, aTransferRate, mTier, false, true); - if (d > 0) { - d = ElectricItem.manager.charge(aInvStack, aTransferRate, mTier, false, false); - ElectricItem.manager.discharge(aBaubleStack, d, mTier, false, true, false); - //Logger.INFO("Charging " + aInvStack.getDisplayName() + " | " + d + " | "+electricItem.getMaxCharge(aInvStack)); - } - } - else { - //Logger.INFO("5"); - } - } - else { - //Logger.INFO("4"); - } - } - else { - //Logger.INFO("3"); - } - - } - else { - //Logger.INFO("1"); - } - } - } - } - if (this.getCharge(aBaubleStack) > 0) { - continue; - } else { - break; - } - } - } - } - } - catch (Throwable t) { - - } - } - - - - - } - - @Override - public String getTextureNameForBauble() { - return "chargepack/"+mTier; - } - + public BatteryPackBaseBauble(int tier) { + super(BaubleType.BELT, tier, GT_Values.V[tier] * 20 * 300, "GTPP.BattPack.0" + tier + ".name"); + String aUnlocalName = "GTPP.BattPack.0" + tier + ".name"; + this.setCreativeTab(AddToCreativeTab.tabMachines); + if (GameRegistry.findItem(CORE.MODID, aUnlocalName) == null) { + GameRegistry.registerItem(this, aUnlocalName); + } + } + + @SideOnly(Side.CLIENT) + @Override + public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { + ItemStack itemStack = new ItemStack(this, 1); + ItemStack charged; + if (this.getEmptyItem(itemStack) == this) { + charged = new ItemStack(this, 1); + ElectricItem.manager.charge(charged, 0.0D, Integer.MAX_VALUE, true, false); + itemList.add(charged); + } + if (this.getChargedItem(itemStack) == this) { + charged = new ItemStack(this, 1); + ElectricItem.manager.charge(charged, Double.POSITIVE_INFINITY, Integer.MAX_VALUE, true, false); + itemList.add(charged); + } + } + + @Override + public void onUpdate( + final ItemStack itemStack, + final World worldObj, + final Entity player, + final int p_77663_4_, + final boolean p_77663_5_) { + super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); + } + + @Override + public boolean canProvideEnergy(final ItemStack itemStack) { + double aItemCharge = ElectricItem.manager.getCharge(itemStack); + return aItemCharge > 0; + } + + @Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + return (EnumChatFormatting.BLUE + super.getItemStackDisplayName(p_77653_1_) + EnumChatFormatting.GRAY); + } + + @Override + public boolean showDurabilityBar(final ItemStack stack) { + return true; + } + + public int secondsLeft(final ItemStack stack) { + double r = 0; + r = this.getCharge(stack) / (10000 * 20); + return (int) MathUtils.decimalRounding(r); + } + + @SuppressWarnings("unchecked") + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add(""); + String aString1 = StatCollector.translateToLocal("GTPP.battpack.tooltip.1"); + String aString2 = StatCollector.translateToLocal("GTPP.battpack.tooltip.2"); + String aString3 = StatCollector.translateToLocal("GTPP.battpack.tooltip.3"); + String aString4 = StatCollector.translateToLocal("GTPP.battpack.tooltip.4"); + + String aEU = StatCollector.translateToLocal("GTPP.info.eu"); + String aEUT = aEU + "/t"; + + list.add(EnumChatFormatting.GREEN + aString1 + EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GREEN + aString2 + " " + (int) getTransferLimit(stack) + aEUT + " " + aString3 + + EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GREEN + aString4 + EnumChatFormatting.GRAY); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public String getToolTip(final ItemStack stack) { + return ElectricItem.manager.getToolTip(stack); + } + + @Override + public boolean canEquip(final ItemStack arg0, final EntityLivingBase arg1) { + return true; + } + + @Override + public boolean canUnequip(final ItemStack arg0, final EntityLivingBase arg1) { + return true; + } + + @Override // TODO + public void onEquipped(final ItemStack arg0, final EntityLivingBase arg1) {} + + @Override // TODO + public void onUnequipped(final ItemStack arg0, final EntityLivingBase arg1) {} + + @Override // TODO + public void onWornTick(final ItemStack aBaubleStack, final EntityLivingBase aPlayer) { + if (!aPlayer.worldObj.isRemote) { + + try { + + if (this.getCharge(aBaubleStack) >= getTransferLimit(aBaubleStack)) { + // Try Iterate Armour Slots of Player + if (aPlayer instanceof EntityPlayer) { + + // amour + for (final ItemStack aInvStack : ((EntityPlayer) aPlayer).inventory.armorInventory) { + if (aInvStack != null) { + if (aInvStack == aBaubleStack) { + continue; + } + if (ChargingHelper.isItemValid(aInvStack)) { + double aTransferRate = 0; + final IElectricItem electricItem = (IElectricItem) aInvStack.getItem(); + if (electricItem != null) { + aTransferRate = electricItem.getTransferLimit(aInvStack); + double aItemCharge = ElectricItem.manager.getCharge(aInvStack); + if (aItemCharge >= 0 && aItemCharge != electricItem.getMaxCharge(aInvStack)) { + if (aItemCharge <= (electricItem.getMaxCharge(aInvStack) - aTransferRate)) { + if (ElectricItem.manager.getCharge(aBaubleStack) >= aTransferRate) { + if (ElectricItem.manager.getCharge(aInvStack) + <= (electricItem.getMaxCharge(aInvStack) - aTransferRate)) { + double d = ElectricItem.manager.charge( + aInvStack, aTransferRate * 16, mTier, false, true); + if (d > 0) { + d = ElectricItem.manager.charge( + aInvStack, aTransferRate * 16, mTier, false, false); + ElectricItem.manager.discharge( + aBaubleStack, d, mTier, false, true, false); + // Logger.INFO("Charging " + aInvStack.getDisplayName() + " + // | " + d + " | "+electricItem.getMaxCharge(aInvStack)); + } + } else { + // Logger.INFO("5"); + } + } else { + // Logger.INFO("4"); + } + } else { + // Logger.INFO("3"); + } + + } else { + // Logger.INFO("1"); + } + } + } + } + if (this.getCharge(aBaubleStack) > 0) { + continue; + } else { + break; + } + } + + // Hotbar Slots + int aSlotCounter = 0; + for (final ItemStack aInvStack : ((EntityPlayer) aPlayer).inventory.mainInventory) { + if (aSlotCounter > (InventoryPlayer.getHotbarSize() - 1)) { + break; + } + aSlotCounter++; + if (aInvStack != null) { + if (aInvStack == aBaubleStack) { + continue; + } + if (ChargingHelper.isItemValid(aInvStack)) { + double aTransferRate = 0; + final IElectricItem electricItem = (IElectricItem) aInvStack.getItem(); + if (electricItem != null) { + aTransferRate = electricItem.getTransferLimit(aInvStack); + double aItemCharge = ElectricItem.manager.getCharge(aInvStack); + if (aItemCharge >= 0 && aItemCharge != electricItem.getMaxCharge(aInvStack)) { + if (aItemCharge <= (electricItem.getMaxCharge(aInvStack) - aTransferRate)) { + if (ElectricItem.manager.getCharge(aBaubleStack) >= aTransferRate) { + if (ElectricItem.manager.getCharge(aInvStack) + <= (electricItem.getMaxCharge(aInvStack) - aTransferRate)) { + double d = ElectricItem.manager.charge( + aInvStack, aTransferRate, mTier, false, true); + if (d > 0) { + d = ElectricItem.manager.charge( + aInvStack, aTransferRate, mTier, false, false); + ElectricItem.manager.discharge( + aBaubleStack, d, mTier, false, true, false); + // Logger.INFO("Charging " + aInvStack.getDisplayName() + " + // | " + d + " | "+electricItem.getMaxCharge(aInvStack)); + } + } else { + // Logger.INFO("5"); + } + } else { + // Logger.INFO("4"); + } + } else { + // Logger.INFO("3"); + } + + } else { + // Logger.INFO("1"); + } + } + } + } + if (this.getCharge(aBaubleStack) > 0) { + continue; + } else { + break; + } + } + } + } + } catch (Throwable t) { + + } + } + } + + @Override + public String getTextureNameForBauble() { + return "chargepack/" + mTier; + } } diff --git a/src/main/java/gtPlusPlus/core/item/bauble/ElectricBaseBauble.java b/src/main/java/gtPlusPlus/core/item/bauble/ElectricBaseBauble.java index 4316f13401..321b3515aa 100644 --- a/src/main/java/gtPlusPlus/core/item/bauble/ElectricBaseBauble.java +++ b/src/main/java/gtPlusPlus/core/item/bauble/ElectricBaseBauble.java @@ -1,7 +1,5 @@ package gtPlusPlus.core.item.bauble; -import java.util.List; - import baubles.api.BaubleType; import baubles.api.IBauble; import cpw.mods.fml.common.Optional; @@ -15,6 +13,7 @@ import gtPlusPlus.core.util.math.MathUtils; import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; import ic2.api.item.IElectricItemManager; +import java.util.List; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -25,173 +24,188 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraft.world.World; -@Optional.InterfaceList(value = { @Optional.Interface(iface = "baubles.api.IBauble", modid = "Baubles"), -@Optional.Interface(iface = "baubles.api.BaubleType", modid = "Baubles") }) +@Optional.InterfaceList( + value = { + @Optional.Interface(iface = "baubles.api.IBauble", modid = "Baubles"), + @Optional.Interface(iface = "baubles.api.BaubleType", modid = "Baubles") + }) public abstract class ElectricBaseBauble extends BaseBauble implements IElectricItem, IElectricItemManager, IBauble { - public final int mTier; - private final double maxValueEU; - private final BaubleType mType; - - public ElectricBaseBauble(BaubleType aType, int aTier, double aMaxEU, String aUnlocalName) { - super(aType, aUnlocalName, 0); - mType = aType; - mTier = aTier; - maxValueEU = aMaxEU; - this.setUnlocalizedName(aUnlocalName); - this.setTextureName(CORE.MODID + ":" + getTextureNameForBauble()); - this.setMaxDamage(27); - this.setMaxStackSize(1); - this.setNoRepair(); - this.setCreativeTab(AddToCreativeTab.tabMachines); - if (GameRegistry.findItem(CORE.MODID, aUnlocalName) == null) { - GameRegistry.registerItem(this, aUnlocalName); - } - } - - public abstract String getTextureNameForBauble(); - - @SuppressWarnings("unchecked") - @SideOnly(Side.CLIENT) - @Override - public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { - ItemStack itemStack = new ItemStack(this, 1); - ItemStack charged; - if (this.getEmptyItem(itemStack) == this) { - charged = new ItemStack(this, 1); - ElectricItem.manager.charge(charged, 0.0D, Integer.MAX_VALUE, true, false); - itemList.add(charged); - } - if (this.getChargedItem(itemStack) == this) { - charged = new ItemStack(this, 1); - ElectricItem.manager.charge(charged, Double.POSITIVE_INFINITY, Integer.MAX_VALUE, true, false); - itemList.add(charged); - } - - } - - @Override - public void onUpdate(final ItemStack itemStack, final World worldObj, final Entity player, final int p_77663_4_, - final boolean p_77663_5_) { - super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); - } - - @Override - public boolean canProvideEnergy(final ItemStack itemStack) { - double aItemCharge = ElectricItem.manager.getCharge(itemStack); - return aItemCharge > 0; - } - - @Override - public final Item getChargedItem(final ItemStack itemStack) { - final ItemStack x = itemStack.copy(); - x.setItemDamage(27); - return x.getItem(); - } - - @Override - public final Item getEmptyItem(final ItemStack itemStack) { - final ItemStack x = itemStack.copy(); - x.setItemDamage(0); - return x.getItem(); - } - - @Override - public final double getMaxCharge(final ItemStack itemStack) { - return maxValueEU; - } - - @Override - public final int getTier(final ItemStack itemStack) { - return mTier; - } - - @Override - public final double getTransferLimit(final ItemStack itemStack) { - return GT_Values.V[mTier]; - } - - @Override - public final double getDurabilityForDisplay(final ItemStack stack) { - return 1.0D - (this.getCharge(stack) / this.getMaxCharge(stack)); - } - - @Override - public boolean showDurabilityBar(final ItemStack stack) { - return true; - } - - @SuppressWarnings("unchecked") - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - list.add(""); - String aEuInfo = StatCollector.translateToLocal("GTPP.info.euInfo"); - String aTier = StatCollector.translateToLocal("GTPP.machines.tier"); - String aInputLimit = StatCollector.translateToLocal("GTPP.info.inputLimit"); - String aCurrentPower = StatCollector.translateToLocal("GTPP.info.currentPower"); - String aEU = StatCollector.translateToLocal("GTPP.info.eu"); - String aEUT = aEU+"/t"; - - list.add(EnumChatFormatting.GOLD + aEuInfo + EnumChatFormatting.GRAY); - list.add(EnumChatFormatting.GRAY + aTier+": [" + EnumChatFormatting.YELLOW + this.getTier(stack) - + EnumChatFormatting.GRAY + "] "+aInputLimit+": [" + EnumChatFormatting.YELLOW - + this.getTransferLimit(stack) + EnumChatFormatting.GRAY + aEUT+"]"); - list.add(EnumChatFormatting.GRAY + aCurrentPower +": [" + EnumChatFormatting.YELLOW + (long) this.getCharge(stack) - + EnumChatFormatting.GRAY + aEU +"] [" + EnumChatFormatting.YELLOW - + MathUtils.findPercentage(this.getCharge(stack), this.getMaxCharge(stack)) + EnumChatFormatting.GRAY - + "%]"); - super.addInformation(stack, aPlayer, list, bool); - } - - @Override - public final double charge(final ItemStack stack, final double amount, final int tier, final boolean ignoreTransferLimit, - final boolean simulate) { - /*if (!simulate) { - ElectricItem.manager.charge(stack, amount, tier, true, simulate); - }*/ - - return ElectricItem.manager.charge(stack, amount, tier, true, simulate); - } - - @Override - public final double discharge(final ItemStack stack, final double amount, final int tier, - final boolean ignoreTransferLimit, final boolean externally, final boolean simulate) { - /*if (!simulate) { - ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate); - }*/ - - return ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate); - } - - @Override - public final double getCharge(final ItemStack stack) { - return ElectricItem.manager.getCharge(stack); - } - - @Override - public final boolean canUse(final ItemStack stack, final double amount) { - return ElectricItem.manager.canUse(stack, amount); - } - - @Override - public final boolean use(final ItemStack stack, final double amount, final EntityLivingBase entity) { - return ElectricItem.manager.use(stack, amount, entity); - } - - @Override - public final void chargeFromArmor(final ItemStack stack, final EntityLivingBase entity) { - ElectricItem.manager.chargeFromArmor(stack, entity); - } - - @Override - public String getToolTip(final ItemStack stack) { - //return ElectricItem.manager.getToolTip(stack); - return null; - } - - @Override - public final BaubleType getBaubleType(final ItemStack arg0) { - return mType; - } - + public final int mTier; + private final double maxValueEU; + private final BaubleType mType; + + public ElectricBaseBauble(BaubleType aType, int aTier, double aMaxEU, String aUnlocalName) { + super(aType, aUnlocalName, 0); + mType = aType; + mTier = aTier; + maxValueEU = aMaxEU; + this.setUnlocalizedName(aUnlocalName); + this.setTextureName(CORE.MODID + ":" + getTextureNameForBauble()); + this.setMaxDamage(27); + this.setMaxStackSize(1); + this.setNoRepair(); + this.setCreativeTab(AddToCreativeTab.tabMachines); + if (GameRegistry.findItem(CORE.MODID, aUnlocalName) == null) { + GameRegistry.registerItem(this, aUnlocalName); + } + } + + public abstract String getTextureNameForBauble(); + + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + @Override + public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { + ItemStack itemStack = new ItemStack(this, 1); + ItemStack charged; + if (this.getEmptyItem(itemStack) == this) { + charged = new ItemStack(this, 1); + ElectricItem.manager.charge(charged, 0.0D, Integer.MAX_VALUE, true, false); + itemList.add(charged); + } + if (this.getChargedItem(itemStack) == this) { + charged = new ItemStack(this, 1); + ElectricItem.manager.charge(charged, Double.POSITIVE_INFINITY, Integer.MAX_VALUE, true, false); + itemList.add(charged); + } + } + + @Override + public void onUpdate( + final ItemStack itemStack, + final World worldObj, + final Entity player, + final int p_77663_4_, + final boolean p_77663_5_) { + super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); + } + + @Override + public boolean canProvideEnergy(final ItemStack itemStack) { + double aItemCharge = ElectricItem.manager.getCharge(itemStack); + return aItemCharge > 0; + } + + @Override + public final Item getChargedItem(final ItemStack itemStack) { + final ItemStack x = itemStack.copy(); + x.setItemDamage(27); + return x.getItem(); + } + + @Override + public final Item getEmptyItem(final ItemStack itemStack) { + final ItemStack x = itemStack.copy(); + x.setItemDamage(0); + return x.getItem(); + } + + @Override + public final double getMaxCharge(final ItemStack itemStack) { + return maxValueEU; + } + + @Override + public final int getTier(final ItemStack itemStack) { + return mTier; + } + + @Override + public final double getTransferLimit(final ItemStack itemStack) { + return GT_Values.V[mTier]; + } + + @Override + public final double getDurabilityForDisplay(final ItemStack stack) { + return 1.0D - (this.getCharge(stack) / this.getMaxCharge(stack)); + } + + @Override + public boolean showDurabilityBar(final ItemStack stack) { + return true; + } + + @SuppressWarnings("unchecked") + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add(""); + String aEuInfo = StatCollector.translateToLocal("GTPP.info.euInfo"); + String aTier = StatCollector.translateToLocal("GTPP.machines.tier"); + String aInputLimit = StatCollector.translateToLocal("GTPP.info.inputLimit"); + String aCurrentPower = StatCollector.translateToLocal("GTPP.info.currentPower"); + String aEU = StatCollector.translateToLocal("GTPP.info.eu"); + String aEUT = aEU + "/t"; + + list.add(EnumChatFormatting.GOLD + aEuInfo + EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GRAY + aTier + ": [" + EnumChatFormatting.YELLOW + this.getTier(stack) + + EnumChatFormatting.GRAY + "] " + aInputLimit + ": [" + EnumChatFormatting.YELLOW + + this.getTransferLimit(stack) + EnumChatFormatting.GRAY + aEUT + "]"); + list.add(EnumChatFormatting.GRAY + aCurrentPower + ": [" + EnumChatFormatting.YELLOW + + (long) this.getCharge(stack) + + EnumChatFormatting.GRAY + aEU + "] [" + EnumChatFormatting.YELLOW + + MathUtils.findPercentage(this.getCharge(stack), this.getMaxCharge(stack)) + EnumChatFormatting.GRAY + + "%]"); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public final double charge( + final ItemStack stack, + final double amount, + final int tier, + final boolean ignoreTransferLimit, + final boolean simulate) { + /*if (!simulate) { + ElectricItem.manager.charge(stack, amount, tier, true, simulate); + }*/ + + return ElectricItem.manager.charge(stack, amount, tier, true, simulate); + } + + @Override + public final double discharge( + final ItemStack stack, + final double amount, + final int tier, + final boolean ignoreTransferLimit, + final boolean externally, + final boolean simulate) { + /*if (!simulate) { + ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate); + }*/ + + return ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate); + } + + @Override + public final double getCharge(final ItemStack stack) { + return ElectricItem.manager.getCharge(stack); + } + + @Override + public final boolean canUse(final ItemStack stack, final double amount) { + return ElectricItem.manager.canUse(stack, amount); + } + + @Override + public final boolean use(final ItemStack stack, final double amount, final EntityLivingBase entity) { + return ElectricItem.manager.use(stack, amount, entity); + } + + @Override + public final void chargeFromArmor(final ItemStack stack, final EntityLivingBase entity) { + ElectricItem.manager.chargeFromArmor(stack, entity); + } + + @Override + public String getToolTip(final ItemStack stack) { + // return ElectricItem.manager.getToolTip(stack); + return null; + } + + @Override + public final BaubleType getBaubleType(final ItemStack arg0) { + return mType; + } } diff --git a/src/main/java/gtPlusPlus/core/item/bauble/FireProtectionBauble.java b/src/main/java/gtPlusPlus/core/item/bauble/FireProtectionBauble.java index 6a8751b682..e0f8cc6e27 100644 --- a/src/main/java/gtPlusPlus/core/item/bauble/FireProtectionBauble.java +++ b/src/main/java/gtPlusPlus/core/item/bauble/FireProtectionBauble.java @@ -1,17 +1,16 @@ package gtPlusPlus.core.item.bauble; -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.UUID; - import baubles.api.BaubleType; import cpw.mods.fml.common.registry.GameRegistry; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.preloader.DevHelper; +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.UUID; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -23,115 +22,118 @@ import net.minecraft.world.World; public class FireProtectionBauble extends BaseBauble { - public static HashMap mDataMap = new HashMap(); - public static HashSet mPlayerMap = new HashSet(); - - private static Field isImmuneToFire; - - static { - isImmuneToFire = ReflectionUtils.getField(Entity.class, DevHelper.isObfuscatedEnvironment() ? "func_70045_F" : "isImmuneToFire"); - } - - public static boolean fireImmune(Entity aEntity) { - return aEntity.isImmuneToFire(); - } - - public static boolean setEntityImmuneToFire(Entity aEntity, boolean aImmune) { - try { - return ReflectionUtils.setField(aEntity, isImmuneToFire, aImmune); - } - catch (Throwable t) {} - return false; - } - - public FireProtectionBauble() { - super(BaubleType.RING, "GTPP.bauble.fireprotection.0" + ".name", 0); - String aUnlocalName = "GTPP.bauble.fireprotection.0" + ".name"; - this.setUnlocalizedName(aUnlocalName); - this.setTextureName(CORE.MODID + ":" + getTextureNameForBauble()); - this.setMaxDamage(100); - this.setMaxStackSize(1); - this.setNoRepair(); - this.setCreativeTab(AddToCreativeTab.tabMachines); - if (GameRegistry.findItem(CORE.MODID, aUnlocalName) == null) { - GameRegistry.registerItem(this, aUnlocalName); - } - } - - @Override - public void onUpdate(final ItemStack itemStack, final World worldObj, final Entity player, final int p_77663_4_, - final boolean p_77663_5_) { - super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); - - } - - @Override - public String getItemStackDisplayName(final ItemStack p_77653_1_) { - return (EnumChatFormatting.DARK_RED + super.getItemStackDisplayName(p_77653_1_) + EnumChatFormatting.GRAY); - } - - @Override - public boolean showDurabilityBar(final ItemStack stack) { - return false; - } - - @SuppressWarnings("unchecked") - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - super.addInformation(stack, aPlayer, list, bool); - } - - @Override - public boolean canEquip(final ItemStack arg0, final EntityLivingBase arg1) { - return true; - } - - @Override - public boolean canUnequip(final ItemStack arg0, final EntityLivingBase arg1) { - return true; - } - - @Override - public void onEquipped(final ItemStack arg0, final EntityLivingBase aPlayer) { - if (!aPlayer.worldObj.isRemote) { - if (aPlayer instanceof EntityPlayer) { - EntityPlayer bPlayer = (EntityPlayer) aPlayer; - mPlayerMap.add(bPlayer.getUniqueID()); - } - } - } - - @Override - public void onUnequipped(final ItemStack arg0, final EntityLivingBase aPlayer) { - if (!aPlayer.worldObj.isRemote) { - if (aPlayer instanceof EntityPlayer) { - EntityPlayer bPlayer = (EntityPlayer) aPlayer; - if (bPlayer.isPotionActive(Potion.fireResistance)) { - bPlayer.removePotionEffect(Potion.fireResistance.id); - } - mPlayerMap.remove(bPlayer.getUniqueID()); - setEntityImmuneToFire(bPlayer, false); - } - } - } - - @Override - public void onWornTick(final ItemStack aBaubleStack, final EntityLivingBase aPlayer) { - if (!aPlayer.worldObj.isRemote) { - if (aPlayer instanceof EntityPlayer) { - EntityPlayer bPlayer = (EntityPlayer) aPlayer; - if (!fireImmune(bPlayer)) { - setEntityImmuneToFire(bPlayer, true); - } - if (!bPlayer.isPotionActive(Potion.fireResistance)) { - bPlayer.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 100, 4)); - } - } - } - } - - public String getTextureNameForBauble() { - return "baubles/itemFireProtectGlovesBetter"; - } + public static HashMap mDataMap = new HashMap(); + public static HashSet mPlayerMap = new HashSet(); + + private static Field isImmuneToFire; + + static { + isImmuneToFire = ReflectionUtils.getField( + Entity.class, DevHelper.isObfuscatedEnvironment() ? "func_70045_F" : "isImmuneToFire"); + } + + public static boolean fireImmune(Entity aEntity) { + return aEntity.isImmuneToFire(); + } + + public static boolean setEntityImmuneToFire(Entity aEntity, boolean aImmune) { + try { + return ReflectionUtils.setField(aEntity, isImmuneToFire, aImmune); + } catch (Throwable t) { + } + return false; + } + + public FireProtectionBauble() { + super(BaubleType.RING, "GTPP.bauble.fireprotection.0" + ".name", 0); + String aUnlocalName = "GTPP.bauble.fireprotection.0" + ".name"; + this.setUnlocalizedName(aUnlocalName); + this.setTextureName(CORE.MODID + ":" + getTextureNameForBauble()); + this.setMaxDamage(100); + this.setMaxStackSize(1); + this.setNoRepair(); + this.setCreativeTab(AddToCreativeTab.tabMachines); + if (GameRegistry.findItem(CORE.MODID, aUnlocalName) == null) { + GameRegistry.registerItem(this, aUnlocalName); + } + } + + @Override + public void onUpdate( + final ItemStack itemStack, + final World worldObj, + final Entity player, + final int p_77663_4_, + final boolean p_77663_5_) { + super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); + } + + @Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + return (EnumChatFormatting.DARK_RED + super.getItemStackDisplayName(p_77653_1_) + EnumChatFormatting.GRAY); + } + + @Override + public boolean showDurabilityBar(final ItemStack stack) { + return false; + } + + @SuppressWarnings("unchecked") + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public boolean canEquip(final ItemStack arg0, final EntityLivingBase arg1) { + return true; + } + + @Override + public boolean canUnequip(final ItemStack arg0, final EntityLivingBase arg1) { + return true; + } + + @Override + public void onEquipped(final ItemStack arg0, final EntityLivingBase aPlayer) { + if (!aPlayer.worldObj.isRemote) { + if (aPlayer instanceof EntityPlayer) { + EntityPlayer bPlayer = (EntityPlayer) aPlayer; + mPlayerMap.add(bPlayer.getUniqueID()); + } + } + } + + @Override + public void onUnequipped(final ItemStack arg0, final EntityLivingBase aPlayer) { + if (!aPlayer.worldObj.isRemote) { + if (aPlayer instanceof EntityPlayer) { + EntityPlayer bPlayer = (EntityPlayer) aPlayer; + if (bPlayer.isPotionActive(Potion.fireResistance)) { + bPlayer.removePotionEffect(Potion.fireResistance.id); + } + mPlayerMap.remove(bPlayer.getUniqueID()); + setEntityImmuneToFire(bPlayer, false); + } + } + } + + @Override + public void onWornTick(final ItemStack aBaubleStack, final EntityLivingBase aPlayer) { + if (!aPlayer.worldObj.isRemote) { + if (aPlayer instanceof EntityPlayer) { + EntityPlayer bPlayer = (EntityPlayer) aPlayer; + if (!fireImmune(bPlayer)) { + setEntityImmuneToFire(bPlayer, true); + } + if (!bPlayer.isPotionActive(Potion.fireResistance)) { + bPlayer.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 100, 4)); + } + } + } + } + public String getTextureNameForBauble() { + return "baubles/itemFireProtectGlovesBetter"; + } } diff --git a/src/main/java/gtPlusPlus/core/item/bauble/HealthBoostBauble.java b/src/main/java/gtPlusPlus/core/item/bauble/HealthBoostBauble.java index 49ce7ad715..8e4769860c 100644 --- a/src/main/java/gtPlusPlus/core/item/bauble/HealthBoostBauble.java +++ b/src/main/java/gtPlusPlus/core/item/bauble/HealthBoostBauble.java @@ -1,9 +1,9 @@ package gtPlusPlus.core.item.bauble; -import java.util.List; - +import baubles.api.BaubleType; import com.google.common.collect.Multimap; - +import gtPlusPlus.core.lib.CORE; +import java.util.List; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; @@ -11,29 +11,25 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumChatFormatting; -import baubles.api.BaubleType; -import gtPlusPlus.core.lib.CORE; +public class HealthBoostBauble extends BaseBauble { -public class HealthBoostBauble extends BaseBauble{ + public HealthBoostBauble() { + super(BaubleType.AMULET, "The Key to the City"); + addDamageNegation(DamageSource.wither); + this.setTextureName(CORE.MODID + ":" + "itemKeyGold"); + } - - public HealthBoostBauble() { - super(BaubleType.AMULET, "The Key to the City"); - addDamageNegation(DamageSource.wither); - this.setTextureName(CORE.MODID + ":" + "itemKeyGold"); - } + @Override + void fillModifiers(Multimap attributes, ItemStack stack) { + attributes.put( + SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), + new AttributeModifier(getBaubleUUID(stack), "Bauble modifier", 40, 0)); + } - @Override - void fillModifiers(Multimap attributes, ItemStack stack) { - attributes.put(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), new AttributeModifier(getBaubleUUID(stack), "Bauble modifier", 40, 0)); - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { - list.add(EnumChatFormatting.GRAY+"You feel like you're on top of the world."); - list.add(EnumChatFormatting.GRAY+"Wear it around your neck like an amulet."); - super.addInformation(stack, player, list, bool); - } - - + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { + list.add(EnumChatFormatting.GRAY + "You feel like you're on top of the world."); + list.add(EnumChatFormatting.GRAY + "Wear it around your neck like an amulet."); + super.addInformation(stack, player, list, bool); + } } diff --git a/src/main/java/gtPlusPlus/core/item/bauble/ModularBauble.java b/src/main/java/gtPlusPlus/core/item/bauble/ModularBauble.java index a8d216e1bc..bbedb9feb4 100644 --- a/src/main/java/gtPlusPlus/core/item/bauble/ModularBauble.java +++ b/src/main/java/gtPlusPlus/core/item/bauble/ModularBauble.java @@ -1,14 +1,16 @@ package gtPlusPlus.core.item.bauble; -import java.util.List; - -import org.lwjgl.input.Keyboard; - +import baubles.api.BaubleType; import com.google.common.collect.Multimap; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.minecraft.ModularArmourUtils; +import gtPlusPlus.core.util.minecraft.ModularArmourUtils.BT; +import gtPlusPlus.core.util.minecraft.ModularArmourUtils.Modifiers; +import gtPlusPlus.core.util.minecraft.NBTUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; @@ -20,389 +22,397 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; - -import baubles.api.BaubleType; -import gtPlusPlus.core.lib.LoadedMods; -import gtPlusPlus.core.util.minecraft.ModularArmourUtils; -import gtPlusPlus.core.util.minecraft.ModularArmourUtils.BT; -import gtPlusPlus.core.util.minecraft.ModularArmourUtils.Modifiers; -import gtPlusPlus.core.util.minecraft.NBTUtils; -import gtPlusPlus.core.util.minecraft.PlayerUtils; +import org.lwjgl.input.Keyboard; public class ModularBauble extends BaseBauble { - @SideOnly(Side.CLIENT) - private IIcon mTextureAmulet; - @SideOnly(Side.CLIENT) - private IIcon mTextureRing; - @SideOnly(Side.CLIENT) - private IIcon mTextureBelt; - private IIcon iconArray[] = new IIcon[3]; - @SideOnly(Side.CLIENT) - private IIcon mfallback; - - public ModularBauble() { - super(BaubleType.AMULET, "Modular Bauble"); - } - - @Override - void fillModifiers(Multimap attributes, ItemStack stack) { - - // Get Stats - int mStatlevel = 0; - if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_DAMAGE)) > 0) { - if (mStatlevel > 0 && mStatlevel < 20) { - attributes.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), - new AttributeModifier(getBaubleUUID(stack), "AD" + mStatlevel, 1, 0)); - } else if (mStatlevel > 20 && mStatlevel < 45) { - attributes.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), - new AttributeModifier(getBaubleUUID(stack), "AD" + mStatlevel, 2, 0)); - } else if (mStatlevel >= 45 && mStatlevel < 75) { - attributes.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), - new AttributeModifier(getBaubleUUID(stack), "AD" + mStatlevel, 4, 0)); - } else if (mStatlevel >= 75 && mStatlevel < 99) { - attributes.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), - new AttributeModifier(getBaubleUUID(stack), "AD" + mStatlevel, 8, 0)); - } else if (mStatlevel >= 100) { - attributes.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), - new AttributeModifier(getBaubleUUID(stack), "AD" + mStatlevel, 16, 0)); - } - } - if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_DEF)) > 0) { - if (mStatlevel > 0 && mStatlevel < 20) { - attributes.put(SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), - new AttributeModifier(getBaubleUUID(stack), "BD" + mStatlevel, 1, 0)); - } else if (mStatlevel > 20 && mStatlevel < 45) { - attributes.put(SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), - new AttributeModifier(getBaubleUUID(stack), "BD" + mStatlevel, 2, 0)); - } else if (mStatlevel > 45 && mStatlevel < 75) { - attributes.put(SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), - new AttributeModifier(getBaubleUUID(stack), "BD" + mStatlevel, 3, 0)); - } else if (mStatlevel > 75 && mStatlevel < 99) { - attributes.put(SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), - new AttributeModifier(getBaubleUUID(stack), "BD" + mStatlevel, 6, 0)); - } else if (mStatlevel >= 100) { - attributes.put(SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), - new AttributeModifier(getBaubleUUID(stack), "BD" + mStatlevel, 10, 0)); - } - } - if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_HP)) > 0) { - if (mStatlevel > 0 && mStatlevel <= 100) { - int bonus = mStatlevel / 5; - attributes.put(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), - new AttributeModifier(getBaubleUUID(stack), "HP" + mStatlevel, bonus * 2, 0)); - } - } - if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_SPEED)) > 0) { - if (mStatlevel > 0 && mStatlevel < 20) { - attributes.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), - new AttributeModifier(getBaubleUUID(stack), "SP" + mStatlevel, 1, 0)); - } else if (mStatlevel > 20 && mStatlevel < 45) { - attributes.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), - new AttributeModifier(getBaubleUUID(stack), "SP" + mStatlevel, 2, 0)); - } else if (mStatlevel > 45 && mStatlevel < 75) { - attributes.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), - new AttributeModifier(getBaubleUUID(stack), "SP" + mStatlevel, 3, 0)); - } else if (mStatlevel > 75 && mStatlevel < 99) { - attributes.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), - new AttributeModifier(getBaubleUUID(stack), "SP" + mStatlevel, 4, 0)); - } else if (mStatlevel >= 100) { - attributes.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), - new AttributeModifier(getBaubleUUID(stack), "SP" + mStatlevel, 5, 0)); - } - } - if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_MINING)) > 0) { - } - if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_HOLY)) > 0) { - } - - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { - // Bauble Type - if (ModularArmourUtils.getBaubleType(stack) == BaubleType.AMULET) { - list.add(EnumChatFormatting.GRAY + "Current Form: " + EnumChatFormatting.RED + "Amulet" - + EnumChatFormatting.GRAY + "."); - list.add(EnumChatFormatting.GRAY + "You can change this into a Ring or a Belt."); - } else if (ModularArmourUtils.getBaubleType(stack) == BaubleType.RING) { - list.add(EnumChatFormatting.GRAY + "Current Form: " + EnumChatFormatting.RED + "Ring" - + EnumChatFormatting.GRAY + "."); - list.add(EnumChatFormatting.GRAY + "You can change this into an Amulet or a Belt."); - } else if (ModularArmourUtils.getBaubleType(stack) == BaubleType.BELT) { - list.add(EnumChatFormatting.GRAY + "Current Form: " + EnumChatFormatting.RED + "Belt" - + EnumChatFormatting.GRAY + "."); - list.add(EnumChatFormatting.GRAY + "You can change this into a Ring or an Amulet."); - } - - // Get Stats - int mStatlevel = 0; - if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_DAMAGE)) > 0) { - list.add(EnumChatFormatting.GRAY + "Damage Boost: " + EnumChatFormatting.DARK_RED + mStatlevel - + EnumChatFormatting.GRAY + "/100."); - } - if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_HP)) > 0) { - list.add(EnumChatFormatting.GRAY + "Health Boost: " + EnumChatFormatting.RED + mStatlevel - + EnumChatFormatting.GRAY + "/100. Bonus " + (mStatlevel / 5) + " hearts."); - } - if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_SPEED)) > 0) { - list.add(EnumChatFormatting.GRAY + "Speed Boost: " + EnumChatFormatting.WHITE + mStatlevel - + EnumChatFormatting.GRAY + "/100."); - } - if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_MINING)) > 0) { - list.add(EnumChatFormatting.GRAY + "Mining Boost: " + EnumChatFormatting.DARK_GRAY + mStatlevel - + EnumChatFormatting.GRAY + "/100."); - } - if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_HOLY)) > 0) { - list.add(EnumChatFormatting.GRAY + "Holy Boost: " + EnumChatFormatting.GOLD + mStatlevel - + EnumChatFormatting.GRAY + "/100."); - } - - // Defence Boost - if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_DEF)) > 0) { - list.add(EnumChatFormatting.GRAY + "Defence Boost: " + EnumChatFormatting.BLUE + mStatlevel - + EnumChatFormatting.GRAY + "/100."); - - if ((Keyboard.isKeyDown(42)) || (Keyboard.isKeyDown(54))) { - - if (mStatlevel >= 1) { - list.add(EnumChatFormatting.GRAY + "Protected From: " + EnumChatFormatting.BLUE + "Cactus" - + EnumChatFormatting.GRAY + "."); - } - if (mStatlevel >= 10) { - list.add(EnumChatFormatting.GRAY + "Protected From: " + EnumChatFormatting.BLUE + "Falling Blocks" - + EnumChatFormatting.GRAY + "."); - } - if (mStatlevel >= 20) { - list.add(EnumChatFormatting.GRAY + "Protected From: " + EnumChatFormatting.BLUE + "Wall Suffocation" - + EnumChatFormatting.GRAY + "."); - } - if (mStatlevel >= 35) { - list.add(EnumChatFormatting.GRAY + "Protected From: " + EnumChatFormatting.BLUE + "Drowning" - + EnumChatFormatting.GRAY + "."); - } - if (mStatlevel >= 50) { - list.add(EnumChatFormatting.GRAY + "Protected From: " + EnumChatFormatting.BLUE + "Starvation" - + EnumChatFormatting.GRAY + "."); - } - if (mStatlevel >= 60) { - list.add(EnumChatFormatting.GRAY + "Protected From: " + EnumChatFormatting.BLUE + "Falling" - + EnumChatFormatting.GRAY + "."); - } - if (mStatlevel >= 75) { - list.add(EnumChatFormatting.GRAY + "Protected From: " + EnumChatFormatting.BLUE + "Lava" - + EnumChatFormatting.GRAY + "."); - } - if (mStatlevel >= 80) { - list.add(EnumChatFormatting.GRAY + "Protected From: " + EnumChatFormatting.BLUE + "Magic" - + EnumChatFormatting.GRAY + "."); - } - if (mStatlevel >= 95) { - list.add(EnumChatFormatting.GRAY + "Protected From: " + EnumChatFormatting.BLUE + "Wither" - + EnumChatFormatting.GRAY + "."); - } - if (mStatlevel >= 100) { - list.add(EnumChatFormatting.GRAY + "Protected From: " + EnumChatFormatting.BLUE + "Fire" - + EnumChatFormatting.GRAY + "."); - } - if (mStatlevel >= 100) { - list.add(EnumChatFormatting.GRAY + "Protected From: " + EnumChatFormatting.BLUE + "Void" - + EnumChatFormatting.GRAY + "."); - } - - } - else { - list.add(EnumChatFormatting.GRAY + ""); - } - } - - if (NBTUtils.getBotanicaSoulboundOwner(stack) != null) { - if (!NBTUtils.getBotanicaSoulboundOwner(stack).equals("")) { - list.add(EnumChatFormatting.GRAY + "Owner: " + EnumChatFormatting.GREEN - + NBTUtils.getBotanicaSoulboundOwner(stack) + EnumChatFormatting.GRAY + "."); - } - } - super.addInformation(stack, player, list, bool); - } - - @Override - public boolean addDamageNegation(DamageSource damageSource, ItemStack aStack) { - - this.clearDamageNegation(); - int mStatlevel = 0; - if ((mStatlevel = ModularArmourUtils.getModifierLevel(aStack, Modifiers.BOOST_HOLY)) > 0) { - if (mStatlevel >= 1) { - addDamageNegation(DamageSource.cactus); - } - if (mStatlevel >= 10) { - addDamageNegation(DamageSource.fallingBlock); - } - if (mStatlevel >= 20) { - addDamageNegation(DamageSource.inWall); - } - if (mStatlevel >= 35) { - addDamageNegation(DamageSource.drown); - } - if (mStatlevel >= 50) { - addDamageNegation(DamageSource.starve); - } - if (mStatlevel >= 60) { - addDamageNegation(DamageSource.fall); - } - if (mStatlevel >= 75) { - addDamageNegation(DamageSource.lava); - } - if (mStatlevel >= 80) { - addDamageNegation(DamageSource.magic); - } - if (mStatlevel >= 95) { - addDamageNegation(DamageSource.wither); - } - if (mStatlevel >= 100) { - addDamageNegation(DamageSource.inFire); - } - if (mStatlevel >= 100) { - addDamageNegation(DamageSource.onFire); - } - if (mStatlevel >= 100) { - addDamageNegation(DamageSource.outOfWorld); - } - } - return super.addDamageNegation(damageSource, null); - } - - @Override - public boolean canEquip(ItemStack arg0, EntityLivingBase arg1) { - if (ModularArmourUtils.getBaubleTypeID(arg0) == BT.TYPE_AMULET.getID()) { - this.SetBaubleType(BT.TYPE_AMULET); - } else if (ModularArmourUtils.getBaubleTypeID(arg0) == BT.TYPE_RING.getID()) { - this.SetBaubleType(BT.TYPE_RING); - } else if (ModularArmourUtils.getBaubleTypeID(arg0) == BT.TYPE_BELT.getID()) { - this.SetBaubleType(BT.TYPE_BELT); - } else { - this.SetBaubleType(BT.TYPE_RING); - } - if (PlayerUtils.isPlayerOP((EntityPlayer) arg1)) { - return true; // Let OPs wear other peoples shit. - } - - String mOwner; - if (NBTUtils.getBotanicaSoulboundOwner(arg0) == null || NBTUtils.getBotanicaSoulboundOwner(arg0).equals("")) { - return true; - } else if ((mOwner = NBTUtils.getBotanicaSoulboundOwner(arg0)) != null) { - String mPlayerName = arg1.getCommandSenderName(); - if (mOwner.toLowerCase().equals(mPlayerName.toLowerCase())) { - return true; - } else { - return false; - } - } else { - return false; - } - } - - @Override - public BaubleType getBaubleType(ItemStack arg0) { - return ModularArmourUtils.getBaubleType(arg0); - } - - @Override - public void onEquipped(ItemStack stack, EntityLivingBase entity) { - if (entity instanceof EntityPlayer) { - if (NBTUtils.getBotanicaSoulboundOwner(stack) == null - || NBTUtils.getBotanicaSoulboundOwner(stack).equals("")) { - NBTUtils.setBotanicaSoulboundOwner(stack, entity.getCommandSenderName()); - } - } - super.onEquipped(stack, entity); - } - - /*@Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { - if (usingItem == null) { - return mfallback; - } - try { - if (stack.getItemDamage() == 0) { - return mfallback = mTextureAmulet; - } - else if (stack.getItemDamage() == 1) { - return mfallback = mTextureRing; - } - else if (stack.getItemDamage() == 2) { - return mfallback = mTextureBelt; - } else { - return mfallback = mTextureRing; - } - } catch (Throwable t) { - return mfallback = mTextureRing; - } - }*/ - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int meta) { - if (meta < this.iconArray.length && this.iconArray[meta] != null){ - return this.iconArray[meta]; - } - return this.mfallback; - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < 3; i ++) { - list.add(new ItemStack(item, 1, i)); - } - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister register) { - this.mfallback = register.registerIcon("miscutils" + ":" + "itemAmulet"); - // you cannot initialize iconArray when declared nor in the constructor, - // as it is client-side only, so do it here: - if (LoadedMods.Thaumcraft) { - iconArray[0] = register.registerIcon("thaumcraft" + ":" + "bauble_amulet"); - iconArray[1] = register.registerIcon("thaumcraft" + ":" + "bauble_ring"); - iconArray[2] = register.registerIcon("thaumcraft" + ":" + "bauble_belt"); - } else { - iconArray[0] = register.registerIcon("miscutils" + ":" + "itemAmulet"); - iconArray[1] = register.registerIcon("miscutils" + ":" + "itemRingWearable"); - iconArray[2] = register.registerIcon("miscutils" + ":" + "itemBelt"); - } - - mTextureAmulet = iconArray[0]; - mTextureRing = iconArray[1]; - mTextureBelt = iconArray[2]; - - } - - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - super.onWornTick(stack, player); - } - - @Override - public boolean showDurabilityBar(ItemStack stack) { - return false; - } - - @Override - public Item setFull3D() { - // TODO Auto-generated method stub - return super.setFull3D(); - } - - @Override - public boolean isFull3D() { - return true; - } - - @Override - public boolean isRepairable() { - return false; - } - + @SideOnly(Side.CLIENT) + private IIcon mTextureAmulet; + + @SideOnly(Side.CLIENT) + private IIcon mTextureRing; + + @SideOnly(Side.CLIENT) + private IIcon mTextureBelt; + + private IIcon iconArray[] = new IIcon[3]; + + @SideOnly(Side.CLIENT) + private IIcon mfallback; + + public ModularBauble() { + super(BaubleType.AMULET, "Modular Bauble"); + } + + @Override + void fillModifiers(Multimap attributes, ItemStack stack) { + + // Get Stats + int mStatlevel = 0; + if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_DAMAGE)) > 0) { + if (mStatlevel > 0 && mStatlevel < 20) { + attributes.put( + SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), + new AttributeModifier(getBaubleUUID(stack), "AD" + mStatlevel, 1, 0)); + } else if (mStatlevel > 20 && mStatlevel < 45) { + attributes.put( + SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), + new AttributeModifier(getBaubleUUID(stack), "AD" + mStatlevel, 2, 0)); + } else if (mStatlevel >= 45 && mStatlevel < 75) { + attributes.put( + SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), + new AttributeModifier(getBaubleUUID(stack), "AD" + mStatlevel, 4, 0)); + } else if (mStatlevel >= 75 && mStatlevel < 99) { + attributes.put( + SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), + new AttributeModifier(getBaubleUUID(stack), "AD" + mStatlevel, 8, 0)); + } else if (mStatlevel >= 100) { + attributes.put( + SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), + new AttributeModifier(getBaubleUUID(stack), "AD" + mStatlevel, 16, 0)); + } + } + if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_DEF)) > 0) { + if (mStatlevel > 0 && mStatlevel < 20) { + attributes.put( + SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), + new AttributeModifier(getBaubleUUID(stack), "BD" + mStatlevel, 1, 0)); + } else if (mStatlevel > 20 && mStatlevel < 45) { + attributes.put( + SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), + new AttributeModifier(getBaubleUUID(stack), "BD" + mStatlevel, 2, 0)); + } else if (mStatlevel > 45 && mStatlevel < 75) { + attributes.put( + SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), + new AttributeModifier(getBaubleUUID(stack), "BD" + mStatlevel, 3, 0)); + } else if (mStatlevel > 75 && mStatlevel < 99) { + attributes.put( + SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), + new AttributeModifier(getBaubleUUID(stack), "BD" + mStatlevel, 6, 0)); + } else if (mStatlevel >= 100) { + attributes.put( + SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), + new AttributeModifier(getBaubleUUID(stack), "BD" + mStatlevel, 10, 0)); + } + } + if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_HP)) > 0) { + if (mStatlevel > 0 && mStatlevel <= 100) { + int bonus = mStatlevel / 5; + attributes.put( + SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), + new AttributeModifier(getBaubleUUID(stack), "HP" + mStatlevel, bonus * 2, 0)); + } + } + if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_SPEED)) > 0) { + if (mStatlevel > 0 && mStatlevel < 20) { + attributes.put( + SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), + new AttributeModifier(getBaubleUUID(stack), "SP" + mStatlevel, 1, 0)); + } else if (mStatlevel > 20 && mStatlevel < 45) { + attributes.put( + SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), + new AttributeModifier(getBaubleUUID(stack), "SP" + mStatlevel, 2, 0)); + } else if (mStatlevel > 45 && mStatlevel < 75) { + attributes.put( + SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), + new AttributeModifier(getBaubleUUID(stack), "SP" + mStatlevel, 3, 0)); + } else if (mStatlevel > 75 && mStatlevel < 99) { + attributes.put( + SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), + new AttributeModifier(getBaubleUUID(stack), "SP" + mStatlevel, 4, 0)); + } else if (mStatlevel >= 100) { + attributes.put( + SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), + new AttributeModifier(getBaubleUUID(stack), "SP" + mStatlevel, 5, 0)); + } + } + if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_MINING)) > 0) {} + if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_HOLY)) > 0) {} + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { + // Bauble Type + if (ModularArmourUtils.getBaubleType(stack) == BaubleType.AMULET) { + list.add(EnumChatFormatting.GRAY + "Current Form: " + EnumChatFormatting.RED + "Amulet" + + EnumChatFormatting.GRAY + "."); + list.add(EnumChatFormatting.GRAY + "You can change this into a Ring or a Belt."); + } else if (ModularArmourUtils.getBaubleType(stack) == BaubleType.RING) { + list.add(EnumChatFormatting.GRAY + "Current Form: " + EnumChatFormatting.RED + "Ring" + + EnumChatFormatting.GRAY + "."); + list.add(EnumChatFormatting.GRAY + "You can change this into an Amulet or a Belt."); + } else if (ModularArmourUtils.getBaubleType(stack) == BaubleType.BELT) { + list.add(EnumChatFormatting.GRAY + "Current Form: " + EnumChatFormatting.RED + "Belt" + + EnumChatFormatting.GRAY + "."); + list.add(EnumChatFormatting.GRAY + "You can change this into a Ring or an Amulet."); + } + + // Get Stats + int mStatlevel = 0; + if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_DAMAGE)) > 0) { + list.add(EnumChatFormatting.GRAY + "Damage Boost: " + EnumChatFormatting.DARK_RED + mStatlevel + + EnumChatFormatting.GRAY + "/100."); + } + if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_HP)) > 0) { + list.add(EnumChatFormatting.GRAY + "Health Boost: " + EnumChatFormatting.RED + mStatlevel + + EnumChatFormatting.GRAY + "/100. Bonus " + (mStatlevel / 5) + " hearts."); + } + if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_SPEED)) > 0) { + list.add(EnumChatFormatting.GRAY + "Speed Boost: " + EnumChatFormatting.WHITE + mStatlevel + + EnumChatFormatting.GRAY + "/100."); + } + if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_MINING)) > 0) { + list.add(EnumChatFormatting.GRAY + "Mining Boost: " + EnumChatFormatting.DARK_GRAY + mStatlevel + + EnumChatFormatting.GRAY + "/100."); + } + if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_HOLY)) > 0) { + list.add(EnumChatFormatting.GRAY + "Holy Boost: " + EnumChatFormatting.GOLD + mStatlevel + + EnumChatFormatting.GRAY + "/100."); + } + + // Defence Boost + if ((mStatlevel = ModularArmourUtils.getModifierLevel(stack, Modifiers.BOOST_DEF)) > 0) { + list.add(EnumChatFormatting.GRAY + "Defence Boost: " + EnumChatFormatting.BLUE + mStatlevel + + EnumChatFormatting.GRAY + "/100."); + + if ((Keyboard.isKeyDown(42)) || (Keyboard.isKeyDown(54))) { + + if (mStatlevel >= 1) { + list.add(EnumChatFormatting.GRAY + "Protected From: " + EnumChatFormatting.BLUE + "Cactus" + + EnumChatFormatting.GRAY + "."); + } + if (mStatlevel >= 10) { + list.add(EnumChatFormatting.GRAY + "Protected From: " + EnumChatFormatting.BLUE + "Falling Blocks" + + EnumChatFormatting.GRAY + "."); + } + if (mStatlevel >= 20) { + list.add(EnumChatFormatting.GRAY + "Protected From: " + EnumChatFormatting.BLUE + "Wall Suffocation" + + EnumChatFormatting.GRAY + "."); + } + if (mStatlevel >= 35) { + list.add(EnumChatFormatting.GRAY + "Protected From: " + EnumChatFormatting.BLUE + "Drowning" + + EnumChatFormatting.GRAY + "."); + } + if (mStatlevel >= 50) { + list.add(EnumChatFormatting.GRAY + "Protected From: " + EnumChatFormatting.BLUE + "Starvation" + + EnumChatFormatting.GRAY + "."); + } + if (mStatlevel >= 60) { + list.add(EnumChatFormatting.GRAY + "Protected From: " + EnumChatFormatting.BLUE + "Falling" + + EnumChatFormatting.GRAY + "."); + } + if (mStatlevel >= 75) { + list.add(EnumChatFormatting.GRAY + "Protected From: " + EnumChatFormatting.BLUE + "Lava" + + EnumChatFormatting.GRAY + "."); + } + if (mStatlevel >= 80) { + list.add(EnumChatFormatting.GRAY + "Protected From: " + EnumChatFormatting.BLUE + "Magic" + + EnumChatFormatting.GRAY + "."); + } + if (mStatlevel >= 95) { + list.add(EnumChatFormatting.GRAY + "Protected From: " + EnumChatFormatting.BLUE + "Wither" + + EnumChatFormatting.GRAY + "."); + } + if (mStatlevel >= 100) { + list.add(EnumChatFormatting.GRAY + "Protected From: " + EnumChatFormatting.BLUE + "Fire" + + EnumChatFormatting.GRAY + "."); + } + if (mStatlevel >= 100) { + list.add(EnumChatFormatting.GRAY + "Protected From: " + EnumChatFormatting.BLUE + "Void" + + EnumChatFormatting.GRAY + "."); + } + + } else { + list.add(EnumChatFormatting.GRAY + ""); + } + } + + if (NBTUtils.getBotanicaSoulboundOwner(stack) != null) { + if (!NBTUtils.getBotanicaSoulboundOwner(stack).equals("")) { + list.add(EnumChatFormatting.GRAY + "Owner: " + EnumChatFormatting.GREEN + + NBTUtils.getBotanicaSoulboundOwner(stack) + EnumChatFormatting.GRAY + "."); + } + } + super.addInformation(stack, player, list, bool); + } + + @Override + public boolean addDamageNegation(DamageSource damageSource, ItemStack aStack) { + + this.clearDamageNegation(); + int mStatlevel = 0; + if ((mStatlevel = ModularArmourUtils.getModifierLevel(aStack, Modifiers.BOOST_HOLY)) > 0) { + if (mStatlevel >= 1) { + addDamageNegation(DamageSource.cactus); + } + if (mStatlevel >= 10) { + addDamageNegation(DamageSource.fallingBlock); + } + if (mStatlevel >= 20) { + addDamageNegation(DamageSource.inWall); + } + if (mStatlevel >= 35) { + addDamageNegation(DamageSource.drown); + } + if (mStatlevel >= 50) { + addDamageNegation(DamageSource.starve); + } + if (mStatlevel >= 60) { + addDamageNegation(DamageSource.fall); + } + if (mStatlevel >= 75) { + addDamageNegation(DamageSource.lava); + } + if (mStatlevel >= 80) { + addDamageNegation(DamageSource.magic); + } + if (mStatlevel >= 95) { + addDamageNegation(DamageSource.wither); + } + if (mStatlevel >= 100) { + addDamageNegation(DamageSource.inFire); + } + if (mStatlevel >= 100) { + addDamageNegation(DamageSource.onFire); + } + if (mStatlevel >= 100) { + addDamageNegation(DamageSource.outOfWorld); + } + } + return super.addDamageNegation(damageSource, null); + } + + @Override + public boolean canEquip(ItemStack arg0, EntityLivingBase arg1) { + if (ModularArmourUtils.getBaubleTypeID(arg0) == BT.TYPE_AMULET.getID()) { + this.SetBaubleType(BT.TYPE_AMULET); + } else if (ModularArmourUtils.getBaubleTypeID(arg0) == BT.TYPE_RING.getID()) { + this.SetBaubleType(BT.TYPE_RING); + } else if (ModularArmourUtils.getBaubleTypeID(arg0) == BT.TYPE_BELT.getID()) { + this.SetBaubleType(BT.TYPE_BELT); + } else { + this.SetBaubleType(BT.TYPE_RING); + } + if (PlayerUtils.isPlayerOP((EntityPlayer) arg1)) { + return true; // Let OPs wear other peoples shit. + } + + String mOwner; + if (NBTUtils.getBotanicaSoulboundOwner(arg0) == null + || NBTUtils.getBotanicaSoulboundOwner(arg0).equals("")) { + return true; + } else if ((mOwner = NBTUtils.getBotanicaSoulboundOwner(arg0)) != null) { + String mPlayerName = arg1.getCommandSenderName(); + if (mOwner.toLowerCase().equals(mPlayerName.toLowerCase())) { + return true; + } else { + return false; + } + } else { + return false; + } + } + + @Override + public BaubleType getBaubleType(ItemStack arg0) { + return ModularArmourUtils.getBaubleType(arg0); + } + + @Override + public void onEquipped(ItemStack stack, EntityLivingBase entity) { + if (entity instanceof EntityPlayer) { + if (NBTUtils.getBotanicaSoulboundOwner(stack) == null + || NBTUtils.getBotanicaSoulboundOwner(stack).equals("")) { + NBTUtils.setBotanicaSoulboundOwner(stack, entity.getCommandSenderName()); + } + } + super.onEquipped(stack, entity); + } + + /*@Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { + if (usingItem == null) { + return mfallback; + } + try { + if (stack.getItemDamage() == 0) { + return mfallback = mTextureAmulet; + } + else if (stack.getItemDamage() == 1) { + return mfallback = mTextureRing; + } + else if (stack.getItemDamage() == 2) { + return mfallback = mTextureBelt; + } else { + return mfallback = mTextureRing; + } + } catch (Throwable t) { + return mfallback = mTextureRing; + } + }*/ + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int meta) { + if (meta < this.iconArray.length && this.iconArray[meta] != null) { + return this.iconArray[meta]; + } + return this.mfallback; + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 3; i++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister register) { + this.mfallback = register.registerIcon("miscutils" + ":" + "itemAmulet"); + // you cannot initialize iconArray when declared nor in the constructor, + // as it is client-side only, so do it here: + if (LoadedMods.Thaumcraft) { + iconArray[0] = register.registerIcon("thaumcraft" + ":" + "bauble_amulet"); + iconArray[1] = register.registerIcon("thaumcraft" + ":" + "bauble_ring"); + iconArray[2] = register.registerIcon("thaumcraft" + ":" + "bauble_belt"); + } else { + iconArray[0] = register.registerIcon("miscutils" + ":" + "itemAmulet"); + iconArray[1] = register.registerIcon("miscutils" + ":" + "itemRingWearable"); + iconArray[2] = register.registerIcon("miscutils" + ":" + "itemBelt"); + } + + mTextureAmulet = iconArray[0]; + mTextureRing = iconArray[1]; + mTextureBelt = iconArray[2]; + } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + super.onWornTick(stack, player); + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } + + @Override + public Item setFull3D() { + // TODO Auto-generated method stub + return super.setFull3D(); + } + + @Override + public boolean isFull3D() { + return true; + } + + @Override + public boolean isRepairable() { + return false; + } } diff --git a/src/main/java/gtPlusPlus/core/item/bauble/MonsterKillerBaseBauble.java b/src/main/java/gtPlusPlus/core/item/bauble/MonsterKillerBaseBauble.java index aab302688b..5164ab5c19 100644 --- a/src/main/java/gtPlusPlus/core/item/bauble/MonsterKillerBaseBauble.java +++ b/src/main/java/gtPlusPlus/core/item/bauble/MonsterKillerBaseBauble.java @@ -1,18 +1,16 @@ package gtPlusPlus.core.item.bauble; -import java.util.List; - import baubles.api.BaubleType; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.GT_Values; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.AABB; -import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.EntityUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; import ic2.api.item.ElectricItem; +import java.util.List; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; @@ -26,150 +24,152 @@ import net.minecraft.world.World; public class MonsterKillerBaseBauble extends ElectricBaseBauble { - private final Class[] mTargets; - - public MonsterKillerBaseBauble(Class[] aMonsterBaseClassArray, String aMonsterTypeName, int aPowerTier) { - super(BaubleType.AMULET, aPowerTier, GT_Values.V[aPowerTier] * 20 * 300, - "GTPP.MonsterKiller." + aMonsterTypeName + ".name"); - mTargets = aMonsterBaseClassArray; - } - - @SideOnly(Side.CLIENT) - @Override - public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { - ItemStack itemStack = new ItemStack(this, 1); - ItemStack charged; - if (this.getEmptyItem(itemStack) == this) { - charged = new ItemStack(this, 1); - ElectricItem.manager.charge(charged, 0.0D, Integer.MAX_VALUE, true, false); - itemList.add(charged); - } - if (this.getChargedItem(itemStack) == this) { - charged = new ItemStack(this, 1); - ElectricItem.manager.charge(charged, Double.POSITIVE_INFINITY, Integer.MAX_VALUE, true, false); - itemList.add(charged); - } - - } - - @Override - public void onUpdate(final ItemStack itemStack, final World worldObj, final Entity player, final int p_77663_4_, - final boolean p_77663_5_) { - super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); - } - - @Override - public boolean canProvideEnergy(final ItemStack itemStack) { - double aItemCharge = ElectricItem.manager.getCharge(itemStack); - return aItemCharge > 0; - } - - @Override - public String getItemStackDisplayName(final ItemStack p_77653_1_) { - return (EnumChatFormatting.WHITE + super.getItemStackDisplayName(p_77653_1_) + EnumChatFormatting.GRAY); - } - - @Override - public boolean showDurabilityBar(final ItemStack stack) { - return true; - } - - @SuppressWarnings("unchecked") - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - list.add(""); - String aString1 = StatCollector.translateToLocal("GTPP.monsterkiller.tooltip.1"); - String aString2 = StatCollector.translateToLocal("GTPP.monsterkiller.tooltip.2"); - String aString3 = StatCollector.translateToLocal("GTPP.monsterkiller.tooltip.3"); - String aString4 = StatCollector.translateToLocal("GTPP.monsterkiller.tooltip.4"); - String aEU = StatCollector.translateToLocal("GTPP.info.eu"); - String aEUT = aEU + "/t"; - - list.add(EnumChatFormatting.GREEN + aString1 + EnumChatFormatting.GRAY); - list.add(EnumChatFormatting.GREEN + aString2 + " " + (int) getTransferLimit(stack) + aEUT + " " + aString3 - + EnumChatFormatting.GRAY); - list.add(""); - list.add("" + EnumChatFormatting.GREEN + aString4 + " " + EnumChatFormatting.GRAY); - for (Class cz : mTargets) { - list.add("- " + EnumChatFormatting.DARK_GREEN + cz.getSimpleName().replace("Entity", "") + EnumChatFormatting.GRAY); - } - - super.addInformation(stack, aPlayer, list, bool); - } - - @Override - public boolean canEquip(final ItemStack arg0, final EntityLivingBase arg1) { - return true; - } - - @Override - public boolean canUnequip(final ItemStack arg0, final EntityLivingBase arg1) { - return true; - } - - @Override - public void onEquipped(final ItemStack arg0, final EntityLivingBase arg1) { - - } - - @Override - public void onUnequipped(final ItemStack arg0, final EntityLivingBase arg1) { - - } - - @Override // TODO - public void onWornTick(final ItemStack aBaubleStack, final EntityLivingBase aPlayerEntity) { - if (aPlayerEntity == null) { - return; - } - EntityPlayer aPlayer = (EntityPlayer) aPlayerEntity; - if (!aPlayer.worldObj.isRemote) { - if (this.getCharge(aBaubleStack) >= getTransferLimit(aBaubleStack)) { - AABB aPlayerBox = new AABB(aPlayerEntity, 5, 5, 5); - if (this.mTargets != null && this.mTargets.length > 0) { - for (Class clazz : mTargets) { - AutoMap aEnts = EntityUtils.getEntitiesWithinBoundingBox(clazz, aPlayerBox); - if (aEnts.isEmpty()) { - continue; - } else { - EntityLiving aClosest = null; - double aEntityDistance = Short.MIN_VALUE; - for (Object ent : aEnts) { - if (!EntityLiving.class.isInstance(ent)) { - continue; - } else { - double aCurEntDis = EntityUtils.getDistance(aPlayerEntity, (Entity) ent); - if (aEntityDistance == Short.MIN_VALUE || aCurEntDis < aEntityDistance) { - aEntityDistance = aCurEntDis; - aClosest = (EntityLiving) ent; - } - } - } - if (aClosest != null) { - float aEntHealth = aClosest.getHealth(); - float aEntMaxHealth = aClosest.getMaxHealth(); - double aEntHealthPerc = MathUtils.findPercentage(aEntHealth, aEntMaxHealth); - long aEuUsage = (long) (aEntHealthPerc * 50 * aEntMaxHealth); - if (this.discharge(aBaubleStack, aEuUsage, mTier, true, false, false) > 0) { - aClosest.setDead(); - PlayerUtils.messagePlayer(aPlayer, "Removed 1x "+aClosest.getCommandSenderName()); - break; - } - } else { - continue; - } - } - } - } - } else { - return; - } - } - } - - @Override - public String getTextureNameForBauble() { - return "baubles/itemAmulet"; - } - + private final Class[] mTargets; + + public MonsterKillerBaseBauble(Class[] aMonsterBaseClassArray, String aMonsterTypeName, int aPowerTier) { + super( + BaubleType.AMULET, + aPowerTier, + GT_Values.V[aPowerTier] * 20 * 300, + "GTPP.MonsterKiller." + aMonsterTypeName + ".name"); + mTargets = aMonsterBaseClassArray; + } + + @SideOnly(Side.CLIENT) + @Override + public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { + ItemStack itemStack = new ItemStack(this, 1); + ItemStack charged; + if (this.getEmptyItem(itemStack) == this) { + charged = new ItemStack(this, 1); + ElectricItem.manager.charge(charged, 0.0D, Integer.MAX_VALUE, true, false); + itemList.add(charged); + } + if (this.getChargedItem(itemStack) == this) { + charged = new ItemStack(this, 1); + ElectricItem.manager.charge(charged, Double.POSITIVE_INFINITY, Integer.MAX_VALUE, true, false); + itemList.add(charged); + } + } + + @Override + public void onUpdate( + final ItemStack itemStack, + final World worldObj, + final Entity player, + final int p_77663_4_, + final boolean p_77663_5_) { + super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); + } + + @Override + public boolean canProvideEnergy(final ItemStack itemStack) { + double aItemCharge = ElectricItem.manager.getCharge(itemStack); + return aItemCharge > 0; + } + + @Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + return (EnumChatFormatting.WHITE + super.getItemStackDisplayName(p_77653_1_) + EnumChatFormatting.GRAY); + } + + @Override + public boolean showDurabilityBar(final ItemStack stack) { + return true; + } + + @SuppressWarnings("unchecked") + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add(""); + String aString1 = StatCollector.translateToLocal("GTPP.monsterkiller.tooltip.1"); + String aString2 = StatCollector.translateToLocal("GTPP.monsterkiller.tooltip.2"); + String aString3 = StatCollector.translateToLocal("GTPP.monsterkiller.tooltip.3"); + String aString4 = StatCollector.translateToLocal("GTPP.monsterkiller.tooltip.4"); + String aEU = StatCollector.translateToLocal("GTPP.info.eu"); + String aEUT = aEU + "/t"; + + list.add(EnumChatFormatting.GREEN + aString1 + EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GREEN + aString2 + " " + (int) getTransferLimit(stack) + aEUT + " " + aString3 + + EnumChatFormatting.GRAY); + list.add(""); + list.add("" + EnumChatFormatting.GREEN + aString4 + " " + EnumChatFormatting.GRAY); + for (Class cz : mTargets) { + list.add("- " + EnumChatFormatting.DARK_GREEN + cz.getSimpleName().replace("Entity", "") + + EnumChatFormatting.GRAY); + } + + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public boolean canEquip(final ItemStack arg0, final EntityLivingBase arg1) { + return true; + } + + @Override + public boolean canUnequip(final ItemStack arg0, final EntityLivingBase arg1) { + return true; + } + + @Override + public void onEquipped(final ItemStack arg0, final EntityLivingBase arg1) {} + + @Override + public void onUnequipped(final ItemStack arg0, final EntityLivingBase arg1) {} + + @Override // TODO + public void onWornTick(final ItemStack aBaubleStack, final EntityLivingBase aPlayerEntity) { + if (aPlayerEntity == null) { + return; + } + EntityPlayer aPlayer = (EntityPlayer) aPlayerEntity; + if (!aPlayer.worldObj.isRemote) { + if (this.getCharge(aBaubleStack) >= getTransferLimit(aBaubleStack)) { + AABB aPlayerBox = new AABB(aPlayerEntity, 5, 5, 5); + if (this.mTargets != null && this.mTargets.length > 0) { + for (Class clazz : mTargets) { + AutoMap aEnts = EntityUtils.getEntitiesWithinBoundingBox(clazz, aPlayerBox); + if (aEnts.isEmpty()) { + continue; + } else { + EntityLiving aClosest = null; + double aEntityDistance = Short.MIN_VALUE; + for (Object ent : aEnts) { + if (!EntityLiving.class.isInstance(ent)) { + continue; + } else { + double aCurEntDis = EntityUtils.getDistance(aPlayerEntity, (Entity) ent); + if (aEntityDistance == Short.MIN_VALUE || aCurEntDis < aEntityDistance) { + aEntityDistance = aCurEntDis; + aClosest = (EntityLiving) ent; + } + } + } + if (aClosest != null) { + float aEntHealth = aClosest.getHealth(); + float aEntMaxHealth = aClosest.getMaxHealth(); + double aEntHealthPerc = MathUtils.findPercentage(aEntHealth, aEntMaxHealth); + long aEuUsage = (long) (aEntHealthPerc * 50 * aEntMaxHealth); + if (this.discharge(aBaubleStack, aEuUsage, mTier, true, false, false) > 0) { + aClosest.setDead(); + PlayerUtils.messagePlayer(aPlayer, "Removed 1x " + aClosest.getCommandSenderName()); + break; + } + } else { + continue; + } + } + } + } + } else { + return; + } + } + } + + @Override + public String getTextureNameForBauble() { + return "baubles/itemAmulet"; + } } diff --git a/src/main/java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java b/src/main/java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java index 8e7a760195..84e02d452f 100644 --- a/src/main/java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java +++ b/src/main/java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java @@ -1,9 +1,5 @@ package gtPlusPlus.core.item.chemistry; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.List; - import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; import gtPlusPlus.api.helpers.MaterialHelper; @@ -23,6 +19,9 @@ import gtPlusPlus.plugin.agrichem.item.algae.ItemAgrichemBase; import gtPlusPlus.plugin.agrichem.item.algae.ItemAlgaeBase; import gtPlusPlus.plugin.agrichem.item.algae.ItemBioChip; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -32,583 +31,614 @@ import net.minecraftforge.oredict.OreDictionary; public class AgriculturalChem extends ItemPackage { - private static boolean aBOP; - private static boolean aTiCon; - - private static AutoMap mBloodFluids = new AutoMap(); - - /** - * Fluids - */ - - // Poop Juice - public static Fluid PoopJuice; - // Manure Slurry - public static Fluid ManureSlurry; - // Fertile Manure Slurry - public static Fluid FertileManureSlurry; - // Blood - public static Fluid CustomBlood; - // Red Mud - public static Fluid RedMud; - /** - * Items - */ - - // Manure Byproducts - public static Item dustManureByproducts; - // Organic Fertilizer - public static Item dustOrganicFertilizer; - // Dirt - public static Item dustDirt; - - // Poop Juice - // vv - Centrifuge - // Manure Slurry && Manure Byproducts -> (Elements) Centrifuge to several tiny - // piles - // vv - Chem Reactor - Add Peat, Meat - // Organic Fertilizer - // vv - Dehydrate - // Fertilizer - - // Poop Juice - // vv - Mixer - Add Blood, Bone, Meat (1000L Poo, 200L Blood, x2 Bone, x3 Meat) - // Fertile Manure Slurry - // vv - Chem Reactor - Add Peat x1.5 - // Organic Fertilizer x3 - // vv - Dehydrate - // Fertilizer - - - - public static Item mAlgae; - public static Item mBioCircuit; - public static Item mAgrichemItem1; - - /* - * 0 - Algae Biomass - * 1 - Green Algae Biomass - * 2 - Brown Algae Biomass - * 3 - Golden-Brown Algae Biomass - * 4 - Red Algae Biomass - * 5 - Cellulose Fiber - * 6 - Golden-Brown Cellulose Fiber - * 7 - Red Cellulose Fiber - * 8 - Compost - * 9 - Wood Pellet - * 10 - Wood Brick - * 11 - Cellulose Pulp - * 12 - Raw Bio Resin - * 13 - Catalyst Carrier - * 14 - Green Metal Catalyst - * 15 - Alginic Acid - * 16 - Alumina - * 17 - Aluminium Pellet - * 18 - Sodium Aluminate - * 19 - Sodium Hydroxide // Exists in Newer GT - * 20 - Sodium Carbonate - * 21 - Lithium Chloride - * 22 - Pellet Mold - * 23 - Clean Aluminium Mix - * 24 - Pinecone - */ - - public static ItemStack mAlgaeBiosmass; - public static ItemStack mGreenAlgaeBiosmass; - public static ItemStack mBrownAlgaeBiosmass; - public static ItemStack mGoldenBrownAlgaeBiosmass; - public static ItemStack mRedAlgaeBiosmass; - public static ItemStack mCelluloseFiber; - public static ItemStack mGoldenBrownCelluloseFiber; - public static ItemStack mRedCelluloseFiber; - public static ItemStack mCompost; - public static ItemStack mWoodPellet; - public static ItemStack mWoodBrick; - public static ItemStack mCellulosePulp; - public static ItemStack mRawBioResin; - public static ItemStack mCatalystCarrier; - public static ItemStack mGreenCatalyst; - public static ItemStack mAlginicAcid; - public static ItemStack mAlumina; - public static ItemStack mAluminiumPellet; - public static ItemStack mSodiumAluminate; - public static ItemStack mSodiumHydroxide; - public static ItemStack mSodiumCarbonate; - public static ItemStack mLithiumChloride; - public static ItemStack mPelletMold; - public static ItemStack mCleanAluminiumMix; - public static ItemStack mPinecone; - public static ItemStack mCrushedPine; - - - @Override - public void items() { - // Nitrogen, Ammonium Nitrate, Phosphates, Calcium, Copper, Carbon - dustManureByproducts = ItemUtils.generateSpecialUseDusts("ManureByproducts", "Manure Byproduct", - "(N2H4O3)N2P2Ca3CuC8", Utils.rgbtoHexValue(110, 75, 25))[0]; - - // Basically Guano - dustOrganicFertilizer = ItemUtils.generateSpecialUseDusts("OrganicFertilizer", "Organic Fertilizer", - "Ca5(PO4)3(OH)", Utils.rgbtoHexValue(240, 240, 240))[0]; - - // Dirt Dust :) - dustDirt = ItemUtils.generateSpecialUseDusts("Dirt", "Dried Earth", Utils.rgbtoHexValue(65, 50, 15))[0]; - - mAlgae = new ItemAlgaeBase(); - mAgrichemItem1 = new ItemAgrichemBase(); - mBioCircuit = new ItemBioChip(); - GregtechItemList.Circuit_BioRecipeSelector.set(mBioCircuit); - - - - mAlgaeBiosmass = ItemUtils.simpleMetaStack(mAgrichemItem1, 0, 1); - mGreenAlgaeBiosmass = ItemUtils.simpleMetaStack(mAgrichemItem1, 1, 1); - mBrownAlgaeBiosmass = ItemUtils.simpleMetaStack(mAgrichemItem1, 2, 1); - mGoldenBrownAlgaeBiosmass = ItemUtils.simpleMetaStack(mAgrichemItem1, 3, 1); - mRedAlgaeBiosmass = ItemUtils.simpleMetaStack(mAgrichemItem1, 4, 1); - mCelluloseFiber = ItemUtils.simpleMetaStack(mAgrichemItem1, 5, 1); - mGoldenBrownCelluloseFiber = ItemUtils.simpleMetaStack(mAgrichemItem1, 6, 1); - mRedCelluloseFiber = ItemUtils.simpleMetaStack(mAgrichemItem1, 7, 1); - mCompost = ItemUtils.simpleMetaStack(mAgrichemItem1, 8, 1); - mWoodPellet = ItemUtils.simpleMetaStack(mAgrichemItem1, 9, 1); - mWoodBrick = ItemUtils.simpleMetaStack(mAgrichemItem1, 10, 1); - mCellulosePulp = ItemUtils.simpleMetaStack(mAgrichemItem1, 11, 1); - mRawBioResin = ItemUtils.simpleMetaStack(mAgrichemItem1, 12, 1); - mCatalystCarrier = ItemUtils.simpleMetaStack(mAgrichemItem1, 13, 1); - mGreenCatalyst = ItemUtils.simpleMetaStack(mAgrichemItem1, 14, 1); - mAlginicAcid = ItemUtils.simpleMetaStack(mAgrichemItem1, 15, 1); - mAlumina = ItemUtils.simpleMetaStack(mAgrichemItem1, 16, 1); - mAluminiumPellet = ItemUtils.simpleMetaStack(mAgrichemItem1, 17, 1); - mSodiumAluminate = ItemUtils.simpleMetaStack(mAgrichemItem1, 18, 1); - - /** - * If It exists, don't add a new one. - */ - if (OreDictionary.doesOreNameExist("dustSodiumHydroxide_GT5U") || OreDictionary.doesOreNameExist("dustSodiumHydroxide")) { - List aTest = OreDictionary.getOres("dustSodiumHydroxide", false); - ItemStack aTestStack; - if (aTest.isEmpty()) { - aTest = OreDictionary.getOres("dustSodiumHydroxide_GT5U", false); - if (aTest.isEmpty()) { - aTestStack = ItemUtils.simpleMetaStack(mAgrichemItem1, 19, 1); - } - else { - aTestStack = aTest.get(0); - } - } - else { - aTestStack = aTest.get(0); - } - mSodiumHydroxide = aTestStack; - } - else { - mSodiumHydroxide = ItemUtils.simpleMetaStack(mAgrichemItem1, 19, 1); - } - mSodiumCarbonate = ItemUtils.simpleMetaStack(mAgrichemItem1, 20, 1); - mLithiumChloride = ItemUtils.simpleMetaStack(mAgrichemItem1, 21, 1); - mPelletMold = ItemUtils.simpleMetaStack(mAgrichemItem1, 22, 1); - mCleanAluminiumMix = ItemUtils.simpleMetaStack(mAgrichemItem1, 23, 1); - mPinecone = ItemUtils.simpleMetaStack(mAgrichemItem1, 24, 1); - mCrushedPine = ItemUtils.simpleMetaStack(mAgrichemItem1, 25, 1); - - ItemUtils.addItemToOreDictionary(mGreenAlgaeBiosmass, "biomassGreenAlgae"); - ItemUtils.addItemToOreDictionary(mBrownAlgaeBiosmass, "biomassBrownAlgae"); - ItemUtils.addItemToOreDictionary(mGoldenBrownAlgaeBiosmass, "biomassGoldenBrownAlgae"); - ItemUtils.addItemToOreDictionary(mRedAlgaeBiosmass, "biomassRedAlgae"); - - ItemUtils.addItemToOreDictionary(mCelluloseFiber, "fiberCellulose"); - ItemUtils.addItemToOreDictionary(mGoldenBrownCelluloseFiber, "fiberCellulose"); - ItemUtils.addItemToOreDictionary(mGoldenBrownCelluloseFiber, "fiberGoldenBrownCellulose"); - ItemUtils.addItemToOreDictionary(mRedCelluloseFiber, "fiberCellulose"); - ItemUtils.addItemToOreDictionary(mRedCelluloseFiber, "fiberRedCellulose"); - - ItemUtils.addItemToOreDictionary(mWoodPellet, "pelletWood"); - ItemUtils.addItemToOreDictionary(mWoodBrick, "brickWood"); - ItemUtils.addItemToOreDictionary(mCellulosePulp, "pulpCellulose"); - - ItemUtils.addItemToOreDictionary(mCatalystCarrier, "catalystEmpty"); - ItemUtils.addItemToOreDictionary(mGreenCatalyst, "catalystAluminiumSilver"); - ItemUtils.addItemToOreDictionary(mAlginicAcid, "dustAlginicAcid"); - ItemUtils.addItemToOreDictionary(mAlumina, "dustAlumina"); - ItemUtils.addItemToOreDictionary(mAluminiumPellet, "pelletAluminium"); - - ItemUtils.addItemToOreDictionary(mSodiumAluminate, "dustSodiumAluminate"); - ItemUtils.addItemToOreDictionary(mSodiumHydroxide, "dustSodiumHydroxide"); - ItemUtils.addItemToOreDictionary(mSodiumCarbonate, "dustSodiumCarbonate"); - ItemUtils.addItemToOreDictionary(mLithiumChloride, "dustLithiumChloride"); - ItemUtils.addItemToOreDictionary(mPinecone, "pinecone"); - ItemUtils.addItemToOreDictionary(mCrushedPine, "crushedPineMaterial"); - - //Handle GT NaOH dusts - List NaOHSmall = OreDictionary.getOres("dustSmallSodiumHydroxide_GT5U", false); - if (!NaOHSmall.isEmpty()) { - ItemUtils.addItemToOreDictionary(NaOHSmall.get(0), "dustSmallSodiumHydroxide"); - } - List NaOHTiny = OreDictionary.getOres("dustTinySodiumHydroxide_GT5U", false); - if (!NaOHTiny.isEmpty()) { - ItemUtils.addItemToOreDictionary(NaOHTiny.get(0), "dustTinySodiumHydroxide"); - } - - - } - - @Override - public void blocks() { - // None yet - } - - @Override - public void fluids() { - // Sewage - PoopJuice = FluidUtils.generateFluidNonMolten("raw.waste", "Raw Animal Waste", 32 + 175, - new short[] { 100, 70, 30, 100 }, null, null, 0, true); - - // Sewage - ManureSlurry = FluidUtils.generateFluidNonMolten("manure.slurry", "Manure Slurry", 39 + 175, - new short[] { 75, 45, 15, 100 }, null, null, 0, true); - - // Sewage - FertileManureSlurry = FluidUtils.generateFluidNonMolten("fertile.manure.slurry", "Fertile Manure Slurry", - 45 + 175, new short[] { 65, 50, 15, 100 }, null, null, 0, true); - - RedMud = FluidUtils.generateFluidNoPrefix("mud.red.slurry", "Red Mud Slurry", 32 + 175, new short[] { 180, 35, 25, 100 }, true); - - } - - - - public AgriculturalChem() { - super(); - - aBOP = LoadedMods.BiomesOPlenty; - aTiCon = LoadedMods.TiCon; - - Logger.INFO("Adding Agrochemical content"); - - FluidStack aBlood; - if (aBOP) { - aBlood = FluidUtils.getFluidStack("hell_blood", 100); - if (aBlood != null) { - Logger.INFO("Found Biome's o Plenty, enabled Blood support."); - CustomBlood = aBlood.getFluid(); - mBloodFluids.put(aBlood); - } - } - - if (aTiCon) { - aBlood = FluidUtils.getFluidStack("blood", 100); - if (aBlood != null) { - Logger.INFO("Found Tinker's Construct, enabled Blood support."); - CustomBlood = aBlood.getFluid(); - mBloodFluids.put(FluidUtils.getFluidStack("blood", 100)); - } - } - - // Handle Blood Internally, Create if required. - if (mBloodFluids.isEmpty() || CustomBlood == null) { - Logger.INFO( - "Did not find any existing Blood fluids. Trying to wildcard search the fluid registry, then generate our own if that fails."); - FluidStack aTempBlood = FluidUtils.getWildcardFluidStack("blood", 100); - if (aTempBlood != null) { - CustomBlood = aTempBlood.getFluid(); - } else { - aTempBlood = FluidUtils.getWildcardFluidStack("hell_blood", 100); - if (aTempBlood == null) { - CustomBlood = FluidUtils.generateFluidNoPrefix("blood", "Blood", 32 + 175, - new short[] { 175, 25, 25, 100 }, true); - } else { - CustomBlood = aTempBlood.getFluid(); - } - } - Logger.INFO("Using " + CustomBlood.getName()); - mBloodFluids.put(FluidUtils.getFluidStack(CustomBlood, 100)); - } - - } - - private final static AutoMap mMeats = new AutoMap(); - private final static AutoMap mFish = new AutoMap(); - private final static AutoMap mFruits = new AutoMap(); - private final static AutoMap mVege = new AutoMap(); - private final static AutoMap mNuts = new AutoMap(); - private final static AutoMap mSeeds = new AutoMap(); - private final static AutoMap mPeat = new AutoMap(); - private final static AutoMap mBones = new AutoMap(); - private final static AutoMap mBoneMeal = new AutoMap(); - - private final static AutoMap mList_Master_Meats = new AutoMap(); - private final static AutoMap mList_Master_FruitVege = new AutoMap(); - private final static AutoMap mList_Master_Seeds = new AutoMap(); - private final static AutoMap mList_Master_Bones = new AutoMap(); - - private static void processAllOreDict() { - processOreDict("listAllmeatraw", mMeats); - processOreDict("listAllfishraw", mFish); - processOreDict("listAllfruit", mFruits); - processOreDict("listAllVeggie", mVege); - processOreDict("listAllnut", mNuts); - processOreDict("listAllSeed", mSeeds); - processOreDict("brickPeat", mPeat); - processOreDict("bone", mBones); - processOreDict("dustBone", mBoneMeal); - // Just make a mega list, makes life easier. - if (!mMeats.isEmpty()) { - for (ItemStack g : mMeats) { - mList_Master_Meats.put(g); - } - } - if (!mFish.isEmpty()) { - for (ItemStack g : mFish) { - mList_Master_Meats.put(g); - } - } - if (!mFruits.isEmpty()) { - for (ItemStack g : mFruits) { - mList_Master_FruitVege.put(g); - } - } - if (!mVege.isEmpty()) { - for (ItemStack g : mVege) { - mList_Master_FruitVege.put(g); - } - } - if (!mNuts.isEmpty()) { - for (ItemStack g : mNuts) { - mList_Master_FruitVege.put(g); - } - } - if (!mSeeds.isEmpty()) { - for (ItemStack g : mSeeds) { - mList_Master_Seeds.put(g); - } - } - if (!mBoneMeal.isEmpty()) { - for (ItemStack g : mBoneMeal) { - mList_Master_Bones.put(g); - } - } - if (!mBones.isEmpty()) { - for (ItemStack g : mBones) { - mList_Master_Bones.put(g); - } - } - } - - private static void processOreDict(String aOreName, AutoMap aMap) { - ArrayList aTemp = OreDictionary.getOres(aOreName); - if (!aTemp.isEmpty()) { - for (ItemStack stack : aTemp) { - aMap.put(stack); - } - } - } - - private static void addBasicSlurryRecipes() { - - ItemStack aManureByprod1 = ItemUtils.getItemStackOfAmountFromOreDict("dustTinyManureByproducts", 1); - ItemStack aManureByprod2 = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallManureByproducts", 1); - ItemStack aDirtDust = ItemUtils.getSimpleStack(dustDirt, 1); - - // Poop Juice to Basic Slurry - GT_Values.RA.addCentrifugeRecipe(CI.getNumberedCircuit(10), null, FluidUtils.getFluidStack(PoopJuice, 1000), // In - // Fluid - FluidUtils.getFluidStack(ManureSlurry, 250), // Out Fluid - aDirtDust, aDirtDust, aManureByprod1, aManureByprod1, aManureByprod1, aManureByprod1, - new int[] { 2000, 2000, 500, 500, 250, 250 }, // Chances - 10 * 20, // Time - 30); // EU - - // More Efficient way to get byproducts, less Slurry - GT_Values.RA.addCentrifugeRecipe(CI.getNumberedCircuit(20), null, FluidUtils.getFluidStack(PoopJuice, 1000), // In - // Fluid - FluidUtils.getFluidStack(ManureSlurry, 50), // Out Fluid - aDirtDust, aDirtDust, aManureByprod1, aManureByprod1, aManureByprod2, aManureByprod2, - new int[] { 4000, 3000, 1250, 1250, 675, 675 }, // Chances - 20 * 20, // Time - 60); // EU - - } - - private static void addAdvancedSlurryRecipes() { - - ItemStack aCircuit = CI.getNumberedCircuit(10); - ItemStack aBone; - ItemStack aMeat; - ItemStack aEmptyCells = CI.emptyCells(2); - ItemStack aInputCells = ItemUtils.getItemStackOfAmountFromOreDict("cellRawAnimalWaste", 2); - FluidStack aOutput = FluidUtils.getFluidStack(FertileManureSlurry, 1000); - - for (FluidStack aBloodStack : mBloodFluids) { - for (ItemStack aBoneStack : mList_Master_Bones) { - aBone = ItemUtils.getSimpleStack(aBoneStack, 2); - for (ItemStack aMeatStack : mList_Master_Meats) { - aMeat = ItemUtils.getSimpleStack(aMeatStack, 5); - // Poop Juice to Fertile Slurry - GT_Values.RA.addMixerRecipe(aCircuit, aBone, aMeat, aInputCells, aBloodStack, // Input Fluid - aOutput, // Output Fluid - aEmptyCells, // Output Item - 20 * 8, // Time? - 60 // Eu? - ); - } - } - } - } - - private static void addBasicOrganiseFertRecipes() { - FluidStack aInputFluid = FluidUtils.getFluidStack(ManureSlurry, 1000); - ItemStack aOutputDust = ItemUtils.getSimpleStack(dustOrganicFertilizer, 3); - ItemStack aPeat; - ItemStack aMeat; - for (ItemStack aPeatStack : mPeat) { - aPeat = ItemUtils.getSimpleStack(aPeatStack, 3); - for (ItemStack aMeatStack : mList_Master_Meats) { - aMeat = ItemUtils.getSimpleStack(aMeatStack, 5); - CORE.RA.addChemicalRecipe(aPeat, aMeat, aInputFluid, null, aOutputDust, 20 * 20, 120); - } - - aPeat = ItemUtils.getSimpleStack(aPeatStack, 2); - for (ItemStack aMeatStack : mList_Master_FruitVege) { - aMeat = ItemUtils.getSimpleStack(aMeatStack, 9); - CORE.RA.addChemicalRecipe(aPeat, aMeat, aInputFluid, null, aOutputDust, 10 * 20, 120); - } - } - } - - private static void addAdvancedOrganiseFertRecipes() { - FluidStack aInputFluid = FluidUtils.getFluidStack(FertileManureSlurry, 1000); - ItemStack aOutputDust = ItemUtils.getSimpleStack(dustOrganicFertilizer, 7); - ItemStack aPeat; - ItemStack aMeat; - for (ItemStack aPeatStack : mPeat) { - aPeat = ItemUtils.getSimpleStack(aPeatStack, 5); - for (ItemStack aMeatStack : mList_Master_Meats) { - aMeat = ItemUtils.getSimpleStack(aMeatStack, 7); - CORE.RA.addChemicalRecipe(aPeat, aMeat, aInputFluid, null, aOutputDust, 10 * 20, 140); - } - aPeat = ItemUtils.getSimpleStack(aPeatStack, 3); - for (ItemStack aMeatStack : mList_Master_FruitVege) { - aMeat = ItemUtils.getSimpleStack(aMeatStack, 12); - CORE.RA.addChemicalRecipe(aPeat, aMeat, aInputFluid, null, aOutputDust, 5 * 20, 140); - } - } - } - - public static ItemStack aFertForestry; - public static ItemStack aFertIC2; - - - private static void addMiscRecipes() { - - ItemStack aDustOrganicFert = ItemUtils.getSimpleStack(dustOrganicFertilizer, 1); - ItemStack aManureByprod = ItemUtils.getSimpleStack(dustManureByproducts, 1); - - // Dehydrate Organise Fert to Normal Fert. - - /** - * Forestry Support - */ - if (LoadedMods.Forestry) { - Field aItemField = ReflectionUtils.getField(ReflectionUtils.getClass("forestry.plugins.PluginCore"), "items"); - try { - Object aItemRegInstance = aItemField != null ? aItemField.get(aItemField) : null; - if (aItemRegInstance != null) { - Field aFertField = ReflectionUtils.getField(aItemRegInstance.getClass(), "fertilizerCompound"); - Object aItemInstance = aFertField.get(aItemRegInstance); - if (aItemInstance instanceof Item) { - aFertForestry = ItemUtils.getSimpleStack((Item) aItemInstance); - Item aForestryFert = (Item) aItemInstance; - CORE.RA.addDehydratorRecipe( - new ItemStack[] { CI.getNumberedCircuit(11), ItemUtils.getSimpleStack(aDustOrganicFert, 4) }, null, - null, new ItemStack[] { ItemUtils.getSimpleStack(aForestryFert, 3), aManureByprod, aManureByprod }, - new int[] { 10000, 2000, 2000 }, 20 * 20, 240); - } - } - } - catch (IllegalArgumentException | IllegalAccessException e) { - - } - } - - /** - * IC2 Support - */ - if (LoadedMods.IndustrialCraft2) { - aFertIC2 = ItemUtils.getItemStackFromFQRN("IC2:itemFertilizer", 1); - CORE.RA.addDehydratorRecipe( - new ItemStack[] { CI.getNumberedCircuit(12), ItemUtils.getSimpleStack(aDustOrganicFert, 4) }, null, - null, new ItemStack[] { ItemUtils.getItemStackFromFQRN("IC2:itemFertilizer", 3), aManureByprod, - aManureByprod }, - new int[] { 10000, 2000, 2000 }, 20 * 20, 240); - } - - // Dirt Production - CORE.RA.addCompressorRecipe(ItemUtils.getSimpleStack(dustDirt, 9), ItemUtils.getSimpleStack(Blocks.dirt), - 20 * 2, 8); - - // Centrifuge Byproducts - - // Ammonium Nitrate, Phosphates, Calcium, Copper, Carbon - GT_Values.RA.addCentrifugeRecipe(CI.getNumberedCircuit(20), ItemUtils.getSimpleStack(aManureByprod, 4), - FluidUtils.getFluidStack("sulfuricacid", 250), // In Fluid - FluidUtils.getFluidStack("sulfuricapatite", 50), // Out Fluid - MaterialHelper.getDustSmall(Materials.Phosphorus, 2), MaterialHelper.getDustSmall(Materials.Calcium, 2), - MaterialHelper.getDustTiny(Materials.Copper, 1), MaterialHelper.getDust(Materials.Carbon, 1), ItemUtils.getSimpleStack(dustDirt, 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustTinyAmmoniumNitrate", 1), - new int[] { 2500, 2500, 750, 1000, 5000, 250 }, // Chances - 20 * 20, // Time - 60); // EU - - // Add Fuel Usages - CORE.RA.addSemifluidFuel(FluidUtils.getFluidStack(PoopJuice, 1000), 12); - CORE.RA.addSemifluidFuel(FluidUtils.getFluidStack(ManureSlurry, 1000), 24); - CORE.RA.addSemifluidFuel(FluidUtils.getFluidStack(FertileManureSlurry, 1000), 32); - - // Red Slurry / Tailings Processing - GT_Values.RA.addCentrifugeRecipe( - CI.getNumberedBioCircuit(10), - GT_Values.NI, - FluidUtils.getFluidStack(AgriculturalChem.RedMud, 1000), - FluidUtils.getWater(500), - ELEMENT.getInstance().IRON.getSmallDust(1), - ELEMENT.getInstance().COPPER.getSmallDust(1), - ELEMENT.getInstance().TIN.getSmallDust(1), - ELEMENT.getInstance().SULFUR.getSmallDust(1), - ELEMENT.getInstance().NICKEL.getTinyDust(1), - ELEMENT.getInstance().LEAD.getTinyDust(1), - new int[] { 3000, 3000, 2000, 2000, 1000, 1000 }, - 30 * 20, - 30); - - } - - @Override - public String errorMessage() { - return "Failed to generate recipes for AgroChem."; - } - - @Override - public boolean generateRecipes() { - if (mBloodFluids.isEmpty()) { - Logger.INFO("Could not find, nor create Blood fluid. Unable to add recipes."); - return false; - } - - // Organise OreDict - processAllOreDict(); - - // Slurry Production - addBasicSlurryRecipes(); - addAdvancedSlurryRecipes(); - - // Organic Fert. Production - addBasicOrganiseFertRecipes(); - addAdvancedOrganiseFertRecipes(); - - addMiscRecipes(); - - BioRecipes.init(); - - return true; - } + private static boolean aBOP; + private static boolean aTiCon; + + private static AutoMap mBloodFluids = new AutoMap(); + + /** + * Fluids + */ + + // Poop Juice + public static Fluid PoopJuice; + // Manure Slurry + public static Fluid ManureSlurry; + // Fertile Manure Slurry + public static Fluid FertileManureSlurry; + // Blood + public static Fluid CustomBlood; + // Red Mud + public static Fluid RedMud; + /** + * Items + */ + + // Manure Byproducts + public static Item dustManureByproducts; + // Organic Fertilizer + public static Item dustOrganicFertilizer; + // Dirt + public static Item dustDirt; + + // Poop Juice + // vv - Centrifuge + // Manure Slurry && Manure Byproducts -> (Elements) Centrifuge to several tiny + // piles + // vv - Chem Reactor - Add Peat, Meat + // Organic Fertilizer + // vv - Dehydrate + // Fertilizer + + // Poop Juice + // vv - Mixer - Add Blood, Bone, Meat (1000L Poo, 200L Blood, x2 Bone, x3 Meat) + // Fertile Manure Slurry + // vv - Chem Reactor - Add Peat x1.5 + // Organic Fertilizer x3 + // vv - Dehydrate + // Fertilizer + + public static Item mAlgae; + public static Item mBioCircuit; + public static Item mAgrichemItem1; + + /* + * 0 - Algae Biomass + * 1 - Green Algae Biomass + * 2 - Brown Algae Biomass + * 3 - Golden-Brown Algae Biomass + * 4 - Red Algae Biomass + * 5 - Cellulose Fiber + * 6 - Golden-Brown Cellulose Fiber + * 7 - Red Cellulose Fiber + * 8 - Compost + * 9 - Wood Pellet + * 10 - Wood Brick + * 11 - Cellulose Pulp + * 12 - Raw Bio Resin + * 13 - Catalyst Carrier + * 14 - Green Metal Catalyst + * 15 - Alginic Acid + * 16 - Alumina + * 17 - Aluminium Pellet + * 18 - Sodium Aluminate + * 19 - Sodium Hydroxide // Exists in Newer GT + * 20 - Sodium Carbonate + * 21 - Lithium Chloride + * 22 - Pellet Mold + * 23 - Clean Aluminium Mix + * 24 - Pinecone + */ + + public static ItemStack mAlgaeBiosmass; + public static ItemStack mGreenAlgaeBiosmass; + public static ItemStack mBrownAlgaeBiosmass; + public static ItemStack mGoldenBrownAlgaeBiosmass; + public static ItemStack mRedAlgaeBiosmass; + public static ItemStack mCelluloseFiber; + public static ItemStack mGoldenBrownCelluloseFiber; + public static ItemStack mRedCelluloseFiber; + public static ItemStack mCompost; + public static ItemStack mWoodPellet; + public static ItemStack mWoodBrick; + public static ItemStack mCellulosePulp; + public static ItemStack mRawBioResin; + public static ItemStack mCatalystCarrier; + public static ItemStack mGreenCatalyst; + public static ItemStack mAlginicAcid; + public static ItemStack mAlumina; + public static ItemStack mAluminiumPellet; + public static ItemStack mSodiumAluminate; + public static ItemStack mSodiumHydroxide; + public static ItemStack mSodiumCarbonate; + public static ItemStack mLithiumChloride; + public static ItemStack mPelletMold; + public static ItemStack mCleanAluminiumMix; + public static ItemStack mPinecone; + public static ItemStack mCrushedPine; + + @Override + public void items() { + // Nitrogen, Ammonium Nitrate, Phosphates, Calcium, Copper, Carbon + dustManureByproducts = ItemUtils.generateSpecialUseDusts( + "ManureByproducts", "Manure Byproduct", "(N2H4O3)N2P2Ca3CuC8", Utils.rgbtoHexValue(110, 75, 25))[0]; + + // Basically Guano + dustOrganicFertilizer = ItemUtils.generateSpecialUseDusts( + "OrganicFertilizer", "Organic Fertilizer", "Ca5(PO4)3(OH)", Utils.rgbtoHexValue(240, 240, 240))[0]; + + // Dirt Dust :) + dustDirt = ItemUtils.generateSpecialUseDusts("Dirt", "Dried Earth", Utils.rgbtoHexValue(65, 50, 15))[0]; + + mAlgae = new ItemAlgaeBase(); + mAgrichemItem1 = new ItemAgrichemBase(); + mBioCircuit = new ItemBioChip(); + GregtechItemList.Circuit_BioRecipeSelector.set(mBioCircuit); + + mAlgaeBiosmass = ItemUtils.simpleMetaStack(mAgrichemItem1, 0, 1); + mGreenAlgaeBiosmass = ItemUtils.simpleMetaStack(mAgrichemItem1, 1, 1); + mBrownAlgaeBiosmass = ItemUtils.simpleMetaStack(mAgrichemItem1, 2, 1); + mGoldenBrownAlgaeBiosmass = ItemUtils.simpleMetaStack(mAgrichemItem1, 3, 1); + mRedAlgaeBiosmass = ItemUtils.simpleMetaStack(mAgrichemItem1, 4, 1); + mCelluloseFiber = ItemUtils.simpleMetaStack(mAgrichemItem1, 5, 1); + mGoldenBrownCelluloseFiber = ItemUtils.simpleMetaStack(mAgrichemItem1, 6, 1); + mRedCelluloseFiber = ItemUtils.simpleMetaStack(mAgrichemItem1, 7, 1); + mCompost = ItemUtils.simpleMetaStack(mAgrichemItem1, 8, 1); + mWoodPellet = ItemUtils.simpleMetaStack(mAgrichemItem1, 9, 1); + mWoodBrick = ItemUtils.simpleMetaStack(mAgrichemItem1, 10, 1); + mCellulosePulp = ItemUtils.simpleMetaStack(mAgrichemItem1, 11, 1); + mRawBioResin = ItemUtils.simpleMetaStack(mAgrichemItem1, 12, 1); + mCatalystCarrier = ItemUtils.simpleMetaStack(mAgrichemItem1, 13, 1); + mGreenCatalyst = ItemUtils.simpleMetaStack(mAgrichemItem1, 14, 1); + mAlginicAcid = ItemUtils.simpleMetaStack(mAgrichemItem1, 15, 1); + mAlumina = ItemUtils.simpleMetaStack(mAgrichemItem1, 16, 1); + mAluminiumPellet = ItemUtils.simpleMetaStack(mAgrichemItem1, 17, 1); + mSodiumAluminate = ItemUtils.simpleMetaStack(mAgrichemItem1, 18, 1); + + /** + * If It exists, don't add a new one. + */ + if (OreDictionary.doesOreNameExist("dustSodiumHydroxide_GT5U") + || OreDictionary.doesOreNameExist("dustSodiumHydroxide")) { + List aTest = OreDictionary.getOres("dustSodiumHydroxide", false); + ItemStack aTestStack; + if (aTest.isEmpty()) { + aTest = OreDictionary.getOres("dustSodiumHydroxide_GT5U", false); + if (aTest.isEmpty()) { + aTestStack = ItemUtils.simpleMetaStack(mAgrichemItem1, 19, 1); + } else { + aTestStack = aTest.get(0); + } + } else { + aTestStack = aTest.get(0); + } + mSodiumHydroxide = aTestStack; + } else { + mSodiumHydroxide = ItemUtils.simpleMetaStack(mAgrichemItem1, 19, 1); + } + mSodiumCarbonate = ItemUtils.simpleMetaStack(mAgrichemItem1, 20, 1); + mLithiumChloride = ItemUtils.simpleMetaStack(mAgrichemItem1, 21, 1); + mPelletMold = ItemUtils.simpleMetaStack(mAgrichemItem1, 22, 1); + mCleanAluminiumMix = ItemUtils.simpleMetaStack(mAgrichemItem1, 23, 1); + mPinecone = ItemUtils.simpleMetaStack(mAgrichemItem1, 24, 1); + mCrushedPine = ItemUtils.simpleMetaStack(mAgrichemItem1, 25, 1); + + ItemUtils.addItemToOreDictionary(mGreenAlgaeBiosmass, "biomassGreenAlgae"); + ItemUtils.addItemToOreDictionary(mBrownAlgaeBiosmass, "biomassBrownAlgae"); + ItemUtils.addItemToOreDictionary(mGoldenBrownAlgaeBiosmass, "biomassGoldenBrownAlgae"); + ItemUtils.addItemToOreDictionary(mRedAlgaeBiosmass, "biomassRedAlgae"); + + ItemUtils.addItemToOreDictionary(mCelluloseFiber, "fiberCellulose"); + ItemUtils.addItemToOreDictionary(mGoldenBrownCelluloseFiber, "fiberCellulose"); + ItemUtils.addItemToOreDictionary(mGoldenBrownCelluloseFiber, "fiberGoldenBrownCellulose"); + ItemUtils.addItemToOreDictionary(mRedCelluloseFiber, "fiberCellulose"); + ItemUtils.addItemToOreDictionary(mRedCelluloseFiber, "fiberRedCellulose"); + + ItemUtils.addItemToOreDictionary(mWoodPellet, "pelletWood"); + ItemUtils.addItemToOreDictionary(mWoodBrick, "brickWood"); + ItemUtils.addItemToOreDictionary(mCellulosePulp, "pulpCellulose"); + + ItemUtils.addItemToOreDictionary(mCatalystCarrier, "catalystEmpty"); + ItemUtils.addItemToOreDictionary(mGreenCatalyst, "catalystAluminiumSilver"); + ItemUtils.addItemToOreDictionary(mAlginicAcid, "dustAlginicAcid"); + ItemUtils.addItemToOreDictionary(mAlumina, "dustAlumina"); + ItemUtils.addItemToOreDictionary(mAluminiumPellet, "pelletAluminium"); + + ItemUtils.addItemToOreDictionary(mSodiumAluminate, "dustSodiumAluminate"); + ItemUtils.addItemToOreDictionary(mSodiumHydroxide, "dustSodiumHydroxide"); + ItemUtils.addItemToOreDictionary(mSodiumCarbonate, "dustSodiumCarbonate"); + ItemUtils.addItemToOreDictionary(mLithiumChloride, "dustLithiumChloride"); + ItemUtils.addItemToOreDictionary(mPinecone, "pinecone"); + ItemUtils.addItemToOreDictionary(mCrushedPine, "crushedPineMaterial"); + + // Handle GT NaOH dusts + List NaOHSmall = OreDictionary.getOres("dustSmallSodiumHydroxide_GT5U", false); + if (!NaOHSmall.isEmpty()) { + ItemUtils.addItemToOreDictionary(NaOHSmall.get(0), "dustSmallSodiumHydroxide"); + } + List NaOHTiny = OreDictionary.getOres("dustTinySodiumHydroxide_GT5U", false); + if (!NaOHTiny.isEmpty()) { + ItemUtils.addItemToOreDictionary(NaOHTiny.get(0), "dustTinySodiumHydroxide"); + } + } + + @Override + public void blocks() { + // None yet + } + + @Override + public void fluids() { + // Sewage + PoopJuice = FluidUtils.generateFluidNonMolten( + "raw.waste", "Raw Animal Waste", 32 + 175, new short[] {100, 70, 30, 100}, null, null, 0, true); + + // Sewage + ManureSlurry = FluidUtils.generateFluidNonMolten( + "manure.slurry", "Manure Slurry", 39 + 175, new short[] {75, 45, 15, 100}, null, null, 0, true); + + // Sewage + FertileManureSlurry = FluidUtils.generateFluidNonMolten( + "fertile.manure.slurry", + "Fertile Manure Slurry", + 45 + 175, + new short[] {65, 50, 15, 100}, + null, + null, + 0, + true); + + RedMud = FluidUtils.generateFluidNoPrefix( + "mud.red.slurry", "Red Mud Slurry", 32 + 175, new short[] {180, 35, 25, 100}, true); + } + + public AgriculturalChem() { + super(); + + aBOP = LoadedMods.BiomesOPlenty; + aTiCon = LoadedMods.TiCon; + + Logger.INFO("Adding Agrochemical content"); + + FluidStack aBlood; + if (aBOP) { + aBlood = FluidUtils.getFluidStack("hell_blood", 100); + if (aBlood != null) { + Logger.INFO("Found Biome's o Plenty, enabled Blood support."); + CustomBlood = aBlood.getFluid(); + mBloodFluids.put(aBlood); + } + } + + if (aTiCon) { + aBlood = FluidUtils.getFluidStack("blood", 100); + if (aBlood != null) { + Logger.INFO("Found Tinker's Construct, enabled Blood support."); + CustomBlood = aBlood.getFluid(); + mBloodFluids.put(FluidUtils.getFluidStack("blood", 100)); + } + } + + // Handle Blood Internally, Create if required. + if (mBloodFluids.isEmpty() || CustomBlood == null) { + Logger.INFO( + "Did not find any existing Blood fluids. Trying to wildcard search the fluid registry, then generate our own if that fails."); + FluidStack aTempBlood = FluidUtils.getWildcardFluidStack("blood", 100); + if (aTempBlood != null) { + CustomBlood = aTempBlood.getFluid(); + } else { + aTempBlood = FluidUtils.getWildcardFluidStack("hell_blood", 100); + if (aTempBlood == null) { + CustomBlood = FluidUtils.generateFluidNoPrefix( + "blood", "Blood", 32 + 175, new short[] {175, 25, 25, 100}, true); + } else { + CustomBlood = aTempBlood.getFluid(); + } + } + Logger.INFO("Using " + CustomBlood.getName()); + mBloodFluids.put(FluidUtils.getFluidStack(CustomBlood, 100)); + } + } + + private static final AutoMap mMeats = new AutoMap(); + private static final AutoMap mFish = new AutoMap(); + private static final AutoMap mFruits = new AutoMap(); + private static final AutoMap mVege = new AutoMap(); + private static final AutoMap mNuts = new AutoMap(); + private static final AutoMap mSeeds = new AutoMap(); + private static final AutoMap mPeat = new AutoMap(); + private static final AutoMap mBones = new AutoMap(); + private static final AutoMap mBoneMeal = new AutoMap(); + + private static final AutoMap mList_Master_Meats = new AutoMap(); + private static final AutoMap mList_Master_FruitVege = new AutoMap(); + private static final AutoMap mList_Master_Seeds = new AutoMap(); + private static final AutoMap mList_Master_Bones = new AutoMap(); + + private static void processAllOreDict() { + processOreDict("listAllmeatraw", mMeats); + processOreDict("listAllfishraw", mFish); + processOreDict("listAllfruit", mFruits); + processOreDict("listAllVeggie", mVege); + processOreDict("listAllnut", mNuts); + processOreDict("listAllSeed", mSeeds); + processOreDict("brickPeat", mPeat); + processOreDict("bone", mBones); + processOreDict("dustBone", mBoneMeal); + // Just make a mega list, makes life easier. + if (!mMeats.isEmpty()) { + for (ItemStack g : mMeats) { + mList_Master_Meats.put(g); + } + } + if (!mFish.isEmpty()) { + for (ItemStack g : mFish) { + mList_Master_Meats.put(g); + } + } + if (!mFruits.isEmpty()) { + for (ItemStack g : mFruits) { + mList_Master_FruitVege.put(g); + } + } + if (!mVege.isEmpty()) { + for (ItemStack g : mVege) { + mList_Master_FruitVege.put(g); + } + } + if (!mNuts.isEmpty()) { + for (ItemStack g : mNuts) { + mList_Master_FruitVege.put(g); + } + } + if (!mSeeds.isEmpty()) { + for (ItemStack g : mSeeds) { + mList_Master_Seeds.put(g); + } + } + if (!mBoneMeal.isEmpty()) { + for (ItemStack g : mBoneMeal) { + mList_Master_Bones.put(g); + } + } + if (!mBones.isEmpty()) { + for (ItemStack g : mBones) { + mList_Master_Bones.put(g); + } + } + } + + private static void processOreDict(String aOreName, AutoMap aMap) { + ArrayList aTemp = OreDictionary.getOres(aOreName); + if (!aTemp.isEmpty()) { + for (ItemStack stack : aTemp) { + aMap.put(stack); + } + } + } + + private static void addBasicSlurryRecipes() { + + ItemStack aManureByprod1 = ItemUtils.getItemStackOfAmountFromOreDict("dustTinyManureByproducts", 1); + ItemStack aManureByprod2 = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallManureByproducts", 1); + ItemStack aDirtDust = ItemUtils.getSimpleStack(dustDirt, 1); + + // Poop Juice to Basic Slurry + GT_Values.RA.addCentrifugeRecipe( + CI.getNumberedCircuit(10), + null, + FluidUtils.getFluidStack(PoopJuice, 1000), // In + // Fluid + FluidUtils.getFluidStack(ManureSlurry, 250), // Out Fluid + aDirtDust, + aDirtDust, + aManureByprod1, + aManureByprod1, + aManureByprod1, + aManureByprod1, + new int[] {2000, 2000, 500, 500, 250, 250}, // Chances + 10 * 20, // Time + 30); // EU + + // More Efficient way to get byproducts, less Slurry + GT_Values.RA.addCentrifugeRecipe( + CI.getNumberedCircuit(20), + null, + FluidUtils.getFluidStack(PoopJuice, 1000), // In + // Fluid + FluidUtils.getFluidStack(ManureSlurry, 50), // Out Fluid + aDirtDust, + aDirtDust, + aManureByprod1, + aManureByprod1, + aManureByprod2, + aManureByprod2, + new int[] {4000, 3000, 1250, 1250, 675, 675}, // Chances + 20 * 20, // Time + 60); // EU + } + + private static void addAdvancedSlurryRecipes() { + + ItemStack aCircuit = CI.getNumberedCircuit(10); + ItemStack aBone; + ItemStack aMeat; + ItemStack aEmptyCells = CI.emptyCells(2); + ItemStack aInputCells = ItemUtils.getItemStackOfAmountFromOreDict("cellRawAnimalWaste", 2); + FluidStack aOutput = FluidUtils.getFluidStack(FertileManureSlurry, 1000); + + for (FluidStack aBloodStack : mBloodFluids) { + for (ItemStack aBoneStack : mList_Master_Bones) { + aBone = ItemUtils.getSimpleStack(aBoneStack, 2); + for (ItemStack aMeatStack : mList_Master_Meats) { + aMeat = ItemUtils.getSimpleStack(aMeatStack, 5); + // Poop Juice to Fertile Slurry + GT_Values.RA.addMixerRecipe( + aCircuit, + aBone, + aMeat, + aInputCells, + aBloodStack, // Input Fluid + aOutput, // Output Fluid + aEmptyCells, // Output Item + 20 * 8, // Time? + 60 // Eu? + ); + } + } + } + } + + private static void addBasicOrganiseFertRecipes() { + FluidStack aInputFluid = FluidUtils.getFluidStack(ManureSlurry, 1000); + ItemStack aOutputDust = ItemUtils.getSimpleStack(dustOrganicFertilizer, 3); + ItemStack aPeat; + ItemStack aMeat; + for (ItemStack aPeatStack : mPeat) { + aPeat = ItemUtils.getSimpleStack(aPeatStack, 3); + for (ItemStack aMeatStack : mList_Master_Meats) { + aMeat = ItemUtils.getSimpleStack(aMeatStack, 5); + CORE.RA.addChemicalRecipe(aPeat, aMeat, aInputFluid, null, aOutputDust, 20 * 20, 120); + } + + aPeat = ItemUtils.getSimpleStack(aPeatStack, 2); + for (ItemStack aMeatStack : mList_Master_FruitVege) { + aMeat = ItemUtils.getSimpleStack(aMeatStack, 9); + CORE.RA.addChemicalRecipe(aPeat, aMeat, aInputFluid, null, aOutputDust, 10 * 20, 120); + } + } + } + + private static void addAdvancedOrganiseFertRecipes() { + FluidStack aInputFluid = FluidUtils.getFluidStack(FertileManureSlurry, 1000); + ItemStack aOutputDust = ItemUtils.getSimpleStack(dustOrganicFertilizer, 7); + ItemStack aPeat; + ItemStack aMeat; + for (ItemStack aPeatStack : mPeat) { + aPeat = ItemUtils.getSimpleStack(aPeatStack, 5); + for (ItemStack aMeatStack : mList_Master_Meats) { + aMeat = ItemUtils.getSimpleStack(aMeatStack, 7); + CORE.RA.addChemicalRecipe(aPeat, aMeat, aInputFluid, null, aOutputDust, 10 * 20, 140); + } + aPeat = ItemUtils.getSimpleStack(aPeatStack, 3); + for (ItemStack aMeatStack : mList_Master_FruitVege) { + aMeat = ItemUtils.getSimpleStack(aMeatStack, 12); + CORE.RA.addChemicalRecipe(aPeat, aMeat, aInputFluid, null, aOutputDust, 5 * 20, 140); + } + } + } + + public static ItemStack aFertForestry; + public static ItemStack aFertIC2; + + private static void addMiscRecipes() { + + ItemStack aDustOrganicFert = ItemUtils.getSimpleStack(dustOrganicFertilizer, 1); + ItemStack aManureByprod = ItemUtils.getSimpleStack(dustManureByproducts, 1); + + // Dehydrate Organise Fert to Normal Fert. + + /** + * Forestry Support + */ + if (LoadedMods.Forestry) { + Field aItemField = + ReflectionUtils.getField(ReflectionUtils.getClass("forestry.plugins.PluginCore"), "items"); + try { + Object aItemRegInstance = aItemField != null ? aItemField.get(aItemField) : null; + if (aItemRegInstance != null) { + Field aFertField = ReflectionUtils.getField(aItemRegInstance.getClass(), "fertilizerCompound"); + Object aItemInstance = aFertField.get(aItemRegInstance); + if (aItemInstance instanceof Item) { + aFertForestry = ItemUtils.getSimpleStack((Item) aItemInstance); + Item aForestryFert = (Item) aItemInstance; + CORE.RA.addDehydratorRecipe( + new ItemStack[] { + CI.getNumberedCircuit(11), ItemUtils.getSimpleStack(aDustOrganicFert, 4) + }, + null, + null, + new ItemStack[] { + ItemUtils.getSimpleStack(aForestryFert, 3), aManureByprod, aManureByprod + }, + new int[] {10000, 2000, 2000}, + 20 * 20, + 240); + } + } + } catch (IllegalArgumentException | IllegalAccessException e) { + + } + } + + /** + * IC2 Support + */ + if (LoadedMods.IndustrialCraft2) { + aFertIC2 = ItemUtils.getItemStackFromFQRN("IC2:itemFertilizer", 1); + CORE.RA.addDehydratorRecipe( + new ItemStack[] {CI.getNumberedCircuit(12), ItemUtils.getSimpleStack(aDustOrganicFert, 4)}, + null, + null, + new ItemStack[] { + ItemUtils.getItemStackFromFQRN("IC2:itemFertilizer", 3), aManureByprod, aManureByprod + }, + new int[] {10000, 2000, 2000}, + 20 * 20, + 240); + } + + // Dirt Production + CORE.RA.addCompressorRecipe( + ItemUtils.getSimpleStack(dustDirt, 9), ItemUtils.getSimpleStack(Blocks.dirt), 20 * 2, 8); + + // Centrifuge Byproducts + + // Ammonium Nitrate, Phosphates, Calcium, Copper, Carbon + GT_Values.RA.addCentrifugeRecipe( + CI.getNumberedCircuit(20), + ItemUtils.getSimpleStack(aManureByprod, 4), + FluidUtils.getFluidStack("sulfuricacid", 250), // In Fluid + FluidUtils.getFluidStack("sulfuricapatite", 50), // Out Fluid + MaterialHelper.getDustSmall(Materials.Phosphorus, 2), + MaterialHelper.getDustSmall(Materials.Calcium, 2), + MaterialHelper.getDustTiny(Materials.Copper, 1), + MaterialHelper.getDust(Materials.Carbon, 1), + ItemUtils.getSimpleStack(dustDirt, 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyAmmoniumNitrate", 1), + new int[] {2500, 2500, 750, 1000, 5000, 250}, // Chances + 20 * 20, // Time + 60); // EU + + // Add Fuel Usages + CORE.RA.addSemifluidFuel(FluidUtils.getFluidStack(PoopJuice, 1000), 12); + CORE.RA.addSemifluidFuel(FluidUtils.getFluidStack(ManureSlurry, 1000), 24); + CORE.RA.addSemifluidFuel(FluidUtils.getFluidStack(FertileManureSlurry, 1000), 32); + + // Red Slurry / Tailings Processing + GT_Values.RA.addCentrifugeRecipe( + CI.getNumberedBioCircuit(10), + GT_Values.NI, + FluidUtils.getFluidStack(AgriculturalChem.RedMud, 1000), + FluidUtils.getWater(500), + ELEMENT.getInstance().IRON.getSmallDust(1), + ELEMENT.getInstance().COPPER.getSmallDust(1), + ELEMENT.getInstance().TIN.getSmallDust(1), + ELEMENT.getInstance().SULFUR.getSmallDust(1), + ELEMENT.getInstance().NICKEL.getTinyDust(1), + ELEMENT.getInstance().LEAD.getTinyDust(1), + new int[] {3000, 3000, 2000, 2000, 1000, 1000}, + 30 * 20, + 30); + } + + @Override + public String errorMessage() { + return "Failed to generate recipes for AgroChem."; + } + + @Override + public boolean generateRecipes() { + if (mBloodFluids.isEmpty()) { + Logger.INFO("Could not find, nor create Blood fluid. Unable to add recipes."); + return false; + } + + // Organise OreDict + processAllOreDict(); + + // Slurry Production + addBasicSlurryRecipes(); + addAdvancedSlurryRecipes(); + + // Organic Fert. Production + addBasicOrganiseFertRecipes(); + addAdvancedOrganiseFertRecipes(); + + addMiscRecipes(); + + BioRecipes.init(); + + return true; + } } diff --git a/src/main/java/gtPlusPlus/core/item/chemistry/CoalTar.java b/src/main/java/gtPlusPlus/core/item/chemistry/CoalTar.java index c7864efac8..a99386340d 100644 --- a/src/main/java/gtPlusPlus/core/item/chemistry/CoalTar.java +++ b/src/main/java/gtPlusPlus/core/item/chemistry/CoalTar.java @@ -17,361 +17,357 @@ import net.minecraftforge.fluids.FluidStack; public class CoalTar extends ItemPackage { - public static Fluid Coal_Gas; - public static Fluid Coal_Oil; - public static Fluid Ethylene; - public static Fluid Ethylbenzene; - public static Fluid Anthracene; - public static Fluid Toluene; - public static Fluid Coal_Tar; - public static Fluid Coal_Tar_Oil; - public static Fluid Sulfuric_Coal_Tar_Oil; - public static Fluid Naphthalene; - public static Fluid Phthalic_Acid; - - private static void recipeEthylBenzineFuelsIntoHeavyFuel() { - CORE.RA.addChemicalRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("cellFuel", 9), - ItemUtils.getItemStackOfAmountFromOreDict("cellEthylbenzene", 2), - null, - FluidUtils.getFluidStack("nitrofuel", 7500), - ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 11), - 100, - CORE.GTNH ? 1000 : 500); - CORE.RA.addChemicalRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("cellBioDiesel", 9), - ItemUtils.getItemStackOfAmountFromOreDict("cellEthylbenzene", 2), - null, - FluidUtils.getFluidStack("nitrofuel", 3000), - ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 11), - 300, - CORE.GTNH ? 1000 : 500); - } - - public static void recipeCreateEthylene(){ - - FluidStack bioEth1 = FluidUtils.getFluidStack("fluid.bioethanol", 1000); - FluidStack bioEth2 = FluidUtils.getFluidStack("bioethanol", 1000); - - //C2H6O = C2H4 + H2O - if (bioEth1 != null){ - CORE.RA.addDehydratorRecipe( - new ItemStack[] { - CI.getNumberedBioCircuit(17), - ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 1) - }, - bioEth1, - FluidUtils.getWater(1000), - new ItemStack[]{ - ItemUtils.getItemStackOfAmountFromOreDict("cellEthylene", 1) - }, - new int[] {10000}, - 120 * 20, - 80); - } - - if (bioEth2 != null){ - CORE.RA.addDehydratorRecipe( - new ItemStack[] { - CI.getNumberedBioCircuit(18), - ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 1) - }, - bioEth2, - FluidUtils.getWater(1000), - new ItemStack[]{ - ItemUtils.getItemStackOfAmountFromOreDict("cellEthylene", 1) - }, - new int[] {10000}, - 120 * 20, - 80); - } - } - - public static void recipeCreateBenzene(){ - //C7H8 + 2H = CH4 + C6H6 - CORE.RA.addDehydratorRecipe( - new ItemStack[]{ - ItemUtils.getItemStackOfAmountFromOreDict("cellToluene", 1), - ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 2) - }, - null, - null, - new ItemStack[]{ - ItemUtils.getItemStackOfAmountFromOreDict("cellMethane", 1), - ItemUtils.getItemStackOfAmountFromOreDict("cellBenzene", 1), - Materials.Empty.getCells(1) - }, - new int[]{10000, 10000, 10000}, - 20*10, - 90); - } - - public static void recipeCreateEthylbenzene(){ - //C2H4 + C6H6 = C8H10 - GT_Values.RA.addChemicalRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("cellEthylene", 2), - ItemUtils.getItemStackOfAmountFromOreDict("cellBenzene", 2), - null, - FluidUtils.getFluidStack("fluid.ethylbenzene", 2000), - ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 4), - 300); - } - - - public static void recipeCoalToCoalTar(){ - //Charcoal - AddGregtechRecipe.addCokeAndPyrolyseRecipes( - GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Charcoal, 32L), - 8, - GT_Values.NF, - ItemUtils.getItemStackOfAmountFromOreDict("dustSmallDirt", 2), - FluidUtils.getFluidStack("fluid.coaltar", 800), - 15, - 120); - //Lignite - AddGregtechRecipe.addCokeAndPyrolyseRecipes( - GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Lignite, 16L), - 8, - GT_Values.NF, - ItemUtils.getItemStackOfAmountFromOreDict("dustSmallDarkAsh", 2), - FluidUtils.getFluidStack("fluid.coaltar", 800), - 45, - 60); - - //Coal - AddGregtechRecipe.addCokeAndPyrolyseRecipes( - GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Coal, 12L), - 8, - GT_Values.NF, - ItemUtils.getItemStackOfAmountFromOreDict("dustSmallDarkAsh", 2), - FluidUtils.getFluidStack("fluid.coaltar", 2200), - 30, - 120); - - //Coke - AddGregtechRecipe.addCokeAndPyrolyseRecipes( - ItemUtils.getItemStackOfAmountFromOreDict("fuelCoke", 8), - 8, - GT_Values.NF, - ItemUtils.getItemStackOfAmountFromOreDict("dustSmallAsh", 3), - FluidUtils.getFluidStack("fluid.coaltar", 3400), - 15, - 240); - - } - - private static void recipeCoalTarToCoalTarOil() { - // v - Distill (60% Tar oil/15% Naphtha/20% Ethylbenzene/5% Anthracene) - //Create Coal Tar Oil - //FluidUtils.generateFluidNonMolten("CoalTarOil", "Coal Tar Oil", 240, new short[]{240, 240, 150, 100}, null, null); - GT_Values.RA.addDistilleryRecipe( - CI.getNumberedCircuit(1), //Circuit - FluidUtils.getFluidStack("fluid.coaltar", 1000), //aInput - FluidUtils.getFluidStack("fluid.coaltaroil", 600), //aOutput - 600, //aDuration - 64,//aEUt - false //Hidden? - ); - GT_Values.RA.addDistilleryRecipe( - CI.getNumberedCircuit(2), //Circuit - FluidUtils.getFluidStack("fluid.coaltar", 1000), //aInput - FluidUtils.getFluidStack("liquid_naphtha", 150), //aOutput - 300, //aDuration - 30,//aEUt - false //Hidden? - ); - GT_Values.RA.addDistilleryRecipe( - CI.getNumberedCircuit(3), //Circuit - FluidUtils.getFluidStack("fluid.coaltar", 1000), //aInput - FluidUtils.getFluidStack("fluid.ethylbenzene", 200), //aOutput - 450, //aDuration - 86,//aEUt - false //Hidden? - ); - GT_Values.RA.addDistilleryRecipe( - CI.getNumberedCircuit(4), //Circuit - FluidUtils.getFluidStack("fluid.coaltar", 1000), //aInput - FluidUtils.getFluidStack("fluid.anthracene", 50), //aOutput - 900, //aDuration - 30,//aEUt - false //Hidden? - ); - GT_Values.RA.addDistilleryRecipe( - CI.getNumberedCircuit(5), //Circuit - FluidUtils.getFluidStack("fluid.coaltar", 1500), //aInput - FluidUtils.getFluidStack("fluid.kerosene", 600), //aOutput - 300, //aDuration - 64,//aEUt - false //Hidden? - ); - - GT_Values.RA.addDistillationTowerRecipe( - FluidUtils.getFluidStack("fluid.coaltar", 1200), - new FluidStack[]{ - FluidUtils.getFluidStack("fluid.coaltaroil", 500), //aOutput - FluidUtils.getFluidStack("liquid_naphtha", 100), //aOutput - FluidUtils.getFluidStack("fluid.ethylbenzene", 150), //aOutput - FluidUtils.getFluidStack("fluid.anthracene", 50), //aOutput - FluidUtils.getFluidStack("fluid.kerosene", 400), //aOutput - }, - null, - 900, - 60); - - } - - private static void recipeCoalTarOilToSulfuricOilToNaphthalene() { - //SulfuricCoalTarOil - GT_Values.RA.addChemicalRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("cellCoalTarOil", 8), - ItemUtils.getItemStackOfAmountFromOreDict("cellSulfuricAcid", 8), - null, - null, - ItemUtils.getItemStackOfAmountFromOreDict("cellSulfuricCoalTarOil", 16), - 20*16); - GT_Values.RA.addDistilleryRecipe( - CI.getNumberedCircuit(6), //Circuit - FluidUtils.getFluidStack("fluid.sulfuriccoaltaroil", 1000), //aInput - FluidUtils.getFluidStack("fluid.naphthalene", 1000), //aOutput - 1200, //aDuration - 30,//aEUt - false //Hidden? - ); - - } - - private static void recipeNaphthaleneToPhthalicAcid() { - //SulfuricCoalTarOil - GT_Values.RA.addChemicalRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("cellNaphthalene", 2), - ItemUtils.getItemStackOfAmountFromOreDict("dustLithium", 5), - null, - FluidUtils.getFluidStack("fluid.phthalicacid", 2500), - ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 2), - 20*16); - - } - - private static void recipePhthalicAcidToPhthalicAnhydride() { - CORE.RA.addDehydratorRecipe( - new ItemStack[] { - CI.getNumberedBioCircuit(15) - }, - FluidUtils.getFluidStack("fluid.phthalicacid", 1000), - null, - new ItemStack[]{ - ItemUtils.getItemStackOfAmountFromOreDict("dustPhthalicAnhydride", 15) - }, - new int[] {10000}, - 60 * 20, - 120); - } - - @Override - public String errorMessage() { - return "Bad Coal Science!"; - } - - @Override - public boolean generateRecipes() { - recipeCreateEthylene(); - recipeCreateBenzene(); - recipeCreateEthylbenzene(); - - recipeCoalToCoalTar(); - recipeCoalTarToCoalTarOil(); - recipeCoalTarOilToSulfuricOilToNaphthalene(); - recipeNaphthaleneToPhthalicAcid(); - recipePhthalicAcidToPhthalicAnhydride(); - - recipeEthylBenzineFuelsIntoHeavyFuel(); - - recipePhthalicAcidConversion(); - - //Burn the coal gas! - GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalGas", 1), null, 96, 1); - CORE.RA.addSemifluidFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellSulfuricCoalTarOil", 1), 64); - CORE.RA.addSemifluidFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalTarOil", 1), 32); - CORE.RA.addSemifluidFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalTar", 1), 16); - - return true; - } - - private void recipePhthalicAcidConversion() { - FluidStack aMyAcid = FluidUtils.getFluidStack(Phthalic_Acid, 500); - FluidStack aGtAcid = FluidUtils.getFluidStack("phtalicacid", 500); - if (aMyAcid != null && aGtAcid != null) { - CORE.RA.addDistilleryRecipe(CI.getNumberedBioCircuit(8), aMyAcid, aGtAcid, null, 50, 16, false); - CORE.RA.addDistilleryRecipe(CI.getNumberedBioCircuit(9), aGtAcid, aMyAcid, null, 50, 16, false); - } - } - - @Override - public void items() { - //Phthalic_Acid = FluidUtils.generateFluidNonMolten("PhthalicAcid", "Phthalic Acid", 207, new short[]{210, 220, 210, 100}, null, null); - // v - Dehydrate at 180C+ - //Create Phthalic Anhydride - ItemUtils.generateSpecialUseDusts("PhthalicAnhydride", "Phthalic Anhydride", "C6H4(CO)2O", Utils.rgbtoHexValue(175, 175, 175)); - - //Lithium Hydroperoxide - LiOH + H2O2 → LiOOH + 2 H2O - ItemUtils.generateSpecialUseDusts("LithiumHydroperoxide", "Lithium Hydroperoxide", "HLiO2", Utils.rgbtoHexValue(125, 125, 125)); - // v - Dehydrate - //Lithium Peroxide - 2 LiOOH → Li2O2 + H2O2 + 2 H2O - //Lithium_Peroxide = FluidUtils.generateFluidNonMolten("LithiumPeroxide", "Lithium Peroxide", 446, new short[]{135, 135, 135, 100}, null, null); - } - - @Override - public void blocks() { - - } - - @Override - public void fluids() { - - //Create Coal Gas - Coal_Gas = FluidUtils.generateFluidNonMolten("CoalGas", "Coal Gas", 500, new short[]{48, 48, 48, 100}, null, null); - //Ethanol - // v - Dehydrate cells to remove water - - - //Create Ethylene - if (!FluidUtils.doesFluidExist("ethylene")){ - Ethylene = FluidUtils.generateFluidNonMolten("ethylene", "Ethylene", -103, new short[]{255, 255, 255, 100}, null, null); - } - else { - Ethylene = FluidUtils.getWildcardFluidStack("ethylene", 1).getFluid(); - } - - //Create Ethylbenzene - Ethylbenzene is produced in on a large scale by combining benzene and ethylene in an acid-catalyzed chemical reaction - //Use Chemical Reactor - Ethylbenzene = FluidUtils.generateFluidNonMolten("Ethylbenzene", "Ethylbenzene", 136, new short[]{255, 255, 255, 100}, null, null); - //Create Anthracene - Anthracene = FluidUtils.generateFluidNonMolten("Anthracene", "Anthracene", 340, new short[]{255, 255, 255, 100}, null, null); - //Toluene - if (!FluidUtils.doesFluidExist("liquid_toluene")){ - Toluene = FluidUtils.generateFluidNonMolten("liquid_toluene", "Toluene", -95, new short[]{140, 70, 20, 100}, null, null); - } - else { - Toluene = FluidUtils.getWildcardFluidStack("liquid_toluene", 1).getFluid(); - } - - //Create Coal Tar - Coal_Tar = FluidUtils.generateFluidNonMolten("CoalTar", "Coal Tar", 450, new short[]{32, 32, 32, 100}, null, null); - // v - Distill (60% Tar oil/15% Naphtha/20% Ethylbenzene/5% Anthracene) - //Create Coal Tar Oil - Coal_Tar_Oil = FluidUtils.generateFluidNonMolten("CoalTarOil", "Coal Tar Oil", 240, new short[]{240, 240, 150, 100}, null, null); - // v - Wash With Sulfuric Acid - //Create Sulfuric Coal Tar Oil - Sulfuric_Coal_Tar_Oil = FluidUtils.generateFluidNonMolten("SulfuricCoalTarOil", "Sulfuric Coal Tar Oil", 240, new short[]{250, 170, 12, 100}, null, null); - // v - Distill (No loss, just time consuming) - //Create Naphthalene - Naphthalene = FluidUtils.generateFluidNonMolten("Naphthalene", "Naphthalene", 115, new short[]{210, 185, 135, 100}, null, null); - // v - Oxidize with mercury and nitric acid - //Create Phthalic Acid - Phthalic_Acid = FluidUtils.generateFluidNonMolten("PhthalicAcid", "Phthalic Acid", 207, new short[]{210, 220, 210, 100}, null, null); - // v - Dehydrate at 180C+ - //Create Phthalic Anhydride - //ItemUtils.generateSpecialUseDusts("PhthalicAnhydride", "Phthalic Anhydride", "C6H4(CO)2O", Utils.rgbtoHexValue(175, 175, 175)); - } - + public static Fluid Coal_Gas; + public static Fluid Coal_Oil; + public static Fluid Ethylene; + public static Fluid Ethylbenzene; + public static Fluid Anthracene; + public static Fluid Toluene; + public static Fluid Coal_Tar; + public static Fluid Coal_Tar_Oil; + public static Fluid Sulfuric_Coal_Tar_Oil; + public static Fluid Naphthalene; + public static Fluid Phthalic_Acid; + + private static void recipeEthylBenzineFuelsIntoHeavyFuel() { + CORE.RA.addChemicalRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("cellFuel", 9), + ItemUtils.getItemStackOfAmountFromOreDict("cellEthylbenzene", 2), + null, + FluidUtils.getFluidStack("nitrofuel", 7500), + ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 11), + 100, + CORE.GTNH ? 1000 : 500); + CORE.RA.addChemicalRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("cellBioDiesel", 9), + ItemUtils.getItemStackOfAmountFromOreDict("cellEthylbenzene", 2), + null, + FluidUtils.getFluidStack("nitrofuel", 3000), + ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 11), + 300, + CORE.GTNH ? 1000 : 500); + } + + public static void recipeCreateEthylene() { + + FluidStack bioEth1 = FluidUtils.getFluidStack("fluid.bioethanol", 1000); + FluidStack bioEth2 = FluidUtils.getFluidStack("bioethanol", 1000); + + // C2H6O = C2H4 + H2O + if (bioEth1 != null) { + CORE.RA.addDehydratorRecipe( + new ItemStack[] { + CI.getNumberedBioCircuit(17), ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 1) + }, + bioEth1, + FluidUtils.getWater(1000), + new ItemStack[] {ItemUtils.getItemStackOfAmountFromOreDict("cellEthylene", 1)}, + new int[] {10000}, + 120 * 20, + 80); + } + + if (bioEth2 != null) { + CORE.RA.addDehydratorRecipe( + new ItemStack[] { + CI.getNumberedBioCircuit(18), ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 1) + }, + bioEth2, + FluidUtils.getWater(1000), + new ItemStack[] {ItemUtils.getItemStackOfAmountFromOreDict("cellEthylene", 1)}, + new int[] {10000}, + 120 * 20, + 80); + } + } + + public static void recipeCreateBenzene() { + // C7H8 + 2H = CH4 + C6H6 + CORE.RA.addDehydratorRecipe( + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("cellToluene", 1), + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 2) + }, + null, + null, + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("cellMethane", 1), + ItemUtils.getItemStackOfAmountFromOreDict("cellBenzene", 1), + Materials.Empty.getCells(1) + }, + new int[] {10000, 10000, 10000}, + 20 * 10, + 90); + } + + public static void recipeCreateEthylbenzene() { + // C2H4 + C6H6 = C8H10 + GT_Values.RA.addChemicalRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("cellEthylene", 2), + ItemUtils.getItemStackOfAmountFromOreDict("cellBenzene", 2), + null, + FluidUtils.getFluidStack("fluid.ethylbenzene", 2000), + ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 4), + 300); + } + + public static void recipeCoalToCoalTar() { + // Charcoal + AddGregtechRecipe.addCokeAndPyrolyseRecipes( + GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Charcoal, 32L), + 8, + GT_Values.NF, + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallDirt", 2), + FluidUtils.getFluidStack("fluid.coaltar", 800), + 15, + 120); + // Lignite + AddGregtechRecipe.addCokeAndPyrolyseRecipes( + GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Lignite, 16L), + 8, + GT_Values.NF, + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallDarkAsh", 2), + FluidUtils.getFluidStack("fluid.coaltar", 800), + 45, + 60); + + // Coal + AddGregtechRecipe.addCokeAndPyrolyseRecipes( + GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Coal, 12L), + 8, + GT_Values.NF, + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallDarkAsh", 2), + FluidUtils.getFluidStack("fluid.coaltar", 2200), + 30, + 120); + + // Coke + AddGregtechRecipe.addCokeAndPyrolyseRecipes( + ItemUtils.getItemStackOfAmountFromOreDict("fuelCoke", 8), + 8, + GT_Values.NF, + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallAsh", 3), + FluidUtils.getFluidStack("fluid.coaltar", 3400), + 15, + 240); + } + + private static void recipeCoalTarToCoalTarOil() { + // v - Distill (60% Tar oil/15% Naphtha/20% Ethylbenzene/5% Anthracene) + // Create Coal Tar Oil + // FluidUtils.generateFluidNonMolten("CoalTarOil", "Coal Tar Oil", 240, new short[]{240, 240, 150, 100}, null, + // null); + GT_Values.RA.addDistilleryRecipe( + CI.getNumberedCircuit(1), // Circuit + FluidUtils.getFluidStack("fluid.coaltar", 1000), // aInput + FluidUtils.getFluidStack("fluid.coaltaroil", 600), // aOutput + 600, // aDuration + 64, // aEUt + false // Hidden? + ); + GT_Values.RA.addDistilleryRecipe( + CI.getNumberedCircuit(2), // Circuit + FluidUtils.getFluidStack("fluid.coaltar", 1000), // aInput + FluidUtils.getFluidStack("liquid_naphtha", 150), // aOutput + 300, // aDuration + 30, // aEUt + false // Hidden? + ); + GT_Values.RA.addDistilleryRecipe( + CI.getNumberedCircuit(3), // Circuit + FluidUtils.getFluidStack("fluid.coaltar", 1000), // aInput + FluidUtils.getFluidStack("fluid.ethylbenzene", 200), // aOutput + 450, // aDuration + 86, // aEUt + false // Hidden? + ); + GT_Values.RA.addDistilleryRecipe( + CI.getNumberedCircuit(4), // Circuit + FluidUtils.getFluidStack("fluid.coaltar", 1000), // aInput + FluidUtils.getFluidStack("fluid.anthracene", 50), // aOutput + 900, // aDuration + 30, // aEUt + false // Hidden? + ); + GT_Values.RA.addDistilleryRecipe( + CI.getNumberedCircuit(5), // Circuit + FluidUtils.getFluidStack("fluid.coaltar", 1500), // aInput + FluidUtils.getFluidStack("fluid.kerosene", 600), // aOutput + 300, // aDuration + 64, // aEUt + false // Hidden? + ); + + GT_Values.RA.addDistillationTowerRecipe( + FluidUtils.getFluidStack("fluid.coaltar", 1200), + new FluidStack[] { + FluidUtils.getFluidStack("fluid.coaltaroil", 500), // aOutput + FluidUtils.getFluidStack("liquid_naphtha", 100), // aOutput + FluidUtils.getFluidStack("fluid.ethylbenzene", 150), // aOutput + FluidUtils.getFluidStack("fluid.anthracene", 50), // aOutput + FluidUtils.getFluidStack("fluid.kerosene", 400), // aOutput + }, + null, + 900, + 60); + } + + private static void recipeCoalTarOilToSulfuricOilToNaphthalene() { + // SulfuricCoalTarOil + GT_Values.RA.addChemicalRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("cellCoalTarOil", 8), + ItemUtils.getItemStackOfAmountFromOreDict("cellSulfuricAcid", 8), + null, + null, + ItemUtils.getItemStackOfAmountFromOreDict("cellSulfuricCoalTarOil", 16), + 20 * 16); + GT_Values.RA.addDistilleryRecipe( + CI.getNumberedCircuit(6), // Circuit + FluidUtils.getFluidStack("fluid.sulfuriccoaltaroil", 1000), // aInput + FluidUtils.getFluidStack("fluid.naphthalene", 1000), // aOutput + 1200, // aDuration + 30, // aEUt + false // Hidden? + ); + } + + private static void recipeNaphthaleneToPhthalicAcid() { + // SulfuricCoalTarOil + GT_Values.RA.addChemicalRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("cellNaphthalene", 2), + ItemUtils.getItemStackOfAmountFromOreDict("dustLithium", 5), + null, + FluidUtils.getFluidStack("fluid.phthalicacid", 2500), + ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 2), + 20 * 16); + } + + private static void recipePhthalicAcidToPhthalicAnhydride() { + CORE.RA.addDehydratorRecipe( + new ItemStack[] {CI.getNumberedBioCircuit(15)}, + FluidUtils.getFluidStack("fluid.phthalicacid", 1000), + null, + new ItemStack[] {ItemUtils.getItemStackOfAmountFromOreDict("dustPhthalicAnhydride", 15)}, + new int[] {10000}, + 60 * 20, + 120); + } + + @Override + public String errorMessage() { + return "Bad Coal Science!"; + } + + @Override + public boolean generateRecipes() { + recipeCreateEthylene(); + recipeCreateBenzene(); + recipeCreateEthylbenzene(); + + recipeCoalToCoalTar(); + recipeCoalTarToCoalTarOil(); + recipeCoalTarOilToSulfuricOilToNaphthalene(); + recipeNaphthaleneToPhthalicAcid(); + recipePhthalicAcidToPhthalicAnhydride(); + + recipeEthylBenzineFuelsIntoHeavyFuel(); + + recipePhthalicAcidConversion(); + + // Burn the coal gas! + GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalGas", 1), null, 96, 1); + CORE.RA.addSemifluidFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellSulfuricCoalTarOil", 1), 64); + CORE.RA.addSemifluidFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalTarOil", 1), 32); + CORE.RA.addSemifluidFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalTar", 1), 16); + + return true; + } + + private void recipePhthalicAcidConversion() { + FluidStack aMyAcid = FluidUtils.getFluidStack(Phthalic_Acid, 500); + FluidStack aGtAcid = FluidUtils.getFluidStack("phtalicacid", 500); + if (aMyAcid != null && aGtAcid != null) { + CORE.RA.addDistilleryRecipe(CI.getNumberedBioCircuit(8), aMyAcid, aGtAcid, null, 50, 16, false); + CORE.RA.addDistilleryRecipe(CI.getNumberedBioCircuit(9), aGtAcid, aMyAcid, null, 50, 16, false); + } + } + + @Override + public void items() { + // Phthalic_Acid = FluidUtils.generateFluidNonMolten("PhthalicAcid", "Phthalic Acid", 207, new short[]{210, 220, + // 210, 100}, null, null); + // v - Dehydrate at 180C+ + // Create Phthalic Anhydride + ItemUtils.generateSpecialUseDusts( + "PhthalicAnhydride", "Phthalic Anhydride", "C6H4(CO)2O", Utils.rgbtoHexValue(175, 175, 175)); + + // Lithium Hydroperoxide - LiOH + H2O2 → LiOOH + 2 H2O + ItemUtils.generateSpecialUseDusts( + "LithiumHydroperoxide", "Lithium Hydroperoxide", "HLiO2", Utils.rgbtoHexValue(125, 125, 125)); + // v - Dehydrate + // Lithium Peroxide - 2 LiOOH → Li2O2 + H2O2 + 2 H2O + // Lithium_Peroxide = FluidUtils.generateFluidNonMolten("LithiumPeroxide", "Lithium Peroxide", 446, new + // short[]{135, 135, 135, 100}, null, null); + } + + @Override + public void blocks() {} + + @Override + public void fluids() { + + // Create Coal Gas + Coal_Gas = FluidUtils.generateFluidNonMolten( + "CoalGas", "Coal Gas", 500, new short[] {48, 48, 48, 100}, null, null); + // Ethanol + // v - Dehydrate cells to remove water + + // Create Ethylene + if (!FluidUtils.doesFluidExist("ethylene")) { + Ethylene = FluidUtils.generateFluidNonMolten( + "ethylene", "Ethylene", -103, new short[] {255, 255, 255, 100}, null, null); + } else { + Ethylene = FluidUtils.getWildcardFluidStack("ethylene", 1).getFluid(); + } + + // Create Ethylbenzene - Ethylbenzene is produced in on a large scale by combining benzene and ethylene in an + // acid-catalyzed chemical reaction + // Use Chemical Reactor + Ethylbenzene = FluidUtils.generateFluidNonMolten( + "Ethylbenzene", "Ethylbenzene", 136, new short[] {255, 255, 255, 100}, null, null); + // Create Anthracene + Anthracene = FluidUtils.generateFluidNonMolten( + "Anthracene", "Anthracene", 340, new short[] {255, 255, 255, 100}, null, null); + // Toluene + if (!FluidUtils.doesFluidExist("liquid_toluene")) { + Toluene = FluidUtils.generateFluidNonMolten( + "liquid_toluene", "Toluene", -95, new short[] {140, 70, 20, 100}, null, null); + } else { + Toluene = FluidUtils.getWildcardFluidStack("liquid_toluene", 1).getFluid(); + } + + // Create Coal Tar + Coal_Tar = FluidUtils.generateFluidNonMolten( + "CoalTar", "Coal Tar", 450, new short[] {32, 32, 32, 100}, null, null); + // v - Distill (60% Tar oil/15% Naphtha/20% Ethylbenzene/5% Anthracene) + // Create Coal Tar Oil + Coal_Tar_Oil = FluidUtils.generateFluidNonMolten( + "CoalTarOil", "Coal Tar Oil", 240, new short[] {240, 240, 150, 100}, null, null); + // v - Wash With Sulfuric Acid + // Create Sulfuric Coal Tar Oil + Sulfuric_Coal_Tar_Oil = FluidUtils.generateFluidNonMolten( + "SulfuricCoalTarOil", "Sulfuric Coal Tar Oil", 240, new short[] {250, 170, 12, 100}, null, null); + // v - Distill (No loss, just time consuming) + // Create Naphthalene + Naphthalene = FluidUtils.generateFluidNonMolten( + "Naphthalene", "Naphthalene", 115, new short[] {210, 185, 135, 100}, null, null); + // v - Oxidize with mercury and nitric acid + // Create Phthalic Acid + Phthalic_Acid = FluidUtils.generateFluidNonMolten( + "PhthalicAcid", "Phthalic Acid", 207, new short[] {210, 220, 210, 100}, null, null); + // v - Dehydrate at 180C+ + // Create Phthalic Anhydride + // ItemUtils.generateSpecialUseDusts("PhthalicAnhydride", "Phthalic Anhydride", "C6H4(CO)2O", + // Utils.rgbtoHexValue(175, 175, 175)); + } } diff --git a/src/main/java/gtPlusPlus/core/item/chemistry/GenericChem.java b/src/main/java/gtPlusPlus/core/item/chemistry/GenericChem.java index 66e3949aed..e8069b8903 100644 --- a/src/main/java/gtPlusPlus/core/item/chemistry/GenericChem.java +++ b/src/main/java/gtPlusPlus/core/item/chemistry/GenericChem.java @@ -24,1149 +24,1225 @@ import net.minecraftforge.fluids.*; public class GenericChem extends ItemPackage { - /** - * Switches - */ - - private static boolean usingGregtechNitricOxide = false; - private static boolean usingGregtechNitrogenDioxide = false; - private static boolean usingGregtechHydricSulfur = false; - - /** - * Materials - */ - - //public static final Material BAKELITE = new Material("Bakelite", MaterialState.SOLID, TextureSet.SET_DULL, new short[]{90, 140, 140}, 120, 240, 23, 24, true, null, 0);//Not a GT Inherited Material - //public static final Material NYLON = new Material("Nylon", MaterialState.SOLID, TextureSet.SET_SHINY, new short[]{45, 45, 45}, 300, 600, 44, 48, true, null, 0);//Not a GT Inherited Material - //public static final Material CARBYNE = new Material("Carbyne", MaterialState.SOLID, TextureSet.SET_DULL, new short[]{25, 25, 25}, 2500, 5000, 63, 52, true, null, 0);//Not a GT Inherited Material - - - //Refined PTFE - public static final Material TEFLON = new Material( - "Teflon", - MaterialState.SOLID, - TextureSet.SET_SHINY, - new short[] { 75, 45, 75 }, - 330, 640, - -1, -1, - false, - null, - 0, - new MaterialStack(NONMATERIAL.PTFE, 75), - new MaterialStack(NONMATERIAL.PLASTIC, 15), - new MaterialStack(ELEMENT.getInstance().CARBON, 5), - new MaterialStack(ELEMENT.getInstance().SODIUM, 5)); - - /** - * Fluids - */ - - public static Fluid Benzene; - public static Fluid NitroBenzene; - public static Fluid Aniline; - public static Fluid Polyurethane; - public static Fluid Phenol; //https://en.wikipedia.org/wiki/Phenol#Uses - public static Fluid Cyclohexane; //https://en.wikipedia.org/wiki/Cyclohexane - public static Fluid Cyclohexanone; //https://en.wikipedia.org/wiki/Cyclohexanone - public static Fluid Cadaverine; //https://en.wikipedia.org/wiki/Cadaverine - public static Fluid Putrescine; //https://en.wikipedia.org/wiki/Putrescine - public static Fluid BoricAcid; - public static Fluid HydrochloricAcid; - - - public static Fluid Ethylanthraquinone2; - public static Fluid Ethylanthrahydroquinone2; - public static Fluid Hydrogen_Peroxide; - public static Fluid Lithium_Peroxide; - public static Fluid Nitric_Oxide; - public static Fluid Nitrogen_Dioxide; - public static Fluid Carbon_Disulfide; - public static Fluid Hydrogen_Sulfide; - - /** - * Items - */ - - // Phenol Byproducts - public Item PhenolicResins; //https://en.wikipedia.org/wiki/Phenol_formaldehyde_resin - public static ItemGenericChemBase mGenericChemItem1; - public static Item mAdvancedCircuit; - - private ItemStack mCatalystCarrier; - - public static ItemStack mRedCatalyst; - public static ItemStack mYellowCatalyst; - public static ItemStack mBlueCatalyst; - public static ItemStack mOrangeCatalyst; - public static ItemStack mPurpleCatalyst; - public static ItemStack mBrownCatalyst; - public static ItemStack mPinkCatalyst; - public static ItemStack mFormaldehydeCatalyst; - public static ItemStack mSolidAcidCatalyst; - public static ItemStack mInfiniteMutationCatalyst; - - public static ItemStack mMillingBallAlumina; - public static ItemStack mMillingBallSoapstone; - - public static ItemStack mSodiumEthoxide; - public static ItemStack mSodiumEthylXanthate; - public static ItemStack mPotassiumEthylXanthate; - public static ItemStack mPotassiumHydroxide; - - - - @Override - public void items() { - PhenolicResins = ItemUtils.generateSpecialUseDusts("phenolicresins", "Phenolic Resin", "HOC6H4CH2OH", Utils.rgbtoHexValue(80, 40, 40))[0]; - //MaterialGenerator.generate(BAKELITE, false); - //MaterialGenerator.generate(NYLON, false); - MaterialGenerator.generate(TEFLON, false); - - mGenericChemItem1 = new ItemGenericChemBase(); - mAdvancedCircuit = new ItemAdvancedChip(); - GregtechItemList.Circuit_T3RecipeSelector.set(mAdvancedCircuit); - - registerItemStacks(); - registerOreDict(); - - GregtechItemList.Milling_Ball_Alumina.set(mMillingBallAlumina); - GregtechItemList.Milling_Ball_Soapstone.set(mMillingBallSoapstone); - - } - - - public void registerItemStacks() { - - mCatalystCarrier = ItemUtils.simpleMetaStack(AgriculturalChem.mAgrichemItem1, 13, 1); - - mRedCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 0, 1); - mYellowCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 1, 1); - mBlueCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 2, 1); - mOrangeCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 3, 1); - mPurpleCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 4, 1); - mBrownCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 5, 1); - mPinkCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 6, 1); - mMillingBallAlumina = ItemUtils.simpleMetaStack(mGenericChemItem1, 7, 1); - mMillingBallSoapstone = ItemUtils.simpleMetaStack(mGenericChemItem1, 8, 1); - mSodiumEthoxide = ItemUtils.simpleMetaStack(mGenericChemItem1, 9, 1); - mSodiumEthylXanthate = ItemUtils.simpleMetaStack(mGenericChemItem1, 10, 1); - mPotassiumEthylXanthate = ItemUtils.simpleMetaStack(mGenericChemItem1, 11, 1); - mPotassiumHydroxide = ItemUtils.simpleMetaStack(mGenericChemItem1, 12, 1); - mFormaldehydeCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 13, 1); - mSolidAcidCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 14, 1); - mInfiniteMutationCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 15, 1); - - - } - - public void registerOreDict() { - - ItemUtils.addItemToOreDictionary(mRedCatalyst, "catalystIronCopper"); - ItemUtils.addItemToOreDictionary(mYellowCatalyst, "catalystTungstenNickel"); - ItemUtils.addItemToOreDictionary(mBlueCatalyst, "catalystCobaltTitanium"); - ItemUtils.addItemToOreDictionary(mOrangeCatalyst, "catalystVanadiumPalladium"); - ItemUtils.addItemToOreDictionary(mPurpleCatalyst, "catalystIridiumRuthenium"); - ItemUtils.addItemToOreDictionary(mBrownCatalyst, "catalystNickelAluminium"); - ItemUtils.addItemToOreDictionary(mPinkCatalyst, "catalystPlatinumRhodium"); - ItemUtils.addItemToOreDictionary(mMillingBallAlumina, "millingballAlumina"); - ItemUtils.addItemToOreDictionary(mMillingBallSoapstone, "millingballSoapstone"); - ItemUtils.addItemToOreDictionary(mSodiumEthoxide, "dustSodiumEthoxide"); - ItemUtils.addItemToOreDictionary(mSodiumEthylXanthate, "dustSodiumEthylXanthate"); - ItemUtils.addItemToOreDictionary(mPotassiumEthylXanthate, "dustPotassiumEthylXanthate"); - ItemUtils.addItemToOreDictionary(mPotassiumHydroxide, "dustPotassiumHydroxide"); - ItemUtils.addItemToOreDictionary(mFormaldehydeCatalyst, "catalystFormaldehyde"); - ItemUtils.addItemToOreDictionary(mSolidAcidCatalyst, "catalystSolidAcid"); - ItemUtils.addItemToOreDictionary(mInfiniteMutationCatalyst, "catalystInfiniteMutation"); - - } - - @Override - public void blocks() {} - - @Override - public void fluids() { - - if (!FluidRegistry.isFluidRegistered("benzene")) { - Benzene = FluidUtils.generateFluidNoPrefix("benzene", "Benzene", 278, new short[] { 100, 70, 30, 100 }, true); - } - else { - Benzene = FluidRegistry.getFluid("benzene"); - } - - NitroBenzene = FluidUtils.generateFluidNoPrefix("nitrobenzene", "Nitrobenzene", 278, new short[] { 70, 50, 40, 100 }, true); - - Aniline = FluidUtils.generateFluidNoPrefix("aniline", "Aniline", 266, new short[] { 100, 100, 30, 100 }, true); - - BoricAcid = FluidUtils.generateFluidNoPrefix("boricacid", "Boric Acid", 278, new short[] { 90, 30, 120, 100 }, true); - - Polyurethane = FluidUtils.generateFluidNoPrefix("polyurethane", "Polyurethane", 350, new short[] { 100, 70, 100, 100 }, true); - - if (!FluidRegistry.isFluidRegistered("phenol")) { - Phenol = FluidUtils.generateFluidNoPrefix("phenol", "Phenol", 313, new short[] { 100, 70, 30, 100 }, true); - } - else { - Phenol = FluidRegistry.getFluid("phenol"); - } - - // Use GT's if it exists, else make our own. - if (FluidRegistry.isFluidRegistered("hydrochloricacid_gt5u")) { - HydrochloricAcid = FluidRegistry.getFluid("hydrochloricacid_gt5u"); - } - else { - HydrochloricAcid = FluidUtils.generateFluidNoPrefix("hydrochloricacid", "Hydrochloric Acid", 285, new short[] { 183, 200, 196, 100 }, true); - } - - Cyclohexane = FluidUtils.generateFluidNoPrefix("cyclohexane", "Cyclohexane", 32 + 175, new short[] { 100, 70, 30, 100 }, true); - Cyclohexanone = FluidUtils.generateFluidNoPrefix("cyclohexanone", "Cyclohexanone", 32 + 175, new short[] { 100, 70, 30, 100 }, true); - - Cadaverine = FluidUtils.generateFluidNoPrefix("cadaverine", "Cadaverine", 32 + 175, new short[] { 100, 70, 30, 100 }, true); - Putrescine = FluidUtils.generateFluidNoPrefix("putrescine", "Putrescine", 32 + 175, new short[] { 100, 70, 30, 100 }, true); - - //Create 2-Ethylanthraquinone - //2-Ethylanthraquinone is prepared from the reaction of phthalic anhydride and ethylbenzene - Ethylanthraquinone2 = FluidUtils.generateFluidNonMolten("2Ethylanthraquinone", "2-Ethylanthraquinone", 415, new short[]{227, 255, 159, 100}, null, null); - //Create 2-Ethylanthrahydroquinone - //Palladium plate + Hydrogen(250) + 2-Ethylanthraquinone(500) = 600 Ethylanthrahydroquinone - Ethylanthrahydroquinone2 = FluidUtils.generateFluidNonMolten("2Ethylanthrahydroquinone", "2-Ethylanthrahydroquinone", 415, new short[]{207, 225, 129, 100}, null, null); - //Create Hydrogen Peroxide - //Compressed Air(1500) + Ethylanthrahydroquinone(500) + Anthracene(5) = 450 Ethylanthraquinone && 200 Peroxide - Hydrogen_Peroxide = FluidUtils.generateFluidNonMolten("HydrogenPeroxide", "Hydrogen Peroxide", 150, new short[]{210, 255, 255, 100}, null, null); - - if (FluidRegistry.isFluidRegistered("nitricoxide")) { - Nitric_Oxide = FluidRegistry.getFluid("nitricoxide"); - usingGregtechNitricOxide = true; - } - else { - Nitric_Oxide = FluidUtils.generateFluidNoPrefix("nitricoxide", "Nitric Oxide", 200, new short[] {125, 200, 240, 100}); - } - if (FluidRegistry.isFluidRegistered("nitrogendioxide")) { - Nitrogen_Dioxide = FluidRegistry.getFluid("nitrogendioxide"); - usingGregtechNitrogenDioxide = true; - } - else { - Nitrogen_Dioxide = FluidUtils.generateFluidNoPrefix("nitrogendioxide", "Nitrogen Dioxide", 200, new short[] {100, 175, 255, 100}); - } - - - - //Lithium Hydroperoxide - LiOH + H2O2 → LiOOH + 2 H2O - //ItemUtils.generateSpecialUseDusts("LithiumHydroperoxide", "Lithium Hydroperoxide", "HLiO2", Utils.rgbtoHexValue(125, 125, 125)); - // v - Dehydrate - //Lithium Peroxide - 2 LiOOH → Li2O2 + H2O2 + 2 H2O - Lithium_Peroxide = FluidUtils.generateFluidNonMolten("LithiumPeroxide", "Lithium Peroxide", 446, new short[]{135, 135, 135, 100}, null, null); - - Carbon_Disulfide = FluidUtils.generateFluidNoPrefix("CarbonDisulfide", "Carbon Disulfide", 350, new short[]{175, 175, 175, 100}); - - if (FluidRegistry.isFluidRegistered("fluid.liquid_hydricsulfur") || MaterialUtils.doesMaterialExist("HydricSulfide")) { - usingGregtechHydricSulfur = true; - Fluid aFluid = null; - if (ItemUtils.doesItemListEntryExist("sHydricSulfur")) { - ItemStack aListItem = ItemUtils.getValueOfItemList("sHydricSulfur", 1, (ItemList) null); - if (aListItem != null) { - FluidStack aFluidStack = FluidContainerRegistry.getFluidForFilledItem(aListItem); - if (aFluidStack != null) { - aFluid = aFluidStack.getFluid(); - } - - } - } - if (aFluid == null) { - aFluid = FluidUtils.getWildcardFluidStack("liquid_hydricsulfur", 1000).getFluid(); - } - Hydrogen_Sulfide = aFluid; - } - else { - Hydrogen_Sulfide = FluidUtils.generateFluidNoPrefix("HydrogenSulfide", "Hydrogen Sulfide", 446, new short[]{240, 130, 30, 100}); - } - - } - - @Override - public String errorMessage() { - return "Failed to generate recipes for GenericChem."; - } - - @Override - public boolean generateRecipes() { - - recipeAdvancedChip(); - recipeCatalystRed(); - recipeCatalystYellow(); - recipeCatalystBlue(); - recipeCatalystOrange(); - recipeCatalystPurple(); - recipeCatalystBrown(); - recipeCatalystPink(); - recipeCatalystFormaldehyde(); - recipeCatalystSolidAcid(); - recipeCatalystInfiniteMutation(); - - recipeGrindingBallAlumina(); - recipeGrindingBallSoapstone(); - - recipeNitroBenzene(); - recipeAniline(); - recipeCadaverineAndPutrescine(); - recipeCyclohexane(); - recipeCyclohexanone(); - - recipe2Ethylanthraquinone(); - recipe2Ethylanthrahydroquinone(); - recipeHydrogenPeroxide(); - recipeLithiumHydroperoxide(); - recipeLithiumPeroxide(); - //The follow is using alk science, ignore them - if (!usingGregtechNitricOxide) { - recipeNitricOxide(); - } - if (!usingGregtechNitrogenDioxide) { - recipeNitrogenDioxide(); - } - if (!usingGregtechHydricSulfur) { - recipeHydricSulfur(); - } - - // Add recipes if we are not using GT's fluid. - if (!FluidRegistry.isFluidRegistered("hydrochloricacid_gt5u")) { - recipeHydrochloricAcid(); - } - - recipeSodiumEthoxide(); - recipeCarbonDisulfide(); - recipeEthylXanthates(); - recipePotassiumHydroxide(); - - recipeMutatedLivingSolder(); - - registerFuels(); - - return true; - } - - - private void recipeSodiumEthoxide() { - //C2H5OH + Na → C2H5ONa + H - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedCircuit(16), - ELEMENT.getInstance().SODIUM.getDust(1) - }, - new FluidStack[] { - Materials.Ethanol.getFluid(1000) - }, - new ItemStack[] { - ItemUtils.getSimpleStack(mSodiumEthoxide, 9) - }, - new FluidStack[] { - ELEMENT.getInstance().HYDROGEN.getFluidStack(1000) - }, - 20 *20, - 120, - 2); - } - - private void recipePotassiumHydroxide() { - //Ca(OH)2 + K2O + CO2 → CaCO3 + 2 KOH - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedCircuit(18), - Materials.Potash.getDust(3), - ItemUtils.getItemStackOfAmountFromOreDict("dustCalciumHydroxide", 5), - }, - new FluidStack[] { - Materials.CarbonDioxide.getGas(1000) - }, - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("dustCalciumCarbonate", 5), - ItemUtils.getSimpleStack(mPotassiumHydroxide, 6) - - }, - new FluidStack[] { - - }, - 20 *30, - 120, - 2); - - } - - - private void recipeEthylXanthates() { - - //Potassium ethyl xanthate - CH3CH2OH + CS2 + KOH → C3H5KOS2 + H2O - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedCircuit(17), - ItemUtils.getSimpleStack(mPotassiumHydroxide, 3), - }, - new FluidStack[] { - Materials.Ethanol.getFluid(1000), - FluidUtils.getFluidStack(Carbon_Disulfide, 1000), - }, - new ItemStack[] { - ItemUtils.getSimpleStack(mPotassiumEthylXanthate, 12) - }, - new FluidStack[] { - FluidUtils.getWater(1000) - }, - 20 *60, - 120, - 4); - - //Sodium ethyl xanthate - CH3CH2ONa + CS2 → CH3CH2OCS2Na - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedCircuit(17), - ItemUtils.getSimpleStack(mSodiumEthoxide, 9) - }, - new FluidStack[] { - FluidUtils.getFluidStack(Carbon_Disulfide, 1000), - }, - new ItemStack[] { - ItemUtils.getSimpleStack(mSodiumEthylXanthate, 12) - }, - new FluidStack[] { - - }, - 20 *60, - 120, - 4); - - } - - //The follow is using alk science, ignore them - private void recipeHydricSulfur() { - - ItemStack aCellHydricSulfide = ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogenSulfide", 1); - GT_Values.RA.addChemicalRecipe( ELEMENT.getInstance().SULFUR.getDust(1), GT_Utility.getIntegratedCircuit(1), ELEMENT.getInstance().HYDROGEN.getFluidStack(2000), FluidUtils.getFluidStack(Hydrogen_Sulfide, 3000), GT_Values.NI, 60, 8); - GT_Values.RA.addChemicalRecipeForBasicMachineOnly(ELEMENT.getInstance().SULFUR.getDust(1), CI.emptyCells(3), ELEMENT.getInstance().HYDROGEN.getFluidStack(2000), GT_Values.NF, ItemUtils.getSimpleStack(aCellHydricSulfide, 3), GT_Values.NI, 60, 8); - - } - - - private void recipeCarbonDisulfide() { - - CORE.RA.addBlastRecipe( - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("fuelCoke", 8), - ItemUtils.getItemStackOfAmountFromOreDict("dustSulfur", 16) - }, - new FluidStack[] { - - }, - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("dustDarkAsh", 1) - }, - new FluidStack[] { - FluidUtils.getFluidStack(Carbon_Disulfide, 4000) - }, - 20 *60 * 10, - 30, - 1500); - - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedCircuit(20), - ItemUtils.getSimpleStack(mBrownCatalyst, 0), - ItemUtils.getItemStackOfAmountFromOreDict("dustSulfur", 4) - }, - new FluidStack[] { - FluidUtils.getFluidStack(CoalTar.Coal_Gas, 1000), - }, - new ItemStack[] { - - }, - new FluidStack[] { - FluidUtils.getFluidStack(Carbon_Disulfide, 2000) - }, - 20 *60 * 5, - 30, - 2); - } - - private void recipeMutatedLivingSolder() { - - //Endgame soldering alloy meant for the bioware circuit line and beyond. - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - ItemUtils.getSimpleStack(GenericChem.mInfiniteMutationCatalyst, 0), - ItemList.Circuit_Chip_Biocell.get(64), - ItemList.Gravistar.get(8), - Materials.InfinityCatalyst.getDust(2) - - }, - new FluidStack[] { - FluidUtils.getFluidStack("plasma.tin", 18000), - FluidUtils.getFluidStack("plasma.bismuth", 18000), - FluidUtils.getFluidStack("cryotheum", 4000) - }, - new ItemStack[] { - - }, - new FluidStack[] { - MISC_MATERIALS.MUTATED_LIVING_SOLDER.getFluidStack(144 * 280) - }, - 20*800, - 3842160, - 7); - - } - - - private static void registerFuels() { - - // Burnables - - // Gas Fuels - GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellNitrobenzene", 1), null, 1600, 1); - - } - - private void recipeGrindingBallAlumina() { - CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - CI.getNumberedCircuit(10), - ItemUtils.getSimpleStack(AgriculturalChem.mAlumina, 64) - }, - FluidUtils.getFluidStack(GenericChem.Aniline, 4000), - ItemUtils.getSimpleStack(mMillingBallAlumina, 8), - 180 * 20, - 480); - } - private void recipeGrindingBallSoapstone() { - CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - CI.getNumberedCircuit(10), - ItemUtils.getItemStackOfAmountFromOreDict("dustSoapstone", 32) - }, - FluidUtils.getFluidStack(AgrichemFluids.mLiquidResin, 2500), - ItemUtils.getSimpleStack(mMillingBallSoapstone, 8), - 120 * 20, - 480); - } - - //The follow is using alk science, ignore them - private void recipeNitrogenDioxide() { - ItemStack aNitricOxideCell = ItemUtils.getItemStackOfAmountFromOreDict("cellNitricOxide", 1); - ItemStack aNitrogenDioxideCell = ItemUtils.getItemStackOfAmountFromOreDict("cellNitrogenDioxide", 1); - GT_Values.RA.addChemicalRecipe( ItemUtils.getSimpleStack(aNitricOxideCell, 2), GT_Utility.getIntegratedCircuit(1), ELEMENT.getInstance().OXYGEN.getFluidStack(1000), FluidUtils.getFluidStack(Nitrogen_Dioxide, 3000), CI.emptyCells(2), 160); - GT_Values.RA.addChemicalRecipe( ELEMENT.getInstance().OXYGEN.getCell(1), GT_Utility.getIntegratedCircuit(1), FluidUtils.getFluidStack(Nitric_Oxide, 2000), FluidUtils.getFluidStack(Nitrogen_Dioxide, 3000), CI.emptyCells(1), 160); - GT_Values.RA.addChemicalRecipeForBasicMachineOnly(ItemUtils.getSimpleStack(aNitricOxideCell, 2), CI.emptyCells(1), ELEMENT.getInstance().OXYGEN.getFluidStack(1000), GT_Values.NF, ItemUtils.getSimpleStack(aNitrogenDioxideCell, 3), GT_Values.NI, 160, 30); - GT_Values.RA.addChemicalRecipeForBasicMachineOnly(ELEMENT.getInstance().OXYGEN.getCell(1), CI.emptyCells(2), FluidUtils.getFluidStack(Nitric_Oxide, 2000), GT_Values.NF, ItemUtils.getSimpleStack(aNitrogenDioxideCell, 3), GT_Values.NI, 160, 30); - GT_Values.RA.addChemicalRecipeForBasicMachineOnly(ItemUtils.getSimpleStack(aNitricOxideCell, 2), ELEMENT.getInstance().OXYGEN.getCell(1), GT_Values.NF, GT_Values.NF, ItemUtils.getSimpleStack(aNitrogenDioxideCell, 3), GT_Values.NI, 160, 30); - } - - //The follow is using alk science, ignore them - private void recipeNitricOxide() { - ItemStack aWaterCell = ItemUtils.getItemStackOfAmountFromOreDict("cellWater", 1); - ItemStack aNitricOxideCell = ItemUtils.getItemStackOfAmountFromOreDict("cellNitricOxide", 1); - GT_Values.RA.addChemicalRecipeForBasicMachineOnly(MISC_MATERIALS.AMMONIA.getCell(8), CI.emptyCells(1), ELEMENT.getInstance().OXYGEN.getFluidStack(5000), FluidUtils.getFluidStack(Nitric_Oxide, 4000), ItemUtils.getSimpleStack(aWaterCell, 9), GT_Values.NI, 160, 30); - GT_Values.RA.addChemicalRecipeForBasicMachineOnly(ELEMENT.getInstance().OXYGEN.getCell(5), CI.emptyCells(4), MISC_MATERIALS.AMMONIA.getFluidStack(8000), FluidUtils.getFluidStack(Nitric_Oxide, 4000), ItemUtils.getSimpleStack(aWaterCell, 9), GT_Values.NI, 160, 30); - GT_Values.RA.addChemicalRecipe( MISC_MATERIALS.AMMONIA.getCell(8), GT_Utility.getIntegratedCircuit(11), ELEMENT.getInstance().OXYGEN.getFluidStack(5000), FluidUtils.getWater(9000), ItemUtils.getSimpleStack(aNitricOxideCell, 4), CI.emptyCells(4), 160); - GT_Values.RA.addChemicalRecipe( ELEMENT.getInstance().OXYGEN.getCell(5), GT_Utility.getIntegratedCircuit(11), MISC_MATERIALS.AMMONIA.getFluidStack(8000), FluidUtils.getWater(9000), ItemUtils.getSimpleStack(aNitricOxideCell, 4), CI.emptyCells(1), 160); - GT_Values.RA.addChemicalRecipe( MISC_MATERIALS.AMMONIA.getCell(8), GT_Utility.getIntegratedCircuit(2), ELEMENT.getInstance().OXYGEN.getFluidStack(5000), FluidUtils.getFluidStack(Nitric_Oxide, 4000), CI.emptyCells(8), 320); - GT_Values.RA.addChemicalRecipe( ELEMENT.getInstance().OXYGEN.getCell(5), GT_Utility.getIntegratedCircuit(2), MISC_MATERIALS.AMMONIA.getFluidStack(8000), FluidUtils.getFluidStack(Nitric_Oxide, 4000), CI.emptyCells(5), 320); - GT_Values.RA.addChemicalRecipe( MISC_MATERIALS.AMMONIA.getCell(8), GT_Utility.getIntegratedCircuit(12), ELEMENT.getInstance().OXYGEN.getFluidStack(5000), GT_Values.NF, ItemUtils.getSimpleStack(aNitricOxideCell, 4), CI.emptyCells(4), 160); - GT_Values.RA.addChemicalRecipe( ELEMENT.getInstance().OXYGEN.getCell(5), GT_Utility.getIntegratedCircuit(12), MISC_MATERIALS.AMMONIA.getFluidStack(8000), GT_Values.NF, ItemUtils.getSimpleStack(aNitricOxideCell, 4), CI.emptyCells(1), 160); - GT_Values.RA.addChemicalRecipeForBasicMachineOnly(MISC_MATERIALS.AMMONIA.getCell(8), ELEMENT.getInstance().OXYGEN.getCell(5), GT_Values.NF, GT_Values.NF, ItemUtils.getSimpleStack(aNitricOxideCell, 4), ItemUtils.getSimpleStack(aWaterCell, 9), 160, 30); - GT_Values.RA.addMultiblockChemicalRecipe(new ItemStack[]{GT_Utility.getIntegratedCircuit(1)}, new FluidStack[]{MISC_MATERIALS.AMMONIA.getFluidStack(8000), ELEMENT.getInstance().OXYGEN.getFluidStack(5000)}, new FluidStack[]{FluidUtils.getFluidStack(Nitric_Oxide, 4000), FluidUtils.getWater(9000)}, null, 160, 30); - } - - //The follow is using alk science, ignore them - private void recipeHydrochloricAcid() { - - ItemStack aAcidCell = ItemUtils.getItemStackOfAmountFromOreDict("cellHydrochloricAcid", 1); - - CORE.RA.addChemicalRecipe( - ELEMENT.getInstance().CHLORINE.getCell(1), - GT_Utility.getIntegratedCircuit(1), - ELEMENT.getInstance().HYDROGEN.getFluidStack(1000), - FluidUtils.getFluidStack(HydrochloricAcid, 2000), - CI.emptyCells(1), - 60, - 8); - - CORE.RA.addChemicalRecipe( - ELEMENT.getInstance().HYDROGEN.getCell(1), - GT_Utility.getIntegratedCircuit(1), - ELEMENT.getInstance().CHLORINE.getFluidStack(1000), - FluidUtils.getFluidStack(HydrochloricAcid, 2000), - CI.emptyCells(1), - 60, - 8); - - GT_Values.RA.addElectrolyzerRecipe( - CI.emptyCells(1), - GT_Utility.getIntegratedCircuit(1), - FluidUtils.getFluidStack(HydrochloricAcid, 2000), - ELEMENT.getInstance().CHLORINE.getFluidStack(1000), - ELEMENT.getInstance().HYDROGEN.getCell(1), - GT_Values.NI, - GT_Values.NI, - GT_Values.NI, - GT_Values.NI, - GT_Values.NI, - null, - 720, - 30); - - GT_Values.RA.addElectrolyzerRecipe( - CI.emptyCells(1), - GT_Utility.getIntegratedCircuit(11), - FluidUtils.getFluidStack(HydrochloricAcid, 2000), - ELEMENT.getInstance().HYDROGEN.getFluidStack(1000), - ELEMENT.getInstance().CHLORINE.getCell(1), - GT_Values.NI, - GT_Values.NI, - GT_Values.NI, - GT_Values.NI, - GT_Values.NI, - null, - 720, - 30); - - GT_Values.RA.addElectrolyzerRecipe( - ItemUtils.getSimpleStack(aAcidCell, 2), - GT_Values.NI, - GT_Values.NF, - GT_Values.NF, - ELEMENT.getInstance().HYDROGEN.getCell(1), - ELEMENT.getInstance().CHLORINE.getCell(1), - GT_Values.NI, - GT_Values.NI, - GT_Values.NI, - GT_Values.NI, - null, - 720, - 30); - } - - private void recipeCyclohexane() { - - //C6H6 + 6H = C6H12 - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - getTierTwoChip(), - ItemUtils.getSimpleStack(mBrownCatalyst, 0) - }, - new FluidStack[] { - FluidUtils.getFluidStack(Benzene, 1000), - FluidUtils.getFluidStack("hydrogen", 6000) - }, - new ItemStack[] { - - }, - new FluidStack[] { - FluidUtils.getFluidStack(Cyclohexane, 1000), - }, - 20 * 120, - 120, - 2); - - } - - private void recipeCyclohexanone() { - - //C6H12 + 2O(Air) = C6H10O + H2O - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - getTierTwoChip(), - ItemUtils.getSimpleStack(mBlueCatalyst, 0) - }, - new FluidStack[] { - FluidUtils.getFluidStack(Cyclohexane, 1000), - FluidUtils.getFluidStack("air", 4000) - }, - new ItemStack[] { - - }, - new FluidStack[] { - FluidUtils.getFluidStack(Cyclohexanone, 1000), - }, - 20 * 120, - 120, - 2); - - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - getTierTwoChip(), - }, - new FluidStack[] { - FluidUtils.getFluidStack(Cyclohexane, 1000), - FluidUtils.getFluidStack("oxygen", 2000) - }, - new ItemStack[] { - - }, - new FluidStack[] { - FluidUtils.getFluidStack(Cyclohexanone, 1000), - }, - 20 * 120, - 120, - 2); - - } - - private void recipeCatalystRed() { - // Assembly Recipe - CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - getTierOneChip(), - CI.getEmptyCatalyst(10), - ELEMENT.getInstance().IRON.getDust(2), - ELEMENT.getInstance().COPPER.getDust(2), - }, - GT_Values.NF, - ItemUtils.getSimpleStack(mRedCatalyst, 10), - 20 * 20, - 30); - - } - - private void recipeCatalystYellow() { - // Assembly Recipe - CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - getTierThreeChip(), - CI.getEmptyCatalyst(10), - ELEMENT.getInstance().TUNGSTEN.getDust(4), - ELEMENT.getInstance().NICKEL.getDust(4), - }, - GT_Values.NF, - ItemUtils.getSimpleStack(mYellowCatalyst, 10), - 60 * 20, - 2000); - - } - - private void recipeCatalystBlue() { - // Assembly Recipe - CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - getTierTwoChip(), - CI.getEmptyCatalyst(10), - ELEMENT.getInstance().COBALT.getDust(3), - ELEMENT.getInstance().TITANIUM.getDust(3), - }, - GT_Values.NF, - ItemUtils.getSimpleStack(mBlueCatalyst, 10), - 40 * 20, - 500); - - } - - private void recipeCatalystOrange() { - // Assembly Recipe - CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - getTierTwoChip(), - CI.getEmptyCatalyst(10), - ELEMENT.getInstance().VANADIUM.getDust(5), - ELEMENT.getInstance().PALLADIUM.getDust(5), - }, - GT_Values.NF, - ItemUtils.getSimpleStack(mOrangeCatalyst, 10), - 40 * 20, - 500); - - } - - private void recipeCatalystPurple() { - // Assembly Recipe - CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - getTierFourChip(), - CI.getEmptyCatalyst(10), - ELEMENT.getInstance().IRIDIUM.getDust(6), - ELEMENT.getInstance().RUTHENIUM.getDust(6), - }, - GT_Values.NF, - ItemUtils.getSimpleStack(mPurpleCatalyst, 10), - 120 * 20, - 8000); - - } - - private void recipeCatalystBrown() { - // Assembly Recipe - CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - getTierOneChip(), - CI.getEmptyCatalyst(10), - ELEMENT.getInstance().NICKEL.getDust(4), - ELEMENT.getInstance().ALUMINIUM.getDust(4), - }, - GT_Values.NF, - ItemUtils.getSimpleStack(mBrownCatalyst, 10), - 15 * 20, - 30); - - } - - private void recipeCatalystPink() { - // Assembly Recipe - CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - getTierThreeChip(), - CI.getEmptyCatalyst(10), - ELEMENT.getInstance().PLATINUM.getDust(4), - ELEMENT.getInstance().RHODIUM.getDust(4), - }, - GT_Values.NF, - ItemUtils.getSimpleStack(mPinkCatalyst, 10), - 30 * 20, - 2000); - - } - - private void recipeCatalystFormaldehyde() { - // Assembly Recipe - CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - getTierThreeChip(), - CI.getEmptyCatalyst(4), - ItemUtils.getSimpleStack(RocketFuels.Formaldehyde_Catalyst_Dust, 8) - }, - GT_Values.NF, - ItemUtils.getSimpleStack(mFormaldehydeCatalyst, 4), - 30 * 20, - 240); - - } - - private void recipeCatalystSolidAcid() { - // Assembly Recipe - CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - getTierThreeChip(), - CI.getEmptyCatalyst(5), - ItemUtils.getItemStackOfAmountFromOreDict("dustLapis", 2) - }, - MISC_MATERIALS.SOLID_ACID_MIXTURE.getFluidStack(1000), - ItemUtils.getSimpleStack(GenericChem.mSolidAcidCatalyst, 5), - 30 * 20, - 2000); - - } - - private void recipeCatalystInfiniteMutation() { - // Assembly Recipe - CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - getTierThreeChip(), - CI.getEmptyCatalyst(5), - Materials.Infinity.getDust(1), - Materials.Naquadria.getDust(10) - }, - GT_Values.NF, - ItemUtils.getSimpleStack(GenericChem.mInfiniteMutationCatalyst, 1), - 5 * 20, - 1966080); - - } - - private void recipeCadaverineAndPutrescine() { - - // Basic Recipe - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - getTierOneChip(), - ItemUtils.getSimpleStack(Items.rotten_flesh, 64) - }, - new FluidStack[] { - FluidUtils.getHotWater(2000) - }, - new ItemStack[] { - - }, - new FluidStack[] { - FluidUtils.getFluidStack(Cadaverine, 250), - FluidUtils.getFluidStack(Putrescine, 250), - }, - 20 * 120, - 120, - 1); - - // Advanced Recipe - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - getTierTwoChip(), - ItemUtils.getSimpleStack(Items.rotten_flesh, 128), - ItemUtils.simpleMetaStack(AgriculturalChem.mAgrichemItem1, 8, 32) - }, - new FluidStack[] { - FluidUtils.getHotWater(3000) - }, - new ItemStack[] { - - }, - new FluidStack[] { - FluidUtils.getFluidStack(Cadaverine, 750), - FluidUtils.getFluidStack(Putrescine, 750), - }, - 20 * 120, - 240, - 2); - - } - - private void recipeAniline() { - - //C6H5NO2 + 6H = C6H7N + 2H2O - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - getTierThreeChip(), - ItemUtils.getSimpleStack(mBlueCatalyst, 0) - }, - new FluidStack[] { - FluidUtils.getFluidStack(NitroBenzene, 1000), - FluidUtils.getFluidStack("hydrogen", 6000) - }, - new ItemStack[] { - - }, - new FluidStack[] { - FluidUtils.getFluidStack(Aniline, 1000), - }, - 20 * 30, - 500, - 3); - - } - - private void recipeNitroBenzene() { - - //C6H6 + HNO3 =H2SO4= C6H5NO2 +H2O - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - getTierThreeChip(), - }, - new FluidStack[] { - FluidUtils.getFluidStack(Benzene, 5000), - FluidUtils.getFluidStack("sulfuricacid", 3000), - FluidUtils.getFluidStack("nitricacid", 5000), - FluidUtils.getDistilledWater(10000) - }, - new ItemStack[] { - - }, - new FluidStack[] { - FluidUtils.getFluidStack("dilutedsulfuricacid", 3000), - FluidUtils.getFluidStack(NitroBenzene, 5000), - }, - 20 * 30, - 500, - 4); - - } - - private void recipe2Ethylanthraquinone() { - - //C6H4(CO)2O + C6H5CH2CH3 = C6H4(CO)2C6H3CH2CH3 + H2O - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedCircuit(4), - ItemUtils.getItemStackOfAmountFromOreDict("dustPhthalicAnhydride", 15), - }, - new FluidStack[] { - FluidUtils.getFluidStack(CoalTar.Ethylbenzene, 1000), - }, - new ItemStack[] { - - }, - new FluidStack[] { - FluidUtils.getFluidStack(Ethylanthraquinone2, 1000), - }, - 20 * 15, - 120, - 2); - } - - private void recipe2Ethylanthrahydroquinone() { - - //C6H4(CO)2C6H3CH2CH3 + 2H = C6H4(COH)2C6H3CH2CH3 - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedCircuit(4), - ItemUtils.getSimpleStack(mOrangeCatalyst, 0), - }, - new FluidStack[] { - FluidUtils.getFluidStack(Ethylanthraquinone2, 1000), - FluidUtils.getFluidStack("hydrogen", 2000), - }, - new ItemStack[] { - - }, - new FluidStack[] { - FluidUtils.getFluidStack(Ethylanthrahydroquinone2, 1000), - }, - 20 * 40, - 120, - 2); - } - - private void recipeLithiumPeroxide() { - //2HLiO2 = Li2O2 + H2O2 - CORE.RA.addDehydratorRecipe( - new ItemStack[]{ - ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumHydroperoxide", 8), - ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 1) - }, - null, - null, - new ItemStack[]{ - ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumPeroxide", 4), - ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogenPeroxide", 1), - }, - new int[]{10000, 10000}, - 20*100, - 120); - } - - private void recipeLithiumHydroperoxide() { - - //LiOH + H2O2 = HLiO2 + H2O - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedCircuit(4), - ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumHydroxide", 3), - }, - new FluidStack[] { - FluidUtils.getFluidStack("fluid.hydrogenperoxide", 1000), - }, - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumHydroperoxide", 4), - }, - new FluidStack[] { - - }, - 20 * 30, - 240, - 1); - - - - /*CORE.RA.addChemicalRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumHydroxide", 7), - ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogenPeroxide", 1), - 20, - FluidUtils.getFluidStack("fluid.cellhydrogenperoxide", 50), - null, - ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumHydroperoxide", 14), - CI.emptyCells(1), - 20*30, - 240); */ - } - - private void recipeHydrogenPeroxide() { - - //C6H4(COH)2C6H3CH2CH3 + 2O =(C6H4CH)2= H2O2 + C6H4(CO)2C6H3CH2CH3 - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedCircuit(4), - }, - new FluidStack[] { - FluidUtils.getFluidStack("air", 20000), - FluidUtils.getFluidStack(Ethylanthrahydroquinone2, 5000), - FluidUtils.getFluidStack("fluid.anthracene", 50), - }, - new ItemStack[] { - }, - new FluidStack[] { - FluidUtils.getFluidStack(Ethylanthraquinone2, 5000), - FluidUtils.getFluidStack("fluid.hydrogenperoxide", 5000), - }, - 20 * 30, - 240, - 1); - - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedCircuit(4), - }, - new FluidStack[] { - Materials.Oxygen.getGas(10000), - FluidUtils.getFluidStack(Ethylanthrahydroquinone2, 5000), - FluidUtils.getFluidStack("fluid.anthracene", 50), - }, - new ItemStack[] { - }, - new FluidStack[] { - FluidUtils.getFluidStack(Ethylanthraquinone2, 5000), - FluidUtils.getFluidStack("fluid.hydrogenperoxide", 5000), - }, - 20 * 5, - 240, - 1); - - /* CORE.RA.addChemicalRecipe( - GT_ModHandler.getAirCell(15), - ItemUtils.getItemStackOfAmountFromOreDict("cell2Ethylanthrahydroquinone", 5), - 20, - FluidUtils.getFluidStack("fluid.anthracene", 50), - FluidUtils.getFluidStack("fluid.2ethylanthrahydroquinone", 4450), - ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogenPeroxide", 2), - CI.emptyCells(18), - 20*30, - 240);*/ - - } - - private static final ItemStack getTierOneChip() { - return CI.getNumberedAdvancedCircuit(4); - } - private static final ItemStack getTierTwoChip() { - return CI.getNumberedAdvancedCircuit(8); - } - private static final ItemStack getTierThreeChip() { - return CI.getNumberedAdvancedCircuit(12); - } - private static final ItemStack getTierFourChip() { - return CI.getNumberedAdvancedCircuit(16); - } - - private static void recipeAdvancedChip() { - GT_ModHandler.addShapelessCraftingRecipe( - GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 0L), 0, new Object[]{OrePrefixes.circuit.get(Materials.Advanced)}); - - long bits = 0; - BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 1L, new Object[0]), bits, - new Object[]{"d ", " P ", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); - BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 2L, new Object[0]), bits, - new Object[]{" d ", " P ", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); - BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 3L, new Object[0]), bits, - new Object[]{" d", " P ", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); - BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 4L, new Object[0]), bits, - new Object[]{" ", " Pd", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); - BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 5L, new Object[0]), bits, - new Object[]{" ", " P ", " d", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); - BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 6L, new Object[0]), bits, - new Object[]{" ", " P ", " d ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); - BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 7L, new Object[0]), bits, - new Object[]{" ", " P ", "d ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); - BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 8L, new Object[0]), bits, - new Object[]{" ", "dP ", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); - BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 9L, new Object[0]), bits, - new Object[]{"P d", " ", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); - BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 10L, new Object[0]), bits, - new Object[]{"P ", " d", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); - BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 11L, new Object[0]), bits, - new Object[]{"P ", " ", " d", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); - BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 12L, new Object[0]), bits, - new Object[]{"P ", " ", " d ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); - BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 13L, new Object[0]), bits, - new Object[]{" P", " ", " d", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); - BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 14L, new Object[0]), bits, - new Object[]{" P", " ", " d ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); - BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 15L, new Object[0]), bits, - new Object[]{" P", " ", "d ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); - BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 16L, new Object[0]), bits, - new Object[]{" P", "d ", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); - BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 17L, new Object[0]), bits, - new Object[]{" ", " ", "d P", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); - BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 18L, new Object[0]), bits, - new Object[]{" ", "d ", " P", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); - BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 19L, new Object[0]), bits, - new Object[]{"d ", " ", " P", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); - BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 20L, new Object[0]), bits, - new Object[]{" d ", " ", " P", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); - BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 21L, new Object[0]), bits, - new Object[]{"d ", " ", "P ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); - BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 22L, new Object[0]), bits, - new Object[]{" d ", " ", "P ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); - BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 23L, new Object[0]), bits, - new Object[]{" d", " ", "P ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); - BioRecipes.addCraftingRecipe(GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 24L, new Object[0]), bits, - new Object[]{" ", " d", "P ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0])}); - } - - + /** + * Switches + */ + private static boolean usingGregtechNitricOxide = false; + + private static boolean usingGregtechNitrogenDioxide = false; + private static boolean usingGregtechHydricSulfur = false; + + /** + * Materials + */ + + // public static final Material BAKELITE = new Material("Bakelite", MaterialState.SOLID, TextureSet.SET_DULL, new + // short[]{90, 140, 140}, 120, 240, 23, 24, true, null, 0);//Not a GT Inherited Material + // public static final Material NYLON = new Material("Nylon", MaterialState.SOLID, TextureSet.SET_SHINY, new + // short[]{45, 45, 45}, 300, 600, 44, 48, true, null, 0);//Not a GT Inherited Material + // public static final Material CARBYNE = new Material("Carbyne", MaterialState.SOLID, TextureSet.SET_DULL, new + // short[]{25, 25, 25}, 2500, 5000, 63, 52, true, null, 0);//Not a GT Inherited Material + + // Refined PTFE + public static final Material TEFLON = new Material( + "Teflon", + MaterialState.SOLID, + TextureSet.SET_SHINY, + new short[] {75, 45, 75}, + 330, + 640, + -1, + -1, + false, + null, + 0, + new MaterialStack(NONMATERIAL.PTFE, 75), + new MaterialStack(NONMATERIAL.PLASTIC, 15), + new MaterialStack(ELEMENT.getInstance().CARBON, 5), + new MaterialStack(ELEMENT.getInstance().SODIUM, 5)); + + /** + * Fluids + */ + public static Fluid Benzene; + + public static Fluid NitroBenzene; + public static Fluid Aniline; + public static Fluid Polyurethane; + public static Fluid Phenol; // https://en.wikipedia.org/wiki/Phenol#Uses + public static Fluid Cyclohexane; // https://en.wikipedia.org/wiki/Cyclohexane + public static Fluid Cyclohexanone; // https://en.wikipedia.org/wiki/Cyclohexanone + public static Fluid Cadaverine; // https://en.wikipedia.org/wiki/Cadaverine + public static Fluid Putrescine; // https://en.wikipedia.org/wiki/Putrescine + public static Fluid BoricAcid; + public static Fluid HydrochloricAcid; + + public static Fluid Ethylanthraquinone2; + public static Fluid Ethylanthrahydroquinone2; + public static Fluid Hydrogen_Peroxide; + public static Fluid Lithium_Peroxide; + public static Fluid Nitric_Oxide; + public static Fluid Nitrogen_Dioxide; + public static Fluid Carbon_Disulfide; + public static Fluid Hydrogen_Sulfide; + + /** + * Items + */ + + // Phenol Byproducts + public Item PhenolicResins; // https://en.wikipedia.org/wiki/Phenol_formaldehyde_resin + + public static ItemGenericChemBase mGenericChemItem1; + public static Item mAdvancedCircuit; + + private ItemStack mCatalystCarrier; + + public static ItemStack mRedCatalyst; + public static ItemStack mYellowCatalyst; + public static ItemStack mBlueCatalyst; + public static ItemStack mOrangeCatalyst; + public static ItemStack mPurpleCatalyst; + public static ItemStack mBrownCatalyst; + public static ItemStack mPinkCatalyst; + public static ItemStack mFormaldehydeCatalyst; + public static ItemStack mSolidAcidCatalyst; + public static ItemStack mInfiniteMutationCatalyst; + + public static ItemStack mMillingBallAlumina; + public static ItemStack mMillingBallSoapstone; + + public static ItemStack mSodiumEthoxide; + public static ItemStack mSodiumEthylXanthate; + public static ItemStack mPotassiumEthylXanthate; + public static ItemStack mPotassiumHydroxide; + + @Override + public void items() { + PhenolicResins = ItemUtils.generateSpecialUseDusts( + "phenolicresins", "Phenolic Resin", "HOC6H4CH2OH", Utils.rgbtoHexValue(80, 40, 40))[0]; + // MaterialGenerator.generate(BAKELITE, false); + // MaterialGenerator.generate(NYLON, false); + MaterialGenerator.generate(TEFLON, false); + + mGenericChemItem1 = new ItemGenericChemBase(); + mAdvancedCircuit = new ItemAdvancedChip(); + GregtechItemList.Circuit_T3RecipeSelector.set(mAdvancedCircuit); + + registerItemStacks(); + registerOreDict(); + + GregtechItemList.Milling_Ball_Alumina.set(mMillingBallAlumina); + GregtechItemList.Milling_Ball_Soapstone.set(mMillingBallSoapstone); + } + + public void registerItemStacks() { + + mCatalystCarrier = ItemUtils.simpleMetaStack(AgriculturalChem.mAgrichemItem1, 13, 1); + + mRedCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 0, 1); + mYellowCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 1, 1); + mBlueCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 2, 1); + mOrangeCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 3, 1); + mPurpleCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 4, 1); + mBrownCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 5, 1); + mPinkCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 6, 1); + mMillingBallAlumina = ItemUtils.simpleMetaStack(mGenericChemItem1, 7, 1); + mMillingBallSoapstone = ItemUtils.simpleMetaStack(mGenericChemItem1, 8, 1); + mSodiumEthoxide = ItemUtils.simpleMetaStack(mGenericChemItem1, 9, 1); + mSodiumEthylXanthate = ItemUtils.simpleMetaStack(mGenericChemItem1, 10, 1); + mPotassiumEthylXanthate = ItemUtils.simpleMetaStack(mGenericChemItem1, 11, 1); + mPotassiumHydroxide = ItemUtils.simpleMetaStack(mGenericChemItem1, 12, 1); + mFormaldehydeCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 13, 1); + mSolidAcidCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 14, 1); + mInfiniteMutationCatalyst = ItemUtils.simpleMetaStack(mGenericChemItem1, 15, 1); + } + + public void registerOreDict() { + + ItemUtils.addItemToOreDictionary(mRedCatalyst, "catalystIronCopper"); + ItemUtils.addItemToOreDictionary(mYellowCatalyst, "catalystTungstenNickel"); + ItemUtils.addItemToOreDictionary(mBlueCatalyst, "catalystCobaltTitanium"); + ItemUtils.addItemToOreDictionary(mOrangeCatalyst, "catalystVanadiumPalladium"); + ItemUtils.addItemToOreDictionary(mPurpleCatalyst, "catalystIridiumRuthenium"); + ItemUtils.addItemToOreDictionary(mBrownCatalyst, "catalystNickelAluminium"); + ItemUtils.addItemToOreDictionary(mPinkCatalyst, "catalystPlatinumRhodium"); + ItemUtils.addItemToOreDictionary(mMillingBallAlumina, "millingballAlumina"); + ItemUtils.addItemToOreDictionary(mMillingBallSoapstone, "millingballSoapstone"); + ItemUtils.addItemToOreDictionary(mSodiumEthoxide, "dustSodiumEthoxide"); + ItemUtils.addItemToOreDictionary(mSodiumEthylXanthate, "dustSodiumEthylXanthate"); + ItemUtils.addItemToOreDictionary(mPotassiumEthylXanthate, "dustPotassiumEthylXanthate"); + ItemUtils.addItemToOreDictionary(mPotassiumHydroxide, "dustPotassiumHydroxide"); + ItemUtils.addItemToOreDictionary(mFormaldehydeCatalyst, "catalystFormaldehyde"); + ItemUtils.addItemToOreDictionary(mSolidAcidCatalyst, "catalystSolidAcid"); + ItemUtils.addItemToOreDictionary(mInfiniteMutationCatalyst, "catalystInfiniteMutation"); + } + + @Override + public void blocks() {} + + @Override + public void fluids() { + + if (!FluidRegistry.isFluidRegistered("benzene")) { + Benzene = FluidUtils.generateFluidNoPrefix("benzene", "Benzene", 278, new short[] {100, 70, 30, 100}, true); + } else { + Benzene = FluidRegistry.getFluid("benzene"); + } + + NitroBenzene = FluidUtils.generateFluidNoPrefix( + "nitrobenzene", "Nitrobenzene", 278, new short[] {70, 50, 40, 100}, true); + + Aniline = FluidUtils.generateFluidNoPrefix("aniline", "Aniline", 266, new short[] {100, 100, 30, 100}, true); + + BoricAcid = + FluidUtils.generateFluidNoPrefix("boricacid", "Boric Acid", 278, new short[] {90, 30, 120, 100}, true); + + Polyurethane = FluidUtils.generateFluidNoPrefix( + "polyurethane", "Polyurethane", 350, new short[] {100, 70, 100, 100}, true); + + if (!FluidRegistry.isFluidRegistered("phenol")) { + Phenol = FluidUtils.generateFluidNoPrefix("phenol", "Phenol", 313, new short[] {100, 70, 30, 100}, true); + } else { + Phenol = FluidRegistry.getFluid("phenol"); + } + + // Use GT's if it exists, else make our own. + if (FluidRegistry.isFluidRegistered("hydrochloricacid_gt5u")) { + HydrochloricAcid = FluidRegistry.getFluid("hydrochloricacid_gt5u"); + } else { + HydrochloricAcid = FluidUtils.generateFluidNoPrefix( + "hydrochloricacid", "Hydrochloric Acid", 285, new short[] {183, 200, 196, 100}, true); + } + + Cyclohexane = FluidUtils.generateFluidNoPrefix( + "cyclohexane", "Cyclohexane", 32 + 175, new short[] {100, 70, 30, 100}, true); + Cyclohexanone = FluidUtils.generateFluidNoPrefix( + "cyclohexanone", "Cyclohexanone", 32 + 175, new short[] {100, 70, 30, 100}, true); + + Cadaverine = FluidUtils.generateFluidNoPrefix( + "cadaverine", "Cadaverine", 32 + 175, new short[] {100, 70, 30, 100}, true); + Putrescine = FluidUtils.generateFluidNoPrefix( + "putrescine", "Putrescine", 32 + 175, new short[] {100, 70, 30, 100}, true); + + // Create 2-Ethylanthraquinone + // 2-Ethylanthraquinone is prepared from the reaction of phthalic anhydride and ethylbenzene + Ethylanthraquinone2 = FluidUtils.generateFluidNonMolten( + "2Ethylanthraquinone", "2-Ethylanthraquinone", 415, new short[] {227, 255, 159, 100}, null, null); + // Create 2-Ethylanthrahydroquinone + // Palladium plate + Hydrogen(250) + 2-Ethylanthraquinone(500) = 600 Ethylanthrahydroquinone + Ethylanthrahydroquinone2 = FluidUtils.generateFluidNonMolten( + "2Ethylanthrahydroquinone", + "2-Ethylanthrahydroquinone", + 415, + new short[] {207, 225, 129, 100}, + null, + null); + // Create Hydrogen Peroxide + // Compressed Air(1500) + Ethylanthrahydroquinone(500) + Anthracene(5) = 450 Ethylanthraquinone && 200 Peroxide + Hydrogen_Peroxide = FluidUtils.generateFluidNonMolten( + "HydrogenPeroxide", "Hydrogen Peroxide", 150, new short[] {210, 255, 255, 100}, null, null); + + if (FluidRegistry.isFluidRegistered("nitricoxide")) { + Nitric_Oxide = FluidRegistry.getFluid("nitricoxide"); + usingGregtechNitricOxide = true; + } else { + Nitric_Oxide = FluidUtils.generateFluidNoPrefix( + "nitricoxide", "Nitric Oxide", 200, new short[] {125, 200, 240, 100}); + } + if (FluidRegistry.isFluidRegistered("nitrogendioxide")) { + Nitrogen_Dioxide = FluidRegistry.getFluid("nitrogendioxide"); + usingGregtechNitrogenDioxide = true; + } else { + Nitrogen_Dioxide = FluidUtils.generateFluidNoPrefix( + "nitrogendioxide", "Nitrogen Dioxide", 200, new short[] {100, 175, 255, 100}); + } + + // Lithium Hydroperoxide - LiOH + H2O2 → LiOOH + 2 H2O + // ItemUtils.generateSpecialUseDusts("LithiumHydroperoxide", "Lithium Hydroperoxide", "HLiO2", + // Utils.rgbtoHexValue(125, 125, 125)); + // v - Dehydrate + // Lithium Peroxide - 2 LiOOH → Li2O2 + H2O2 + 2 H2O + Lithium_Peroxide = FluidUtils.generateFluidNonMolten( + "LithiumPeroxide", "Lithium Peroxide", 446, new short[] {135, 135, 135, 100}, null, null); + + Carbon_Disulfide = FluidUtils.generateFluidNoPrefix( + "CarbonDisulfide", "Carbon Disulfide", 350, new short[] {175, 175, 175, 100}); + + if (FluidRegistry.isFluidRegistered("fluid.liquid_hydricsulfur") + || MaterialUtils.doesMaterialExist("HydricSulfide")) { + usingGregtechHydricSulfur = true; + Fluid aFluid = null; + if (ItemUtils.doesItemListEntryExist("sHydricSulfur")) { + ItemStack aListItem = ItemUtils.getValueOfItemList("sHydricSulfur", 1, (ItemList) null); + if (aListItem != null) { + FluidStack aFluidStack = FluidContainerRegistry.getFluidForFilledItem(aListItem); + if (aFluidStack != null) { + aFluid = aFluidStack.getFluid(); + } + } + } + if (aFluid == null) { + aFluid = FluidUtils.getWildcardFluidStack("liquid_hydricsulfur", 1000) + .getFluid(); + } + Hydrogen_Sulfide = aFluid; + } else { + Hydrogen_Sulfide = FluidUtils.generateFluidNoPrefix( + "HydrogenSulfide", "Hydrogen Sulfide", 446, new short[] {240, 130, 30, 100}); + } + } + + @Override + public String errorMessage() { + return "Failed to generate recipes for GenericChem."; + } + + @Override + public boolean generateRecipes() { + + recipeAdvancedChip(); + recipeCatalystRed(); + recipeCatalystYellow(); + recipeCatalystBlue(); + recipeCatalystOrange(); + recipeCatalystPurple(); + recipeCatalystBrown(); + recipeCatalystPink(); + recipeCatalystFormaldehyde(); + recipeCatalystSolidAcid(); + recipeCatalystInfiniteMutation(); + + recipeGrindingBallAlumina(); + recipeGrindingBallSoapstone(); + + recipeNitroBenzene(); + recipeAniline(); + recipeCadaverineAndPutrescine(); + recipeCyclohexane(); + recipeCyclohexanone(); + + recipe2Ethylanthraquinone(); + recipe2Ethylanthrahydroquinone(); + recipeHydrogenPeroxide(); + recipeLithiumHydroperoxide(); + recipeLithiumPeroxide(); + // The follow is using alk science, ignore them + if (!usingGregtechNitricOxide) { + recipeNitricOxide(); + } + if (!usingGregtechNitrogenDioxide) { + recipeNitrogenDioxide(); + } + if (!usingGregtechHydricSulfur) { + recipeHydricSulfur(); + } + + // Add recipes if we are not using GT's fluid. + if (!FluidRegistry.isFluidRegistered("hydrochloricacid_gt5u")) { + recipeHydrochloricAcid(); + } + + recipeSodiumEthoxide(); + recipeCarbonDisulfide(); + recipeEthylXanthates(); + recipePotassiumHydroxide(); + + recipeMutatedLivingSolder(); + + registerFuels(); + + return true; + } + + private void recipeSodiumEthoxide() { + // C2H5OH + Na → C2H5ONa + H + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedCircuit(16), ELEMENT.getInstance().SODIUM.getDust(1) + }, + new FluidStack[] {Materials.Ethanol.getFluid(1000)}, + new ItemStack[] {ItemUtils.getSimpleStack(mSodiumEthoxide, 9)}, + new FluidStack[] {ELEMENT.getInstance().HYDROGEN.getFluidStack(1000)}, + 20 * 20, + 120, + 2); + } + + private void recipePotassiumHydroxide() { + // Ca(OH)2 + K2O + CO2 → CaCO3 + 2 KOH + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedCircuit(18), + Materials.Potash.getDust(3), + ItemUtils.getItemStackOfAmountFromOreDict("dustCalciumHydroxide", 5), + }, + new FluidStack[] {Materials.CarbonDioxide.getGas(1000)}, + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("dustCalciumCarbonate", 5), + ItemUtils.getSimpleStack(mPotassiumHydroxide, 6) + }, + new FluidStack[] {}, + 20 * 30, + 120, + 2); + } + + private void recipeEthylXanthates() { + + // Potassium ethyl xanthate - CH3CH2OH + CS2 + KOH → C3H5KOS2 + H2O + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedCircuit(17), ItemUtils.getSimpleStack(mPotassiumHydroxide, 3), + }, + new FluidStack[] { + Materials.Ethanol.getFluid(1000), FluidUtils.getFluidStack(Carbon_Disulfide, 1000), + }, + new ItemStack[] {ItemUtils.getSimpleStack(mPotassiumEthylXanthate, 12)}, + new FluidStack[] {FluidUtils.getWater(1000)}, + 20 * 60, + 120, + 4); + + // Sodium ethyl xanthate - CH3CH2ONa + CS2 → CH3CH2OCS2Na + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] {CI.getNumberedCircuit(17), ItemUtils.getSimpleStack(mSodiumEthoxide, 9)}, + new FluidStack[] { + FluidUtils.getFluidStack(Carbon_Disulfide, 1000), + }, + new ItemStack[] {ItemUtils.getSimpleStack(mSodiumEthylXanthate, 12)}, + new FluidStack[] {}, + 20 * 60, + 120, + 4); + } + + // The follow is using alk science, ignore them + private void recipeHydricSulfur() { + + ItemStack aCellHydricSulfide = ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogenSulfide", 1); + GT_Values.RA.addChemicalRecipe( + ELEMENT.getInstance().SULFUR.getDust(1), + GT_Utility.getIntegratedCircuit(1), + ELEMENT.getInstance().HYDROGEN.getFluidStack(2000), + FluidUtils.getFluidStack(Hydrogen_Sulfide, 3000), + GT_Values.NI, + 60, + 8); + GT_Values.RA.addChemicalRecipeForBasicMachineOnly( + ELEMENT.getInstance().SULFUR.getDust(1), + CI.emptyCells(3), + ELEMENT.getInstance().HYDROGEN.getFluidStack(2000), + GT_Values.NF, + ItemUtils.getSimpleStack(aCellHydricSulfide, 3), + GT_Values.NI, + 60, + 8); + } + + private void recipeCarbonDisulfide() { + + CORE.RA.addBlastRecipe( + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("fuelCoke", 8), + ItemUtils.getItemStackOfAmountFromOreDict("dustSulfur", 16) + }, + new FluidStack[] {}, + new ItemStack[] {ItemUtils.getItemStackOfAmountFromOreDict("dustDarkAsh", 1)}, + new FluidStack[] {FluidUtils.getFluidStack(Carbon_Disulfide, 4000)}, + 20 * 60 * 10, + 30, + 1500); + + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedCircuit(20), + ItemUtils.getSimpleStack(mBrownCatalyst, 0), + ItemUtils.getItemStackOfAmountFromOreDict("dustSulfur", 4) + }, + new FluidStack[] { + FluidUtils.getFluidStack(CoalTar.Coal_Gas, 1000), + }, + new ItemStack[] {}, + new FluidStack[] {FluidUtils.getFluidStack(Carbon_Disulfide, 2000)}, + 20 * 60 * 5, + 30, + 2); + } + + private void recipeMutatedLivingSolder() { + + // Endgame soldering alloy meant for the bioware circuit line and beyond. + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + ItemUtils.getSimpleStack(GenericChem.mInfiniteMutationCatalyst, 0), + ItemList.Circuit_Chip_Biocell.get(64), + ItemList.Gravistar.get(8), + Materials.InfinityCatalyst.getDust(2) + }, + new FluidStack[] { + FluidUtils.getFluidStack("plasma.tin", 18000), + FluidUtils.getFluidStack("plasma.bismuth", 18000), + FluidUtils.getFluidStack("cryotheum", 4000) + }, + new ItemStack[] {}, + new FluidStack[] {MISC_MATERIALS.MUTATED_LIVING_SOLDER.getFluidStack(144 * 280)}, + 20 * 800, + 3842160, + 7); + } + + private static void registerFuels() { + + // Burnables + + // Gas Fuels + GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellNitrobenzene", 1), null, 1600, 1); + } + + private void recipeGrindingBallAlumina() { + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] {CI.getNumberedCircuit(10), ItemUtils.getSimpleStack(AgriculturalChem.mAlumina, 64)}, + FluidUtils.getFluidStack(GenericChem.Aniline, 4000), + ItemUtils.getSimpleStack(mMillingBallAlumina, 8), + 180 * 20, + 480); + } + + private void recipeGrindingBallSoapstone() { + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedCircuit(10), ItemUtils.getItemStackOfAmountFromOreDict("dustSoapstone", 32) + }, + FluidUtils.getFluidStack(AgrichemFluids.mLiquidResin, 2500), + ItemUtils.getSimpleStack(mMillingBallSoapstone, 8), + 120 * 20, + 480); + } + + // The follow is using alk science, ignore them + private void recipeNitrogenDioxide() { + ItemStack aNitricOxideCell = ItemUtils.getItemStackOfAmountFromOreDict("cellNitricOxide", 1); + ItemStack aNitrogenDioxideCell = ItemUtils.getItemStackOfAmountFromOreDict("cellNitrogenDioxide", 1); + GT_Values.RA.addChemicalRecipe( + ItemUtils.getSimpleStack(aNitricOxideCell, 2), + GT_Utility.getIntegratedCircuit(1), + ELEMENT.getInstance().OXYGEN.getFluidStack(1000), + FluidUtils.getFluidStack(Nitrogen_Dioxide, 3000), + CI.emptyCells(2), + 160); + GT_Values.RA.addChemicalRecipe( + ELEMENT.getInstance().OXYGEN.getCell(1), + GT_Utility.getIntegratedCircuit(1), + FluidUtils.getFluidStack(Nitric_Oxide, 2000), + FluidUtils.getFluidStack(Nitrogen_Dioxide, 3000), + CI.emptyCells(1), + 160); + GT_Values.RA.addChemicalRecipeForBasicMachineOnly( + ItemUtils.getSimpleStack(aNitricOxideCell, 2), + CI.emptyCells(1), + ELEMENT.getInstance().OXYGEN.getFluidStack(1000), + GT_Values.NF, + ItemUtils.getSimpleStack(aNitrogenDioxideCell, 3), + GT_Values.NI, + 160, + 30); + GT_Values.RA.addChemicalRecipeForBasicMachineOnly( + ELEMENT.getInstance().OXYGEN.getCell(1), + CI.emptyCells(2), + FluidUtils.getFluidStack(Nitric_Oxide, 2000), + GT_Values.NF, + ItemUtils.getSimpleStack(aNitrogenDioxideCell, 3), + GT_Values.NI, + 160, + 30); + GT_Values.RA.addChemicalRecipeForBasicMachineOnly( + ItemUtils.getSimpleStack(aNitricOxideCell, 2), + ELEMENT.getInstance().OXYGEN.getCell(1), + GT_Values.NF, + GT_Values.NF, + ItemUtils.getSimpleStack(aNitrogenDioxideCell, 3), + GT_Values.NI, + 160, + 30); + } + + // The follow is using alk science, ignore them + private void recipeNitricOxide() { + ItemStack aWaterCell = ItemUtils.getItemStackOfAmountFromOreDict("cellWater", 1); + ItemStack aNitricOxideCell = ItemUtils.getItemStackOfAmountFromOreDict("cellNitricOxide", 1); + GT_Values.RA.addChemicalRecipeForBasicMachineOnly( + MISC_MATERIALS.AMMONIA.getCell(8), + CI.emptyCells(1), + ELEMENT.getInstance().OXYGEN.getFluidStack(5000), + FluidUtils.getFluidStack(Nitric_Oxide, 4000), + ItemUtils.getSimpleStack(aWaterCell, 9), + GT_Values.NI, + 160, + 30); + GT_Values.RA.addChemicalRecipeForBasicMachineOnly( + ELEMENT.getInstance().OXYGEN.getCell(5), + CI.emptyCells(4), + MISC_MATERIALS.AMMONIA.getFluidStack(8000), + FluidUtils.getFluidStack(Nitric_Oxide, 4000), + ItemUtils.getSimpleStack(aWaterCell, 9), + GT_Values.NI, + 160, + 30); + GT_Values.RA.addChemicalRecipe( + MISC_MATERIALS.AMMONIA.getCell(8), + GT_Utility.getIntegratedCircuit(11), + ELEMENT.getInstance().OXYGEN.getFluidStack(5000), + FluidUtils.getWater(9000), + ItemUtils.getSimpleStack(aNitricOxideCell, 4), + CI.emptyCells(4), + 160); + GT_Values.RA.addChemicalRecipe( + ELEMENT.getInstance().OXYGEN.getCell(5), + GT_Utility.getIntegratedCircuit(11), + MISC_MATERIALS.AMMONIA.getFluidStack(8000), + FluidUtils.getWater(9000), + ItemUtils.getSimpleStack(aNitricOxideCell, 4), + CI.emptyCells(1), + 160); + GT_Values.RA.addChemicalRecipe( + MISC_MATERIALS.AMMONIA.getCell(8), + GT_Utility.getIntegratedCircuit(2), + ELEMENT.getInstance().OXYGEN.getFluidStack(5000), + FluidUtils.getFluidStack(Nitric_Oxide, 4000), + CI.emptyCells(8), + 320); + GT_Values.RA.addChemicalRecipe( + ELEMENT.getInstance().OXYGEN.getCell(5), + GT_Utility.getIntegratedCircuit(2), + MISC_MATERIALS.AMMONIA.getFluidStack(8000), + FluidUtils.getFluidStack(Nitric_Oxide, 4000), + CI.emptyCells(5), + 320); + GT_Values.RA.addChemicalRecipe( + MISC_MATERIALS.AMMONIA.getCell(8), + GT_Utility.getIntegratedCircuit(12), + ELEMENT.getInstance().OXYGEN.getFluidStack(5000), + GT_Values.NF, + ItemUtils.getSimpleStack(aNitricOxideCell, 4), + CI.emptyCells(4), + 160); + GT_Values.RA.addChemicalRecipe( + ELEMENT.getInstance().OXYGEN.getCell(5), + GT_Utility.getIntegratedCircuit(12), + MISC_MATERIALS.AMMONIA.getFluidStack(8000), + GT_Values.NF, + ItemUtils.getSimpleStack(aNitricOxideCell, 4), + CI.emptyCells(1), + 160); + GT_Values.RA.addChemicalRecipeForBasicMachineOnly( + MISC_MATERIALS.AMMONIA.getCell(8), + ELEMENT.getInstance().OXYGEN.getCell(5), + GT_Values.NF, + GT_Values.NF, + ItemUtils.getSimpleStack(aNitricOxideCell, 4), + ItemUtils.getSimpleStack(aWaterCell, 9), + 160, + 30); + GT_Values.RA.addMultiblockChemicalRecipe( + new ItemStack[] {GT_Utility.getIntegratedCircuit(1)}, + new FluidStack[] { + MISC_MATERIALS.AMMONIA.getFluidStack(8000), + ELEMENT.getInstance().OXYGEN.getFluidStack(5000) + }, + new FluidStack[] {FluidUtils.getFluidStack(Nitric_Oxide, 4000), FluidUtils.getWater(9000)}, + null, + 160, + 30); + } + + // The follow is using alk science, ignore them + private void recipeHydrochloricAcid() { + + ItemStack aAcidCell = ItemUtils.getItemStackOfAmountFromOreDict("cellHydrochloricAcid", 1); + + CORE.RA.addChemicalRecipe( + ELEMENT.getInstance().CHLORINE.getCell(1), + GT_Utility.getIntegratedCircuit(1), + ELEMENT.getInstance().HYDROGEN.getFluidStack(1000), + FluidUtils.getFluidStack(HydrochloricAcid, 2000), + CI.emptyCells(1), + 60, + 8); + + CORE.RA.addChemicalRecipe( + ELEMENT.getInstance().HYDROGEN.getCell(1), + GT_Utility.getIntegratedCircuit(1), + ELEMENT.getInstance().CHLORINE.getFluidStack(1000), + FluidUtils.getFluidStack(HydrochloricAcid, 2000), + CI.emptyCells(1), + 60, + 8); + + GT_Values.RA.addElectrolyzerRecipe( + CI.emptyCells(1), + GT_Utility.getIntegratedCircuit(1), + FluidUtils.getFluidStack(HydrochloricAcid, 2000), + ELEMENT.getInstance().CHLORINE.getFluidStack(1000), + ELEMENT.getInstance().HYDROGEN.getCell(1), + GT_Values.NI, + GT_Values.NI, + GT_Values.NI, + GT_Values.NI, + GT_Values.NI, + null, + 720, + 30); + + GT_Values.RA.addElectrolyzerRecipe( + CI.emptyCells(1), + GT_Utility.getIntegratedCircuit(11), + FluidUtils.getFluidStack(HydrochloricAcid, 2000), + ELEMENT.getInstance().HYDROGEN.getFluidStack(1000), + ELEMENT.getInstance().CHLORINE.getCell(1), + GT_Values.NI, + GT_Values.NI, + GT_Values.NI, + GT_Values.NI, + GT_Values.NI, + null, + 720, + 30); + + GT_Values.RA.addElectrolyzerRecipe( + ItemUtils.getSimpleStack(aAcidCell, 2), + GT_Values.NI, + GT_Values.NF, + GT_Values.NF, + ELEMENT.getInstance().HYDROGEN.getCell(1), + ELEMENT.getInstance().CHLORINE.getCell(1), + GT_Values.NI, + GT_Values.NI, + GT_Values.NI, + GT_Values.NI, + null, + 720, + 30); + } + + private void recipeCyclohexane() { + + // C6H6 + 6H = C6H12 + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] {getTierTwoChip(), ItemUtils.getSimpleStack(mBrownCatalyst, 0)}, + new FluidStack[] {FluidUtils.getFluidStack(Benzene, 1000), FluidUtils.getFluidStack("hydrogen", 6000)}, + new ItemStack[] {}, + new FluidStack[] { + FluidUtils.getFluidStack(Cyclohexane, 1000), + }, + 20 * 120, + 120, + 2); + } + + private void recipeCyclohexanone() { + + // C6H12 + 2O(Air) = C6H10O + H2O + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] {getTierTwoChip(), ItemUtils.getSimpleStack(mBlueCatalyst, 0)}, + new FluidStack[] {FluidUtils.getFluidStack(Cyclohexane, 1000), FluidUtils.getFluidStack("air", 4000)}, + new ItemStack[] {}, + new FluidStack[] { + FluidUtils.getFluidStack(Cyclohexanone, 1000), + }, + 20 * 120, + 120, + 2); + + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + getTierTwoChip(), + }, + new FluidStack[] {FluidUtils.getFluidStack(Cyclohexane, 1000), FluidUtils.getFluidStack("oxygen", 2000) + }, + new ItemStack[] {}, + new FluidStack[] { + FluidUtils.getFluidStack(Cyclohexanone, 1000), + }, + 20 * 120, + 120, + 2); + } + + private void recipeCatalystRed() { + // Assembly Recipe + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + getTierOneChip(), + CI.getEmptyCatalyst(10), + ELEMENT.getInstance().IRON.getDust(2), + ELEMENT.getInstance().COPPER.getDust(2), + }, + GT_Values.NF, + ItemUtils.getSimpleStack(mRedCatalyst, 10), + 20 * 20, + 30); + } + + private void recipeCatalystYellow() { + // Assembly Recipe + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + getTierThreeChip(), + CI.getEmptyCatalyst(10), + ELEMENT.getInstance().TUNGSTEN.getDust(4), + ELEMENT.getInstance().NICKEL.getDust(4), + }, + GT_Values.NF, + ItemUtils.getSimpleStack(mYellowCatalyst, 10), + 60 * 20, + 2000); + } + + private void recipeCatalystBlue() { + // Assembly Recipe + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + getTierTwoChip(), + CI.getEmptyCatalyst(10), + ELEMENT.getInstance().COBALT.getDust(3), + ELEMENT.getInstance().TITANIUM.getDust(3), + }, + GT_Values.NF, + ItemUtils.getSimpleStack(mBlueCatalyst, 10), + 40 * 20, + 500); + } + + private void recipeCatalystOrange() { + // Assembly Recipe + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + getTierTwoChip(), + CI.getEmptyCatalyst(10), + ELEMENT.getInstance().VANADIUM.getDust(5), + ELEMENT.getInstance().PALLADIUM.getDust(5), + }, + GT_Values.NF, + ItemUtils.getSimpleStack(mOrangeCatalyst, 10), + 40 * 20, + 500); + } + + private void recipeCatalystPurple() { + // Assembly Recipe + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + getTierFourChip(), + CI.getEmptyCatalyst(10), + ELEMENT.getInstance().IRIDIUM.getDust(6), + ELEMENT.getInstance().RUTHENIUM.getDust(6), + }, + GT_Values.NF, + ItemUtils.getSimpleStack(mPurpleCatalyst, 10), + 120 * 20, + 8000); + } + + private void recipeCatalystBrown() { + // Assembly Recipe + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + getTierOneChip(), + CI.getEmptyCatalyst(10), + ELEMENT.getInstance().NICKEL.getDust(4), + ELEMENT.getInstance().ALUMINIUM.getDust(4), + }, + GT_Values.NF, + ItemUtils.getSimpleStack(mBrownCatalyst, 10), + 15 * 20, + 30); + } + + private void recipeCatalystPink() { + // Assembly Recipe + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + getTierThreeChip(), + CI.getEmptyCatalyst(10), + ELEMENT.getInstance().PLATINUM.getDust(4), + ELEMENT.getInstance().RHODIUM.getDust(4), + }, + GT_Values.NF, + ItemUtils.getSimpleStack(mPinkCatalyst, 10), + 30 * 20, + 2000); + } + + private void recipeCatalystFormaldehyde() { + // Assembly Recipe + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + getTierThreeChip(), + CI.getEmptyCatalyst(4), + ItemUtils.getSimpleStack(RocketFuels.Formaldehyde_Catalyst_Dust, 8) + }, + GT_Values.NF, + ItemUtils.getSimpleStack(mFormaldehydeCatalyst, 4), + 30 * 20, + 240); + } + + private void recipeCatalystSolidAcid() { + // Assembly Recipe + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + getTierThreeChip(), + CI.getEmptyCatalyst(5), + ItemUtils.getItemStackOfAmountFromOreDict("dustLapis", 2) + }, + MISC_MATERIALS.SOLID_ACID_MIXTURE.getFluidStack(1000), + ItemUtils.getSimpleStack(GenericChem.mSolidAcidCatalyst, 5), + 30 * 20, + 2000); + } + + private void recipeCatalystInfiniteMutation() { + // Assembly Recipe + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + getTierThreeChip(), + CI.getEmptyCatalyst(5), + Materials.Infinity.getDust(1), + Materials.Naquadria.getDust(10) + }, + GT_Values.NF, + ItemUtils.getSimpleStack(GenericChem.mInfiniteMutationCatalyst, 1), + 5 * 20, + 1966080); + } + + private void recipeCadaverineAndPutrescine() { + + // Basic Recipe + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] {getTierOneChip(), ItemUtils.getSimpleStack(Items.rotten_flesh, 64)}, + new FluidStack[] {FluidUtils.getHotWater(2000)}, + new ItemStack[] {}, + new FluidStack[] { + FluidUtils.getFluidStack(Cadaverine, 250), FluidUtils.getFluidStack(Putrescine, 250), + }, + 20 * 120, + 120, + 1); + + // Advanced Recipe + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + getTierTwoChip(), + ItemUtils.getSimpleStack(Items.rotten_flesh, 128), + ItemUtils.simpleMetaStack(AgriculturalChem.mAgrichemItem1, 8, 32) + }, + new FluidStack[] {FluidUtils.getHotWater(3000)}, + new ItemStack[] {}, + new FluidStack[] { + FluidUtils.getFluidStack(Cadaverine, 750), FluidUtils.getFluidStack(Putrescine, 750), + }, + 20 * 120, + 240, + 2); + } + + private void recipeAniline() { + + // C6H5NO2 + 6H = C6H7N + 2H2O + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] {getTierThreeChip(), ItemUtils.getSimpleStack(mBlueCatalyst, 0)}, + new FluidStack[] { + FluidUtils.getFluidStack(NitroBenzene, 1000), FluidUtils.getFluidStack("hydrogen", 6000) + }, + new ItemStack[] {}, + new FluidStack[] { + FluidUtils.getFluidStack(Aniline, 1000), + }, + 20 * 30, + 500, + 3); + } + + private void recipeNitroBenzene() { + + // C6H6 + HNO3 =H2SO4= C6H5NO2 +H2O + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + getTierThreeChip(), + }, + new FluidStack[] { + FluidUtils.getFluidStack(Benzene, 5000), + FluidUtils.getFluidStack("sulfuricacid", 3000), + FluidUtils.getFluidStack("nitricacid", 5000), + FluidUtils.getDistilledWater(10000) + }, + new ItemStack[] {}, + new FluidStack[] { + FluidUtils.getFluidStack("dilutedsulfuricacid", 3000), FluidUtils.getFluidStack(NitroBenzene, 5000), + }, + 20 * 30, + 500, + 4); + } + + private void recipe2Ethylanthraquinone() { + + // C6H4(CO)2O + C6H5CH2CH3 = C6H4(CO)2C6H3CH2CH3 + H2O + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedCircuit(4), ItemUtils.getItemStackOfAmountFromOreDict("dustPhthalicAnhydride", 15), + }, + new FluidStack[] { + FluidUtils.getFluidStack(CoalTar.Ethylbenzene, 1000), + }, + new ItemStack[] {}, + new FluidStack[] { + FluidUtils.getFluidStack(Ethylanthraquinone2, 1000), + }, + 20 * 15, + 120, + 2); + } + + private void recipe2Ethylanthrahydroquinone() { + + // C6H4(CO)2C6H3CH2CH3 + 2H = C6H4(COH)2C6H3CH2CH3 + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedCircuit(4), ItemUtils.getSimpleStack(mOrangeCatalyst, 0), + }, + new FluidStack[] { + FluidUtils.getFluidStack(Ethylanthraquinone2, 1000), FluidUtils.getFluidStack("hydrogen", 2000), + }, + new ItemStack[] {}, + new FluidStack[] { + FluidUtils.getFluidStack(Ethylanthrahydroquinone2, 1000), + }, + 20 * 40, + 120, + 2); + } + + private void recipeLithiumPeroxide() { + // 2HLiO2 = Li2O2 + H2O2 + CORE.RA.addDehydratorRecipe( + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumHydroperoxide", 8), + ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 1) + }, + null, + null, + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumPeroxide", 4), + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogenPeroxide", 1), + }, + new int[] {10000, 10000}, + 20 * 100, + 120); + } + + private void recipeLithiumHydroperoxide() { + + // LiOH + H2O2 = HLiO2 + H2O + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedCircuit(4), ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumHydroxide", 3), + }, + new FluidStack[] { + FluidUtils.getFluidStack("fluid.hydrogenperoxide", 1000), + }, + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumHydroperoxide", 4), + }, + new FluidStack[] {}, + 20 * 30, + 240, + 1); + + /*CORE.RA.addChemicalRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumHydroxide", 7), + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogenPeroxide", 1), + 20, + FluidUtils.getFluidStack("fluid.cellhydrogenperoxide", 50), + null, + ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumHydroperoxide", 14), + CI.emptyCells(1), + 20*30, + 240); */ + } + + private void recipeHydrogenPeroxide() { + + // C6H4(COH)2C6H3CH2CH3 + 2O =(C6H4CH)2= H2O2 + C6H4(CO)2C6H3CH2CH3 + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedCircuit(4), + }, + new FluidStack[] { + FluidUtils.getFluidStack("air", 20000), + FluidUtils.getFluidStack(Ethylanthrahydroquinone2, 5000), + FluidUtils.getFluidStack("fluid.anthracene", 50), + }, + new ItemStack[] {}, + new FluidStack[] { + FluidUtils.getFluidStack(Ethylanthraquinone2, 5000), + FluidUtils.getFluidStack("fluid.hydrogenperoxide", 5000), + }, + 20 * 30, + 240, + 1); + + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedCircuit(4), + }, + new FluidStack[] { + Materials.Oxygen.getGas(10000), + FluidUtils.getFluidStack(Ethylanthrahydroquinone2, 5000), + FluidUtils.getFluidStack("fluid.anthracene", 50), + }, + new ItemStack[] {}, + new FluidStack[] { + FluidUtils.getFluidStack(Ethylanthraquinone2, 5000), + FluidUtils.getFluidStack("fluid.hydrogenperoxide", 5000), + }, + 20 * 5, + 240, + 1); + + /* CORE.RA.addChemicalRecipe( + GT_ModHandler.getAirCell(15), + ItemUtils.getItemStackOfAmountFromOreDict("cell2Ethylanthrahydroquinone", 5), + 20, + FluidUtils.getFluidStack("fluid.anthracene", 50), + FluidUtils.getFluidStack("fluid.2ethylanthrahydroquinone", 4450), + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogenPeroxide", 2), + CI.emptyCells(18), + 20*30, + 240);*/ + + } + + private static final ItemStack getTierOneChip() { + return CI.getNumberedAdvancedCircuit(4); + } + + private static final ItemStack getTierTwoChip() { + return CI.getNumberedAdvancedCircuit(8); + } + + private static final ItemStack getTierThreeChip() { + return CI.getNumberedAdvancedCircuit(12); + } + + private static final ItemStack getTierFourChip() { + return CI.getNumberedAdvancedCircuit(16); + } + + private static void recipeAdvancedChip() { + GT_ModHandler.addShapelessCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 0L), + 0, + new Object[] {OrePrefixes.circuit.get(Materials.Advanced)}); + + long bits = 0; + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 1L, new Object[0]), bits, new Object[] { + "d ", " P ", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) + }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 2L, new Object[0]), bits, new Object[] { + " d ", " P ", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) + }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 3L, new Object[0]), bits, new Object[] { + " d", " P ", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) + }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 4L, new Object[0]), bits, new Object[] { + " ", " Pd", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) + }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 5L, new Object[0]), bits, new Object[] { + " ", " P ", " d", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) + }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 6L, new Object[0]), bits, new Object[] { + " ", " P ", " d ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) + }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 7L, new Object[0]), bits, new Object[] { + " ", " P ", "d ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) + }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 8L, new Object[0]), bits, new Object[] { + " ", "dP ", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) + }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 9L, new Object[0]), bits, new Object[] { + "P d", " ", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) + }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 10L, new Object[0]), bits, new Object[] { + "P ", " d", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) + }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 11L, new Object[0]), bits, new Object[] { + "P ", " ", " d", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) + }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 12L, new Object[0]), bits, new Object[] { + "P ", " ", " d ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) + }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 13L, new Object[0]), bits, new Object[] { + " P", " ", " d", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) + }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 14L, new Object[0]), bits, new Object[] { + " P", " ", " d ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) + }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 15L, new Object[0]), bits, new Object[] { + " P", " ", "d ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) + }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 16L, new Object[0]), bits, new Object[] { + " P", "d ", " ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) + }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 17L, new Object[0]), bits, new Object[] { + " ", " ", "d P", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) + }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 18L, new Object[0]), bits, new Object[] { + " ", "d ", " P", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) + }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 19L, new Object[0]), bits, new Object[] { + "d ", " ", " P", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) + }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 20L, new Object[0]), bits, new Object[] { + " d ", " ", " P", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) + }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 21L, new Object[0]), bits, new Object[] { + "d ", " ", "P ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) + }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 22L, new Object[0]), bits, new Object[] { + " d ", " ", "P ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) + }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 23L, new Object[0]), bits, new Object[] { + " d", " ", "P ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) + }); + BioRecipes.addCraftingRecipe( + GregtechItemList.Circuit_T3RecipeSelector.getWithDamage(1L, 24L, new Object[0]), bits, new Object[] { + " ", " d", "P ", 'P', GregtechItemList.Circuit_T3RecipeSelector.getWildcard(1L, new Object[0]) + }); + } } diff --git a/src/main/java/gtPlusPlus/core/item/chemistry/IonParticles.java b/src/main/java/gtPlusPlus/core/item/chemistry/IonParticles.java index e08a509436..c2671fd401 100644 --- a/src/main/java/gtPlusPlus/core/item/chemistry/IonParticles.java +++ b/src/main/java/gtPlusPlus/core/item/chemistry/IonParticles.java @@ -1,13 +1,12 @@ package gtPlusPlus.core.item.chemistry; -import java.util.HashMap; -import java.util.List; - import gregtech.api.enums.Materials; import gtPlusPlus.core.item.base.misc.BaseItemParticle; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.util.Utils; +import java.util.HashMap; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; @@ -18,148 +17,142 @@ import net.minecraft.util.IIcon; public class IonParticles extends BaseItemParticle { - public static HashMap NameToMetaMap = new HashMap(); - public static HashMap MetaToNameMap = new HashMap(); - - - public IonParticles() { - super("Ion", ELEMENT.NAMES.length, EnumRarity.rare); - } - - public static IIcon[] overlays = new IIcon[ELEMENT.NAMES.length]; - public static IIcon baseTexture; - - static { - //Generate Ions - int key = 0; - for (String s : ELEMENT.NAMES) { - //Map names to Meta - NameToMetaMap.put(Utils.sanitizeString(s.toLowerCase()), key); - MetaToNameMap.put(key, Utils.sanitizeString(s.toLowerCase())); - Materials m = Materials.get(s); - int aColour = 0; - if (m == null) { - aColour = Utils.rgbtoHexValue(128, 128, 128); - } - else { - aColour = Utils.rgbtoHexValue(m.mRGBa[0], m.mRGBa[1], m.mRGBa[2]); - } - aColourMap.put(key++, aColour); - } - - } - - @Override - public String[] getAffixes() { - return new String[] {"", ""}; - } - - @Override - public String getUnlocalizedName() { - return ""; - } - - @Override + public static HashMap NameToMetaMap = new HashMap(); + public static HashMap MetaToNameMap = new HashMap(); + + public IonParticles() { + super("Ion", ELEMENT.NAMES.length, EnumRarity.rare); + } + + public static IIcon[] overlays = new IIcon[ELEMENT.NAMES.length]; + public static IIcon baseTexture; + + static { + // Generate Ions + int key = 0; + for (String s : ELEMENT.NAMES) { + // Map names to Meta + NameToMetaMap.put(Utils.sanitizeString(s.toLowerCase()), key); + MetaToNameMap.put(key, Utils.sanitizeString(s.toLowerCase())); + Materials m = Materials.get(s); + int aColour = 0; + if (m == null) { + aColour = Utils.rgbtoHexValue(128, 128, 128); + } else { + aColour = Utils.rgbtoHexValue(m.mRGBa[0], m.mRGBa[1], m.mRGBa[2]); + } + aColourMap.put(key++, aColour); + } + } + + @Override + public String[] getAffixes() { + return new String[] {"", ""}; + } + + @Override + public String getUnlocalizedName() { + return ""; + } + + @Override public String getUnlocalizedName(final ItemStack itemStack) { return "item.particle.ion" + "." + ELEMENT.NAMES[itemStack.getItemDamage()]; } - - private static boolean createNBT(ItemStack rStack){ - final NBTTagCompound tagMain = new NBTTagCompound(); - final NBTTagCompound tagNBT = new NBTTagCompound(); - tagNBT.setLong("Charge", 0); - tagMain.setTag("Ion", tagNBT); - rStack.setTagCompound(tagMain); - return true; - } - - public static final long getChargeState(final ItemStack aStack) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("Ion"); - if (aNBT != null) { - return aNBT.getLong("Charge"); - } - } - else { - createNBT(aStack); - } - return 0L; - } - - public static final boolean setChargeState(final ItemStack aStack, final long aCharge) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("Ion"); - if (aNBT != null) { - aNBT.setLong("Charge", aCharge); - return true; - } - } - return false; - } - - @Override - public double getDurabilityForDisplay(ItemStack stack) { - if (stack.getTagCompound() == null){ - createNBT(stack); + + private static boolean createNBT(ItemStack rStack) { + final NBTTagCompound tagMain = new NBTTagCompound(); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setLong("Charge", 0); + tagMain.setTag("Ion", tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public static final long getChargeState(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("Ion"); + if (aNBT != null) { + return aNBT.getLong("Charge"); + } + } else { + createNBT(aStack); } - double chargeState = getChargeState(stack); - return chargeState; - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { - long aCharge = getChargeState(stack); - String aState = EnumChatFormatting.YELLOW+"Unknown"+EnumChatFormatting.GRAY; - //State not set - if (aCharge == 0) { - list.add(EnumChatFormatting.GRAY+"A "+MetaToNameMap.get(stack.getItemDamage())+" Ion with an "+aState+" charge state"); - } - else { - if (aCharge > 0) { - aState = EnumChatFormatting.GREEN+"Positive"+EnumChatFormatting.GRAY; - } - else { - aState = EnumChatFormatting.RED+"Negative"+EnumChatFormatting.GRAY; - } - - list.add(EnumChatFormatting.GRAY+"A "+MetaToNameMap.get(stack.getItemDamage())+" Ion with a "+aState+" charge state of "+aCharge+""); - } - super.addInformation(stack, player, list, bool); - } - - @Override - public void registerIcons(IIconRegister reg) { - for (int i = 0; i < IonParticles.overlays.length; i++) { - IonParticles.overlays[i] = reg.registerIcon(CORE.MODID + ":" + "ion/"+i); - } - IonParticles.baseTexture = reg.registerIcon(CORE.MODID + ":" + "ion/IonBase"); - } - - @Override - public IIcon getIconFromDamage(int meta) { - return IonParticles.overlays[meta]; - } - - @Override - public boolean requiresMultipleRenderPasses() { - return true; - } - - @Override - public IIcon getIconFromDamageForRenderPass(int aMeta, int aPass) { - if (aPass == 0) { - return IonParticles.baseTexture; - } - else { - return IonParticles.overlays[aMeta]; - } - } - - @Override - public int getRenderPasses(int metadata) { - return 2; - } + return 0L; + } + public static final boolean setChargeState(final ItemStack aStack, final long aCharge) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("Ion"); + if (aNBT != null) { + aNBT.setLong("Charge", aCharge); + return true; + } + } + return false; + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + if (stack.getTagCompound() == null) { + createNBT(stack); + } + double chargeState = getChargeState(stack); + return chargeState; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { + long aCharge = getChargeState(stack); + String aState = EnumChatFormatting.YELLOW + "Unknown" + EnumChatFormatting.GRAY; + // State not set + if (aCharge == 0) { + list.add(EnumChatFormatting.GRAY + "A " + MetaToNameMap.get(stack.getItemDamage()) + " Ion with an " + + aState + " charge state"); + } else { + if (aCharge > 0) { + aState = EnumChatFormatting.GREEN + "Positive" + EnumChatFormatting.GRAY; + } else { + aState = EnumChatFormatting.RED + "Negative" + EnumChatFormatting.GRAY; + } + + list.add(EnumChatFormatting.GRAY + "A " + MetaToNameMap.get(stack.getItemDamage()) + " Ion with a " + aState + + " charge state of " + aCharge + ""); + } + super.addInformation(stack, player, list, bool); + } + + @Override + public void registerIcons(IIconRegister reg) { + for (int i = 0; i < IonParticles.overlays.length; i++) { + IonParticles.overlays[i] = reg.registerIcon(CORE.MODID + ":" + "ion/" + i); + } + IonParticles.baseTexture = reg.registerIcon(CORE.MODID + ":" + "ion/IonBase"); + } + + @Override + public IIcon getIconFromDamage(int meta) { + return IonParticles.overlays[meta]; + } + + @Override + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + public IIcon getIconFromDamageForRenderPass(int aMeta, int aPass) { + if (aPass == 0) { + return IonParticles.baseTexture; + } else { + return IonParticles.overlays[aMeta]; + } + } + + @Override + public int getRenderPasses(int metadata) { + return 2; + } } diff --git a/src/main/java/gtPlusPlus/core/item/chemistry/MilledOreProcessing.java b/src/main/java/gtPlusPlus/core/item/chemistry/MilledOreProcessing.java index 461a542e15..497334881d 100644 --- a/src/main/java/gtPlusPlus/core/item/chemistry/MilledOreProcessing.java +++ b/src/main/java/gtPlusPlus/core/item/chemistry/MilledOreProcessing.java @@ -1,7 +1,5 @@ package gtPlusPlus.core.item.chemistry; -import java.util.HashMap; - import gregtech.api.enums.Materials; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; @@ -20,6 +18,7 @@ import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.minecraft.*; import gtPlusPlus.xmod.bop.HANDLER_BiomesOPlenty; import gtPlusPlus.xmod.bop.blocks.BOP_Block_Registrator; +import java.util.HashMap; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; @@ -27,794 +26,776 @@ import net.minecraftforge.fluids.FluidStack; public class MilledOreProcessing extends ItemPackage { - /** - * Fluids - */ - - public static Fluid SphaleriteFlotationFroth; - public static Fluid ChalcopyriteFlotationFroth; - public static Fluid NickelFlotationFroth; - public static Fluid PlatinumFlotationFroth; - public static Fluid PentlanditeFlotationFroth; - - public static Fluid RedstoneFlotationFroth; - public static Fluid SpessartineFlotationFroth; - public static Fluid GrossularFlotationFroth; - public static Fluid AlmandineFlotationFroth; - public static Fluid PyropeFlotationFroth; - public static Fluid MonaziteFlotationFroth; - - public static Fluid PineOil; - - - /** - * Items - */ - - // Zinc, Iron, Indium, Germanium - public static Item milledSphalerite; - - // Copper, Iron, Cadmium, Indium - public static Item milledChalcopyrite; - - // Nickel, Cobalt, Rhodium, Ruthenium - public static Item milledNickel; - - // Platinum, Rhodium, Selenium, Tellurium - public static Item milledPlatinum; - - // Iron, Nickel, Promethium, Hafnium - public static Item milledPentlandite; - - - - - // Redstone, Chrome, Firestone, Dysprosium - public static Item milledRedstone; - - // Manganese, Aluminium, Osmium, Strontium - public static Item milledSpessartine; - - // Calcium, Aluminium, Tungsten, Thallium - public static Item milledGrossular; - - // Aluminium, Magnesium, Yttrium, Ytterbium - public static Item milledAlmandine; - - // Magnesium, Manganese, Borax, Rhenium - public static Item milledPyrope; - - // Erbium, Lanthanum, Praseodymium, Europium - public static Item milledMonazite; - - - @Override - public void items() { - - milledSphalerite = BaseItemMilledOre.generate(Materials.Sphalerite, MaterialUtils.getVoltageForTier(6)); - milledChalcopyrite = BaseItemMilledOre.generate(Materials.Chalcopyrite, MaterialUtils.getVoltageForTier(5)); - milledNickel = BaseItemMilledOre.generate(Materials.Nickel, MaterialUtils.getVoltageForTier(5)); - milledPlatinum = BaseItemMilledOre.generate(Materials.Platinum, MaterialUtils.getVoltageForTier(6)); - milledPentlandite = BaseItemMilledOre.generate(Materials.Pentlandite, MaterialUtils.getVoltageForTier(6)); - - milledRedstone = BaseItemMilledOre.generate(Materials.Redstone, MaterialUtils.getVoltageForTier(5)); - milledSpessartine = BaseItemMilledOre.generate(Materials.Spessartine, MaterialUtils.getVoltageForTier(6)); - milledGrossular = BaseItemMilledOre.generate(Materials.Grossular, MaterialUtils.getVoltageForTier(6)); - milledAlmandine = BaseItemMilledOre.generate(Materials.Almandine, MaterialUtils.getVoltageForTier(6)); - milledPyrope = BaseItemMilledOre.generate(Materials.Pyrope, MaterialUtils.getVoltageForTier(4)); - milledMonazite = BaseItemMilledOre.generate(Materials.Monazite, MaterialUtils.getVoltageForTier(7)); - - } - - @Override - public void blocks() { - // None yet - } - - @Override - public void fluids() { - - short[] aZincFrothRGB = Materials.Sphalerite.mRGBa; - SphaleriteFlotationFroth = FluidUtils.generateFluidNoPrefix("froth.zincflotation", "Sphalerite Froth", 32 + 175, new short[] { aZincFrothRGB[0], aZincFrothRGB[1], aZincFrothRGB[2], 100 }, true); - short[] aCopperFrothRGB = Materials.Chalcopyrite.mRGBa; - ChalcopyriteFlotationFroth = FluidUtils.generateFluidNoPrefix("froth.copperflotation", "Chalcopyrite Froth", 32 + 175, new short[] { aCopperFrothRGB[0], aCopperFrothRGB[1], aCopperFrothRGB[2], 100 }, true); - short[] aNickelFrothRGB = Materials.Nickel.mRGBa; - NickelFlotationFroth = FluidUtils.generateFluidNoPrefix("froth.nickelflotation", "Nickel Froth", 32 + 175, new short[] { aNickelFrothRGB[0], aNickelFrothRGB[1], aNickelFrothRGB[2], 100 }, true); - short[] aPlatinumFrothRGB = Materials.Platinum.mRGBa; - PlatinumFlotationFroth = FluidUtils.generateFluidNoPrefix("froth.platinumflotation", "Platinum Froth", 32 + 175, new short[] { aPlatinumFrothRGB[0], aPlatinumFrothRGB[1], aPlatinumFrothRGB[2], 100 }, true); - short[] aPentlanditeFrothRGB = Materials.Pentlandite.mRGBa; - PentlanditeFlotationFroth = FluidUtils.generateFluidNoPrefix("froth.pentlanditeflotation", "Pentlandite Froth", 32 + 175, new short[] { aPentlanditeFrothRGB[0], aPentlanditeFrothRGB[1], aPentlanditeFrothRGB[2], 100 }, true); - - short[] aRedstoneFrothRGB = Materials.Redstone.mRGBa; - RedstoneFlotationFroth = FluidUtils.generateFluidNoPrefix("froth.redstoneflotation", "Redstone Froth", 32 + 175, new short[] { aRedstoneFrothRGB[0], aRedstoneFrothRGB[1], aRedstoneFrothRGB[2], 100 }, true); - short[] aSpessartineFrothRGB = Materials.Spessartine.mRGBa; - SpessartineFlotationFroth = FluidUtils.generateFluidNoPrefix("froth.spessartineflotation", "Spessartine Froth", 32 + 175, new short[] { aSpessartineFrothRGB[0], aSpessartineFrothRGB[1], aSpessartineFrothRGB[2], 100 }, true); - short[] aGrossularFrothRGB = Materials.Grossular.mRGBa; - GrossularFlotationFroth = FluidUtils.generateFluidNoPrefix("froth.grossularflotation", "Grossular Froth", 32 + 175, new short[] { aGrossularFrothRGB[0], aGrossularFrothRGB[1], aGrossularFrothRGB[2], 100 }, true); - short[] aAlmandineFrothRGB = Materials.Almandine.mRGBa; - AlmandineFlotationFroth = FluidUtils.generateFluidNoPrefix("froth.almandineflotation", "Almandine Froth", 32 + 175, new short[] { aAlmandineFrothRGB[0], aAlmandineFrothRGB[1], aAlmandineFrothRGB[2], 100 }, true); - short[] aPyropeFrothRGB = Materials.Pyrope.mRGBa; - PyropeFlotationFroth = FluidUtils.generateFluidNoPrefix("froth.pyropeflotation", "Pyrope Froth", 32 + 175, new short[] { aPyropeFrothRGB[0], aPyropeFrothRGB[1], aPyropeFrothRGB[2], 100 }, true); - short[] aMonaziteFrothRGB = Materials.Monazite.mRGBa; - MonaziteFlotationFroth = FluidUtils.generateFluidNoPrefix("froth.Monaziteflotation", "Monazite Froth", 32 + 175, new short[] { aMonaziteFrothRGB[0], aMonaziteFrothRGB[1], aMonaziteFrothRGB[2], 100 }, true); - - - PineOil = FluidUtils.generateFluidNoPrefix("pineoil", "Pine Oil", 32 + 175, new short[] { 250, 200, 60, 100 }, true); - - } - - - - public MilledOreProcessing() { - super(); - Logger.INFO("Adding Ore Milling content"); - } - - private static void addMiscRecipes() { - - /* - * First 5 - */ - - //milledSphalerite - registerOreDataForMilledType( - SphaleriteFlotationFroth, - ELEMENT.getInstance().ZINC, 180, - ELEMENT.getInstance().IRON, 120, - ELEMENT.getInstance().INDIUM, 64, - ELEMENT.getInstance().GERMANIUM, 15 - ); - //milledChalcopyrite - registerOreDataForMilledType( - ChalcopyriteFlotationFroth, - ELEMENT.getInstance().COPPER, 180, - ELEMENT.getInstance().IRON, 120, - ELEMENT.getInstance().CADMIUM, 50, - ELEMENT.getInstance().INDIUM, 10 - ); - //milledNickel - registerOreDataForMilledType( - NickelFlotationFroth, - ELEMENT.getInstance().NICKEL, 150, - ELEMENT.getInstance().COBALT, 120, - ELEMENT.getInstance().RHODIUM, 32, - ELEMENT.getInstance().RUTHENIUM, 16 - ); - //milledPlatinum - registerOreDataForMilledType( - PlatinumFlotationFroth, - ELEMENT.getInstance().PLATINUM, 120, - ELEMENT.getInstance().RHODIUM, 60, - ELEMENT.getInstance().SELENIUM, 40, - ELEMENT.getInstance().TELLURIUM, 10 - ); - //milledPentlandite - registerOreDataForMilledType( - PentlanditeFlotationFroth, - ELEMENT.getInstance().IRON, 150, - ELEMENT.getInstance().NICKEL, 100, - ELEMENT.getInstance().PROMETHIUM, 20, - ELEMENT.getInstance().HAFNIUM, 10 - ); - - /* - * Second 5 - */ - //milledRedstone - registerOreDataForMilledType( - RedstoneFlotationFroth, - NONMATERIAL.REDSTONE, 300, - ELEMENT.getInstance().CHROMIUM, 60, - MaterialUtils.generateMaterialFromGtENUM(Materials.Firestone), 45, - ELEMENT.getInstance().DYSPROSIUM, 16 - ); - //milledSpessartine - registerOreDataForMilledType( - SpessartineFlotationFroth, - ELEMENT.getInstance().MANGANESE, 150, - ELEMENT.getInstance().ALUMINIUM, 90, - ELEMENT.getInstance().OSMIUM, 30, - ELEMENT.getInstance().STRONTIUM, 20 - ); - //milledGrossular - registerOreDataForMilledType( - GrossularFlotationFroth, - ELEMENT.getInstance().CALCIUM, 180, - ELEMENT.getInstance().ALUMINIUM, 110, - ELEMENT.getInstance().TUNGSTEN, 60, - ELEMENT.getInstance().THALLIUM, 15 - ); - //milledAlmandine - registerOreDataForMilledType( - AlmandineFlotationFroth, - ELEMENT.getInstance().ALUMINIUM, 150, - ELEMENT.getInstance().MAGNESIUM, 75, - ELEMENT.getInstance().YTTRIUM, 25, - ELEMENT.getInstance().YTTERBIUM, 15 - ); - //milledPyrope - registerOreDataForMilledType( - PyropeFlotationFroth, - ELEMENT.getInstance().MAGNESIUM, 110, - ELEMENT.getInstance().MANGANESE, 70, - MaterialUtils.generateMaterialFromGtENUM(Materials.Borax), 60, - ELEMENT.getInstance().RHENIUM, 20 - ); - //milledMonazite TODO - registerOreDataForMilledType( - MonaziteFlotationFroth, - ELEMENT.getInstance().ERBIUM, 64, - ELEMENT.getInstance().LANTHANUM, 32, - ELEMENT.getInstance().LUTETIUM, 16, - ELEMENT.getInstance().EUROPIUM, 8 - ); - - - } - - @Override - public String errorMessage() { - return "Failed to generate recipes for OreMillingProc."; - } - - @Override - public boolean generateRecipes() { - addMiscRecipes(); - addPineOilExtraction(); - addFlotationRecipes1(); - addFlotationRecipes2(); - addVacuumFurnaceRecipes(); - return true; - } - - private void addVacuumFurnaceRecipes() { - int aCircuitID = 1; - - CORE.RA.addVacuumFurnaceRecipe( - new ItemStack[] { - CI.getNumberedCircuit(aCircuitID++) - }, - new FluidStack[] { - FluidUtils.getFluidStack(SphaleriteFlotationFroth, 4000) - }, - getOutputsFromMap(SphaleriteFlotationFroth), - new FluidStack[] { - FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), - FluidUtils.getWater(2000) - }, - 20 * 120, - MaterialUtils.getVoltageForTier(6), - 5500); - CORE.RA.addVacuumFurnaceRecipe( - new ItemStack[] { - CI.getNumberedCircuit(aCircuitID++) - }, - new FluidStack[] { - FluidUtils.getFluidStack(ChalcopyriteFlotationFroth, 4000) - }, - getOutputsFromMap(ChalcopyriteFlotationFroth), - new FluidStack[] { - FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), - FluidUtils.getWater(2000) - }, - 20 * 120, - MaterialUtils.getVoltageForTier(5), - 4500); - - CORE.RA.addVacuumFurnaceRecipe( - new ItemStack[] { - CI.getNumberedCircuit(aCircuitID++) - }, - new FluidStack[] { - FluidUtils.getFluidStack(NickelFlotationFroth, 4000) - }, - getOutputsFromMap(NickelFlotationFroth), - new FluidStack[] { - FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), - FluidUtils.getWater(2000) - }, - 20 * 120, - MaterialUtils.getVoltageForTier(5), - 4500); - CORE.RA.addVacuumFurnaceRecipe( - new ItemStack[] { - CI.getNumberedCircuit(aCircuitID++) - }, - new FluidStack[] { - FluidUtils.getFluidStack(PlatinumFlotationFroth, 4000) - }, - getOutputsFromMap(PlatinumFlotationFroth), - new FluidStack[] { - FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), - FluidUtils.getWater(2000) - }, - 20 * 120, - MaterialUtils.getVoltageForTier(6), - 5500); - CORE.RA.addVacuumFurnaceRecipe( - new ItemStack[] { - CI.getNumberedCircuit(aCircuitID++) - }, - new FluidStack[] { - FluidUtils.getFluidStack(PentlanditeFlotationFroth, 4000) - }, - getOutputsFromMap(PentlanditeFlotationFroth), - new FluidStack[] { - FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), - FluidUtils.getWater(2000) - }, - 20 * 120, - MaterialUtils.getVoltageForTier(6), - 5500); - - - - CORE.RA.addVacuumFurnaceRecipe( - new ItemStack[] { - CI.getNumberedCircuit(aCircuitID++) - }, - new FluidStack[] { - FluidUtils.getFluidStack(RedstoneFlotationFroth, 4000) - }, - getOutputsFromMap(RedstoneFlotationFroth), - new FluidStack[] { - FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), - FluidUtils.getWater(2000) - }, - 20 * 120, - MaterialUtils.getVoltageForTier(5), - 4500); - CORE.RA.addVacuumFurnaceRecipe( - new ItemStack[] { - CI.getNumberedCircuit(aCircuitID++) - }, - new FluidStack[] { - FluidUtils.getFluidStack(SpessartineFlotationFroth, 4000) - }, - getOutputsFromMap(SpessartineFlotationFroth), - new FluidStack[] { - FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), - FluidUtils.getWater(2000) - }, - 20 * 120, - MaterialUtils.getVoltageForTier(6), - 5500); - CORE.RA.addVacuumFurnaceRecipe( - new ItemStack[] { - CI.getNumberedCircuit(aCircuitID++) - }, - new FluidStack[] { - FluidUtils.getFluidStack(GrossularFlotationFroth, 4000) - }, - getOutputsFromMap(GrossularFlotationFroth), - new FluidStack[] { - FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), - FluidUtils.getWater(2000) - }, - 20 * 120, - MaterialUtils.getVoltageForTier(6), - 5500); - CORE.RA.addVacuumFurnaceRecipe( - new ItemStack[] { - CI.getNumberedCircuit(aCircuitID++) - }, - new FluidStack[] { - FluidUtils.getFluidStack(AlmandineFlotationFroth, 4000) - }, - getOutputsFromMap(AlmandineFlotationFroth), - new FluidStack[] { - FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), - FluidUtils.getWater(2000) - }, - 20 * 120, - MaterialUtils.getVoltageForTier(6), - 5500); - CORE.RA.addVacuumFurnaceRecipe( - new ItemStack[] { - CI.getNumberedCircuit(aCircuitID++) - }, - new FluidStack[] { - FluidUtils.getFluidStack(PyropeFlotationFroth, 4000) - }, - getOutputsFromMap(PyropeFlotationFroth), - new FluidStack[] { - FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), - FluidUtils.getWater(2000) - }, - 20 * 120, - MaterialUtils.getVoltageForTier(4), - 3500); - CORE.RA.addVacuumFurnaceRecipe( - new ItemStack[] { - CI.getNumberedCircuit(aCircuitID++) - }, - new FluidStack[] { - FluidUtils.getFluidStack(MonaziteFlotationFroth, 4000) - }, - getOutputsFromMap(MonaziteFlotationFroth), - new FluidStack[] { - FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), - FluidUtils.getWater(2000) - }, - 20 * 120, - MaterialUtils.getVoltageForTier(7), - 7500); - - } - - private void addFlotationRecipes1() { - - // Sphalerite - CORE.RA.addFlotationRecipe( - Materials.Sphalerite, - ItemUtils.getSimpleStack(GenericChem.mSodiumEthylXanthate, 1), - new FluidStack[] { - FluidUtils.getFluidStack(PineOil, 14000), - }, - new FluidStack[] { - FluidUtils.getFluidStack(SphaleriteFlotationFroth, 1000) - }, - 20 * 480, - MaterialUtils.getVoltageForTier(6) - ); - - // Chalcopyrite - CORE.RA.addFlotationRecipe( - Materials.Chalcopyrite, - ItemUtils.getSimpleStack(GenericChem.mSodiumEthylXanthate, 1), - new FluidStack[] { - FluidUtils.getFluidStack(PineOil, 12000), - }, - new FluidStack[] { - FluidUtils.getFluidStack(ChalcopyriteFlotationFroth, 1000) - }, - 20 * 480, - MaterialUtils.getVoltageForTier(5) - ); - - // Nickel - CORE.RA.addFlotationRecipe( - Materials.Nickel, - ItemUtils.getSimpleStack(GenericChem.mPotassiumEthylXanthate, 1), - new FluidStack[] { - FluidUtils.getFluidStack(PineOil, 25000), - }, - new FluidStack[] { - FluidUtils.getFluidStack(NickelFlotationFroth, 1000) - }, - 20 * 480, - MaterialUtils.getVoltageForTier(5) - ); - - // Platinum - CORE.RA.addFlotationRecipe( - Materials.Platinum, - ItemUtils.getSimpleStack(GenericChem.mPotassiumEthylXanthate, 1), - new FluidStack[] { - FluidUtils.getFluidStack(PineOil, 35000), - }, - new FluidStack[] { - FluidUtils.getFluidStack(PlatinumFlotationFroth, 1000) - }, - 20 * 480, - MaterialUtils.getVoltageForTier(6) - ); - - - // Pentlandite - CORE.RA.addFlotationRecipe( - Materials.Pentlandite, - ItemUtils.getSimpleStack(GenericChem.mSodiumEthylXanthate, 1), - new FluidStack[] { - FluidUtils.getFluidStack(PineOil, 14000), - }, - new FluidStack[] { - FluidUtils.getFluidStack(PentlanditeFlotationFroth, 1000) - }, - 20 * 480, - MaterialUtils.getVoltageForTier(6) - ); - - } - - private void addFlotationRecipes2() { - - // Redstone - CORE.RA.addFlotationRecipe( - Materials.Redstone, - ItemUtils.getSimpleStack(GenericChem.mSodiumEthylXanthate, 1), - new FluidStack[] { - FluidUtils.getFluidStack(PineOil, 13000), - }, - new FluidStack[] { - FluidUtils.getFluidStack(RedstoneFlotationFroth, 1000) - }, - 20 * 480, - MaterialUtils.getVoltageForTier(5) - ); - - // Spessartine - CORE.RA.addFlotationRecipe( - Materials.Spessartine, - ItemUtils.getSimpleStack(GenericChem.mPotassiumEthylXanthate, 1), - new FluidStack[] { - FluidUtils.getFluidStack(PineOil, 35000), - }, - new FluidStack[] { - FluidUtils.getFluidStack(SpessartineFlotationFroth, 1000) - }, - 20 * 480, - MaterialUtils.getVoltageForTier(6) - ); - - // Grossular - CORE.RA.addFlotationRecipe( - Materials.Grossular, - ItemUtils.getSimpleStack(GenericChem.mPotassiumEthylXanthate, 1), - new FluidStack[] { - FluidUtils.getFluidStack(PineOil, 28000), - }, - new FluidStack[] { - FluidUtils.getFluidStack(GrossularFlotationFroth, 1000) - }, - 20 * 480, - MaterialUtils.getVoltageForTier(6) - ); - - // Almandine - CORE.RA.addFlotationRecipe( - Materials.Almandine, - ItemUtils.getSimpleStack(GenericChem.mSodiumEthylXanthate, 1), - new FluidStack[] { - FluidUtils.getFluidStack(PineOil, 18000), - }, - new FluidStack[] { - FluidUtils.getFluidStack(AlmandineFlotationFroth, 1000) - }, - 20 * 480, - MaterialUtils.getVoltageForTier(5) - ); - - // Pyrope - CORE.RA.addFlotationRecipe( - Materials.Pyrope, - ItemUtils.getSimpleStack(GenericChem.mSodiumEthylXanthate, 1), - new FluidStack[] { - FluidUtils.getFluidStack(PineOil, 8000), - }, - new FluidStack[] { - FluidUtils.getFluidStack(PyropeFlotationFroth, 1000) - }, - 20 * 480, - MaterialUtils.getVoltageForTier(4) - ); - - // Monazite - CORE.RA.addFlotationRecipe( - Materials.Monazite, - ItemUtils.getSimpleStack(GenericChem.mPotassiumEthylXanthate, 1), - new FluidStack[] { - FluidUtils.getFluidStack(PineOil, 30000), - }, - new FluidStack[] { - FluidUtils.getFluidStack(MonaziteFlotationFroth, 1000) - }, - 20 * 480, - MaterialUtils.getVoltageForTier(6) - ); - - } - - private void addPineOilExtraction() { - AutoMap aLogs = new AutoMap(); - AutoMap aLeaves = new AutoMap(); - AutoMap aSaplings = new AutoMap(); - AutoMap aPinecones = new AutoMap(); - - ItemStack aCrushedPine = ItemUtils.getSimpleStack(AgriculturalChem.mCrushedPine, 1); - - aLogs.add(ItemUtils.getSimpleStack(BOP_Block_Registrator.log_Pine)); - aLeaves.add(ItemUtils.getSimpleStack(BOP_Block_Registrator.leaves_Pine)); - aSaplings.add(ItemUtils.getSimpleStack(BOP_Block_Registrator.sapling_Pine)); - aPinecones.add(ItemUtils.getSimpleStack(AgriculturalChem.mPinecone, 1)); - - if (LoadedMods.BiomesOPlenty) { - aLogs.add(HANDLER_BiomesOPlenty.getStack(HANDLER_BiomesOPlenty.logs4, 0, 1)); - aLeaves.add(HANDLER_BiomesOPlenty.getStack(HANDLER_BiomesOPlenty.colorizedLeaves2, 1, 1)); - aSaplings.add(HANDLER_BiomesOPlenty.getStack(HANDLER_BiomesOPlenty.colorizedSaplings, 5, 1)); - aPinecones.add(ItemUtils.simpleMetaStack(HANDLER_BiomesOPlenty.mPineCone, 13, 1)); - } - if (LoadedMods.Forestry) { - ItemStack aForestryLog = ItemUtils.getItemStackFromFQRN("Forestry:logs", 1); - if (aForestryLog != null) { - aForestryLog.setItemDamage(20); // Set to Pine - aLogs.add(aForestryLog); - } - ItemStack aForestryLeaves = ItemUtils.getItemStackFromFQRN("Forestry:leaves", 1); - if (aForestryLeaves != null) { - NBTUtils.setString(aForestryLeaves, "species", "forestry.treePine"); // Set to Pine - aLeaves.add(aForestryLeaves); - } - } - - for (ItemStack aLog : aLogs) { - addRecipe(aLog, ItemUtils.getSimpleStack(aCrushedPine, 16), new int[] {10000, 7500, 5000, 2500}, 10, 120); - } - for (ItemStack aLeaf : aLeaves) { - addRecipe(aLeaf, ItemUtils.getSimpleStack(aCrushedPine, 2), new int[] {5000, 5000, 2500, 2500}, 10, 30); - } - for (ItemStack aSapling : aSaplings) { - addRecipe(aSapling, ItemUtils.getSimpleStack(aCrushedPine, 4), new int[] {7500, 7500, 2500, 2500}, 10, 60); - } - for (ItemStack aCone : aPinecones) { - addRecipe(aCone, ItemUtils.getSimpleStack(aCrushedPine, 1), new int[] {7500, 7500, 5000, 2500}, 10, 60); - } - - - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(16), - ItemUtils.getSimpleStack(aCrushedPine, 64) - }, - new FluidStack[] { - FluidUtils.getSteam(5000), - }, - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("dustTinyAsh", 5), - ItemUtils.getItemStackOfAmountFromOreDict("dustTinyAsh", 5), - ItemUtils.getItemStackOfAmountFromOreDict("dustTinyDarkAsh", 5), - ItemUtils.getItemStackOfAmountFromOreDict("dustTinyDarkAsh", 5) - }, - new FluidStack[] { - FluidUtils.getFluidStack(PineOil, 500) - }, - new int[] { - 2000, 2000, 2000, 2000 - }, - 20 * 60, - 120, - 3); - - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(18), - ItemUtils.getSimpleStack(aCrushedPine, 64) - }, - new FluidStack[] { - FluidUtils.getSuperHeatedSteam(5000), - }, - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("dustTinyAsh", 5), - ItemUtils.getItemStackOfAmountFromOreDict("dustTinyAsh", 5), - ItemUtils.getItemStackOfAmountFromOreDict("dustTinyDarkAsh", 5), - ItemUtils.getItemStackOfAmountFromOreDict("dustTinyDarkAsh", 5) - }, - new FluidStack[] { - FluidUtils.getFluidStack(PineOil, 1500) - }, - new int[] { - 3000, 3000, 3000, 3000 - }, - 20 * 45, - 120, - 4); - - } - - public boolean addRecipe(ItemStack aInput, ItemStack aOutput1, int[] aChances, int aTime, int aEU) { - aOutput1 = GT_OreDictUnificator.get(true, aOutput1); - ItemStack aOutputs[] = new ItemStack[4]; - for (int i=0;i aCleanedItems = new AutoMap(); - for (ItemStack checkStack : input) { - if (ItemUtils.checkForInvalidItems(checkStack)) { - aCleanedItems.put(checkStack); - } - } - ItemStack[] aOutput = new ItemStack[aCleanedItems.size()]; - for (int i=0;i, Pair, Pair, Pair>> aMilledFluidMap = new HashMap, Pair, Pair, Pair>>(); - - public static void registerOreDataForMilledType(Fluid aMilledFluid, Materials aOutput1, int aPerc1, Materials aOutput2, int aPerc2, Materials aOutput3, int aPerc3, Materials aOutput4, int aPerc4) { - registerOreDataForMilledType(aMilledFluid, MaterialUtils.generateMaterialFromGtENUM(aOutput1), aPerc1, MaterialUtils.generateMaterialFromGtENUM(aOutput2), aPerc2, MaterialUtils.generateMaterialFromGtENUM(aOutput3), aPerc3, MaterialUtils.generateMaterialFromGtENUM(aOutput4), aPerc4); - } - - public static void registerOreDataForMilledType(Fluid aMilledFluid, Material aOutput1, int aPerc1, Material aOutput2, int aPerc2, Material aOutput3, int aPerc3, Material aOutput4, int aPerc4) { - - Pair aFluidOutput1 = new Pair(aOutput1, aPerc1); - Pair aFluidOutput2 = new Pair(aOutput2, aPerc2); - Pair aFluidOutput3 = new Pair(aOutput3, aPerc3); - Pair aFluidOutput4 = new Pair(aOutput4, aPerc4); - Quad, Pair, Pair, Pair> aDataQuad = new Quad, Pair, Pair, Pair>(aFluidOutput1, aFluidOutput2, aFluidOutput3, aFluidOutput4); - aMilledFluidMap.put(aMilledFluid.getUnlocalizedName(), aDataQuad); - - } - - private static ItemStack[] getOutputsFromMap(Fluid aFluid) { - String aKey = aFluid.getUnlocalizedName(); - return getArrayFromQuad(aMilledFluidMap.get(aKey)); - } - - private static ItemStack[] getArrayFromQuad(Quad, Pair, Pair, Pair> aData) { - AutoMap aOutputs = new AutoMap(); - for (Object aPair : aData.values()) { - if (aPair != null && Pair.class.isInstance(aPair)) { - Pair aObj = (Pair) aPair; - Material aMat = (Material) aObj.getKey(); - int aCount = (int) aObj.getValue(); - aOutputs.addAll(getItemStackFromPair(aMat, aCount)); - } - } - ItemStack[] aRealOutputArray = new ItemStack[aOutputs.size()]; - int aIndex = 0; - for (ItemStack aStack : aOutputs) { - aRealOutputArray[aIndex++] = aStack; - } - return aRealOutputArray; - } - - private static AutoMap getItemStackFromPair(Material aMat, Integer aCount) { - AutoMap aOutputs = new AutoMap(); - if (aCount > 64) { - AutoMap sizes = getStackSizes(aCount); - for (int aSplitSize : sizes) { - ItemStack aDustStack = aMat.getDust(aSplitSize); - aOutputs.put(aDustStack); - } - } - else { - ItemStack aDustStack = aMat.getDust(aCount); - aOutputs.put(aDustStack); - } - return aOutputs; - } - - private static AutoMap getStackSizes(int aBigSize){ - AutoMap aSizes = new AutoMap(); - if (aBigSize <= 64) { - aSizes.add(aBigSize); - } - else { - for (int i = aBigSize; i > 0; i -= 64) { - aSizes.add(i); - } - } - return aSizes; - } - + /** + * Fluids + */ + public static Fluid SphaleriteFlotationFroth; + + public static Fluid ChalcopyriteFlotationFroth; + public static Fluid NickelFlotationFroth; + public static Fluid PlatinumFlotationFroth; + public static Fluid PentlanditeFlotationFroth; + + public static Fluid RedstoneFlotationFroth; + public static Fluid SpessartineFlotationFroth; + public static Fluid GrossularFlotationFroth; + public static Fluid AlmandineFlotationFroth; + public static Fluid PyropeFlotationFroth; + public static Fluid MonaziteFlotationFroth; + + public static Fluid PineOil; + + /** + * Items + */ + + // Zinc, Iron, Indium, Germanium + public static Item milledSphalerite; + + // Copper, Iron, Cadmium, Indium + public static Item milledChalcopyrite; + + // Nickel, Cobalt, Rhodium, Ruthenium + public static Item milledNickel; + + // Platinum, Rhodium, Selenium, Tellurium + public static Item milledPlatinum; + + // Iron, Nickel, Promethium, Hafnium + public static Item milledPentlandite; + + // Redstone, Chrome, Firestone, Dysprosium + public static Item milledRedstone; + + // Manganese, Aluminium, Osmium, Strontium + public static Item milledSpessartine; + + // Calcium, Aluminium, Tungsten, Thallium + public static Item milledGrossular; + + // Aluminium, Magnesium, Yttrium, Ytterbium + public static Item milledAlmandine; + + // Magnesium, Manganese, Borax, Rhenium + public static Item milledPyrope; + + // Erbium, Lanthanum, Praseodymium, Europium + public static Item milledMonazite; + + @Override + public void items() { + + milledSphalerite = BaseItemMilledOre.generate(Materials.Sphalerite, MaterialUtils.getVoltageForTier(6)); + milledChalcopyrite = BaseItemMilledOre.generate(Materials.Chalcopyrite, MaterialUtils.getVoltageForTier(5)); + milledNickel = BaseItemMilledOre.generate(Materials.Nickel, MaterialUtils.getVoltageForTier(5)); + milledPlatinum = BaseItemMilledOre.generate(Materials.Platinum, MaterialUtils.getVoltageForTier(6)); + milledPentlandite = BaseItemMilledOre.generate(Materials.Pentlandite, MaterialUtils.getVoltageForTier(6)); + + milledRedstone = BaseItemMilledOre.generate(Materials.Redstone, MaterialUtils.getVoltageForTier(5)); + milledSpessartine = BaseItemMilledOre.generate(Materials.Spessartine, MaterialUtils.getVoltageForTier(6)); + milledGrossular = BaseItemMilledOre.generate(Materials.Grossular, MaterialUtils.getVoltageForTier(6)); + milledAlmandine = BaseItemMilledOre.generate(Materials.Almandine, MaterialUtils.getVoltageForTier(6)); + milledPyrope = BaseItemMilledOre.generate(Materials.Pyrope, MaterialUtils.getVoltageForTier(4)); + milledMonazite = BaseItemMilledOre.generate(Materials.Monazite, MaterialUtils.getVoltageForTier(7)); + } + + @Override + public void blocks() { + // None yet + } + + @Override + public void fluids() { + + short[] aZincFrothRGB = Materials.Sphalerite.mRGBa; + SphaleriteFlotationFroth = FluidUtils.generateFluidNoPrefix( + "froth.zincflotation", + "Sphalerite Froth", + 32 + 175, + new short[] {aZincFrothRGB[0], aZincFrothRGB[1], aZincFrothRGB[2], 100}, + true); + short[] aCopperFrothRGB = Materials.Chalcopyrite.mRGBa; + ChalcopyriteFlotationFroth = FluidUtils.generateFluidNoPrefix( + "froth.copperflotation", + "Chalcopyrite Froth", + 32 + 175, + new short[] {aCopperFrothRGB[0], aCopperFrothRGB[1], aCopperFrothRGB[2], 100}, + true); + short[] aNickelFrothRGB = Materials.Nickel.mRGBa; + NickelFlotationFroth = FluidUtils.generateFluidNoPrefix( + "froth.nickelflotation", + "Nickel Froth", + 32 + 175, + new short[] {aNickelFrothRGB[0], aNickelFrothRGB[1], aNickelFrothRGB[2], 100}, + true); + short[] aPlatinumFrothRGB = Materials.Platinum.mRGBa; + PlatinumFlotationFroth = FluidUtils.generateFluidNoPrefix( + "froth.platinumflotation", + "Platinum Froth", + 32 + 175, + new short[] {aPlatinumFrothRGB[0], aPlatinumFrothRGB[1], aPlatinumFrothRGB[2], 100}, + true); + short[] aPentlanditeFrothRGB = Materials.Pentlandite.mRGBa; + PentlanditeFlotationFroth = FluidUtils.generateFluidNoPrefix( + "froth.pentlanditeflotation", + "Pentlandite Froth", + 32 + 175, + new short[] {aPentlanditeFrothRGB[0], aPentlanditeFrothRGB[1], aPentlanditeFrothRGB[2], 100}, + true); + + short[] aRedstoneFrothRGB = Materials.Redstone.mRGBa; + RedstoneFlotationFroth = FluidUtils.generateFluidNoPrefix( + "froth.redstoneflotation", + "Redstone Froth", + 32 + 175, + new short[] {aRedstoneFrothRGB[0], aRedstoneFrothRGB[1], aRedstoneFrothRGB[2], 100}, + true); + short[] aSpessartineFrothRGB = Materials.Spessartine.mRGBa; + SpessartineFlotationFroth = FluidUtils.generateFluidNoPrefix( + "froth.spessartineflotation", + "Spessartine Froth", + 32 + 175, + new short[] {aSpessartineFrothRGB[0], aSpessartineFrothRGB[1], aSpessartineFrothRGB[2], 100}, + true); + short[] aGrossularFrothRGB = Materials.Grossular.mRGBa; + GrossularFlotationFroth = FluidUtils.generateFluidNoPrefix( + "froth.grossularflotation", + "Grossular Froth", + 32 + 175, + new short[] {aGrossularFrothRGB[0], aGrossularFrothRGB[1], aGrossularFrothRGB[2], 100}, + true); + short[] aAlmandineFrothRGB = Materials.Almandine.mRGBa; + AlmandineFlotationFroth = FluidUtils.generateFluidNoPrefix( + "froth.almandineflotation", + "Almandine Froth", + 32 + 175, + new short[] {aAlmandineFrothRGB[0], aAlmandineFrothRGB[1], aAlmandineFrothRGB[2], 100}, + true); + short[] aPyropeFrothRGB = Materials.Pyrope.mRGBa; + PyropeFlotationFroth = FluidUtils.generateFluidNoPrefix( + "froth.pyropeflotation", + "Pyrope Froth", + 32 + 175, + new short[] {aPyropeFrothRGB[0], aPyropeFrothRGB[1], aPyropeFrothRGB[2], 100}, + true); + short[] aMonaziteFrothRGB = Materials.Monazite.mRGBa; + MonaziteFlotationFroth = FluidUtils.generateFluidNoPrefix( + "froth.Monaziteflotation", + "Monazite Froth", + 32 + 175, + new short[] {aMonaziteFrothRGB[0], aMonaziteFrothRGB[1], aMonaziteFrothRGB[2], 100}, + true); + + PineOil = FluidUtils.generateFluidNoPrefix( + "pineoil", "Pine Oil", 32 + 175, new short[] {250, 200, 60, 100}, true); + } + + public MilledOreProcessing() { + super(); + Logger.INFO("Adding Ore Milling content"); + } + + private static void addMiscRecipes() { + + /* + * First 5 + */ + + // milledSphalerite + registerOreDataForMilledType( + SphaleriteFlotationFroth, + ELEMENT.getInstance().ZINC, + 180, + ELEMENT.getInstance().IRON, + 120, + ELEMENT.getInstance().INDIUM, + 64, + ELEMENT.getInstance().GERMANIUM, + 15); + // milledChalcopyrite + registerOreDataForMilledType( + ChalcopyriteFlotationFroth, + ELEMENT.getInstance().COPPER, + 180, + ELEMENT.getInstance().IRON, + 120, + ELEMENT.getInstance().CADMIUM, + 50, + ELEMENT.getInstance().INDIUM, + 10); + // milledNickel + registerOreDataForMilledType( + NickelFlotationFroth, + ELEMENT.getInstance().NICKEL, + 150, + ELEMENT.getInstance().COBALT, + 120, + ELEMENT.getInstance().RHODIUM, + 32, + ELEMENT.getInstance().RUTHENIUM, + 16); + // milledPlatinum + registerOreDataForMilledType( + PlatinumFlotationFroth, + ELEMENT.getInstance().PLATINUM, + 120, + ELEMENT.getInstance().RHODIUM, + 60, + ELEMENT.getInstance().SELENIUM, + 40, + ELEMENT.getInstance().TELLURIUM, + 10); + // milledPentlandite + registerOreDataForMilledType( + PentlanditeFlotationFroth, + ELEMENT.getInstance().IRON, + 150, + ELEMENT.getInstance().NICKEL, + 100, + ELEMENT.getInstance().PROMETHIUM, + 20, + ELEMENT.getInstance().HAFNIUM, + 10); + + /* + * Second 5 + */ + // milledRedstone + registerOreDataForMilledType( + RedstoneFlotationFroth, + NONMATERIAL.REDSTONE, + 300, + ELEMENT.getInstance().CHROMIUM, + 60, + MaterialUtils.generateMaterialFromGtENUM(Materials.Firestone), + 45, + ELEMENT.getInstance().DYSPROSIUM, + 16); + // milledSpessartine + registerOreDataForMilledType( + SpessartineFlotationFroth, + ELEMENT.getInstance().MANGANESE, + 150, + ELEMENT.getInstance().ALUMINIUM, + 90, + ELEMENT.getInstance().OSMIUM, + 30, + ELEMENT.getInstance().STRONTIUM, + 20); + // milledGrossular + registerOreDataForMilledType( + GrossularFlotationFroth, + ELEMENT.getInstance().CALCIUM, + 180, + ELEMENT.getInstance().ALUMINIUM, + 110, + ELEMENT.getInstance().TUNGSTEN, + 60, + ELEMENT.getInstance().THALLIUM, + 15); + // milledAlmandine + registerOreDataForMilledType( + AlmandineFlotationFroth, + ELEMENT.getInstance().ALUMINIUM, + 150, + ELEMENT.getInstance().MAGNESIUM, + 75, + ELEMENT.getInstance().YTTRIUM, + 25, + ELEMENT.getInstance().YTTERBIUM, + 15); + // milledPyrope + registerOreDataForMilledType( + PyropeFlotationFroth, + ELEMENT.getInstance().MAGNESIUM, + 110, + ELEMENT.getInstance().MANGANESE, + 70, + MaterialUtils.generateMaterialFromGtENUM(Materials.Borax), + 60, + ELEMENT.getInstance().RHENIUM, + 20); + // milledMonazite TODO + registerOreDataForMilledType( + MonaziteFlotationFroth, + ELEMENT.getInstance().ERBIUM, + 64, + ELEMENT.getInstance().LANTHANUM, + 32, + ELEMENT.getInstance().LUTETIUM, + 16, + ELEMENT.getInstance().EUROPIUM, + 8); + } + + @Override + public String errorMessage() { + return "Failed to generate recipes for OreMillingProc."; + } + + @Override + public boolean generateRecipes() { + addMiscRecipes(); + addPineOilExtraction(); + addFlotationRecipes1(); + addFlotationRecipes2(); + addVacuumFurnaceRecipes(); + return true; + } + + private void addVacuumFurnaceRecipes() { + int aCircuitID = 1; + + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] {CI.getNumberedCircuit(aCircuitID++)}, + new FluidStack[] {FluidUtils.getFluidStack(SphaleriteFlotationFroth, 4000)}, + getOutputsFromMap(SphaleriteFlotationFroth), + new FluidStack[] {FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), FluidUtils.getWater(2000)}, + 20 * 120, + MaterialUtils.getVoltageForTier(6), + 5500); + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] {CI.getNumberedCircuit(aCircuitID++)}, + new FluidStack[] {FluidUtils.getFluidStack(ChalcopyriteFlotationFroth, 4000)}, + getOutputsFromMap(ChalcopyriteFlotationFroth), + new FluidStack[] {FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), FluidUtils.getWater(2000)}, + 20 * 120, + MaterialUtils.getVoltageForTier(5), + 4500); + + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] {CI.getNumberedCircuit(aCircuitID++)}, + new FluidStack[] {FluidUtils.getFluidStack(NickelFlotationFroth, 4000)}, + getOutputsFromMap(NickelFlotationFroth), + new FluidStack[] {FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), FluidUtils.getWater(2000)}, + 20 * 120, + MaterialUtils.getVoltageForTier(5), + 4500); + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] {CI.getNumberedCircuit(aCircuitID++)}, + new FluidStack[] {FluidUtils.getFluidStack(PlatinumFlotationFroth, 4000)}, + getOutputsFromMap(PlatinumFlotationFroth), + new FluidStack[] {FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), FluidUtils.getWater(2000)}, + 20 * 120, + MaterialUtils.getVoltageForTier(6), + 5500); + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] {CI.getNumberedCircuit(aCircuitID++)}, + new FluidStack[] {FluidUtils.getFluidStack(PentlanditeFlotationFroth, 4000)}, + getOutputsFromMap(PentlanditeFlotationFroth), + new FluidStack[] {FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), FluidUtils.getWater(2000)}, + 20 * 120, + MaterialUtils.getVoltageForTier(6), + 5500); + + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] {CI.getNumberedCircuit(aCircuitID++)}, + new FluidStack[] {FluidUtils.getFluidStack(RedstoneFlotationFroth, 4000)}, + getOutputsFromMap(RedstoneFlotationFroth), + new FluidStack[] {FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), FluidUtils.getWater(2000)}, + 20 * 120, + MaterialUtils.getVoltageForTier(5), + 4500); + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] {CI.getNumberedCircuit(aCircuitID++)}, + new FluidStack[] {FluidUtils.getFluidStack(SpessartineFlotationFroth, 4000)}, + getOutputsFromMap(SpessartineFlotationFroth), + new FluidStack[] {FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), FluidUtils.getWater(2000)}, + 20 * 120, + MaterialUtils.getVoltageForTier(6), + 5500); + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] {CI.getNumberedCircuit(aCircuitID++)}, + new FluidStack[] {FluidUtils.getFluidStack(GrossularFlotationFroth, 4000)}, + getOutputsFromMap(GrossularFlotationFroth), + new FluidStack[] {FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), FluidUtils.getWater(2000)}, + 20 * 120, + MaterialUtils.getVoltageForTier(6), + 5500); + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] {CI.getNumberedCircuit(aCircuitID++)}, + new FluidStack[] {FluidUtils.getFluidStack(AlmandineFlotationFroth, 4000)}, + getOutputsFromMap(AlmandineFlotationFroth), + new FluidStack[] {FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), FluidUtils.getWater(2000)}, + 20 * 120, + MaterialUtils.getVoltageForTier(6), + 5500); + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] {CI.getNumberedCircuit(aCircuitID++)}, + new FluidStack[] {FluidUtils.getFluidStack(PyropeFlotationFroth, 4000)}, + getOutputsFromMap(PyropeFlotationFroth), + new FluidStack[] {FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), FluidUtils.getWater(2000)}, + 20 * 120, + MaterialUtils.getVoltageForTier(4), + 3500); + CORE.RA.addVacuumFurnaceRecipe( + new ItemStack[] {CI.getNumberedCircuit(aCircuitID++)}, + new FluidStack[] {FluidUtils.getFluidStack(MonaziteFlotationFroth, 4000)}, + getOutputsFromMap(MonaziteFlotationFroth), + new FluidStack[] {FluidUtils.getFluidStack(AgriculturalChem.RedMud, 2000), FluidUtils.getWater(2000)}, + 20 * 120, + MaterialUtils.getVoltageForTier(7), + 7500); + } + + private void addFlotationRecipes1() { + + // Sphalerite + CORE.RA.addFlotationRecipe( + Materials.Sphalerite, + ItemUtils.getSimpleStack(GenericChem.mSodiumEthylXanthate, 1), + new FluidStack[] { + FluidUtils.getFluidStack(PineOil, 14000), + }, + new FluidStack[] {FluidUtils.getFluidStack(SphaleriteFlotationFroth, 1000)}, + 20 * 480, + MaterialUtils.getVoltageForTier(6)); + + // Chalcopyrite + CORE.RA.addFlotationRecipe( + Materials.Chalcopyrite, + ItemUtils.getSimpleStack(GenericChem.mSodiumEthylXanthate, 1), + new FluidStack[] { + FluidUtils.getFluidStack(PineOil, 12000), + }, + new FluidStack[] {FluidUtils.getFluidStack(ChalcopyriteFlotationFroth, 1000)}, + 20 * 480, + MaterialUtils.getVoltageForTier(5)); + + // Nickel + CORE.RA.addFlotationRecipe( + Materials.Nickel, + ItemUtils.getSimpleStack(GenericChem.mPotassiumEthylXanthate, 1), + new FluidStack[] { + FluidUtils.getFluidStack(PineOil, 25000), + }, + new FluidStack[] {FluidUtils.getFluidStack(NickelFlotationFroth, 1000)}, + 20 * 480, + MaterialUtils.getVoltageForTier(5)); + + // Platinum + CORE.RA.addFlotationRecipe( + Materials.Platinum, + ItemUtils.getSimpleStack(GenericChem.mPotassiumEthylXanthate, 1), + new FluidStack[] { + FluidUtils.getFluidStack(PineOil, 35000), + }, + new FluidStack[] {FluidUtils.getFluidStack(PlatinumFlotationFroth, 1000)}, + 20 * 480, + MaterialUtils.getVoltageForTier(6)); + + // Pentlandite + CORE.RA.addFlotationRecipe( + Materials.Pentlandite, + ItemUtils.getSimpleStack(GenericChem.mSodiumEthylXanthate, 1), + new FluidStack[] { + FluidUtils.getFluidStack(PineOil, 14000), + }, + new FluidStack[] {FluidUtils.getFluidStack(PentlanditeFlotationFroth, 1000)}, + 20 * 480, + MaterialUtils.getVoltageForTier(6)); + } + + private void addFlotationRecipes2() { + + // Redstone + CORE.RA.addFlotationRecipe( + Materials.Redstone, + ItemUtils.getSimpleStack(GenericChem.mSodiumEthylXanthate, 1), + new FluidStack[] { + FluidUtils.getFluidStack(PineOil, 13000), + }, + new FluidStack[] {FluidUtils.getFluidStack(RedstoneFlotationFroth, 1000)}, + 20 * 480, + MaterialUtils.getVoltageForTier(5)); + + // Spessartine + CORE.RA.addFlotationRecipe( + Materials.Spessartine, + ItemUtils.getSimpleStack(GenericChem.mPotassiumEthylXanthate, 1), + new FluidStack[] { + FluidUtils.getFluidStack(PineOil, 35000), + }, + new FluidStack[] {FluidUtils.getFluidStack(SpessartineFlotationFroth, 1000)}, + 20 * 480, + MaterialUtils.getVoltageForTier(6)); + + // Grossular + CORE.RA.addFlotationRecipe( + Materials.Grossular, + ItemUtils.getSimpleStack(GenericChem.mPotassiumEthylXanthate, 1), + new FluidStack[] { + FluidUtils.getFluidStack(PineOil, 28000), + }, + new FluidStack[] {FluidUtils.getFluidStack(GrossularFlotationFroth, 1000)}, + 20 * 480, + MaterialUtils.getVoltageForTier(6)); + + // Almandine + CORE.RA.addFlotationRecipe( + Materials.Almandine, + ItemUtils.getSimpleStack(GenericChem.mSodiumEthylXanthate, 1), + new FluidStack[] { + FluidUtils.getFluidStack(PineOil, 18000), + }, + new FluidStack[] {FluidUtils.getFluidStack(AlmandineFlotationFroth, 1000)}, + 20 * 480, + MaterialUtils.getVoltageForTier(5)); + + // Pyrope + CORE.RA.addFlotationRecipe( + Materials.Pyrope, + ItemUtils.getSimpleStack(GenericChem.mSodiumEthylXanthate, 1), + new FluidStack[] { + FluidUtils.getFluidStack(PineOil, 8000), + }, + new FluidStack[] {FluidUtils.getFluidStack(PyropeFlotationFroth, 1000)}, + 20 * 480, + MaterialUtils.getVoltageForTier(4)); + + // Monazite + CORE.RA.addFlotationRecipe( + Materials.Monazite, + ItemUtils.getSimpleStack(GenericChem.mPotassiumEthylXanthate, 1), + new FluidStack[] { + FluidUtils.getFluidStack(PineOil, 30000), + }, + new FluidStack[] {FluidUtils.getFluidStack(MonaziteFlotationFroth, 1000)}, + 20 * 480, + MaterialUtils.getVoltageForTier(6)); + } + + private void addPineOilExtraction() { + AutoMap aLogs = new AutoMap(); + AutoMap aLeaves = new AutoMap(); + AutoMap aSaplings = new AutoMap(); + AutoMap aPinecones = new AutoMap(); + + ItemStack aCrushedPine = ItemUtils.getSimpleStack(AgriculturalChem.mCrushedPine, 1); + + aLogs.add(ItemUtils.getSimpleStack(BOP_Block_Registrator.log_Pine)); + aLeaves.add(ItemUtils.getSimpleStack(BOP_Block_Registrator.leaves_Pine)); + aSaplings.add(ItemUtils.getSimpleStack(BOP_Block_Registrator.sapling_Pine)); + aPinecones.add(ItemUtils.getSimpleStack(AgriculturalChem.mPinecone, 1)); + + if (LoadedMods.BiomesOPlenty) { + aLogs.add(HANDLER_BiomesOPlenty.getStack(HANDLER_BiomesOPlenty.logs4, 0, 1)); + aLeaves.add(HANDLER_BiomesOPlenty.getStack(HANDLER_BiomesOPlenty.colorizedLeaves2, 1, 1)); + aSaplings.add(HANDLER_BiomesOPlenty.getStack(HANDLER_BiomesOPlenty.colorizedSaplings, 5, 1)); + aPinecones.add(ItemUtils.simpleMetaStack(HANDLER_BiomesOPlenty.mPineCone, 13, 1)); + } + if (LoadedMods.Forestry) { + ItemStack aForestryLog = ItemUtils.getItemStackFromFQRN("Forestry:logs", 1); + if (aForestryLog != null) { + aForestryLog.setItemDamage(20); // Set to Pine + aLogs.add(aForestryLog); + } + ItemStack aForestryLeaves = ItemUtils.getItemStackFromFQRN("Forestry:leaves", 1); + if (aForestryLeaves != null) { + NBTUtils.setString(aForestryLeaves, "species", "forestry.treePine"); // Set to Pine + aLeaves.add(aForestryLeaves); + } + } + + for (ItemStack aLog : aLogs) { + addRecipe(aLog, ItemUtils.getSimpleStack(aCrushedPine, 16), new int[] {10000, 7500, 5000, 2500}, 10, 120); + } + for (ItemStack aLeaf : aLeaves) { + addRecipe(aLeaf, ItemUtils.getSimpleStack(aCrushedPine, 2), new int[] {5000, 5000, 2500, 2500}, 10, 30); + } + for (ItemStack aSapling : aSaplings) { + addRecipe(aSapling, ItemUtils.getSimpleStack(aCrushedPine, 4), new int[] {7500, 7500, 2500, 2500}, 10, 60); + } + for (ItemStack aCone : aPinecones) { + addRecipe(aCone, ItemUtils.getSimpleStack(aCrushedPine, 1), new int[] {7500, 7500, 5000, 2500}, 10, 60); + } + + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] {CI.getNumberedAdvancedCircuit(16), ItemUtils.getSimpleStack(aCrushedPine, 64)}, + new FluidStack[] { + FluidUtils.getSteam(5000), + }, + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyAsh", 5), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyAsh", 5), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyDarkAsh", 5), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyDarkAsh", 5) + }, + new FluidStack[] {FluidUtils.getFluidStack(PineOil, 500)}, + new int[] {2000, 2000, 2000, 2000}, + 20 * 60, + 120, + 3); + + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] {CI.getNumberedAdvancedCircuit(18), ItemUtils.getSimpleStack(aCrushedPine, 64)}, + new FluidStack[] { + FluidUtils.getSuperHeatedSteam(5000), + }, + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyAsh", 5), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyAsh", 5), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyDarkAsh", 5), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyDarkAsh", 5) + }, + new FluidStack[] {FluidUtils.getFluidStack(PineOil, 1500)}, + new int[] {3000, 3000, 3000, 3000}, + 20 * 45, + 120, + 4); + } + + public boolean addRecipe(ItemStack aInput, ItemStack aOutput1, int[] aChances, int aTime, int aEU) { + aOutput1 = GT_OreDictUnificator.get(true, aOutput1); + ItemStack aOutputs[] = new ItemStack[4]; + for (int i = 0; i < aChances.length; i++) { + aOutputs[i] = aOutput1; + } + aOutputs = cleanArray(aOutputs); + if ((GT_Utility.isStackInvalid(aInput)) + || (GT_Utility.isStackInvalid(aOutput1) || (GT_Utility.getContainerItem(aInput, false) != null))) { + return false; + } + + return CORE.RA.addChemicalPlantRecipe( + new ItemStack[] {CI.getNumberedAdvancedCircuit(14), aInput}, + new FluidStack[] {}, + aOutputs, + new FluidStack[] {}, + aChances, + aTime * 20, + aEU, + 3); + } + + public static ItemStack[] cleanArray(ItemStack[] input) { + int aArraySize = input.length; + AutoMap aCleanedItems = new AutoMap(); + for (ItemStack checkStack : input) { + if (ItemUtils.checkForInvalidItems(checkStack)) { + aCleanedItems.put(checkStack); + } + } + ItemStack[] aOutput = new ItemStack[aCleanedItems.size()]; + for (int i = 0; i < aArraySize; i++) { + ItemStack aMappedStack = aCleanedItems.get(i); + if (aMappedStack != null) { + aOutput[i] = aMappedStack; + } + } + return aOutput; + } + + private static final HashMap< + String, + Quad< + Pair, + Pair, + Pair, + Pair>> + aMilledFluidMap = new HashMap< + String, + Quad< + Pair, + Pair, + Pair, + Pair>>(); + + public static void registerOreDataForMilledType( + Fluid aMilledFluid, + Materials aOutput1, + int aPerc1, + Materials aOutput2, + int aPerc2, + Materials aOutput3, + int aPerc3, + Materials aOutput4, + int aPerc4) { + registerOreDataForMilledType( + aMilledFluid, + MaterialUtils.generateMaterialFromGtENUM(aOutput1), + aPerc1, + MaterialUtils.generateMaterialFromGtENUM(aOutput2), + aPerc2, + MaterialUtils.generateMaterialFromGtENUM(aOutput3), + aPerc3, + MaterialUtils.generateMaterialFromGtENUM(aOutput4), + aPerc4); + } + + public static void registerOreDataForMilledType( + Fluid aMilledFluid, + Material aOutput1, + int aPerc1, + Material aOutput2, + int aPerc2, + Material aOutput3, + int aPerc3, + Material aOutput4, + int aPerc4) { + + Pair aFluidOutput1 = new Pair(aOutput1, aPerc1); + Pair aFluidOutput2 = new Pair(aOutput2, aPerc2); + Pair aFluidOutput3 = new Pair(aOutput3, aPerc3); + Pair aFluidOutput4 = new Pair(aOutput4, aPerc4); + Quad, Pair, Pair, Pair> + aDataQuad = new Quad< + Pair, + Pair, + Pair, + Pair>(aFluidOutput1, aFluidOutput2, aFluidOutput3, aFluidOutput4); + aMilledFluidMap.put(aMilledFluid.getUnlocalizedName(), aDataQuad); + } + + private static ItemStack[] getOutputsFromMap(Fluid aFluid) { + String aKey = aFluid.getUnlocalizedName(); + return getArrayFromQuad(aMilledFluidMap.get(aKey)); + } + + private static ItemStack[] getArrayFromQuad( + Quad, Pair, Pair, Pair> + aData) { + AutoMap aOutputs = new AutoMap(); + for (Object aPair : aData.values()) { + if (aPair != null && Pair.class.isInstance(aPair)) { + Pair aObj = (Pair) aPair; + Material aMat = (Material) aObj.getKey(); + int aCount = (int) aObj.getValue(); + aOutputs.addAll(getItemStackFromPair(aMat, aCount)); + } + } + ItemStack[] aRealOutputArray = new ItemStack[aOutputs.size()]; + int aIndex = 0; + for (ItemStack aStack : aOutputs) { + aRealOutputArray[aIndex++] = aStack; + } + return aRealOutputArray; + } + + private static AutoMap getItemStackFromPair(Material aMat, Integer aCount) { + AutoMap aOutputs = new AutoMap(); + if (aCount > 64) { + AutoMap sizes = getStackSizes(aCount); + for (int aSplitSize : sizes) { + ItemStack aDustStack = aMat.getDust(aSplitSize); + aOutputs.put(aDustStack); + } + } else { + ItemStack aDustStack = aMat.getDust(aCount); + aOutputs.put(aDustStack); + } + return aOutputs; + } + + private static AutoMap getStackSizes(int aBigSize) { + AutoMap aSizes = new AutoMap(); + if (aBigSize <= 64) { + aSizes.add(aBigSize); + } else { + for (int i = aBigSize; i > 0; i -= 64) { + aSizes.add(i); + } + } + return aSizes; + } } diff --git a/src/main/java/gtPlusPlus/core/item/chemistry/NuclearChem.java b/src/main/java/gtPlusPlus/core/item/chemistry/NuclearChem.java index 61f8b0a236..069ab4a724 100644 --- a/src/main/java/gtPlusPlus/core/item/chemistry/NuclearChem.java +++ b/src/main/java/gtPlusPlus/core/item/chemistry/NuclearChem.java @@ -2,7 +2,6 @@ package gtPlusPlus.core.item.chemistry; import gtPlusPlus.api.objects.minecraft.ItemPackage; import gtPlusPlus.core.item.ModItems; -import gtPlusPlus.core.item.chemistry.general.ItemGenericChemBase; import gtPlusPlus.core.item.chemistry.general.ItemNuclearChemBase; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; @@ -14,103 +13,102 @@ import net.minecraftforge.fluids.Fluid; public class NuclearChem extends ItemPackage { - public static Fluid Burnt_LiFBeF2ThF4UF4; - public static Fluid Burnt_LiFBeF2ZrF4UF4; - public static Fluid Burnt_LiFBeF2ZrF4U235; - - - public static Fluid Impure_LiFBeF2; - - public static Fluid GeneticMutagen; - private static boolean generateMutagenRecipe = false; - - public static ItemNuclearChemBase mNuclearChemItem1; - - public static ItemStack mResidueUranium; - public static ItemStack mResiduePlutonium; - public static ItemStack mResidueFluorides; - public static ItemStack mResidueNobles; - - @Override - public void items() { - - mNuclearChemItem1 = new ItemNuclearChemBase(); - registerItemStacks(); - registerOreDict(); - } - - - public void registerItemStacks() { - - mResidueUranium = ItemUtils.simpleMetaStack(mNuclearChemItem1, 0, 1); - mResidueUranium = ItemUtils.simpleMetaStack(mNuclearChemItem1, 1, 1); - mResidueUranium = ItemUtils.simpleMetaStack(mNuclearChemItem1, 2, 1); - mResidueUranium = ItemUtils.simpleMetaStack(mNuclearChemItem1, 3, 1); - - } - - public void registerOreDict() { - - ItemUtils.addItemToOreDictionary(mResidueUranium, "dustResidueUranium"); - ItemUtils.addItemToOreDictionary(mResiduePlutonium, "dustResiduePlutonium"); - ItemUtils.addItemToOreDictionary(mResidueFluorides, "dustResidueFluoride"); - ItemUtils.addItemToOreDictionary(mResidueNobles, "dustResidueNoble"); - - } - - @Override - public void blocks() { - } - - @Override - public void fluids() { - //Create Used Nuclear Fuels - Burnt_LiFBeF2ThF4UF4 = FluidUtils.generateFluidNonMolten("BurntLiFBeF2ThF4UF4", "Burnt LiFBeF2ThF4UF4 Salt", 545, new short[]{48, 175, 48, 100}, null, null); - Burnt_LiFBeF2ZrF4UF4 = FluidUtils.generateFluidNonMolten("BurntLiFBeF2ZrF4UF4", "Burnt LiFBeF2ZrF4UF4 Salt", 520, new short[]{48, 168, 68, 100}, null, null); - Burnt_LiFBeF2ZrF4U235 = FluidUtils.generateFluidNonMolten("BurntLiFBeF2ZrF4U235", "Burnt LiFBeF2ZrF4U235 Salt", 533, new short[]{68, 185, 48, 100}, null, null); - Impure_LiFBeF2 = FluidUtils.generateFluidNonMolten("ImpureLiFBeF2", "Impure Molten Salt Base", 533, new short[]{110, 75, 186, 100}, null, null); - if (FluidUtils.getFluidStack("fluid.Mutagen", 1) == null) { - GeneticMutagen = FluidUtils.generateFluidNonMolten("GeneticMutagen", "Genetic Mutagen", 12, new short[]{22, 148, 185, 100}, null, null); - generateMutagenRecipe = true; - } - else { - GeneticMutagen = FluidUtils.getFluidStack("fluid.Mutagen", 1).getFluid(); - } - } - - @Override - public String errorMessage() { - return "Bad Nuclear Chemistry Recipes."; - } - - @Override - public boolean generateRecipes() { - if (generateMutagenRecipe) { - chemReator_CreateMutagen(); - } - chemReactor_MutagenWithEggs(); - return true; - } - - private static void chemReator_CreateMutagen() { - CORE.RA.addChemicalRecipe( - CI.getNumberedCircuit(20), - ItemUtils.getSimpleStack(Items.nether_star, 2), - FluidUtils.getMobEssence(5000), - FluidUtils.getFluidStack(GeneticMutagen, 8000), - null, - 30*20, - 500); - } - - private static void chemReactor_MutagenWithEggs() { - CORE.RA.addChemicalRecipe( - CI.getNumberedCircuit(20), - ItemUtils.getSimpleStack(Items.egg, 2), - FluidUtils.getFluidStack(GeneticMutagen, 500), - null, - ItemUtils.getSimpleStack(ModItems.itemBigEgg, 2), - 300*20, - 500); - } + public static Fluid Burnt_LiFBeF2ThF4UF4; + public static Fluid Burnt_LiFBeF2ZrF4UF4; + public static Fluid Burnt_LiFBeF2ZrF4U235; + + public static Fluid Impure_LiFBeF2; + + public static Fluid GeneticMutagen; + private static boolean generateMutagenRecipe = false; + + public static ItemNuclearChemBase mNuclearChemItem1; + + public static ItemStack mResidueUranium; + public static ItemStack mResiduePlutonium; + public static ItemStack mResidueFluorides; + public static ItemStack mResidueNobles; + + @Override + public void items() { + + mNuclearChemItem1 = new ItemNuclearChemBase(); + registerItemStacks(); + registerOreDict(); + } + + public void registerItemStacks() { + + mResidueUranium = ItemUtils.simpleMetaStack(mNuclearChemItem1, 0, 1); + mResidueUranium = ItemUtils.simpleMetaStack(mNuclearChemItem1, 1, 1); + mResidueUranium = ItemUtils.simpleMetaStack(mNuclearChemItem1, 2, 1); + mResidueUranium = ItemUtils.simpleMetaStack(mNuclearChemItem1, 3, 1); + } + + public void registerOreDict() { + + ItemUtils.addItemToOreDictionary(mResidueUranium, "dustResidueUranium"); + ItemUtils.addItemToOreDictionary(mResiduePlutonium, "dustResiduePlutonium"); + ItemUtils.addItemToOreDictionary(mResidueFluorides, "dustResidueFluoride"); + ItemUtils.addItemToOreDictionary(mResidueNobles, "dustResidueNoble"); + } + + @Override + public void blocks() {} + + @Override + public void fluids() { + // Create Used Nuclear Fuels + Burnt_LiFBeF2ThF4UF4 = FluidUtils.generateFluidNonMolten( + "BurntLiFBeF2ThF4UF4", "Burnt LiFBeF2ThF4UF4 Salt", 545, new short[] {48, 175, 48, 100}, null, null); + Burnt_LiFBeF2ZrF4UF4 = FluidUtils.generateFluidNonMolten( + "BurntLiFBeF2ZrF4UF4", "Burnt LiFBeF2ZrF4UF4 Salt", 520, new short[] {48, 168, 68, 100}, null, null); + Burnt_LiFBeF2ZrF4U235 = FluidUtils.generateFluidNonMolten( + "BurntLiFBeF2ZrF4U235", "Burnt LiFBeF2ZrF4U235 Salt", 533, new short[] {68, 185, 48, 100}, null, null); + Impure_LiFBeF2 = FluidUtils.generateFluidNonMolten( + "ImpureLiFBeF2", "Impure Molten Salt Base", 533, new short[] {110, 75, 186, 100}, null, null); + if (FluidUtils.getFluidStack("fluid.Mutagen", 1) == null) { + GeneticMutagen = FluidUtils.generateFluidNonMolten( + "GeneticMutagen", "Genetic Mutagen", 12, new short[] {22, 148, 185, 100}, null, null); + generateMutagenRecipe = true; + } else { + GeneticMutagen = FluidUtils.getFluidStack("fluid.Mutagen", 1).getFluid(); + } + } + + @Override + public String errorMessage() { + return "Bad Nuclear Chemistry Recipes."; + } + + @Override + public boolean generateRecipes() { + if (generateMutagenRecipe) { + chemReator_CreateMutagen(); + } + chemReactor_MutagenWithEggs(); + return true; + } + + private static void chemReator_CreateMutagen() { + CORE.RA.addChemicalRecipe( + CI.getNumberedCircuit(20), + ItemUtils.getSimpleStack(Items.nether_star, 2), + FluidUtils.getMobEssence(5000), + FluidUtils.getFluidStack(GeneticMutagen, 8000), + null, + 30 * 20, + 500); + } + + private static void chemReactor_MutagenWithEggs() { + CORE.RA.addChemicalRecipe( + CI.getNumberedCircuit(20), + ItemUtils.getSimpleStack(Items.egg, 2), + FluidUtils.getFluidStack(GeneticMutagen, 500), + null, + ItemUtils.getSimpleStack(ModItems.itemBigEgg, 2), + 300 * 20, + 500); + } } diff --git a/src/main/java/gtPlusPlus/core/item/chemistry/OilChem.java b/src/main/java/gtPlusPlus/core/item/chemistry/OilChem.java index 4406995d27..b3c0842327 100644 --- a/src/main/java/gtPlusPlus/core/item/chemistry/OilChem.java +++ b/src/main/java/gtPlusPlus/core/item/chemistry/OilChem.java @@ -4,42 +4,32 @@ import gtPlusPlus.api.objects.minecraft.ItemPackage; public class OilChem extends ItemPackage { - /** - * Fluids - */ - - - /** - * Items - */ - - - - @Override - public void items() { - - } - - @Override - public void blocks() { - // None yet - } - - @Override - public void fluids() { - - } - - - - @Override - public String errorMessage() { - return "Failed to generate recipes for OilChem."; - } - - @Override - public boolean generateRecipes() { - - return true; - } + /** + * Fluids + */ + + /** + * Items + */ + @Override + public void items() {} + + @Override + public void blocks() { + // None yet + } + + @Override + public void fluids() {} + + @Override + public String errorMessage() { + return "Failed to generate recipes for OilChem."; + } + + @Override + public boolean generateRecipes() { + + return true; + } } diff --git a/src/main/java/gtPlusPlus/core/item/chemistry/RocketFuels.java b/src/main/java/gtPlusPlus/core/item/chemistry/RocketFuels.java index 46a037c839..0c84e778d6 100644 --- a/src/main/java/gtPlusPlus/core/item/chemistry/RocketFuels.java +++ b/src/main/java/gtPlusPlus/core/item/chemistry/RocketFuels.java @@ -1,16 +1,12 @@ package gtPlusPlus.core.item.chemistry; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; - import cpw.mods.fml.common.event.FMLLoadCompleteEvent; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; +import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; -import gregtech.api.util.GTPP_Recipe; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.ItemPackage; @@ -22,6 +18,9 @@ import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.MaterialUtils; import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; @@ -30,1117 +29,1105 @@ import net.minecraftforge.fluids.FluidStack; public class RocketFuels extends ItemPackage { - public static HashSet mValidRocketFuelNames = new HashSet(); - public static HashMap mValidRocketFuels = new HashMap(); - - public static Fluid Oil_Heavy; - public static Fluid Diesel; - public static Fluid Kerosene; - public static Fluid RP1; - public static Fluid Nitrogen_Tetroxide; - public static Fluid Hydrazine; - public static Fluid Monomethylhydrazine; - public static Fluid Unsymmetrical_Dimethylhydrazine; - public static Fluid Nitrous_Oxide; - public static Fluid Hydrated_Ammonium_Nitrate_Slurry; - public static Fluid Liquid_Oxygen; - public static Fluid Liquid_Hydrogen; - public static Fluid Formaldehyde; - - - //Rocket Fuel Mixes - public static Fluid Unsymmetrical_Dimethylhydrazine_Plus_Nitrogen_Tetroxide; - public static Fluid RP1_Plus_Liquid_Oxygen; - public static Fluid Dense_Hydrazine_Mix; - public static Fluid Monomethylhydrazine_Plus_Nitric_Acid; - - public static Item Ammonium_Nitrate_Dust; - public static Item Formaldehyde_Catalyst_Dust; - public static ItemStack Formaldehyde_Catalyst_Stack; - - public RocketFuels() { - super(true); - } - - public static void createKerosene(){ - - FluidStack fuelA = FluidUtils.getFluidStack("diesel", 3000); - FluidStack fuelB = FluidUtils.getFluidStack("fuel", 3000); - - if (fuelA != null){ - //GT_Values.RA.addDistilleryRecipe(23, fuelA, FluidUtils.getFluidStack(Kerosene, 50), 200, 64, false); - GT_Values.RA.addDistilleryRecipe(CI.getNumberedCircuit(23), fuelA, FluidUtils.getFluidStack(Kerosene, 1800), 200, 64, false); - } - if (fuelA == null && fuelB != null){ - //GT_Values.RA.addDistilleryRecipe(23, fuelB, FluidUtils.getFluidStack(Kerosene, 50), 200, 64, false); - GT_Values.RA.addDistilleryRecipe(CI.getNumberedCircuit(23), fuelB, FluidUtils.getFluidStack(Kerosene, 1800), 200, 64, false); - } - } - - public static void createRP1(){ - FluidStack fuelA = FluidUtils.getFluidStack(Kerosene, 1000); - if (fuelA != null){ - GT_Values.RA.addDistilleryRecipe(CI.getNumberedCircuit(23), fuelA, FluidUtils.getFluidStack(RP1, 750), 20 * 40, 120, false); - } - } - - public static void createNitrogenTetroxide(){ - //2HNO3 + Cu = N2O4 + H2O + CuO - CORE.RA.addChemicalPlantRecipe( - new ItemStack[]{ - ItemUtils.getItemStackOfAmountFromOreDict("dustCopper", 1), - ItemUtils.getSimpleStack(GenericChem.mOrangeCatalyst, 0), - }, - new FluidStack[] { - FluidUtils.getFluidStack("nitricacid", 2000) - }, - new ItemStack[]{ - Materials.CupricOxide.getDust(2), - }, - new FluidStack[] { - FluidUtils.getFluidStack(Nitrogen_Tetroxide, 1000), - }, - new int[]{100, 100, 50, 50}, - 20 * 30, - MaterialUtils.getVoltageForTier(3), - 3); - - } - - public static void createHydrazine(){ - - //H2O2 + 2NH3 = N2H4 + 2H2O - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedCircuit(21) - }, - new FluidStack[] { - FluidUtils.getFluidStack("fluid.hydrogenperoxide", 1000), - FluidUtils.getFluidStack("ammonia", 2000), - }, - new ItemStack[] { - - }, - new FluidStack[] { - FluidUtils.getFluidStack(Hydrazine, 1000), - }, - 20 * 30, - MaterialUtils.getVoltageForTier(2), - 1); - - FluidStack aBartWorksHydrazine = FluidUtils.getWildcardFluidStack("hydrazine", 1000); - if (aBartWorksHydrazine != null) { - Logger.INFO("Found BW Hydrazine, adding compat recipe."); - CORE.RA.addDistilleryRecipe( - GT_Utility.getIntegratedCircuit(24), - FluidUtils.getFluidStack(Hydrazine, 1000), - aBartWorksHydrazine, - null, - 20, - 8, - false - ); - - CORE.RA.addDistilleryRecipe( - GT_Utility.getIntegratedCircuit(24), - aBartWorksHydrazine, - FluidUtils.getFluidStack(Hydrazine, 1000), - null, - 20, - 8, - false - ); - } - - FluidStack aBartWorksHydrogenPeroxide = FluidUtils.getWildcardFluidStack("Hydrogen Peroxide", 1000); - if (aBartWorksHydrogenPeroxide != null) { - Logger.INFO("Found BW Hydrogen Peroxide, adding compat recipe."); - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedCircuit(22) - }, - new FluidStack[] { - aBartWorksHydrogenPeroxide, - FluidUtils.getFluidStack("ammonia", 2000), - }, - new ItemStack[] { - - }, - new FluidStack[] { - FluidUtils.getFluidStack(Hydrazine, 1000), - }, - 20 * 30, - MaterialUtils.getVoltageForTier(2), - 1); - - CORE.RA.addDistilleryRecipe( - GT_Utility.getIntegratedCircuit(24), - FluidUtils.getFluidStack("fluid.hydrogenperoxide", 1000), - aBartWorksHydrogenPeroxide, - null, - 20, - 8, - false - ); - - CORE.RA.addDistilleryRecipe( - GT_Utility.getIntegratedCircuit(24), - aBartWorksHydrogenPeroxide, - FluidUtils.getFluidStack("fluid.hydrogenperoxide", 1000), - null, - 20, - 8, - false - ); - } - - } - - - public static void createMonomethylhydrazine(){ - - //C + 2H + N2H4 = CH6N2 - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedCircuit(21), - ItemUtils.getItemStackOfAmountFromOreDict("dustCarbon", 1) - }, - new FluidStack[] { - FluidUtils.getFluidStack("hydrogen", 2000), - FluidUtils.getFluidStack(Hydrazine, 1000), - }, - new ItemStack[] { - - }, - new FluidStack[] { - FluidUtils.getFluidStack(Monomethylhydrazine, 1000), - - }, - 20 * 48, - 240, - 2); - - FluidStack aBartWorksMonomethylhydrazine = FluidUtils.getWildcardFluidStack("Monomethylhydrazine", 1000); - if (aBartWorksMonomethylhydrazine != null) { - Logger.INFO("Found BW Hydrazine, adding compat recipe."); - CORE.RA.addDistilleryRecipe( - GT_Utility.getIntegratedCircuit(24), - FluidUtils.getFluidStack(Monomethylhydrazine, 1000), - aBartWorksMonomethylhydrazine, - null, - 20, - 8, - false - ); - - CORE.RA.addDistilleryRecipe( - GT_Utility.getIntegratedCircuit(24), - aBartWorksMonomethylhydrazine, - FluidUtils.getFluidStack(Monomethylhydrazine, 1000), - null, - 20, - 8, - false - ); - } - - } - - private static void createLOX() { - GT_Values.RA.addVacuumFreezerRecipe(ItemUtils.getItemStackOfAmountFromOreDict("cellOxygen", 1), ItemUtils.getItemStackOfAmountFromOreDict("cellLiquidOxygen", 1), 20*16); - CORE.RA.addAdvancedFreezerRecipe(new ItemStack[] {}, new FluidStack[] {FluidUtils.getFluidStack("oxygen", 3000)}, new FluidStack[] {FluidUtils.getFluidStack(Liquid_Oxygen, 3000)}, new ItemStack[] {}, new int[] {}, 20*16, 240, 0); - } - - private static void createLOH() { - GT_Values.RA.addVacuumFreezerRecipe(ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 1), ItemUtils.getItemStackOfAmountFromOreDict("cellLiquidHydrogen", 1), 20*16); - CORE.RA.addAdvancedFreezerRecipe(new ItemStack[] {}, new FluidStack[] {FluidUtils.getFluidStack("hydrogen", 300)}, new FluidStack[] {FluidUtils.getFluidStack(Liquid_Hydrogen, 300)}, new ItemStack[] {}, new int[] {}, 20*4, 540, 0); - } - - private static void createHydratedAmmoniumNitrateSlurry() { - - //NH3 + HNO3 = NH4NO3 - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(21), - }, - new FluidStack[] { - FluidUtils.getFluidStack("ammonia", 4000), - FluidUtils.getFluidStack("nitricacid", 4000), - }, - new ItemStack[] { - - }, - new FluidStack[] { - FluidUtils.getFluidStack(Hydrated_Ammonium_Nitrate_Slurry, 5184), - - }, - 20 * 60, - 120, - 1); - } - - private static void createAmmoniumNitrateDust() { - CORE.RA.addDehydratorRecipe( - new ItemStack[] {CI.getNumberedCircuit(8)}, - FluidUtils.getFluidStack(Hydrated_Ammonium_Nitrate_Slurry, 8 * 144), - FluidUtils.getWater(2000), - new ItemStack[] { - ItemUtils.getSimpleStack(Ammonium_Nitrate_Dust, 8) - }, - new int[] {10000}, - 90 * 20, - 480); - } - - private static void createFormaldehyde() { - - //O + CH4O = CH2O + H2O - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(21), - ItemUtils.getSimpleStack(GenericChem.mFormaldehydeCatalyst, 0), - }, - new FluidStack[] { - FluidUtils.getFluidStack("oxygen", 32000), - FluidUtils.getFluidStack("methanol", 32000), - }, - new ItemStack[] { - - }, - new FluidStack[] { - FluidUtils.getFluidStack(Formaldehyde, 32000), - }, - 20 * 90, - 120, - 1); - - FluidStack aBartWorksFormaldehyde = FluidUtils.getWildcardFluidStack("Formaldehyde", 1000); - if (aBartWorksFormaldehyde != null) { - Logger.INFO("Found BW Formaldehyde, adding compat recipe."); - CORE.RA.addDistilleryRecipe( - GT_Utility.getIntegratedCircuit(24), - FluidUtils.getFluidStack(Formaldehyde, 1000), - aBartWorksFormaldehyde, - null, - 20, - 8, - false - ); - - CORE.RA.addDistilleryRecipe( - GT_Utility.getIntegratedCircuit(24), - aBartWorksFormaldehyde, - FluidUtils.getFluidStack(Formaldehyde, 1000), - null, - 20, - 8, - false - ); - } - - } - - private static void createFormaldehydeCatalyst() { - GT_Values.RA.addMixerRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("dustIron", 16), - ItemUtils.getItemStackOfAmountFromOreDict("dustVanadium", 1), - CI.getNumberedCircuit(18), - null, - null, - null, - ItemUtils.getSimpleStack(Formaldehyde_Catalyst_Dust, 4), - 160, - 30); - - } - - private static void createUnsymmetricalDimethylhydrazine() { - - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(21), - ItemUtils.getSimpleStack(GenericChem.mFormaldehydeCatalyst, 0), - }, - new FluidStack[] { - FluidUtils.getFluidStack("fluid.hydrazine", 2000), - FluidUtils.getFluidStack(Formaldehyde, 2000), - FluidUtils.getFluidStack("hydrogen", 4000), - }, - new ItemStack[] { - - }, - new FluidStack[] { - FluidUtils.getFluidStack(Unsymmetrical_Dimethylhydrazine, 2000), - FluidUtils.getWater(2000) - - }, - 20 * 60, - 120, - 3); - - } - - private static void addRocketFuelsToMap() { - HashMap mRocketFuels = new LinkedHashMap(); - mRocketFuels.put(0, new GTPP_Recipe( - true, - new ItemStack[] {}, - new ItemStack[] {}, - null, - new int[] {}, - new FluidStack[] {FluidUtils.getFluidStack(RP1_Plus_Liquid_Oxygen, 1000)}, - new FluidStack[] {}, - 0, - 0, - 512)); //Fuel Value - - mRocketFuels.put(1, new GTPP_Recipe( - true, - new ItemStack[] {}, - new ItemStack[] {}, - null, - new int[] {}, - new FluidStack[] {FluidUtils.getFluidStack(Dense_Hydrazine_Mix, 1000)}, - new FluidStack[] {}, - 0, - 0, - 1024)); //Fuel Value - - mRocketFuels.put(2, new GTPP_Recipe( - true, - new ItemStack[] {}, - new ItemStack[] {}, - null, - new int[] {}, - new FluidStack[] {FluidUtils.getFluidStack(Monomethylhydrazine_Plus_Nitric_Acid, 1000)}, - new FluidStack[] {}, - 0, - 0, - 2048)); //Fuel Value - - mRocketFuels.put(3, new GTPP_Recipe( - true, - new ItemStack[] {}, - new ItemStack[] {}, - null, - new int[] {}, - new FluidStack[] {FluidUtils.getFluidStack(Unsymmetrical_Dimethylhydrazine_Plus_Nitrogen_Tetroxide, 1000)}, - new FluidStack[] {}, - 0, - 0, - 4196)); //Fuel Value - - - //Add in default Diesel for the Buggy - mValidRocketFuels.put(-1, Diesel); - - mValidRocketFuelNames.add(FluidRegistry.getFluidName(Diesel)); - for (int mID : mRocketFuels.keySet()) { - GTPP_Recipe aFuelRecipe = mRocketFuels.get(mID); - if (aFuelRecipe != null) { - mValidRocketFuelNames.add(FluidRegistry.getFluidName(aFuelRecipe.mFluidInputs[0].getFluid())); - mValidRocketFuels.put(mID, aFuelRecipe.mFluidInputs[0].getFluid()); - GTPP_Recipe.GTPP_Recipe_Map.sRocketFuels.add(aFuelRecipe); - } - } - - } - - - private static void createRocketFuels() { - - // RP1_Plus_Liquid_Oxygen - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedCircuit(1), - }, - new FluidStack[] { - FluidUtils.getFluidStack(Liquid_Oxygen, 2000), - FluidUtils.getFluidStack(RP1, 500), - }, - new ItemStack[] { - - }, - new FluidStack[] { - FluidUtils.getFluidStack(RP1_Plus_Liquid_Oxygen, 1500), - - }, - 20 * 15, - 240, - 3); - - - // Dense_Hydrazine_Mix - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedCircuit(2), - }, - new FluidStack[] { - FluidUtils.getFluidStack(Hydrazine, 4000), - FluidUtils.getFluidStack("methanol", 6000), - }, - new ItemStack[] { - - }, - new FluidStack[] { - FluidUtils.getFluidStack(Dense_Hydrazine_Mix, 10000), - - }, - 20 * 30, - 240, - 4); - - - // Monomethylhydrazine_Plus_Nitric_Acid - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedCircuit(3), - }, - new FluidStack[] { - FluidUtils.getFluidStack(Monomethylhydrazine, 2000), - FluidUtils.getFluidStack("nitricacid", 1000), - }, - new ItemStack[] { - - }, - new FluidStack[] { - FluidUtils.getFluidStack(Monomethylhydrazine_Plus_Nitric_Acid, 2000), - - }, - 20 * 45, - 480, - 5); - - - // Unsymmetrical_Dimethylhydrazine_Plus_Nitrogen_Tetroxide - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedCircuit(4), - }, - new FluidStack[] { - FluidUtils.getFluidStack(Unsymmetrical_Dimethylhydrazine, 2000), - FluidUtils.getFluidStack(Nitrogen_Tetroxide, 2000), - }, - new ItemStack[] { - - }, - new FluidStack[] { - FluidUtils.getFluidStack(Unsymmetrical_Dimethylhydrazine_Plus_Nitrogen_Tetroxide, 5000), - - }, - 20 * 60, - 480, - 6); - - } - - @Override - public String errorMessage() { - return "Bad Rocket Fuel Science!"; - } - - @Override - public boolean generateRecipes() { - createKerosene(); - createRP1(); - createNitrogenTetroxide(); - createHydrazine(); - createMonomethylhydrazine(); - - if (!CORE.GTNH) { - createLOX(); - } - createLOH(); - - - createHydratedAmmoniumNitrateSlurry(); - createAmmoniumNitrateDust(); - createFormaldehyde(); - createFormaldehydeCatalyst(); - createUnsymmetricalDimethylhydrazine(); - - createRocketFuels(); - addRocketFuelsToMap(); - - return true; - } - - @Override - public void items() { - Formaldehyde_Catalyst_Dust = ItemUtils.generateSpecialUseDusts("FormaldehydeCatalyst", "Formaldehyde Catalyst", "Fe16V1", Utils.rgbtoHexValue(25, 5, 25))[0]; - Formaldehyde_Catalyst_Stack = ItemUtils.getSimpleStack(Formaldehyde_Catalyst_Dust); - } - - @Override - public void blocks() { - } - - @Override - public void fluids() { - - //Register default fluids - Diesel = MaterialUtils.getMaterial("Fuel", "Diesel").getFluid(1).getFluid(); - - // 5.08 Compat - if (!FluidUtils.doesFluidExist("liquid_heavy_oil")){ - Oil_Heavy = FluidUtils.generateFluidNoPrefix("liquid_heavy_oil", "Heavy Oil", 200, new short[]{10, 10, 10, 100}); - } - else { - Oil_Heavy = MaterialUtils.getMaterial("OilHeavy", "Oil").getFluid(1).getFluid(); - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cellOilHeavy", 1) == null){ - new BaseItemComponent("OilHeavy", "Heavy Oil", new short[] {10, 10, 10}); - } - } - - - //Create Kerosene - Kerosene = FluidUtils.generateFluidNonMolten("Kerosene", "Kerosene", 233, new short[]{150, 40, 150, 100}, null, null); - CoalTar.Coal_Oil = Kerosene; - - //RP! Focket Fuel - RP1 = FluidUtils.generateFluidNonMolten("RP1Fuel", "RP-1", 500, new short[]{210, 50, 50, 100}, null, null); - - //Create Nitrogen Tetroxide - Nitrogen_Tetroxide = FluidUtils.generateFluidNonMolten("NitrogenTetroxide", "Nitrogen Tetroxide", 261, new short[]{170, 170, 0, 100}, null, null); - - //Create Hydrazine - Hydrazine = FluidUtils.generateFluidNonMolten("Hydrazine", "Hydrazine", 275, new short[]{250, 250, 250, 100}, null, null); - - //Create Monomethylhydrazine - Monomethylhydrazine = FluidUtils.generateFluidNonMolten("Monomethylhydrazine", "Monomethylhydrazine", 221, new short[]{125, 125, 125, 100}, null, null); - - //Create Anthracene - Nitrous_Oxide = FluidUtils.generateFluidNonMolten("NitrousOxide", "Nitrous Oxide", 182, new short[]{255, 255, 255, 100}, null, null); - - //Nos - if (!FluidUtils.doesFluidExist("NitrousOxide")){ - Nitrous_Oxide = FluidUtils.generateFluidNoPrefix("NitrousOxide", "Nitrous Oxide", 182, new short[]{255, 255, 255, 100}); - } - else { - Nitrous_Oxide = FluidUtils.getWildcardFluidStack("NitrousOxide", 1).getFluid(); - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cellNitrousOxide", 1) == null){ - new BaseItemComponent("NitrousOxide", "Nitrous Oxide", new short[] {10, 10, 175}); - } - } - - //Unsymmetrical_Dimethylhydrazine - if (FluidUtils.getFluidStack("1,1dimethylhydrazine", 1) == null){ - Unsymmetrical_Dimethylhydrazine = FluidUtils.generateFluidNonMolten("UnsymmetricalDimethylhydrazine", "Unsymmetrical Dimethylhydrazine", 216, new short[]{70, 210, 20, 100}, null, null); - } - else { - Unsymmetrical_Dimethylhydrazine = FluidUtils.getFluidStack("1,1dimethylhydrazine", 1000).getFluid(); - } - - //Create Hydrated_Ammonium_Nitrate_Slurry - Hydrated_Ammonium_Nitrate_Slurry = FluidUtils.generateFluidNonMolten("AmmoniumNitrateSlurry", "Hydrated Ammonium Nitrate Slurry", 450, new short[]{150, 75, 150, 100}, null, null); - - //Lithium Hydroperoxide - LiOH + H2O2 → LiOOH + 2 H2O - Ammonium_Nitrate_Dust = ItemUtils.generateSpecialUseDusts("AmmoniumNitrate", "Ammonium Nitrate", "N2H4O3", Utils.rgbtoHexValue(150, 75, 150))[0]; - - //Create Liquid_Oxygen - if (FluidUtils.getFluidStack("LiquidOxygen", 1) == null && FluidUtils.getFluidStack("liquidoxygen", 1) == null){ - Liquid_Oxygen = FluidUtils.generateFluidNonMolten("LiquidOxygen", "Liquid Oxygen", 54, new short[]{75, 75, 220, 100}, null, null); - } - else { - if (FluidUtils.getFluidStack("LiquidOxygen", 1) != null ) { - Liquid_Oxygen = FluidUtils.getFluidStack("LiquidOxygen", 1).getFluid(); - } - else { - Liquid_Oxygen = FluidUtils.getFluidStack("liquidoxygen", 1).getFluid(); - } - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cellLiquidOxygen", 1) == null){ - new BaseItemComponent("LiquidOxygen", "Liquid Oxygen", new short[] {10, 10, 175}); - } - } - - //Create Liquid_Hydrogen - if (FluidUtils.getFluidStack("LiquidHydrogen", 1) == null && FluidUtils.getFluidStack("liquidhydrogen", 1) == null){ - Liquid_Hydrogen = FluidUtils.generateFluidNonMolten("LiquidHydrogen", "Liquid Hydrogen", 14, new short[]{75, 75, 220, 100}, null, null); - } - else { - if (FluidUtils.getFluidStack("LiquidHydrogen", 1) != null ) { - Liquid_Hydrogen = FluidUtils.getFluidStack("LiquidHydrogen", 1).getFluid(); - } - else { - Liquid_Hydrogen = FluidUtils.getFluidStack("liquidhydrogen", 1).getFluid(); - } - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cellLiquidHydrogen", 1) == null){ - new BaseItemComponent("LiquidHydrogen", "Liquid Hydrogen", new short[] {10, 10, 175}); - } - } - - Formaldehyde = FluidUtils.generateFluidNonMolten("Formaldehyde", "Formaldehyde", 185, new short[]{150, 75, 150, 100}, null, null); - - Unsymmetrical_Dimethylhydrazine_Plus_Nitrogen_Tetroxide = FluidUtils.generateFluidNonMolten("RocketFuelMixA", "H8N4C2O4 Rocket Fuel", 216, new short[]{50, 220, 50, 100}, null, null); - RP1_Plus_Liquid_Oxygen = FluidUtils.generateFluidNonMolten("RocketFuelMixB", "Rp-1 Rocket Fuel", 250, new short[]{250, 50, 50, 100}, null, null); - Monomethylhydrazine_Plus_Nitric_Acid = FluidUtils.generateFluidNonMolten("RocketFuelMixC", "CN3H7O3 Rocket Fuel", 221, new short[]{125, 75, 180, 100}, null, null); - Dense_Hydrazine_Mix = FluidUtils.generateFluidNonMolten("RocketFuelMixD", "Dense Hydrazine Fuel Mixture", 275, new short[]{175, 80, 120, 100}, null, null); - - } - - @Override - public boolean onLoadComplete(FMLLoadCompleteEvent event) { - - Logger.INFO("Trying to remove GT recipes for '1,1dimethylhydrazine' && 'rocket_fuel' if they exist."); - /*if (FluidRegistry.isFluidRegistered("1,1dimethylhydrazine")) { - - // Try Remove recipes for GT/EIO Rocket Fuel Cells - if (FluidRegistry.isFluidRegistered("rocket_fuel")) { - - // Old Recipe - if (MaterialUtils.doesMaterialExist("NitrogenDioxide")) { - GT_Recipe aOldRecipe = getHalfBakedRecipe( - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("cellNitrogenDioxide", 1), - ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 3), - }, - new FluidStack[] { - FluidUtils.getFluidStack("air", 500) - }, - 388); - boolean aDidRemove = removeRecipe(aOldRecipe, GT_Recipe_Map.sChemicalRecipes); - Logger.INFO("Removed Old Recipe for Rocket Fuel: "+aDidRemove); - } - - // Simple Recipes - if (MaterialUtils.doesMaterialExist("Ammonia") && MaterialUtils.doesMaterialExist("Methanol")) { - - GT_Recipe aSimpleRecipe1 = getHalfBakedRecipe( - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("cellAmmonia", 3), - ItemUtils.getItemStackOfAmountFromOreDict("cellMethanol", 4), - }, - new FluidStack[] { - FluidUtils.getFluidStack("chlorine", 1000) - }, - 480); - GT_Recipe aSimpleRecipe2 = getHalfBakedRecipe( - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("cellChlorine", 1), - ItemUtils.getItemStackOfAmountFromOreDict("cellMethanol", 4), - }, - new FluidStack[] { - FluidUtils.getFluidStack("ammonia", 3000) - }, - 480); - GT_Recipe aSimpleRecipe3 = getHalfBakedRecipe( - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("cellAmmonia", 3), - ItemUtils.getItemStackOfAmountFromOreDict("cellChlorine", 1), - }, - new FluidStack[] { - FluidUtils.getFluidStack("methanol", 4000) - }, - 480); - - boolean aDidRemove1 = removeRecipe(aSimpleRecipe1, GT_Recipe_Map.sChemicalRecipes); - boolean aDidRemove2 = removeRecipe(aSimpleRecipe2, GT_Recipe_Map.sChemicalRecipes); - boolean aDidRemove3 = removeRecipe(aSimpleRecipe3, GT_Recipe_Map.sChemicalRecipes); - Logger.INFO("Removed Simple Recipe 1 for Rocket Fuel: "+aDidRemove1); - Logger.INFO("Removed Simple Recipe 2 for Rocket Fuel: "+aDidRemove2); - Logger.INFO("Removed Simple Recipe 3 for Rocket Fuel: "+aDidRemove3); - } - - - // Complex Recipes I - if (MaterialUtils.doesMaterialExist("Dimethylhydrazine") && MaterialUtils.doesMaterialExist("DinitrogenTetroxide")) { - - GT_Recipe aAdvRecipe1 = getHalfBakedRecipe( - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("cellDimethylhydrazine", 1), - }, - new FluidStack[] { - FluidUtils.getFluidStack("dinitrogentetroxide", 1000) - }, - 16); - GT_Recipe aAdvRecipe2 = getHalfBakedRecipe( - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("cellDinitrogenTetroxide", 1), - }, - new FluidStack[] { - FluidUtils.getFluidStack("dimethylhydrazine", 1000) - }, - 16); - - GT_Recipe aAdvRecipe3 = getHalfBakedRecipe( - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("cellDimethylhydrazine", 2), - }, - new FluidStack[] { - FluidUtils.getFluidStack("oxygen", 1000) - }, - 16); - GT_Recipe aAdvRecipe4 = getHalfBakedRecipe( - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("cellOxygen", 1), - }, - new FluidStack[] { - FluidUtils.getFluidStack("dimethylhydrazine", 2000) - }, - 16); - - boolean aDidRemove1 = removeRecipe(aAdvRecipe1, GT_Recipe_Map.sMixerRecipes); - boolean aDidRemove2 = removeRecipe(aAdvRecipe2, GT_Recipe_Map.sMixerRecipes); - boolean aDidRemove3 = removeRecipe(aAdvRecipe3, GT_Recipe_Map.sMixerRecipes); - boolean aDidRemove4 = removeRecipe(aAdvRecipe4, GT_Recipe_Map.sMixerRecipes); - Logger.INFO("Removed Complex Recipe 1 for Rocket Fuel: "+aDidRemove1); - Logger.INFO("Removed Complex Recipe 2 for Rocket Fuel: "+aDidRemove2); - Logger.INFO("Removed Complex Recipe 3 for Rocket Fuel: "+aDidRemove3); - Logger.INFO("Removed Complex Recipe 4 for Rocket Fuel: "+aDidRemove4); - } - } - - - // Complex Recipes II - if (MaterialUtils.doesMaterialExist("Dimethylhydrazine")) { - - GT_Recipe aAdvRecipe1 = getHalfBakedRecipe( - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("cellDimethylhydrazine", 2), - }, - new FluidStack[] { - FluidUtils.getFluidStack("oxygen", 1000) - }, - 16); - GT_Recipe aAdvRecipe2 = getHalfBakedRecipe( - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("cellOxygen", 1), - }, - new FluidStack[] { - FluidUtils.getFluidStack("dimethylhydrazine", 2000) - }, - 16); - - boolean aDidRemove1 = removeRecipe(aAdvRecipe1, GT_Recipe_Map.sMixerRecipes); - boolean aDidRemove2 = removeRecipe(aAdvRecipe2, GT_Recipe_Map.sMixerRecipes); - Logger.INFO("Removed Complex Recipe 5 for Rocket Fuel: "+aDidRemove1); - Logger.INFO("Removed Complex Recipe 6 for Rocket Fuel: "+aDidRemove2); - } - - if (MaterialUtils.doesMaterialExist("Chloramine") && MaterialUtils.doesMaterialExist("Dimethylamine")) { - GT_Recipe aSimpleRecipe1 = getHalfBakedRecipe( - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("cellChloramine", 2), - GT_Utility.getIntegratedCircuit(1) - }, - new FluidStack[] { - FluidUtils.getFluidStack("dimethylamine", 5000) - }, - 480); - GT_Recipe aSimpleRecipe2 = getHalfBakedRecipe( - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("cellDimethylamine", 5), - GT_Utility.getIntegratedCircuit(1) - }, - new FluidStack[] { - FluidUtils.getFluidStack("chloramine", 2000) - }, - 16); - - - - GT_Recipe aAdvRecipe1 = getHalfBakedRecipe( - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("cellChloramine", 2), - CI.emptyCells(4) - }, - new FluidStack[] { - FluidUtils.getFluidStack("dimethylamine", 5000) - }, - 480); - GT_Recipe aAdvRecipe2 = getHalfBakedRecipe( - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("cellDimethylamine", 5), - CI.emptyCells(1) - }, - new FluidStack[] { - FluidUtils.getFluidStack("chloramine", 2000) - }, - 16); - GT_Recipe aAdvRecipe3 = getHalfBakedRecipe( - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("cellChloramine", 2), - ItemUtils.getItemStackOfAmountFromOreDict("cellDimethylamine", 5), - }, - new FluidStack[] { - FluidUtils.getFluidStack("chloramine", 2000) - }, - 480); - - boolean aDidRemove1 = removeRecipe(aSimpleRecipe1, GT_Recipe_Map.sChemicalRecipes); - boolean aDidRemove2 = removeRecipe(aSimpleRecipe2, GT_Recipe_Map.sChemicalRecipes); - boolean aDidRemove3 = removeRecipe(aAdvRecipe1, GT_Recipe_Map.sChemicalRecipes); - boolean aDidRemove4 = removeRecipe(aAdvRecipe2, GT_Recipe_Map.sChemicalRecipes); - boolean aDidRemove5 = removeRecipe(aAdvRecipe3, GT_Recipe_Map.sChemicalRecipes); - Logger.INFO("Removed Complex Recipe 1 for 1,1dimethylhydrazine: "+aDidRemove1); - Logger.INFO("Removed Complex Recipe 2 for 1,1dimethylhydrazine: "+aDidRemove2); - Logger.INFO("Removed Complex Recipe 3 for 1,1dimethylhydrazine: "+aDidRemove3); - Logger.INFO("Removed Complex Recipe 4 for 1,1dimethylhydrazine: "+aDidRemove4); - Logger.INFO("Removed Complex Recipe 5 for 1,1dimethylhydrazine: "+aDidRemove5); - - } - - if (MaterialUtils.doesMaterialExist("Chloramine") && MaterialUtils.doesMaterialExist("Dimethylamine")) { - GT_Recipe aSimpleRecipe1 = getHalfBakedRecipe( - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("cellChloramine", 1), - GT_Utility.getIntegratedCircuit(1) - }, - new FluidStack[] { - FluidUtils.getFluidStack("dimethylamine", 1000) - }, - 480); - GT_Recipe aSimpleRecipe2 = getHalfBakedRecipe( - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("cellDimethylamine", 1), - GT_Utility.getIntegratedCircuit(1) - }, - new FluidStack[] { - FluidUtils.getFluidStack("chloramine", 1000) - }, - 16); - - - - GT_Recipe aAdvRecipe1 = getHalfBakedRecipe( - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("cellChloramine", 1), - GT_Utility.getIntegratedCircuit(11) - }, - new FluidStack[] { - FluidUtils.getFluidStack("dimethylamine", 1000) - }, - 480); - GT_Recipe aAdvRecipe2 = getHalfBakedRecipe( - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("cellDimethylamine", 1), - GT_Utility.getIntegratedCircuit(11) - }, - new FluidStack[] { - FluidUtils.getFluidStack("chloramine", 1000) - }, - 16); - - boolean aDidRemove1 = removeRecipe(aSimpleRecipe1, GT_Recipe_Map.sChemicalRecipes); - boolean aDidRemove2 = removeRecipe(aSimpleRecipe2, GT_Recipe_Map.sChemicalRecipes); - boolean aDidRemove3 = removeRecipe(aAdvRecipe1, GT_Recipe_Map.sChemicalRecipes); - boolean aDidRemove4 = removeRecipe(aAdvRecipe2, GT_Recipe_Map.sChemicalRecipes); - Logger.INFO("Removed Complex Recipe 5 for 1,1dimethylhydrazine: "+aDidRemove1); - Logger.INFO("Removed Complex Recipe 6 for 1,1dimethylhydrazine: "+aDidRemove2); - Logger.INFO("Removed Complex Recipe 7 for 1,1dimethylhydrazine: "+aDidRemove3); - Logger.INFO("Removed Complex Recipe 8 for 1,1dimethylhydrazine: "+aDidRemove4); - - } - - if (MaterialUtils.doesMaterialExist("HypochlorousAcid") && MaterialUtils.doesMaterialExist("Ammonia") && MaterialUtils.doesMaterialExist("Methanol")) { - - GT_Recipe aAdvRecipe1 = getHalfBakedRecipe( - new ItemStack[] { - GT_Utility.getIntegratedCircuit(24), - }, - new FluidStack[] { - FluidUtils.getFluidStack("hypochlorousacid", 3000), - FluidUtils.getFluidStack("ammonia", 8000), - FluidUtils.getFluidStack("methanol", 12000) - }, - 480); - - GT_Recipe aAdvRecipe2 = getHalfBakedRecipe( - new ItemStack[] { - GT_Utility.getIntegratedCircuit(24), - }, - new FluidStack[] { - FluidUtils.getFluidStack("hypochlorousacid", 1000), - FluidUtils.getFluidStack("ammonia", 1000), - FluidUtils.getFluidStack("methanol", 2000) - }, - 480); - - boolean aDidRemove1 = removeRecipe(aAdvRecipe1, StaticFields59.getLargeChemicalReactorRecipeMap()); - boolean aDidRemove2 = removeRecipe(aAdvRecipe2, StaticFields59.getLargeChemicalReactorRecipeMap()); - Logger.INFO("Removed Complex Recipe 9 for 1,1dimethylhydrazine: "+aDidRemove1); - Logger.INFO("Removed Complex Recipe 10 for 1,1dimethylhydrazine: "+aDidRemove2); - - - } - }*/ - - // Try Butcher recipes manually - - //1,1Dimethylhydrazine - if (FluidRegistry.isFluidRegistered("1,1dimethylhydrazine")) { - Logger.INFO("Making sure all Chemical Reactor recipes for 1,1dimethylhydrazine have been removed."); - AutoMap aToRemoveSingle = new AutoMap(); - ItemStack aUnsymCell = ItemUtils.getItemStackOfAmountFromOreDict("cell1,1Dimethylhydrazine", 1); - FluidStack aUnsymFluid = FluidUtils.getFluidStack("1,1dimethylhydrazine", 1); - recipe : for (GT_Recipe aRecipeSingleBlock : GT_Recipe_Map.sChemicalRecipes.mRecipeList) { - if (aRecipeSingleBlock != null && aRecipeSingleBlock.mEnabled) { - if (aRecipeSingleBlock.mOutputs != null && aRecipeSingleBlock.mOutputs.length > 0) { - for (ItemStack aOutputItem : aRecipeSingleBlock.mOutputs) { - ItemStack aTemp = aOutputItem.copy(); - aTemp.stackSize = 1; - if (GT_Utility.areStacksEqual(aTemp, aUnsymCell)) { - aToRemoveSingle.add(aRecipeSingleBlock); - continue recipe; - } - } - } - if (aRecipeSingleBlock.mFluidOutputs != null && aRecipeSingleBlock.mFluidOutputs.length > 0) { - for (FluidStack aOutput : aRecipeSingleBlock.mFluidOutputs) { - if (GT_Utility.areFluidsEqual(aOutput, aUnsymFluid)) { - aToRemoveSingle.add(aRecipeSingleBlock); - continue recipe; - } - } - } - } - } - // Handle Multi Also - AutoMap aToRemoveMulti = new AutoMap(); - recipe : for (GT_Recipe aRecipeSingleBlock : StaticFields59.getLargeChemicalReactorRecipeMap().mRecipeList) { - if (aRecipeSingleBlock != null && aRecipeSingleBlock.mEnabled) { - if (aRecipeSingleBlock.mOutputs != null && aRecipeSingleBlock.mOutputs.length > 0) { - for (ItemStack aOutputItem : aRecipeSingleBlock.mOutputs) { - ItemStack aTemp = aOutputItem.copy(); - aTemp.stackSize = 1; - if (GT_Utility.areStacksEqual(aTemp, aUnsymCell)) { - aToRemoveMulti.add(aRecipeSingleBlock); - continue recipe; - } - } - } - if (aRecipeSingleBlock.mFluidOutputs != null && aRecipeSingleBlock.mFluidOutputs.length > 0) { - for (FluidStack aOutput : aRecipeSingleBlock.mFluidOutputs) { - if (GT_Utility.areFluidsEqual(aOutput, aUnsymFluid)) { - aToRemoveMulti.add(aRecipeSingleBlock); - continue recipe; - } - } - } - } - } - if (!aToRemoveSingle.isEmpty()) { - Logger.INFO("Found "+aToRemoveSingle.size()+" single block recipes, removing by force."); - for (GT_Recipe remove : aToRemoveSingle) { - GT_Recipe_Map.sChemicalRecipes.mRecipeList.remove(remove); - } - } - if (!aToRemoveMulti.isEmpty()) { - Logger.INFO("Found "+aToRemoveSingle.size()+" multiblock recipes, removing by force."); - for (GT_Recipe remove : aToRemoveMulti) { - StaticFields59.getLargeChemicalReactorRecipeMap().mRecipeList.remove(remove); - } - } - } - - - if (FluidRegistry.isFluidRegistered("rocket_fuel")) { - Logger.INFO("Making sure all Mixer recipes for rocket_fuel have been removed."); - AutoMap aToRemoveSingle = new AutoMap(); - FluidStack aRocketFluid = FluidUtils.getFluidStack("rocket_fuel", 1); - recipe : for (GT_Recipe aRecipeSingleBlock : GT_Recipe_Map.sMixerRecipes.mRecipeList) { - if (aRecipeSingleBlock != null && aRecipeSingleBlock.mEnabled) { - if (aRecipeSingleBlock.mFluidOutputs != null && aRecipeSingleBlock.mFluidOutputs.length > 0) { - for (FluidStack aOutput : aRecipeSingleBlock.mFluidOutputs) { - if (GT_Utility.areFluidsEqual(aOutput, aRocketFluid)) { - aToRemoveSingle.add(aRecipeSingleBlock); - continue recipe; - } - } - } - } - } - if (!aToRemoveSingle.isEmpty()) { - Logger.INFO("Found "+aToRemoveSingle.size()+" recipes, removing by force."); - for (GT_Recipe remove : aToRemoveSingle) { - GT_Recipe_Map.sMixerRecipes.mRecipeList.remove(remove); - } - aToRemoveSingle.clear(); - } - - Logger.INFO("Making sure all Chemical Reactor recipes for rocket_fuel have been removed."); - recipe : for (GT_Recipe aRecipeSingleBlock : GT_Recipe_Map.sChemicalRecipes.mRecipeList) { - if (aRecipeSingleBlock != null && aRecipeSingleBlock.mEnabled) { - if (aRecipeSingleBlock.mFluidOutputs != null && aRecipeSingleBlock.mFluidOutputs.length > 0) { - for (FluidStack aOutput : aRecipeSingleBlock.mFluidOutputs) { - if (GT_Utility.areFluidsEqual(aOutput, aRocketFluid)) { - aToRemoveSingle.add(aRecipeSingleBlock); - continue recipe; - } - } - } - } - } - // Handle Multi Also - AutoMap aToRemoveMulti = new AutoMap(); - recipe : for (GT_Recipe aRecipeSingleBlock : StaticFields59.getLargeChemicalReactorRecipeMap().mRecipeList) { - if (aRecipeSingleBlock != null && aRecipeSingleBlock.mEnabled) { - if (aRecipeSingleBlock.mFluidOutputs != null && aRecipeSingleBlock.mFluidOutputs.length > 0) { - for (FluidStack aOutput : aRecipeSingleBlock.mFluidOutputs) { - if (GT_Utility.areFluidsEqual(aOutput, aRocketFluid)) { - aToRemoveMulti.add(aRecipeSingleBlock); - continue recipe; - } - } - } - } - } - if (!aToRemoveSingle.isEmpty()) { - Logger.INFO("Found "+aToRemoveSingle.size()+" single block recipes, removing by force."); - for (GT_Recipe remove : aToRemoveSingle) { - GT_Recipe_Map.sChemicalRecipes.mRecipeList.remove(remove); - } - } - if (!aToRemoveMulti.isEmpty()) { - Logger.INFO("Found "+aToRemoveSingle.size()+" multiblock recipes, removing by force."); - for (GT_Recipe remove : aToRemoveMulti) { - StaticFields59.getLargeChemicalReactorRecipeMap().mRecipeList.remove(remove); - } - } - - } - - - - Logger.INFO("Finished clean-up of GT Rocket Fuel Recipes."); - return true; - } - - private static GTPP_Recipe getHalfBakedRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, int aEU) { - return new GTPP_Recipe(false, aInputs, null, null, null, aFluidInputs, null, 0, aEU, 0); - - } - - public static boolean removeRecipe(GT_Recipe aRecipe, GT_Recipe_Map aMap) { - if (aMap != GT_Recipe_Map.sChemicalRecipes) { - GT_Recipe aFoundRecipe = aMap.findRecipe(null, false, true, aRecipe.mEUt, aRecipe.mFluidInputs, aRecipe.mInputs); - boolean aSingle = false; - if (aFoundRecipe != null) { - Logger.INFO("Found Single Block Recipe, removing."); - aSingle = aMap.mRecipeList.remove(aFoundRecipe); - Logger.INFO("Success? "+aSingle); - } - return aSingle; - } - else { - GT_Recipe aFoundRecipe = aMap.findRecipe(null, false, true, aRecipe.mEUt, aRecipe.mFluidInputs, aRecipe.mInputs); - GT_Recipe aFoundRecipe2 = StaticFields59.getLargeChemicalReactorRecipeMap().findRecipe(null, false, true, aRecipe.mEUt, aRecipe.mFluidInputs, aRecipe.mInputs); - boolean aSingle = false; - boolean aMulti = false; - if (aFoundRecipe != null) { - Logger.INFO("Found Single Block Recipe, removing."); - aSingle = GT_Recipe_Map.sChemicalRecipes.mRecipeList.remove(aFoundRecipe); - Logger.INFO("Success? "+aSingle); - } - if (aFoundRecipe2 != null) { - Logger.INFO("Found Multiblock Recipe, removing."); - aMulti = StaticFields59.getLargeChemicalReactorRecipeMap().mRecipeList.remove(aFoundRecipe2); - Logger.INFO("Success? "+aSingle); - } - return aSingle && aMulti; - } - } - - - + public static HashSet mValidRocketFuelNames = new HashSet(); + public static HashMap mValidRocketFuels = new HashMap(); + + public static Fluid Oil_Heavy; + public static Fluid Diesel; + public static Fluid Kerosene; + public static Fluid RP1; + public static Fluid Nitrogen_Tetroxide; + public static Fluid Hydrazine; + public static Fluid Monomethylhydrazine; + public static Fluid Unsymmetrical_Dimethylhydrazine; + public static Fluid Nitrous_Oxide; + public static Fluid Hydrated_Ammonium_Nitrate_Slurry; + public static Fluid Liquid_Oxygen; + public static Fluid Liquid_Hydrogen; + public static Fluid Formaldehyde; + + // Rocket Fuel Mixes + public static Fluid Unsymmetrical_Dimethylhydrazine_Plus_Nitrogen_Tetroxide; + public static Fluid RP1_Plus_Liquid_Oxygen; + public static Fluid Dense_Hydrazine_Mix; + public static Fluid Monomethylhydrazine_Plus_Nitric_Acid; + + public static Item Ammonium_Nitrate_Dust; + public static Item Formaldehyde_Catalyst_Dust; + public static ItemStack Formaldehyde_Catalyst_Stack; + + public RocketFuels() { + super(true); + } + + public static void createKerosene() { + + FluidStack fuelA = FluidUtils.getFluidStack("diesel", 3000); + FluidStack fuelB = FluidUtils.getFluidStack("fuel", 3000); + + if (fuelA != null) { + // GT_Values.RA.addDistilleryRecipe(23, fuelA, FluidUtils.getFluidStack(Kerosene, 50), 200, 64, false); + GT_Values.RA.addDistilleryRecipe( + CI.getNumberedCircuit(23), fuelA, FluidUtils.getFluidStack(Kerosene, 1800), 200, 64, false); + } + if (fuelA == null && fuelB != null) { + // GT_Values.RA.addDistilleryRecipe(23, fuelB, FluidUtils.getFluidStack(Kerosene, 50), 200, 64, false); + GT_Values.RA.addDistilleryRecipe( + CI.getNumberedCircuit(23), fuelB, FluidUtils.getFluidStack(Kerosene, 1800), 200, 64, false); + } + } + + public static void createRP1() { + FluidStack fuelA = FluidUtils.getFluidStack(Kerosene, 1000); + if (fuelA != null) { + GT_Values.RA.addDistilleryRecipe( + CI.getNumberedCircuit(23), fuelA, FluidUtils.getFluidStack(RP1, 750), 20 * 40, 120, false); + } + } + + public static void createNitrogenTetroxide() { + // 2HNO3 + Cu = N2O4 + H2O + CuO + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("dustCopper", 1), + ItemUtils.getSimpleStack(GenericChem.mOrangeCatalyst, 0), + }, + new FluidStack[] {FluidUtils.getFluidStack("nitricacid", 2000)}, + new ItemStack[] { + Materials.CupricOxide.getDust(2), + }, + new FluidStack[] { + FluidUtils.getFluidStack(Nitrogen_Tetroxide, 1000), + }, + new int[] {100, 100, 50, 50}, + 20 * 30, + MaterialUtils.getVoltageForTier(3), + 3); + } + + public static void createHydrazine() { + + // H2O2 + 2NH3 = N2H4 + 2H2O + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] {CI.getNumberedCircuit(21)}, + new FluidStack[] { + FluidUtils.getFluidStack("fluid.hydrogenperoxide", 1000), FluidUtils.getFluidStack("ammonia", 2000), + }, + new ItemStack[] {}, + new FluidStack[] { + FluidUtils.getFluidStack(Hydrazine, 1000), + }, + 20 * 30, + MaterialUtils.getVoltageForTier(2), + 1); + + FluidStack aBartWorksHydrazine = FluidUtils.getWildcardFluidStack("hydrazine", 1000); + if (aBartWorksHydrazine != null) { + Logger.INFO("Found BW Hydrazine, adding compat recipe."); + CORE.RA.addDistilleryRecipe( + GT_Utility.getIntegratedCircuit(24), + FluidUtils.getFluidStack(Hydrazine, 1000), + aBartWorksHydrazine, + null, + 20, + 8, + false); + + CORE.RA.addDistilleryRecipe( + GT_Utility.getIntegratedCircuit(24), + aBartWorksHydrazine, + FluidUtils.getFluidStack(Hydrazine, 1000), + null, + 20, + 8, + false); + } + + FluidStack aBartWorksHydrogenPeroxide = FluidUtils.getWildcardFluidStack("Hydrogen Peroxide", 1000); + if (aBartWorksHydrogenPeroxide != null) { + Logger.INFO("Found BW Hydrogen Peroxide, adding compat recipe."); + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] {CI.getNumberedCircuit(22)}, + new FluidStack[] { + aBartWorksHydrogenPeroxide, FluidUtils.getFluidStack("ammonia", 2000), + }, + new ItemStack[] {}, + new FluidStack[] { + FluidUtils.getFluidStack(Hydrazine, 1000), + }, + 20 * 30, + MaterialUtils.getVoltageForTier(2), + 1); + + CORE.RA.addDistilleryRecipe( + GT_Utility.getIntegratedCircuit(24), + FluidUtils.getFluidStack("fluid.hydrogenperoxide", 1000), + aBartWorksHydrogenPeroxide, + null, + 20, + 8, + false); + + CORE.RA.addDistilleryRecipe( + GT_Utility.getIntegratedCircuit(24), + aBartWorksHydrogenPeroxide, + FluidUtils.getFluidStack("fluid.hydrogenperoxide", 1000), + null, + 20, + 8, + false); + } + } + + public static void createMonomethylhydrazine() { + + // C + 2H + N2H4 = CH6N2 + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] {CI.getNumberedCircuit(21), ItemUtils.getItemStackOfAmountFromOreDict("dustCarbon", 1)}, + new FluidStack[] { + FluidUtils.getFluidStack("hydrogen", 2000), FluidUtils.getFluidStack(Hydrazine, 1000), + }, + new ItemStack[] {}, + new FluidStack[] { + FluidUtils.getFluidStack(Monomethylhydrazine, 1000), + }, + 20 * 48, + 240, + 2); + + FluidStack aBartWorksMonomethylhydrazine = FluidUtils.getWildcardFluidStack("Monomethylhydrazine", 1000); + if (aBartWorksMonomethylhydrazine != null) { + Logger.INFO("Found BW Hydrazine, adding compat recipe."); + CORE.RA.addDistilleryRecipe( + GT_Utility.getIntegratedCircuit(24), + FluidUtils.getFluidStack(Monomethylhydrazine, 1000), + aBartWorksMonomethylhydrazine, + null, + 20, + 8, + false); + + CORE.RA.addDistilleryRecipe( + GT_Utility.getIntegratedCircuit(24), + aBartWorksMonomethylhydrazine, + FluidUtils.getFluidStack(Monomethylhydrazine, 1000), + null, + 20, + 8, + false); + } + } + + private static void createLOX() { + GT_Values.RA.addVacuumFreezerRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("cellOxygen", 1), + ItemUtils.getItemStackOfAmountFromOreDict("cellLiquidOxygen", 1), + 20 * 16); + CORE.RA.addAdvancedFreezerRecipe( + new ItemStack[] {}, + new FluidStack[] {FluidUtils.getFluidStack("oxygen", 3000)}, + new FluidStack[] {FluidUtils.getFluidStack(Liquid_Oxygen, 3000)}, + new ItemStack[] {}, + new int[] {}, + 20 * 16, + 240, + 0); + } + + private static void createLOH() { + GT_Values.RA.addVacuumFreezerRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 1), + ItemUtils.getItemStackOfAmountFromOreDict("cellLiquidHydrogen", 1), + 20 * 16); + CORE.RA.addAdvancedFreezerRecipe( + new ItemStack[] {}, + new FluidStack[] {FluidUtils.getFluidStack("hydrogen", 300)}, + new FluidStack[] {FluidUtils.getFluidStack(Liquid_Hydrogen, 300)}, + new ItemStack[] {}, + new int[] {}, + 20 * 4, + 540, + 0); + } + + private static void createHydratedAmmoniumNitrateSlurry() { + + // NH3 + HNO3 = NH4NO3 + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(21), + }, + new FluidStack[] { + FluidUtils.getFluidStack("ammonia", 4000), FluidUtils.getFluidStack("nitricacid", 4000), + }, + new ItemStack[] {}, + new FluidStack[] { + FluidUtils.getFluidStack(Hydrated_Ammonium_Nitrate_Slurry, 5184), + }, + 20 * 60, + 120, + 1); + } + + private static void createAmmoniumNitrateDust() { + CORE.RA.addDehydratorRecipe( + new ItemStack[] {CI.getNumberedCircuit(8)}, + FluidUtils.getFluidStack(Hydrated_Ammonium_Nitrate_Slurry, 8 * 144), + FluidUtils.getWater(2000), + new ItemStack[] {ItemUtils.getSimpleStack(Ammonium_Nitrate_Dust, 8)}, + new int[] {10000}, + 90 * 20, + 480); + } + + private static void createFormaldehyde() { + + // O + CH4O = CH2O + H2O + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(21), ItemUtils.getSimpleStack(GenericChem.mFormaldehydeCatalyst, 0), + }, + new FluidStack[] { + FluidUtils.getFluidStack("oxygen", 32000), FluidUtils.getFluidStack("methanol", 32000), + }, + new ItemStack[] {}, + new FluidStack[] { + FluidUtils.getFluidStack(Formaldehyde, 32000), + }, + 20 * 90, + 120, + 1); + + FluidStack aBartWorksFormaldehyde = FluidUtils.getWildcardFluidStack("Formaldehyde", 1000); + if (aBartWorksFormaldehyde != null) { + Logger.INFO("Found BW Formaldehyde, adding compat recipe."); + CORE.RA.addDistilleryRecipe( + GT_Utility.getIntegratedCircuit(24), + FluidUtils.getFluidStack(Formaldehyde, 1000), + aBartWorksFormaldehyde, + null, + 20, + 8, + false); + + CORE.RA.addDistilleryRecipe( + GT_Utility.getIntegratedCircuit(24), + aBartWorksFormaldehyde, + FluidUtils.getFluidStack(Formaldehyde, 1000), + null, + 20, + 8, + false); + } + } + + private static void createFormaldehydeCatalyst() { + GT_Values.RA.addMixerRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("dustIron", 16), + ItemUtils.getItemStackOfAmountFromOreDict("dustVanadium", 1), + CI.getNumberedCircuit(18), + null, + null, + null, + ItemUtils.getSimpleStack(Formaldehyde_Catalyst_Dust, 4), + 160, + 30); + } + + private static void createUnsymmetricalDimethylhydrazine() { + + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(21), ItemUtils.getSimpleStack(GenericChem.mFormaldehydeCatalyst, 0), + }, + new FluidStack[] { + FluidUtils.getFluidStack("fluid.hydrazine", 2000), + FluidUtils.getFluidStack(Formaldehyde, 2000), + FluidUtils.getFluidStack("hydrogen", 4000), + }, + new ItemStack[] {}, + new FluidStack[] { + FluidUtils.getFluidStack(Unsymmetrical_Dimethylhydrazine, 2000), FluidUtils.getWater(2000) + }, + 20 * 60, + 120, + 3); + } + + private static void addRocketFuelsToMap() { + HashMap mRocketFuels = new LinkedHashMap(); + mRocketFuels.put( + 0, + new GTPP_Recipe( + true, + new ItemStack[] {}, + new ItemStack[] {}, + null, + new int[] {}, + new FluidStack[] {FluidUtils.getFluidStack(RP1_Plus_Liquid_Oxygen, 1000)}, + new FluidStack[] {}, + 0, + 0, + 512)); // Fuel Value + + mRocketFuels.put( + 1, + new GTPP_Recipe( + true, + new ItemStack[] {}, + new ItemStack[] {}, + null, + new int[] {}, + new FluidStack[] {FluidUtils.getFluidStack(Dense_Hydrazine_Mix, 1000)}, + new FluidStack[] {}, + 0, + 0, + 1024)); // Fuel Value + + mRocketFuels.put( + 2, + new GTPP_Recipe( + true, + new ItemStack[] {}, + new ItemStack[] {}, + null, + new int[] {}, + new FluidStack[] {FluidUtils.getFluidStack(Monomethylhydrazine_Plus_Nitric_Acid, 1000)}, + new FluidStack[] {}, + 0, + 0, + 2048)); // Fuel Value + + mRocketFuels.put( + 3, + new GTPP_Recipe( + true, + new ItemStack[] {}, + new ItemStack[] {}, + null, + new int[] {}, + new FluidStack[] { + FluidUtils.getFluidStack(Unsymmetrical_Dimethylhydrazine_Plus_Nitrogen_Tetroxide, 1000) + }, + new FluidStack[] {}, + 0, + 0, + 4196)); // Fuel Value + + // Add in default Diesel for the Buggy + mValidRocketFuels.put(-1, Diesel); + + mValidRocketFuelNames.add(FluidRegistry.getFluidName(Diesel)); + for (int mID : mRocketFuels.keySet()) { + GTPP_Recipe aFuelRecipe = mRocketFuels.get(mID); + if (aFuelRecipe != null) { + mValidRocketFuelNames.add(FluidRegistry.getFluidName(aFuelRecipe.mFluidInputs[0].getFluid())); + mValidRocketFuels.put(mID, aFuelRecipe.mFluidInputs[0].getFluid()); + GTPP_Recipe.GTPP_Recipe_Map.sRocketFuels.add(aFuelRecipe); + } + } + } + + private static void createRocketFuels() { + + // RP1_Plus_Liquid_Oxygen + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedCircuit(1), + }, + new FluidStack[] { + FluidUtils.getFluidStack(Liquid_Oxygen, 2000), FluidUtils.getFluidStack(RP1, 500), + }, + new ItemStack[] {}, + new FluidStack[] { + FluidUtils.getFluidStack(RP1_Plus_Liquid_Oxygen, 1500), + }, + 20 * 15, + 240, + 3); + + // Dense_Hydrazine_Mix + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedCircuit(2), + }, + new FluidStack[] { + FluidUtils.getFluidStack(Hydrazine, 4000), FluidUtils.getFluidStack("methanol", 6000), + }, + new ItemStack[] {}, + new FluidStack[] { + FluidUtils.getFluidStack(Dense_Hydrazine_Mix, 10000), + }, + 20 * 30, + 240, + 4); + + // Monomethylhydrazine_Plus_Nitric_Acid + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedCircuit(3), + }, + new FluidStack[] { + FluidUtils.getFluidStack(Monomethylhydrazine, 2000), FluidUtils.getFluidStack("nitricacid", 1000), + }, + new ItemStack[] {}, + new FluidStack[] { + FluidUtils.getFluidStack(Monomethylhydrazine_Plus_Nitric_Acid, 2000), + }, + 20 * 45, + 480, + 5); + + // Unsymmetrical_Dimethylhydrazine_Plus_Nitrogen_Tetroxide + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedCircuit(4), + }, + new FluidStack[] { + FluidUtils.getFluidStack(Unsymmetrical_Dimethylhydrazine, 2000), + FluidUtils.getFluidStack(Nitrogen_Tetroxide, 2000), + }, + new ItemStack[] {}, + new FluidStack[] { + FluidUtils.getFluidStack(Unsymmetrical_Dimethylhydrazine_Plus_Nitrogen_Tetroxide, 5000), + }, + 20 * 60, + 480, + 6); + } + + @Override + public String errorMessage() { + return "Bad Rocket Fuel Science!"; + } + + @Override + public boolean generateRecipes() { + createKerosene(); + createRP1(); + createNitrogenTetroxide(); + createHydrazine(); + createMonomethylhydrazine(); + + if (!CORE.GTNH) { + createLOX(); + } + createLOH(); + + createHydratedAmmoniumNitrateSlurry(); + createAmmoniumNitrateDust(); + createFormaldehyde(); + createFormaldehydeCatalyst(); + createUnsymmetricalDimethylhydrazine(); + + createRocketFuels(); + addRocketFuelsToMap(); + + return true; + } + + @Override + public void items() { + Formaldehyde_Catalyst_Dust = ItemUtils.generateSpecialUseDusts( + "FormaldehydeCatalyst", "Formaldehyde Catalyst", "Fe16V1", Utils.rgbtoHexValue(25, 5, 25))[0]; + Formaldehyde_Catalyst_Stack = ItemUtils.getSimpleStack(Formaldehyde_Catalyst_Dust); + } + + @Override + public void blocks() {} + + @Override + public void fluids() { + + // Register default fluids + Diesel = MaterialUtils.getMaterial("Fuel", "Diesel").getFluid(1).getFluid(); + + // 5.08 Compat + if (!FluidUtils.doesFluidExist("liquid_heavy_oil")) { + Oil_Heavy = FluidUtils.generateFluidNoPrefix( + "liquid_heavy_oil", "Heavy Oil", 200, new short[] {10, 10, 10, 100}); + } else { + Oil_Heavy = MaterialUtils.getMaterial("OilHeavy", "Oil").getFluid(1).getFluid(); + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cellOilHeavy", 1) == null) { + new BaseItemComponent("OilHeavy", "Heavy Oil", new short[] {10, 10, 10}); + } + } + + // Create Kerosene + Kerosene = FluidUtils.generateFluidNonMolten( + "Kerosene", "Kerosene", 233, new short[] {150, 40, 150, 100}, null, null); + CoalTar.Coal_Oil = Kerosene; + + // RP! Focket Fuel + RP1 = FluidUtils.generateFluidNonMolten("RP1Fuel", "RP-1", 500, new short[] {210, 50, 50, 100}, null, null); + + // Create Nitrogen Tetroxide + Nitrogen_Tetroxide = FluidUtils.generateFluidNonMolten( + "NitrogenTetroxide", "Nitrogen Tetroxide", 261, new short[] {170, 170, 0, 100}, null, null); + + // Create Hydrazine + Hydrazine = FluidUtils.generateFluidNonMolten( + "Hydrazine", "Hydrazine", 275, new short[] {250, 250, 250, 100}, null, null); + + // Create Monomethylhydrazine + Monomethylhydrazine = FluidUtils.generateFluidNonMolten( + "Monomethylhydrazine", "Monomethylhydrazine", 221, new short[] {125, 125, 125, 100}, null, null); + + // Create Anthracene + Nitrous_Oxide = FluidUtils.generateFluidNonMolten( + "NitrousOxide", "Nitrous Oxide", 182, new short[] {255, 255, 255, 100}, null, null); + + // Nos + if (!FluidUtils.doesFluidExist("NitrousOxide")) { + Nitrous_Oxide = FluidUtils.generateFluidNoPrefix( + "NitrousOxide", "Nitrous Oxide", 182, new short[] {255, 255, 255, 100}); + } else { + Nitrous_Oxide = FluidUtils.getWildcardFluidStack("NitrousOxide", 1).getFluid(); + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cellNitrousOxide", 1) == null) { + new BaseItemComponent("NitrousOxide", "Nitrous Oxide", new short[] {10, 10, 175}); + } + } + + // Unsymmetrical_Dimethylhydrazine + if (FluidUtils.getFluidStack("1,1dimethylhydrazine", 1) == null) { + Unsymmetrical_Dimethylhydrazine = FluidUtils.generateFluidNonMolten( + "UnsymmetricalDimethylhydrazine", + "Unsymmetrical Dimethylhydrazine", + 216, + new short[] {70, 210, 20, 100}, + null, + null); + } else { + Unsymmetrical_Dimethylhydrazine = + FluidUtils.getFluidStack("1,1dimethylhydrazine", 1000).getFluid(); + } + + // Create Hydrated_Ammonium_Nitrate_Slurry + Hydrated_Ammonium_Nitrate_Slurry = FluidUtils.generateFluidNonMolten( + "AmmoniumNitrateSlurry", + "Hydrated Ammonium Nitrate Slurry", + 450, + new short[] {150, 75, 150, 100}, + null, + null); + + // Lithium Hydroperoxide - LiOH + H2O2 → LiOOH + 2 H2O + Ammonium_Nitrate_Dust = ItemUtils.generateSpecialUseDusts( + "AmmoniumNitrate", "Ammonium Nitrate", "N2H4O3", Utils.rgbtoHexValue(150, 75, 150))[0]; + + // Create Liquid_Oxygen + if (FluidUtils.getFluidStack("LiquidOxygen", 1) == null + && FluidUtils.getFluidStack("liquidoxygen", 1) == null) { + Liquid_Oxygen = FluidUtils.generateFluidNonMolten( + "LiquidOxygen", "Liquid Oxygen", 54, new short[] {75, 75, 220, 100}, null, null); + } else { + if (FluidUtils.getFluidStack("LiquidOxygen", 1) != null) { + Liquid_Oxygen = FluidUtils.getFluidStack("LiquidOxygen", 1).getFluid(); + } else { + Liquid_Oxygen = FluidUtils.getFluidStack("liquidoxygen", 1).getFluid(); + } + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cellLiquidOxygen", 1) == null) { + new BaseItemComponent("LiquidOxygen", "Liquid Oxygen", new short[] {10, 10, 175}); + } + } + + // Create Liquid_Hydrogen + if (FluidUtils.getFluidStack("LiquidHydrogen", 1) == null + && FluidUtils.getFluidStack("liquidhydrogen", 1) == null) { + Liquid_Hydrogen = FluidUtils.generateFluidNonMolten( + "LiquidHydrogen", "Liquid Hydrogen", 14, new short[] {75, 75, 220, 100}, null, null); + } else { + if (FluidUtils.getFluidStack("LiquidHydrogen", 1) != null) { + Liquid_Hydrogen = FluidUtils.getFluidStack("LiquidHydrogen", 1).getFluid(); + } else { + Liquid_Hydrogen = FluidUtils.getFluidStack("liquidhydrogen", 1).getFluid(); + } + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cellLiquidHydrogen", 1) == null) { + new BaseItemComponent("LiquidHydrogen", "Liquid Hydrogen", new short[] {10, 10, 175}); + } + } + + Formaldehyde = FluidUtils.generateFluidNonMolten( + "Formaldehyde", "Formaldehyde", 185, new short[] {150, 75, 150, 100}, null, null); + + Unsymmetrical_Dimethylhydrazine_Plus_Nitrogen_Tetroxide = FluidUtils.generateFluidNonMolten( + "RocketFuelMixA", "H8N4C2O4 Rocket Fuel", 216, new short[] {50, 220, 50, 100}, null, null); + RP1_Plus_Liquid_Oxygen = FluidUtils.generateFluidNonMolten( + "RocketFuelMixB", "Rp-1 Rocket Fuel", 250, new short[] {250, 50, 50, 100}, null, null); + Monomethylhydrazine_Plus_Nitric_Acid = FluidUtils.generateFluidNonMolten( + "RocketFuelMixC", "CN3H7O3 Rocket Fuel", 221, new short[] {125, 75, 180, 100}, null, null); + Dense_Hydrazine_Mix = FluidUtils.generateFluidNonMolten( + "RocketFuelMixD", "Dense Hydrazine Fuel Mixture", 275, new short[] {175, 80, 120, 100}, null, null); + } + + @Override + public boolean onLoadComplete(FMLLoadCompleteEvent event) { + + Logger.INFO("Trying to remove GT recipes for '1,1dimethylhydrazine' && 'rocket_fuel' if they exist."); + /*if (FluidRegistry.isFluidRegistered("1,1dimethylhydrazine")) { + + // Try Remove recipes for GT/EIO Rocket Fuel Cells + if (FluidRegistry.isFluidRegistered("rocket_fuel")) { + + // Old Recipe + if (MaterialUtils.doesMaterialExist("NitrogenDioxide")) { + GT_Recipe aOldRecipe = getHalfBakedRecipe( + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("cellNitrogenDioxide", 1), + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 3), + }, + new FluidStack[] { + FluidUtils.getFluidStack("air", 500) + }, + 388); + boolean aDidRemove = removeRecipe(aOldRecipe, GT_Recipe_Map.sChemicalRecipes); + Logger.INFO("Removed Old Recipe for Rocket Fuel: "+aDidRemove); + } + + // Simple Recipes + if (MaterialUtils.doesMaterialExist("Ammonia") && MaterialUtils.doesMaterialExist("Methanol")) { + + GT_Recipe aSimpleRecipe1 = getHalfBakedRecipe( + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("cellAmmonia", 3), + ItemUtils.getItemStackOfAmountFromOreDict("cellMethanol", 4), + }, + new FluidStack[] { + FluidUtils.getFluidStack("chlorine", 1000) + }, + 480); + GT_Recipe aSimpleRecipe2 = getHalfBakedRecipe( + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("cellChlorine", 1), + ItemUtils.getItemStackOfAmountFromOreDict("cellMethanol", 4), + }, + new FluidStack[] { + FluidUtils.getFluidStack("ammonia", 3000) + }, + 480); + GT_Recipe aSimpleRecipe3 = getHalfBakedRecipe( + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("cellAmmonia", 3), + ItemUtils.getItemStackOfAmountFromOreDict("cellChlorine", 1), + }, + new FluidStack[] { + FluidUtils.getFluidStack("methanol", 4000) + }, + 480); + + boolean aDidRemove1 = removeRecipe(aSimpleRecipe1, GT_Recipe_Map.sChemicalRecipes); + boolean aDidRemove2 = removeRecipe(aSimpleRecipe2, GT_Recipe_Map.sChemicalRecipes); + boolean aDidRemove3 = removeRecipe(aSimpleRecipe3, GT_Recipe_Map.sChemicalRecipes); + Logger.INFO("Removed Simple Recipe 1 for Rocket Fuel: "+aDidRemove1); + Logger.INFO("Removed Simple Recipe 2 for Rocket Fuel: "+aDidRemove2); + Logger.INFO("Removed Simple Recipe 3 for Rocket Fuel: "+aDidRemove3); + } + + + // Complex Recipes I + if (MaterialUtils.doesMaterialExist("Dimethylhydrazine") && MaterialUtils.doesMaterialExist("DinitrogenTetroxide")) { + + GT_Recipe aAdvRecipe1 = getHalfBakedRecipe( + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("cellDimethylhydrazine", 1), + }, + new FluidStack[] { + FluidUtils.getFluidStack("dinitrogentetroxide", 1000) + }, + 16); + GT_Recipe aAdvRecipe2 = getHalfBakedRecipe( + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("cellDinitrogenTetroxide", 1), + }, + new FluidStack[] { + FluidUtils.getFluidStack("dimethylhydrazine", 1000) + }, + 16); + + GT_Recipe aAdvRecipe3 = getHalfBakedRecipe( + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("cellDimethylhydrazine", 2), + }, + new FluidStack[] { + FluidUtils.getFluidStack("oxygen", 1000) + }, + 16); + GT_Recipe aAdvRecipe4 = getHalfBakedRecipe( + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("cellOxygen", 1), + }, + new FluidStack[] { + FluidUtils.getFluidStack("dimethylhydrazine", 2000) + }, + 16); + + boolean aDidRemove1 = removeRecipe(aAdvRecipe1, GT_Recipe_Map.sMixerRecipes); + boolean aDidRemove2 = removeRecipe(aAdvRecipe2, GT_Recipe_Map.sMixerRecipes); + boolean aDidRemove3 = removeRecipe(aAdvRecipe3, GT_Recipe_Map.sMixerRecipes); + boolean aDidRemove4 = removeRecipe(aAdvRecipe4, GT_Recipe_Map.sMixerRecipes); + Logger.INFO("Removed Complex Recipe 1 for Rocket Fuel: "+aDidRemove1); + Logger.INFO("Removed Complex Recipe 2 for Rocket Fuel: "+aDidRemove2); + Logger.INFO("Removed Complex Recipe 3 for Rocket Fuel: "+aDidRemove3); + Logger.INFO("Removed Complex Recipe 4 for Rocket Fuel: "+aDidRemove4); + } + } + + + // Complex Recipes II + if (MaterialUtils.doesMaterialExist("Dimethylhydrazine")) { + + GT_Recipe aAdvRecipe1 = getHalfBakedRecipe( + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("cellDimethylhydrazine", 2), + }, + new FluidStack[] { + FluidUtils.getFluidStack("oxygen", 1000) + }, + 16); + GT_Recipe aAdvRecipe2 = getHalfBakedRecipe( + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("cellOxygen", 1), + }, + new FluidStack[] { + FluidUtils.getFluidStack("dimethylhydrazine", 2000) + }, + 16); + + boolean aDidRemove1 = removeRecipe(aAdvRecipe1, GT_Recipe_Map.sMixerRecipes); + boolean aDidRemove2 = removeRecipe(aAdvRecipe2, GT_Recipe_Map.sMixerRecipes); + Logger.INFO("Removed Complex Recipe 5 for Rocket Fuel: "+aDidRemove1); + Logger.INFO("Removed Complex Recipe 6 for Rocket Fuel: "+aDidRemove2); + } + + if (MaterialUtils.doesMaterialExist("Chloramine") && MaterialUtils.doesMaterialExist("Dimethylamine")) { + GT_Recipe aSimpleRecipe1 = getHalfBakedRecipe( + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("cellChloramine", 2), + GT_Utility.getIntegratedCircuit(1) + }, + new FluidStack[] { + FluidUtils.getFluidStack("dimethylamine", 5000) + }, + 480); + GT_Recipe aSimpleRecipe2 = getHalfBakedRecipe( + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("cellDimethylamine", 5), + GT_Utility.getIntegratedCircuit(1) + }, + new FluidStack[] { + FluidUtils.getFluidStack("chloramine", 2000) + }, + 16); + + + + GT_Recipe aAdvRecipe1 = getHalfBakedRecipe( + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("cellChloramine", 2), + CI.emptyCells(4) + }, + new FluidStack[] { + FluidUtils.getFluidStack("dimethylamine", 5000) + }, + 480); + GT_Recipe aAdvRecipe2 = getHalfBakedRecipe( + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("cellDimethylamine", 5), + CI.emptyCells(1) + }, + new FluidStack[] { + FluidUtils.getFluidStack("chloramine", 2000) + }, + 16); + GT_Recipe aAdvRecipe3 = getHalfBakedRecipe( + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("cellChloramine", 2), + ItemUtils.getItemStackOfAmountFromOreDict("cellDimethylamine", 5), + }, + new FluidStack[] { + FluidUtils.getFluidStack("chloramine", 2000) + }, + 480); + + boolean aDidRemove1 = removeRecipe(aSimpleRecipe1, GT_Recipe_Map.sChemicalRecipes); + boolean aDidRemove2 = removeRecipe(aSimpleRecipe2, GT_Recipe_Map.sChemicalRecipes); + boolean aDidRemove3 = removeRecipe(aAdvRecipe1, GT_Recipe_Map.sChemicalRecipes); + boolean aDidRemove4 = removeRecipe(aAdvRecipe2, GT_Recipe_Map.sChemicalRecipes); + boolean aDidRemove5 = removeRecipe(aAdvRecipe3, GT_Recipe_Map.sChemicalRecipes); + Logger.INFO("Removed Complex Recipe 1 for 1,1dimethylhydrazine: "+aDidRemove1); + Logger.INFO("Removed Complex Recipe 2 for 1,1dimethylhydrazine: "+aDidRemove2); + Logger.INFO("Removed Complex Recipe 3 for 1,1dimethylhydrazine: "+aDidRemove3); + Logger.INFO("Removed Complex Recipe 4 for 1,1dimethylhydrazine: "+aDidRemove4); + Logger.INFO("Removed Complex Recipe 5 for 1,1dimethylhydrazine: "+aDidRemove5); + + } + + if (MaterialUtils.doesMaterialExist("Chloramine") && MaterialUtils.doesMaterialExist("Dimethylamine")) { + GT_Recipe aSimpleRecipe1 = getHalfBakedRecipe( + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("cellChloramine", 1), + GT_Utility.getIntegratedCircuit(1) + }, + new FluidStack[] { + FluidUtils.getFluidStack("dimethylamine", 1000) + }, + 480); + GT_Recipe aSimpleRecipe2 = getHalfBakedRecipe( + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("cellDimethylamine", 1), + GT_Utility.getIntegratedCircuit(1) + }, + new FluidStack[] { + FluidUtils.getFluidStack("chloramine", 1000) + }, + 16); + + + + GT_Recipe aAdvRecipe1 = getHalfBakedRecipe( + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("cellChloramine", 1), + GT_Utility.getIntegratedCircuit(11) + }, + new FluidStack[] { + FluidUtils.getFluidStack("dimethylamine", 1000) + }, + 480); + GT_Recipe aAdvRecipe2 = getHalfBakedRecipe( + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("cellDimethylamine", 1), + GT_Utility.getIntegratedCircuit(11) + }, + new FluidStack[] { + FluidUtils.getFluidStack("chloramine", 1000) + }, + 16); + + boolean aDidRemove1 = removeRecipe(aSimpleRecipe1, GT_Recipe_Map.sChemicalRecipes); + boolean aDidRemove2 = removeRecipe(aSimpleRecipe2, GT_Recipe_Map.sChemicalRecipes); + boolean aDidRemove3 = removeRecipe(aAdvRecipe1, GT_Recipe_Map.sChemicalRecipes); + boolean aDidRemove4 = removeRecipe(aAdvRecipe2, GT_Recipe_Map.sChemicalRecipes); + Logger.INFO("Removed Complex Recipe 5 for 1,1dimethylhydrazine: "+aDidRemove1); + Logger.INFO("Removed Complex Recipe 6 for 1,1dimethylhydrazine: "+aDidRemove2); + Logger.INFO("Removed Complex Recipe 7 for 1,1dimethylhydrazine: "+aDidRemove3); + Logger.INFO("Removed Complex Recipe 8 for 1,1dimethylhydrazine: "+aDidRemove4); + + } + + if (MaterialUtils.doesMaterialExist("HypochlorousAcid") && MaterialUtils.doesMaterialExist("Ammonia") && MaterialUtils.doesMaterialExist("Methanol")) { + + GT_Recipe aAdvRecipe1 = getHalfBakedRecipe( + new ItemStack[] { + GT_Utility.getIntegratedCircuit(24), + }, + new FluidStack[] { + FluidUtils.getFluidStack("hypochlorousacid", 3000), + FluidUtils.getFluidStack("ammonia", 8000), + FluidUtils.getFluidStack("methanol", 12000) + }, + 480); + + GT_Recipe aAdvRecipe2 = getHalfBakedRecipe( + new ItemStack[] { + GT_Utility.getIntegratedCircuit(24), + }, + new FluidStack[] { + FluidUtils.getFluidStack("hypochlorousacid", 1000), + FluidUtils.getFluidStack("ammonia", 1000), + FluidUtils.getFluidStack("methanol", 2000) + }, + 480); + + boolean aDidRemove1 = removeRecipe(aAdvRecipe1, StaticFields59.getLargeChemicalReactorRecipeMap()); + boolean aDidRemove2 = removeRecipe(aAdvRecipe2, StaticFields59.getLargeChemicalReactorRecipeMap()); + Logger.INFO("Removed Complex Recipe 9 for 1,1dimethylhydrazine: "+aDidRemove1); + Logger.INFO("Removed Complex Recipe 10 for 1,1dimethylhydrazine: "+aDidRemove2); + + + } + }*/ + + // Try Butcher recipes manually + + // 1,1Dimethylhydrazine + if (FluidRegistry.isFluidRegistered("1,1dimethylhydrazine")) { + Logger.INFO("Making sure all Chemical Reactor recipes for 1,1dimethylhydrazine have been removed."); + AutoMap aToRemoveSingle = new AutoMap(); + ItemStack aUnsymCell = ItemUtils.getItemStackOfAmountFromOreDict("cell1,1Dimethylhydrazine", 1); + FluidStack aUnsymFluid = FluidUtils.getFluidStack("1,1dimethylhydrazine", 1); + recipe: + for (GT_Recipe aRecipeSingleBlock : GT_Recipe_Map.sChemicalRecipes.mRecipeList) { + if (aRecipeSingleBlock != null && aRecipeSingleBlock.mEnabled) { + if (aRecipeSingleBlock.mOutputs != null && aRecipeSingleBlock.mOutputs.length > 0) { + for (ItemStack aOutputItem : aRecipeSingleBlock.mOutputs) { + ItemStack aTemp = aOutputItem.copy(); + aTemp.stackSize = 1; + if (GT_Utility.areStacksEqual(aTemp, aUnsymCell)) { + aToRemoveSingle.add(aRecipeSingleBlock); + continue recipe; + } + } + } + if (aRecipeSingleBlock.mFluidOutputs != null && aRecipeSingleBlock.mFluidOutputs.length > 0) { + for (FluidStack aOutput : aRecipeSingleBlock.mFluidOutputs) { + if (GT_Utility.areFluidsEqual(aOutput, aUnsymFluid)) { + aToRemoveSingle.add(aRecipeSingleBlock); + continue recipe; + } + } + } + } + } + // Handle Multi Also + AutoMap aToRemoveMulti = new AutoMap(); + recipe: + for (GT_Recipe aRecipeSingleBlock : StaticFields59.getLargeChemicalReactorRecipeMap().mRecipeList) { + if (aRecipeSingleBlock != null && aRecipeSingleBlock.mEnabled) { + if (aRecipeSingleBlock.mOutputs != null && aRecipeSingleBlock.mOutputs.length > 0) { + for (ItemStack aOutputItem : aRecipeSingleBlock.mOutputs) { + ItemStack aTemp = aOutputItem.copy(); + aTemp.stackSize = 1; + if (GT_Utility.areStacksEqual(aTemp, aUnsymCell)) { + aToRemoveMulti.add(aRecipeSingleBlock); + continue recipe; + } + } + } + if (aRecipeSingleBlock.mFluidOutputs != null && aRecipeSingleBlock.mFluidOutputs.length > 0) { + for (FluidStack aOutput : aRecipeSingleBlock.mFluidOutputs) { + if (GT_Utility.areFluidsEqual(aOutput, aUnsymFluid)) { + aToRemoveMulti.add(aRecipeSingleBlock); + continue recipe; + } + } + } + } + } + if (!aToRemoveSingle.isEmpty()) { + Logger.INFO("Found " + aToRemoveSingle.size() + " single block recipes, removing by force."); + for (GT_Recipe remove : aToRemoveSingle) { + GT_Recipe_Map.sChemicalRecipes.mRecipeList.remove(remove); + } + } + if (!aToRemoveMulti.isEmpty()) { + Logger.INFO("Found " + aToRemoveSingle.size() + " multiblock recipes, removing by force."); + for (GT_Recipe remove : aToRemoveMulti) { + StaticFields59.getLargeChemicalReactorRecipeMap() + .mRecipeList + .remove(remove); + } + } + } + + if (FluidRegistry.isFluidRegistered("rocket_fuel")) { + Logger.INFO("Making sure all Mixer recipes for rocket_fuel have been removed."); + AutoMap aToRemoveSingle = new AutoMap(); + FluidStack aRocketFluid = FluidUtils.getFluidStack("rocket_fuel", 1); + recipe: + for (GT_Recipe aRecipeSingleBlock : GT_Recipe_Map.sMixerRecipes.mRecipeList) { + if (aRecipeSingleBlock != null && aRecipeSingleBlock.mEnabled) { + if (aRecipeSingleBlock.mFluidOutputs != null && aRecipeSingleBlock.mFluidOutputs.length > 0) { + for (FluidStack aOutput : aRecipeSingleBlock.mFluidOutputs) { + if (GT_Utility.areFluidsEqual(aOutput, aRocketFluid)) { + aToRemoveSingle.add(aRecipeSingleBlock); + continue recipe; + } + } + } + } + } + if (!aToRemoveSingle.isEmpty()) { + Logger.INFO("Found " + aToRemoveSingle.size() + " recipes, removing by force."); + for (GT_Recipe remove : aToRemoveSingle) { + GT_Recipe_Map.sMixerRecipes.mRecipeList.remove(remove); + } + aToRemoveSingle.clear(); + } + + Logger.INFO("Making sure all Chemical Reactor recipes for rocket_fuel have been removed."); + recipe: + for (GT_Recipe aRecipeSingleBlock : GT_Recipe_Map.sChemicalRecipes.mRecipeList) { + if (aRecipeSingleBlock != null && aRecipeSingleBlock.mEnabled) { + if (aRecipeSingleBlock.mFluidOutputs != null && aRecipeSingleBlock.mFluidOutputs.length > 0) { + for (FluidStack aOutput : aRecipeSingleBlock.mFluidOutputs) { + if (GT_Utility.areFluidsEqual(aOutput, aRocketFluid)) { + aToRemoveSingle.add(aRecipeSingleBlock); + continue recipe; + } + } + } + } + } + // Handle Multi Also + AutoMap aToRemoveMulti = new AutoMap(); + recipe: + for (GT_Recipe aRecipeSingleBlock : StaticFields59.getLargeChemicalReactorRecipeMap().mRecipeList) { + if (aRecipeSingleBlock != null && aRecipeSingleBlock.mEnabled) { + if (aRecipeSingleBlock.mFluidOutputs != null && aRecipeSingleBlock.mFluidOutputs.length > 0) { + for (FluidStack aOutput : aRecipeSingleBlock.mFluidOutputs) { + if (GT_Utility.areFluidsEqual(aOutput, aRocketFluid)) { + aToRemoveMulti.add(aRecipeSingleBlock); + continue recipe; + } + } + } + } + } + if (!aToRemoveSingle.isEmpty()) { + Logger.INFO("Found " + aToRemoveSingle.size() + " single block recipes, removing by force."); + for (GT_Recipe remove : aToRemoveSingle) { + GT_Recipe_Map.sChemicalRecipes.mRecipeList.remove(remove); + } + } + if (!aToRemoveMulti.isEmpty()) { + Logger.INFO("Found " + aToRemoveSingle.size() + " multiblock recipes, removing by force."); + for (GT_Recipe remove : aToRemoveMulti) { + StaticFields59.getLargeChemicalReactorRecipeMap() + .mRecipeList + .remove(remove); + } + } + } + + Logger.INFO("Finished clean-up of GT Rocket Fuel Recipes."); + return true; + } + + private static GTPP_Recipe getHalfBakedRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, int aEU) { + return new GTPP_Recipe(false, aInputs, null, null, null, aFluidInputs, null, 0, aEU, 0); + } + + public static boolean removeRecipe(GT_Recipe aRecipe, GT_Recipe_Map aMap) { + if (aMap != GT_Recipe_Map.sChemicalRecipes) { + GT_Recipe aFoundRecipe = + aMap.findRecipe(null, false, true, aRecipe.mEUt, aRecipe.mFluidInputs, aRecipe.mInputs); + boolean aSingle = false; + if (aFoundRecipe != null) { + Logger.INFO("Found Single Block Recipe, removing."); + aSingle = aMap.mRecipeList.remove(aFoundRecipe); + Logger.INFO("Success? " + aSingle); + } + return aSingle; + } else { + GT_Recipe aFoundRecipe = + aMap.findRecipe(null, false, true, aRecipe.mEUt, aRecipe.mFluidInputs, aRecipe.mInputs); + GT_Recipe aFoundRecipe2 = StaticFields59.getLargeChemicalReactorRecipeMap() + .findRecipe(null, false, true, aRecipe.mEUt, aRecipe.mFluidInputs, aRecipe.mInputs); + boolean aSingle = false; + boolean aMulti = false; + if (aFoundRecipe != null) { + Logger.INFO("Found Single Block Recipe, removing."); + aSingle = GT_Recipe_Map.sChemicalRecipes.mRecipeList.remove(aFoundRecipe); + Logger.INFO("Success? " + aSingle); + } + if (aFoundRecipe2 != null) { + Logger.INFO("Found Multiblock Recipe, removing."); + aMulti = StaticFields59.getLargeChemicalReactorRecipeMap() + .mRecipeList + .remove(aFoundRecipe2); + Logger.INFO("Success? " + aSingle); + } + return aSingle && aMulti; + } + } } diff --git a/src/main/java/gtPlusPlus/core/item/chemistry/StandardBaseParticles.java b/src/main/java/gtPlusPlus/core/item/chemistry/StandardBaseParticles.java index 10eaaf0da9..1b8a5f21cc 100644 --- a/src/main/java/gtPlusPlus/core/item/chemistry/StandardBaseParticles.java +++ b/src/main/java/gtPlusPlus/core/item/chemistry/StandardBaseParticles.java @@ -1,14 +1,13 @@ package gtPlusPlus.core.item.chemistry; -import java.util.HashMap; -import java.util.List; - import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.item.base.misc.BaseItemParticle; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.Particle; import gtPlusPlus.core.material.Particle.ElementaryGroup; import gtPlusPlus.core.util.Utils; +import java.util.HashMap; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; @@ -18,144 +17,153 @@ import net.minecraft.util.IIcon; public class StandardBaseParticles extends BaseItemParticle { - public static HashMap NameToMetaMap = new HashMap(); - public static HashMap MetaToNameMap = new HashMap(); - - public StandardBaseParticles() { - super("Base", aTypes.length, EnumRarity.rare); - } - - private static final String[] aTypes = new String[] { "Graviton", "Up", "Down", "Charm", "Strange", "Top", - "Bottom", "Electron", "Electron Neutrino", "Muon", "Muon Neutrino", "Tau", "Tau Neutrino", "Gluon", - "Photon", "Z Boson", "W Boson", "Higgs Boson", "Proton", "Neutron", "Lambda", "Omega", "Pion", - "ETA Meson", "Unknown" }; - - public IIcon[] icons = new IIcon[aTypes.length]; - - static { - //Generate Ions - int key = 0; - - - for (String s : aTypes) { - //Map names to Meta - NameToMetaMap.put(Utils.sanitizeString(s.toLowerCase()), key); - MetaToNameMap.put(key, Utils.sanitizeString(s.toLowerCase())); - for (Particle o : Particle.aMap) { - int aColour = 0; - if (o.mParticleName.toLowerCase().equals(s.toLowerCase())) { - if (o.mParticleType == ElementaryGroup.BARYON) { - aColour = Utils.rgbtoHexValue(174, 226, 156); - aColourMap.put(key++, aColour); - } - else if (o.mParticleType == ElementaryGroup.BOSON) { - if (o == Particle.HIGGS_BOSON) { - aColour = Utils.rgbtoHexValue(226, 196, 104); - aColourMap.put(key++, aColour); - } - else { - aColour = Utils.rgbtoHexValue(226, 52, 66); - aColourMap.put(key++, aColour); - } - } - else if (o.mParticleType == ElementaryGroup.LEPTON) { - aColour = Utils.rgbtoHexValue(126, 226, 95); - aColourMap.put(key++, aColour); - } - else if (o.mParticleType == ElementaryGroup.MESON) { - aColour = Utils.rgbtoHexValue(90, 154, 226); - aColourMap.put(key++, aColour); - } - else { - aColour = Utils.rgbtoHexValue(188, 61, 226); - aColourMap.put(key++, aColour); - } - } - } - } - - } - - @Override - public String[] getAffixes() { - return new String[] {"", ""}; - } - - @Override - public String getUnlocalizedName() { - return ""; - } - - @Override + public static HashMap NameToMetaMap = new HashMap(); + public static HashMap MetaToNameMap = new HashMap(); + + public StandardBaseParticles() { + super("Base", aTypes.length, EnumRarity.rare); + } + + private static final String[] aTypes = new String[] { + "Graviton", + "Up", + "Down", + "Charm", + "Strange", + "Top", + "Bottom", + "Electron", + "Electron Neutrino", + "Muon", + "Muon Neutrino", + "Tau", + "Tau Neutrino", + "Gluon", + "Photon", + "Z Boson", + "W Boson", + "Higgs Boson", + "Proton", + "Neutron", + "Lambda", + "Omega", + "Pion", + "ETA Meson", + "Unknown" + }; + + public IIcon[] icons = new IIcon[aTypes.length]; + + static { + // Generate Ions + int key = 0; + + for (String s : aTypes) { + // Map names to Meta + NameToMetaMap.put(Utils.sanitizeString(s.toLowerCase()), key); + MetaToNameMap.put(key, Utils.sanitizeString(s.toLowerCase())); + for (Particle o : Particle.aMap) { + int aColour = 0; + if (o.mParticleName.toLowerCase().equals(s.toLowerCase())) { + if (o.mParticleType == ElementaryGroup.BARYON) { + aColour = Utils.rgbtoHexValue(174, 226, 156); + aColourMap.put(key++, aColour); + } else if (o.mParticleType == ElementaryGroup.BOSON) { + if (o == Particle.HIGGS_BOSON) { + aColour = Utils.rgbtoHexValue(226, 196, 104); + aColourMap.put(key++, aColour); + } else { + aColour = Utils.rgbtoHexValue(226, 52, 66); + aColourMap.put(key++, aColour); + } + } else if (o.mParticleType == ElementaryGroup.LEPTON) { + aColour = Utils.rgbtoHexValue(126, 226, 95); + aColourMap.put(key++, aColour); + } else if (o.mParticleType == ElementaryGroup.MESON) { + aColour = Utils.rgbtoHexValue(90, 154, 226); + aColourMap.put(key++, aColour); + } else { + aColour = Utils.rgbtoHexValue(188, 61, 226); + aColourMap.put(key++, aColour); + } + } + } + } + } + + @Override + public String[] getAffixes() { + return new String[] {"", ""}; + } + + @Override + public String getUnlocalizedName() { + return ""; + } + + @Override public String getUnlocalizedName(final ItemStack itemStack) { return "item.particle.base" + "." + aTypes[itemStack.getItemDamage()]; } - - public static Particle getParticle(ItemStack aStack) { - AutoMap g = Particle.aMap; - for (Particle p : g) { - String aPartName = Utils.sanitizeString(p.mParticleName.toLowerCase()); - String expectedPart = Utils.sanitizeString(aTypes[aStack.getItemDamage()].toLowerCase()); - if (aPartName.equals(expectedPart)) { - return p; - } - } - return Particle.UNKNOWN; - } - - @Override - public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { - //return Utils.rgbtoHexValue(200, 200, 200); - return super.getColorFromParentClass(stack, HEX_OxFFFFFF); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { - Particle aCharge = getParticle(stack); - EnumChatFormatting aColour = EnumChatFormatting.GRAY; - String aState = aColour+"Unknown"+EnumChatFormatting.RESET; - if (aCharge != null) { - String aGroup = aCharge.mParticleType.name().toLowerCase(); - if (aGroup.toLowerCase().contains("quark")) { - aColour = EnumChatFormatting.LIGHT_PURPLE; - } - else if (aGroup.toLowerCase().contains("lepton")) { - aColour = EnumChatFormatting.GREEN; - } - else if (aCharge == Particle.HIGGS_BOSON) { - aColour = EnumChatFormatting.YELLOW; - } - else if (aGroup.toLowerCase().contains("boson")) { - aColour = EnumChatFormatting.RED; - } - else if (aGroup.toLowerCase().contains("baryon")) { - aColour = EnumChatFormatting.BLUE; - } - else if (aGroup.toLowerCase().contains("meson")) { - aColour = EnumChatFormatting.WHITE; - } - else { - aColour = EnumChatFormatting.GRAY; - } - String aFirstLet = aGroup.substring(0, 1).toUpperCase(); - aGroup = aGroup.replaceFirst(aGroup.substring(0, 1), aFirstLet); - aState = aColour+aGroup+EnumChatFormatting.RESET; - list.add(EnumChatFormatting.GRAY + "Type: "+aState); - } - super.addInformation(stack, player, list, bool); - } - - @Override - public void registerIcons(IIconRegister reg) { - for (int i = 0; i < this.icons.length; i++) { - this.icons[i] = reg.registerIcon(CORE.MODID + ":" + "particle/new/"+i); - } - } - - @Override - public IIcon getIconFromDamage(int meta) { - return this.icons[meta]; - } + public static Particle getParticle(ItemStack aStack) { + AutoMap g = Particle.aMap; + for (Particle p : g) { + String aPartName = Utils.sanitizeString(p.mParticleName.toLowerCase()); + String expectedPart = Utils.sanitizeString(aTypes[aStack.getItemDamage()].toLowerCase()); + if (aPartName.equals(expectedPart)) { + return p; + } + } + return Particle.UNKNOWN; + } + + @Override + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + // return Utils.rgbtoHexValue(200, 200, 200); + return super.getColorFromParentClass(stack, HEX_OxFFFFFF); + } + + @SuppressWarnings({"rawtypes", "unchecked"}) + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { + Particle aCharge = getParticle(stack); + EnumChatFormatting aColour = EnumChatFormatting.GRAY; + String aState = aColour + "Unknown" + EnumChatFormatting.RESET; + if (aCharge != null) { + String aGroup = aCharge.mParticleType.name().toLowerCase(); + if (aGroup.toLowerCase().contains("quark")) { + aColour = EnumChatFormatting.LIGHT_PURPLE; + } else if (aGroup.toLowerCase().contains("lepton")) { + aColour = EnumChatFormatting.GREEN; + } else if (aCharge == Particle.HIGGS_BOSON) { + aColour = EnumChatFormatting.YELLOW; + } else if (aGroup.toLowerCase().contains("boson")) { + aColour = EnumChatFormatting.RED; + } else if (aGroup.toLowerCase().contains("baryon")) { + aColour = EnumChatFormatting.BLUE; + } else if (aGroup.toLowerCase().contains("meson")) { + aColour = EnumChatFormatting.WHITE; + } else { + aColour = EnumChatFormatting.GRAY; + } + String aFirstLet = aGroup.substring(0, 1).toUpperCase(); + aGroup = aGroup.replaceFirst(aGroup.substring(0, 1), aFirstLet); + aState = aColour + aGroup + EnumChatFormatting.RESET; + list.add(EnumChatFormatting.GRAY + "Type: " + aState); + } + super.addInformation(stack, player, list, bool); + } + + @Override + public void registerIcons(IIconRegister reg) { + for (int i = 0; i < this.icons.length; i++) { + this.icons[i] = reg.registerIcon(CORE.MODID + ":" + "particle/new/" + i); + } + } + + @Override + public IIcon getIconFromDamage(int meta) { + return this.icons[meta]; + } } diff --git a/src/main/java/gtPlusPlus/core/item/chemistry/general/ItemGenericChemBase.java b/src/main/java/gtPlusPlus/core/item/chemistry/general/ItemGenericChemBase.java index 41b7d4daf1..35204999d1 100644 --- a/src/main/java/gtPlusPlus/core/item/chemistry/general/ItemGenericChemBase.java +++ b/src/main/java/gtPlusPlus/core/item/chemistry/general/ItemGenericChemBase.java @@ -1,12 +1,11 @@ package gtPlusPlus.core.item.chemistry.general; -import java.util.List; - import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.item.chemistry.GenericChem; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.ItemUtils; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; @@ -21,300 +20,294 @@ import net.minecraft.world.World; public class ItemGenericChemBase extends Item { - final protected IIcon base[]; - - final private int aMetaSize = 16; - - /* - * 0 - Red Metal Catalyst //FeCu - * 1 - Yellow Metal Catalyst //WNi - * 2 - Blue Metal Catalyst //CoTi - * 3 - Orange Metal Catalyst //Vanadium Pd - * 4 - Purple Metal Catalyst //IrIdium Ruthenium - * 5 - Brown Metal Catalyst //NiAl - * 6 - Pink Metal Catalyst //PtRh - * 7 - Alumina Grinding Ball - * 8 - Soapstone Grinding Ball - * 9 - Sodium Ethoxide // 2 Sodium + 1 Ethanol | 2 C2H5OH + 2 Na → 2 C2H5ONa + H2 - * 10 - Sodium Ethyl Xanthate //CH3CH2ONa + CS2 → CH3CH2OCS2Na - * 11 - Potassium Ethyl Xanthate //CH3CH2OH + CS2 + KOH → CH3CH2OCS2K + H2O - * 12 - Potassium Hydroxide // KOH - * 13 - Formaldehyde Catalyst //Fe16V1 - * 14 - Solid Acid Catalyst //H2SO4 - */ - - public ItemGenericChemBase() { - this.setHasSubtypes(true); - this.setNoRepair(); - this.setMaxStackSize(64); - this.setMaxDamage(0); - base = new IIcon[aMetaSize]; - this.setUnlocalizedName("BasicGenericChemItem"); - GameRegistry.registerItem(this, this.getUnlocalizedName()); - } - - @Override - public int getItemStackLimit(ItemStack stack) { - if (ItemUtils.isMillingBall(stack)) { - return 16; - } - return super.getItemStackLimit(stack); - } - - @Override - public boolean isDamageable() { - return false; - } - - @Override - public boolean shouldRotateAroundWhenRendering() { - return super.shouldRotateAroundWhenRendering(); - } - - @Override - public void onUpdate(ItemStack p_77663_1_, World p_77663_2_, Entity p_77663_3_, int p_77663_4_, boolean p_77663_5_) { - super.onUpdate(p_77663_1_, p_77663_2_, p_77663_3_, p_77663_4_, p_77663_5_); - } - - @Override - public String getItemStackDisplayName(ItemStack aStack) { - return super.getItemStackDisplayName(aStack); - } - - @Override - public EnumRarity getRarity(ItemStack p_77613_1_) { - return EnumRarity.common; - } - - @Override - public boolean requiresMultipleRenderPasses() { - return false; - } - - @Override - public void getSubItems(Item aItem, CreativeTabs p_150895_2_, List aList) { - for (int i=0;i aDamageSegment * 3){ - durability = EnumChatFormatting.GREEN; - } - else if (aDam > aDamageSegment * 2){ - durability = EnumChatFormatting.YELLOW; - } - else if (aDam > aDamageSegment){ - durability = EnumChatFormatting.GOLD; - } - else if (aDam >= 0){ - durability = EnumChatFormatting.RED; - } - list.add(durability+""+(aDam)+EnumChatFormatting.GRAY+" / "+aMaxDamage); - } - super.addInformation(aStack, player, list, bool); - } - - @Override - public boolean showDurabilityBar(ItemStack aStack) { - if (ItemUtils.isMillingBall(aStack)) { - int aDam = getMillingBallDamage(aStack); - if (aDam > 0) { - return true; - } - } - else if (ItemUtils.isCatalyst(aStack)) { - int aDam = getCatalystDamage(aStack); - if (aDam > 0) { - return true; - } - } - return false; - } - - public static boolean createMillingBallNBT(ItemStack rStack){ - final NBTTagCompound tagMain = new NBTTagCompound(); - final NBTTagCompound tagNBT = new NBTTagCompound(); - tagNBT.setLong("Damage", 0); - tagNBT.setLong("MaxDamage", getMaxBallDurability(rStack)); - tagMain.setTag("MillingBall", tagNBT); - rStack.setTagCompound(tagMain); - return true; - } - - public static int getMillingBallDamage(ItemStack aStack) { - if (aStack.getTagCompound() == null || aStack.getTagCompound().hasNoTags()) { - createMillingBallNBT(aStack); - } - NBTTagCompound aNBT = aStack.getTagCompound(); - return aNBT.getCompoundTag("MillingBall").getInteger("Damage"); - } - - public static int getMillingBallMaxDamage(ItemStack aStack) { - if (aStack.getTagCompound() == null || aStack.getTagCompound().hasNoTags()) { - createMillingBallNBT(aStack); - } - NBTTagCompound aNBT = aStack.getTagCompound(); - return aNBT.getCompoundTag("MillingBall").getInteger("MaxDamage"); - } - - public static void setMillingBallDamage(ItemStack aStack,int aAmount) { - NBTTagCompound aNBT = aStack.getTagCompound(); - aNBT = aNBT.getCompoundTag("MillingBall"); - aNBT.setInteger("Damage", aAmount); - } - - public static int getMaxBallDurability(ItemStack aStack) { - if (GT_Utility.areStacksEqual(aStack, GenericChem.mMillingBallAlumina, true)) { - return 100; - } - if (GT_Utility.areStacksEqual(aStack, GenericChem.mMillingBallSoapstone, true)) { - return 50; - } - return 0; - } - - public static boolean createCatalystNBT(ItemStack rStack){ - final NBTTagCompound tagMain = new NBTTagCompound(); - final NBTTagCompound tagNBT = new NBTTagCompound(); - tagNBT.setLong("Damage", 0); - tagNBT.setLong("MaxDamage", getMaxCatalystDurability(rStack)); - tagMain.setTag("catalyst", tagNBT); - rStack.setTagCompound(tagMain); - return true; - } - - public static int getCatalystDamage(ItemStack aStack) { - if (aStack.getTagCompound() == null || aStack.getTagCompound().hasNoTags()) { - createCatalystNBT(aStack); - } - NBTTagCompound aNBT = aStack.getTagCompound(); - return aNBT.getCompoundTag("catalyst").getInteger("Damage"); - } - - public static int getCatalystMaxDamage(ItemStack aStack) { - if (aStack.getTagCompound() == null || aStack.getTagCompound().hasNoTags()) { - createCatalystNBT(aStack); - } - NBTTagCompound aNBT = aStack.getTagCompound(); - return aNBT.getCompoundTag("catalyst").getInteger("MaxDamage"); - } - - public static void setCatalystDamage(ItemStack aStack,int aAmount) { - NBTTagCompound aNBT = aStack.getTagCompound(); - aNBT = aNBT.getCompoundTag("catalyst"); - aNBT.setInteger("Damage", aAmount); - } - - public static int getMaxCatalystDurability(ItemStack aStack) { - return 50; - } + return super.getUnlocalizedName() + "." + stack.getItemDamage(); + } + + @Override + public double getDurabilityForDisplay(ItemStack aStack) { + if (ItemUtils.isMillingBall(aStack)) { + if (aStack.getTagCompound() == null || aStack.getTagCompound().hasNoTags()) { + createMillingBallNBT(aStack); + } + double currentDamage = getMillingBallDamage(aStack); + return currentDamage / getMaxBallDurability(aStack); + } else if (ItemUtils.isCatalyst(aStack)) { + if (aStack.getTagCompound() == null || aStack.getTagCompound().hasNoTags()) { + createCatalystNBT(aStack); + } + double currentDamage = getCatalystDamage(aStack); + return currentDamage / getCatalystMaxDamage(aStack); + } else { + return 1D; + } + } + + @SuppressWarnings("unchecked") + @Override + public void addInformation(ItemStack aStack, EntityPlayer player, List list, boolean bool) { + boolean aHasSpecialTooltips = false; + int aMaxDamage = 0; + int aDamageSegment = 0; + int aDam = 0; + EnumChatFormatting durability = EnumChatFormatting.GRAY; + if (ItemUtils.isMillingBall(aStack)) { + list.add(EnumChatFormatting.GRAY + "Tumble Tumble Tumble"); + aMaxDamage = getMillingBallMaxDamage(aStack); + aDamageSegment = aMaxDamage / 5; + aDam = aMaxDamage - getMillingBallDamage(aStack); + aHasSpecialTooltips = true; + } + if (ItemUtils.isCatalyst(aStack)) { + list.add(EnumChatFormatting.GRAY + "Active Reaction Agent"); + aMaxDamage = getCatalystMaxDamage(aStack); + aDamageSegment = aMaxDamage / 5; + aDam = aMaxDamage - getCatalystDamage(aStack); + aHasSpecialTooltips = true; + } + if (aHasSpecialTooltips) { + if (aDam > aDamageSegment * 3) { + durability = EnumChatFormatting.GREEN; + } else if (aDam > aDamageSegment * 2) { + durability = EnumChatFormatting.YELLOW; + } else if (aDam > aDamageSegment) { + durability = EnumChatFormatting.GOLD; + } else if (aDam >= 0) { + durability = EnumChatFormatting.RED; + } + list.add(durability + "" + (aDam) + EnumChatFormatting.GRAY + " / " + aMaxDamage); + } + super.addInformation(aStack, player, list, bool); + } + + @Override + public boolean showDurabilityBar(ItemStack aStack) { + if (ItemUtils.isMillingBall(aStack)) { + int aDam = getMillingBallDamage(aStack); + if (aDam > 0) { + return true; + } + } else if (ItemUtils.isCatalyst(aStack)) { + int aDam = getCatalystDamage(aStack); + if (aDam > 0) { + return true; + } + } + return false; + } + + public static boolean createMillingBallNBT(ItemStack rStack) { + final NBTTagCompound tagMain = new NBTTagCompound(); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setLong("Damage", 0); + tagNBT.setLong("MaxDamage", getMaxBallDurability(rStack)); + tagMain.setTag("MillingBall", tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public static int getMillingBallDamage(ItemStack aStack) { + if (aStack.getTagCompound() == null || aStack.getTagCompound().hasNoTags()) { + createMillingBallNBT(aStack); + } + NBTTagCompound aNBT = aStack.getTagCompound(); + return aNBT.getCompoundTag("MillingBall").getInteger("Damage"); + } + + public static int getMillingBallMaxDamage(ItemStack aStack) { + if (aStack.getTagCompound() == null || aStack.getTagCompound().hasNoTags()) { + createMillingBallNBT(aStack); + } + NBTTagCompound aNBT = aStack.getTagCompound(); + return aNBT.getCompoundTag("MillingBall").getInteger("MaxDamage"); + } + + public static void setMillingBallDamage(ItemStack aStack, int aAmount) { + NBTTagCompound aNBT = aStack.getTagCompound(); + aNBT = aNBT.getCompoundTag("MillingBall"); + aNBT.setInteger("Damage", aAmount); + } + + public static int getMaxBallDurability(ItemStack aStack) { + if (GT_Utility.areStacksEqual(aStack, GenericChem.mMillingBallAlumina, true)) { + return 100; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mMillingBallSoapstone, true)) { + return 50; + } + return 0; + } + + public static boolean createCatalystNBT(ItemStack rStack) { + final NBTTagCompound tagMain = new NBTTagCompound(); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setLong("Damage", 0); + tagNBT.setLong("MaxDamage", getMaxCatalystDurability(rStack)); + tagMain.setTag("catalyst", tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public static int getCatalystDamage(ItemStack aStack) { + if (aStack.getTagCompound() == null || aStack.getTagCompound().hasNoTags()) { + createCatalystNBT(aStack); + } + NBTTagCompound aNBT = aStack.getTagCompound(); + return aNBT.getCompoundTag("catalyst").getInteger("Damage"); + } + + public static int getCatalystMaxDamage(ItemStack aStack) { + if (aStack.getTagCompound() == null || aStack.getTagCompound().hasNoTags()) { + createCatalystNBT(aStack); + } + NBTTagCompound aNBT = aStack.getTagCompound(); + return aNBT.getCompoundTag("catalyst").getInteger("MaxDamage"); + } + + public static void setCatalystDamage(ItemStack aStack, int aAmount) { + NBTTagCompound aNBT = aStack.getTagCompound(); + aNBT = aNBT.getCompoundTag("catalyst"); + aNBT.setInteger("Damage", aAmount); + } + + public static int getMaxCatalystDurability(ItemStack aStack) { + return 50; + } } diff --git a/src/main/java/gtPlusPlus/core/item/chemistry/general/ItemNuclearChemBase.java b/src/main/java/gtPlusPlus/core/item/chemistry/general/ItemNuclearChemBase.java index cfd3fd6259..4e3ca1477e 100644 --- a/src/main/java/gtPlusPlus/core/item/chemistry/general/ItemNuclearChemBase.java +++ b/src/main/java/gtPlusPlus/core/item/chemistry/general/ItemNuclearChemBase.java @@ -1,10 +1,9 @@ package gtPlusPlus.core.item.chemistry.general; -import java.util.List; - import cpw.mods.fml.common.registry.GameRegistry; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.ItemUtils; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; @@ -17,136 +16,135 @@ import net.minecraft.world.World; public class ItemNuclearChemBase extends Item { - final protected IIcon base[]; - - final private int aMetaSize = 4; - - /* - * 0 - Uranium Residue - * 1 - Plutonium Residue - * 2 - Fluoride Reside - * 3 - Noble Gas Residue - */ - - public ItemNuclearChemBase() { - this.setHasSubtypes(true); - this.setNoRepair(); - this.setMaxStackSize(64); - this.setMaxDamage(0); - base = new IIcon[aMetaSize]; - this.setUnlocalizedName("BasicNuclearChemItem"); - GameRegistry.registerItem(this, this.getUnlocalizedName()); - } - - @Override - public int getItemStackLimit(ItemStack stack) { - return super.getItemStackLimit(stack); - } - - @Override - public boolean isDamageable() { - return false; - } - - @Override - public boolean shouldRotateAroundWhenRendering() { - return super.shouldRotateAroundWhenRendering(); - } - - @Override - public void onUpdate(ItemStack p_77663_1_, World p_77663_2_, Entity p_77663_3_, int p_77663_4_, boolean p_77663_5_) { - super.onUpdate(p_77663_1_, p_77663_2_, p_77663_3_, p_77663_4_, p_77663_5_); - } - - @Override - public String getItemStackDisplayName(ItemStack aStack) { - return super.getItemStackDisplayName(aStack); - } - - @Override - public EnumRarity getRarity(ItemStack p_77613_1_) { - return EnumRarity.common; - } - - @Override - public boolean requiresMultipleRenderPasses() { - return false; - } - - @Override - public void getSubItems(Item aItem, CreativeTabs p_150895_2_, List aList) { - for (int i=0;i ALL_VARIANTS = new ArrayList<>(); - protected IIcon base; - - public ItemAdvancedChip() { - this.setHasSubtypes(true); - this.setNoRepair(); - this.setMaxStackSize(64); - this.setMaxDamage(0); - this.setUnlocalizedName("T3RecipeSelector"); - GameRegistry.registerItem(this, this.getUnlocalizedName()); - ALL_VARIANTS.add(new ItemStack(this, 0, 0)); - for (int i = 1; i <= 24; i++) { - ItemStack aStack = new ItemStack(this, 0, i); - ALL_VARIANTS.add(aStack); - } - } - - @Override - public boolean isDamageable() { - return false; - } - - @Override - public boolean shouldRotateAroundWhenRendering() { - return super.shouldRotateAroundWhenRendering(); - } - - @Override - public void onUpdate(ItemStack p_77663_1_, World p_77663_2_, Entity p_77663_3_, int p_77663_4_, boolean p_77663_5_) { - super.onUpdate(p_77663_1_, p_77663_2_, p_77663_3_, p_77663_4_, p_77663_5_); - } - - @Override - public String getItemStackDisplayName(ItemStack aStack) { - return super.getItemStackDisplayName(aStack); - } - - @Override - public void addInformation(ItemStack aStack, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { - try { - aList.add("Configuration == "+aStack.getItemDamage()); - aList.add(GT_LanguageManager.addStringLocalization(new StringBuilder().append(getUnlocalizedName()).append(".tooltip.0").toString(), "Right click to reconfigure")); - aList.add(GT_LanguageManager.addStringLocalization(new StringBuilder().append(getUnlocalizedName()).append(".tooltip.1").toString(), "Needs a screwdriver or circuit programming tool")); - } - catch (Throwable t) { - t.printStackTrace(); - } - super.addInformation(aStack, p_77624_2_, aList, p_77624_4_); - } - - @Override - public EnumRarity getRarity(ItemStack p_77613_1_) { - return EnumRarity.common; - } - - @Override - public void getSubItems(Item aItem, CreativeTabs p_150895_2_, List aList) { - aList.add(ItemUtils.simpleMetaStack(aItem, 0, 1)); - } - - @Override - public boolean getIsRepairable(ItemStack p_82789_1_, ItemStack p_82789_2_) { - return false; - } - - @Override - public boolean isRepairable() { - return false; - } - - @Override - public boolean isBookEnchantable(ItemStack stack, ItemStack book) { - return false; - } - - @Override - public int getDisplayDamage(ItemStack stack) { - return stack.getItemDamage(); - } - - @Override - public boolean showDurabilityBar(ItemStack stack) { - return false; - } - - @Override - public int getItemEnchantability() { - return 0; - } - - @Override - public int getItemEnchantability(ItemStack stack) { - return 0; - } - - @Override - public void registerIcons(final IIconRegister u) { - this.base = u.registerIcon(CORE.MODID + ":" + "science/general/AdvancedCircuit"); - } - - @Override - public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) { - return this.base; - } - - @Override - public IIcon getIconFromDamage(int damage) { - return this.base; - } - - @Override - public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { - return this.base; - } - - @Override - public IIcon getIcon(ItemStack stack, int pass) { - return this.base; - } - - @Override + private static final List ALL_VARIANTS = new ArrayList<>(); + protected IIcon base; + + public ItemAdvancedChip() { + this.setHasSubtypes(true); + this.setNoRepair(); + this.setMaxStackSize(64); + this.setMaxDamage(0); + this.setUnlocalizedName("T3RecipeSelector"); + GameRegistry.registerItem(this, this.getUnlocalizedName()); + ALL_VARIANTS.add(new ItemStack(this, 0, 0)); + for (int i = 1; i <= 24; i++) { + ItemStack aStack = new ItemStack(this, 0, i); + ALL_VARIANTS.add(aStack); + } + } + + @Override + public boolean isDamageable() { + return false; + } + + @Override + public boolean shouldRotateAroundWhenRendering() { + return super.shouldRotateAroundWhenRendering(); + } + + @Override + public void onUpdate( + ItemStack p_77663_1_, World p_77663_2_, Entity p_77663_3_, int p_77663_4_, boolean p_77663_5_) { + super.onUpdate(p_77663_1_, p_77663_2_, p_77663_3_, p_77663_4_, p_77663_5_); + } + + @Override + public String getItemStackDisplayName(ItemStack aStack) { + return super.getItemStackDisplayName(aStack); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { + try { + aList.add("Configuration == " + aStack.getItemDamage()); + aList.add(GT_LanguageManager.addStringLocalization( + new StringBuilder() + .append(getUnlocalizedName()) + .append(".tooltip.0") + .toString(), + "Right click to reconfigure")); + aList.add(GT_LanguageManager.addStringLocalization( + new StringBuilder() + .append(getUnlocalizedName()) + .append(".tooltip.1") + .toString(), + "Needs a screwdriver or circuit programming tool")); + } catch (Throwable t) { + t.printStackTrace(); + } + super.addInformation(aStack, p_77624_2_, aList, p_77624_4_); + } + + @Override + public EnumRarity getRarity(ItemStack p_77613_1_) { + return EnumRarity.common; + } + + @Override + public void getSubItems(Item aItem, CreativeTabs p_150895_2_, List aList) { + aList.add(ItemUtils.simpleMetaStack(aItem, 0, 1)); + } + + @Override + public boolean getIsRepairable(ItemStack p_82789_1_, ItemStack p_82789_2_) { + return false; + } + + @Override + public boolean isRepairable() { + return false; + } + + @Override + public boolean isBookEnchantable(ItemStack stack, ItemStack book) { + return false; + } + + @Override + public int getDisplayDamage(ItemStack stack) { + return stack.getItemDamage(); + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } + + @Override + public int getItemEnchantability() { + return 0; + } + + @Override + public int getItemEnchantability(ItemStack stack) { + return 0; + } + + @Override + public void registerIcons(final IIconRegister u) { + this.base = u.registerIcon(CORE.MODID + ":" + "science/general/AdvancedCircuit"); + } + + @Override + public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) { + return this.base; + } + + @Override + public IIcon getIconFromDamage(int damage) { + return this.base; + } + + @Override + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { + return this.base; + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return this.base; + } + + @Override public String getUnlocalizedName(ItemStack stack) { - return super.getUnlocalizedName(); - } - - @Override - public boolean receive(ItemStack stack, EntityPlayerMP player, NBTTagCompound tag) { - int meta = tag.hasKey("meta", Constants.NBT.TAG_BYTE) ? tag.getByte("meta") : -1; - if (meta < 0 || meta > 24) - return true; - - if (!player.capabilities.isCreativeMode) { - Pair> toolIndex = findConfiguratorInInv(player); - if (toolIndex == null) return true; - - ItemStack[] mainInventory = player.inventory.mainInventory; - mainInventory[toolIndex.getKey()] = toolIndex.getValue().apply(mainInventory[toolIndex.getKey()], player); - } - stack.setItemDamage(meta); - - return true; - } - - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) { - // nothing on server side or fake player - if (player instanceof FakePlayer || !world.isRemote) return false; - // check if any screwdriver - ItemStack configuratorStack; - if (player.capabilities.isCreativeMode) { - configuratorStack = null; - } else { - Pair configurator = findConfiguratorInInv(player); - if (configurator == null) { - int count; - try { - count = Integer.parseInt(StatCollector.translateToLocal("GT5U.item.programmed_circuit.no_screwdriver.count")); - } catch (NumberFormatException e) { - player.addChatComponentMessage(new ChatComponentText("Error in translation GT5U.item.programmed_circuit.no_screwdriver.count: " + e.getMessage())); - count = 1; - } - player.addChatComponentMessage(new ChatComponentTranslation("GT5U.item.programmed_circuit.no_screwdriver." + XSTR.XSTR_INSTANCE.nextInt(count))); - return false; - } - configuratorStack = player.inventory.mainInventory[configurator.getKey()]; - } - openSelectorGui(configuratorStack, stack.getItemDamage()); - return true; - } - - private void openSelectorGui(ItemStack configurator, int meta) { - FMLCommonHandler.instance().showGuiScreen(new GT_GUIDialogSelectItem( - StatCollector.translateToLocal("GT5U.item.programmed_circuit.select.header"), - configurator, - null, - ItemAdvancedChip::onConfigured, - ALL_VARIANTS, - meta, - true - )); - } - - private static void onConfigured(ItemStack stack) { - NBTTagCompound tag = new NBTTagCompound(); - tag.setByte("meta", (byte) stack.getItemDamage()); - GT_Values.NW.sendToServer(new GT_Packet_UpdateItem(tag)); - } - - private static Pair> findConfiguratorInInv(EntityPlayer player) { - ItemStack[] mainInventory = player.inventory.mainInventory; - for (int j = 0, mainInventoryLength = mainInventory.length; j < mainInventoryLength; j++) { - ItemStack toolStack = mainInventory[j]; - - if (!GT_Utility.isStackValid(toolStack)) - continue; - - for (Map.Entry, BiFunction> p : GregTech_API.sCircuitProgrammerList.entrySet()) - if (p.getKey().test(toolStack)) - return Pair.of(j, p.getValue()); - } - return null; - } + return super.getUnlocalizedName(); + } + + @Override + public boolean receive(ItemStack stack, EntityPlayerMP player, NBTTagCompound tag) { + int meta = tag.hasKey("meta", Constants.NBT.TAG_BYTE) ? tag.getByte("meta") : -1; + if (meta < 0 || meta > 24) return true; + + if (!player.capabilities.isCreativeMode) { + Pair> toolIndex = findConfiguratorInInv(player); + if (toolIndex == null) return true; + + ItemStack[] mainInventory = player.inventory.mainInventory; + mainInventory[toolIndex.getKey()] = toolIndex.getValue().apply(mainInventory[toolIndex.getKey()], player); + } + stack.setItemDamage(meta); + + return true; + } + + @Override + public boolean onItemUse( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float xOffset, + float yOffset, + float zOffset) { + // nothing on server side or fake player + if (player instanceof FakePlayer || !world.isRemote) return false; + // check if any screwdriver + ItemStack configuratorStack; + if (player.capabilities.isCreativeMode) { + configuratorStack = null; + } else { + Pair configurator = findConfiguratorInInv(player); + if (configurator == null) { + int count; + try { + count = Integer.parseInt( + StatCollector.translateToLocal("GT5U.item.programmed_circuit.no_screwdriver.count")); + } catch (NumberFormatException e) { + player.addChatComponentMessage(new ChatComponentText( + "Error in translation GT5U.item.programmed_circuit.no_screwdriver.count: " + + e.getMessage())); + count = 1; + } + player.addChatComponentMessage(new ChatComponentTranslation( + "GT5U.item.programmed_circuit.no_screwdriver." + XSTR.XSTR_INSTANCE.nextInt(count))); + return false; + } + configuratorStack = player.inventory.mainInventory[configurator.getKey()]; + } + openSelectorGui(configuratorStack, stack.getItemDamage()); + return true; + } + + private void openSelectorGui(ItemStack configurator, int meta) { + FMLCommonHandler.instance() + .showGuiScreen(new GT_GUIDialogSelectItem( + StatCollector.translateToLocal("GT5U.item.programmed_circuit.select.header"), + configurator, + null, + ItemAdvancedChip::onConfigured, + ALL_VARIANTS, + meta, + true)); + } + + private static void onConfigured(ItemStack stack) { + NBTTagCompound tag = new NBTTagCompound(); + tag.setByte("meta", (byte) stack.getItemDamage()); + GT_Values.NW.sendToServer(new GT_Packet_UpdateItem(tag)); + } + + private static Pair> findConfiguratorInInv( + EntityPlayer player) { + ItemStack[] mainInventory = player.inventory.mainInventory; + for (int j = 0, mainInventoryLength = mainInventory.length; j < mainInventoryLength; j++) { + ItemStack toolStack = mainInventory[j]; + + if (!GT_Utility.isStackValid(toolStack)) continue; + + for (Map.Entry, BiFunction> p : + GregTech_API.sCircuitProgrammerList.entrySet()) + if (p.getKey().test(toolStack)) return Pair.of(j, p.getValue()); + } + return null; + } } diff --git a/src/main/java/gtPlusPlus/core/item/crafting/ItemDummyResearch.java b/src/main/java/gtPlusPlus/core/item/crafting/ItemDummyResearch.java index b7bf8a7c8e..ddd3ab1542 100644 --- a/src/main/java/gtPlusPlus/core/item/crafting/ItemDummyResearch.java +++ b/src/main/java/gtPlusPlus/core/item/crafting/ItemDummyResearch.java @@ -1,8 +1,5 @@ package gtPlusPlus.core.item.crafting; -import java.util.LinkedHashMap; -import java.util.Map; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.core.item.ModItems; @@ -10,106 +7,82 @@ import gtPlusPlus.core.item.general.ItemGenericToken; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import java.util.LinkedHashMap; +import java.util.Map; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; public class ItemDummyResearch extends ItemGenericToken { - - public static enum ASSEMBLY_LINE_RESEARCH { - - - RESEARCH_1_CONTAINMENT("Containment Fields", "Advanced scientific study"), - RESEARCH_2_BASIC_CHEM("Basic Chemistry", "Time to start at the beginning"), - RESEARCH_3_ADV_CHEM("Advanced Chemistry", "Best learn more than chemical equations"), - RESEARCH_4_BASIC_PHYSICS("Basic Physics", "Fundamental laws of motion"), - RESEARCH_5_ADV_PHYSICS("Advanced Physics", "Advanced knowledge!"), - RESEARCH_6_BASIC_METALLURGY("Basic Metallurgy", "Information about material smelting"), - RESEARCH_7_ADV_METALLURGY("Advanced Metallurgy", "Advanced Material Sciences!"), - RESEARCH_8_TURBINE_AUTOMATION("Turbine Automation", "You really don't want to share this with anyone!"), - RESEARCH_9_CLOAKING("Cloaking Technologies", "Sneaking around like a mouse"), - RESEARCH_10_SPARGING("Gas Sparging", "Blowing gas for results"), - RESEARCH_11_MOLECULAR_TRANSFORMER("Molecular Transformation", "Turning things into something better"); - - - - - - - - - - - - - - - - - - - private String mName; - private String mDesc; - - private ASSEMBLY_LINE_RESEARCH(String aName, String aDesc) { - mName = aName; - mDesc = aDesc; - ModItems.itemDummyResearch.register(mName, mDesc); - } - - } - - - - - - - - - - - private static Map mInternalNameToIdMap = new LinkedHashMap(); - - public static ItemStack getResearchStack(ASSEMBLY_LINE_RESEARCH aResearchName, int aStacksize) { - Integer aMeta = mInternalNameToIdMap.get(Utils.sanitizeString(aResearchName.mName)); - if (aMeta == null) { - aMeta = 0; - } - return ItemUtils.simpleMetaStack(ModItems.itemDummyResearch, aMeta, aStacksize); - } - - private int aID = 0; - public ItemDummyResearch() { - super("dummyResearch", "Research", new String[] {"This object requires some further study"}, "research"); - - - } - - /** - * - * @param aResearchType - What is the research for? - * @param aDescriptThe - tooltip for this research - * @return - Did we register a custom research item? - */ - public boolean register(String aResearchType, String aDescript) { - int aNewID = aID++; - mInternalNameToIdMap.put(Utils.sanitizeString(aResearchType), aNewID); - return register(aNewID, "Research on "+aResearchType, 1, aDescript); - } - - @Override - public boolean register(int id, String aLocalName, int aMaxStack, String aDescript) { - return register(id, aLocalName, 1, new String[] {aDescript, EnumChatFormatting.DARK_GRAY+"Used to further your knowledge"}, EnumRarity.common, EnumChatFormatting.LIGHT_PURPLE); - } - - @Override - @SideOnly(Side.CLIENT) - public final void registerIcons(final IIconRegister aIconRegister) { - for (int i = 0, j = mLocalNames.size(); i < j; i++) { - mIcons.put(i, aIconRegister.registerIcon(CORE.MODID + ":" + "research" + "/" + "note")); - } - } - + public static enum ASSEMBLY_LINE_RESEARCH { + RESEARCH_1_CONTAINMENT("Containment Fields", "Advanced scientific study"), + RESEARCH_2_BASIC_CHEM("Basic Chemistry", "Time to start at the beginning"), + RESEARCH_3_ADV_CHEM("Advanced Chemistry", "Best learn more than chemical equations"), + RESEARCH_4_BASIC_PHYSICS("Basic Physics", "Fundamental laws of motion"), + RESEARCH_5_ADV_PHYSICS("Advanced Physics", "Advanced knowledge!"), + RESEARCH_6_BASIC_METALLURGY("Basic Metallurgy", "Information about material smelting"), + RESEARCH_7_ADV_METALLURGY("Advanced Metallurgy", "Advanced Material Sciences!"), + RESEARCH_8_TURBINE_AUTOMATION("Turbine Automation", "You really don't want to share this with anyone!"), + RESEARCH_9_CLOAKING("Cloaking Technologies", "Sneaking around like a mouse"), + RESEARCH_10_SPARGING("Gas Sparging", "Blowing gas for results"), + RESEARCH_11_MOLECULAR_TRANSFORMER("Molecular Transformation", "Turning things into something better"); + + private String mName; + private String mDesc; + + private ASSEMBLY_LINE_RESEARCH(String aName, String aDesc) { + mName = aName; + mDesc = aDesc; + ModItems.itemDummyResearch.register(mName, mDesc); + } + } + + private static Map mInternalNameToIdMap = new LinkedHashMap(); + + public static ItemStack getResearchStack(ASSEMBLY_LINE_RESEARCH aResearchName, int aStacksize) { + Integer aMeta = mInternalNameToIdMap.get(Utils.sanitizeString(aResearchName.mName)); + if (aMeta == null) { + aMeta = 0; + } + return ItemUtils.simpleMetaStack(ModItems.itemDummyResearch, aMeta, aStacksize); + } + + private int aID = 0; + + public ItemDummyResearch() { + super("dummyResearch", "Research", new String[] {"This object requires some further study"}, "research"); + } + + /** + * + * @param aResearchType - What is the research for? + * @param aDescriptThe - tooltip for this research + * @return - Did we register a custom research item? + */ + public boolean register(String aResearchType, String aDescript) { + int aNewID = aID++; + mInternalNameToIdMap.put(Utils.sanitizeString(aResearchType), aNewID); + return register(aNewID, "Research on " + aResearchType, 1, aDescript); + } + + @Override + public boolean register(int id, String aLocalName, int aMaxStack, String aDescript) { + return register( + id, + aLocalName, + 1, + new String[] {aDescript, EnumChatFormatting.DARK_GRAY + "Used to further your knowledge"}, + EnumRarity.common, + EnumChatFormatting.LIGHT_PURPLE); + } + + @Override + @SideOnly(Side.CLIENT) + public final void registerIcons(final IIconRegister aIconRegister) { + for (int i = 0, j = mLocalNames.size(); i < j; i++) { + mIcons.put(i, aIconRegister.registerIcon(CORE.MODID + ":" + "research" + "/" + "note")); + } + } } diff --git a/src/main/java/gtPlusPlus/core/item/effects/RarityEffect.java b/src/main/java/gtPlusPlus/core/item/effects/RarityEffect.java index 7cfd64a2e7..310a940090 100644 --- a/src/main/java/gtPlusPlus/core/item/effects/RarityEffect.java +++ b/src/main/java/gtPlusPlus/core/item/effects/RarityEffect.java @@ -2,7 +2,6 @@ package gtPlusPlus.core.item.effects; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; @@ -23,20 +22,19 @@ Side.SERVER marks the method as existing only on the server side. public class RarityEffect extends Item { - public RarityEffect(final int par1){ - super(); - this.setCreativeTab(CreativeTabs.tabMaterials); - } - - @Override - @SideOnly(Side.CLIENT) - public EnumRarity getRarity(final ItemStack par1ItemStack){ - return EnumRarity.common; - } - - @Override - public boolean hasEffect(final ItemStack par1ItemStack){ - return true; - } - + public RarityEffect(final int par1) { + super(); + this.setCreativeTab(CreativeTabs.tabMaterials); + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(final ItemStack par1ItemStack) { + return EnumRarity.common; + } + + @Override + public boolean hasEffect(final ItemStack par1ItemStack) { + return true; + } } diff --git a/src/main/java/gtPlusPlus/core/item/effects/RarityEpic.java b/src/main/java/gtPlusPlus/core/item/effects/RarityEpic.java index 74ee5ab12c..a1234d6885 100644 --- a/src/main/java/gtPlusPlus/core/item/effects/RarityEpic.java +++ b/src/main/java/gtPlusPlus/core/item/effects/RarityEpic.java @@ -2,7 +2,6 @@ package gtPlusPlus.core.item.effects; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; @@ -10,20 +9,19 @@ import net.minecraft.item.ItemStack; public class RarityEpic extends Item { - public RarityEpic(final int par1){ - super(); - this.setCreativeTab(CreativeTabs.tabMaterials); - } - - @Override - @SideOnly(Side.CLIENT) - public EnumRarity getRarity(final ItemStack par1ItemStack){ - return EnumRarity.epic; - } + public RarityEpic(final int par1) { + super(); + this.setCreativeTab(CreativeTabs.tabMaterials); + } - @Override - public boolean hasEffect(final ItemStack par1ItemStack){ - return true; - } + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(final ItemStack par1ItemStack) { + return EnumRarity.epic; + } + @Override + public boolean hasEffect(final ItemStack par1ItemStack) { + return true; + } } diff --git a/src/main/java/gtPlusPlus/core/item/effects/RarityRare.java b/src/main/java/gtPlusPlus/core/item/effects/RarityRare.java index 60d5a681b9..fc1fabea14 100644 --- a/src/main/java/gtPlusPlus/core/item/effects/RarityRare.java +++ b/src/main/java/gtPlusPlus/core/item/effects/RarityRare.java @@ -2,7 +2,6 @@ package gtPlusPlus.core.item.effects; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; @@ -10,20 +9,19 @@ import net.minecraft.item.ItemStack; public class RarityRare extends Item { - public RarityRare(){ - super(); - this.setCreativeTab(CreativeTabs.tabMaterials); - } - - @Override - @SideOnly(Side.CLIENT) - public EnumRarity getRarity(final ItemStack par1ItemStack){ - return EnumRarity.rare; - } + public RarityRare() { + super(); + this.setCreativeTab(CreativeTabs.tabMaterials); + } - @Override - public boolean hasEffect(final ItemStack par1ItemStack){ - return true; - } + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(final ItemStack par1ItemStack) { + return EnumRarity.rare; + } + @Override + public boolean hasEffect(final ItemStack par1ItemStack) { + return true; + } } diff --git a/src/main/java/gtPlusPlus/core/item/effects/RarityUncommon.java b/src/main/java/gtPlusPlus/core/item/effects/RarityUncommon.java index 1ce8eec5d8..f16a6693c6 100644 --- a/src/main/java/gtPlusPlus/core/item/effects/RarityUncommon.java +++ b/src/main/java/gtPlusPlus/core/item/effects/RarityUncommon.java @@ -2,22 +2,20 @@ package gtPlusPlus.core.item.effects; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; public class RarityUncommon extends Item { - @Override - @SideOnly(Side.CLIENT) - public EnumRarity getRarity(final ItemStack par1ItemStack){ - return EnumRarity.uncommon; - } - - @Override - public boolean hasEffect(final ItemStack par1ItemStack){ - return true; - } + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(final ItemStack par1ItemStack) { + return EnumRarity.uncommon; + } + @Override + public boolean hasEffect(final ItemStack par1ItemStack) { + return true; + } } diff --git a/src/main/java/gtPlusPlus/core/item/food/BaseItemMetaFood.java b/src/main/java/gtPlusPlus/core/item/food/BaseItemMetaFood.java index 94d5a8e80f..1a4be0d8e9 100644 --- a/src/main/java/gtPlusPlus/core/item/food/BaseItemMetaFood.java +++ b/src/main/java/gtPlusPlus/core/item/food/BaseItemMetaFood.java @@ -1,9 +1,5 @@ package gtPlusPlus.core.item.food; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - import cpw.mods.fml.common.registry.GameRegistry; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.creative.AddToCreativeTab; @@ -12,6 +8,9 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.EntityUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; @@ -27,405 +26,522 @@ import net.minecraft.world.World; public class BaseItemMetaFood extends ItemFood { - private static final HashMap mIconMap = new HashMap(); - private static int mTotalMetaItems = 0; - - /* - * 0 - Raw Human Meat - * 1 - Cooked Human Meat - * 2 - Raw Horse Meat - * 3 - Cooked Horse Meat - * 4 - Raw Wolf Meat - * 5 - Cooked Wolf Meat - * 6 - Raw Ocelot Meat - * 7 - Cooked Ocelot Meat - * 8 - Blaze Flesh - */ - - //listAllmeatraw - //listAllmeatcooked - - public static void registerMetaFoods() { - registerNewMetaFood(0, "I wouldn't eat this unless I was starving", 2, 0, 64, getPotionEffectPackage(new EffectWeaknessModerate(80), new EffectSlownessModerate(80)), getOreDictNamesAsArrayList("listAllmeatraw")); - registerNewMetaFood(1, "Doesn't look any better cooked", 4, 1, 64, getPotionEffectPackage(new EffectWeaknessBasic(50), new EffectSlownessBasic(50)), getOreDictNamesAsArrayList("listAllmeatcooked")); - registerNewMetaFood(2, "", 2, 0, 64, getPotionEffectPackage(new EffectWeaknessBasic(30), new EffectSlownessBasic(30)), getOreDictNamesAsArrayList("listAllmeatraw")); - registerNewMetaFood(3, "", 4, 1, 64, getOreDictNamesAsArrayList("listAllmeatcooked")); - registerNewMetaFood(4, "", 2, 0, 64, getPotionEffectPackage(new EffectWeaknessBasic(25), new EffectSlownessBasic(30)), getOreDictNamesAsArrayList("listAllmeatraw")); - registerNewMetaFood(5, "", 4, 1, 64, getOreDictNamesAsArrayList("listAllmeatcooked")); - registerNewMetaFood(6, "", 2, 0, 64, getPotionEffectPackage(new EffectWeaknessBasic(30), new EffectSlownessBasic(25)), getOreDictNamesAsArrayList("listAllmeatraw")); - registerNewMetaFood(7, "", 4, 1, 64, getOreDictNamesAsArrayList("listAllmeatcooked")); - registerNewMetaFood(8, "Warm to the touch", EnumRarity.uncommon, 4, 1, 64, new AutoMap(), new setOnFire(), getOreDictNamesAsArrayList("listAllmeatcooked")); - } - - private static final HashMap mMaxStackSizeMap = new HashMap(); - private static final HashMap mTooltipMap = new HashMap(); - private static final HashMap mRarityMap = new HashMap(); - private static final HashMap mHealAmountMap = new HashMap(); - private static final HashMap mSaturationAmountMap = new HashMap(); - private static final HashMap> mPotionEffectsMap = new HashMap>(); - private static final HashMap mHasSpecialBehaviourMap = new HashMap(); - private static final HashMap mSpecialBehaviourMap = new HashMap(); - private static final HashMap> mOreDictNames = new HashMap>(); - - - public static void registerNewMetaFood(final int aMetaID, String aTooltip, final int aHealAmount, final float aSaturationModifier, final int aMaxStacksize) { - registerNewMetaFood(aMetaID, aTooltip, EnumRarity.common, aHealAmount, aSaturationModifier, aMaxStacksize, new AutoMap(), null, new ArrayList()); - } - - public static void registerNewMetaFood(final int aMetaID, String aTooltip, final int aHealAmount, final float aSaturationModifier, final int aMaxStacksize, final ArrayList aOreDictNames) { - registerNewMetaFood(aMetaID, aTooltip, EnumRarity.common, aHealAmount, aSaturationModifier, aMaxStacksize, new AutoMap(), null, aOreDictNames); - } - - - public static void registerNewMetaFood(final int aMetaID, String aTooltip, final int aHealAmount, final float aSaturationModifier, final int aMaxStacksize, final AutoMap aPotionEffects) { - registerNewMetaFood(aMetaID, aTooltip, EnumRarity.common, aHealAmount, aSaturationModifier, aMaxStacksize, new AutoMap(), null, new ArrayList()); - } - - public static void registerNewMetaFood(final int aMetaID, String aTooltip, final int aHealAmount, final float aSaturationModifier, final int aMaxStacksize, final AutoMap aPotionEffects, final ArrayList aOreDictNames) { - registerNewMetaFood(aMetaID, aTooltip, EnumRarity.common, aHealAmount, aSaturationModifier, aMaxStacksize, aPotionEffects, null, aOreDictNames); - } - - public static void registerNewMetaFood(final int aMetaID, String aTooltip, EnumRarity aRarity, final int aHealAmount, final float aSaturationModifier, final int aMaxStacksize, final AutoMap aPotionEffects, final SpecialFoodBehaviour aSpecialBehaviour) { - registerNewMetaFood(aMetaID, aTooltip, EnumRarity.common, aHealAmount, aSaturationModifier, aMaxStacksize, aPotionEffects, null, new ArrayList()); - } - - public static void registerNewMetaFood(final int aMetaID, String aTooltip, EnumRarity aRarity, final int aHealAmount, final float aSaturationModifier, final int aMaxStacksize, final AutoMap aPotionEffects, final SpecialFoodBehaviour aSpecialBehaviour, final ArrayList aOreDictNames) { - mTotalMetaItems++; - mMaxStackSizeMap.put(aMetaID, aMaxStacksize); - mTooltipMap.put(aMetaID, aTooltip); - mRarityMap.put(aMetaID, aRarity); - mHealAmountMap.put(aMetaID, aHealAmount); - mSaturationAmountMap.put(aMetaID, aSaturationModifier); - mPotionEffectsMap.put(aMetaID, aPotionEffects); - mHasSpecialBehaviourMap.put(aMetaID, (aSpecialBehaviour != null)); - if (aSpecialBehaviour != null) { - mSpecialBehaviourMap.put(aMetaID, aSpecialBehaviour); - } - mOreDictNames.put(aMetaID, aOreDictNames); - } - - public static void registerFoodsToOreDict() { - for (int aMetaID=0; aMetaID < mTotalMetaItems; aMetaID++) { - ArrayList aOreDictNames = mOreDictNames.get(aMetaID); - if (aOreDictNames != null && !aOreDictNames.isEmpty()) { - ItemStack aFoodStack = ItemUtils.simpleMetaStack(ModItems.itemMetaFood, aMetaID, 1); - for (String aOreName : aOreDictNames) { - ItemUtils.addItemToOreDictionary(aFoodStack, aOreName); - } - } - } - } - - - public BaseItemMetaFood() { - super(0, 0, false); - this.setHasSubtypes(true); - this.setNoRepair(); - this.setMaxStackSize(64); - this.setMaxDamage(0); - this.setUnlocalizedName("BasicMetaFood"); - this.setCreativeTab(AddToCreativeTab.tabMisc); - GameRegistry.registerItem(this, this.getUnlocalizedName()); - BaseItemMetaFood.registerMetaFoods(); - } - - private static final int getMetaKey(ItemStack aStack) { - return aStack.getItemDamage(); - } - - // Heal Amount - public int func_150905_g(ItemStack aStack) { - return mHealAmountMap.get(getMetaKey(aStack)); - } - - // Saturation Amount - public float func_150906_h(ItemStack aStack) { - return mSaturationAmountMap.get(getMetaKey(aStack)); - } - - // Whether wolves like this food, sadly doesn't support meta items - public boolean isWolfsFavoriteMeat() { - return false; - } - - @Override - protected void onFoodEaten(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { - //super.onFoodEaten(stack, world, player); - AutoMap aPotionEffects = mPotionEffectsMap.get(getMetaKey(aStack)); - if (!aWorld.isRemote && aPotionEffects != null && aPotionEffects.size() > 0) { - for (PotionEffectPackage aFoodEffect : aPotionEffects) { - if (MathUtils.randInt(0, 100) <= aFoodEffect.getChance() || aFoodEffect.getChance() == 100) { - PotionEffect aEffect = aFoodEffect.getEffect(); - if (aEffect != null && aEffect.getPotionID() > 0) { - aPlayer.addPotionEffect(new PotionEffect(aEffect.getPotionID(), aEffect.getDuration() * 20, aEffect.getAmplifier(), aEffect.getIsAmbient())); - } - } - } - } - - boolean aHasEpcialBehaviour = mHasSpecialBehaviourMap.get(getMetaKey(aStack)); - if (!aWorld.isRemote && aHasEpcialBehaviour) { - SpecialFoodBehaviour aBehaviour = mSpecialBehaviourMap.get(getMetaKey(aStack)); - if (aBehaviour != null) { - aBehaviour.doBehaviour(aPlayer); - } - } - } - - @Override - public ItemStack onEaten(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { - return super.onEaten(aStack, aWorld, aPlayer); - } - - - @Override - public int getItemStackLimit(ItemStack aStack) { - return mMaxStackSizeMap.get(getMetaKey(aStack)); - } - - - @Override - public boolean isDamageable() { - return false; - } - - @Override - public boolean shouldRotateAroundWhenRendering() { - return super.shouldRotateAroundWhenRendering(); - } - - @Override - public void onUpdate(ItemStack p_77663_1_, World p_77663_2_, Entity p_77663_3_, int p_77663_4_, boolean p_77663_5_) { - super.onUpdate(p_77663_1_, p_77663_2_, p_77663_3_, p_77663_4_, p_77663_5_); - } - - @Override - public String getItemStackDisplayName(ItemStack aStack) { - return super.getItemStackDisplayName(aStack); - } - - @Override - public void addInformation(ItemStack aStack, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { - try { - String aTooltip = mTooltipMap.get(getMetaKey(aStack)); - if (aTooltip != null && aTooltip.length() > 0) { - aList.add(aTooltip); - } - } - catch (Throwable t) { - t.printStackTrace(); - } - super.addInformation(aStack, p_77624_2_, aList, p_77624_4_); - } - - @Override - public EnumRarity getRarity(ItemStack aStack) { - return mRarityMap.get(getMetaKey(aStack)); - } - - @Override - public boolean requiresMultipleRenderPasses() { - return false; - } - - @Override - public void getSubItems(Item aItem, CreativeTabs p_150895_2_, List aList) { - for (int i=0;i getPotionEffectPackage(PotionEffectPackage... aEffects){ - AutoMap aPackage = new AutoMap(); - if (aEffects != null && aEffects.length > 0) { - for (PotionEffectPackage aEffect : aEffects) { - aPackage.put(aEffect); - } - } - return aPackage; - } - - private static ArrayList getOreDictNamesAsArrayList(String... aOreDictNames){ - ArrayList aPackage = new ArrayList(); - if (aOreDictNames != null && aOreDictNames.length > 0) { - for (String aEffect : aOreDictNames) { - aPackage.add(aEffect); - } - } - return aPackage; - } - - private static class EffectWeaknessBasic extends PotionEffectPackage { - - protected EffectWeaknessBasic(int aChance) { - super(new PotionEffect(Potion.weakness.getId(), 1, 20), aChance); - } - - } - - private static class EffectWeaknessModerate extends PotionEffectPackage { - - protected EffectWeaknessModerate(int aChance) { - super(new PotionEffect(Potion.weakness.getId(), 2, 40), aChance); - } - - } - - private static class EffectWeaknessSevere extends PotionEffectPackage { - - protected EffectWeaknessSevere(int aChance) { - super(new PotionEffect(Potion.weakness.getId(), 3, 60), aChance); - } - - } - - private static class EffectSlownessBasic extends PotionEffectPackage { - - protected EffectSlownessBasic(int aChance) { - super(new PotionEffect(Potion.moveSlowdown.getId(), 1, 20), aChance); - } - - } - - private static class EffectSlownessModerate extends PotionEffectPackage { - - protected EffectSlownessModerate(int aChance) { - super(new PotionEffect(Potion.moveSlowdown.getId(), 2, 40), aChance); - } - - } - - private static class EffectSlownessSevere extends PotionEffectPackage { - - protected EffectSlownessSevere(int aChance) { - super(new PotionEffect(Potion.moveSlowdown.getId(), 3, 60), aChance); - } - - } - - - - - private static abstract class SpecialFoodBehaviour { - - protected final int mChance; - - public SpecialFoodBehaviour(int aChance) { - mChance = aChance; - } - - public final void doBehaviour(EntityPlayer aPlayer) { - if (aPlayer != null && !aPlayer.worldObj.isRemote) { - if (MathUtils.randInt(0, 100) < mChance || mChance == 100) { - behaviour(aPlayer); - } - } - } - - protected abstract void behaviour(EntityPlayer aPlayer); - - } - - - private static class setOnFire extends SpecialFoodBehaviour { - - public setOnFire() { - super(100); - } - - @Override - public void behaviour(EntityPlayer aPlayer) { - EntityUtils.setEntityOnFire(aPlayer, 5); - } - - } - -} \ No newline at end of file + private static final HashMap mIconMap = new HashMap(); + private static int mTotalMetaItems = 0; + + /* + * 0 - Raw Human Meat + * 1 - Cooked Human Meat + * 2 - Raw Horse Meat + * 3 - Cooked Horse Meat + * 4 - Raw Wolf Meat + * 5 - Cooked Wolf Meat + * 6 - Raw Ocelot Meat + * 7 - Cooked Ocelot Meat + * 8 - Blaze Flesh + */ + + // listAllmeatraw + // listAllmeatcooked + + public static void registerMetaFoods() { + registerNewMetaFood( + 0, + "I wouldn't eat this unless I was starving", + 2, + 0, + 64, + getPotionEffectPackage(new EffectWeaknessModerate(80), new EffectSlownessModerate(80)), + getOreDictNamesAsArrayList("listAllmeatraw")); + registerNewMetaFood( + 1, + "Doesn't look any better cooked", + 4, + 1, + 64, + getPotionEffectPackage(new EffectWeaknessBasic(50), new EffectSlownessBasic(50)), + getOreDictNamesAsArrayList("listAllmeatcooked")); + registerNewMetaFood( + 2, + "", + 2, + 0, + 64, + getPotionEffectPackage(new EffectWeaknessBasic(30), new EffectSlownessBasic(30)), + getOreDictNamesAsArrayList("listAllmeatraw")); + registerNewMetaFood(3, "", 4, 1, 64, getOreDictNamesAsArrayList("listAllmeatcooked")); + registerNewMetaFood( + 4, + "", + 2, + 0, + 64, + getPotionEffectPackage(new EffectWeaknessBasic(25), new EffectSlownessBasic(30)), + getOreDictNamesAsArrayList("listAllmeatraw")); + registerNewMetaFood(5, "", 4, 1, 64, getOreDictNamesAsArrayList("listAllmeatcooked")); + registerNewMetaFood( + 6, + "", + 2, + 0, + 64, + getPotionEffectPackage(new EffectWeaknessBasic(30), new EffectSlownessBasic(25)), + getOreDictNamesAsArrayList("listAllmeatraw")); + registerNewMetaFood(7, "", 4, 1, 64, getOreDictNamesAsArrayList("listAllmeatcooked")); + registerNewMetaFood( + 8, + "Warm to the touch", + EnumRarity.uncommon, + 4, + 1, + 64, + new AutoMap(), + new setOnFire(), + getOreDictNamesAsArrayList("listAllmeatcooked")); + } + + private static final HashMap mMaxStackSizeMap = new HashMap(); + private static final HashMap mTooltipMap = new HashMap(); + private static final HashMap mRarityMap = new HashMap(); + private static final HashMap mHealAmountMap = new HashMap(); + private static final HashMap mSaturationAmountMap = new HashMap(); + private static final HashMap> mPotionEffectsMap = + new HashMap>(); + private static final HashMap mHasSpecialBehaviourMap = new HashMap(); + private static final HashMap mSpecialBehaviourMap = + new HashMap(); + private static final HashMap> mOreDictNames = new HashMap>(); + + public static void registerNewMetaFood( + final int aMetaID, + String aTooltip, + final int aHealAmount, + final float aSaturationModifier, + final int aMaxStacksize) { + registerNewMetaFood( + aMetaID, + aTooltip, + EnumRarity.common, + aHealAmount, + aSaturationModifier, + aMaxStacksize, + new AutoMap(), + null, + new ArrayList()); + } + + public static void registerNewMetaFood( + final int aMetaID, + String aTooltip, + final int aHealAmount, + final float aSaturationModifier, + final int aMaxStacksize, + final ArrayList aOreDictNames) { + registerNewMetaFood( + aMetaID, + aTooltip, + EnumRarity.common, + aHealAmount, + aSaturationModifier, + aMaxStacksize, + new AutoMap(), + null, + aOreDictNames); + } + + public static void registerNewMetaFood( + final int aMetaID, + String aTooltip, + final int aHealAmount, + final float aSaturationModifier, + final int aMaxStacksize, + final AutoMap aPotionEffects) { + registerNewMetaFood( + aMetaID, + aTooltip, + EnumRarity.common, + aHealAmount, + aSaturationModifier, + aMaxStacksize, + new AutoMap(), + null, + new ArrayList()); + } + + public static void registerNewMetaFood( + final int aMetaID, + String aTooltip, + final int aHealAmount, + final float aSaturationModifier, + final int aMaxStacksize, + final AutoMap aPotionEffects, + final ArrayList aOreDictNames) { + registerNewMetaFood( + aMetaID, + aTooltip, + EnumRarity.common, + aHealAmount, + aSaturationModifier, + aMaxStacksize, + aPotionEffects, + null, + aOreDictNames); + } + + public static void registerNewMetaFood( + final int aMetaID, + String aTooltip, + EnumRarity aRarity, + final int aHealAmount, + final float aSaturationModifier, + final int aMaxStacksize, + final AutoMap aPotionEffects, + final SpecialFoodBehaviour aSpecialBehaviour) { + registerNewMetaFood( + aMetaID, + aTooltip, + EnumRarity.common, + aHealAmount, + aSaturationModifier, + aMaxStacksize, + aPotionEffects, + null, + new ArrayList()); + } + + public static void registerNewMetaFood( + final int aMetaID, + String aTooltip, + EnumRarity aRarity, + final int aHealAmount, + final float aSaturationModifier, + final int aMaxStacksize, + final AutoMap aPotionEffects, + final SpecialFoodBehaviour aSpecialBehaviour, + final ArrayList aOreDictNames) { + mTotalMetaItems++; + mMaxStackSizeMap.put(aMetaID, aMaxStacksize); + mTooltipMap.put(aMetaID, aTooltip); + mRarityMap.put(aMetaID, aRarity); + mHealAmountMap.put(aMetaID, aHealAmount); + mSaturationAmountMap.put(aMetaID, aSaturationModifier); + mPotionEffectsMap.put(aMetaID, aPotionEffects); + mHasSpecialBehaviourMap.put(aMetaID, (aSpecialBehaviour != null)); + if (aSpecialBehaviour != null) { + mSpecialBehaviourMap.put(aMetaID, aSpecialBehaviour); + } + mOreDictNames.put(aMetaID, aOreDictNames); + } + + public static void registerFoodsToOreDict() { + for (int aMetaID = 0; aMetaID < mTotalMetaItems; aMetaID++) { + ArrayList aOreDictNames = mOreDictNames.get(aMetaID); + if (aOreDictNames != null && !aOreDictNames.isEmpty()) { + ItemStack aFoodStack = ItemUtils.simpleMetaStack(ModItems.itemMetaFood, aMetaID, 1); + for (String aOreName : aOreDictNames) { + ItemUtils.addItemToOreDictionary(aFoodStack, aOreName); + } + } + } + } + + public BaseItemMetaFood() { + super(0, 0, false); + this.setHasSubtypes(true); + this.setNoRepair(); + this.setMaxStackSize(64); + this.setMaxDamage(0); + this.setUnlocalizedName("BasicMetaFood"); + this.setCreativeTab(AddToCreativeTab.tabMisc); + GameRegistry.registerItem(this, this.getUnlocalizedName()); + BaseItemMetaFood.registerMetaFoods(); + } + + private static final int getMetaKey(ItemStack aStack) { + return aStack.getItemDamage(); + } + + // Heal Amount + public int func_150905_g(ItemStack aStack) { + return mHealAmountMap.get(getMetaKey(aStack)); + } + + // Saturation Amount + public float func_150906_h(ItemStack aStack) { + return mSaturationAmountMap.get(getMetaKey(aStack)); + } + + // Whether wolves like this food, sadly doesn't support meta items + public boolean isWolfsFavoriteMeat() { + return false; + } + + @Override + protected void onFoodEaten(final ItemStack aStack, final World aWorld, final EntityPlayer aPlayer) { + // super.onFoodEaten(stack, world, player); + AutoMap aPotionEffects = mPotionEffectsMap.get(getMetaKey(aStack)); + if (!aWorld.isRemote && aPotionEffects != null && aPotionEffects.size() > 0) { + for (PotionEffectPackage aFoodEffect : aPotionEffects) { + if (MathUtils.randInt(0, 100) <= aFoodEffect.getChance() || aFoodEffect.getChance() == 100) { + PotionEffect aEffect = aFoodEffect.getEffect(); + if (aEffect != null && aEffect.getPotionID() > 0) { + aPlayer.addPotionEffect(new PotionEffect( + aEffect.getPotionID(), + aEffect.getDuration() * 20, + aEffect.getAmplifier(), + aEffect.getIsAmbient())); + } + } + } + } + + boolean aHasEpcialBehaviour = mHasSpecialBehaviourMap.get(getMetaKey(aStack)); + if (!aWorld.isRemote && aHasEpcialBehaviour) { + SpecialFoodBehaviour aBehaviour = mSpecialBehaviourMap.get(getMetaKey(aStack)); + if (aBehaviour != null) { + aBehaviour.doBehaviour(aPlayer); + } + } + } + + @Override + public ItemStack onEaten(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { + return super.onEaten(aStack, aWorld, aPlayer); + } + + @Override + public int getItemStackLimit(ItemStack aStack) { + return mMaxStackSizeMap.get(getMetaKey(aStack)); + } + + @Override + public boolean isDamageable() { + return false; + } + + @Override + public boolean shouldRotateAroundWhenRendering() { + return super.shouldRotateAroundWhenRendering(); + } + + @Override + public void onUpdate( + ItemStack p_77663_1_, World p_77663_2_, Entity p_77663_3_, int p_77663_4_, boolean p_77663_5_) { + super.onUpdate(p_77663_1_, p_77663_2_, p_77663_3_, p_77663_4_, p_77663_5_); + } + + @Override + public String getItemStackDisplayName(ItemStack aStack) { + return super.getItemStackDisplayName(aStack); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { + try { + String aTooltip = mTooltipMap.get(getMetaKey(aStack)); + if (aTooltip != null && aTooltip.length() > 0) { + aList.add(aTooltip); + } + } catch (Throwable t) { + t.printStackTrace(); + } + super.addInformation(aStack, p_77624_2_, aList, p_77624_4_); + } + + @Override + public EnumRarity getRarity(ItemStack aStack) { + return mRarityMap.get(getMetaKey(aStack)); + } + + @Override + public boolean requiresMultipleRenderPasses() { + return false; + } + + @Override + public void getSubItems(Item aItem, CreativeTabs p_150895_2_, List aList) { + for (int i = 0; i < mIconMap.size(); i++) { + aList.add(ItemUtils.simpleMetaStack(aItem, i, 1)); + } + } + + @Override + public boolean getIsRepairable(ItemStack p_82789_1_, ItemStack p_82789_2_) { + return false; + } + + @Override + public boolean isRepairable() { + return false; + } + + @Override + public boolean isBookEnchantable(ItemStack stack, ItemStack book) { + return false; + } + + @Override + public int getDisplayDamage(ItemStack stack) { + return stack.getItemDamage(); + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } + + @Override + public int getItemEnchantability() { + return 0; + } + + @Override + public int getItemEnchantability(ItemStack stack) { + return 0; + } + + @Override + public void registerIcons(final IIconRegister u) { + for (int i = 0; i < mTotalMetaItems; i++) { + String aPath = CORE.MODID + ":" + "food/MetaItem1/" + i; + mIconMap.put(i, u.registerIcon(aPath)); + } + } + + @Override + public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) { + return mIconMap.get(damage); + } + + @Override + public IIcon getIconFromDamage(int damage) { + return mIconMap.get(damage); + } + + @Override + public IIcon getIcon(ItemStack aStack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { + return mIconMap.get(getMetaKey(aStack)); + } + + @Override + public IIcon getIcon(ItemStack aStack, int pass) { + return mIconMap.get(getMetaKey(aStack)); + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return super.getUnlocalizedName() + "." + stack.getItemDamage(); + } + + private static class PotionEffectPackage { + + private final PotionEffect mEffect; + private final int mChance; + + private PotionEffectPackage(PotionEffect aEffect, int aChance) { + mEffect = aEffect; + mChance = aChance; + } + + public PotionEffect getEffect() { + return this.mEffect; + } + + public int getChance() { + return this.mChance; + } + } + + private static AutoMap getPotionEffectPackage(PotionEffectPackage... aEffects) { + AutoMap aPackage = new AutoMap(); + if (aEffects != null && aEffects.length > 0) { + for (PotionEffectPackage aEffect : aEffects) { + aPackage.put(aEffect); + } + } + return aPackage; + } + + private static ArrayList getOreDictNamesAsArrayList(String... aOreDictNames) { + ArrayList aPackage = new ArrayList(); + if (aOreDictNames != null && aOreDictNames.length > 0) { + for (String aEffect : aOreDictNames) { + aPackage.add(aEffect); + } + } + return aPackage; + } + + private static class EffectWeaknessBasic extends PotionEffectPackage { + + protected EffectWeaknessBasic(int aChance) { + super(new PotionEffect(Potion.weakness.getId(), 1, 20), aChance); + } + } + + private static class EffectWeaknessModerate extends PotionEffectPackage { + + protected EffectWeaknessModerate(int aChance) { + super(new PotionEffect(Potion.weakness.getId(), 2, 40), aChance); + } + } + + private static class EffectWeaknessSevere extends PotionEffectPackage { + + protected EffectWeaknessSevere(int aChance) { + super(new PotionEffect(Potion.weakness.getId(), 3, 60), aChance); + } + } + + private static class EffectSlownessBasic extends PotionEffectPackage { + + protected EffectSlownessBasic(int aChance) { + super(new PotionEffect(Potion.moveSlowdown.getId(), 1, 20), aChance); + } + } + + private static class EffectSlownessModerate extends PotionEffectPackage { + + protected EffectSlownessModerate(int aChance) { + super(new PotionEffect(Potion.moveSlowdown.getId(), 2, 40), aChance); + } + } + + private static class EffectSlownessSevere extends PotionEffectPackage { + + protected EffectSlownessSevere(int aChance) { + super(new PotionEffect(Potion.moveSlowdown.getId(), 3, 60), aChance); + } + } + + private abstract static class SpecialFoodBehaviour { + + protected final int mChance; + + public SpecialFoodBehaviour(int aChance) { + mChance = aChance; + } + + public final void doBehaviour(EntityPlayer aPlayer) { + if (aPlayer != null && !aPlayer.worldObj.isRemote) { + if (MathUtils.randInt(0, 100) < mChance || mChance == 100) { + behaviour(aPlayer); + } + } + } + + protected abstract void behaviour(EntityPlayer aPlayer); + } + + private static class setOnFire extends SpecialFoodBehaviour { + + public setOnFire() { + super(100); + } + + @Override + public void behaviour(EntityPlayer aPlayer) { + EntityUtils.setEntityOnFire(aPlayer, 5); + } + } +} diff --git a/src/main/java/gtPlusPlus/core/item/general/BaseItemGrindle.java b/src/main/java/gtPlusPlus/core/item/general/BaseItemGrindle.java index 0ff922d853..6eaa4b1588 100644 --- a/src/main/java/gtPlusPlus/core/item/general/BaseItemGrindle.java +++ b/src/main/java/gtPlusPlus/core/item/general/BaseItemGrindle.java @@ -1,11 +1,13 @@ package gtPlusPlus.core.item.general; -import java.util.List; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.GTplusplus; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.core.lib.CORE; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; @@ -13,72 +15,67 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import gtPlusPlus.GTplusplus; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.handler.GuiHandler; -import gtPlusPlus.core.lib.CORE; - public class BaseItemGrindle extends Item { - protected final String unlocalName; + protected final String unlocalName; - public BaseItemGrindle() { - this.unlocalName = "itemGrindleTablet"; - this.setUnlocalizedName("itemGrindleTablet"); - this.setTextureName(CORE.MODID + ":" + "itemTablet"); - GameRegistry.registerItem(this, "itemGrindleTablet"); - this.setMaxStackSize(1); - this.setCreativeTab(AddToCreativeTab.tabOther); - } + public BaseItemGrindle() { + this.unlocalName = "itemGrindleTablet"; + this.setUnlocalizedName("itemGrindleTablet"); + this.setTextureName(CORE.MODID + ":" + "itemTablet"); + GameRegistry.registerItem(this, "itemGrindleTablet"); + this.setMaxStackSize(1); + this.setCreativeTab(AddToCreativeTab.tabOther); + } - @Override - public int getMaxItemUseDuration(final ItemStack stack) { - return 1; - } + @Override + public int getMaxItemUseDuration(final ItemStack stack) { + return 1; + } - @Override - public ItemStack onItemRightClick(final ItemStack itemstack, final World world, final EntityPlayer player) { - if (!world.isRemote) { - if (!player.isSneaking()) { - player.openGui(GTplusplus.instance, GuiHandler.GUI9, world, 0, 0, 0); - } - } - return itemstack; - } + @Override + public ItemStack onItemRightClick(final ItemStack itemstack, final World world, final EntityPlayer player) { + if (!world.isRemote) { + if (!player.isSneaking()) { + player.openGui(GTplusplus.instance, GuiHandler.GUI9, world, 0, 0, 0); + } + } + return itemstack; + } - @Override - public String getItemStackDisplayName(final ItemStack aStack) { - String aName = super.getItemStackDisplayName(aStack); - if (aName.toLowerCase().contains(".name") || aName.toLowerCase().contains("git")) { - aName = "Grindle"; - } - return aName; - } + @Override + public String getItemStackDisplayName(final ItemStack aStack) { + String aName = super.getItemStackDisplayName(aStack); + if (aName.toLowerCase().contains(".name") || aName.toLowerCase().contains("git")) { + aName = "Grindle"; + } + return aName; + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(final IIconRegister iconRegister) { - this.itemIcon = iconRegister.registerIcon(CORE.MODID + ":" + "itemTablet"); - } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(final IIconRegister iconRegister) { + this.itemIcon = iconRegister.registerIcon(CORE.MODID + ":" + "itemTablet"); + } - @Override - public String getPotionEffect(ItemStack p_150896_1_) { - return super.getPotionEffect(p_150896_1_); - } + @Override + public String getPotionEffect(ItemStack p_150896_1_) { + return super.getPotionEffect(p_150896_1_); + } - @Override - public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { - super.addInformation(p_77624_1_, p_77624_2_, aList, p_77624_4_); - aList.add("Used to read data from DataSticks & DataOrbs."); - } + @Override + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { + super.addInformation(p_77624_1_, p_77624_2_, aList, p_77624_4_); + aList.add("Used to read data from DataSticks & DataOrbs."); + } - @Override - public EnumRarity getRarity(ItemStack i) { - return EnumRarity.uncommon; - } + @Override + public EnumRarity getRarity(ItemStack i) { + return EnumRarity.uncommon; + } - @Override - public boolean isRepairable() { - return false; - } + @Override + public boolean isRepairable() { + return false; + } } diff --git a/src/main/java/gtPlusPlus/core/item/general/BedLocator_Base.java b/src/main/java/gtPlusPlus/core/item/general/BedLocator_Base.java index 5aa2e4ae9e..a57f1ff63f 100644 --- a/src/main/java/gtPlusPlus/core/item/general/BedLocator_Base.java +++ b/src/main/java/gtPlusPlus/core/item/general/BedLocator_Base.java @@ -1,7 +1,8 @@ package gtPlusPlus.core.item.general; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; import java.util.List; - import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -10,98 +11,91 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; - -public class BedLocator_Base extends Item{ - - public int bed_X = 0; - public int bed_Y = 0; - public int bed_Z = 0; - - public BedLocator_Base(final String unlocalizedName) { - this.setUnlocalizedName(unlocalizedName); - this.setTextureName(CORE.MODID + ":" + unlocalizedName); - this.setMaxStackSize(1); - this.setCreativeTab(AddToCreativeTab.tabMachines); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - - - int NBT_X = this.bed_X; - int NBT_Y = this.bed_Y; - int NBT_Z = this.bed_Z; - - - if (stack.stackTagCompound != null) { - NBT_X = stack.stackTagCompound.getInteger("pos_x"); - NBT_Y = stack.stackTagCompound.getInteger("pos_y"); - NBT_Z = stack.stackTagCompound.getInteger("pos_z"); - - final String tempX = String.valueOf(NBT_X); - final String tempY = String.valueOf(NBT_Y); - final String tempZ = String.valueOf(NBT_Z); - final String formattedX = EnumChatFormatting.DARK_RED+tempX+EnumChatFormatting.GRAY; - final String formattedY = EnumChatFormatting.RED+tempY+EnumChatFormatting.GRAY; - final String formattedZ = EnumChatFormatting.RED+tempZ+EnumChatFormatting.GRAY; - - list.add(EnumChatFormatting.GRAY+"X: "+formattedX+"."); - list.add(EnumChatFormatting.GRAY+"Y: "+formattedY+"."); - list.add(EnumChatFormatting.GRAY+"Z: "+formattedZ+"."); - super.addInformation(stack, aPlayer, list, bool); - } - } - - //Ticking and NBT Handling - /* Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and - * update it's contents. - * - * public int fuelRemaining = 0; - public int maximumFuel = 0; - public String fuelType = ""; - public float heat = 0; - public float maxHeat = 5000; - * - */ - @Override - public void onCreated(final ItemStack itemStack, final World world, final EntityPlayer player) { - itemStack.stackTagCompound = new NBTTagCompound(); - this.bed_X = 0; - this.bed_Y = 0; - this.bed_Z = 0; - itemStack.stackTagCompound.setInteger("pos_x", this.bed_X); - itemStack.stackTagCompound.setInteger("pos_y", this.bed_Y); - itemStack.stackTagCompound.setInteger("pos_z", this.bed_Z); - } - - @Override - public void onUpdate(final ItemStack itemStack, final World par2World, final Entity par3Entity, final int par4, final boolean par5) { - - - } - - @Override - public ItemStack onItemRightClick(final ItemStack itemStack, final World world, final EntityPlayer par3Entity) { - itemStack.stackTagCompound = new NBTTagCompound(); - if (par3Entity.getBedLocation() != null){ - this.bed_X = par3Entity.getBedLocation().posX; - this.bed_Y = par3Entity.getBedLocation().posY; - this.bed_Z = par3Entity.getBedLocation().posZ; - } - else { - this.bed_X = 0; - this.bed_Y = 0; - this.bed_Z = 0; - } - itemStack.stackTagCompound.setInteger("pos_x", this.bed_X); - itemStack.stackTagCompound.setInteger("pos_y", this.bed_Y); - itemStack.stackTagCompound.setInteger("pos_z", this.bed_Z); - return super.onItemRightClick(itemStack, world, par3Entity); - } - - - +public class BedLocator_Base extends Item { + + public int bed_X = 0; + public int bed_Y = 0; + public int bed_Z = 0; + + public BedLocator_Base(final String unlocalizedName) { + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setMaxStackSize(1); + this.setCreativeTab(AddToCreativeTab.tabMachines); + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + + int NBT_X = this.bed_X; + int NBT_Y = this.bed_Y; + int NBT_Z = this.bed_Z; + + if (stack.stackTagCompound != null) { + NBT_X = stack.stackTagCompound.getInteger("pos_x"); + NBT_Y = stack.stackTagCompound.getInteger("pos_y"); + NBT_Z = stack.stackTagCompound.getInteger("pos_z"); + + final String tempX = String.valueOf(NBT_X); + final String tempY = String.valueOf(NBT_Y); + final String tempZ = String.valueOf(NBT_Z); + final String formattedX = EnumChatFormatting.DARK_RED + tempX + EnumChatFormatting.GRAY; + final String formattedY = EnumChatFormatting.RED + tempY + EnumChatFormatting.GRAY; + final String formattedZ = EnumChatFormatting.RED + tempZ + EnumChatFormatting.GRAY; + + list.add(EnumChatFormatting.GRAY + "X: " + formattedX + "."); + list.add(EnumChatFormatting.GRAY + "Y: " + formattedY + "."); + list.add(EnumChatFormatting.GRAY + "Z: " + formattedZ + "."); + super.addInformation(stack, aPlayer, list, bool); + } + } + + // Ticking and NBT Handling + /* Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and + * update it's contents. + * + * public int fuelRemaining = 0; + public int maximumFuel = 0; + public String fuelType = ""; + public float heat = 0; + public float maxHeat = 5000; + * + */ + @Override + public void onCreated(final ItemStack itemStack, final World world, final EntityPlayer player) { + itemStack.stackTagCompound = new NBTTagCompound(); + this.bed_X = 0; + this.bed_Y = 0; + this.bed_Z = 0; + itemStack.stackTagCompound.setInteger("pos_x", this.bed_X); + itemStack.stackTagCompound.setInteger("pos_y", this.bed_Y); + itemStack.stackTagCompound.setInteger("pos_z", this.bed_Z); + } + + @Override + public void onUpdate( + final ItemStack itemStack, + final World par2World, + final Entity par3Entity, + final int par4, + final boolean par5) {} + + @Override + public ItemStack onItemRightClick(final ItemStack itemStack, final World world, final EntityPlayer par3Entity) { + itemStack.stackTagCompound = new NBTTagCompound(); + if (par3Entity.getBedLocation() != null) { + this.bed_X = par3Entity.getBedLocation().posX; + this.bed_Y = par3Entity.getBedLocation().posY; + this.bed_Z = par3Entity.getBedLocation().posZ; + } else { + this.bed_X = 0; + this.bed_Y = 0; + this.bed_Z = 0; + } + itemStack.stackTagCompound.setInteger("pos_x", this.bed_X); + itemStack.stackTagCompound.setInteger("pos_y", this.bed_Y); + itemStack.stackTagCompound.setInteger("pos_z", this.bed_Z); + return super.onItemRightClick(itemStack, world, par3Entity); + } } diff --git a/src/main/java/gtPlusPlus/core/item/general/BufferCore.java b/src/main/java/gtPlusPlus/core/item/general/BufferCore.java index 9b00d3d034..a85c23be81 100644 --- a/src/main/java/gtPlusPlus/core/item/general/BufferCore.java +++ b/src/main/java/gtPlusPlus/core/item/general/BufferCore.java @@ -1,72 +1,70 @@ package gtPlusPlus.core.item.general; -import java.util.List; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.GT_Values; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; - import gtPlusPlus.core.item.base.BaseItemWithDamageValue; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; +import java.util.List; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; -public class BufferCore extends BaseItemWithDamageValue{ +public class BufferCore extends BaseItemWithDamageValue { - public int coreTier = 0; + public int coreTier = 0; - public BufferCore(final String unlocalizedName, final int i) { - super(unlocalizedName+i); - this.setTextureName(CORE.MODID + ":" + unlocalizedName); - this.setMaxStackSize(32); - this.coreTier = i; - } + public BufferCore(final String unlocalizedName, final int i) { + super(unlocalizedName + i); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setMaxStackSize(32); + this.coreTier = i; + } - @Override - public String getItemStackDisplayName(final ItemStack stack) { - return super.getItemStackDisplayName(stack)/*+" ["+GT_Values.VN[this.coreTier-1]+"]."*/; - } + @Override + public String getItemStackDisplayName(final ItemStack stack) { + return super.getItemStackDisplayName(stack) /*+" ["+GT_Values.VN[this.coreTier-1]+"]."*/; + } - @Override - @SideOnly(Side.CLIENT) - public boolean requiresMultipleRenderPasses() - { - return true; - } + @Override + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses() { + return true; + } - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - list.add(EnumChatFormatting.GRAY+"A key crafting component for "+GT_Values.VN[this.coreTier-1]+" Applicances"); - } + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add(EnumChatFormatting.GRAY + "A key crafting component for " + GT_Values.VN[this.coreTier - 1] + + " Applicances"); + } - public final int getCoreTier() { - return this.coreTier; - } + public final int getCoreTier() { + return this.coreTier; + } - @Override - public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { + @Override + public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { - int[] mTierTypes = new int[] { - Utils.rgbtoHexValue(200, 180, 180), - Utils.rgbtoHexValue(142, 153, 161), - Utils.rgbtoHexValue(230, 121, 75), - Utils.rgbtoHexValue(215, 156, 70), - Utils.rgbtoHexValue(97, 97, 96), //EV - Utils.rgbtoHexValue(202, 202, 201), - Utils.rgbtoHexValue(247, 159, 157), - Utils.rgbtoHexValue(181, 223, 223), - Utils.rgbtoHexValue(187, 219, 185), - }; - - if (this.coreTier == 10){ - return Utils.rgbtoHexValue(MathUtils.randInt(220, 250), MathUtils.randInt(221, 251), MathUtils.randInt(220, 250)); - } + int[] mTierTypes = new int[] { + Utils.rgbtoHexValue(200, 180, 180), + Utils.rgbtoHexValue(142, 153, 161), + Utils.rgbtoHexValue(230, 121, 75), + Utils.rgbtoHexValue(215, 156, 70), + Utils.rgbtoHexValue(97, 97, 96), // EV + Utils.rgbtoHexValue(202, 202, 201), + Utils.rgbtoHexValue(247, 159, 157), + Utils.rgbtoHexValue(181, 223, 223), + Utils.rgbtoHexValue(187, 219, 185), + }; - return mTierTypes[this.coreTier-1]; - } + if (this.coreTier == 10) { + return Utils.rgbtoHexValue( + MathUtils.randInt(220, 250), MathUtils.randInt(221, 251), MathUtils.randInt(220, 250)); + } + return mTierTypes[this.coreTier - 1]; + } } diff --git a/src/main/java/gtPlusPlus/core/item/general/ItemAirFilter.java b/src/main/java/gtPlusPlus/core/item/general/ItemAirFilter.java index a354e63fe3..98cb1bba74 100644 --- a/src/main/java/gtPlusPlus/core/item/general/ItemAirFilter.java +++ b/src/main/java/gtPlusPlus/core/item/general/ItemAirFilter.java @@ -1,8 +1,10 @@ package gtPlusPlus.core.item.general; -import java.util.List; import cpw.mods.fml.common.registry.GameRegistry; - +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -12,130 +14,123 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; - public class ItemAirFilter extends Item { - public IIcon[] icons = new IIcon[1]; - - public ItemAirFilter() { - super(); - this.setHasSubtypes(true); - String unlocalizedName = "itemAirFilter"; - this.setUnlocalizedName(unlocalizedName); - this.setCreativeTab(AddToCreativeTab.tabMisc); - this.setMaxStackSize(1); - GameRegistry.registerItem(this, unlocalizedName); - } - - @Override - public void registerIcons(IIconRegister reg) { - this.icons[0] = reg.registerIcon(CORE.MODID + ":" + "itemAirFilter"); - } - - @Override - public IIcon getIconFromDamage(int meta) { - return this.icons[0]; - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < 2; i ++) { - list.add(new ItemStack(item, 1, i)); - } - } - - @Override - public String getUnlocalizedName(ItemStack stack) { - return this.getUnlocalizedName() + "_" + stack.getItemDamage(); - } - - @Override - public String getItemStackDisplayName(final ItemStack tItem) { - - if (tItem == null) { - return "Air Filter"; - } - - String itemName = tItem == null ? "Air Filter" : super.getItemStackDisplayName(tItem); - String suffixName = ""; - if (tItem.getItemDamage() == 0){ - suffixName = " [Tier 1]"; - } - else if (tItem.getItemDamage() == 1){ - suffixName = " [Tier 2]"; - } - return (itemName+suffixName); - } - - @Override - public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { - int meta = stack.getItemDamage(); - if (meta == 1){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(150,180,35); - } - return HEX_OxFFFFFF; - } - - private static boolean createNBT(ItemStack rStack){ - final NBTTagCompound tagMain = new NBTTagCompound(); - final NBTTagCompound tagNBT = new NBTTagCompound(); - tagNBT.setLong("Damage", 0); - tagMain.setTag("AirFilter", tagNBT); - rStack.setTagCompound(tagMain); - return true; - } - - public static final long getFilterDamage(final ItemStack aStack) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("AirFilter"); - if (aNBT != null) { - return aNBT.getLong("Damage"); - } - } - else { - createNBT(aStack); - } - return 0L; - } - - public static final boolean setFilterDamage(final ItemStack aStack, final long aDamage) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("AirFilter"); - if (aNBT != null) { - aNBT.setLong("Damage", aDamage); - return true; - } - } - return false; - } - - @Override - public double getDurabilityForDisplay(ItemStack stack) { - if (stack.getTagCompound() == null){ - createNBT(stack); + public IIcon[] icons = new IIcon[1]; + + public ItemAirFilter() { + super(); + this.setHasSubtypes(true); + String unlocalizedName = "itemAirFilter"; + this.setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setMaxStackSize(1); + GameRegistry.registerItem(this, unlocalizedName); + } + + @Override + public void registerIcons(IIconRegister reg) { + this.icons[0] = reg.registerIcon(CORE.MODID + ":" + "itemAirFilter"); + } + + @Override + public IIcon getIconFromDamage(int meta) { + return this.icons[0]; + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 2; i++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return this.getUnlocalizedName() + "_" + stack.getItemDamage(); + } + + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + + if (tItem == null) { + return "Air Filter"; + } + + String itemName = tItem == null ? "Air Filter" : super.getItemStackDisplayName(tItem); + String suffixName = ""; + if (tItem.getItemDamage() == 0) { + suffixName = " [Tier 1]"; + } else if (tItem.getItemDamage() == 1) { + suffixName = " [Tier 2]"; + } + return (itemName + suffixName); + } + + @Override + public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { + int meta = stack.getItemDamage(); + if (meta == 1) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(150, 180, 35); + } + return HEX_OxFFFFFF; + } + + private static boolean createNBT(ItemStack rStack) { + final NBTTagCompound tagMain = new NBTTagCompound(); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setLong("Damage", 0); + tagMain.setTag("AirFilter", tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public static final long getFilterDamage(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("AirFilter"); + if (aNBT != null) { + return aNBT.getLong("Damage"); + } + } else { + createNBT(aStack); + } + return 0L; + } + + public static final boolean setFilterDamage(final ItemStack aStack, final long aDamage) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("AirFilter"); + if (aNBT != null) { + aNBT.setLong("Damage", aDamage); + return true; + } + } + return false; + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + if (stack.getTagCompound() == null) { + createNBT(stack); } - double currentDamage = getFilterDamage(stack); - double meta = stack.getItemDamage() == 0 ? 50 : 2500; - double durabilitypercent = currentDamage / meta; - return durabilitypercent; - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { - list.add(EnumChatFormatting.GRAY+"An Air filter for Atmospheric Reconditioning."); - int maxDamage = (stack.getItemDamage() == 0 ? 50 : 2500); - list.add(EnumChatFormatting.GRAY+""+(maxDamage-getFilterDamage(stack))+"/"+maxDamage+" uses left."); - super.addInformation(stack, player, list, bool); - } - - @Override - public boolean showDurabilityBar(ItemStack stack) { - return true; - } - -} \ No newline at end of file + double currentDamage = getFilterDamage(stack); + double meta = stack.getItemDamage() == 0 ? 50 : 2500; + double durabilitypercent = currentDamage / meta; + return durabilitypercent; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { + list.add(EnumChatFormatting.GRAY + "An Air filter for Atmospheric Reconditioning."); + int maxDamage = (stack.getItemDamage() == 0 ? 50 : 2500); + list.add(EnumChatFormatting.GRAY + "" + (maxDamage - getFilterDamage(stack)) + "/" + maxDamage + " uses left."); + super.addInformation(stack, player, list, bool); + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/general/ItemAreaClear.java b/src/main/java/gtPlusPlus/core/item/general/ItemAreaClear.java index 16d0c0253b..b4b35c06e8 100644 --- a/src/main/java/gtPlusPlus/core/item/general/ItemAreaClear.java +++ b/src/main/java/gtPlusPlus/core/item/general/ItemAreaClear.java @@ -1,9 +1,16 @@ package gtPlusPlus.core.item.general; -import java.util.List; - import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.common.blocks.GT_Block_Ores; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.block.base.BlockBaseOre; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.CoreItem; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.EntityUtils; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -16,188 +23,184 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; import net.minecraft.world.World; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.minecraft.BlockPos; -import gtPlusPlus.core.block.base.BlockBaseOre; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.item.base.CoreItem; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.EntityUtils; - public class ItemAreaClear extends CoreItem { - public IIcon[] mIcon = new IIcon[1]; - - public ItemAreaClear() { - super("itemDebugClearing", AddToCreativeTab.tabMachines, 1, 100, new String[] {EnumChatFormatting.OBFUSCATED+"F A N C Y N A M E"}, EnumRarity.rare, - EnumChatFormatting.BOLD, false, null); - } - - @Override - public void registerIcons(IIconRegister reg) { - this.mIcon[0] = reg.registerIcon(CORE.MODID + ":" + "itemLavaFilter"); - } - - @Override - public IIcon getIconFromDamage(int meta) { - return this.mIcon[0]; - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < 2; i ++) { - list.add(new ItemStack(item, 1, i)); - } - } - - @Override - public String getItemStackDisplayName(final ItemStack tItem) { - String itemName = "Debug Square"; - String suffixName = ""; - if (tItem.getItemDamage() == 0){ - suffixName = " [1]"; - } - else if (tItem.getItemDamage() == 1){ - suffixName = " [2]"; - } - return (itemName+suffixName); - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { - String mMode = (stack.getItemDamage() == 0 ? "Clear" : "Fill"); - list.add(EnumChatFormatting.GRAY+""+("Mode: "+mMode)); - super.addInformation(stack, player, list, bool); - } - - private static boolean createNBT(ItemStack rStack){ - final NBTTagCompound tagMain = new NBTTagCompound(); - final NBTTagCompound tagNBT = new NBTTagCompound(); - tagNBT.setLong("Mode", 0); - tagMain.setTag("GTPP_DEBUG", tagNBT); - rStack.setTagCompound(tagMain); - return true; - } - - public static final long getFilterDamage(final ItemStack aStack) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("GTPP_DEBUG"); - if (aNBT != null) { - return aNBT.getLong("Mode"); - } - } - else { - createNBT(aStack); - } - return 0L; - } - - public static final boolean setFilterDamage(final ItemStack aStack, final long aDamage) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("GTPP_DEBUG"); - if (aNBT != null) { - aNBT.setLong("Mode", aDamage); - return true; - } - } - return false; - } - - public boolean removeBlocks(World world, BlockPos pos){ - int x1 = pos.xPos; - int y1 = pos.yPos; - int z1 = pos.zPos; - - int x2 = (x1-24); - int y2 = (y1-10); - int z2 = (z1-24); - - removeBlockColumn(world, new BlockPos(x2, y2, z2, world)); - return true; - } - - public boolean removeBlockColumn(World world, BlockPos pos){ - for (int i=0; i<50; i++){ - removeBlockRow(world, new BlockPos(pos.xPos, pos.yPos-10, pos.zPos+i, world)); - removeBlockRow(world, new BlockPos(pos.xPos, pos.yPos, pos.zPos+i, world)); - removeBlockRow(world, new BlockPos(pos.xPos, pos.yPos+10, pos.zPos+i, world)); - } - return true; - } - - public boolean removeBlockRow(World world, BlockPos pos){ - for (int j=0; j<20; j++){ - for (int i=0; i<50; i++){ - - if (!(world.getBlock(pos.xPos+i, pos.yPos+j, pos.zPos) instanceof BlockBaseOre) && - !(world.getBlock(pos.xPos+i, pos.yPos+j, pos.zPos) instanceof IGregTechTileEntity) && - !(world.getBlock(pos.xPos+i, pos.yPos+j, pos.zPos) instanceof GT_Block_Ores)){ - if (!world.isAirBlock(pos.xPos+i, pos.yPos+j, pos.zPos) && - world.getBlock(pos.xPos+i, pos.yPos+j, pos.zPos) != Blocks.bedrock){ - int chance = MathUtils.randInt(0, 500); - if (chance <= 0){ - if (pos.yPos+j <= 50){ - world.setBlock(pos.xPos+i, pos.yPos+j, pos.zPos, Blocks.glowstone); - } - } - else { - if ((world.getBlock(pos.xPos+i, pos.yPos+j, pos.zPos) == Blocks.glowstone && ((pos.yPos+j) > 50)) || world.getBlock(pos.xPos+i, pos.yPos+j, pos.zPos) != Blocks.glowstone){ - world.setBlockToAir(pos.xPos+i, pos.yPos+j, pos.zPos); - } - } - } - } - } - } - return true; - } - - public boolean fillBlocks(World world, BlockPos pos){ - int x1 = pos.xPos; - int y1 = pos.yPos; - int z1 = pos.zPos; - - int x2 = (x1-15); - int y2 = (y1-1); - int z2 = (z1-15); - - fillBlockColumn(world, new BlockPos(x2, y2, z2, world)); - return true; - } - - public boolean fillBlockColumn(World world, BlockPos pos){ - for (int i=0; i<30; i++){ - fillBlockRow(world, new BlockPos(pos.xPos, pos.yPos, pos.zPos+i, world)); - } - return true; - } - - public boolean fillBlockRow(World world, BlockPos pos){ - for (int j=0; j<2; j++){ - for (int i=0; i<30; i++){ - if (world.getBlock(pos.xPos+i, pos.yPos+j, pos.zPos) != Blocks.bedrock){ - world.setBlock(pos.xPos+i, pos.yPos+j, pos.zPos, Blocks.dirt); - world.setBlockMetadataWithNotify(pos.xPos+i, pos.yPos+j, pos.zPos, 2, 2); - } - } - } - return true; - } - - @Override - public ItemStack onItemRightClick(ItemStack thisItem, World world, EntityPlayer parEntity) { - BlockPos groundBlock = EntityUtils.findBlockPosUnderEntity(parEntity); - if (thisItem.getItemDamage() == 0){ - removeBlocks(world, groundBlock); - } - else { - Logger.INFO("Filling."); - fillBlocks(world, groundBlock); - } - return super.onItemRightClick(thisItem, world, parEntity); - } - + public IIcon[] mIcon = new IIcon[1]; + + public ItemAreaClear() { + super( + "itemDebugClearing", + AddToCreativeTab.tabMachines, + 1, + 100, + new String[] {EnumChatFormatting.OBFUSCATED + "F A N C Y N A M E"}, + EnumRarity.rare, + EnumChatFormatting.BOLD, + false, + null); + } + + @Override + public void registerIcons(IIconRegister reg) { + this.mIcon[0] = reg.registerIcon(CORE.MODID + ":" + "itemLavaFilter"); + } + + @Override + public IIcon getIconFromDamage(int meta) { + return this.mIcon[0]; + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 2; i++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + String itemName = "Debug Square"; + String suffixName = ""; + if (tItem.getItemDamage() == 0) { + suffixName = " [1]"; + } else if (tItem.getItemDamage() == 1) { + suffixName = " [2]"; + } + return (itemName + suffixName); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { + String mMode = (stack.getItemDamage() == 0 ? "Clear" : "Fill"); + list.add(EnumChatFormatting.GRAY + "" + ("Mode: " + mMode)); + super.addInformation(stack, player, list, bool); + } + + private static boolean createNBT(ItemStack rStack) { + final NBTTagCompound tagMain = new NBTTagCompound(); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setLong("Mode", 0); + tagMain.setTag("GTPP_DEBUG", tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public static final long getFilterDamage(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("GTPP_DEBUG"); + if (aNBT != null) { + return aNBT.getLong("Mode"); + } + } else { + createNBT(aStack); + } + return 0L; + } + + public static final boolean setFilterDamage(final ItemStack aStack, final long aDamage) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("GTPP_DEBUG"); + if (aNBT != null) { + aNBT.setLong("Mode", aDamage); + return true; + } + } + return false; + } + + public boolean removeBlocks(World world, BlockPos pos) { + int x1 = pos.xPos; + int y1 = pos.yPos; + int z1 = pos.zPos; + + int x2 = (x1 - 24); + int y2 = (y1 - 10); + int z2 = (z1 - 24); + + removeBlockColumn(world, new BlockPos(x2, y2, z2, world)); + return true; + } + + public boolean removeBlockColumn(World world, BlockPos pos) { + for (int i = 0; i < 50; i++) { + removeBlockRow(world, new BlockPos(pos.xPos, pos.yPos - 10, pos.zPos + i, world)); + removeBlockRow(world, new BlockPos(pos.xPos, pos.yPos, pos.zPos + i, world)); + removeBlockRow(world, new BlockPos(pos.xPos, pos.yPos + 10, pos.zPos + i, world)); + } + return true; + } + + public boolean removeBlockRow(World world, BlockPos pos) { + for (int j = 0; j < 20; j++) { + for (int i = 0; i < 50; i++) { + + if (!(world.getBlock(pos.xPos + i, pos.yPos + j, pos.zPos) instanceof BlockBaseOre) + && !(world.getBlock(pos.xPos + i, pos.yPos + j, pos.zPos) instanceof IGregTechTileEntity) + && !(world.getBlock(pos.xPos + i, pos.yPos + j, pos.zPos) instanceof GT_Block_Ores)) { + if (!world.isAirBlock(pos.xPos + i, pos.yPos + j, pos.zPos) + && world.getBlock(pos.xPos + i, pos.yPos + j, pos.zPos) != Blocks.bedrock) { + int chance = MathUtils.randInt(0, 500); + if (chance <= 0) { + if (pos.yPos + j <= 50) { + world.setBlock(pos.xPos + i, pos.yPos + j, pos.zPos, Blocks.glowstone); + } + } else { + if ((world.getBlock(pos.xPos + i, pos.yPos + j, pos.zPos) == Blocks.glowstone + && ((pos.yPos + j) > 50)) + || world.getBlock(pos.xPos + i, pos.yPos + j, pos.zPos) != Blocks.glowstone) { + world.setBlockToAir(pos.xPos + i, pos.yPos + j, pos.zPos); + } + } + } + } + } + } + return true; + } + + public boolean fillBlocks(World world, BlockPos pos) { + int x1 = pos.xPos; + int y1 = pos.yPos; + int z1 = pos.zPos; + + int x2 = (x1 - 15); + int y2 = (y1 - 1); + int z2 = (z1 - 15); + + fillBlockColumn(world, new BlockPos(x2, y2, z2, world)); + return true; + } + + public boolean fillBlockColumn(World world, BlockPos pos) { + for (int i = 0; i < 30; i++) { + fillBlockRow(world, new BlockPos(pos.xPos, pos.yPos, pos.zPos + i, world)); + } + return true; + } + + public boolean fillBlockRow(World world, BlockPos pos) { + for (int j = 0; j < 2; j++) { + for (int i = 0; i < 30; i++) { + if (world.getBlock(pos.xPos + i, pos.yPos + j, pos.zPos) != Blocks.bedrock) { + world.setBlock(pos.xPos + i, pos.yPos + j, pos.zPos, Blocks.dirt); + world.setBlockMetadataWithNotify(pos.xPos + i, pos.yPos + j, pos.zPos, 2, 2); + } + } + } + return true; + } + + @Override + public ItemStack onItemRightClick(ItemStack thisItem, World world, EntityPlayer parEntity) { + BlockPos groundBlock = EntityUtils.findBlockPosUnderEntity(parEntity); + if (thisItem.getItemDamage() == 0) { + removeBlocks(world, groundBlock); + } else { + Logger.INFO("Filling."); + fillBlocks(world, groundBlock); + } + return super.onItemRightClick(thisItem, world, parEntity); + } } diff --git a/src/main/java/gtPlusPlus/core/item/general/ItemBasicFirestarter.java b/src/main/java/gtPlusPlus/core/item/general/ItemBasicFirestarter.java index ca6c5e8c8c..e64b85c515 100644 --- a/src/main/java/gtPlusPlus/core/item/general/ItemBasicFirestarter.java +++ b/src/main/java/gtPlusPlus/core/item/general/ItemBasicFirestarter.java @@ -1,85 +1,102 @@ package gtPlusPlus.core.item.general; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - import gtPlusPlus.core.block.general.FirePit; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.item.base.CoreItem; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; public class ItemBasicFirestarter extends CoreItem { - public ItemBasicFirestarter() { - super("itemSimpleFiremaker", AddToCreativeTab.tabTools, 1, 5, "Can probably make you a fire"); - this.setTextureName(CORE.MODID+":"+"itemFireStarter"); - } + public ItemBasicFirestarter() { + super("itemSimpleFiremaker", AddToCreativeTab.tabTools, 1, 5, "Can probably make you a fire"); + this.setTextureName(CORE.MODID + ":" + "itemFireStarter"); + } - @Override - public boolean onItemUse( - final ItemStack thisItem, final EntityPlayer thisPlayer, final World thisWorld, - int blockX, int blockY, int blockZ, - final int p_77648_7_, final float p_77648_8_, final float p_77648_9_, final float p_77648_10_) { - if (p_77648_7_ == 0) { - --blockY; - } - if (p_77648_7_ == 1) { - ++blockY; - } - if (p_77648_7_ == 2) { - --blockZ; - } - if (p_77648_7_ == 3) { - ++blockZ; - } - if (p_77648_7_ == 4) { - --blockX; - } - if (p_77648_7_ == 5) { - ++blockX; - } - if (!thisPlayer.canPlayerEdit(blockX, blockY, blockZ, p_77648_7_, thisItem)) { - return false; - } - if (thisWorld.getBlock(blockX, blockY, blockZ) instanceof FirePit){ - thisWorld.setBlockMetadataWithNotify(blockX, blockY, blockZ, 2, 4); - PlayerUtils.messagePlayer(thisPlayer, "You light the fire pit. "); - } - if (thisWorld.isAirBlock(blockX, blockY, blockZ)) - { - final int random = MathUtils.randInt(0, 3); - //Explode, lol. - if (random == 0){ - PlayerUtils.messagePlayer(thisPlayer, "You somehow managed to set yourself on fire... "); - thisWorld.playSoundEffect(thisPlayer.posX + 0.5D, thisPlayer.posY + 0.5D, thisPlayer.posZ + 0.5D, "fire.ignite", 1.0F, (itemRand.nextFloat() * 0.4F) + 0.8F); - thisPlayer.setFire(4); - thisItem.damageItem(thisItem.getMaxDamage(), thisPlayer); - } + @Override + public boolean onItemUse( + final ItemStack thisItem, + final EntityPlayer thisPlayer, + final World thisWorld, + int blockX, + int blockY, + int blockZ, + final int p_77648_7_, + final float p_77648_8_, + final float p_77648_9_, + final float p_77648_10_) { + if (p_77648_7_ == 0) { + --blockY; + } + if (p_77648_7_ == 1) { + ++blockY; + } + if (p_77648_7_ == 2) { + --blockZ; + } + if (p_77648_7_ == 3) { + ++blockZ; + } + if (p_77648_7_ == 4) { + --blockX; + } + if (p_77648_7_ == 5) { + ++blockX; + } + if (!thisPlayer.canPlayerEdit(blockX, blockY, blockZ, p_77648_7_, thisItem)) { + return false; + } + if (thisWorld.getBlock(blockX, blockY, blockZ) instanceof FirePit) { + thisWorld.setBlockMetadataWithNotify(blockX, blockY, blockZ, 2, 4); + PlayerUtils.messagePlayer(thisPlayer, "You light the fire pit. "); + } + if (thisWorld.isAirBlock(blockX, blockY, blockZ)) { + final int random = MathUtils.randInt(0, 3); + // Explode, lol. + if (random == 0) { + PlayerUtils.messagePlayer(thisPlayer, "You somehow managed to set yourself on fire... "); + thisWorld.playSoundEffect( + thisPlayer.posX + 0.5D, + thisPlayer.posY + 0.5D, + thisPlayer.posZ + 0.5D, + "fire.ignite", + 1.0F, + (itemRand.nextFloat() * 0.4F) + 0.8F); + thisPlayer.setFire(4); + thisItem.damageItem(thisItem.getMaxDamage(), thisPlayer); + } - //Create a fire - else if (random == 2){ - PlayerUtils.messagePlayer(thisPlayer, "You created a fire!"); - thisWorld.playSoundEffect(blockX + 0.5D, blockY + 0.5D, blockZ + 0.5D, "fire.ignite", 1.0F, (itemRand.nextFloat() * 0.4F) + 0.8F); - thisWorld.setBlock(blockX, blockY, blockZ, Blocks.fire); - } + // Create a fire + else if (random == 2) { + PlayerUtils.messagePlayer(thisPlayer, "You created a fire!"); + thisWorld.playSoundEffect( + blockX + 0.5D, + blockY + 0.5D, + blockZ + 0.5D, + "fire.ignite", + 1.0F, + (itemRand.nextFloat() * 0.4F) + 0.8F); + thisWorld.setBlock(blockX, blockY, blockZ, Blocks.fire); + } - //Do nothing - else { - PlayerUtils.messagePlayer(thisPlayer, "Your attemp does nothing."); - thisItem.damageItem(1, thisPlayer); - return false; - } - } - thisItem.damageItem(1, thisPlayer); - return true; - } + // Do nothing + else { + PlayerUtils.messagePlayer(thisPlayer, "Your attemp does nothing."); + thisItem.damageItem(1, thisPlayer); + return false; + } + } + thisItem.damageItem(1, thisPlayer); + return true; + } - @Override - public String getItemStackDisplayName(final ItemStack thisItem) { - return "Basic Firemaker"; - } -} \ No newline at end of file + @Override + public String getItemStackDisplayName(final ItemStack thisItem) { + return "Basic Firemaker"; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/general/ItemBasicScrubberTurbine.java b/src/main/java/gtPlusPlus/core/item/general/ItemBasicScrubberTurbine.java index 2b7b98640e..b1a06daab6 100644 --- a/src/main/java/gtPlusPlus/core/item/general/ItemBasicScrubberTurbine.java +++ b/src/main/java/gtPlusPlus/core/item/general/ItemBasicScrubberTurbine.java @@ -1,8 +1,10 @@ package gtPlusPlus.core.item.general; -import java.util.List; import cpw.mods.fml.common.registry.GameRegistry; - +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -12,142 +14,136 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; - public class ItemBasicScrubberTurbine extends Item { - public IIcon[] icons = new IIcon[1]; - - public ItemBasicScrubberTurbine() { - super(); - this.setHasSubtypes(true); - String unlocalizedName = "itemBasicTurbine"; - this.setUnlocalizedName(unlocalizedName); - this.setCreativeTab(AddToCreativeTab.tabMisc); - this.setMaxStackSize(1); - GameRegistry.registerItem(this, unlocalizedName); - } - - @Override - public void registerIcons(IIconRegister reg) { - this.icons[0] = reg.registerIcon(CORE.MODID + ":" + "itemBasicTurbine"); - } - - @Override - public IIcon getIconFromDamage(int meta) { - return this.icons[0]; - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < 3; i ++) { - list.add(new ItemStack(item, 1, i)); - } - } - - @Override - public String getUnlocalizedName(ItemStack stack) { - return this.getUnlocalizedName() + "_" + stack.getItemDamage(); - } - - @Override - public String getItemStackDisplayName(final ItemStack tItem) { - if (tItem == null) { - return "Basic Turbine"; - } - return super.getItemStackDisplayName(tItem); - } - - @Override - public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { - int meta = stack.getItemDamage(); - if (meta == 0){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(200,200,200); - } - if (meta == 1){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(255,128,0); - } - if (meta == 2){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(128,128,128); - } - return HEX_OxFFFFFF; - } - - private static boolean createNBT(ItemStack rStack){ - final NBTTagCompound tagMain = new NBTTagCompound(); - final NBTTagCompound tagNBT = new NBTTagCompound(); - tagNBT.setLong("Damage", 0); - tagMain.setTag("BasicTurbine", tagNBT); - rStack.setTagCompound(tagMain); - return true; - } - - public static final long getFilterDamage(final ItemStack aStack) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("BasicTurbine"); - if (aNBT != null) { - return aNBT.getLong("Damage"); - } - } - else { - createNBT(aStack); - } - return 0L; - } - - public static final boolean setFilterDamage(final ItemStack aStack, final long aDamage) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("BasicTurbine"); - if (aNBT != null) { - aNBT.setLong("Damage", aDamage); - return true; - } - } - return false; - } - - public int getMaxDurability(ItemStack aStack) { - if (aStack != null) { - int aMeta = aStack.getItemDamage(); - if (aMeta == 0) { - return 2000; - } - if (aMeta == 1) { - return 4000; - } - if (aMeta == 2) { - return 6000; - } - } - return 0; - } - - @Override - public double getDurabilityForDisplay(ItemStack stack) { - if (stack.getTagCompound() == null){ - createNBT(stack); + public IIcon[] icons = new IIcon[1]; + + public ItemBasicScrubberTurbine() { + super(); + this.setHasSubtypes(true); + String unlocalizedName = "itemBasicTurbine"; + this.setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setMaxStackSize(1); + GameRegistry.registerItem(this, unlocalizedName); + } + + @Override + public void registerIcons(IIconRegister reg) { + this.icons[0] = reg.registerIcon(CORE.MODID + ":" + "itemBasicTurbine"); + } + + @Override + public IIcon getIconFromDamage(int meta) { + return this.icons[0]; + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 3; i++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return this.getUnlocalizedName() + "_" + stack.getItemDamage(); + } + + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + if (tItem == null) { + return "Basic Turbine"; + } + return super.getItemStackDisplayName(tItem); + } + + @Override + public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { + int meta = stack.getItemDamage(); + if (meta == 0) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(200, 200, 200); + } + if (meta == 1) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(255, 128, 0); + } + if (meta == 2) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(128, 128, 128); + } + return HEX_OxFFFFFF; + } + + private static boolean createNBT(ItemStack rStack) { + final NBTTagCompound tagMain = new NBTTagCompound(); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setLong("Damage", 0); + tagMain.setTag("BasicTurbine", tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public static final long getFilterDamage(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("BasicTurbine"); + if (aNBT != null) { + return aNBT.getLong("Damage"); + } + } else { + createNBT(aStack); + } + return 0L; + } + + public static final boolean setFilterDamage(final ItemStack aStack, final long aDamage) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("BasicTurbine"); + if (aNBT != null) { + aNBT.setLong("Damage", aDamage); + return true; + } + } + return false; + } + + public int getMaxDurability(ItemStack aStack) { + if (aStack != null) { + int aMeta = aStack.getItemDamage(); + if (aMeta == 0) { + return 2000; + } + if (aMeta == 1) { + return 4000; + } + if (aMeta == 2) { + return 6000; + } + } + return 0; + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + if (stack.getTagCompound() == null) { + createNBT(stack); } - double currentDamage = getFilterDamage(stack); - double meta = getMaxDurability(stack); - double durabilitypercent = currentDamage / meta; - return durabilitypercent; - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { - list.add(EnumChatFormatting.GRAY+"An early tier Turbine for Atmospheric Reconditioning."); - int maxDamage = getMaxDurability(stack); - list.add(EnumChatFormatting.GRAY+""+(maxDamage-getFilterDamage(stack))+"/"+maxDamage+" uses left."); - super.addInformation(stack, player, list, bool); - } - - @Override - public boolean showDurabilityBar(ItemStack stack) { - return true; - } - -} \ No newline at end of file + double currentDamage = getFilterDamage(stack); + double meta = getMaxDurability(stack); + double durabilitypercent = currentDamage / meta; + return durabilitypercent; + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { + list.add(EnumChatFormatting.GRAY + "An early tier Turbine for Atmospheric Reconditioning."); + int maxDamage = getMaxDurability(stack); + list.add(EnumChatFormatting.GRAY + "" + (maxDamage - getFilterDamage(stack)) + "/" + maxDamage + " uses left."); + super.addInformation(stack, player, list, bool); + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/general/ItemBlueprint.java b/src/main/java/gtPlusPlus/core/item/general/ItemBlueprint.java index 5df17979a9..d3f1c2bed6 100644 --- a/src/main/java/gtPlusPlus/core/item/general/ItemBlueprint.java +++ b/src/main/java/gtPlusPlus/core/item/general/ItemBlueprint.java @@ -1,9 +1,14 @@ package gtPlusPlus.core.item.general; -import java.util.List; - import cpw.mods.fml.common.registry.GameRegistry; - +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.interfaces.IItemBlueprint; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import java.util.List; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -14,282 +19,269 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.interfaces.IItemBlueprint; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.minecraft.PlayerUtils; - -public class ItemBlueprint extends Item implements IItemBlueprint{ - - public ItemBlueprint(final String unlocalizedName) { - this.setUnlocalizedName(unlocalizedName); - this.setTextureName(CORE.MODID + ":" + unlocalizedName); - this.setMaxStackSize(1); - this.setCreativeTab(AddToCreativeTab.tabMachines); - //this.bpID = MathUtils.randInt(0, 1000); - GameRegistry.registerItem(this, unlocalizedName); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(final ItemStack itemStack, final EntityPlayer aPlayer, final List list, final boolean bool) { - //Create some NBT if it's not there, otherwise this does nothing. - if (!itemStack.hasTagCompound()){ - this.createNBT(itemStack); - } - //Set up some default variables. - int id = -1; - String name = ""; - boolean blueprint = false; - //Get proper display vars from NBT if it's there - if (itemStack.hasTagCompound()){ - //Utils.LOG_WARNING("Found TagCompound"); - id = (int) this.getNBT(itemStack, "mID"); - name = (String) this.getNBT(itemStack, "mName"); - blueprint = (boolean) this.getNBT(itemStack, "mBlueprint"); - } - //Write to tooltip list for each viable setting. - if (itemStack.hasTagCompound()) { - if (id != -1){ - list.add(EnumChatFormatting.GRAY+"Technical Document No. "+id); - } - if(blueprint){ - list.add(EnumChatFormatting.BLUE+"Currently holding a blueprint for "+name); - } - else { - list.add(EnumChatFormatting.RED+"Currently not holding a blueprint for anything."); - } - } - else { - list.add(EnumChatFormatting.RED+"Currently not holding a blueprint for anything."); - } - super.addInformation(itemStack, aPlayer, list, bool); - } - - @Override - public String getItemStackDisplayName(final ItemStack p_77653_1_) { - return "Blueprint"; - } +public class ItemBlueprint extends Item implements IItemBlueprint { - @Override - public void onCreated(final ItemStack itemStack, final World world, final EntityPlayer player) { - this.createNBT(itemStack); - } + public ItemBlueprint(final String unlocalizedName) { + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setMaxStackSize(1); + this.setCreativeTab(AddToCreativeTab.tabMachines); + // this.bpID = MathUtils.randInt(0, 1000); + GameRegistry.registerItem(this, unlocalizedName); + } - @Override - public void onUpdate(final ItemStack itemStack, final World par2World, final Entity par3Entity, final int par4, final boolean par5) { + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public void addInformation( + final ItemStack itemStack, final EntityPlayer aPlayer, final List list, final boolean bool) { + // Create some NBT if it's not there, otherwise this does nothing. + if (!itemStack.hasTagCompound()) { + this.createNBT(itemStack); + } + // Set up some default variables. + int id = -1; + String name = ""; + boolean blueprint = false; + // Get proper display vars from NBT if it's there + if (itemStack.hasTagCompound()) { + // Utils.LOG_WARNING("Found TagCompound"); + id = (int) this.getNBT(itemStack, "mID"); + name = (String) this.getNBT(itemStack, "mName"); + blueprint = (boolean) this.getNBT(itemStack, "mBlueprint"); + } + // Write to tooltip list for each viable setting. + if (itemStack.hasTagCompound()) { + if (id != -1) { + list.add(EnumChatFormatting.GRAY + "Technical Document No. " + id); + } + if (blueprint) { + list.add(EnumChatFormatting.BLUE + "Currently holding a blueprint for " + name); + } else { + list.add(EnumChatFormatting.RED + "Currently not holding a blueprint for anything."); + } + } else { + list.add(EnumChatFormatting.RED + "Currently not holding a blueprint for anything."); + } + super.addInformation(itemStack, aPlayer, list, bool); + } - } + @Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + return "Blueprint"; + } - @Override - public ItemStack onItemRightClick(final ItemStack itemStack, final World world, final EntityPlayer par3Entity) { - //Let the player know what blueprint is held - if (itemStack.hasTagCompound()) { - PlayerUtils.messagePlayer(par3Entity, "This Blueprint holds NBT data. "+"|"+this.getNBT(itemStack, "mID")+"|"+this.getNBT(itemStack, "mBlueprint")+"|"+this.getNBT(itemStack, "mName")+"|"+ItemUtils.getArrayStackNames(this.readItemsFromNBT(itemStack))); - } - else { - this.createNBT(itemStack); - PlayerUtils.messagePlayer(par3Entity, "This is a placeholder. "+this.getNBT(itemStack, "mID")); - } + @Override + public void onCreated(final ItemStack itemStack, final World world, final EntityPlayer player) { + this.createNBT(itemStack); + } + @Override + public void onUpdate( + final ItemStack itemStack, + final World par2World, + final Entity par3Entity, + final int par4, + final boolean par5) {} - return super.onItemRightClick(itemStack, world, par3Entity); - } + @Override + public ItemStack onItemRightClick(final ItemStack itemStack, final World world, final EntityPlayer par3Entity) { + // Let the player know what blueprint is held + if (itemStack.hasTagCompound()) { + PlayerUtils.messagePlayer( + par3Entity, + "This Blueprint holds NBT data. " + "|" + this.getNBT(itemStack, "mID") + "|" + + this.getNBT(itemStack, "mBlueprint") + "|" + this.getNBT(itemStack, "mName") + "|" + + ItemUtils.getArrayStackNames(this.readItemsFromNBT(itemStack))); + } else { + this.createNBT(itemStack); + PlayerUtils.messagePlayer(par3Entity, "This is a placeholder. " + this.getNBT(itemStack, "mID")); + } - public ItemStack[] readItemsFromNBT(final ItemStack itemStack){ - ItemStack[] blueprint = new ItemStack[9]; - if (itemStack.hasTagCompound()){ - final NBTTagCompound nbt = itemStack.getTagCompound(); - final NBTTagList list = nbt.getTagList("Inventory", 10); - blueprint = new ItemStack[INV_SIZE]; - for(int i = 0;i= 0) && (slot < INV_SIZE)) - { - blueprint[slot] = ItemStack.loadItemStackFromNBT(data); - } - } - return blueprint; - } - return null; - } + return super.onItemRightClick(itemStack, world, par3Entity); + } - public ItemStack writeItemsToNBT(final ItemStack itemStack, final ItemStack[] craftingGrid){ - final ItemStack[] blueprint = craftingGrid; - if (itemStack.hasTagCompound()){ - final NBTTagCompound nbt = itemStack.getTagCompound(); - final NBTTagList list = new NBTTagList(); - for(int i = 0;i= 0) && (slot < INV_SIZE)) { + blueprint[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + return blueprint; + } + return null; + } - @Override - public boolean isBlueprint(final ItemStack stack) { - return true; - } + public ItemStack writeItemsToNBT(final ItemStack itemStack, final ItemStack[] craftingGrid) { + final ItemStack[] blueprint = craftingGrid; + if (itemStack.hasTagCompound()) { + final NBTTagCompound nbt = itemStack.getTagCompound(); + final NBTTagList list = new NBTTagList(); + for (int i = 0; i < INV_SIZE; i++) { + final ItemStack stack = blueprint[i]; + if (stack != null) { + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + nbt.setTag("Inventory", list); + itemStack.setTagCompound(nbt); + return itemStack; + } + return null; + } - @Override - public boolean setBlueprint(final ItemStack stack, final IInventory craftingTable, final ItemStack output) { - boolean hasBP = false; - ItemStack[] blueprint = new ItemStack[9]; + @Override + public boolean isBlueprint(final ItemStack stack) { + return true; + } - if (stack.hasTagCompound()){ - hasBP = (boolean) this.getNBT(stack, "mBlueprint"); - blueprint = this.readItemsFromNBT(stack); - } + @Override + public boolean setBlueprint(final ItemStack stack, final IInventory craftingTable, final ItemStack output) { + boolean hasBP = false; + ItemStack[] blueprint = new ItemStack[9]; - if (!hasBP){ - try { - for (int o=0; o= 10000){ - arg1.addPotionEffect(new PotionEffect(Potion.invisibility.id, 10, 2)); - this.discharge(arg0, 10000, 5, true, true, false); - } - else { - if (arg1.isPotionActive((Potion.invisibility))){ - arg1.removePotionEffect(Potion.invisibility.id); - } - } - } - } - +@Optional.InterfaceList( + value = { + @Optional.Interface(iface = "baubles.api.IBauble", modid = "Baubles"), + @Optional.Interface(iface = "baubles.api.BaubleType", modid = "Baubles") + }) +public class ItemCloakingDevice extends Item implements IElectricItem, IElectricItemManager, IBauble { + + private final String unlocalizedName = "personalCloakingDevice"; + private final ItemStack thisStack; + private static final int maxValueEU = 10000 * 20 * 500; + protected double chargeEU = 0; + + public ItemCloakingDevice(final double charge) { + this.chargeEU = charge; + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setUnlocalizedName(this.unlocalizedName); + this.setMaxStackSize(1); + this.setTextureName(CORE.MODID + ":" + "personalCloakingDevice"); + this.thisStack = ItemUtils.getSimpleStack(this); + this.charge(this.thisStack, charge, 3, true, false); + if (charge == (10000 * 20 * 500)) { + this.setDamage(this.thisStack, 13); + } + GameRegistry.registerItem(this, this.unlocalizedName + "-" + charge); + } + + @Override + public void onUpdate( + final ItemStack itemStack, + final World worldObj, + final Entity player, + final int p_77663_4_, + final boolean p_77663_5_) { + if (worldObj.isRemote) { + return; + } + + if (player instanceof EntityPlayer) { + for (final ItemStack is : ((EntityPlayer) player).inventory.mainInventory) { + if (is == itemStack) { + continue; + } + if (is != null) { + if (is.getItem() instanceof IElectricItem) { + final IElectricItem electricItem = (IElectricItem) is.getItem(); + this.chargeEU = ElectricItem.manager.getCharge(is); + } + } + } + } + + super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); + } + + @Override + public boolean canProvideEnergy(final ItemStack itemStack) { + return true; + } + + @Override + public Item getChargedItem(final ItemStack itemStack) { + final ItemStack x = itemStack.copy(); + x.setItemDamage(maxValueEU); + return x.getItem(); + } + + @Override + public Item getEmptyItem(final ItemStack itemStack) { + final ItemStack x = itemStack.copy(); + x.setItemDamage(0); + return x.getItem(); + } + + @Override + public double getMaxCharge(final ItemStack itemStack) { + return maxValueEU; + } + + @Override + public int getTier(final ItemStack itemStack) { + return 5; + } + + @Override + public double getTransferLimit(final ItemStack itemStack) { + return 8196; + } + + @Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + + return (EnumChatFormatting.BLUE + "Personal Cloaking Device" + EnumChatFormatting.GRAY); + } + + @Override + public double getDurabilityForDisplay(final ItemStack stack) { + // return 1.0D - getEnergyStored(stack) / this.capacity; + return 1.0D - (this.getCharge(stack) / this.getMaxCharge(stack)); + } + + @Override + public boolean showDurabilityBar(final ItemStack stack) { + return true; + } + + public int secondsLeft(final ItemStack stack) { + double r = 0; + r = this.getCharge(stack) / (10000 * 20); + return (int) MathUtils.decimalRounding(r); + } + + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add(""); + list.add(EnumChatFormatting.GREEN + "Worn as a Belt within Baubles." + EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GREEN + "Drains 10,000EU/t to provide invisibility." + EnumChatFormatting.GRAY); + list.add(""); + list.add(EnumChatFormatting.GOLD + "IC2/EU Information" + EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GRAY + "Tier: [" + EnumChatFormatting.YELLOW + this.getTier(this.thisStack) + + EnumChatFormatting.GRAY + "] Input Limit: [" + EnumChatFormatting.YELLOW + + this.getTransferLimit(this.thisStack) + EnumChatFormatting.GRAY + "EU/t]"); + list.add(EnumChatFormatting.GRAY + "Current Power: [" + EnumChatFormatting.YELLOW + (long) this.getCharge(stack) + + EnumChatFormatting.GRAY + "EU] [" + EnumChatFormatting.YELLOW + + MathUtils.findPercentage(this.getCharge(stack), this.getMaxCharge(stack)) + EnumChatFormatting.GRAY + + "%]"); + list.add(EnumChatFormatting.GRAY + "Time Remaining: [" + EnumChatFormatting.YELLOW + this.secondsLeft(stack) + + EnumChatFormatting.GRAY + " seconds]"); + super.addInformation(stack, aPlayer, list, bool); + } + + /*@Override + public ItemStack getContainerItem(ItemStack itemStack) + { + ItemStack newItem = itemStack.copy(); + newItem.stackSize = 1; + extractEnergy(newItem, 150000, false); + return newItem; + }*/ + + /*@Override + public boolean hasContainerItem(ItemStack stack) + { + return true; + }*/ + + /*@Override + public int getBurnTime(ItemStack fuel) { + if ((fuel == null) || (fuel.getItem() != this)) { + return 0; + } + return extractEnergy(fuel, 150000, true) / 50 / 100; + }*/ + + @Override + public double charge( + final ItemStack stack, + final double amount, + final int tier, + final boolean ignoreTransferLimit, + final boolean simulate) { + + if (!simulate) { + ElectricItem.manager.charge(stack, amount, tier, true, simulate); + } + return ElectricItem.manager.charge(stack, amount, tier, true, simulate); + } + + @Override + public double discharge( + final ItemStack stack, + final double amount, + final int tier, + final boolean ignoreTransferLimit, + final boolean externally, + final boolean simulate) { + if (!simulate) { + ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate); + } + + return ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate); + } + + @Override + public double getCharge(final ItemStack stack) { + return ElectricItem.manager.getCharge(stack); + } + + @Override + public boolean canUse(final ItemStack stack, final double amount) { + return ElectricItem.manager.canUse(stack, amount); + } + + @Override + public boolean use(final ItemStack stack, final double amount, final EntityLivingBase entity) { + return ElectricItem.manager.use(stack, amount, entity); + } + + @Override + public void chargeFromArmor(final ItemStack stack, final EntityLivingBase entity) { + ElectricItem.manager.chargeFromArmor(stack, entity); + } + + @Override + public String getToolTip(final ItemStack stack) { + return ElectricItem.manager.getToolTip(stack); + } + + @Override + public boolean canEquip(final ItemStack arg0, final EntityLivingBase arg1) { + return true; + } + + @Override + public boolean canUnequip(final ItemStack arg0, final EntityLivingBase arg1) { + return true; + } + + @Override + public BaubleType getBaubleType(final ItemStack arg0) { + return BaubleType.BELT; + } + + @Override // TODO + public void onEquipped(final ItemStack arg0, final EntityLivingBase arg1) {} + + @Override // TODO + public void onUnequipped(final ItemStack arg0, final EntityLivingBase arg1) {} + + @Override // TODO + public void onWornTick(final ItemStack arg0, final EntityLivingBase arg1) { + // Utils.LOG_INFO("Trying to Tick Belt. 1"); + if (!arg1.worldObj.isRemote) { + if (this.getCharge(arg0) >= 10000) { + arg1.addPotionEffect(new PotionEffect(Potion.invisibility.id, 10, 2)); + this.discharge(arg0, 10000, 5, true, true, false); + } else { + if (arg1.isPotionActive((Potion.invisibility))) { + arg1.removePotionEffect(Potion.invisibility.id); + } + } + } + } } diff --git a/src/main/java/gtPlusPlus/core/item/general/ItemControlCore.java b/src/main/java/gtPlusPlus/core/item/general/ItemControlCore.java index b74b7972be..e210ba87b6 100644 --- a/src/main/java/gtPlusPlus/core/item/general/ItemControlCore.java +++ b/src/main/java/gtPlusPlus/core/item/general/ItemControlCore.java @@ -1,10 +1,10 @@ package gtPlusPlus.core.item.general; -import java.util.List; - import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; +import gtPlusPlus.core.lib.CORE; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -13,116 +13,106 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; -import gtPlusPlus.core.lib.CORE; - public class ItemControlCore extends Item { - public static IIcon[] icons = new IIcon[10]; + public static IIcon[] icons = new IIcon[10]; - public ItemControlCore() { - super(); - this.setHasSubtypes(true); - String unlocalizedName = "itemControlCore"; - this.setUnlocalizedName(unlocalizedName); - this.setCreativeTab(GregTech_API.TAB_GREGTECH); - //this.setCreativeTab(AddToCreativeTab.tabMisc); - GameRegistry.registerItem(this, unlocalizedName); - } + public ItemControlCore() { + super(); + this.setHasSubtypes(true); + String unlocalizedName = "itemControlCore"; + this.setUnlocalizedName(unlocalizedName); + this.setCreativeTab(GregTech_API.TAB_GREGTECH); + // this.setCreativeTab(AddToCreativeTab.tabMisc); + GameRegistry.registerItem(this, unlocalizedName); + } - @Override - public void registerIcons(IIconRegister reg) { - icons[0] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_0"); - icons[1] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_1"); - icons[2] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_2"); - icons[3] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_3"); - icons[4] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_4"); - icons[5] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_5"); - icons[6] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_6"); - icons[7] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_7"); - icons[8] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_8"); - icons[9] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_9"); - } + @Override + public void registerIcons(IIconRegister reg) { + icons[0] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_0"); + icons[1] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_1"); + icons[2] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_2"); + icons[3] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_3"); + icons[4] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_4"); + icons[5] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_5"); + icons[6] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_6"); + icons[7] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_7"); + icons[8] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_8"); + icons[9] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_9"); + } - @Override - public IIcon getIconFromDamage(int meta) { - return this.icons[meta]; - } + @Override + public IIcon getIconFromDamage(int meta) { + return this.icons[meta]; + } - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < 10; i ++) { - list.add(new ItemStack(item, 1, i)); - } - } + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 10; i++) { + list.add(new ItemStack(item, 1, i)); + } + } - @Override - public String getUnlocalizedName(ItemStack stack) { - return this.getUnlocalizedName() + "_" + stack.getItemDamage(); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - list.add(EnumChatFormatting.GRAY+"Allows a Multiblock to function upto "+GT_Values.VN[stack.getItemDamage()]+""); - list.add(EnumChatFormatting.GRAY+"Required Tier is determined by the sum of the eu/t of all Energy Inputs"); - list.add(EnumChatFormatting.GRAY+"Lower tiers may be used to underclock, which is useful in some situations"); - } + @Override + public String getUnlocalizedName(ItemStack stack) { + return this.getUnlocalizedName() + "_" + stack.getItemDamage(); + } - @Override - public String getItemStackDisplayName(final ItemStack tItem) { - if (tItem == null) { - return "Control Core"; - } - String aReturnValue = super.getItemStackDisplayName(tItem); - if (tItem != null) { - try { - if (aReturnValue != null) { - if (aReturnValue.toLowerCase().contains(".name")) { - aReturnValue = "Control Core"; - } - else { - return aReturnValue; - } - } - } - catch (Throwable t) {} - } - if (aReturnValue == null || !aReturnValue.toLowerCase().contains("control core") || aReturnValue.length() <= 0) { - aReturnValue = "Error"; - } - String suffixName = ""; - if (tItem.getItemDamage() == 0){ - suffixName = " [ULV]"; - } - else if (tItem.getItemDamage() == 1){ - suffixName = " [LV]"; - } - else if (tItem.getItemDamage() == 2){ - suffixName = " [MV]"; - } - else if (tItem.getItemDamage() == 3){ - suffixName = " [HV]"; - } - else if (tItem.getItemDamage() == 4){ - suffixName = " [EV]"; - } - else if (tItem.getItemDamage() == 5){ - suffixName = " [IV]"; - } - else if (tItem.getItemDamage() == 6){ - suffixName = " [LuV]"; - } - else if (tItem.getItemDamage() == 7){ - suffixName = " [ZPM]"; - } - else if (tItem.getItemDamage() == 8){ - suffixName = " [UV]"; - } - else if (tItem.getItemDamage() == 9){ - suffixName = " [MAX]"; - } - return (aReturnValue+suffixName); - } + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add(EnumChatFormatting.GRAY + "Allows a Multiblock to function upto " + GT_Values.VN[stack.getItemDamage()] + + ""); + list.add(EnumChatFormatting.GRAY + "Required Tier is determined by the sum of the eu/t of all Energy Inputs"); + list.add(EnumChatFormatting.GRAY + "Lower tiers may be used to underclock, which is useful in some situations"); + } -} \ No newline at end of file + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + if (tItem == null) { + return "Control Core"; + } + String aReturnValue = super.getItemStackDisplayName(tItem); + if (tItem != null) { + try { + if (aReturnValue != null) { + if (aReturnValue.toLowerCase().contains(".name")) { + aReturnValue = "Control Core"; + } else { + return aReturnValue; + } + } + } catch (Throwable t) { + } + } + if (aReturnValue == null + || !aReturnValue.toLowerCase().contains("control core") + || aReturnValue.length() <= 0) { + aReturnValue = "Error"; + } + String suffixName = ""; + if (tItem.getItemDamage() == 0) { + suffixName = " [ULV]"; + } else if (tItem.getItemDamage() == 1) { + suffixName = " [LV]"; + } else if (tItem.getItemDamage() == 2) { + suffixName = " [MV]"; + } else if (tItem.getItemDamage() == 3) { + suffixName = " [HV]"; + } else if (tItem.getItemDamage() == 4) { + suffixName = " [EV]"; + } else if (tItem.getItemDamage() == 5) { + suffixName = " [IV]"; + } else if (tItem.getItemDamage() == 6) { + suffixName = " [LuV]"; + } else if (tItem.getItemDamage() == 7) { + suffixName = " [ZPM]"; + } else if (tItem.getItemDamage() == 8) { + suffixName = " [UV]"; + } else if (tItem.getItemDamage() == 9) { + suffixName = " [MAX]"; + } + return (aReturnValue + suffixName); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/general/ItemCreativeTab.java b/src/main/java/gtPlusPlus/core/item/general/ItemCreativeTab.java index c1a2655a03..9c6e6b257c 100644 --- a/src/main/java/gtPlusPlus/core/item/general/ItemCreativeTab.java +++ b/src/main/java/gtPlusPlus/core/item/general/ItemCreativeTab.java @@ -1,10 +1,9 @@ package gtPlusPlus.core.item.general; -import java.util.List; - import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.GregTech_API; import gtPlusPlus.core.lib.CORE; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; @@ -12,48 +11,47 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; public class ItemCreativeTab extends Item { - - public IIcon[] icons = new IIcon[10]; - - public ItemCreativeTab() { - super(); - this.setHasSubtypes(true); - String unlocalizedName = "itemCreativeTabs"; - this.setUnlocalizedName(unlocalizedName); - this.setCreativeTab(GregTech_API.TAB_GREGTECH); - GameRegistry.registerItem(this, unlocalizedName); - } - - @Override - public void registerIcons(IIconRegister reg) { - this.icons[0] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_0"); - this.icons[1] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_1"); - this.icons[2] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_2"); - this.icons[3] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_3"); - this.icons[4] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_4"); - this.icons[5] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_5"); - this.icons[6] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_6"); - this.icons[7] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_7"); - this.icons[8] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_8"); - this.icons[9] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_9"); - } - - @Override - public IIcon getIconFromDamage(int meta) { - return this.icons[meta]; - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < 10; i ++) { - list.add(new ItemStack(item, 1, i)); - } - } - - @Override - public String getUnlocalizedName(ItemStack stack) { - return this.getUnlocalizedName() + "_" + stack.getItemDamage(); - } + public IIcon[] icons = new IIcon[10]; + + public ItemCreativeTab() { + super(); + this.setHasSubtypes(true); + String unlocalizedName = "itemCreativeTabs"; + this.setUnlocalizedName(unlocalizedName); + this.setCreativeTab(GregTech_API.TAB_GREGTECH); + GameRegistry.registerItem(this, unlocalizedName); + } + + @Override + public void registerIcons(IIconRegister reg) { + this.icons[0] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_0"); + this.icons[1] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_1"); + this.icons[2] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_2"); + this.icons[3] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_3"); + this.icons[4] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_4"); + this.icons[5] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_5"); + this.icons[6] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_6"); + this.icons[7] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_7"); + this.icons[8] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_8"); + this.icons[9] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_9"); + } + + @Override + public IIcon getIconFromDamage(int meta) { + return this.icons[meta]; + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 10; i++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return this.getUnlocalizedName() + "_" + stack.getItemDamage(); + } } diff --git a/src/main/java/gtPlusPlus/core/item/general/ItemEmpty.java b/src/main/java/gtPlusPlus/core/item/general/ItemEmpty.java index c832d28bbd..dc306f8fa2 100644 --- a/src/main/java/gtPlusPlus/core/item/general/ItemEmpty.java +++ b/src/main/java/gtPlusPlus/core/item/general/ItemEmpty.java @@ -1,21 +1,17 @@ package gtPlusPlus.core.item.general; -import net.minecraft.item.ItemStack; - import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.item.base.CoreItem; +import net.minecraft.item.ItemStack; -public class ItemEmpty extends CoreItem{ - - public ItemEmpty() { - super("item.empty", AddToCreativeTab.tabMisc); - } +public class ItemEmpty extends CoreItem { - @Override - public String getItemStackDisplayName(ItemStack tItem) { - return "Empty"; - } + public ItemEmpty() { + super("item.empty", AddToCreativeTab.tabMisc); + } - - + @Override + public String getItemStackDisplayName(ItemStack tItem) { + return "Empty"; + } } diff --git a/src/main/java/gtPlusPlus/core/item/general/ItemGemShards.java b/src/main/java/gtPlusPlus/core/item/general/ItemGemShards.java index 5181a32bc7..25c67aeb21 100644 --- a/src/main/java/gtPlusPlus/core/item/general/ItemGemShards.java +++ b/src/main/java/gtPlusPlus/core/item/general/ItemGemShards.java @@ -1,78 +1,91 @@ package gtPlusPlus.core.item.general; +import gtPlusPlus.core.item.base.BaseItemColourable; +import gtPlusPlus.core.util.Utils; import java.util.List; - import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; -import gtPlusPlus.core.item.base.BaseItemColourable; -import gtPlusPlus.core.util.Utils; +public class ItemGemShards extends BaseItemColourable { + + public ItemGemShards( + String unlocalizedName, + CreativeTabs creativeTab, + int stackSize, + int maxDmg, + String description, + EnumRarity regRarity, + EnumChatFormatting colour, + boolean Effect, + int rgb) { + super(unlocalizedName, creativeTab, stackSize, maxDmg, description, regRarity, colour, Effect, rgb); + } -public class ItemGemShards extends BaseItemColourable{ + public ItemGemShards( + String unlocalizedName, + String displayName, + CreativeTabs creativeTab, + int stackSize, + int maxDmg, + String description, + EnumRarity regRarity, + EnumChatFormatting colour, + boolean Effect, + int rgb) { + super( + unlocalizedName, + displayName, + creativeTab, + stackSize, + maxDmg, + description, + regRarity, + colour, + Effect, + rgb); + } - public ItemGemShards(String unlocalizedName, CreativeTabs creativeTab, int stackSize, int maxDmg, - String description, EnumRarity regRarity, EnumChatFormatting colour, boolean Effect, int rgb) { - super(unlocalizedName, creativeTab, stackSize, maxDmg, description, regRarity, colour, Effect, rgb); - } - - public ItemGemShards(String unlocalizedName, String displayName, CreativeTabs creativeTab, int stackSize, - int maxDmg, String description, EnumRarity regRarity, EnumChatFormatting colour, boolean Effect, int rgb) { - super(unlocalizedName, displayName, creativeTab, stackSize, maxDmg, description, regRarity, colour, Effect, rgb); - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < 4; i ++) { - list.add(new ItemStack(item, 1, i)); - } - } - - //0 - Diamond - //1 - Emerald - //2 - Ruby - //3 - Sapphire - - @Override - public String getItemStackDisplayName(final ItemStack tItem) { - String suffix = " Shards"; - String gemType = ""; - if (tItem.getItemDamage() == 0){ - gemType = "Diamond"; - } - else if (tItem.getItemDamage() == 1){ - gemType = "Emerald"; - } - else if (tItem.getItemDamage() == 2){ - gemType = "Ruby"; - } - else if (tItem.getItemDamage() == 3){ - gemType = "Sapphire"; - } - return (gemType+suffix); - - } + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 4; i++) { + list.add(new ItemStack(item, 1, i)); + } + } - @Override - public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { - if (this.getDamage(stack)==0){ - return Utils.rgbtoHexValue(150, 150, 220); - } - else if (this.getDamage(stack)==1){ - return Utils.rgbtoHexValue(75, 182, 75); - } - else if (this.getDamage(stack)==2){ - return Utils.rgbtoHexValue(182, 77, 77); - } - else { - return Utils.rgbtoHexValue(77, 75, 182); - } - } - - + // 0 - Diamond + // 1 - Emerald + // 2 - Ruby + // 3 - Sapphire - + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + String suffix = " Shards"; + String gemType = ""; + if (tItem.getItemDamage() == 0) { + gemType = "Diamond"; + } else if (tItem.getItemDamage() == 1) { + gemType = "Emerald"; + } else if (tItem.getItemDamage() == 2) { + gemType = "Ruby"; + } else if (tItem.getItemDamage() == 3) { + gemType = "Sapphire"; + } + return (gemType + suffix); + } + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (this.getDamage(stack) == 0) { + return Utils.rgbtoHexValue(150, 150, 220); + } else if (this.getDamage(stack) == 1) { + return Utils.rgbtoHexValue(75, 182, 75); + } else if (this.getDamage(stack) == 2) { + return Utils.rgbtoHexValue(182, 77, 77); + } else { + return Utils.rgbtoHexValue(77, 75, 182); + } + } } diff --git a/src/main/java/gtPlusPlus/core/item/general/ItemGenericToken.java b/src/main/java/gtPlusPlus/core/item/general/ItemGenericToken.java index 21d2c6e120..8ab8efcd12 100644 --- a/src/main/java/gtPlusPlus/core/item/general/ItemGenericToken.java +++ b/src/main/java/gtPlusPlus/core/item/general/ItemGenericToken.java @@ -1,13 +1,12 @@ package gtPlusPlus.core.item.general; -import java.util.HashMap; -import java.util.List; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.item.base.CoreItem; import gtPlusPlus.core.lib.CORE; +import java.util.HashMap; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -19,164 +18,180 @@ import net.minecraft.util.IIcon; public class ItemGenericToken extends CoreItem { - public final HashMap mLocalNames; - public final HashMap mMaxStackSizes; - public final HashMap mDescriptionArrays; - public final HashMap mRarities; - public final HashMap mCustomNameColours; - public final HashMap mIcons; - private final String mTextureDir; - - public ItemGenericToken() { - this("itemGenericToken", "Token", new String[] { "Can be reclaimed in some way, shape or form" }, "token"); - } - - public ItemGenericToken(String aUnlocalName, String aInternalName, String[] aBaseTooltip, String aTextureDir) { - super(aUnlocalName, aInternalName, AddToCreativeTab.tabMisc, 64, 1000, aBaseTooltip, EnumRarity.common, EnumChatFormatting.RESET, false, null); - mLocalNames = new HashMap(); - mMaxStackSizes = new HashMap(); - mDescriptionArrays = new HashMap(); - mRarities = new HashMap(); - mCustomNameColours = new HashMap(); - mIcons = new HashMap(); - mTextureDir = aTextureDir; - } - - public boolean register(int id, String aLocalName, int aMaxStack, String aDescript) { - return register(id, aLocalName, aMaxStack, new String[] { aDescript }); - } - - public boolean register(int id, String aLocalName, int aMaxStack, String[] aDescript) { - return register(id, aLocalName, aMaxStack, aDescript, EnumRarity.common, EnumChatFormatting.RESET); - } - - public boolean register(int id, String aLocalName, int aMaxStack, String[] aDescript, EnumRarity aRarity, - EnumChatFormatting aCustomNameColour) { - int[][] sizes = new int[2][6]; - sizes[0][0] = mLocalNames.size(); - sizes[0][1] = mMaxStackSizes.size(); - sizes[0][2] = mDescriptionArrays.size(); - sizes[0][3] = mRarities.size(); - sizes[0][4] = mCustomNameColours.size(); - //sizes[0][5] = mIcons.size(); - mLocalNames.put(id, aLocalName); - mMaxStackSizes.put(id, aMaxStack); - mDescriptionArrays.put(id, aDescript); - mRarities.put(id, aRarity); - mCustomNameColours.put(id, aCustomNameColour); - sizes[1][0] = mLocalNames.size(); - sizes[1][1] = mMaxStackSizes.size(); - sizes[1][2] = mDescriptionArrays.size(); - sizes[1][3] = mRarities.size(); - sizes[1][4] = mCustomNameColours.size(); - //sizes[1][5] = mIcons.size(); - boolean b = sizes[0][0] > sizes[1][0] && sizes[0][1] > sizes[1][1] && sizes[0][2] > sizes[1][2] - && sizes[0][3] > sizes[1][3] && sizes[0][4] > sizes[1][4]; - return b; - } - - // Handle Sub items - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - @SideOnly(Side.CLIENT) - public void getSubItems(final Item var1, final CreativeTabs aCreativeTab, final List aList) { - for (int i = 0, j = mIcons.size(); i < j; i++) { - final ItemStack tStack = new ItemStack(this, 1, i); - aList.add(tStack); - } - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { - super.addInformation(stack, aPlayer, list, bool); - for (String s : mDescriptionArrays.get(stack.getItemDamage())) { - list.add(s); - } - } - - @Override - public String getItemStackDisplayName(final ItemStack tItem) { - - String s = "" + mCustomNameColours.get(tItem.getItemDamage()); - String parent = super.getItemStackDisplayName(tItem); - if (mLocalNames.get(tItem.getItemDamage()).length() > 0 && parent.toLowerCase().contains(".name")) { - s = s + mLocalNames.get(tItem.getItemDamage()); - } else { - s = s + parent; - } - return s; - } - - @Override - public EnumRarity getRarity(ItemStack par1ItemStack) { - return mRarities.get(par1ItemStack.getItemDamage()); - } - - @Override - public boolean hasEffect(ItemStack par1ItemStack) { - return false; - } - - @Override - public int getMetadata(int p_77647_1_) { - return 0; - } - - @Override - public int getDisplayDamage(ItemStack stack) { - return 0; - } - - @Override - public boolean showDurabilityBar(ItemStack stack) { - return false; - } - - @Override - public double getDurabilityForDisplay(ItemStack stack) { - return 0D; - } - - @Override - public boolean isDamaged(ItemStack stack) { - return false; - } - - @Override - public int getItemStackLimit() { - return 64; - } - - @Override - public int getItemStackLimit(ItemStack aStack) { - if (aStack == null) { - return getItemStackLimit(); - } - else { - Integer aSize = mMaxStackSizes.get(aStack.getItemDamage()); - if (aSize != null) { - return aSize; - } - else { - return getItemStackLimit(); - } - } - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(final IIconRegister aIconRegister) { - for (int i = 0, j = mLocalNames.size(); i < j; i++) { - mIcons.put(i, aIconRegister.registerIcon(CORE.MODID + ":" + mTextureDir + "/" + i)); - } - } - - @Override - public final IIcon getIconFromDamage(final int aMetaData) { - if (aMetaData < 0) { - return null; - } - return mIcons.get(aMetaData); - } - + public final HashMap mLocalNames; + public final HashMap mMaxStackSizes; + public final HashMap mDescriptionArrays; + public final HashMap mRarities; + public final HashMap mCustomNameColours; + public final HashMap mIcons; + private final String mTextureDir; + + public ItemGenericToken() { + this("itemGenericToken", "Token", new String[] {"Can be reclaimed in some way, shape or form"}, "token"); + } + + public ItemGenericToken(String aUnlocalName, String aInternalName, String[] aBaseTooltip, String aTextureDir) { + super( + aUnlocalName, + aInternalName, + AddToCreativeTab.tabMisc, + 64, + 1000, + aBaseTooltip, + EnumRarity.common, + EnumChatFormatting.RESET, + false, + null); + mLocalNames = new HashMap(); + mMaxStackSizes = new HashMap(); + mDescriptionArrays = new HashMap(); + mRarities = new HashMap(); + mCustomNameColours = new HashMap(); + mIcons = new HashMap(); + mTextureDir = aTextureDir; + } + + public boolean register(int id, String aLocalName, int aMaxStack, String aDescript) { + return register(id, aLocalName, aMaxStack, new String[] {aDescript}); + } + + public boolean register(int id, String aLocalName, int aMaxStack, String[] aDescript) { + return register(id, aLocalName, aMaxStack, aDescript, EnumRarity.common, EnumChatFormatting.RESET); + } + + public boolean register( + int id, + String aLocalName, + int aMaxStack, + String[] aDescript, + EnumRarity aRarity, + EnumChatFormatting aCustomNameColour) { + int[][] sizes = new int[2][6]; + sizes[0][0] = mLocalNames.size(); + sizes[0][1] = mMaxStackSizes.size(); + sizes[0][2] = mDescriptionArrays.size(); + sizes[0][3] = mRarities.size(); + sizes[0][4] = mCustomNameColours.size(); + // sizes[0][5] = mIcons.size(); + mLocalNames.put(id, aLocalName); + mMaxStackSizes.put(id, aMaxStack); + mDescriptionArrays.put(id, aDescript); + mRarities.put(id, aRarity); + mCustomNameColours.put(id, aCustomNameColour); + sizes[1][0] = mLocalNames.size(); + sizes[1][1] = mMaxStackSizes.size(); + sizes[1][2] = mDescriptionArrays.size(); + sizes[1][3] = mRarities.size(); + sizes[1][4] = mCustomNameColours.size(); + // sizes[1][5] = mIcons.size(); + boolean b = sizes[0][0] > sizes[1][0] + && sizes[0][1] > sizes[1][1] + && sizes[0][2] > sizes[1][2] + && sizes[0][3] > sizes[1][3] + && sizes[0][4] > sizes[1][4]; + return b; + } + + // Handle Sub items + @SuppressWarnings({"rawtypes", "unchecked"}) + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(final Item var1, final CreativeTabs aCreativeTab, final List aList) { + for (int i = 0, j = mIcons.size(); i < j; i++) { + final ItemStack tStack = new ItemStack(this, 1, i); + aList.add(tStack); + } + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + super.addInformation(stack, aPlayer, list, bool); + for (String s : mDescriptionArrays.get(stack.getItemDamage())) { + list.add(s); + } + } + + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + + String s = "" + mCustomNameColours.get(tItem.getItemDamage()); + String parent = super.getItemStackDisplayName(tItem); + if (mLocalNames.get(tItem.getItemDamage()).length() > 0 + && parent.toLowerCase().contains(".name")) { + s = s + mLocalNames.get(tItem.getItemDamage()); + } else { + s = s + parent; + } + return s; + } + + @Override + public EnumRarity getRarity(ItemStack par1ItemStack) { + return mRarities.get(par1ItemStack.getItemDamage()); + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack) { + return false; + } + + @Override + public int getMetadata(int p_77647_1_) { + return 0; + } + + @Override + public int getDisplayDamage(ItemStack stack) { + return 0; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 0D; + } + + @Override + public boolean isDamaged(ItemStack stack) { + return false; + } + + @Override + public int getItemStackLimit() { + return 64; + } + + @Override + public int getItemStackLimit(ItemStack aStack) { + if (aStack == null) { + return getItemStackLimit(); + } else { + Integer aSize = mMaxStackSizes.get(aStack.getItemDamage()); + if (aSize != null) { + return aSize; + } else { + return getItemStackLimit(); + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(final IIconRegister aIconRegister) { + for (int i = 0, j = mLocalNames.size(); i < j; i++) { + mIcons.put(i, aIconRegister.registerIcon(CORE.MODID + ":" + mTextureDir + "/" + i)); + } + } + + @Override + public final IIcon getIconFromDamage(final int aMetaData) { + if (aMetaData < 0) { + return null; + } + return mIcons.get(aMetaData); + } } diff --git a/src/main/java/gtPlusPlus/core/item/general/ItemGiantEgg.java b/src/main/java/gtPlusPlus/core/item/general/ItemGiantEgg.java index b3338bb681..8f1d1629a6 100644 --- a/src/main/java/gtPlusPlus/core/item/general/ItemGiantEgg.java +++ b/src/main/java/gtPlusPlus/core/item/general/ItemGiantEgg.java @@ -2,8 +2,6 @@ package gtPlusPlus.core.item.general; import static gtPlusPlus.core.lib.CORE.RANDOM; -import java.util.List; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.entity.item.ItemEntityGiantEgg; @@ -15,6 +13,7 @@ import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.NBTUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -27,274 +26,284 @@ import net.minecraft.world.World; public class ItemGiantEgg extends BaseItemTickable { - private static ItemStack turnsIntoItem; - private static ItemStack mCorrectEgg; - private static ItemStack mCorrectStemCells; - - public void registerFuel(int burn){ - CORE.burnables.add(new Pair(burn, ItemUtils.getSimpleStack(this, 1))); - } + private static ItemStack turnsIntoItem; + private static ItemStack mCorrectEgg; + private static ItemStack mCorrectStemCells; - public final void registerOrdictionary(String name){ - ItemUtils.addItemToOreDictionary(ItemUtils.getSimpleStack(this), name); - } + public void registerFuel(int burn) { + CORE.burnables.add(new Pair(burn, ItemUtils.getSimpleStack(this, 1))); + } - public ItemGiantEgg() { - this(Utils.rgbtoHexValue(255, 255, 255), Short.MAX_VALUE * Byte.MAX_VALUE, new String[] {"I had best try disassemble this.. for science!"}); - } + public final void registerOrdictionary(String name) { + ItemUtils.addItemToOreDictionary(ItemUtils.getSimpleStack(this), name); + } - private ItemGiantEgg(int colour, int maxTicks, String[] desc1) { - super(true, false, "itemBigEgg", colour, maxTicks, desc1); - setTextureName(CORE.MODID + ":itemBigEgg"); - this.setMaxStackSize(1); - registerFuel(5000); - registerOrdictionary("fuelLargeChickenEgg"); - } - - public static void postInit(ItemGiantEgg aGiantEggItem) { - ItemGiantEgg.turnsIntoItem = getSpawnEggStack(); - //new DecayableRecipe(aGiantEggItem.maxTicks, getSimpleStack(aGiantEggItem), ItemUtils.getSimpleStack(ItemGiantEgg.turnsIntoItem, 1)); - } + public ItemGiantEgg() { + this(Utils.rgbtoHexValue(255, 255, 255), Short.MAX_VALUE * Byte.MAX_VALUE, new String[] { + "I had best try disassemble this.. for science!" + }); + } - private static ItemStack getSpawnEggStack() { - //Set the correct egg for future hatches - if (mCorrectEgg == null) { - /*for (int g=0;g 28) { - ItemStack xl = ItemUtils.getValueOfItemList("Circuit_Chip_Stemcell", 1, ItemUtils.getSimpleStack(Items.egg, 2)); - if (xl != null) { - mCorrectStemCells = xl.copy(); - } - } - else { - mCorrectStemCells = ItemUtils.getSimpleStack(Items.egg, 2); - } - } - return mCorrectStemCells; - } + public static void postInit(ItemGiantEgg aGiantEggItem) { + ItemGiantEgg.turnsIntoItem = getSpawnEggStack(); + // new DecayableRecipe(aGiantEggItem.maxTicks, getSimpleStack(aGiantEggItem), + // ItemUtils.getSimpleStack(ItemGiantEgg.turnsIntoItem, 1)); + } - protected int getMaxTicks(ItemStack aStack) { - if (aStack != null && aStack.hasTagCompound() && aStack.getTagCompound().hasKey("mEggAge")) { - return NBTUtils.getInteger(aStack, "mEggAge"); - } - return maxTicks; - } + private static ItemStack getSpawnEggStack() { + // Set the correct egg for future hatches + if (mCorrectEgg == null) { + /*for (int g=0;g 28) { + ItemStack xl = ItemUtils.getValueOfItemList( + "Circuit_Chip_Stemcell", 1, ItemUtils.getSimpleStack(Items.egg, 2)); + if (xl != null) { + mCorrectStemCells = xl.copy(); + } + } else { + mCorrectStemCells = ItemUtils.getSimpleStack(Items.egg, 2); + } + } + return mCorrectStemCells; + } + protected int getMaxTicks(ItemStack aStack) { + if (aStack != null && aStack.hasTagCompound() && aStack.getTagCompound().hasKey("mEggAge")) { + return NBTUtils.getInteger(aStack, "mEggAge"); + } + return maxTicks; + } - @Override - protected boolean createNBT(World world, ItemStack aStack){ - - if (aStack.getTagCompound() != null && aStack.getTagCompound().hasKey("size")) { - return false; - } - Logger.INFO("Egg: "+ReflectionUtils.getMethodName(1)); - Logger.INFO("Egg: "+ReflectionUtils.getMethodName(2)); - Logger.INFO("Egg: "+ReflectionUtils.getMethodName(3)); - Logger.INFO("Egg: "+ReflectionUtils.getMethodName(4)); - Logger.INFO("Egg: "+ReflectionUtils.getMethodName(5)); - Logger.INFO("Egg: "+ReflectionUtils.getMethodName(6)); - //Logger.INFO("Creating Egg NBT."); - boolean aSuper = super.createNBT(world, aStack); - int size = MathUtils.randInt(1, 8); - NBTUtils.setInteger(aStack, "size", size); - NBTUtils.setInteger(aStack, "mEggAge", ((MathUtils.randInt(8000, 16000)*size))); - ItemStack aStemCells = getStemCellStack(); - if (aStemCells != null) { - int mSize = NBTUtils.getInteger(aStack, "size"); - float mSizeMod = (MathUtils.randInt(-5, 5)/5); - mSize += mSizeMod; - mSize = Math.max(mSize, 1); - ItemStack eggYolks[] = new ItemStack[mSize]; - for (int u=0;u 0) { - NBTUtils.setInteger(aStack, "mExpected", mexpected); - NBTUtils.writeItemsToGtCraftingComponents(aStack, new ItemStack[]{ ItemUtils.getSimpleStack(aStemCells, mexpected)}, true); - } - } - return aSuper; - - } + @Override + public void registerIcons(final IIconRegister i) { + this.mIcon[0] = i.registerIcon(CORE.MODID + ":" + "itemBigEgg"); + } + @Override + protected boolean createNBT(World world, ItemStack aStack) { - @Override - public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, final boolean p_77663_5_) { - if (world == null || iStack == null) { - return; - } - if (world.isRemote) { - return; - } - if (iStack.getTagCompound() == null || !iStack.getTagCompound().hasKey("size")) { - this.createNBT(world, iStack); - Logger.INFO("Egg has no NBT, creating (onUpdate)"); - } - boolean a1, a2; - a1 = this.isTicking(world, iStack); - a2 = a1 ? tickItemTag(world, iStack) : false; + if (aStack.getTagCompound() != null && aStack.getTagCompound().hasKey("size")) { + return false; + } + Logger.INFO("Egg: " + ReflectionUtils.getMethodName(1)); + Logger.INFO("Egg: " + ReflectionUtils.getMethodName(2)); + Logger.INFO("Egg: " + ReflectionUtils.getMethodName(3)); + Logger.INFO("Egg: " + ReflectionUtils.getMethodName(4)); + Logger.INFO("Egg: " + ReflectionUtils.getMethodName(5)); + Logger.INFO("Egg: " + ReflectionUtils.getMethodName(6)); + // Logger.INFO("Creating Egg NBT."); + boolean aSuper = super.createNBT(world, aStack); + int size = MathUtils.randInt(1, 8); + NBTUtils.setInteger(aStack, "size", size); + NBTUtils.setInteger(aStack, "mEggAge", ((MathUtils.randInt(8000, 16000) * size))); + ItemStack aStemCells = getStemCellStack(); + if (aStemCells != null) { + int mSize = NBTUtils.getInteger(aStack, "size"); + float mSizeMod = (MathUtils.randInt(-5, 5) / 5); + mSize += mSizeMod; + mSize = Math.max(mSize, 1); + ItemStack eggYolks[] = new ItemStack[mSize]; + for (int u = 0; u < mSize; u++) { + eggYolks[u] = ItemUtils.getSimpleStack(aStemCells, MathUtils.randInt(1, 4)); + } + int mexpected = 0; + for (ItemStack e : eggYolks) { + if (e != null) { + mexpected += e.stackSize; + } + } + if (mexpected > 0) { + NBTUtils.setInteger(aStack, "mExpected", mexpected); + NBTUtils.writeItemsToGtCraftingComponents( + aStack, new ItemStack[] {ItemUtils.getSimpleStack(aStemCells, mexpected)}, true); + } + } + return aSuper; + } - //Logger.INFO("Is Ticking? "+a1); - //Logger.INFO("Did Tick? "+a2); - if (!a1 && !a2) { - if (entityHolding instanceof EntityPlayer){ - if (MathUtils.randInt(0, 1000) >= 990) { - if (NBTUtils.hasKey(iStack, "size")) { - if ((NBTUtils.getInteger(iStack, "size")+1) >= MathUtils.randInt(0, 9)) { - ItemStack replacement = ItemUtils.getSimpleStack(getHatchResult(), 1); - if (replacement == null) { - - } - //Logger.INFO("Replacing "+iStack.getDisplayName()+" with "+replacement.getDisplayName()+"."); - final ItemStack tempTransform = replacement.copy(); - if (iStack.stackSize > 1){ - int u = iStack.stackSize; - tempTransform.stackSize = u; - ((EntityPlayer) entityHolding).inventory.addItemStackToInventory((tempTransform)); - for (int l=0;l= 990) { + if (NBTUtils.hasKey(iStack, "size")) { + if ((NBTUtils.getInteger(iStack, "size") + 1) >= MathUtils.randInt(0, 9)) { + ItemStack replacement = ItemUtils.getSimpleStack(getHatchResult(), 1); + if (replacement == null) {} - @Override - public String getItemStackDisplayName(ItemStack aStack) { - String localName = super.getItemStackDisplayName(aStack); - /*if (aStack.getTagCompound() == null){ - createNBT(null, aStack); - Logger.INFO("Egg has no NBT, creating (getDisplayName)"); - }*/ - int size = 1; - if (NBTUtils.hasKey(aStack, "size")){ - size = NBTUtils.getInteger(aStack, "size"); - return ""+size+" "+localName; - } - return "?? "+localName; - } + // Logger.INFO("Replacing "+iStack.getDisplayName()+" with + // "+replacement.getDisplayName()+"."); + final ItemStack tempTransform = replacement.copy(); + if (iStack.stackSize > 1) { + int u = iStack.stackSize; + tempTransform.stackSize = u; + ((EntityPlayer) entityHolding).inventory.addItemStackToInventory((tempTransform)); + for (int l = 0; l < u; l++) { + ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); + } + } else { + tempTransform.stackSize = 1; + ((EntityPlayer) entityHolding).inventory.addItemStackToInventory((tempTransform)); + ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); + } + } + } + } + } + } + } + public ItemStack getHatchResult() { + return turnsIntoItem; + } - @Override - public boolean hasCustomEntity(ItemStack stack) { - return true; - } + @Override + public String getItemStackDisplayName(ItemStack aStack) { + String localName = super.getItemStackDisplayName(aStack); + /*if (aStack.getTagCompound() == null){ + createNBT(null, aStack); + Logger.INFO("Egg has no NBT, creating (getDisplayName)"); + }*/ + int size = 1; + if (NBTUtils.hasKey(aStack, "size")) { + size = NBTUtils.getInteger(aStack, "size"); + return "" + size + " " + localName; + } + return "?? " + localName; + } - @Override - public Entity createEntity(World world, Entity location, ItemStack itemstack) { - if (location instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) location; - if (itemstack == null) { - return null; - } - else if (itemstack.stackSize == 0) { - return null; - } - else { - ItemEntityGiantEgg entityitem = new ItemEntityGiantEgg(world, player.posX, player.posY - 0.30000001192092896D + (double)player.getEyeHeight(), player.posZ, itemstack); - entityitem.delayBeforeCanPickup = 40; - entityitem.func_145799_b(player.getCommandSenderName()); - float f = 0.1F; - float f1; - f = 0.3F; - entityitem.motionX = (double)(-MathHelper.sin(player.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(player.rotationPitch / 180.0F * (float)Math.PI) * f); - entityitem.motionZ = (double)(MathHelper.cos(player.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(player.rotationPitch / 180.0F * (float)Math.PI) * f); - entityitem.motionY = (double)(-MathHelper.sin(player.rotationPitch / 180.0F * (float)Math.PI) * f + 0.1F); - f = 0.02F; - f1 = RANDOM.nextFloat() * (float)Math.PI * 2.0F; - f *= RANDOM.nextFloat(); - entityitem.motionX += Math.cos((double)f1) * (double)f; - entityitem.motionY += (double)((RANDOM.nextFloat() - RANDOM.nextFloat()) * 0.1F); - entityitem.motionZ += Math.sin((double)f1) * (double)f; - return entityitem; - } - } - return null; - } + @Override + public boolean hasCustomEntity(ItemStack stack) { + return true; + } - @Override - public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { - int size = 0; - long age = 0; - long life = 0; - int expected = 0; - if (this.descriptionString.length > 0) { - list.add(EnumChatFormatting.GRAY+this.descriptionString[0]); - } - if (NBTUtils.hasKey(stack, "size")){ - size = NBTUtils.getInteger(stack, "size"); - if (size > 0 && NBTUtils.hasKey(stack, "TickableItem")){ - NBTTagCompound aNBT = stack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("TickableItem"); - if (aNBT != null) { - age = aNBT.getLong("Tick"); - } - } - } - if (NBTUtils.hasKey(stack, "mEggAge")){ - life = NBTUtils.getInteger(stack, "mEggAge"); - } - if (NBTUtils.hasKey(stack, "mExpected")){ - expected = NBTUtils.getInteger(stack, "mExpected"); - } - } - String aSize = size > 0 ? ""+size : "??"; - String aExpected = expected > 0 ? ""+expected : "??"; - String aAge = age > 0 ? ""+(age/20) : "??"; - String aLife = life > 0 ? ""+(life/20) : "??"; - list.add("Egg Size: "+aSize+" ounces"); - list.add("Expected Stem Cells: "+aExpected); - list.add("Age: "+aAge+"s"+" / "+aLife+"s"); - list.add("Larger eggs take longer to hatch,"); - list.add("but have a better chance of hatching."); - - } + @Override + public Entity createEntity(World world, Entity location, ItemStack itemstack) { + if (location instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) location; + if (itemstack == null) { + return null; + } else if (itemstack.stackSize == 0) { + return null; + } else { + ItemEntityGiantEgg entityitem = new ItemEntityGiantEgg( + world, + player.posX, + player.posY - 0.30000001192092896D + (double) player.getEyeHeight(), + player.posZ, + itemstack); + entityitem.delayBeforeCanPickup = 40; + entityitem.func_145799_b(player.getCommandSenderName()); + float f = 0.1F; + float f1; + f = 0.3F; + entityitem.motionX = (double) (-MathHelper.sin(player.rotationYaw / 180.0F * (float) Math.PI) + * MathHelper.cos(player.rotationPitch / 180.0F * (float) Math.PI) + * f); + entityitem.motionZ = (double) (MathHelper.cos(player.rotationYaw / 180.0F * (float) Math.PI) + * MathHelper.cos(player.rotationPitch / 180.0F * (float) Math.PI) + * f); + entityitem.motionY = + (double) (-MathHelper.sin(player.rotationPitch / 180.0F * (float) Math.PI) * f + 0.1F); + f = 0.02F; + f1 = RANDOM.nextFloat() * (float) Math.PI * 2.0F; + f *= RANDOM.nextFloat(); + entityitem.motionX += Math.cos((double) f1) * (double) f; + entityitem.motionY += (double) ((RANDOM.nextFloat() - RANDOM.nextFloat()) * 0.1F); + entityitem.motionZ += Math.sin((double) f1) * (double) f; + return entityitem; + } + } + return null; + } + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + int size = 0; + long age = 0; + long life = 0; + int expected = 0; + if (this.descriptionString.length > 0) { + list.add(EnumChatFormatting.GRAY + this.descriptionString[0]); + } + if (NBTUtils.hasKey(stack, "size")) { + size = NBTUtils.getInteger(stack, "size"); + if (size > 0 && NBTUtils.hasKey(stack, "TickableItem")) { + NBTTagCompound aNBT = stack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("TickableItem"); + if (aNBT != null) { + age = aNBT.getLong("Tick"); + } + } + } + if (NBTUtils.hasKey(stack, "mEggAge")) { + life = NBTUtils.getInteger(stack, "mEggAge"); + } + if (NBTUtils.hasKey(stack, "mExpected")) { + expected = NBTUtils.getInteger(stack, "mExpected"); + } + } + String aSize = size > 0 ? "" + size : "??"; + String aExpected = expected > 0 ? "" + expected : "??"; + String aAge = age > 0 ? "" + (age / 20) : "??"; + String aLife = life > 0 ? "" + (life / 20) : "??"; + list.add("Egg Size: " + aSize + " ounces"); + list.add("Expected Stem Cells: " + aExpected); + list.add("Age: " + aAge + "s" + " / " + aLife + "s"); + list.add("Larger eggs take longer to hatch,"); + list.add("but have a better chance of hatching."); + } } diff --git a/src/main/java/gtPlusPlus/core/item/general/ItemHalfCompleteCasings.java b/src/main/java/gtPlusPlus/core/item/general/ItemHalfCompleteCasings.java index ad9abc8ab2..aa3d5b62e1 100644 --- a/src/main/java/gtPlusPlus/core/item/general/ItemHalfCompleteCasings.java +++ b/src/main/java/gtPlusPlus/core/item/general/ItemHalfCompleteCasings.java @@ -1,63 +1,62 @@ package gtPlusPlus.core.item.general; +import gtPlusPlus.core.item.base.BaseItemColourable; +import gtPlusPlus.core.util.Utils; import java.util.List; - import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; -import gtPlusPlus.core.item.base.BaseItemColourable; -import gtPlusPlus.core.util.Utils; +public class ItemHalfCompleteCasings extends BaseItemColourable { -public class ItemHalfCompleteCasings extends BaseItemColourable{ + public ItemHalfCompleteCasings( + String unlocalizedName, + CreativeTabs creativeTab, + int stackSize, + int maxDmg, + String description, + EnumRarity regRarity, + EnumChatFormatting colour, + boolean Effect, + int rgb) { + super(unlocalizedName, creativeTab, stackSize, maxDmg, description, regRarity, colour, Effect, rgb); + } - public ItemHalfCompleteCasings(String unlocalizedName, CreativeTabs creativeTab, int stackSize, int maxDmg, - String description, EnumRarity regRarity, EnumChatFormatting colour, boolean Effect, int rgb) { - super(unlocalizedName, creativeTab, stackSize, maxDmg, description, regRarity, colour, Effect, rgb); - } - - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < 4; i ++) { - list.add(new ItemStack(item, 1, i)); - } - } - - @Override - public String getItemStackDisplayName(final ItemStack tItem) { - String prefix = super.getItemStackDisplayName(tItem); - String casingType = ""; - if (tItem.getItemDamage() == 0){ - casingType = " I"; - } - else if (tItem.getItemDamage() == 1){ - casingType = " II"; - } - else if (tItem.getItemDamage() == 2){ - casingType = " III"; - } - else if (tItem.getItemDamage() == 3){ - casingType = " IV"; - } - return (prefix+casingType); - } + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 4; i++) { + list.add(new ItemStack(item, 1, i)); + } + } - @Override - public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { - if (this.getDamage(stack)==0){ - return Utils.rgbtoHexValue(52, 52, 52); - } - else if (this.getDamage(stack)==1){ - return Utils.rgbtoHexValue(80, 90, 222); - } - else if (this.getDamage(stack)==2){ - return Utils.rgbtoHexValue(182, 77, 177); - } - else { - return Utils.rgbtoHexValue(77, 175, 182); - } - } + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + String prefix = super.getItemStackDisplayName(tItem); + String casingType = ""; + if (tItem.getItemDamage() == 0) { + casingType = " I"; + } else if (tItem.getItemDamage() == 1) { + casingType = " II"; + } else if (tItem.getItemDamage() == 2) { + casingType = " III"; + } else if (tItem.getItemDamage() == 3) { + casingType = " IV"; + } + return (prefix + casingType); + } + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (this.getDamage(stack) == 0) { + return Utils.rgbtoHexValue(52, 52, 52); + } else if (this.getDamage(stack) == 1) { + return Utils.rgbtoHexValue(80, 90, 222); + } else if (this.getDamage(stack) == 2) { + return Utils.rgbtoHexValue(182, 77, 177); + } else { + return Utils.rgbtoHexValue(77, 175, 182); + } + } } diff --git a/src/main/java/gtPlusPlus/core/item/general/ItemHealingDevice.java b/src/main/java/gtPlusPlus/core/item/general/ItemHealingDevice.java index ac7a149f3c..c1f316c38f 100644 --- a/src/main/java/gtPlusPlus/core/item/general/ItemHealingDevice.java +++ b/src/main/java/gtPlusPlus/core/item/general/ItemHealingDevice.java @@ -1,7 +1,5 @@ package gtPlusPlus.core.item.general; -import java.util.List; - import baubles.api.BaubleType; import baubles.api.IBauble; import cpw.mods.fml.common.Optional; @@ -16,6 +14,7 @@ import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.core.util.sys.KeyboardUtils; import gtPlusPlus.xmod.gregtech.common.helpers.ChargingHelper; import ic2.api.item.*; +import java.util.List; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -25,363 +24,390 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.*; import net.minecraft.world.World; -@Optional.InterfaceList(value = {@Optional.Interface(iface = "baubles.api.IBauble", modid = "Baubles"), @Optional.Interface(iface = "baubles.api.BaubleType", modid = "Baubles")}) -public class ItemHealingDevice extends Item implements IElectricItem, IElectricItemManager, IBauble{ - - private final String unlocalizedName = "personalHealingDevice"; - private final static int maxValueEU = 1000000000; - protected double chargeEU = 0; - - public ItemHealingDevice(){ - this.setCreativeTab(AddToCreativeTab.tabMachines); - this.setUnlocalizedName(this.unlocalizedName); - this.setMaxStackSize(1); - this.setTextureName(CORE.MODID + ":" + "personalCloakingDevice"); - GameRegistry.registerItem(this, this.unlocalizedName); - } - - @Override - public void onUpdate(final ItemStack itemStack, final World worldObj, final Entity player, final int p_77663_4_, final boolean p_77663_5_) { - if (worldObj.isRemote) { - return; - } - super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); - } - - @Override - public boolean canProvideEnergy(final ItemStack itemStack) { - return false; - } - - @Override - public Item getChargedItem(final ItemStack itemStack) { - final ItemStack x = itemStack.copy(); - x.setItemDamage(maxValueEU); - return x.getItem(); - } - - @Override - public Item getEmptyItem(final ItemStack itemStack) { - final ItemStack x = itemStack.copy(); - x.setItemDamage(0); - return x.getItem(); - } - - @Override - public double getMaxCharge(final ItemStack itemStack) { - return maxValueEU; - } - - @Override - public int getTier(final ItemStack itemStack) { - return 5; - } - - @Override - public double getTransferLimit(final ItemStack itemStack) { - return GT_Values.V[7]; - } - - @Override - public String getItemStackDisplayName(final ItemStack p_77653_1_) { - - return (EnumChatFormatting.BLUE + "Personal Healing NanoBooster" + EnumChatFormatting.RESET); - } - - @Override - public double getDurabilityForDisplay(final ItemStack stack) { - // return 1.0D - getEnergyStored(stack) / this.capacity; - return 1.0D - (this.getCharge(stack) / this.getMaxCharge(stack)); - } - - @Override - public boolean showDurabilityBar(final ItemStack stack) { - return true; - } - - public double secondsLeft(final ItemStack stack) { - - double r = 0; - r = this.getCharge(stack) / (1638400 / 4); - return (int) r; - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - - String aString1 = StatCollector.translateToLocal("GTPP.nanohealer.tooltip.1"); - String aString2 = StatCollector.translateToLocal("GTPP.nanohealer.tooltip.2"); - String aString3 = StatCollector.translateToLocal("GTPP.nanohealer.tooltip.3"); - String aString4 = StatCollector.translateToLocal("GTPP.nanohealer.tooltip.4"); - String aString5 = StatCollector.translateToLocal("GTPP.nanohealer.tooltip.5"); - String aStringTooltip = StatCollector.translateToLocal("GTPP.nanohealer.hidden"); - String aEuInfo = StatCollector.translateToLocal("GTPP.info.euInfo"); - String aTier = StatCollector.translateToLocal("GTPP.machines.tier"); - String aInputLimit = StatCollector.translateToLocal("GTPP.info.inputLimit"); - String aCurrentPower = StatCollector.translateToLocal("GTPP.info.currentPower"); - String aEU = StatCollector.translateToLocal("GTPP.info.eu"); - String aEUT = aEU+"/t"; - boolean isShowing = getShowMessages(stack); - - list.add(""); - - list.add(EnumChatFormatting.GREEN + aString1 + EnumChatFormatting.GRAY); - list.add(EnumChatFormatting.GREEN + aString2 + EnumChatFormatting.GRAY); - list.add(EnumChatFormatting.GREEN + aString3 + EnumChatFormatting.GRAY); - list.add(EnumChatFormatting.RED + aString4 + EnumChatFormatting.GRAY); - - list.add(""); - - list.add(EnumChatFormatting.GOLD + aEuInfo + EnumChatFormatting.GRAY); - list.add(EnumChatFormatting.GRAY + aTier+": [" + EnumChatFormatting.YELLOW + this.getTier(stack) - + EnumChatFormatting.GRAY + "] "+aInputLimit+": [" + EnumChatFormatting.YELLOW - + this.getTransferLimit(stack) + EnumChatFormatting.GRAY + aEUT+"]"); - list.add(EnumChatFormatting.GRAY + aCurrentPower +": [" + EnumChatFormatting.YELLOW + (long) this.getCharge(stack) - + EnumChatFormatting.GRAY + aEU +"] [" + EnumChatFormatting.YELLOW - + MathUtils.findPercentage(this.getCharge(stack), this.getMaxCharge(stack)) + EnumChatFormatting.GRAY - + "%]"); - list.add(EnumChatFormatting.GOLD + aString5 + EnumChatFormatting.GRAY); - list.add(EnumChatFormatting.GOLD + aStringTooltip + " " + (!isShowing ? EnumChatFormatting.DARK_GREEN : EnumChatFormatting.DARK_RED) + !isShowing + EnumChatFormatting.GRAY); - super.addInformation(stack, aPlayer, list, bool); - } - - @Override - public double charge(final ItemStack stack, final double amount, final int tier, - final boolean ignoreTransferLimit, final boolean simulate) { - - if (!simulate) - { - ElectricItem.manager.charge(stack, amount, tier, true, simulate); - - } - return ElectricItem.manager.charge(stack, amount, tier, true, simulate); - } - - @Override - public double discharge(final ItemStack stack, final double amount, final int tier, - final boolean ignoreTransferLimit, final boolean externally, final boolean simulate) { - if (!simulate) - { - ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate); - } - - return ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate); - } - - @Override - public double getCharge(final ItemStack stack) { - return ElectricItem.manager.getCharge(stack); - } - - @Override - public boolean canUse(final ItemStack stack, final double amount) { - return ElectricItem.manager.canUse(stack, amount); - } - - @Override - public boolean use(final ItemStack stack, final double amount, final EntityLivingBase entity) { - return ElectricItem.manager.use(stack, amount, entity); - } - - @Override - public void chargeFromArmor(final ItemStack stack, final EntityLivingBase entity) { - ElectricItem.manager.chargeFromArmor(stack, entity); - } - - @Override - public String getToolTip(final ItemStack stack) { - return ElectricItem.manager.getToolTip(stack); - } - - @Override - public boolean canEquip(final ItemStack arg0, final EntityLivingBase arg1) { - return true; - } - - @Override - public boolean canUnequip(final ItemStack arg0, final EntityLivingBase arg1) { - return true; - } - - @Override - public BaubleType getBaubleType(final ItemStack arg0) { - return BaubleType.AMULET; - } - - @Override //TODO - public void onEquipped(final ItemStack arg0, final EntityLivingBase arg1) { - - } - - @Override //TODO - public void onUnequipped(final ItemStack arg0, final EntityLivingBase arg1) { - - } - - @Override //TODO - public void onWornTick(final ItemStack aBaubleStack, final EntityLivingBase arg1) { - if (arg1 != null && arg1.worldObj != null && !arg1.worldObj.isRemote){ - - //Try Charge First - - //Inv Slots - for (final ItemStack aInvStack : ((EntityPlayer) arg1).inventory.mainInventory) { - if (aInvStack == aBaubleStack) { - continue; - } - - if (this.getCharge(aBaubleStack) == this.getMaxCharge(aBaubleStack)) { - break; - } - - if (aInvStack != null) { - if (ChargingHelper.isItemValid(aInvStack)) { - - - double aTransferRate; - double aCurrentChargeForThisBauble; - int mTier; - final IElectricItem electricItem = (IElectricItem) aInvStack.getItem(); - - if (electricItem != null) { - - aTransferRate = electricItem.getTransferLimit(aInvStack); - mTier = electricItem.getTier(aInvStack); - aCurrentChargeForThisBauble = ElectricItem.manager.getCharge(aBaubleStack); - - if (aCurrentChargeForThisBauble < maxValueEU) { - if ((ElectricItem.manager.getCharge(aInvStack) >= aTransferRate)) { - if (electricItem.canProvideEnergy(aInvStack)) { - double d = ElectricItem.manager.discharge(aInvStack, aTransferRate, mTier, false, true, false); - //Logger.INFO("Charging from "+aInvStack.getDisplayName() +" | "+d); - ElectricItem.manager.charge(aBaubleStack, d, mTier, true, false); - } - } - } - } - } - } - if (this.getCharge(aBaubleStack) <= (this.getMaxCharge(aBaubleStack) - getTransferLimit(aBaubleStack))) { - continue; - } - else { - break; - } - } - - - //Try Heal - if (this.getCharge(aBaubleStack) > 0){ - - if (!(arg1 instanceof EntityPlayer)) { - return; - } - EntityPlayer g = (EntityPlayer) arg1; - //health Check - float hp = 0; - if (arg1.getHealth() < arg1.getMaxHealth()){ - final float rx = arg1.getMaxHealth()-arg1.getHealth(); - Logger.INFO("rx:"+rx); - arg1.heal(rx*2); - hp = rx; - this.discharge(aBaubleStack, (1638400)*rx, 6, true, true, false); - } - - int hunger = 0; - float saturation = 0; - FoodStats aFood = g.getFoodStats(); - if (aFood != null) { - //Hunger Check - hunger = 20 - aFood.getFoodLevel(); - this.discharge(aBaubleStack, (1638400) * hunger, 6, true, true, false); - // Saturation Check - saturation = 20f - aFood.getSaturationLevel(); - this.discharge(aBaubleStack, (1638400) * saturation, 6, true, true, false); - aFood.addStats(hunger, saturation); - } - - //Only show Messages if they're enabled. - if (getShowMessages(aBaubleStack)) { - if (hp > 0 || hunger > 0 || saturation > 0) - PlayerUtils.messagePlayer((EntityPlayer) arg1, - "Your NanoBooster Whirs! Leaving you feeling stronger."); - - if (hp > 0) - PlayerUtils.messagePlayer((EntityPlayer) arg1, "Healed " + hp + " hp."); - - if (hunger > 0) - PlayerUtils.messagePlayer((EntityPlayer) arg1, "Healed " + hunger + " hunger."); - - if (saturation > 0) - PlayerUtils.messagePlayer((EntityPlayer) arg1, "Satured Hunger by " + saturation + "."); - - if (hp > 0 || hunger > 0 || saturation > 0) - PlayerUtils.messagePlayer((EntityPlayer) arg1, - "You check it's remaining uses, it has " + (int) this.secondsLeft(aBaubleStack) + "."); - } - } - } - } - - private static boolean createNBT(ItemStack rStack){ - final NBTTagCompound tagMain = new NBTTagCompound(); - tagMain.setBoolean("ShowMSG", false); - rStack.setTagCompound(tagMain); - return true; - } - - public static final boolean getShowMessages(final ItemStack aStack) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT == null) { - if (!createNBT(aStack)) { - return false; - } - else { - aNBT = aStack.getTagCompound(); - } - } - return aNBT.getBoolean("ShowMSG"); - - } - - public static final boolean setShowMessages(final ItemStack aStack, final boolean aShow) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT == null) { - if (!createNBT(aStack)) { - return false; - } else { - aNBT = aStack.getTagCompound(); - } - } - aNBT.setBoolean("ShowMSG", aShow); - return true; - } - - @Override - public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, - int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { - // TODO Auto-generated method stub - return super.onItemUse(p_77648_1_, p_77648_2_, p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_8_, - p_77648_9_, p_77648_10_); - } - - @Override - public ItemStack onItemRightClick(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { - ItemStack superStack = super.onItemRightClick(aStack, aWorld, aPlayer); - boolean isShiftHeld = KeyboardUtils.isShiftKeyDown(); - if (isShiftHeld) { - boolean oldState = getShowMessages(superStack); - boolean newState = Utils.invertBoolean(oldState); - ItemHealingDevice.setShowMessages(superStack, newState); - PlayerUtils.messagePlayer(aPlayer, (!oldState ? "Showing info messages" : "Hiding info messages")); - } - return superStack; - } - - @Override - public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) { - return true; - } - +@Optional.InterfaceList( + value = { + @Optional.Interface(iface = "baubles.api.IBauble", modid = "Baubles"), + @Optional.Interface(iface = "baubles.api.BaubleType", modid = "Baubles") + }) +public class ItemHealingDevice extends Item implements IElectricItem, IElectricItemManager, IBauble { + + private final String unlocalizedName = "personalHealingDevice"; + private static final int maxValueEU = 1000000000; + protected double chargeEU = 0; + + public ItemHealingDevice() { + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setUnlocalizedName(this.unlocalizedName); + this.setMaxStackSize(1); + this.setTextureName(CORE.MODID + ":" + "personalCloakingDevice"); + GameRegistry.registerItem(this, this.unlocalizedName); + } + + @Override + public void onUpdate( + final ItemStack itemStack, + final World worldObj, + final Entity player, + final int p_77663_4_, + final boolean p_77663_5_) { + if (worldObj.isRemote) { + return; + } + super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); + } + + @Override + public boolean canProvideEnergy(final ItemStack itemStack) { + return false; + } + + @Override + public Item getChargedItem(final ItemStack itemStack) { + final ItemStack x = itemStack.copy(); + x.setItemDamage(maxValueEU); + return x.getItem(); + } + + @Override + public Item getEmptyItem(final ItemStack itemStack) { + final ItemStack x = itemStack.copy(); + x.setItemDamage(0); + return x.getItem(); + } + + @Override + public double getMaxCharge(final ItemStack itemStack) { + return maxValueEU; + } + + @Override + public int getTier(final ItemStack itemStack) { + return 5; + } + + @Override + public double getTransferLimit(final ItemStack itemStack) { + return GT_Values.V[7]; + } + + @Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + + return (EnumChatFormatting.BLUE + "Personal Healing NanoBooster" + EnumChatFormatting.RESET); + } + + @Override + public double getDurabilityForDisplay(final ItemStack stack) { + // return 1.0D - getEnergyStored(stack) / this.capacity; + return 1.0D - (this.getCharge(stack) / this.getMaxCharge(stack)); + } + + @Override + public boolean showDurabilityBar(final ItemStack stack) { + return true; + } + + public double secondsLeft(final ItemStack stack) { + + double r = 0; + r = this.getCharge(stack) / (1638400 / 4); + return (int) r; + } + + @SuppressWarnings({"rawtypes", "unchecked"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + + String aString1 = StatCollector.translateToLocal("GTPP.nanohealer.tooltip.1"); + String aString2 = StatCollector.translateToLocal("GTPP.nanohealer.tooltip.2"); + String aString3 = StatCollector.translateToLocal("GTPP.nanohealer.tooltip.3"); + String aString4 = StatCollector.translateToLocal("GTPP.nanohealer.tooltip.4"); + String aString5 = StatCollector.translateToLocal("GTPP.nanohealer.tooltip.5"); + String aStringTooltip = StatCollector.translateToLocal("GTPP.nanohealer.hidden"); + String aEuInfo = StatCollector.translateToLocal("GTPP.info.euInfo"); + String aTier = StatCollector.translateToLocal("GTPP.machines.tier"); + String aInputLimit = StatCollector.translateToLocal("GTPP.info.inputLimit"); + String aCurrentPower = StatCollector.translateToLocal("GTPP.info.currentPower"); + String aEU = StatCollector.translateToLocal("GTPP.info.eu"); + String aEUT = aEU + "/t"; + boolean isShowing = getShowMessages(stack); + + list.add(""); + + list.add(EnumChatFormatting.GREEN + aString1 + EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GREEN + aString2 + EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GREEN + aString3 + EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.RED + aString4 + EnumChatFormatting.GRAY); + + list.add(""); + + list.add(EnumChatFormatting.GOLD + aEuInfo + EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GRAY + aTier + ": [" + EnumChatFormatting.YELLOW + this.getTier(stack) + + EnumChatFormatting.GRAY + "] " + aInputLimit + ": [" + EnumChatFormatting.YELLOW + + this.getTransferLimit(stack) + EnumChatFormatting.GRAY + aEUT + "]"); + list.add(EnumChatFormatting.GRAY + aCurrentPower + ": [" + EnumChatFormatting.YELLOW + + (long) this.getCharge(stack) + + EnumChatFormatting.GRAY + aEU + "] [" + EnumChatFormatting.YELLOW + + MathUtils.findPercentage(this.getCharge(stack), this.getMaxCharge(stack)) + EnumChatFormatting.GRAY + + "%]"); + list.add(EnumChatFormatting.GOLD + aString5 + EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GOLD + aStringTooltip + " " + + (!isShowing ? EnumChatFormatting.DARK_GREEN : EnumChatFormatting.DARK_RED) + !isShowing + + EnumChatFormatting.GRAY); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public double charge( + final ItemStack stack, + final double amount, + final int tier, + final boolean ignoreTransferLimit, + final boolean simulate) { + + if (!simulate) { + ElectricItem.manager.charge(stack, amount, tier, true, simulate); + } + return ElectricItem.manager.charge(stack, amount, tier, true, simulate); + } + + @Override + public double discharge( + final ItemStack stack, + final double amount, + final int tier, + final boolean ignoreTransferLimit, + final boolean externally, + final boolean simulate) { + if (!simulate) { + ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate); + } + + return ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate); + } + + @Override + public double getCharge(final ItemStack stack) { + return ElectricItem.manager.getCharge(stack); + } + + @Override + public boolean canUse(final ItemStack stack, final double amount) { + return ElectricItem.manager.canUse(stack, amount); + } + + @Override + public boolean use(final ItemStack stack, final double amount, final EntityLivingBase entity) { + return ElectricItem.manager.use(stack, amount, entity); + } + + @Override + public void chargeFromArmor(final ItemStack stack, final EntityLivingBase entity) { + ElectricItem.manager.chargeFromArmor(stack, entity); + } + + @Override + public String getToolTip(final ItemStack stack) { + return ElectricItem.manager.getToolTip(stack); + } + + @Override + public boolean canEquip(final ItemStack arg0, final EntityLivingBase arg1) { + return true; + } + + @Override + public boolean canUnequip(final ItemStack arg0, final EntityLivingBase arg1) { + return true; + } + + @Override + public BaubleType getBaubleType(final ItemStack arg0) { + return BaubleType.AMULET; + } + + @Override // TODO + public void onEquipped(final ItemStack arg0, final EntityLivingBase arg1) {} + + @Override // TODO + public void onUnequipped(final ItemStack arg0, final EntityLivingBase arg1) {} + + @Override // TODO + public void onWornTick(final ItemStack aBaubleStack, final EntityLivingBase arg1) { + if (arg1 != null && arg1.worldObj != null && !arg1.worldObj.isRemote) { + + // Try Charge First + + // Inv Slots + for (final ItemStack aInvStack : ((EntityPlayer) arg1).inventory.mainInventory) { + if (aInvStack == aBaubleStack) { + continue; + } + + if (this.getCharge(aBaubleStack) == this.getMaxCharge(aBaubleStack)) { + break; + } + + if (aInvStack != null) { + if (ChargingHelper.isItemValid(aInvStack)) { + + double aTransferRate; + double aCurrentChargeForThisBauble; + int mTier; + final IElectricItem electricItem = (IElectricItem) aInvStack.getItem(); + + if (electricItem != null) { + + aTransferRate = electricItem.getTransferLimit(aInvStack); + mTier = electricItem.getTier(aInvStack); + aCurrentChargeForThisBauble = ElectricItem.manager.getCharge(aBaubleStack); + + if (aCurrentChargeForThisBauble < maxValueEU) { + if ((ElectricItem.manager.getCharge(aInvStack) >= aTransferRate)) { + if (electricItem.canProvideEnergy(aInvStack)) { + double d = ElectricItem.manager.discharge( + aInvStack, aTransferRate, mTier, false, true, false); + // Logger.INFO("Charging from "+aInvStack.getDisplayName() +" | "+d); + ElectricItem.manager.charge(aBaubleStack, d, mTier, true, false); + } + } + } + } + } + } + if (this.getCharge(aBaubleStack) + <= (this.getMaxCharge(aBaubleStack) - getTransferLimit(aBaubleStack))) { + continue; + } else { + break; + } + } + + // Try Heal + if (this.getCharge(aBaubleStack) > 0) { + + if (!(arg1 instanceof EntityPlayer)) { + return; + } + EntityPlayer g = (EntityPlayer) arg1; + // health Check + float hp = 0; + if (arg1.getHealth() < arg1.getMaxHealth()) { + final float rx = arg1.getMaxHealth() - arg1.getHealth(); + Logger.INFO("rx:" + rx); + arg1.heal(rx * 2); + hp = rx; + this.discharge(aBaubleStack, (1638400) * rx, 6, true, true, false); + } + + int hunger = 0; + float saturation = 0; + FoodStats aFood = g.getFoodStats(); + if (aFood != null) { + // Hunger Check + hunger = 20 - aFood.getFoodLevel(); + this.discharge(aBaubleStack, (1638400) * hunger, 6, true, true, false); + // Saturation Check + saturation = 20f - aFood.getSaturationLevel(); + this.discharge(aBaubleStack, (1638400) * saturation, 6, true, true, false); + aFood.addStats(hunger, saturation); + } + + // Only show Messages if they're enabled. + if (getShowMessages(aBaubleStack)) { + if (hp > 0 || hunger > 0 || saturation > 0) + PlayerUtils.messagePlayer( + (EntityPlayer) arg1, "Your NanoBooster Whirs! Leaving you feeling stronger."); + + if (hp > 0) PlayerUtils.messagePlayer((EntityPlayer) arg1, "Healed " + hp + " hp."); + + if (hunger > 0) PlayerUtils.messagePlayer((EntityPlayer) arg1, "Healed " + hunger + " hunger."); + + if (saturation > 0) + PlayerUtils.messagePlayer((EntityPlayer) arg1, "Satured Hunger by " + saturation + "."); + + if (hp > 0 || hunger > 0 || saturation > 0) + PlayerUtils.messagePlayer( + (EntityPlayer) arg1, + "You check it's remaining uses, it has " + (int) this.secondsLeft(aBaubleStack) + "."); + } + } + } + } + + private static boolean createNBT(ItemStack rStack) { + final NBTTagCompound tagMain = new NBTTagCompound(); + tagMain.setBoolean("ShowMSG", false); + rStack.setTagCompound(tagMain); + return true; + } + + public static final boolean getShowMessages(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT == null) { + if (!createNBT(aStack)) { + return false; + } else { + aNBT = aStack.getTagCompound(); + } + } + return aNBT.getBoolean("ShowMSG"); + } + + public static final boolean setShowMessages(final ItemStack aStack, final boolean aShow) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT == null) { + if (!createNBT(aStack)) { + return false; + } else { + aNBT = aStack.getTagCompound(); + } + } + aNBT.setBoolean("ShowMSG", aShow); + return true; + } + + @Override + public boolean onItemUse( + ItemStack p_77648_1_, + EntityPlayer p_77648_2_, + World p_77648_3_, + int p_77648_4_, + int p_77648_5_, + int p_77648_6_, + int p_77648_7_, + float p_77648_8_, + float p_77648_9_, + float p_77648_10_) { + // TODO Auto-generated method stub + return super.onItemUse( + p_77648_1_, + p_77648_2_, + p_77648_3_, + p_77648_4_, + p_77648_5_, + p_77648_6_, + p_77648_7_, + p_77648_8_, + p_77648_9_, + p_77648_10_); + } + + @Override + public ItemStack onItemRightClick(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { + ItemStack superStack = super.onItemRightClick(aStack, aWorld, aPlayer); + boolean isShiftHeld = KeyboardUtils.isShiftKeyDown(); + if (isShiftHeld) { + boolean oldState = getShowMessages(superStack); + boolean newState = Utils.invertBoolean(oldState); + ItemHealingDevice.setShowMessages(superStack, newState); + PlayerUtils.messagePlayer(aPlayer, (!oldState ? "Showing info messages" : "Hiding info messages")); + } + return superStack; + } + + @Override + public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) { + return true; + } } diff --git a/src/main/java/gtPlusPlus/core/item/general/ItemLavaFilter.java b/src/main/java/gtPlusPlus/core/item/general/ItemLavaFilter.java index c34ad9e8d3..79076ec571 100644 --- a/src/main/java/gtPlusPlus/core/item/general/ItemLavaFilter.java +++ b/src/main/java/gtPlusPlus/core/item/general/ItemLavaFilter.java @@ -1,7 +1,10 @@ package gtPlusPlus.core.item.general; +import gregtech.api.enums.ItemList; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.CoreItem; +import gtPlusPlus.core.lib.CORE; import java.util.List; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; @@ -10,118 +13,112 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; -import gregtech.api.enums.ItemList; +public class ItemLavaFilter extends CoreItem { -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.item.base.CoreItem; -import gtPlusPlus.core.lib.CORE; + public IIcon[] mIcon = new IIcon[1]; -public class ItemLavaFilter extends CoreItem { + public ItemLavaFilter() { + super( + "itemLavaFilter", + AddToCreativeTab.tabMachines, + 1, + 100, + new String[] {"Lava Filter"}, + EnumRarity.common, + EnumChatFormatting.BLACK, + false, + null); + setGregtechItemList(); + } - public IIcon[] mIcon = new IIcon[1]; - - public ItemLavaFilter() { - super("itemLavaFilter", AddToCreativeTab.tabMachines, 1, 100, new String[] {"Lava Filter"}, EnumRarity.common, - EnumChatFormatting.BLACK, false, null); - setGregtechItemList(); - } + private final boolean setGregtechItemList() { + ItemList.Component_LavaFilter.set(this); + return ItemList.Component_LavaFilter.get(1) != null ? true : false; + } - private final boolean setGregtechItemList() { - ItemList.Component_LavaFilter.set(this); - return ItemList.Component_LavaFilter.get(1) != null ? true : false; - } - - @Override - public void registerIcons(IIconRegister reg) { - this.mIcon[0] = reg.registerIcon(CORE.MODID + ":" + "itemLavaFilter"); - } + @Override + public void registerIcons(IIconRegister reg) { + this.mIcon[0] = reg.registerIcon(CORE.MODID + ":" + "itemLavaFilter"); + } - @Override - public IIcon getIconFromDamage(int meta) { - return this.mIcon[0]; - } + @Override + public IIcon getIconFromDamage(int meta) { + return this.mIcon[0]; + } - @Override - public String getItemStackDisplayName(ItemStack tItem) { - return "Lava Filter"; - } - - private static boolean createNBT(ItemStack rStack){ - final NBTTagCompound tagMain = new NBTTagCompound(); - final NBTTagCompound tagNBT = new NBTTagCompound(); - tagNBT.setLong("Damage", 0); - tagMain.setTag("LavaFilter", tagNBT); - rStack.setTagCompound(tagMain); - return true; - } - - public static final long getFilterDamage(final ItemStack aStack) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("LavaFilter"); - if (aNBT != null) { - return aNBT.getLong("Damage"); - } - } - else { - createNBT(aStack); - } - return 0L; - } + @Override + public String getItemStackDisplayName(ItemStack tItem) { + return "Lava Filter"; + } - public static final boolean setFilterDamage(final ItemStack aStack, final long aDamage) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("LavaFilter"); - if (aNBT != null) { - aNBT.setLong("Damage", aDamage); - return true; - } - } - else { - createNBT(aStack); - } - return false; - } + private static boolean createNBT(ItemStack rStack) { + final NBTTagCompound tagMain = new NBTTagCompound(); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setLong("Damage", 0); + tagMain.setTag("LavaFilter", tagNBT); + rStack.setTagCompound(tagMain); + return true; + } - @Override - public double getDurabilityForDisplay(ItemStack stack) { - if (stack.getTagCompound() == null){ - createNBT(stack); + public static final long getFilterDamage(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("LavaFilter"); + if (aNBT != null) { + return aNBT.getLong("Damage"); + } + } else { + createNBT(aStack); } - double currentDamage = getFilterDamage(stack); - double durabilitypercent = currentDamage / 100; - return durabilitypercent; - } + return 0L; + } - @SuppressWarnings("unchecked") - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { - list.add(EnumChatFormatting.GRAY+"Filters Lava within a Thermal Boiler."); - EnumChatFormatting durability = EnumChatFormatting.GRAY; - if (100-getFilterDamage(stack) > 80){ - durability = EnumChatFormatting.GRAY; - } - else if (100-getFilterDamage(stack) > 60){ - durability = EnumChatFormatting.GREEN; - } - else if (100-getFilterDamage(stack) > 40){ - durability = EnumChatFormatting.YELLOW; - } - else if (100-getFilterDamage(stack) > 20){ - durability = EnumChatFormatting.GOLD; - } - else if (100-getFilterDamage(stack) > 0){ - durability = EnumChatFormatting.RED; - } - list.add(durability+""+(100-getFilterDamage(stack))+EnumChatFormatting.GRAY+" / "+100); - //super.addInformation(stack, player, list, bool); - } + public static final boolean setFilterDamage(final ItemStack aStack, final long aDamage) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("LavaFilter"); + if (aNBT != null) { + aNBT.setLong("Damage", aDamage); + return true; + } + } else { + createNBT(aStack); + } + return false; + } - @Override - public boolean showDurabilityBar(ItemStack stack) { - return true; - } + @Override + public double getDurabilityForDisplay(ItemStack stack) { + if (stack.getTagCompound() == null) { + createNBT(stack); + } + double currentDamage = getFilterDamage(stack); + double durabilitypercent = currentDamage / 100; + return durabilitypercent; + } + @SuppressWarnings("unchecked") + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { + list.add(EnumChatFormatting.GRAY + "Filters Lava within a Thermal Boiler."); + EnumChatFormatting durability = EnumChatFormatting.GRAY; + if (100 - getFilterDamage(stack) > 80) { + durability = EnumChatFormatting.GRAY; + } else if (100 - getFilterDamage(stack) > 60) { + durability = EnumChatFormatting.GREEN; + } else if (100 - getFilterDamage(stack) > 40) { + durability = EnumChatFormatting.YELLOW; + } else if (100 - getFilterDamage(stack) > 20) { + durability = EnumChatFormatting.GOLD; + } else if (100 - getFilterDamage(stack) > 0) { + durability = EnumChatFormatting.RED; + } + list.add(durability + "" + (100 - getFilterDamage(stack)) + EnumChatFormatting.GRAY + " / " + 100); + // super.addInformation(stack, player, list, bool); + } + @Override + public boolean showDurabilityBar(ItemStack stack) { + return true; + } } diff --git a/src/main/java/gtPlusPlus/core/item/general/ItemMagicFeather.java b/src/main/java/gtPlusPlus/core/item/general/ItemMagicFeather.java index 91b2ab2c41..feab0f0cf6 100644 --- a/src/main/java/gtPlusPlus/core/item/general/ItemMagicFeather.java +++ b/src/main/java/gtPlusPlus/core/item/general/ItemMagicFeather.java @@ -1,8 +1,5 @@ package gtPlusPlus.core.item.general; -import java.lang.ref.WeakReference; -import java.util.*; - import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; @@ -14,6 +11,8 @@ import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.item.base.CoreItem; import gtPlusPlus.core.lib.CORE; +import java.lang.ref.WeakReference; +import java.util.*; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.*; @@ -25,219 +24,233 @@ import net.minecraftforge.event.entity.living.LivingDeathEvent; public class ItemMagicFeather extends CoreItem { - public static final String NAME = "magicfeather"; - private static final WeakHashMap sPlayerData = new WeakHashMap<>(); - private static final WeakHashMap> sBeaconData = new WeakHashMap<>(); - - public ItemMagicFeather() { - super("magicfeather", AddToCreativeTab.tabMisc, 1, 100, new String[]{"Lets you fly around Beacons"}, EnumRarity.uncommon, null, false, null); - setMaxStackSize(1); - setUnlocalizedName(CORE.MODID + ":" + NAME); - MinecraftForge.EVENT_BUS.register(this); - } - - @Override - public int getEntityLifespan(ItemStack itemStack, World world) { - return Integer.MAX_VALUE; - } - - @SuppressWarnings("unchecked") - @Override - @SideOnly(Side.CLIENT) - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - list.add("Does not need to be the item held in your hand to work"); - super.addInformation(stack, aPlayer, list, bool); - list.add("Needs to be within beacon range"); - list.add("Range is beacon level * 10 + 10"); - } - - public boolean hasCustomEntity(ItemStack stack) { - return true; - } - - private static boolean isInBeaconRange(EntityPlayer player) { - World world = player.getEntityWorld(); - if (world.isRemote) { - return false; - } - HashSet aBeaconData = sBeaconData.computeIfAbsent(player, k -> new HashSet<>()); - int chunkXlo = (int) (player.posX - 50) >> 4, - chunkXhi = (int) (player.posX + 50) >> 4, - chunkZlo = (int) (player.posZ - 50) >> 4, - chunkZhi = (int) (player.posZ + 50) >> 4; - for (int chunkX = chunkXlo; chunkX < chunkXhi; chunkX++) { - for (int chunkZ = chunkZlo; chunkZ < chunkZhi; chunkZ++) { - if (!world.getChunkProvider().chunkExists(chunkX, chunkZ)) continue; - findSuitableBeacon(player, world.getChunkFromChunkCoords(chunkX, chunkZ).chunkTileEntityMap.values(), aBeaconData); - } - } - return aBeaconData.size() > 0; - } - - private static void findSuitableBeacon(EntityPlayer player, Collection tileEntities, HashSet aBeaconData) { - for (TileEntity t : tileEntities) { - if (!(t instanceof TileEntityBeacon)) { - continue; - } - TileEntityBeacon beacon = (TileEntityBeacon) t; - int level = beacon.getLevels(); - if (level == 0) { - continue; - } - int radius = (level * 10 + 10); - int x = beacon.xCoord; - int z = beacon.zCoord; - if (player.posX < (x - radius) || player.posX > (x + radius)) { - continue; - } - if (player.posZ < (z - radius) || player.posZ > (z + radius)) { - continue; - } - aBeaconData.add(beacon); - } - } - - private static void setMayFly(EntityPlayer player, boolean mayFly) { - if (player.capabilities.allowFlying == mayFly) { - return; - } - if (!mayFly) { - // force the player on the ground then remove ability to fly - // this prevent crashing the the ground and dying - // when you accidentally get out of the beacon range - player.capabilities.isFlying = false; - if (player.onGround && player.fallDistance < 1F) { - player.capabilities.allowFlying = false; - } - } - else { - player.capabilities.allowFlying = true; - } - player.sendPlayerAbilities(); - } - - @SubscribeEvent(priority=EventPriority.HIGHEST) - public void onPlayerTick(TickEvent.PlayerTickEvent event) { - if (event.side != Side.SERVER || event.phase != Phase.END) { - return; - } - EntityPlayer player = event.player; - HashSet aBeaconData = sBeaconData.get(player); - if (aBeaconData != null && !aBeaconData.isEmpty()) { - for (Iterator iterator = aBeaconData.iterator(); iterator.hasNext(); ) { - TileEntityBeacon aBeacon = iterator.next(); - int level = aBeacon.getLevels(); - if (level == 0) { - iterator.remove(); - continue; - } - int radius = (level * 10 + 10); - int x = aBeacon.xCoord; - int z = aBeacon.zCoord; - if (player.posX < (x - radius) || player.posX > (x + radius) || - player.posZ < (z - radius) || player.posZ > (z + radius)) { - iterator.remove(); - } - } - } - boolean hasItem = hasItem(player, ModItems.itemMagicFeather); - if (!hasItem) { - ItemMagicFeather.sPlayerData.remove(player); - } - MagicFeatherData data = ItemMagicFeather.sPlayerData.get(player); - if (data == null) { - data = new MagicFeatherData(player); - ItemMagicFeather.sPlayerData.put(player, data); - } - data.onTick(); - } - - @SubscribeEvent(priority=EventPriority.LOWEST) - public void onPlayerDeath(LivingDeathEvent event) { - if (event.entityLiving == null) return; - EntityLivingBase aEntity = event.entityLiving; - if (!(aEntity instanceof EntityPlayer) || aEntity.worldObj == null || aEntity.worldObj.isRemote) return; - EntityPlayer aPlayer = (EntityPlayer) aEntity; - ItemMagicFeather.sPlayerData.remove(aPlayer); - ItemMagicFeather.sBeaconData.remove(aPlayer); - } - - private static boolean hasItem(EntityPlayer player, Item item) { - for (int i = 0; i < player.inventory.getSizeInventory(); i++) { - ItemStack stack = player.inventory.getStackInSlot(i); - if (stack != null && stack.getItem() != null && stack.getItem() instanceof ItemMagicFeather) { - return true; - } - } - return false; - } - - private static class MagicFeatherData { - - private final WeakReference player; - private boolean hasItem = false; - private int checkTick = 0; - private boolean beaconInRangeCache; - - public MagicFeatherData(EntityPlayer player) { - this.player = new WeakReference<>(player); - this.beaconInRangeCache = player.capabilities.allowFlying; - } - - public void onTick() { - EntityPlayer player = this.player.get(); - if (player == null) return; - try { - boolean hasItem = hasItem(player, ModItems.itemMagicFeather); - if (hasItem != this.hasItem) { - if (hasItem) { - this.onAdd(); - } - if (!hasItem) { - this.onRemove(); - } - this.hasItem = hasItem; - Logger.INFO("Ticking feather "+hasItem); - return; - } - } - catch (Throwable t) { - t.printStackTrace(); - } - - if (hasItem) { - // only modify if hasItem. Override other flight methods since you are literally holding this item in - // your own inventory. You have sent your consent. - boolean mayFly = player.capabilities.isCreativeMode || checkBeaconInRange(player); - setMayFly(player, mayFly); - } - } - - private void onAdd() { - if (!ItemMagicFeather.isInBeaconRange(getPlayer())) { - return; - } - setMayFly(getPlayer(), true); - } - - private void onRemove() { - if (getPlayer().capabilities.isCreativeMode) { - return; - } - setMayFly(getPlayer(), false); - } - - private boolean checkBeaconInRange(EntityPlayer player) { - if (checkTick++ % 40 != 0) { - return beaconInRangeCache; - } - beaconInRangeCache = ItemMagicFeather.isInBeaconRange(player); - return beaconInRangeCache; - } - - private EntityPlayer getPlayer() { - return player.get(); - } - } + public static final String NAME = "magicfeather"; + private static final WeakHashMap sPlayerData = new WeakHashMap<>(); + private static final WeakHashMap> sBeaconData = new WeakHashMap<>(); + + public ItemMagicFeather() { + super( + "magicfeather", + AddToCreativeTab.tabMisc, + 1, + 100, + new String[] {"Lets you fly around Beacons"}, + EnumRarity.uncommon, + null, + false, + null); + setMaxStackSize(1); + setUnlocalizedName(CORE.MODID + ":" + NAME); + MinecraftForge.EVENT_BUS.register(this); + } + + @Override + public int getEntityLifespan(ItemStack itemStack, World world) { + return Integer.MAX_VALUE; + } + + @SuppressWarnings("unchecked") + @Override + @SideOnly(Side.CLIENT) + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add("Does not need to be the item held in your hand to work"); + super.addInformation(stack, aPlayer, list, bool); + list.add("Needs to be within beacon range"); + list.add("Range is beacon level * 10 + 10"); + } + + public boolean hasCustomEntity(ItemStack stack) { + return true; + } + + private static boolean isInBeaconRange(EntityPlayer player) { + World world = player.getEntityWorld(); + if (world.isRemote) { + return false; + } + HashSet aBeaconData = sBeaconData.computeIfAbsent(player, k -> new HashSet<>()); + int chunkXlo = (int) (player.posX - 50) >> 4, + chunkXhi = (int) (player.posX + 50) >> 4, + chunkZlo = (int) (player.posZ - 50) >> 4, + chunkZhi = (int) (player.posZ + 50) >> 4; + for (int chunkX = chunkXlo; chunkX < chunkXhi; chunkX++) { + for (int chunkZ = chunkZlo; chunkZ < chunkZhi; chunkZ++) { + if (!world.getChunkProvider().chunkExists(chunkX, chunkZ)) continue; + findSuitableBeacon( + player, + world.getChunkFromChunkCoords(chunkX, chunkZ) + .chunkTileEntityMap + .values(), + aBeaconData); + } + } + return aBeaconData.size() > 0; + } + + private static void findSuitableBeacon( + EntityPlayer player, Collection tileEntities, HashSet aBeaconData) { + for (TileEntity t : tileEntities) { + if (!(t instanceof TileEntityBeacon)) { + continue; + } + TileEntityBeacon beacon = (TileEntityBeacon) t; + int level = beacon.getLevels(); + if (level == 0) { + continue; + } + int radius = (level * 10 + 10); + int x = beacon.xCoord; + int z = beacon.zCoord; + if (player.posX < (x - radius) || player.posX > (x + radius)) { + continue; + } + if (player.posZ < (z - radius) || player.posZ > (z + radius)) { + continue; + } + aBeaconData.add(beacon); + } + } + + private static void setMayFly(EntityPlayer player, boolean mayFly) { + if (player.capabilities.allowFlying == mayFly) { + return; + } + if (!mayFly) { + // force the player on the ground then remove ability to fly + // this prevent crashing the the ground and dying + // when you accidentally get out of the beacon range + player.capabilities.isFlying = false; + if (player.onGround && player.fallDistance < 1F) { + player.capabilities.allowFlying = false; + } + } else { + player.capabilities.allowFlying = true; + } + player.sendPlayerAbilities(); + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onPlayerTick(TickEvent.PlayerTickEvent event) { + if (event.side != Side.SERVER || event.phase != Phase.END) { + return; + } + EntityPlayer player = event.player; + HashSet aBeaconData = sBeaconData.get(player); + if (aBeaconData != null && !aBeaconData.isEmpty()) { + for (Iterator iterator = aBeaconData.iterator(); iterator.hasNext(); ) { + TileEntityBeacon aBeacon = iterator.next(); + int level = aBeacon.getLevels(); + if (level == 0) { + iterator.remove(); + continue; + } + int radius = (level * 10 + 10); + int x = aBeacon.xCoord; + int z = aBeacon.zCoord; + if (player.posX < (x - radius) + || player.posX > (x + radius) + || player.posZ < (z - radius) + || player.posZ > (z + radius)) { + iterator.remove(); + } + } + } + boolean hasItem = hasItem(player, ModItems.itemMagicFeather); + if (!hasItem) { + ItemMagicFeather.sPlayerData.remove(player); + } + MagicFeatherData data = ItemMagicFeather.sPlayerData.get(player); + if (data == null) { + data = new MagicFeatherData(player); + ItemMagicFeather.sPlayerData.put(player, data); + } + data.onTick(); + } + + @SubscribeEvent(priority = EventPriority.LOWEST) + public void onPlayerDeath(LivingDeathEvent event) { + if (event.entityLiving == null) return; + EntityLivingBase aEntity = event.entityLiving; + if (!(aEntity instanceof EntityPlayer) || aEntity.worldObj == null || aEntity.worldObj.isRemote) return; + EntityPlayer aPlayer = (EntityPlayer) aEntity; + ItemMagicFeather.sPlayerData.remove(aPlayer); + ItemMagicFeather.sBeaconData.remove(aPlayer); + } + + private static boolean hasItem(EntityPlayer player, Item item) { + for (int i = 0; i < player.inventory.getSizeInventory(); i++) { + ItemStack stack = player.inventory.getStackInSlot(i); + if (stack != null && stack.getItem() != null && stack.getItem() instanceof ItemMagicFeather) { + return true; + } + } + return false; + } + + private static class MagicFeatherData { + + private final WeakReference player; + private boolean hasItem = false; + private int checkTick = 0; + private boolean beaconInRangeCache; + + public MagicFeatherData(EntityPlayer player) { + this.player = new WeakReference<>(player); + this.beaconInRangeCache = player.capabilities.allowFlying; + } + + public void onTick() { + EntityPlayer player = this.player.get(); + if (player == null) return; + try { + boolean hasItem = hasItem(player, ModItems.itemMagicFeather); + if (hasItem != this.hasItem) { + if (hasItem) { + this.onAdd(); + } + if (!hasItem) { + this.onRemove(); + } + this.hasItem = hasItem; + Logger.INFO("Ticking feather " + hasItem); + return; + } + } catch (Throwable t) { + t.printStackTrace(); + } + + if (hasItem) { + // only modify if hasItem. Override other flight methods since you are literally holding this item in + // your own inventory. You have sent your consent. + boolean mayFly = player.capabilities.isCreativeMode || checkBeaconInRange(player); + setMayFly(player, mayFly); + } + } + + private void onAdd() { + if (!ItemMagicFeather.isInBeaconRange(getPlayer())) { + return; + } + setMayFly(getPlayer(), true); + } + + private void onRemove() { + if (getPlayer().capabilities.isCreativeMode) { + return; + } + setMayFly(getPlayer(), false); + } + + private boolean checkBeaconInRange(EntityPlayer player) { + if (checkTick++ % 40 != 0) { + return beaconInRangeCache; + } + beaconInRangeCache = ItemMagicFeather.isInBeaconRange(player); + return beaconInRangeCache; + } + private EntityPlayer getPlayer() { + return player.get(); + } + } } diff --git a/src/main/java/gtPlusPlus/core/item/general/ItemSlowBuildingRing.java b/src/main/java/gtPlusPlus/core/item/general/ItemSlowBuildingRing.java index fa008bf1a3..3ec417e2d6 100644 --- a/src/main/java/gtPlusPlus/core/item/general/ItemSlowBuildingRing.java +++ b/src/main/java/gtPlusPlus/core/item/general/ItemSlowBuildingRing.java @@ -1,7 +1,5 @@ package gtPlusPlus.core.item.general; -import java.util.List; - import baubles.api.BaubleType; import baubles.api.IBauble; import cpw.mods.fml.common.Optional; @@ -11,6 +9,7 @@ import gtPlusPlus.core.handler.events.CustomMovementHandler; import gtPlusPlus.core.handler.events.SneakManager; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.ItemUtils; +import java.util.List; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -19,122 +18,128 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; -@Optional.InterfaceList(value = {@Optional.Interface(iface = "baubles.api.IBauble", modid = "Baubles"), @Optional.Interface(iface = "baubles.api.BaubleType", modid = "Baubles")}) -public class ItemSlowBuildingRing extends Item implements IBauble{ - - private final String unlocalizedName = "SlowBuildingRing"; - CustomMovementHandler x; - - public ItemSlowBuildingRing(){ - this.setCreativeTab(AddToCreativeTab.tabMachines); - this.setUnlocalizedName(this.unlocalizedName); - this.setMaxStackSize(1); - this.setTextureName(CORE.MODID + ":" + "itemSlowBuildersRing"); - ItemUtils.getSimpleStack(this); - GameRegistry.registerItem(this, this.unlocalizedName); - } - - @Override - public void onUpdate(final ItemStack itemStack, final World worldObj, final Entity player, final int p_77663_4_, final boolean p_77663_5_) { - if (worldObj.isRemote) { - return; - } - super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); - } - - @Override - public String getItemStackDisplayName(final ItemStack p_77653_1_) { - return (EnumChatFormatting.YELLOW+"Slow Building Ring"+EnumChatFormatting.GRAY); - } - - @Override - public boolean showDurabilityBar(final ItemStack stack) - { - return false; - } - - @SuppressWarnings("unchecked") - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - list.add(""); - list.add(EnumChatFormatting.GREEN+"Worn as a Ring within Baubles. Prevents you from sprinting."+EnumChatFormatting.GRAY); - list.add(EnumChatFormatting.GREEN+"Movement speed reduced to crouch speed."+EnumChatFormatting.GRAY); - list.add(EnumChatFormatting.GREEN+"Press shift while worn to toggle crouch on/off."+EnumChatFormatting.GRAY); - list.add(""); - super.addInformation(stack, aPlayer, list, bool); - } - - @Override - public boolean canEquip(final ItemStack arg0, final EntityLivingBase arg1) { - return true; - } - - @Override - public boolean canUnequip(final ItemStack arg0, final EntityLivingBase arg1) { - return true; - } - - @Override - public BaubleType getBaubleType(final ItemStack arg0) { - return BaubleType.RING; - } - - @Override //TODO - public void onEquipped(final ItemStack arg0, final EntityLivingBase arg1) { - try { - EntityPlayer aPlayer; - if (arg1 instanceof EntityPlayer) { - aPlayer = (EntityPlayer) arg1; - SneakManager s = SneakManager.get(aPlayer); - s.putRingOn(); - } - } - catch (Throwable t) { - t.printStackTrace(); - } - } - - @Override //TODO - public void onUnequipped(final ItemStack arg0, final EntityLivingBase arg1) { - try { - EntityPlayer aPlayer; - if (arg1 instanceof EntityPlayer) { - aPlayer = (EntityPlayer) arg1; - SneakManager s = SneakManager.get(aPlayer); - s.takeRingOff(); - } - } - catch (Throwable t) { - t.printStackTrace(); - } - } - - @Override //TODO - public void onWornTick(final ItemStack arg0, final EntityLivingBase arg1) { - doEffect(arg1); - } - - private static void doEffect(final EntityLivingBase arg1){ - try { - // Get World - World aWorld = arg1.worldObj; - if (aWorld != null && !aWorld.isRemote) { - EntityPlayer aPlayer; - if (arg1 instanceof EntityPlayer) { - aPlayer = (EntityPlayer) arg1; - SneakManager s = SneakManager.get(aPlayer); - if (!aPlayer.isSneaking()){ - aPlayer.setSneaking(true); - } - if (aPlayer.isSprinting()) { - aPlayer.setSprinting(false); - } - } - } - } - catch (Throwable t) { - t.printStackTrace(); - } - } - +@Optional.InterfaceList( + value = { + @Optional.Interface(iface = "baubles.api.IBauble", modid = "Baubles"), + @Optional.Interface(iface = "baubles.api.BaubleType", modid = "Baubles") + }) +public class ItemSlowBuildingRing extends Item implements IBauble { + + private final String unlocalizedName = "SlowBuildingRing"; + CustomMovementHandler x; + + public ItemSlowBuildingRing() { + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setUnlocalizedName(this.unlocalizedName); + this.setMaxStackSize(1); + this.setTextureName(CORE.MODID + ":" + "itemSlowBuildersRing"); + ItemUtils.getSimpleStack(this); + GameRegistry.registerItem(this, this.unlocalizedName); + } + + @Override + public void onUpdate( + final ItemStack itemStack, + final World worldObj, + final Entity player, + final int p_77663_4_, + final boolean p_77663_5_) { + if (worldObj.isRemote) { + return; + } + super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); + } + + @Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + return (EnumChatFormatting.YELLOW + "Slow Building Ring" + EnumChatFormatting.GRAY); + } + + @Override + public boolean showDurabilityBar(final ItemStack stack) { + return false; + } + + @SuppressWarnings("unchecked") + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add(""); + list.add(EnumChatFormatting.GREEN + "Worn as a Ring within Baubles. Prevents you from sprinting." + + EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GREEN + "Movement speed reduced to crouch speed." + EnumChatFormatting.GRAY); + list.add( + EnumChatFormatting.GREEN + "Press shift while worn to toggle crouch on/off." + EnumChatFormatting.GRAY); + list.add(""); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public boolean canEquip(final ItemStack arg0, final EntityLivingBase arg1) { + return true; + } + + @Override + public boolean canUnequip(final ItemStack arg0, final EntityLivingBase arg1) { + return true; + } + + @Override + public BaubleType getBaubleType(final ItemStack arg0) { + return BaubleType.RING; + } + + @Override // TODO + public void onEquipped(final ItemStack arg0, final EntityLivingBase arg1) { + try { + EntityPlayer aPlayer; + if (arg1 instanceof EntityPlayer) { + aPlayer = (EntityPlayer) arg1; + SneakManager s = SneakManager.get(aPlayer); + s.putRingOn(); + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + + @Override // TODO + public void onUnequipped(final ItemStack arg0, final EntityLivingBase arg1) { + try { + EntityPlayer aPlayer; + if (arg1 instanceof EntityPlayer) { + aPlayer = (EntityPlayer) arg1; + SneakManager s = SneakManager.get(aPlayer); + s.takeRingOff(); + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + + @Override // TODO + public void onWornTick(final ItemStack arg0, final EntityLivingBase arg1) { + doEffect(arg1); + } + + private static void doEffect(final EntityLivingBase arg1) { + try { + // Get World + World aWorld = arg1.worldObj; + if (aWorld != null && !aWorld.isRemote) { + EntityPlayer aPlayer; + if (arg1 instanceof EntityPlayer) { + aPlayer = (EntityPlayer) arg1; + SneakManager s = SneakManager.get(aPlayer); + if (!aPlayer.isSneaking()) { + aPlayer.setSneaking(true); + } + if (aPlayer.isSprinting()) { + aPlayer.setSprinting(false); + } + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } } diff --git a/src/main/java/gtPlusPlus/core/item/general/ItemSunnariumBit.java b/src/main/java/gtPlusPlus/core/item/general/ItemSunnariumBit.java index 0b61a06934..e3b1314e4b 100644 --- a/src/main/java/gtPlusPlus/core/item/general/ItemSunnariumBit.java +++ b/src/main/java/gtPlusPlus/core/item/general/ItemSunnariumBit.java @@ -8,9 +8,18 @@ import net.minecraft.util.EnumChatFormatting; public class ItemSunnariumBit extends CoreItem { - public ItemSunnariumBit() { - super("SunnariumBit", "Sunnarium Bit", AddToCreativeTab.tabMisc, 64, 0, new String[] {}, EnumRarity.uncommon, EnumChatFormatting.GOLD, false, null); - this.setTextureName(CORE.MODID+":"+"itemSunnariumBit"); - } - + public ItemSunnariumBit() { + super( + "SunnariumBit", + "Sunnarium Bit", + AddToCreativeTab.tabMisc, + 64, + 0, + new String[] {}, + EnumRarity.uncommon, + EnumChatFormatting.GOLD, + false, + null); + this.setTextureName(CORE.MODID + ":" + "itemSunnariumBit"); + } } diff --git a/src/main/java/gtPlusPlus/core/item/general/NuclearFuelRodBase.java b/src/main/java/gtPlusPlus/core/item/general/NuclearFuelRodBase.java index 9feea3c91a..8d5be9f8ec 100644 --- a/src/main/java/gtPlusPlus/core/item/general/NuclearFuelRodBase.java +++ b/src/main/java/gtPlusPlus/core/item/general/NuclearFuelRodBase.java @@ -1,7 +1,6 @@ package gtPlusPlus.core.item.general; import cpw.mods.fml.common.eventhandler.Event; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; @@ -12,200 +11,177 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; - import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.FillBucketEvent; -public class NuclearFuelRodBase extends Item -{ - /** field for checking if the bucket has been filled. */ - private final Block isFull; - public NuclearFuelRodBase(final Block p_i45331_1_) - { - this.maxStackSize = 1; - this.isFull = p_i45331_1_; - this.setCreativeTab(CreativeTabs.tabMisc); - } - - /** - * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer - */ - @Override - public ItemStack onItemRightClick(final ItemStack p_77659_1_, final World p_77659_2_, final EntityPlayer p_77659_3_) - { - final boolean flag = this.isFull == Blocks.air; - final MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(p_77659_2_, p_77659_3_, flag); - - if (movingobjectposition == null) - { - return p_77659_1_; - } - final FillBucketEvent event = new FillBucketEvent(p_77659_3_, p_77659_1_, p_77659_2_, movingobjectposition); - if (MinecraftForge.EVENT_BUS.post(event)) - { - return p_77659_1_; - } - - if (event.getResult() == Event.Result.ALLOW) - { - if (p_77659_3_.capabilities.isCreativeMode) - { - return p_77659_1_; - } - - if (--p_77659_1_.stackSize <= 0) - { - return event.result; - } - - if (!p_77659_3_.inventory.addItemStackToInventory(event.result)) - { - p_77659_3_.dropPlayerItemWithRandomChoice(event.result, false); - } - - return p_77659_1_; - } - if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) - { - int i = movingobjectposition.blockX; - int j = movingobjectposition.blockY; - int k = movingobjectposition.blockZ; - - if (!p_77659_2_.canMineBlock(p_77659_3_, i, j, k)) - { - return p_77659_1_; - } - - if (flag) - { - if (!p_77659_3_.canPlayerEdit(i, j, k, movingobjectposition.sideHit, p_77659_1_)) - { - return p_77659_1_; - } - - final Material material = p_77659_2_.getBlock(i, j, k).getMaterial(); - final int l = p_77659_2_.getBlockMetadata(i, j, k); - - if ((material == Material.water) && (l == 0)) - { - p_77659_2_.setBlockToAir(i, j, k); - return this.func_150910_a(p_77659_1_, p_77659_3_, Items.water_bucket); - } - - if ((material == Material.lava) && (l == 0)) - { - p_77659_2_.setBlockToAir(i, j, k); - return this.func_150910_a(p_77659_1_, p_77659_3_, Items.lava_bucket); - } - } - else - { - if (this.isFull == Blocks.air) - { - return new ItemStack(Items.bucket); - } - - if (movingobjectposition.sideHit == 0) - { - --j; - } - - if (movingobjectposition.sideHit == 1) - { - ++j; - } - - if (movingobjectposition.sideHit == 2) - { - --k; - } - - if (movingobjectposition.sideHit == 3) - { - ++k; - } - - if (movingobjectposition.sideHit == 4) - { - --i; - } - - if (movingobjectposition.sideHit == 5) - { - ++i; - } - - if (!p_77659_3_.canPlayerEdit(i, j, k, movingobjectposition.sideHit, p_77659_1_)) - { - return p_77659_1_; - } - - if (this.tryPlaceContainedLiquid(p_77659_2_, i, j, k) && !p_77659_3_.capabilities.isCreativeMode) - { - return new ItemStack(Items.bucket); - } - } - } - - return p_77659_1_; - } - - private ItemStack func_150910_a(final ItemStack p_150910_1_, final EntityPlayer p_150910_2_, final Item p_150910_3_) - { - if (p_150910_2_.capabilities.isCreativeMode) - { - return p_150910_1_; - } - else if (--p_150910_1_.stackSize <= 0) - { - return new ItemStack(p_150910_3_); - } - else - { - if (!p_150910_2_.inventory.addItemStackToInventory(new ItemStack(p_150910_3_))) - { - p_150910_2_.dropPlayerItemWithRandomChoice(new ItemStack(p_150910_3_, 1, 0), false); - } - - return p_150910_1_; - } - } - - /** - * Attempts to place the liquid contained inside the bucket. - */ - public boolean tryPlaceContainedLiquid(final World p_77875_1_, final int p_77875_2_, final int p_77875_3_, final int p_77875_4_) - { - if (this.isFull == Blocks.air) - { - return false; - } - final Material material = p_77875_1_.getBlock(p_77875_2_, p_77875_3_, p_77875_4_).getMaterial(); - final boolean flag = !material.isSolid(); - - if (!p_77875_1_.isAirBlock(p_77875_2_, p_77875_3_, p_77875_4_) && !flag) - { - return false; - } - if (p_77875_1_.provider.isHellWorld && (this.isFull == Blocks.flowing_water)) - { - p_77875_1_.playSoundEffect(p_77875_2_ + 0.5F, p_77875_3_ + 0.5F, p_77875_4_ + 0.5F, "random.fizz", 0.5F, 2.6F + ((p_77875_1_.rand.nextFloat() - p_77875_1_.rand.nextFloat()) * 0.8F)); - - for (int l = 0; l < 8; ++l) - { - p_77875_1_.spawnParticle("largesmoke", p_77875_2_ + Math.random(), p_77875_3_ + Math.random(), p_77875_4_ + Math.random(), 0.0D, 0.0D, 0.0D); - } - } - else - { - if (!p_77875_1_.isRemote && flag && !material.isLiquid()) - { - p_77875_1_.func_147480_a(p_77875_2_, p_77875_3_, p_77875_4_, true); - } - - p_77875_1_.setBlock(p_77875_2_, p_77875_3_, p_77875_4_, this.isFull, 0, 3); - } - - return true; - } -} \ No newline at end of file +public class NuclearFuelRodBase extends Item { + /** field for checking if the bucket has been filled. */ + private final Block isFull; + + public NuclearFuelRodBase(final Block p_i45331_1_) { + this.maxStackSize = 1; + this.isFull = p_i45331_1_; + this.setCreativeTab(CreativeTabs.tabMisc); + } + + /** + * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer + */ + @Override + public ItemStack onItemRightClick( + final ItemStack p_77659_1_, final World p_77659_2_, final EntityPlayer p_77659_3_) { + final boolean flag = this.isFull == Blocks.air; + final MovingObjectPosition movingobjectposition = + this.getMovingObjectPositionFromPlayer(p_77659_2_, p_77659_3_, flag); + + if (movingobjectposition == null) { + return p_77659_1_; + } + final FillBucketEvent event = new FillBucketEvent(p_77659_3_, p_77659_1_, p_77659_2_, movingobjectposition); + if (MinecraftForge.EVENT_BUS.post(event)) { + return p_77659_1_; + } + + if (event.getResult() == Event.Result.ALLOW) { + if (p_77659_3_.capabilities.isCreativeMode) { + return p_77659_1_; + } + + if (--p_77659_1_.stackSize <= 0) { + return event.result; + } + + if (!p_77659_3_.inventory.addItemStackToInventory(event.result)) { + p_77659_3_.dropPlayerItemWithRandomChoice(event.result, false); + } + + return p_77659_1_; + } + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; + + if (!p_77659_2_.canMineBlock(p_77659_3_, i, j, k)) { + return p_77659_1_; + } + + if (flag) { + if (!p_77659_3_.canPlayerEdit(i, j, k, movingobjectposition.sideHit, p_77659_1_)) { + return p_77659_1_; + } + + final Material material = p_77659_2_.getBlock(i, j, k).getMaterial(); + final int l = p_77659_2_.getBlockMetadata(i, j, k); + + if ((material == Material.water) && (l == 0)) { + p_77659_2_.setBlockToAir(i, j, k); + return this.func_150910_a(p_77659_1_, p_77659_3_, Items.water_bucket); + } + + if ((material == Material.lava) && (l == 0)) { + p_77659_2_.setBlockToAir(i, j, k); + return this.func_150910_a(p_77659_1_, p_77659_3_, Items.lava_bucket); + } + } else { + if (this.isFull == Blocks.air) { + return new ItemStack(Items.bucket); + } + + if (movingobjectposition.sideHit == 0) { + --j; + } + + if (movingobjectposition.sideHit == 1) { + ++j; + } + + if (movingobjectposition.sideHit == 2) { + --k; + } + + if (movingobjectposition.sideHit == 3) { + ++k; + } + + if (movingobjectposition.sideHit == 4) { + --i; + } + + if (movingobjectposition.sideHit == 5) { + ++i; + } + + if (!p_77659_3_.canPlayerEdit(i, j, k, movingobjectposition.sideHit, p_77659_1_)) { + return p_77659_1_; + } + + if (this.tryPlaceContainedLiquid(p_77659_2_, i, j, k) && !p_77659_3_.capabilities.isCreativeMode) { + return new ItemStack(Items.bucket); + } + } + } + + return p_77659_1_; + } + + private ItemStack func_150910_a( + final ItemStack p_150910_1_, final EntityPlayer p_150910_2_, final Item p_150910_3_) { + if (p_150910_2_.capabilities.isCreativeMode) { + return p_150910_1_; + } else if (--p_150910_1_.stackSize <= 0) { + return new ItemStack(p_150910_3_); + } else { + if (!p_150910_2_.inventory.addItemStackToInventory(new ItemStack(p_150910_3_))) { + p_150910_2_.dropPlayerItemWithRandomChoice(new ItemStack(p_150910_3_, 1, 0), false); + } + + return p_150910_1_; + } + } + + /** + * Attempts to place the liquid contained inside the bucket. + */ + public boolean tryPlaceContainedLiquid( + final World p_77875_1_, final int p_77875_2_, final int p_77875_3_, final int p_77875_4_) { + if (this.isFull == Blocks.air) { + return false; + } + final Material material = + p_77875_1_.getBlock(p_77875_2_, p_77875_3_, p_77875_4_).getMaterial(); + final boolean flag = !material.isSolid(); + + if (!p_77875_1_.isAirBlock(p_77875_2_, p_77875_3_, p_77875_4_) && !flag) { + return false; + } + if (p_77875_1_.provider.isHellWorld && (this.isFull == Blocks.flowing_water)) { + p_77875_1_.playSoundEffect( + p_77875_2_ + 0.5F, + p_77875_3_ + 0.5F, + p_77875_4_ + 0.5F, + "random.fizz", + 0.5F, + 2.6F + ((p_77875_1_.rand.nextFloat() - p_77875_1_.rand.nextFloat()) * 0.8F)); + + for (int l = 0; l < 8; ++l) { + p_77875_1_.spawnParticle( + "largesmoke", + p_77875_2_ + Math.random(), + p_77875_3_ + Math.random(), + p_77875_4_ + Math.random(), + 0.0D, + 0.0D, + 0.0D); + } + } else { + if (!p_77875_1_.isRemote && flag && !material.isLiquid()) { + p_77875_1_.func_147480_a(p_77875_2_, p_77875_3_, p_77875_4_, true); + } + + p_77875_1_.setBlock(p_77875_2_, p_77875_3_, p_77875_4_, this.isFull, 0, 3); + } + + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/general/RF2EU_Battery.java b/src/main/java/gtPlusPlus/core/item/general/RF2EU_Battery.java index 5ff5b5a62b..d5c606b964 100644 --- a/src/main/java/gtPlusPlus/core/item/general/RF2EU_Battery.java +++ b/src/main/java/gtPlusPlus/core/item/general/RF2EU_Battery.java @@ -1,13 +1,18 @@ package gtPlusPlus.core.item.general; -import java.util.List; - import cofh.api.energy.ItemEnergyContainer; import cpw.mods.fml.common.IFuelHandler; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; +import ic2.api.item.IElectricItemManager; +import java.util.List; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -19,297 +24,295 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MathHelper; import net.minecraft.world.World; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import ic2.api.item.ElectricItem; -import ic2.api.item.IElectricItem; -import ic2.api.item.IElectricItemManager; - -public class RF2EU_Battery extends ItemEnergyContainer implements IElectricItem, IElectricItemManager, IFuelHandler{ - - public static double rfPerEU = 3.4; - private final String unlocalizedName = "rfEUBattery"; - private final ItemStack thisStack; - private final static int maxValueEU = 100000000; - private final static int maxValueRF = (int) (maxValueEU * rfPerEU); - protected double chargeEU = 0; - - public RF2EU_Battery(){ - super(maxValueRF); - GameRegistry.registerFuelHandler(this); - //this.setMaxDamage(Integer.MAX_VALUE); - //this.setDamage(UtilsItems.getSimpleStack(this), 0); - this.setCreativeTab(AddToCreativeTab.tabMachines); - this.setUnlocalizedName(this.unlocalizedName); - this.setMaxStackSize(1); - this.setTextureName(CORE.MODID + ":" + "itemIngot"); - this.thisStack = ItemUtils.getSimpleStack(this); - GameRegistry.registerItem(this, this.unlocalizedName); - } - - @Override - public void onUpdate(final ItemStack itemStack, final World worldObj, final Entity player, final int p_77663_4_, final boolean p_77663_5_) { - this.getEnergyStored(itemStack); - if (worldObj.isRemote) { - return; - } - - if (player instanceof EntityPlayer){ - for (final ItemStack is : ((EntityPlayer) player).inventory.mainInventory) { - if (is == itemStack) { - continue; - } - if (is != null) { - if (is.getItem() instanceof IElectricItem) { - final IElectricItem electricItem = (IElectricItem) is.getItem(); - this.chargeEU = ElectricItem.manager.getCharge(is); - } - - } - } - } - - - super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); - } - - @Override - public boolean canProvideEnergy(final ItemStack itemStack) { - return true; - } - - @Override - public Item getChargedItem(final ItemStack itemStack) { - final ItemStack x = itemStack.copy(); - x.setItemDamage(maxValueEU); - return x.getItem(); - } - - @Override - public Item getEmptyItem(final ItemStack itemStack) { - final ItemStack x = itemStack.copy(); - x.setItemDamage(0); - return x.getItem(); - } - - @Override - public double getMaxCharge(final ItemStack itemStack) { - return maxValueEU; - } - - @Override - public int getTier(final ItemStack itemStack) { - return 3; - } - - @Override - public double getTransferLimit(final ItemStack itemStack) { - return 8196; - } - - @Override - public String getItemStackDisplayName(final ItemStack p_77653_1_) { - - return ("Universally Chargeable Battery"); - } - - @Override - public double getDurabilityForDisplay(final ItemStack stack) - { - //return 1.0D - getEnergyStored(stack) / this.capacity; - return MathUtils.findPercentage(this.getEnergyStored(stack), this.getMaxEnergyStored(stack)); - } - - @Override - @SideOnly(Side.CLIENT) - public int getColorFromItemStack(final ItemStack par1ItemStack, final int par2) - { - final int i = 30; - - final float f13 = (((Minecraft.getSystemTime() % 6000L) / 3000.0F) * CORE.PI * 2.0F); - - final float t = 0.9F + (0.1F * MathHelper.cos(f13)); - - final double v = 1.0D - this.getDurabilityForDisplay(par1ItemStack); - - int r = i + (int)(v * (255 - i) * t); - if (r > 255) { - r = 255; - } - final int g = i + (int)(v * (64 - i) * t); - - return (r << 16) | (g << 8) | i; - } - - @Override - public boolean showDurabilityBar(final ItemStack stack) - { - return false; - } - - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - list.add(EnumChatFormatting.YELLOW+"IC2/EU Information"+EnumChatFormatting.GRAY); - list.add(EnumChatFormatting.GRAY+"Tier: ["+EnumChatFormatting.YELLOW+this.getTier(this.thisStack)+EnumChatFormatting.GRAY+"] Current Power: ["+EnumChatFormatting.YELLOW+(long) this.getCharge(stack)+EnumChatFormatting.GRAY+"/EU]"); - list.add(EnumChatFormatting.GRAY+"Transfer Limit: ["+EnumChatFormatting.YELLOW+this.getTransferLimit(this.thisStack)+ EnumChatFormatting.GRAY +"Eu/t]" +"Burn Time: ["+EnumChatFormatting.YELLOW+(this.getBurnTime(stack)/20)+EnumChatFormatting.GRAY+"s]"); - list.add(""); - list.add(EnumChatFormatting.RED+"RF Information"); - list.add(EnumChatFormatting.GRAY+"Extraction Rate: [" +EnumChatFormatting.RED+ this.maxExtract + EnumChatFormatting.GRAY + "Rf/t]" + " Insert Rate: [" +EnumChatFormatting.RED+ this.maxReceive+EnumChatFormatting.GRAY+"Rf/t]"); - list.add(EnumChatFormatting.GRAY+"Current Charge: ["+EnumChatFormatting.RED+this.getEnergyStored(stack) + EnumChatFormatting.GRAY + "Rf / " + this.getMaxEnergyStored(stack)+"Rf] "+EnumChatFormatting.RED+MathUtils.findPercentage(this.getEnergyStored(stack), this.getMaxEnergyStored(stack))+EnumChatFormatting.GRAY+"%"); - super.addInformation(stack, aPlayer, list, bool); - } - - @Override - public ItemStack getContainerItem(final ItemStack itemStack) - { - final ItemStack newItem = itemStack.copy(); - newItem.stackSize = 1; - this.extractEnergy(newItem, 150000, false); - return newItem; - } - - @Override - public boolean hasContainerItem(final ItemStack stack) - { - return true; - } - - @Override - public int getBurnTime(final ItemStack fuel) { - if ((fuel == null) || (fuel.getItem() != this)) { - return 0; - } - return this.extractEnergy(fuel, 150000, true) / 50 / 100; - } - - @Override - public double charge(final ItemStack stack, final double amount, final int tier, - final boolean ignoreTransferLimit, final boolean simulate) { - if (stack.stackTagCompound == null) { - stack.stackTagCompound = new NBTTagCompound(); - } - int energy = stack.stackTagCompound.getInteger("Energy"); - final int energyReceived = Math.min(this.capacity - energy, Math.min(this.maxReceive, this.maxReceive)); - if (!simulate) - { - energy += energyReceived; - stack.stackTagCompound.setInteger("Energy", energy); - ElectricItem.manager.discharge(stack, ElectricItem.manager.getCharge(stack), 3, true, true, false); - ElectricItem.manager.charge(stack, energy/rfPerEU, 3, true, false); - - } - return ElectricItem.manager.charge(stack, amount, tier, ignoreTransferLimit, simulate); - } - - @Override - public double discharge(final ItemStack stack, final double amount, final int tier, - final boolean ignoreTransferLimit, final boolean externally, final boolean simulate) { - if ((stack.stackTagCompound == null) || (!stack.stackTagCompound.hasKey("Energy"))) { - final double euCharge = this.getCharge(ItemUtils.getSimpleStack(this)); - if ((euCharge != 0) && (euCharge >= 1)){ - return (int) (MathUtils.decimalRoundingToWholes(euCharge*rfPerEU)); - } - return 0; - } - int energy = stack.stackTagCompound.getInteger("Energy"); - final int energyExtracted = Math.min(energy, Math.min(this.maxExtract, this.maxExtract)); - if (!simulate) - { - energy -= energyExtracted; - stack.stackTagCompound.setInteger("Energy", energy); - ElectricItem.manager.discharge(stack, ElectricItem.manager.getCharge(stack), 3, true, true, false); - ElectricItem.manager.charge(stack, energy/rfPerEU, 3, true, false); - } - - return ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate); - } - - @Override - public double getCharge(final ItemStack stack) { - return ElectricItem.manager.getCharge(stack); - } - - @Override - public boolean canUse(final ItemStack stack, final double amount) { - return ElectricItem.manager.canUse(stack, amount); - } - - @Override - public boolean use(final ItemStack stack, final double amount, final EntityLivingBase entity) { - return ElectricItem.manager.use(stack, amount, entity); - } - - @Override - public void chargeFromArmor(final ItemStack stack, final EntityLivingBase entity) { - ElectricItem.manager.chargeFromArmor(stack, entity); - } - - @Override - public String getToolTip(final ItemStack stack) { - return ElectricItem.manager.getToolTip(stack); - } - - @Override - public int receiveEnergy(final ItemStack container, final int maxReceive, final boolean simulate) - { - if ((container.stackTagCompound == null) || (!container.stackTagCompound.hasKey("Energy"))) { - final double euCharge = this.getCharge(ItemUtils.getSimpleStack(this)); - if ((euCharge != 0) && (euCharge >= 1)){ - return (int) (MathUtils.decimalRoundingToWholes(euCharge*rfPerEU)); - } - return 0; - } - int energy = container.stackTagCompound.getInteger("Energy"); - final int energyReceived = Math.min(this.capacity - energy, Math.min(this.maxReceive, maxReceive)); - if (!simulate) - { - energy += energyReceived; - container.stackTagCompound.setInteger("Energy", energy); - ElectricItem.manager.discharge(container, ElectricItem.manager.getCharge(container), 3, true, true, false); - ElectricItem.manager.charge(container, energy/rfPerEU, 3, true, false); - - } - return energyReceived; - } - - @Override - public int extractEnergy(final ItemStack container, final int maxExtract, final boolean simulate) - { - if ((container.stackTagCompound == null) || (!container.stackTagCompound.hasKey("Energy"))) { - final double euCharge = this.getCharge(ItemUtils.getSimpleStack(this)); - if ((euCharge != 0) && (euCharge >= 1)){ - return (int) (MathUtils.decimalRoundingToWholes(euCharge*rfPerEU)); - } - return 0; - } - int energy = container.stackTagCompound.getInteger("Energy"); - final int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); - if (!simulate) - { - energy -= energyExtracted; - container.stackTagCompound.setInteger("Energy", energy); - ElectricItem.manager.discharge(container, ElectricItem.manager.getCharge(container), 3, true, true, false); - ElectricItem.manager.charge(container, energy/rfPerEU, 3, true, false); - } - return energyExtracted; - } - - @Override - public int getEnergyStored(final ItemStack container) - { - if ((container.stackTagCompound == null) || (!container.stackTagCompound.hasKey("Energy"))) { - final double euCharge = this.getCharge(ItemUtils.getSimpleStack(this)); - if ((euCharge != 0) && (euCharge >= 1)){ - return (int) (MathUtils.decimalRoundingToWholes(euCharge*rfPerEU)); - } - return 0; - } - final int energy = container.stackTagCompound.getInteger("Energy"); - ElectricItem.manager.discharge(container, ElectricItem.manager.getCharge(container), 3, true, true, false); - ElectricItem.manager.charge(container, energy/rfPerEU, 3, true, false); - return energy; - } - +public class RF2EU_Battery extends ItemEnergyContainer implements IElectricItem, IElectricItemManager, IFuelHandler { + + public static double rfPerEU = 3.4; + private final String unlocalizedName = "rfEUBattery"; + private final ItemStack thisStack; + private static final int maxValueEU = 100000000; + private static final int maxValueRF = (int) (maxValueEU * rfPerEU); + protected double chargeEU = 0; + + public RF2EU_Battery() { + super(maxValueRF); + GameRegistry.registerFuelHandler(this); + // this.setMaxDamage(Integer.MAX_VALUE); + // this.setDamage(UtilsItems.getSimpleStack(this), 0); + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setUnlocalizedName(this.unlocalizedName); + this.setMaxStackSize(1); + this.setTextureName(CORE.MODID + ":" + "itemIngot"); + this.thisStack = ItemUtils.getSimpleStack(this); + GameRegistry.registerItem(this, this.unlocalizedName); + } + + @Override + public void onUpdate( + final ItemStack itemStack, + final World worldObj, + final Entity player, + final int p_77663_4_, + final boolean p_77663_5_) { + this.getEnergyStored(itemStack); + if (worldObj.isRemote) { + return; + } + + if (player instanceof EntityPlayer) { + for (final ItemStack is : ((EntityPlayer) player).inventory.mainInventory) { + if (is == itemStack) { + continue; + } + if (is != null) { + if (is.getItem() instanceof IElectricItem) { + final IElectricItem electricItem = (IElectricItem) is.getItem(); + this.chargeEU = ElectricItem.manager.getCharge(is); + } + } + } + } + + super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); + } + + @Override + public boolean canProvideEnergy(final ItemStack itemStack) { + return true; + } + + @Override + public Item getChargedItem(final ItemStack itemStack) { + final ItemStack x = itemStack.copy(); + x.setItemDamage(maxValueEU); + return x.getItem(); + } + + @Override + public Item getEmptyItem(final ItemStack itemStack) { + final ItemStack x = itemStack.copy(); + x.setItemDamage(0); + return x.getItem(); + } + + @Override + public double getMaxCharge(final ItemStack itemStack) { + return maxValueEU; + } + + @Override + public int getTier(final ItemStack itemStack) { + return 3; + } + + @Override + public double getTransferLimit(final ItemStack itemStack) { + return 8196; + } + + @Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + + return ("Universally Chargeable Battery"); + } + + @Override + public double getDurabilityForDisplay(final ItemStack stack) { + // return 1.0D - getEnergyStored(stack) / this.capacity; + return MathUtils.findPercentage(this.getEnergyStored(stack), this.getMaxEnergyStored(stack)); + } + + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(final ItemStack par1ItemStack, final int par2) { + final int i = 30; + + final float f13 = (((Minecraft.getSystemTime() % 6000L) / 3000.0F) * CORE.PI * 2.0F); + + final float t = 0.9F + (0.1F * MathHelper.cos(f13)); + + final double v = 1.0D - this.getDurabilityForDisplay(par1ItemStack); + + int r = i + (int) (v * (255 - i) * t); + if (r > 255) { + r = 255; + } + final int g = i + (int) (v * (64 - i) * t); + + return (r << 16) | (g << 8) | i; + } + + @Override + public boolean showDurabilityBar(final ItemStack stack) { + return false; + } + + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add(EnumChatFormatting.YELLOW + "IC2/EU Information" + EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GRAY + "Tier: [" + EnumChatFormatting.YELLOW + this.getTier(this.thisStack) + + EnumChatFormatting.GRAY + "] Current Power: [" + EnumChatFormatting.YELLOW + + (long) this.getCharge(stack) + EnumChatFormatting.GRAY + "/EU]"); + list.add(EnumChatFormatting.GRAY + "Transfer Limit: [" + EnumChatFormatting.YELLOW + + this.getTransferLimit(this.thisStack) + EnumChatFormatting.GRAY + "Eu/t]" + "Burn Time: [" + + EnumChatFormatting.YELLOW + (this.getBurnTime(stack) / 20) + EnumChatFormatting.GRAY + "s]"); + list.add(""); + list.add(EnumChatFormatting.RED + "RF Information"); + list.add(EnumChatFormatting.GRAY + "Extraction Rate: [" + EnumChatFormatting.RED + this.maxExtract + + EnumChatFormatting.GRAY + "Rf/t]" + " Insert Rate: [" + EnumChatFormatting.RED + this.maxReceive + + EnumChatFormatting.GRAY + "Rf/t]"); + list.add(EnumChatFormatting.GRAY + "Current Charge: [" + EnumChatFormatting.RED + this.getEnergyStored(stack) + + EnumChatFormatting.GRAY + "Rf / " + this.getMaxEnergyStored(stack) + "Rf] " + EnumChatFormatting.RED + + MathUtils.findPercentage(this.getEnergyStored(stack), this.getMaxEnergyStored(stack)) + + EnumChatFormatting.GRAY + "%"); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public ItemStack getContainerItem(final ItemStack itemStack) { + final ItemStack newItem = itemStack.copy(); + newItem.stackSize = 1; + this.extractEnergy(newItem, 150000, false); + return newItem; + } + + @Override + public boolean hasContainerItem(final ItemStack stack) { + return true; + } + + @Override + public int getBurnTime(final ItemStack fuel) { + if ((fuel == null) || (fuel.getItem() != this)) { + return 0; + } + return this.extractEnergy(fuel, 150000, true) / 50 / 100; + } + + @Override + public double charge( + final ItemStack stack, + final double amount, + final int tier, + final boolean ignoreTransferLimit, + final boolean simulate) { + if (stack.stackTagCompound == null) { + stack.stackTagCompound = new NBTTagCompound(); + } + int energy = stack.stackTagCompound.getInteger("Energy"); + final int energyReceived = Math.min(this.capacity - energy, Math.min(this.maxReceive, this.maxReceive)); + if (!simulate) { + energy += energyReceived; + stack.stackTagCompound.setInteger("Energy", energy); + ElectricItem.manager.discharge(stack, ElectricItem.manager.getCharge(stack), 3, true, true, false); + ElectricItem.manager.charge(stack, energy / rfPerEU, 3, true, false); + } + return ElectricItem.manager.charge(stack, amount, tier, ignoreTransferLimit, simulate); + } + + @Override + public double discharge( + final ItemStack stack, + final double amount, + final int tier, + final boolean ignoreTransferLimit, + final boolean externally, + final boolean simulate) { + if ((stack.stackTagCompound == null) || (!stack.stackTagCompound.hasKey("Energy"))) { + final double euCharge = this.getCharge(ItemUtils.getSimpleStack(this)); + if ((euCharge != 0) && (euCharge >= 1)) { + return (int) (MathUtils.decimalRoundingToWholes(euCharge * rfPerEU)); + } + return 0; + } + int energy = stack.stackTagCompound.getInteger("Energy"); + final int energyExtracted = Math.min(energy, Math.min(this.maxExtract, this.maxExtract)); + if (!simulate) { + energy -= energyExtracted; + stack.stackTagCompound.setInteger("Energy", energy); + ElectricItem.manager.discharge(stack, ElectricItem.manager.getCharge(stack), 3, true, true, false); + ElectricItem.manager.charge(stack, energy / rfPerEU, 3, true, false); + } + + return ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate); + } + + @Override + public double getCharge(final ItemStack stack) { + return ElectricItem.manager.getCharge(stack); + } + + @Override + public boolean canUse(final ItemStack stack, final double amount) { + return ElectricItem.manager.canUse(stack, amount); + } + + @Override + public boolean use(final ItemStack stack, final double amount, final EntityLivingBase entity) { + return ElectricItem.manager.use(stack, amount, entity); + } + + @Override + public void chargeFromArmor(final ItemStack stack, final EntityLivingBase entity) { + ElectricItem.manager.chargeFromArmor(stack, entity); + } + + @Override + public String getToolTip(final ItemStack stack) { + return ElectricItem.manager.getToolTip(stack); + } + + @Override + public int receiveEnergy(final ItemStack container, final int maxReceive, final boolean simulate) { + if ((container.stackTagCompound == null) || (!container.stackTagCompound.hasKey("Energy"))) { + final double euCharge = this.getCharge(ItemUtils.getSimpleStack(this)); + if ((euCharge != 0) && (euCharge >= 1)) { + return (int) (MathUtils.decimalRoundingToWholes(euCharge * rfPerEU)); + } + return 0; + } + int energy = container.stackTagCompound.getInteger("Energy"); + final int energyReceived = Math.min(this.capacity - energy, Math.min(this.maxReceive, maxReceive)); + if (!simulate) { + energy += energyReceived; + container.stackTagCompound.setInteger("Energy", energy); + ElectricItem.manager.discharge(container, ElectricItem.manager.getCharge(container), 3, true, true, false); + ElectricItem.manager.charge(container, energy / rfPerEU, 3, true, false); + } + return energyReceived; + } + + @Override + public int extractEnergy(final ItemStack container, final int maxExtract, final boolean simulate) { + if ((container.stackTagCompound == null) || (!container.stackTagCompound.hasKey("Energy"))) { + final double euCharge = this.getCharge(ItemUtils.getSimpleStack(this)); + if ((euCharge != 0) && (euCharge >= 1)) { + return (int) (MathUtils.decimalRoundingToWholes(euCharge * rfPerEU)); + } + return 0; + } + int energy = container.stackTagCompound.getInteger("Energy"); + final int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + if (!simulate) { + energy -= energyExtracted; + container.stackTagCompound.setInteger("Energy", energy); + ElectricItem.manager.discharge(container, ElectricItem.manager.getCharge(container), 3, true, true, false); + ElectricItem.manager.charge(container, energy / rfPerEU, 3, true, false); + } + return energyExtracted; + } + + @Override + public int getEnergyStored(final ItemStack container) { + if ((container.stackTagCompound == null) || (!container.stackTagCompound.hasKey("Energy"))) { + final double euCharge = this.getCharge(ItemUtils.getSimpleStack(this)); + if ((euCharge != 0) && (euCharge >= 1)) { + return (int) (MathUtils.decimalRoundingToWholes(euCharge * rfPerEU)); + } + return 0; + } + final int energy = container.stackTagCompound.getInteger("Energy"); + ElectricItem.manager.discharge(container, ElectricItem.manager.getCharge(container), 3, true, true, false); + ElectricItem.manager.charge(container, energy / rfPerEU, 3, true, false); + return energy; + } } diff --git a/src/main/java/gtPlusPlus/core/item/general/books/ItemBaseBook.java b/src/main/java/gtPlusPlus/core/item/general/books/ItemBaseBook.java index 9be6a0fda5..c71dc5b9e3 100644 --- a/src/main/java/gtPlusPlus/core/item/general/books/ItemBaseBook.java +++ b/src/main/java/gtPlusPlus/core/item/general/books/ItemBaseBook.java @@ -3,14 +3,18 @@ package gtPlusPlus.core.item.general.books; import static gtPlusPlus.core.handler.BookHandler.mBookMap; import static gtPlusPlus.core.util.Utils.addBookTitleLocalization; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.List; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.handler.BookHandler; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.NBTUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.List; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.creativetab.CreativeTabs; @@ -21,111 +25,102 @@ import net.minecraft.item.ItemWritableBook; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Utility; +public class ItemBaseBook extends ItemWritableBook { -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.handler.BookHandler; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.minecraft.NBTUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; + public ItemBaseBook() { + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setMaxStackSize(1); + this.setTextureName(CORE.MODID + ":" + "itemBook"); + this.setUnlocalizedName("itembookgt"); + GameRegistry.registerItem(this, "bookGT"); + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < BookHandler.mBookMap.size(); i++) { + ItemStack bookstack = new ItemStack(item, 1, i); -public class ItemBaseBook extends ItemWritableBook{ + /*bookstack = Utils.getWrittenBook( + bookstack, + i, + mBookMap.get(i).mMapping, + mBookMap.get(i).mTitle, + mBookMap.get(i).mAuthor, + mBookMap.get(i).mPages);*/ - public ItemBaseBook(){ - this.setCreativeTab(AddToCreativeTab.tabMisc); - this.setMaxStackSize(1); - this.setTextureName(CORE.MODID+":"+"itemBook"); - this.setUnlocalizedName("itembookgt"); - GameRegistry.registerItem(this, "bookGT"); - - } + NBTUtils.createIntegerTagCompound(bookstack, "stats", "mMeta", i); + list.add(bookstack); + } + } - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < BookHandler.mBookMap.size(); i ++) { - ItemStack bookstack = new ItemStack(item, 1, i); - - /*bookstack = Utils.getWrittenBook( - bookstack, - i, - mBookMap.get(i).mMapping, - mBookMap.get(i).mTitle, - mBookMap.get(i).mAuthor, - mBookMap.get(i).mPages);*/ + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + if (NBTUtils.hasKey(tItem, "title")) { + return NBTUtils.getString(tItem, "title"); + } else if (tItem.getItemDamage() > -1 && tItem.getItemDamage() <= mBookMap.size()) { + return EnumChatFormatting.ITALIC + "" + + addBookTitleLocalization(mBookMap.get(tItem.getItemDamage()).mTitle); + } + // NBTUtils.tryIterateNBTData(tItem); + return "GT++ Storybook"; + } - NBTUtils.createIntegerTagCompound(bookstack, "stats", "mMeta", i); - list.add(bookstack); - } - } - - @Override - public String getItemStackDisplayName(final ItemStack tItem) { - if (NBTUtils.hasKey(tItem, "title")){ - return NBTUtils.getString(tItem, "title"); - } - else if (tItem.getItemDamage() > -1 && tItem.getItemDamage() <= mBookMap.size()){ - return EnumChatFormatting.ITALIC + "" + addBookTitleLocalization(mBookMap.get(tItem.getItemDamage()).mTitle); - } - //NBTUtils.tryIterateNBTData(tItem); - return "GT++ Storybook"; - } + @Override + public void addInformation(ItemStack tItem, EntityPlayer player, List list, boolean bool) { + // TODO Auto-generated method stub + if (NBTUtils.hasKey(tItem, "author")) { + list.add(EnumChatFormatting.GRAY + "Author: " + NBTUtils.getString(tItem, "author")); + } else if (mBookMap.get(tItem.getItemDamage()).mAuthor != null) { + list.add(EnumChatFormatting.WHITE + "Author: " + mBookMap.get(tItem.getItemDamage()).mAuthor); + } + if (NBTUtils.hasKey(tItem, "title")) { + list.add(EnumChatFormatting.GRAY + "Pages: " + NBTUtils.getString(tItem, "pages")); + } else if (mBookMap.get(tItem.getItemDamage()).mPages != null) { + list.add(EnumChatFormatting.WHITE + "Pages: " + mBookMap.get(tItem.getItemDamage()).mPages.length); + } + // super.addInformation(p_77624_1_, p_77624_2_, p_77624_3_, p_77624_4_); + } - @Override - public void addInformation(ItemStack tItem, EntityPlayer player, List list, boolean bool) { - // TODO Auto-generated method stub - if (NBTUtils.hasKey(tItem, "author")){ - list.add(EnumChatFormatting.GRAY+"Author: "+NBTUtils.getString(tItem, "author")); - } - else if (mBookMap.get(tItem.getItemDamage()).mAuthor != null){ - list.add(EnumChatFormatting.WHITE+"Author: "+mBookMap.get(tItem.getItemDamage()).mAuthor); - } - if (NBTUtils.hasKey(tItem, "title")){ - list.add(EnumChatFormatting.GRAY+"Pages: "+NBTUtils.getString(tItem, "pages")); - } - else if (mBookMap.get(tItem.getItemDamage()).mPages != null){ - list.add(EnumChatFormatting.WHITE+"Pages: "+mBookMap.get(tItem.getItemDamage()).mPages.length); - } - //super.addInformation(p_77624_1_, p_77624_2_, p_77624_3_, p_77624_4_); - } + @Override + public boolean isRepairable() { + return false; + } - @Override - public boolean isRepairable() { - return false; - } + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } - @Override - public boolean showDurabilityBar(ItemStack stack) { - return false; - } + @Override + @SideOnly(Side.CLIENT) + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + // player.displayGUIBook(item); + int i = item.getItemDamage(); + ItemStack bookstack = Utils.getWrittenBook( + null, + mBookMap.get(i).mMeta, + mBookMap.get(i).mMapping, + mBookMap.get(i).mTitle, + mBookMap.get(i).mAuthor, + mBookMap.get(i).mPages); - @Override - @SideOnly(Side.CLIENT) - public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { - //player.displayGUIBook(item); - int i = item.getItemDamage(); - ItemStack bookstack = Utils.getWrittenBook( - null, - mBookMap.get(i).mMeta, - mBookMap.get(i).mMapping, - mBookMap.get(i).mTitle, - mBookMap.get(i).mAuthor, - mBookMap.get(i).mPages); - - if (player.worldObj.isRemote){ - try { - Class clazz = ReflectionUtils.getClass("net.minecraft.client.gui.GuiScreenBook"); - Constructor ctor = clazz.getConstructor(EntityPlayer.class, ItemStack.class, boolean.class); - Object object = ctor.newInstance(new Object[] { player, bookstack, false }); - Minecraft.getMinecraft().displayGuiScreen((GuiScreen) object); - } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - //Minecraft.getMinecraft().displayGuiScreen(new GuiScreenBook(player, bookstack, false)); - } + if (player.worldObj.isRemote) { + try { + Class clazz = ReflectionUtils.getClass("net.minecraft.client.gui.GuiScreenBook"); + Constructor ctor = clazz.getConstructor(EntityPlayer.class, ItemStack.class, boolean.class); + Object object = ctor.newInstance(new Object[] {player, bookstack, false}); + Minecraft.getMinecraft().displayGuiScreen((GuiScreen) object); + } catch (InstantiationException + | IllegalAccessException + | IllegalArgumentException + | InvocationTargetException + | NoSuchMethodException + | SecurityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // Minecraft.getMinecraft().displayGuiScreen(new GuiScreenBook(player, bookstack, false)); + } return item; - } - + } } diff --git a/src/main/java/gtPlusPlus/core/item/general/capture/ItemEntityCatcher.java b/src/main/java/gtPlusPlus/core/item/general/capture/ItemEntityCatcher.java index a95fab4b6c..382765b015 100644 --- a/src/main/java/gtPlusPlus/core/item/general/capture/ItemEntityCatcher.java +++ b/src/main/java/gtPlusPlus/core/item/general/capture/ItemEntityCatcher.java @@ -1,18 +1,6 @@ package gtPlusPlus.core.item.general.capture; -import java.util.List; -import java.util.UUID; - import cpw.mods.fml.common.registry.GameRegistry; - -import net.minecraft.entity.*; -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.EnumChatFormatting; -import net.minecraft.world.World; - import gtPlusPlus.api.interfaces.IEntityCatcher; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.minecraft.BlockPos; @@ -22,225 +10,240 @@ import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.NBTUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import java.util.List; +import java.util.UUID; +import net.minecraft.entity.*; +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.EnumChatFormatting; +import net.minecraft.world.World; public class ItemEntityCatcher extends Item implements IEntityCatcher { - // PlayerInteractEvent.EntityInteract; - - - public ItemEntityCatcher() { - //Probably won't ever need this event handler. - //Utils.registerEvent(this); - this.setUnlocalizedName("itemDragonJar"); - this.setTextureName(CORE.MODID + ":" + getUnlocalizedName()); - this.setCreativeTab(AddToCreativeTab.tabMisc); - this.setMaxStackSize(16); - this.setMaxDamage(0); - GameRegistry.registerItem(this, getUnlocalizedName()); - } - - @Override - public boolean hasEntity(ItemStack aStack) { - if (NBTUtils.hasKey(aStack, "mHasEntity")) { - return NBTUtils.getBoolean(aStack, "mHasEntity"); - } - return false; - } - - @Override - public Entity getStoredEntity(World aWorld, ItemStack aStack) { - if (aStack == null || !hasEntity(aStack)) { - Logger.INFO("Cannot get stored entity."); - return null; - } - - Entity mEntityToSpawn; - int mEntityID; - Logger.WARNING("getStoredEntity(1)"); - - mEntityID = NBTUtils.getInteger(aStack, "mEntityID"); - mEntityToSpawn = EntityList.createEntityByID(mEntityID, aWorld); - if (mEntityToSpawn != null) { - Logger.WARNING("getStoredEntity(2)"); - return mEntityToSpawn; - } - - Logger.INFO("Failed to get stored entity. - getStoredEntity()"); - return null; - } - - @Override - public boolean setStoredEntity(World aWorld, ItemStack aStack, Entity aEntity) { - if (aEntity == null) { - NBTUtils.setBoolean(aStack, "mHasEntity", false); - Logger.INFO("Bad Entity being stored."); - return false; - } - - Logger.WARNING("setStoredEntity(1)"); - - NBTTagCompound mEntityData; - Class mEntityClass; - String mClassName; - String mEntityName; - int mEntityID, mEntityHashcode; - UUID mUuidPersistent, mUuidUnique; - Logger.WARNING("setStoredEntity(2)"); - - mEntityData = aEntity.getEntityData(); - mEntityClass = aEntity.getClass(); - mClassName = mEntityClass.getName(); - mEntityName = aEntity.getCommandSenderName(); - // mEntityID = aEntity.getEntityId(); - mEntityID = EntityList.getEntityID(aEntity); - mEntityHashcode = aEntity.hashCode(); - mUuidPersistent = aEntity.getPersistentID(); - mUuidUnique = aEntity.getUniqueID(); - Logger.WARNING("setStoredEntity(3)"); - - NBTUtils.createTagCompound(aStack, "mEntityData", mEntityData); - NBTUtils.setString(aStack,"mEntityName", mEntityName); - NBTUtils.setInteger(aStack,"mEntityID", mEntityID); - NBTUtils.setString(aStack,"mClassName", mClassName); - NBTUtils.setString(aStack,"mUuidPersistent", mUuidPersistent.toString()); - NBTUtils.setString(aStack,"mUuidUnique", mUuidUnique.toString()); - NBTUtils.setInteger(aStack,"mEntityHashcode", mEntityHashcode); - NBTUtils.setBoolean(aStack,"mHasEntity", true); - Logger.WARNING("setStoredEntity(4)"); - return true; - } - - @SuppressWarnings("unchecked") - @Override - public Class getStoredEntityClass(ItemStack aStack) { - if (aStack == null || !hasEntity(aStack)) { - return null; - } - Class mEntityClass; - String mClassName; - mClassName = NBTUtils.getString(aStack, "mClassName"); - mEntityClass = (Class) ReflectionUtils.getClass(mClassName); - if (mEntityClass != null) { - return mEntityClass; - } - return null; - } - - @Override - public boolean spawnStoredEntity(World aWorld, ItemStack aStack, BlockPos aPos) { - if (aStack == null || !hasEntity(aStack)) { - Logger.INFO("Cannot release, either invalid Itemstack or no entity stored."); - return false; - } - - NBTTagCompound mEntityData = NBTUtils.getTagCompound(aStack, "mEntityData"); - - int mEntityID = NBTUtils.getInteger(aStack,"mEntityID"); - String mClassName = NBTUtils.getString(aStack,"mClassName"); - UUID mUuidPersistent = UUID.fromString(NBTUtils.getString(aStack,"mUuidPersistent")); - UUID mUuidUnique = UUID.fromString(NBTUtils.getString(aStack,"mUuidUnique")); - int mEntityHashcode = NBTUtils.getInteger(aStack,"mEntityHashcode"); - - EntityLiving mEntityToSpawn = (EntityLiving) getStoredEntity(aWorld, aStack); - Class mEntityClass = getStoredEntityClass(aStack); - - Logger.WARNING("spawnStoredEntity(1)"); - - if (mEntityToSpawn != null && mEntityClass != null) { - Logger.WARNING("spawnStoredEntity(2)"); - if (mEntityToSpawn.getEntityData() != mEntityData) { - Logger.WARNING("spawnStoredEntity(x)"); - NBTUtils.setEntityCustomData(mEntityToSpawn, mEntityData); - } - - mEntityToSpawn.setLocationAndAngles(aPos.xPos, aPos.yPos, aPos.zPos, aWorld.rand.nextFloat() * 360.0F, - 0.0F); - if (mEntityToSpawn != null) { - mEntityToSpawn.onSpawnWithEgg(null); - aWorld.spawnEntityInWorld(mEntityToSpawn); - Logger.WARNING("spawnStoredEntity(3)"); - } - if (mEntityToSpawn != null) { - mEntityToSpawn.playLivingSound(); - Logger.WARNING("spawnStoredEntity(4)"); - } - Logger.WARNING("spawnStoredEntity(5)"); - NBTUtils.setBoolean(aStack,"mHasEntity", false); - return true; - } - Logger.INFO("Failed to spawn stored entity. - spawnStoredEntity()"); - return false; - } - - @Override - public ItemStack onItemRightClick(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { - return super.onItemRightClick(aStack, aWorld, aPlayer); - } - - @Override - public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List p_77624_3_, boolean p_77624_4_) { - if (hasEntity(p_77624_1_)){ - String mName = NBTUtils.getString(p_77624_1_,"mEntityName"); - if (mName != null && !mName.equals("")){ - p_77624_3_.add(EnumChatFormatting.GRAY+"Contains a "+mName+"."); - } - } - else { - p_77624_3_.add(EnumChatFormatting.GRAY+"Does not contain anything."); - } - } - - @Override - public boolean showDurabilityBar(ItemStack stack) { - return false; - } - - @Override - public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, - float xOffset, float yOffset, float zOffset) { - if (Utils.isServer()) { - Logger.WARNING("Trying to release (1)"); - if (NBTUtils.hasKey(itemstack,"mHasEntity") - && NBTUtils.getBoolean(itemstack,"mHasEntity")) { - Logger.WARNING("Trying to release (2)"); - boolean mDidSpawn = spawnStoredEntity(world, itemstack, new BlockPos(x, y+1, z, world)); - - if (!mDidSpawn){ - PlayerUtils.messagePlayer(player, "You failed to release a "+NBTUtils.getString(itemstack,"mEntityName")+"."); - } - - return mDidSpawn; - - } - } - return super.onItemUse(itemstack, player, world, x, y, z, side, xOffset, yOffset, zOffset); - - } - - @Override - public boolean itemInteractionForEntity(ItemStack aStack, EntityPlayer aPlayer, EntityLivingBase aEntity) { - if (Utils.isServer()) { - Logger.WARNING("Trying to catch (1)"); - if (!hasEntity(aStack)) { - Logger.WARNING("Trying to catch (2)"); - boolean mStored = setStoredEntity(aPlayer.worldObj, aStack, aEntity); - if (mStored) { - Logger.WARNING("Trying to catch (3)"); - aEntity.setDead(); - PlayerUtils.messagePlayer(aPlayer, "You have captured a "+NBTUtils.getString(aStack,"mEntityName")+" in the Jar."); - //NBTUtils.tryIterateNBTData(aStack); - } - } - } - return super.itemInteractionForEntity(aStack, aPlayer, aEntity); - } - - @Override - public String getItemStackDisplayName(ItemStack aStack) { - if (hasEntity(aStack)){ - return "Captured Dragon Jar"; - } - return "Dragon Capture Jar"; - } - + // PlayerInteractEvent.EntityInteract; + + public ItemEntityCatcher() { + // Probably won't ever need this event handler. + // Utils.registerEvent(this); + this.setUnlocalizedName("itemDragonJar"); + this.setTextureName(CORE.MODID + ":" + getUnlocalizedName()); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setMaxStackSize(16); + this.setMaxDamage(0); + GameRegistry.registerItem(this, getUnlocalizedName()); + } + + @Override + public boolean hasEntity(ItemStack aStack) { + if (NBTUtils.hasKey(aStack, "mHasEntity")) { + return NBTUtils.getBoolean(aStack, "mHasEntity"); + } + return false; + } + + @Override + public Entity getStoredEntity(World aWorld, ItemStack aStack) { + if (aStack == null || !hasEntity(aStack)) { + Logger.INFO("Cannot get stored entity."); + return null; + } + + Entity mEntityToSpawn; + int mEntityID; + Logger.WARNING("getStoredEntity(1)"); + + mEntityID = NBTUtils.getInteger(aStack, "mEntityID"); + mEntityToSpawn = EntityList.createEntityByID(mEntityID, aWorld); + if (mEntityToSpawn != null) { + Logger.WARNING("getStoredEntity(2)"); + return mEntityToSpawn; + } + + Logger.INFO("Failed to get stored entity. - getStoredEntity()"); + return null; + } + + @Override + public boolean setStoredEntity(World aWorld, ItemStack aStack, Entity aEntity) { + if (aEntity == null) { + NBTUtils.setBoolean(aStack, "mHasEntity", false); + Logger.INFO("Bad Entity being stored."); + return false; + } + + Logger.WARNING("setStoredEntity(1)"); + + NBTTagCompound mEntityData; + Class mEntityClass; + String mClassName; + String mEntityName; + int mEntityID, mEntityHashcode; + UUID mUuidPersistent, mUuidUnique; + Logger.WARNING("setStoredEntity(2)"); + + mEntityData = aEntity.getEntityData(); + mEntityClass = aEntity.getClass(); + mClassName = mEntityClass.getName(); + mEntityName = aEntity.getCommandSenderName(); + // mEntityID = aEntity.getEntityId(); + mEntityID = EntityList.getEntityID(aEntity); + mEntityHashcode = aEntity.hashCode(); + mUuidPersistent = aEntity.getPersistentID(); + mUuidUnique = aEntity.getUniqueID(); + Logger.WARNING("setStoredEntity(3)"); + + NBTUtils.createTagCompound(aStack, "mEntityData", mEntityData); + NBTUtils.setString(aStack, "mEntityName", mEntityName); + NBTUtils.setInteger(aStack, "mEntityID", mEntityID); + NBTUtils.setString(aStack, "mClassName", mClassName); + NBTUtils.setString(aStack, "mUuidPersistent", mUuidPersistent.toString()); + NBTUtils.setString(aStack, "mUuidUnique", mUuidUnique.toString()); + NBTUtils.setInteger(aStack, "mEntityHashcode", mEntityHashcode); + NBTUtils.setBoolean(aStack, "mHasEntity", true); + Logger.WARNING("setStoredEntity(4)"); + return true; + } + + @SuppressWarnings("unchecked") + @Override + public Class getStoredEntityClass(ItemStack aStack) { + if (aStack == null || !hasEntity(aStack)) { + return null; + } + Class mEntityClass; + String mClassName; + mClassName = NBTUtils.getString(aStack, "mClassName"); + mEntityClass = (Class) ReflectionUtils.getClass(mClassName); + if (mEntityClass != null) { + return mEntityClass; + } + return null; + } + + @Override + public boolean spawnStoredEntity(World aWorld, ItemStack aStack, BlockPos aPos) { + if (aStack == null || !hasEntity(aStack)) { + Logger.INFO("Cannot release, either invalid Itemstack or no entity stored."); + return false; + } + + NBTTagCompound mEntityData = NBTUtils.getTagCompound(aStack, "mEntityData"); + + int mEntityID = NBTUtils.getInteger(aStack, "mEntityID"); + String mClassName = NBTUtils.getString(aStack, "mClassName"); + UUID mUuidPersistent = UUID.fromString(NBTUtils.getString(aStack, "mUuidPersistent")); + UUID mUuidUnique = UUID.fromString(NBTUtils.getString(aStack, "mUuidUnique")); + int mEntityHashcode = NBTUtils.getInteger(aStack, "mEntityHashcode"); + + EntityLiving mEntityToSpawn = (EntityLiving) getStoredEntity(aWorld, aStack); + Class mEntityClass = getStoredEntityClass(aStack); + + Logger.WARNING("spawnStoredEntity(1)"); + + if (mEntityToSpawn != null && mEntityClass != null) { + Logger.WARNING("spawnStoredEntity(2)"); + if (mEntityToSpawn.getEntityData() != mEntityData) { + Logger.WARNING("spawnStoredEntity(x)"); + NBTUtils.setEntityCustomData(mEntityToSpawn, mEntityData); + } + + mEntityToSpawn.setLocationAndAngles( + aPos.xPos, aPos.yPos, aPos.zPos, aWorld.rand.nextFloat() * 360.0F, 0.0F); + if (mEntityToSpawn != null) { + mEntityToSpawn.onSpawnWithEgg(null); + aWorld.spawnEntityInWorld(mEntityToSpawn); + Logger.WARNING("spawnStoredEntity(3)"); + } + if (mEntityToSpawn != null) { + mEntityToSpawn.playLivingSound(); + Logger.WARNING("spawnStoredEntity(4)"); + } + Logger.WARNING("spawnStoredEntity(5)"); + NBTUtils.setBoolean(aStack, "mHasEntity", false); + return true; + } + Logger.INFO("Failed to spawn stored entity. - spawnStoredEntity()"); + return false; + } + + @Override + public ItemStack onItemRightClick(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { + return super.onItemRightClick(aStack, aWorld, aPlayer); + } + + @Override + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List p_77624_3_, boolean p_77624_4_) { + if (hasEntity(p_77624_1_)) { + String mName = NBTUtils.getString(p_77624_1_, "mEntityName"); + if (mName != null && !mName.equals("")) { + p_77624_3_.add(EnumChatFormatting.GRAY + "Contains a " + mName + "."); + } + } else { + p_77624_3_.add(EnumChatFormatting.GRAY + "Does not contain anything."); + } + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } + + @Override + public boolean onItemUse( + ItemStack itemstack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float xOffset, + float yOffset, + float zOffset) { + if (Utils.isServer()) { + Logger.WARNING("Trying to release (1)"); + if (NBTUtils.hasKey(itemstack, "mHasEntity") && NBTUtils.getBoolean(itemstack, "mHasEntity")) { + Logger.WARNING("Trying to release (2)"); + boolean mDidSpawn = spawnStoredEntity(world, itemstack, new BlockPos(x, y + 1, z, world)); + + if (!mDidSpawn) { + PlayerUtils.messagePlayer( + player, "You failed to release a " + NBTUtils.getString(itemstack, "mEntityName") + "."); + } + + return mDidSpawn; + } + } + return super.onItemUse(itemstack, player, world, x, y, z, side, xOffset, yOffset, zOffset); + } + + @Override + public boolean itemInteractionForEntity(ItemStack aStack, EntityPlayer aPlayer, EntityLivingBase aEntity) { + if (Utils.isServer()) { + Logger.WARNING("Trying to catch (1)"); + if (!hasEntity(aStack)) { + Logger.WARNING("Trying to catch (2)"); + boolean mStored = setStoredEntity(aPlayer.worldObj, aStack, aEntity); + if (mStored) { + Logger.WARNING("Trying to catch (3)"); + aEntity.setDead(); + PlayerUtils.messagePlayer( + aPlayer, + "You have captured a " + NBTUtils.getString(aStack, "mEntityName") + " in the Jar."); + // NBTUtils.tryIterateNBTData(aStack); + } + } + } + return super.itemInteractionForEntity(aStack, aPlayer, aEntity); + } + + @Override + public String getItemStackDisplayName(ItemStack aStack) { + if (hasEntity(aStack)) { + return "Captured Dragon Jar"; + } + return "Dragon Capture Jar"; + } } diff --git a/src/main/java/gtPlusPlus/core/item/general/chassis/ItemBoilerChassis.java b/src/main/java/gtPlusPlus/core/item/general/chassis/ItemBoilerChassis.java index 86c52cc048..ba726bd3ec 100644 --- a/src/main/java/gtPlusPlus/core/item/general/chassis/ItemBoilerChassis.java +++ b/src/main/java/gtPlusPlus/core/item/general/chassis/ItemBoilerChassis.java @@ -1,86 +1,77 @@ package gtPlusPlus.core.item.general.chassis; -import java.util.List; import cpw.mods.fml.common.registry.GameRegistry; - +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; - public class ItemBoilerChassis extends Item { - public IIcon[] icons = new IIcon[1]; - - public ItemBoilerChassis() { - super(); - this.setHasSubtypes(true); - String unlocalizedName = "itemBoilerChassis"; - this.setUnlocalizedName(unlocalizedName); - this.setCreativeTab(AddToCreativeTab.tabMisc); - GameRegistry.registerItem(this, unlocalizedName); - } + public IIcon[] icons = new IIcon[1]; - @Override - public void registerIcons(IIconRegister reg) { - this.icons[0] = reg.registerIcon(CORE.MODID + ":" + "itemBoilerChassis"); - } + public ItemBoilerChassis() { + super(); + this.setHasSubtypes(true); + String unlocalizedName = "itemBoilerChassis"; + this.setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + GameRegistry.registerItem(this, unlocalizedName); + } - @Override - public IIcon getIconFromDamage(int meta) { - return this.icons[0]; - } + @Override + public void registerIcons(IIconRegister reg) { + this.icons[0] = reg.registerIcon(CORE.MODID + ":" + "itemBoilerChassis"); + } - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < 3; i ++) { - list.add(new ItemStack(item, 1, i)); - } - } + @Override + public IIcon getIconFromDamage(int meta) { + return this.icons[0]; + } - @Override - public String getUnlocalizedName(ItemStack stack) { - return this.getUnlocalizedName() + "_" + stack.getItemDamage(); - } + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 3; i++) { + list.add(new ItemStack(item, 1, i)); + } + } - @Override - public String getItemStackDisplayName(final ItemStack tItem) { - String itemName = "Advanced Boiler Chassis"; - String suffixName = ""; - if (tItem.getItemDamage() == 0){ - suffixName = " [Tier 1]"; - } - else if (tItem.getItemDamage() == 1){ - suffixName = " [Tier 2]"; - } - else if (tItem.getItemDamage() == 2){ - suffixName = " [Tier 3]"; - } - return (itemName+suffixName); - - } + @Override + public String getUnlocalizedName(ItemStack stack) { + return this.getUnlocalizedName() + "_" + stack.getItemDamage(); + } - @Override //TODO - public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { - int meta = stack.getItemDamage(); - if (meta == 0){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(10,110,30); - } - else if (meta == 1){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(150,180,35); - } - else if (meta == 2){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(200,85,40); - } - else if (meta == 3){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(255,100,50); - } - return HEX_OxFFFFFF; - } + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + String itemName = "Advanced Boiler Chassis"; + String suffixName = ""; + if (tItem.getItemDamage() == 0) { + suffixName = " [Tier 1]"; + } else if (tItem.getItemDamage() == 1) { + suffixName = " [Tier 2]"; + } else if (tItem.getItemDamage() == 2) { + suffixName = " [Tier 3]"; + } + return (itemName + suffixName); + } -} \ No newline at end of file + @Override // TODO + public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { + int meta = stack.getItemDamage(); + if (meta == 0) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(10, 110, 30); + } else if (meta == 1) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(150, 180, 35); + } else if (meta == 2) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(200, 85, 40); + } else if (meta == 3) { + HEX_OxFFFFFF = Utils.rgbtoHexValue(255, 100, 50); + } + return HEX_OxFFFFFF; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/general/chassis/ItemDehydratorCoil.java b/src/main/java/gtPlusPlus/core/item/general/chassis/ItemDehydratorCoil.java index be1fdfc491..11828ce4ea 100644 --- a/src/main/java/gtPlusPlus/core/item/general/chassis/ItemDehydratorCoil.java +++ b/src/main/java/gtPlusPlus/core/item/general/chassis/ItemDehydratorCoil.java @@ -1,93 +1,85 @@ package gtPlusPlus.core.item.general.chassis; -import java.util.List; - import cpw.mods.fml.common.registry.GameRegistry; - +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; - public class ItemDehydratorCoil extends Item { - public IIcon[] icons = new IIcon[4]; + public IIcon[] icons = new IIcon[4]; - public ItemDehydratorCoil() { - super(); - this.setHasSubtypes(true); - String unlocalizedName = "itemDehydratorCoil"; - this.setUnlocalizedName(unlocalizedName); - this.setCreativeTab(AddToCreativeTab.tabMisc); - GameRegistry.registerItem(this, unlocalizedName); - } + public ItemDehydratorCoil() { + super(); + this.setHasSubtypes(true); + String unlocalizedName = "itemDehydratorCoil"; + this.setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + GameRegistry.registerItem(this, unlocalizedName); + } - @Override - public void registerIcons(IIconRegister reg) { - this.icons[0] = reg.registerIcon(CORE.MODID + ":" + "dehydrator/itemDehydratorCoil_0"); - this.icons[1] = reg.registerIcon(CORE.MODID + ":" + "dehydrator/itemDehydratorCoil_1"); - this.icons[2] = reg.registerIcon(CORE.MODID + ":" + "dehydrator/itemDehydratorCoil_2"); - this.icons[3] = reg.registerIcon(CORE.MODID + ":" + "dehydrator/itemDehydratorCoil_3"); - } + @Override + public void registerIcons(IIconRegister reg) { + this.icons[0] = reg.registerIcon(CORE.MODID + ":" + "dehydrator/itemDehydratorCoil_0"); + this.icons[1] = reg.registerIcon(CORE.MODID + ":" + "dehydrator/itemDehydratorCoil_1"); + this.icons[2] = reg.registerIcon(CORE.MODID + ":" + "dehydrator/itemDehydratorCoil_2"); + this.icons[3] = reg.registerIcon(CORE.MODID + ":" + "dehydrator/itemDehydratorCoil_3"); + } - @Override - public IIcon getIconFromDamage(int meta) { - return this.icons[meta]; - } + @Override + public IIcon getIconFromDamage(int meta) { + return this.icons[meta]; + } - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < 4; i ++) { - list.add(new ItemStack(item, 1, i)); - } - } + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 4; i++) { + list.add(new ItemStack(item, 1, i)); + } + } - @Override - public String getUnlocalizedName(ItemStack stack) { - return this.getUnlocalizedName() + "_" + stack.getItemDamage(); - } + @Override + public String getUnlocalizedName(ItemStack stack) { + return this.getUnlocalizedName() + "_" + stack.getItemDamage(); + } - @Override - public String getItemStackDisplayName(final ItemStack tItem) { - String itemName = "Dehydrator Coil"; - String suffixName = ""; - if (tItem.getItemDamage() == 0){ - suffixName = " [EV]"; - } - else if (tItem.getItemDamage() == 1){ - suffixName = " [IV]"; - } - else if (tItem.getItemDamage() == 2){ - suffixName = " [LuV]"; - } - else if (tItem.getItemDamage() == 3){ - suffixName = " [ZPM]"; - } - return (itemName+suffixName); - - } + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + String itemName = "Dehydrator Coil"; + String suffixName = ""; + if (tItem.getItemDamage() == 0) { + suffixName = " [EV]"; + } else if (tItem.getItemDamage() == 1) { + suffixName = " [IV]"; + } else if (tItem.getItemDamage() == 2) { + suffixName = " [LuV]"; + } else if (tItem.getItemDamage() == 3) { + suffixName = " [ZPM]"; + } + return (itemName + suffixName); + } - /*@Override - public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { - int meta = stack.getItemDamage(); - if (meta == 0){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(10,110,30); - } - else if (meta == 1){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(150,180,35); - } - else if (meta == 2){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(200,85,40); - } - else if (meta == 3){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(255,150,50); - } - return HEX_OxFFFFFF; - }*/ + /*@Override + public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { + int meta = stack.getItemDamage(); + if (meta == 0){ + HEX_OxFFFFFF = Utils.rgbtoHexValue(10,110,30); + } + else if (meta == 1){ + HEX_OxFFFFFF = Utils.rgbtoHexValue(150,180,35); + } + else if (meta == 2){ + HEX_OxFFFFFF = Utils.rgbtoHexValue(200,85,40); + } + else if (meta == 3){ + HEX_OxFFFFFF = Utils.rgbtoHexValue(255,150,50); + } + return HEX_OxFFFFFF; + }*/ -} \ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/core/item/general/chassis/ItemDehydratorCoilWire.java b/src/main/java/gtPlusPlus/core/item/general/chassis/ItemDehydratorCoilWire.java index 99d4a139dd..57cd2fe663 100644 --- a/src/main/java/gtPlusPlus/core/item/general/chassis/ItemDehydratorCoilWire.java +++ b/src/main/java/gtPlusPlus/core/item/general/chassis/ItemDehydratorCoilWire.java @@ -1,93 +1,85 @@ package gtPlusPlus.core.item.general.chassis; -import java.util.List; - import cpw.mods.fml.common.registry.GameRegistry; - +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; - public class ItemDehydratorCoilWire extends Item { - public IIcon[] icons = new IIcon[4]; + public IIcon[] icons = new IIcon[4]; - public ItemDehydratorCoilWire() { - super(); - this.setHasSubtypes(true); - String unlocalizedName = "itemDehydratorCoilWire"; - this.setUnlocalizedName(unlocalizedName); - this.setCreativeTab(AddToCreativeTab.tabMisc); - GameRegistry.registerItem(this, unlocalizedName); - } + public ItemDehydratorCoilWire() { + super(); + this.setHasSubtypes(true); + String unlocalizedName = "itemDehydratorCoilWire"; + this.setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + GameRegistry.registerItem(this, unlocalizedName); + } - @Override - public void registerIcons(IIconRegister reg) { - this.icons[0] = reg.registerIcon(CORE.MODID + ":" + "dehydrator/itemDehydratorCoilWire_0"); - this.icons[1] = reg.registerIcon(CORE.MODID + ":" + "dehydrator/itemDehydratorCoilWire_1"); - this.icons[2] = reg.registerIcon(CORE.MODID + ":" + "dehydrator/itemDehydratorCoilWire_2"); - this.icons[3] = reg.registerIcon(CORE.MODID + ":" + "dehydrator/itemDehydratorCoilWire_3"); - } + @Override + public void registerIcons(IIconRegister reg) { + this.icons[0] = reg.registerIcon(CORE.MODID + ":" + "dehydrator/itemDehydratorCoilWire_0"); + this.icons[1] = reg.registerIcon(CORE.MODID + ":" + "dehydrator/itemDehydratorCoilWire_1"); + this.icons[2] = reg.registerIcon(CORE.MODID + ":" + "dehydrator/itemDehydratorCoilWire_2"); + this.icons[3] = reg.registerIcon(CORE.MODID + ":" + "dehydrator/itemDehydratorCoilWire_3"); + } - @Override - public IIcon getIconFromDamage(int meta) { - return this.icons[meta]; - } + @Override + public IIcon getIconFromDamage(int meta) { + return this.icons[meta]; + } - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < 4; i ++) { - list.add(new ItemStack(item, 1, i)); - } - } + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 4; i++) { + list.add(new ItemStack(item, 1, i)); + } + } - @Override - public String getUnlocalizedName(ItemStack stack) { - return this.getUnlocalizedName() + "_" + stack.getItemDamage(); - } + @Override + public String getUnlocalizedName(ItemStack stack) { + return this.getUnlocalizedName() + "_" + stack.getItemDamage(); + } - @Override - public String getItemStackDisplayName(final ItemStack tItem) { - String itemName = "Coil Wire"; - String suffixName = ""; - if (tItem.getItemDamage() == 0){ - suffixName = " [EV]"; - } - else if (tItem.getItemDamage() == 1){ - suffixName = " [IV]"; - } - else if (tItem.getItemDamage() == 2){ - suffixName = " [LuV]"; - } - else if (tItem.getItemDamage() == 3){ - suffixName = " [ZPM]"; - } - return (itemName+suffixName); - - } + @Override + public String getItemStackDisplayName(final ItemStack tItem) { + String itemName = "Coil Wire"; + String suffixName = ""; + if (tItem.getItemDamage() == 0) { + suffixName = " [EV]"; + } else if (tItem.getItemDamage() == 1) { + suffixName = " [IV]"; + } else if (tItem.getItemDamage() == 2) { + suffixName = " [LuV]"; + } else if (tItem.getItemDamage() == 3) { + suffixName = " [ZPM]"; + } + return (itemName + suffixName); + } -/* @Override - public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { - int meta = stack.getItemDamage(); - if (meta == 0){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(10,110,30); - } - else if (meta == 1){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(150,180,35); - } - else if (meta == 2){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(200,85,40); - } - else if (meta == 3){ - HEX_OxFFFFFF = Utils.rgbtoHexValue(255,150,50); - } - return HEX_OxFFFFFF; - }*/ + /* @Override + public int getColorFromItemStack(final ItemStack stack, int HEX_OxFFFFFF) { + int meta = stack.getItemDamage(); + if (meta == 0){ + HEX_OxFFFFFF = Utils.rgbtoHexValue(10,110,30); + } + else if (meta == 1){ + HEX_OxFFFFFF = Utils.rgbtoHexValue(150,180,35); + } + else if (meta == 2){ + HEX_OxFFFFFF = Utils.rgbtoHexValue(200,85,40); + } + else if (meta == 3){ + HEX_OxFFFFFF = Utils.rgbtoHexValue(255,150,50); + } + return HEX_OxFFFFFF; + }*/ -} \ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/core/item/general/fuelrods/FuelRod_Base.java b/src/main/java/gtPlusPlus/core/item/general/fuelrods/FuelRod_Base.java index 628fba9291..97e5367936 100644 --- a/src/main/java/gtPlusPlus/core/item/general/fuelrods/FuelRod_Base.java +++ b/src/main/java/gtPlusPlus/core/item/general/fuelrods/FuelRod_Base.java @@ -1,7 +1,8 @@ package gtPlusPlus.core.item.general.fuelrods; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; import java.util.List; - import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -10,214 +11,203 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; - -public class FuelRod_Base extends Item{ - - public int fuelRemaining = 0; - public int maximumFuel = 0; - public String fuelType = ""; - public float heat = 0; - public float maxHeat = this.getMaxHeat(); - public FuelRod_Base(final String unlocalizedName, final String type, final int fuelLeft, final int maxFuel) { - this.setUnlocalizedName(unlocalizedName); - this.setTextureName(CORE.MODID + ":" + unlocalizedName); - this.setMaxStackSize(1); - this.setMaxDamage(maxFuel); - this.maximumFuel = maxFuel; - this.fuelRemaining = fuelLeft; - this.fuelType = type; - this.setCreativeTab(AddToCreativeTab.tabMachines); - } - - private float getMaxHeat(){ - float tempvar; - if (this.fuelType == "Thorium"){ - tempvar = 2500; - } - - else if (this.fuelType == "Uranium"){ - tempvar = 5000; - } - - else if (this.fuelType == "Plutonium"){ - tempvar = 10000; - } - - else { - tempvar = 5000; - } - return tempvar; - - } - - private void updateVars(final ItemStack stack){ - if (stack.stackTagCompound != null) { - this.heat = stack.stackTagCompound.getFloat("heat"); - this.fuelRemaining = stack.stackTagCompound.getInteger("fuelRemaining"); - } - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - - Float NBT_Heat = this.heat; - Float NBT_MaxHeat = this.maxHeat; - int NBT_Fuel = this.fuelRemaining; - String NBT_Type= this.fuelType; - - if (stack.stackTagCompound != null) { - NBT_Heat = stack.stackTagCompound.getFloat("heat"); - NBT_MaxHeat = stack.stackTagCompound.getFloat("maxHeat"); - NBT_Fuel = stack.stackTagCompound.getInteger("fuelRemaining"); - NBT_Type = stack.stackTagCompound.getString("fuelType"); - } - - final String tempHeat = String.valueOf(NBT_Heat); - final String tempMaxHeat = String.valueOf(NBT_MaxHeat); - final String tempFuel = String.valueOf(NBT_Fuel); - final String formattedType = EnumChatFormatting.DARK_RED+NBT_Type+EnumChatFormatting.GRAY; - String formattedHeat = EnumChatFormatting.RED+tempHeat+EnumChatFormatting.GRAY; - final String formattedMaxHeat = EnumChatFormatting.RED+tempMaxHeat+EnumChatFormatting.GRAY; - String formattedFuelLeft = tempFuel+EnumChatFormatting.GRAY; - - final int tempMax = this.maximumFuel; - final float tempCurrentHeat = this.heat; - final int tempFuelLeft = this.fuelRemaining; - - //Fuel Usage Formatting - if (tempFuelLeft <= (this.maximumFuel/3)){ - formattedFuelLeft = EnumChatFormatting.RED+tempFuel+EnumChatFormatting.GRAY; - } - else if ((tempFuelLeft >= (this.maximumFuel/3)) && (tempFuelLeft <= ((this.maximumFuel/3)*2))){ - formattedFuelLeft = EnumChatFormatting.YELLOW+tempFuel+EnumChatFormatting.GRAY; - } - else if ((tempFuelLeft >= ((this.maximumFuel/3)*2)) && (tempFuelLeft <= this.maximumFuel)){ - formattedFuelLeft = EnumChatFormatting.GREEN+tempFuel+EnumChatFormatting.GRAY; - } - else { - formattedFuelLeft = EnumChatFormatting.GRAY+tempFuel+EnumChatFormatting.GRAY; - } - - //Heat Formatting - if ((tempCurrentHeat <= 200) && (tempCurrentHeat >= 0)){ - formattedHeat = EnumChatFormatting.GRAY+tempHeat+EnumChatFormatting.GRAY; - } - else if ((tempCurrentHeat <= (this.maxHeat/3)) && (tempCurrentHeat > 200)){ - formattedHeat = EnumChatFormatting.YELLOW+tempHeat+EnumChatFormatting.GRAY; - } - else if ((tempCurrentHeat >= (this.maxHeat/3)) && (tempMax < ((this.maxHeat/3)*2)) && (tempCurrentHeat != 0)){ - formattedHeat = EnumChatFormatting.GOLD+tempHeat+EnumChatFormatting.GRAY; - } - else if ((tempCurrentHeat >= ((this.maxHeat/3)*2)) && (tempMax <= this.maxHeat) && (tempCurrentHeat != 0)){ - formattedHeat = EnumChatFormatting.RED+tempHeat+EnumChatFormatting.GRAY; - } - else { - formattedHeat = EnumChatFormatting.BLUE+tempHeat+EnumChatFormatting.GRAY; - } - list.add(EnumChatFormatting.GRAY+"A "+formattedType+" Fuel Rod."); - list.add(EnumChatFormatting.GRAY+"Running at "+formattedHeat+"/"+formattedMaxHeat+" Kelvin."); - list.add(EnumChatFormatting.GRAY+"Fuel Remaining: "+formattedFuelLeft+"L."); - super.addInformation(stack, aPlayer, list, bool); - } - - public String getType(final ItemStack stack){ - if (stack.stackTagCompound != null){ - return stack.stackTagCompound.getString("fuelType"); - } - return this.fuelType; - } - - public int getFuelRemaining(final ItemStack stack){ - if (stack.stackTagCompound != null){ - return stack.stackTagCompound.getInteger("fuelRemaining"); - } - return 0; - } - - public int getMaxFuel(){ - return this.maximumFuel; - } - - public int getFuel(final ItemStack stack){ - if (stack != null){ - final int i = stack.getItemDamage(); - final int r = this.maximumFuel - i; - return r; - } - return 0; - } - - public boolean setFuelRemainingExplicitly(final int i){ - final int tempFuel = this.fuelRemaining; - this.fuelRemaining = i; - if (i != tempFuel){ - return true; - } - return false; - } - - public boolean addFuel(final int i){ - final int tempFuel = this.fuelRemaining; - this.fuelRemaining = tempFuel+i; - if (this.fuelRemaining != tempFuel){ - return true; - } - return false; - } - - public float getHeat(final ItemStack value){ - if (value.stackTagCompound != null){ - return value.stackTagCompound.getFloat("heat"); - } - return 0f; - } - - public boolean addHeat(final float i){ - final float tempFuel = this.heat; - this.heat = tempFuel+i; - if (this.heat != tempFuel){ - return true; - } - return false; - } - - - //Ticking and NBT Handling - /* Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and - * update it's contents. - * - * public int fuelRemaining = 0; - public int maximumFuel = 0; - public String fuelType = ""; - public float heat = 0; - public float maxHeat = 5000; - * - */ - @Override - public void onCreated(final ItemStack itemStack, final World world, final EntityPlayer player) { - itemStack.stackTagCompound = new NBTTagCompound(); - itemStack.stackTagCompound.setInteger("fuelRemaining", this.getFuelRemaining(itemStack)); - itemStack.stackTagCompound.setInteger("maximumFuel", this.maximumFuel); - itemStack.stackTagCompound.setFloat("heat", this.getHeat(itemStack)); - itemStack.stackTagCompound.setFloat("maxHeat", this.getMaxHeat()); - itemStack.stackTagCompound.setString("fuelType", this.getType(itemStack)); - this.updateVars(itemStack); - } - - @Override - public void onUpdate(final ItemStack itemStack, final World par2World, final Entity par3Entity, final int par4, final boolean par5) { - itemStack.stackTagCompound = new NBTTagCompound(); - itemStack.stackTagCompound.setInteger("fuelRemaining", this.getFuelRemaining(itemStack)); - itemStack.stackTagCompound.setInteger("maximumFuel", this.maximumFuel); - itemStack.stackTagCompound.setFloat("heat", this.getHeat(itemStack)); - itemStack.stackTagCompound.setFloat("maxHeat", this.getMaxHeat()); - itemStack.stackTagCompound.setString("fuelType", this.getType(itemStack)); - this.updateVars(itemStack); - } - - - +public class FuelRod_Base extends Item { + + public int fuelRemaining = 0; + public int maximumFuel = 0; + public String fuelType = ""; + public float heat = 0; + public float maxHeat = this.getMaxHeat(); + + public FuelRod_Base(final String unlocalizedName, final String type, final int fuelLeft, final int maxFuel) { + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setMaxStackSize(1); + this.setMaxDamage(maxFuel); + this.maximumFuel = maxFuel; + this.fuelRemaining = fuelLeft; + this.fuelType = type; + this.setCreativeTab(AddToCreativeTab.tabMachines); + } + + private float getMaxHeat() { + float tempvar; + if (this.fuelType == "Thorium") { + tempvar = 2500; + } else if (this.fuelType == "Uranium") { + tempvar = 5000; + } else if (this.fuelType == "Plutonium") { + tempvar = 10000; + } else { + tempvar = 5000; + } + return tempvar; + } + + private void updateVars(final ItemStack stack) { + if (stack.stackTagCompound != null) { + this.heat = stack.stackTagCompound.getFloat("heat"); + this.fuelRemaining = stack.stackTagCompound.getInteger("fuelRemaining"); + } + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + + Float NBT_Heat = this.heat; + Float NBT_MaxHeat = this.maxHeat; + int NBT_Fuel = this.fuelRemaining; + String NBT_Type = this.fuelType; + + if (stack.stackTagCompound != null) { + NBT_Heat = stack.stackTagCompound.getFloat("heat"); + NBT_MaxHeat = stack.stackTagCompound.getFloat("maxHeat"); + NBT_Fuel = stack.stackTagCompound.getInteger("fuelRemaining"); + NBT_Type = stack.stackTagCompound.getString("fuelType"); + } + + final String tempHeat = String.valueOf(NBT_Heat); + final String tempMaxHeat = String.valueOf(NBT_MaxHeat); + final String tempFuel = String.valueOf(NBT_Fuel); + final String formattedType = EnumChatFormatting.DARK_RED + NBT_Type + EnumChatFormatting.GRAY; + String formattedHeat = EnumChatFormatting.RED + tempHeat + EnumChatFormatting.GRAY; + final String formattedMaxHeat = EnumChatFormatting.RED + tempMaxHeat + EnumChatFormatting.GRAY; + String formattedFuelLeft = tempFuel + EnumChatFormatting.GRAY; + + final int tempMax = this.maximumFuel; + final float tempCurrentHeat = this.heat; + final int tempFuelLeft = this.fuelRemaining; + + // Fuel Usage Formatting + if (tempFuelLeft <= (this.maximumFuel / 3)) { + formattedFuelLeft = EnumChatFormatting.RED + tempFuel + EnumChatFormatting.GRAY; + } else if ((tempFuelLeft >= (this.maximumFuel / 3)) && (tempFuelLeft <= ((this.maximumFuel / 3) * 2))) { + formattedFuelLeft = EnumChatFormatting.YELLOW + tempFuel + EnumChatFormatting.GRAY; + } else if ((tempFuelLeft >= ((this.maximumFuel / 3) * 2)) && (tempFuelLeft <= this.maximumFuel)) { + formattedFuelLeft = EnumChatFormatting.GREEN + tempFuel + EnumChatFormatting.GRAY; + } else { + formattedFuelLeft = EnumChatFormatting.GRAY + tempFuel + EnumChatFormatting.GRAY; + } + + // Heat Formatting + if ((tempCurrentHeat <= 200) && (tempCurrentHeat >= 0)) { + formattedHeat = EnumChatFormatting.GRAY + tempHeat + EnumChatFormatting.GRAY; + } else if ((tempCurrentHeat <= (this.maxHeat / 3)) && (tempCurrentHeat > 200)) { + formattedHeat = EnumChatFormatting.YELLOW + tempHeat + EnumChatFormatting.GRAY; + } else if ((tempCurrentHeat >= (this.maxHeat / 3)) + && (tempMax < ((this.maxHeat / 3) * 2)) + && (tempCurrentHeat != 0)) { + formattedHeat = EnumChatFormatting.GOLD + tempHeat + EnumChatFormatting.GRAY; + } else if ((tempCurrentHeat >= ((this.maxHeat / 3) * 2)) + && (tempMax <= this.maxHeat) + && (tempCurrentHeat != 0)) { + formattedHeat = EnumChatFormatting.RED + tempHeat + EnumChatFormatting.GRAY; + } else { + formattedHeat = EnumChatFormatting.BLUE + tempHeat + EnumChatFormatting.GRAY; + } + list.add(EnumChatFormatting.GRAY + "A " + formattedType + " Fuel Rod."); + list.add(EnumChatFormatting.GRAY + "Running at " + formattedHeat + "/" + formattedMaxHeat + " Kelvin."); + list.add(EnumChatFormatting.GRAY + "Fuel Remaining: " + formattedFuelLeft + "L."); + super.addInformation(stack, aPlayer, list, bool); + } + + public String getType(final ItemStack stack) { + if (stack.stackTagCompound != null) { + return stack.stackTagCompound.getString("fuelType"); + } + return this.fuelType; + } + + public int getFuelRemaining(final ItemStack stack) { + if (stack.stackTagCompound != null) { + return stack.stackTagCompound.getInteger("fuelRemaining"); + } + return 0; + } + + public int getMaxFuel() { + return this.maximumFuel; + } + + public int getFuel(final ItemStack stack) { + if (stack != null) { + final int i = stack.getItemDamage(); + final int r = this.maximumFuel - i; + return r; + } + return 0; + } + + public boolean setFuelRemainingExplicitly(final int i) { + final int tempFuel = this.fuelRemaining; + this.fuelRemaining = i; + if (i != tempFuel) { + return true; + } + return false; + } + + public boolean addFuel(final int i) { + final int tempFuel = this.fuelRemaining; + this.fuelRemaining = tempFuel + i; + if (this.fuelRemaining != tempFuel) { + return true; + } + return false; + } + + public float getHeat(final ItemStack value) { + if (value.stackTagCompound != null) { + return value.stackTagCompound.getFloat("heat"); + } + return 0f; + } + + public boolean addHeat(final float i) { + final float tempFuel = this.heat; + this.heat = tempFuel + i; + if (this.heat != tempFuel) { + return true; + } + return false; + } + + // Ticking and NBT Handling + /* Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and + * update it's contents. + * + * public int fuelRemaining = 0; + public int maximumFuel = 0; + public String fuelType = ""; + public float heat = 0; + public float maxHeat = 5000; + * + */ + @Override + public void onCreated(final ItemStack itemStack, final World world, final EntityPlayer player) { + itemStack.stackTagCompound = new NBTTagCompound(); + itemStack.stackTagCompound.setInteger("fuelRemaining", this.getFuelRemaining(itemStack)); + itemStack.stackTagCompound.setInteger("maximumFuel", this.maximumFuel); + itemStack.stackTagCompound.setFloat("heat", this.getHeat(itemStack)); + itemStack.stackTagCompound.setFloat("maxHeat", this.getMaxHeat()); + itemStack.stackTagCompound.setString("fuelType", this.getType(itemStack)); + this.updateVars(itemStack); + } + + @Override + public void onUpdate( + final ItemStack itemStack, + final World par2World, + final Entity par3Entity, + final int par4, + final boolean par5) { + itemStack.stackTagCompound = new NBTTagCompound(); + itemStack.stackTagCompound.setInteger("fuelRemaining", this.getFuelRemaining(itemStack)); + itemStack.stackTagCompound.setInteger("maximumFuel", this.maximumFuel); + itemStack.stackTagCompound.setFloat("heat", this.getHeat(itemStack)); + itemStack.stackTagCompound.setFloat("maxHeat", this.getMaxHeat()); + itemStack.stackTagCompound.setString("fuelType", this.getType(itemStack)); + this.updateVars(itemStack); + } } diff --git a/src/main/java/gtPlusPlus/core/item/general/fuelrods/FuelRod_Thorium.java b/src/main/java/gtPlusPlus/core/item/general/fuelrods/FuelRod_Thorium.java index dbf1209b50..4b25d0ae8b 100644 --- a/src/main/java/gtPlusPlus/core/item/general/fuelrods/FuelRod_Thorium.java +++ b/src/main/java/gtPlusPlus/core/item/general/fuelrods/FuelRod_Thorium.java @@ -1,13 +1,12 @@ package gtPlusPlus.core.item.general.fuelrods; -public class FuelRod_Thorium extends FuelRod_Base{ - - public FuelRod_Thorium(final String unlocalizedName, final String type, final int fuelLeft, final int maxFuel) { - super(unlocalizedName, type, fuelLeft, maxFuel); - this.setMaxDamage(maxFuel); - this.maximumFuel = maxFuel; - this.fuelRemaining = fuelLeft; - this.fuelType = type; - } +public class FuelRod_Thorium extends FuelRod_Base { + public FuelRod_Thorium(final String unlocalizedName, final String type, final int fuelLeft, final int maxFuel) { + super(unlocalizedName, type, fuelLeft, maxFuel); + this.setMaxDamage(maxFuel); + this.maximumFuel = maxFuel; + this.fuelRemaining = fuelLeft; + this.fuelType = type; + } } diff --git a/src/main/java/gtPlusPlus/core/item/general/rfchargingpack/ChargingPackBase.java b/src/main/java/gtPlusPlus/core/item/general/rfchargingpack/ChargingPackBase.java index 238e765384..d6919a4b80 100644 --- a/src/main/java/gtPlusPlus/core/item/general/rfchargingpack/ChargingPackBase.java +++ b/src/main/java/gtPlusPlus/core/item/general/rfchargingpack/ChargingPackBase.java @@ -1,84 +1,87 @@ package gtPlusPlus.core.item.general.rfchargingpack; -import java.util.List; - import cofh.api.energy.ItemEnergyContainer; +import gtPlusPlus.core.util.math.MathUtils; +import java.util.List; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; -import gtPlusPlus.core.util.math.MathUtils; - public class ChargingPackBase extends ItemEnergyContainer { - protected final int mCapacityMax; - protected final byte mTier; - - public ChargingPackBase(byte tier) { - this(tier, (tier == 1 ? 4000000 : tier == 2 ? 8000000 : tier == 3 ? 16000000 : tier == 4 ? 32000000 : 64000000)); - } + protected final int mCapacityMax; + protected final byte mTier; - private ChargingPackBase(byte tier, int maxStorage) { - super(maxStorage); - mTier = tier; - mCapacityMax = maxStorage; - } + public ChargingPackBase(byte tier) { + this( + tier, + (tier == 1 ? 4000000 : tier == 2 ? 8000000 : tier == 3 ? 16000000 : tier == 4 ? 32000000 : 64000000)); + } - public int getMaxEnergyInput(ItemStack container) - { - return this.maxReceive; - } + private ChargingPackBase(byte tier, int maxStorage) { + super(maxStorage); + mTier = tier; + mCapacityMax = maxStorage; + } - public int getMaxEnergyExtracted(ItemStack container) - { - return this.maxExtract; - } + public int getMaxEnergyInput(ItemStack container) { + return this.maxReceive; + } - @Override - public void onUpdate(ItemStack aStack, World aWorld, Entity aEnt, int p_77663_4_, boolean p_77663_5_) { - super.onUpdate(aStack, aWorld, aEnt, p_77663_4_, p_77663_5_); + public int getMaxEnergyExtracted(ItemStack container) { + return this.maxExtract; + } - ItemEnergyContainer current = this; - int currentStored = 0; - if (current != null) { - currentStored = current.getEnergyStored(aStack); - } - if (currentStored > 0) { - if (aEnt instanceof EntityPlayer) { - if (((EntityPlayer) aEnt).inventory != null) { - for (ItemStack invStack : ((EntityPlayer) aEnt).inventory.mainInventory) { - if (invStack != null) { - if (invStack.getItem() instanceof ItemEnergyContainer) { - if (current != null) { - currentStored = current.getEnergyStored(aStack); - if (currentStored > 0) { - int mTransLimit; - int mMaxStorage; - int mCurrent; - mTransLimit = getMaxEnergyInput(invStack); - mMaxStorage = current.getMaxEnergyStored(invStack); - mCurrent = current.getEnergyStored(invStack); - if (mCurrent+mTransLimit <= mMaxStorage) { - current.extractEnergy(aStack, current.receiveEnergy(invStack, mTransLimit, false), false); - } - } - } - } - } - } - } - } - } - } + @Override + public void onUpdate(ItemStack aStack, World aWorld, Entity aEnt, int p_77663_4_, boolean p_77663_5_) { + super.onUpdate(aStack, aWorld, aEnt, p_77663_4_, p_77663_5_); - @Override - public void addInformation(ItemStack stack, EntityPlayer p_77624_2_, List list, boolean p_77624_4_) { - list.add(EnumChatFormatting.RED+"RF Information"); - list.add(EnumChatFormatting.GRAY+"Extraction Rate: [" +EnumChatFormatting.RED+ this.maxExtract + EnumChatFormatting.GRAY + "Rf/t]" + " Insert Rate: [" +EnumChatFormatting.RED+ this.maxReceive+EnumChatFormatting.GRAY+"Rf/t]"); - list.add(EnumChatFormatting.GRAY+"Current Charge: ["+EnumChatFormatting.RED+this.getEnergyStored(stack) + EnumChatFormatting.GRAY + "Rf / " + this.getMaxEnergyStored(stack)+"Rf] "+EnumChatFormatting.RED+MathUtils.findPercentage(this.getEnergyStored(stack), this.getMaxEnergyStored(stack))+EnumChatFormatting.GRAY+"%"); - super.addInformation(stack, p_77624_2_, list, p_77624_4_); - } + ItemEnergyContainer current = this; + int currentStored = 0; + if (current != null) { + currentStored = current.getEnergyStored(aStack); + } + if (currentStored > 0) { + if (aEnt instanceof EntityPlayer) { + if (((EntityPlayer) aEnt).inventory != null) { + for (ItemStack invStack : ((EntityPlayer) aEnt).inventory.mainInventory) { + if (invStack != null) { + if (invStack.getItem() instanceof ItemEnergyContainer) { + if (current != null) { + currentStored = current.getEnergyStored(aStack); + if (currentStored > 0) { + int mTransLimit; + int mMaxStorage; + int mCurrent; + mTransLimit = getMaxEnergyInput(invStack); + mMaxStorage = current.getMaxEnergyStored(invStack); + mCurrent = current.getEnergyStored(invStack); + if (mCurrent + mTransLimit <= mMaxStorage) { + current.extractEnergy( + aStack, current.receiveEnergy(invStack, mTransLimit, false), false); + } + } + } + } + } + } + } + } + } + } + @Override + public void addInformation(ItemStack stack, EntityPlayer p_77624_2_, List list, boolean p_77624_4_) { + list.add(EnumChatFormatting.RED + "RF Information"); + list.add(EnumChatFormatting.GRAY + "Extraction Rate: [" + EnumChatFormatting.RED + this.maxExtract + + EnumChatFormatting.GRAY + "Rf/t]" + " Insert Rate: [" + EnumChatFormatting.RED + this.maxReceive + + EnumChatFormatting.GRAY + "Rf/t]"); + list.add(EnumChatFormatting.GRAY + "Current Charge: [" + EnumChatFormatting.RED + this.getEnergyStored(stack) + + EnumChatFormatting.GRAY + "Rf / " + this.getMaxEnergyStored(stack) + "Rf] " + EnumChatFormatting.RED + + MathUtils.findPercentage(this.getEnergyStored(stack), this.getMaxEnergyStored(stack)) + + EnumChatFormatting.GRAY + "%"); + super.addInformation(stack, p_77624_2_, list, p_77624_4_); + } } diff --git a/src/main/java/gtPlusPlus/core/item/general/spawn/ItemCustomSpawnEgg.java b/src/main/java/gtPlusPlus/core/item/general/spawn/ItemCustomSpawnEgg.java index 727b933fa7..a8d57c9892 100644 --- a/src/main/java/gtPlusPlus/core/item/general/spawn/ItemCustomSpawnEgg.java +++ b/src/main/java/gtPlusPlus/core/item/general/spawn/ItemCustomSpawnEgg.java @@ -1,15 +1,14 @@ package gtPlusPlus.core.item.general.spawn; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.ItemUtils; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.block.BlockLiquid; import net.minecraft.client.renderer.texture.IIconRegister; @@ -22,264 +21,271 @@ import net.minecraft.world.World; public class ItemCustomSpawnEgg extends ItemMonsterPlacer { - private static final HashMap mIconMap = new HashMap(); - private static int mTotalMetaItems = 0; - - private static final HashMap mMaxStackSizeMap = new HashMap(); - private static final HashMap mRarityMap = new HashMap(); - private static final HashMap> mOreDictNames = new HashMap>(); - - private static final HashMap mColourBaseMap = new HashMap(); - private static final HashMap mColourSpotsMap = new HashMap(); - private static final HashMap mEntityNameMap = new HashMap(); - private static final HashMap mEntityFullNameMap = new HashMap(); - - private static final HashMap mReverseEntityMap = new HashMap(); - - protected EntityLiving entityToSpawn = null; - - public static ItemStack getSpawnEggForEntityname(String aEntityName, int aSize) { - return ItemUtils.simpleMetaStack(ModItems.itemCustomSpawnEgg, mReverseEntityMap.get(aEntityName), aSize); - } - - public static void registerEntityForSpawnEgg(final int aMetaID, String parEntityToSpawnName, int aPrimaryColor, int aSecondaryColor) { - registerEntityForSpawnEgg(aMetaID, parEntityToSpawnName, aPrimaryColor, aSecondaryColor, EnumRarity.common, new ArrayList()); - } - - public static void registerEntityForSpawnEgg(final int aMetaID, String parEntityToSpawnName, int aPrimaryColor, int aSecondaryColor, EnumRarity aRarity, final ArrayList aOreDictNames) { - mTotalMetaItems++; - mMaxStackSizeMap.put(aMetaID, 64); - mRarityMap.put(aMetaID, aRarity); - mOreDictNames.put(aMetaID, aOreDictNames); - mColourBaseMap.put(aMetaID, aPrimaryColor); - mColourSpotsMap.put(aMetaID, aSecondaryColor); - mReverseEntityMap.put(parEntityToSpawnName, aMetaID); - setEntityToSpawnName(aMetaID, parEntityToSpawnName); - } - - public static void registerEggsToOreDict() { - for (int aMetaID = 0; aMetaID < mTotalMetaItems; aMetaID++) { - ArrayList aOreDictNames = mOreDictNames.get(aMetaID); - if (aOreDictNames != null && !aOreDictNames.isEmpty()) { - ItemStack aFoodStack = ItemUtils.simpleMetaStack(ModItems.itemCustomSpawnEgg, aMetaID, 1 - ); - for (String aOreName : aOreDictNames) { - ItemUtils.addItemToOreDictionary(aFoodStack, aOreName); - } - } - } - } - - public ItemCustomSpawnEgg() { - super(); - this.setNoRepair(); - this.setMaxStackSize(64); - this.setMaxDamage(0); - this.setUnlocalizedName("BasicMetaSpawnEgg"); - GameRegistry.registerItem(this, this.getUnlocalizedName()); - } - - /** - * Callback for item usage. If the item does something special on right - * clicking, - * - * he will have one of those. Return True if something happen and false if - * it don't. This is for ITEMS, not BLOCKS - */ - @Override - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10){ - if (par3World.isRemote) { - return true; - } - else { - Block block = par3World.getBlock(par4, par5, par6); - par4 += Facing.offsetsXForSide[par7]; - par5 += Facing.offsetsYForSide[par7]; - par6 += Facing.offsetsZForSide[par7]; - double d0 = 0.0D; - - if (par7 == 1 && block.getRenderType() == 11) { - d0 = 0.5D; - } - - Entity entity = spawnEntity(par1ItemStack, par3World, par4 + 0.5D, par5 + d0, par6 + 0.5D); - - if (entity != null) { - if (entity instanceof EntityLivingBase - && par1ItemStack.hasDisplayName()) { - ((EntityLiving) entity).setCustomNameTag( - par1ItemStack.getDisplayName() - ); - } - - if (!par2EntityPlayer.capabilities.isCreativeMode) { - --par1ItemStack.stackSize; - } - } - - return true; - } - } - - /** - * Called whenever this item is equipped and the right mouse button is - * pressed. - * - * Args: itemStack, world, entityPlayer - */ - @Override - public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - if (par2World.isRemote) { - return par1ItemStack; - } - else { - MovingObjectPosition movingobjectposition = getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true); - - if (movingobjectposition == null) { - return par1ItemStack; - } - else { - if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { - int i = movingobjectposition.blockX; - int j = movingobjectposition.blockY; - int k = movingobjectposition.blockZ; - - if (!par2World.canMineBlock(par3EntityPlayer, i, j, k)) { - return par1ItemStack; - } - - if (!par3EntityPlayer.canPlayerEdit( - i, j, k, movingobjectposition - - .sideHit, par1ItemStack - )) { - return par1ItemStack; - } - - if (par2World.getBlock(i, j, k) instanceof BlockLiquid) { - Entity entity = spawnEntity(par1ItemStack, par2World, i, j, k); - - if (entity != null) { - if (entity instanceof EntityLivingBase - && par1ItemStack - - .hasDisplayName()) { - ((EntityLiving) entity).setCustomNameTag( - par1ItemStack - - .getDisplayName() - ); - } - - if (!par3EntityPlayer.capabilities.isCreativeMode) { - --par1ItemStack.stackSize; - } - } - } - } - - return par1ItemStack; - } - } - } - - /** - * Spawns the creature specified by the egg's type in the location specified - * by - * - * the last three parameters. Parameters: world, entityID, x, y, z. - * @param par1ItemStack - */ - public Entity spawnEntity(ItemStack par1ItemStack, World parWorld, double parX, double parY, double parZ) { - - if (!parWorld.isRemote) // never spawn entity on client side - { - int aDamage = par1ItemStack.getItemDamage(); - String entityToSpawnNameFull = mEntityFullNameMap.get(aDamage); - String entityToSpawnName = mEntityNameMap.get(aDamage); - //entityToSpawnNameFull = WildAnimals.MODID + "." + entityToSpawnName; - if (EntityList.stringToClassMapping.containsKey(entityToSpawnNameFull)) { - entityToSpawn = (EntityLiving) EntityList.createEntityByName(entityToSpawnNameFull, parWorld); - entityToSpawn.setLocationAndAngles(parX, parY, parZ, MathHelper.wrapAngleTo180_float(parWorld.rand.nextFloat() * 360.0F), 0.0F); - parWorld.spawnEntityInWorld(entityToSpawn); - entityToSpawn.onSpawnWithEgg((IEntityLivingData) null); - entityToSpawn.playLivingSound(); - } - else { - // DEBUG - System.out.println("Entity not found " + entityToSpawnName); - } - } - - return entityToSpawn; - } - - /** - * returns a list of items with the same ID, but different meta (eg: dye - * returns 16 items) - */ - @Override - @SideOnly(Side.CLIENT) - public void getSubItems(Item aItem, CreativeTabs p_150895_2_, List aList) { - for (int aMeta : mReverseEntityMap.values()) { - aList.add(ItemUtils.simpleMetaStack(aItem, aMeta, 1)); - } - } - - @Override - @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack par1ItemStack, int parColorType) { - int aID = par1ItemStack.getItemDamage(); - return (parColorType == 0) ? mColourBaseMap.get(aID) : mColourSpotsMap.get(aID); - } - - @Override - @SideOnly(Side.CLIENT) - public boolean requiresMultipleRenderPasses() { - return true; - } - - @Override - // Doing this override means that there is no localization for language - // unless you specifically check for localization here and convert - public String getItemStackDisplayName(ItemStack par1ItemStack) { - return "Spawn " + mEntityNameMap.get(par1ItemStack.getItemDamage()); - } - - - @Override - public void registerIcons(final IIconRegister u) { - mIconMap.put(0, u.registerIcon(CORE.MODID + ":" + "spawn_egg")); - mIconMap.put(1, u.registerIcon(CORE.MODID + ":" + "spawn_egg_overlay")); - } - - @Override - public IIcon getIconFromDamageForRenderPass(final int damage, final int renderPass) { - return mIconMap.get(renderPass); - } - - @Override - public IIcon getIconFromDamage(int damage) { - return getIconFromDamageForRenderPass(0, 0); - } - - @Override - public IIcon getIcon(ItemStack aStack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { - return getIconFromDamageForRenderPass(0, renderPass); - } - - @Override - public IIcon getIcon(ItemStack aStack, int renderPass) { - return getIconFromDamageForRenderPass(0, renderPass); - } - - @Override - public String getUnlocalizedName(ItemStack stack) { - return super.getUnlocalizedName() + "." + stack.getItemDamage(); - } - - public static void setEntityToSpawnName(int aMetaID, String parEntityToSpawnName) { - mEntityNameMap.put(aMetaID, parEntityToSpawnName); - mEntityFullNameMap.put(aMetaID, CORE.MODID + "." + parEntityToSpawnName); - } + private static final HashMap mIconMap = new HashMap(); + private static int mTotalMetaItems = 0; + + private static final HashMap mMaxStackSizeMap = new HashMap(); + private static final HashMap mRarityMap = new HashMap(); + private static final HashMap> mOreDictNames = new HashMap>(); + + private static final HashMap mColourBaseMap = new HashMap(); + private static final HashMap mColourSpotsMap = new HashMap(); + private static final HashMap mEntityNameMap = new HashMap(); + private static final HashMap mEntityFullNameMap = new HashMap(); + + private static final HashMap mReverseEntityMap = new HashMap(); + + protected EntityLiving entityToSpawn = null; + + public static ItemStack getSpawnEggForEntityname(String aEntityName, int aSize) { + return ItemUtils.simpleMetaStack(ModItems.itemCustomSpawnEgg, mReverseEntityMap.get(aEntityName), aSize); + } + + public static void registerEntityForSpawnEgg( + final int aMetaID, String parEntityToSpawnName, int aPrimaryColor, int aSecondaryColor) { + registerEntityForSpawnEgg( + aMetaID, + parEntityToSpawnName, + aPrimaryColor, + aSecondaryColor, + EnumRarity.common, + new ArrayList()); + } + + public static void registerEntityForSpawnEgg( + final int aMetaID, + String parEntityToSpawnName, + int aPrimaryColor, + int aSecondaryColor, + EnumRarity aRarity, + final ArrayList aOreDictNames) { + mTotalMetaItems++; + mMaxStackSizeMap.put(aMetaID, 64); + mRarityMap.put(aMetaID, aRarity); + mOreDictNames.put(aMetaID, aOreDictNames); + mColourBaseMap.put(aMetaID, aPrimaryColor); + mColourSpotsMap.put(aMetaID, aSecondaryColor); + mReverseEntityMap.put(parEntityToSpawnName, aMetaID); + setEntityToSpawnName(aMetaID, parEntityToSpawnName); + } + + public static void registerEggsToOreDict() { + for (int aMetaID = 0; aMetaID < mTotalMetaItems; aMetaID++) { + ArrayList aOreDictNames = mOreDictNames.get(aMetaID); + if (aOreDictNames != null && !aOreDictNames.isEmpty()) { + ItemStack aFoodStack = ItemUtils.simpleMetaStack(ModItems.itemCustomSpawnEgg, aMetaID, 1); + for (String aOreName : aOreDictNames) { + ItemUtils.addItemToOreDictionary(aFoodStack, aOreName); + } + } + } + } + + public ItemCustomSpawnEgg() { + super(); + this.setNoRepair(); + this.setMaxStackSize(64); + this.setMaxDamage(0); + this.setUnlocalizedName("BasicMetaSpawnEgg"); + GameRegistry.registerItem(this, this.getUnlocalizedName()); + } + + /** + * Callback for item usage. If the item does something special on right + * clicking, + * + * he will have one of those. Return True if something happen and false if + * it don't. This is for ITEMS, not BLOCKS + */ + @Override + public boolean onItemUse( + ItemStack par1ItemStack, + EntityPlayer par2EntityPlayer, + World par3World, + int par4, + int par5, + int par6, + int par7, + float par8, + float par9, + float par10) { + if (par3World.isRemote) { + return true; + } else { + Block block = par3World.getBlock(par4, par5, par6); + par4 += Facing.offsetsXForSide[par7]; + par5 += Facing.offsetsYForSide[par7]; + par6 += Facing.offsetsZForSide[par7]; + double d0 = 0.0D; + + if (par7 == 1 && block.getRenderType() == 11) { + d0 = 0.5D; + } + + Entity entity = spawnEntity(par1ItemStack, par3World, par4 + 0.5D, par5 + d0, par6 + 0.5D); + + if (entity != null) { + if (entity instanceof EntityLivingBase && par1ItemStack.hasDisplayName()) { + ((EntityLiving) entity).setCustomNameTag(par1ItemStack.getDisplayName()); + } + + if (!par2EntityPlayer.capabilities.isCreativeMode) { + --par1ItemStack.stackSize; + } + } + + return true; + } + } + + /** + * Called whenever this item is equipped and the right mouse button is + * pressed. + * + * Args: itemStack, world, entityPlayer + */ + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + if (par2World.isRemote) { + return par1ItemStack; + } else { + MovingObjectPosition movingobjectposition = + getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true); + + if (movingobjectposition == null) { + return par1ItemStack; + } else { + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; + + if (!par2World.canMineBlock(par3EntityPlayer, i, j, k)) { + return par1ItemStack; + } + + if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, par1ItemStack)) { + + return par1ItemStack; + } + + if (par2World.getBlock(i, j, k) instanceof BlockLiquid) { + Entity entity = spawnEntity(par1ItemStack, par2World, i, j, k); + + if (entity != null) { + if (entity instanceof EntityLivingBase && par1ItemStack.hasDisplayName()) { + + ((EntityLiving) entity).setCustomNameTag(par1ItemStack.getDisplayName()); + } + + if (!par3EntityPlayer.capabilities.isCreativeMode) { + --par1ItemStack.stackSize; + } + } + } + } + + return par1ItemStack; + } + } + } + + /** + * Spawns the creature specified by the egg's type in the location specified + * by + * + * the last three parameters. Parameters: world, entityID, x, y, z. + * @param par1ItemStack + */ + public Entity spawnEntity(ItemStack par1ItemStack, World parWorld, double parX, double parY, double parZ) { + + if (!parWorld.isRemote) // never spawn entity on client side + { + int aDamage = par1ItemStack.getItemDamage(); + String entityToSpawnNameFull = mEntityFullNameMap.get(aDamage); + String entityToSpawnName = mEntityNameMap.get(aDamage); + // entityToSpawnNameFull = WildAnimals.MODID + "." + entityToSpawnName; + if (EntityList.stringToClassMapping.containsKey(entityToSpawnNameFull)) { + entityToSpawn = (EntityLiving) EntityList.createEntityByName(entityToSpawnNameFull, parWorld); + entityToSpawn.setLocationAndAngles( + parX, parY, parZ, MathHelper.wrapAngleTo180_float(parWorld.rand.nextFloat() * 360.0F), 0.0F); + parWorld.spawnEntityInWorld(entityToSpawn); + entityToSpawn.onSpawnWithEgg((IEntityLivingData) null); + entityToSpawn.playLivingSound(); + } else { + // DEBUG + System.out.println("Entity not found " + entityToSpawnName); + } + } + + return entityToSpawn; + } + + /** + * returns a list of items with the same ID, but different meta (eg: dye + * returns 16 items) + */ + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item aItem, CreativeTabs p_150895_2_, List aList) { + for (int aMeta : mReverseEntityMap.values()) { + aList.add(ItemUtils.simpleMetaStack(aItem, aMeta, 1)); + } + } + + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int parColorType) { + int aID = par1ItemStack.getItemDamage(); + return (parColorType == 0) ? mColourBaseMap.get(aID) : mColourSpotsMap.get(aID); + } + + @Override + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + // Doing this override means that there is no localization for language + // unless you specifically check for localization here and convert + public String getItemStackDisplayName(ItemStack par1ItemStack) { + return "Spawn " + mEntityNameMap.get(par1ItemStack.getItemDamage()); + } + + @Override + public void registerIcons(final IIconRegister u) { + mIconMap.put(0, u.registerIcon(CORE.MODID + ":" + "spawn_egg")); + mIconMap.put(1, u.registerIcon(CORE.MODID + ":" + "spawn_egg_overlay")); + } + + @Override + public IIcon getIconFromDamageForRenderPass(final int damage, final int renderPass) { + return mIconMap.get(renderPass); + } + + @Override + public IIcon getIconFromDamage(int damage) { + return getIconFromDamageForRenderPass(0, 0); + } + + @Override + public IIcon getIcon(ItemStack aStack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { + return getIconFromDamageForRenderPass(0, renderPass); + } + + @Override + public IIcon getIcon(ItemStack aStack, int renderPass) { + return getIconFromDamageForRenderPass(0, renderPass); + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return super.getUnlocalizedName() + "." + stack.getItemDamage(); + } + + public static void setEntityToSpawnName(int aMetaID, String parEntityToSpawnName) { + mEntityNameMap.put(aMetaID, parEntityToSpawnName); + mEntityFullNameMap.put(aMetaID, CORE.MODID + "." + parEntityToSpawnName); + } } diff --git a/src/main/java/gtPlusPlus/core/item/general/throwables/ItemHydrofluoricAcidPotion.java b/src/main/java/gtPlusPlus/core/item/general/throwables/ItemHydrofluoricAcidPotion.java index 57cf8986fa..4aa6f11e7a 100644 --- a/src/main/java/gtPlusPlus/core/item/general/throwables/ItemHydrofluoricAcidPotion.java +++ b/src/main/java/gtPlusPlus/core/item/general/throwables/ItemHydrofluoricAcidPotion.java @@ -1,30 +1,39 @@ package gtPlusPlus.core.item.general.throwables; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.entity.projectile.EntityHydrofluoricAcidPotion; +import gtPlusPlus.core.item.base.CoreItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.entity.projectile.EntityHydrofluoricAcidPotion; -import gtPlusPlus.core.item.base.CoreItem; - public class ItemHydrofluoricAcidPotion extends CoreItem { - public ItemHydrofluoricAcidPotion(String unlocalizedName, String displayName, String description) { - super(unlocalizedName, displayName, AddToCreativeTab.tabMisc, 16, 0, new String[] {description}, EnumRarity.uncommon, EnumChatFormatting.GRAY, false, null); - } - - @Override - public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { - if (!player.capabilities.isCreativeMode) { - --item.stackSize; - } - world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); - if (!world.isRemote) { - world.spawnEntityInWorld(new EntityHydrofluoricAcidPotion(world, player)); - } - return item; - } -} \ No newline at end of file + public ItemHydrofluoricAcidPotion(String unlocalizedName, String displayName, String description) { + super( + unlocalizedName, + displayName, + AddToCreativeTab.tabMisc, + 16, + 0, + new String[] {description}, + EnumRarity.uncommon, + EnumChatFormatting.GRAY, + false, + null); + } + + @Override + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (!player.capabilities.isCreativeMode) { + --item.stackSize; + } + world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + if (!world.isRemote) { + world.spawnEntityInWorld(new EntityHydrofluoricAcidPotion(world, player)); + } + return item; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/general/throwables/ItemSulfuricAcidPotion.java b/src/main/java/gtPlusPlus/core/item/general/throwables/ItemSulfuricAcidPotion.java index 27b35e48d1..a553e46cf3 100644 --- a/src/main/java/gtPlusPlus/core/item/general/throwables/ItemSulfuricAcidPotion.java +++ b/src/main/java/gtPlusPlus/core/item/general/throwables/ItemSulfuricAcidPotion.java @@ -1,30 +1,39 @@ package gtPlusPlus.core.item.general.throwables; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.entity.projectile.EntitySulfuricAcidPotion; +import gtPlusPlus.core.item.base.CoreItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.entity.projectile.EntitySulfuricAcidPotion; -import gtPlusPlus.core.item.base.CoreItem; - public class ItemSulfuricAcidPotion extends CoreItem { - public ItemSulfuricAcidPotion(String unlocalizedName, String displayName, String description) { - super(unlocalizedName, displayName, AddToCreativeTab.tabMisc, 16, 0, new String[] {description}, EnumRarity.common, EnumChatFormatting.GRAY, false, null); - } - - @Override - public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { - if (!player.capabilities.isCreativeMode) { - --item.stackSize; - } - world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); - if (!world.isRemote) { - world.spawnEntityInWorld(new EntitySulfuricAcidPotion(world, player)); - } - return item; - } -} \ No newline at end of file + public ItemSulfuricAcidPotion(String unlocalizedName, String displayName, String description) { + super( + unlocalizedName, + displayName, + AddToCreativeTab.tabMisc, + 16, + 0, + new String[] {description}, + EnumRarity.common, + EnumChatFormatting.GRAY, + false, + null); + } + + @Override + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + if (!player.capabilities.isCreativeMode) { + --item.stackSize; + } + world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + if (!world.isRemote) { + world.spawnEntityInWorld(new EntitySulfuricAcidPotion(world, player)); + } + return item; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/general/throwables/ItemThrowableBomb.java b/src/main/java/gtPlusPlus/core/item/general/throwables/ItemThrowableBomb.java index e8f76ce64c..fedff944d1 100644 --- a/src/main/java/gtPlusPlus/core/item/general/throwables/ItemThrowableBomb.java +++ b/src/main/java/gtPlusPlus/core/item/general/throwables/ItemThrowableBomb.java @@ -1,7 +1,5 @@ package gtPlusPlus.core.item.general.throwables; -import java.util.List; - import gregtech.api.enums.ItemList; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.data.AutoMap; @@ -11,8 +9,8 @@ import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.item.base.CoreItem; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.minecraft.NBTUtils; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -26,99 +24,105 @@ import net.minecraft.world.World; public class ItemThrowableBomb extends CoreItem { - private static AutoMap mLighters = new AutoMap(); - public static IIcon[] icons = new IIcon[10]; - - public ItemThrowableBomb() { - super("gtpp.throwable.bomb", "Bomb", AddToCreativeTab.tabMisc, 16, 0, new String[] {"Just like Bomberman", "Have a fire source in inventory to prime"}, EnumRarity.uncommon, EnumChatFormatting.GRAY, false, null); - this.setHasSubtypes(true); - } - - @Override - public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { - - if (mLighters.isEmpty()) { - mLighters.put(ItemUtils.getSimpleStack(Items.flint_and_steel)); - mLighters.put(ItemList.Tool_Lighter_Invar_Full.get(1)); - mLighters.put(ItemList.Tool_Lighter_Invar_Used.get(1)); - mLighters.put(ItemList.Tool_Lighter_Platinum_Full.get(1)); - mLighters.put(ItemList.Tool_Lighter_Platinum_Used.get(1)); - mLighters.put(ItemUtils.getSimpleStack(ModItems.itemBasicFireMaker)); - } - - //Unlit - if (item.getItemDamage() == 0) { - boolean hasLighter = false; - for (ItemStack aPlaySlot : player.inventory.mainInventory) { - if (aPlaySlot != null) { - for (ItemStack aLighter : mLighters) { - if (GT_Utility.areStacksEqual(aPlaySlot, aLighter) || (aPlaySlot.getItem() instanceof MetaGeneratedGregtechTools && aPlaySlot.getItemDamage() == MetaGeneratedGregtechTools.ELECTRIC_LIGHTER)) { - hasLighter = true; - break; - } - } - } - } - if (hasLighter) { - item.setItemDamage(1); - } - } - //Lit - else if (item.getItemDamage() == 1) { - if (!player.capabilities.isCreativeMode) { - --item.stackSize; - } - world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); - if (!world.isRemote) { - world.spawnEntityInWorld(new EntityThrowableBomb(world, player)); - } - /*if (item.stackSize <= 0) { - item = null; - }*/ - } - return item; - } - + private static AutoMap mLighters = new AutoMap(); + public static IIcon[] icons = new IIcon[10]; + + public ItemThrowableBomb() { + super( + "gtpp.throwable.bomb", + "Bomb", + AddToCreativeTab.tabMisc, + 16, + 0, + new String[] {"Just like Bomberman", "Have a fire source in inventory to prime"}, + EnumRarity.uncommon, + EnumChatFormatting.GRAY, + false, + null); + this.setHasSubtypes(true); + } + + @Override + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + + if (mLighters.isEmpty()) { + mLighters.put(ItemUtils.getSimpleStack(Items.flint_and_steel)); + mLighters.put(ItemList.Tool_Lighter_Invar_Full.get(1)); + mLighters.put(ItemList.Tool_Lighter_Invar_Used.get(1)); + mLighters.put(ItemList.Tool_Lighter_Platinum_Full.get(1)); + mLighters.put(ItemList.Tool_Lighter_Platinum_Used.get(1)); + mLighters.put(ItemUtils.getSimpleStack(ModItems.itemBasicFireMaker)); + } + // Unlit + if (item.getItemDamage() == 0) { + boolean hasLighter = false; + for (ItemStack aPlaySlot : player.inventory.mainInventory) { + if (aPlaySlot != null) { + for (ItemStack aLighter : mLighters) { + if (GT_Utility.areStacksEqual(aPlaySlot, aLighter) + || (aPlaySlot.getItem() instanceof MetaGeneratedGregtechTools + && aPlaySlot.getItemDamage() == MetaGeneratedGregtechTools.ELECTRIC_LIGHTER)) { + hasLighter = true; + break; + } + } + } + } + if (hasLighter) { + item.setItemDamage(1); + } + } + // Lit + else if (item.getItemDamage() == 1) { + if (!player.capabilities.isCreativeMode) { + --item.stackSize; + } + world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + if (!world.isRemote) { + world.spawnEntityInWorld(new EntityThrowableBomb(world, player)); + } + /*if (item.stackSize <= 0) { + item = null; + }*/ + } + return item; + } - @Override - public void registerIcons(IIconRegister reg) { - icons[0] = reg.registerIcon(CORE.MODID + ":" + "bomb"); - icons[1] = reg.registerIcon(CORE.MODID + ":" + "bomb_lit"); - } + @Override + public void registerIcons(IIconRegister reg) { + icons[0] = reg.registerIcon(CORE.MODID + ":" + "bomb"); + icons[1] = reg.registerIcon(CORE.MODID + ":" + "bomb_lit"); + } - @Override - public IIcon getIconFromDamage(int meta) { - return this.icons[meta]; - } + @Override + public IIcon getIconFromDamage(int meta) { + return this.icons[meta]; + } - @SuppressWarnings({ "unchecked" }) - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < 2; i ++) { - list.add(new ItemStack(item, 1, i)); - } - } + @SuppressWarnings({"unchecked"}) + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 2; i++) { + list.add(new ItemStack(item, 1, i)); + } + } - @Override - public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { - String aLitStatus = "unlit"; - if (stack.getItemDamage() == 0) { - aLitStatus = EnumChatFormatting.BLUE+"Unlit"; - } - else if (stack.getItemDamage() == 1) { - aLitStatus = EnumChatFormatting.RED+"Lit"; - } - list.add(EnumChatFormatting.GOLD+"Fuse Status: "+aLitStatus); - super.addInformation(stack, aPlayer, list, bool); - } + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + String aLitStatus = "unlit"; + if (stack.getItemDamage() == 0) { + aLitStatus = EnumChatFormatting.BLUE + "Unlit"; + } else if (stack.getItemDamage() == 1) { + aLitStatus = EnumChatFormatting.RED + "Lit"; + } + list.add(EnumChatFormatting.GOLD + "Fuse Status: " + aLitStatus); + super.addInformation(stack, aPlayer, list, bool); + } - @Override - public String getItemStackDisplayName(ItemStack p_77653_1_) { - // TODO Auto-generated method stub - return super.getItemStackDisplayName(p_77653_1_); - } - - - -} \ No newline at end of file + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + // TODO Auto-generated method stub + return super.getItemStackDisplayName(p_77653_1_); + } +} diff --git a/src/main/java/gtPlusPlus/core/item/init/ItemsFoods.java b/src/main/java/gtPlusPlus/core/item/init/ItemsFoods.java index e5c403c503..c3ca06684e 100644 --- a/src/main/java/gtPlusPlus/core/item/init/ItemsFoods.java +++ b/src/main/java/gtPlusPlus/core/item/init/ItemsFoods.java @@ -20,61 +20,76 @@ import net.minecraft.potion.PotionEffect; public class ItemsFoods { - public static void load(){ - run(); - } + public static void load() { + run(); + } - private static void run(){ + private static void run() { - //Raisin Bread - ModItems.itemIngotRaisinBread = new BaseItemFood("itemIngotRaisinBread", "Raisin Bread", 3, 1.5f, false, new PotionEffect(Potion.weakness.id, 40, 1)).setAlwaysEdible(); - GT_OreDictUnificator.registerOre("foodRaisinBread", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemIngotRaisinBread", 1)); - //Hot Raisin Bread - ModItems.itemHotIngotRaisinBread = new BaseItemHotFood("itemHotIngotRaisinBread", 1, 0.5f, "Raisin Bread", 120, ModItems.itemIngotRaisinBread); - GT_OreDictUnificator.registerOre("foodHotRaisinBread", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemHotIngotRaisinBread", 1)); + // Raisin Bread + ModItems.itemIngotRaisinBread = new BaseItemFood( + "itemIngotRaisinBread", + "Raisin Bread", + 3, + 1.5f, + false, + new PotionEffect(Potion.weakness.id, 40, 1)) + .setAlwaysEdible(); + GT_OreDictUnificator.registerOre( + "foodRaisinBread", ItemUtils.getItemStackFromFQRN(CORE.MODID + ":itemIngotRaisinBread", 1)); + // Hot Raisin Bread + ModItems.itemHotIngotRaisinBread = new BaseItemHotFood( + "itemHotIngotRaisinBread", 1, 0.5f, "Raisin Bread", 120, ModItems.itemIngotRaisinBread); + GT_OreDictUnificator.registerOre( + "foodHotRaisinBread", ItemUtils.getItemStackFromFQRN(CORE.MODID + ":itemHotIngotRaisinBread", 1)); - //Raisin Bread - ModItems.itemFoodRaisinToast = new BaseItemFood("itemFoodRaisinToast", "Raisin Toast", 1, 0.5f, false).setAlwaysEdible(); - GT_OreDictUnificator.registerOre("foodRaisinToast", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemFoodRaisinToast", 1)); - //Hot Raisin Bread - ModItems.itemHotFoodRaisinToast = new BaseItemHotFood("itemHotFoodRaisinToast", 1, 0.5f, "Raisin Toast", 20, ModItems.itemFoodRaisinToast); - GT_OreDictUnificator.registerOre("foodHotRaisinToast", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemHotFoodRaisinToast", 1)); + // Raisin Bread + ModItems.itemFoodRaisinToast = + new BaseItemFood("itemFoodRaisinToast", "Raisin Toast", 1, 0.5f, false).setAlwaysEdible(); + GT_OreDictUnificator.registerOre( + "foodRaisinToast", ItemUtils.getItemStackFromFQRN(CORE.MODID + ":itemFoodRaisinToast", 1)); + // Hot Raisin Bread + ModItems.itemHotFoodRaisinToast = new BaseItemHotFood( + "itemHotFoodRaisinToast", 1, 0.5f, "Raisin Toast", 20, ModItems.itemFoodRaisinToast); + GT_OreDictUnificator.registerOre( + "foodHotRaisinToast", ItemUtils.getItemStackFromFQRN(CORE.MODID + ":itemHotFoodRaisinToast", 1)); - //Raisin Bread - ModItems.itemFoodCurriedSausages = new BaseItemFood("itemFoodCurriedSausages", "Curried Sausages", 5, 2f, false); - GT_OreDictUnificator.registerOre("foodCurriedSausages", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemFoodCurriedSausages", 1)); - //Hot Raisin Bread - ModItems.itemHotFoodCurriedSausages = new BaseItemHotFood("itemHotFoodCurriedSausages", 1, 0.5f, "Curried Sausages", 240, ModItems.itemFoodCurriedSausages); - GT_OreDictUnificator.registerOre("foodHotCurriedSausages", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemHotFoodCurriedSausages", 1)); + // Raisin Bread + ModItems.itemFoodCurriedSausages = + new BaseItemFood("itemFoodCurriedSausages", "Curried Sausages", 5, 2f, false); + GT_OreDictUnificator.registerOre( + "foodCurriedSausages", ItemUtils.getItemStackFromFQRN(CORE.MODID + ":itemFoodCurriedSausages", 1)); + // Hot Raisin Bread + ModItems.itemHotFoodCurriedSausages = new BaseItemHotFood( + "itemHotFoodCurriedSausages", 1, 0.5f, "Curried Sausages", 240, ModItems.itemFoodCurriedSausages); + GT_OreDictUnificator.registerOre( + "foodHotCurriedSausages", + ItemUtils.getItemStackFromFQRN(CORE.MODID + ":itemHotFoodCurriedSausages", 1)); - ModItems.itemMetaFood = new BaseItemMetaFood(); - BaseItemMetaFood.registerFoodsToOreDict(); - addCookingRecipes(); - addFoodDropsToMobs(); - - } - - private static ItemStack getMetaFoodStack(int aID) { - return ItemUtils.simpleMetaStack(ModItems.itemMetaFood, aID, 1); - } - - private static void addCookingRecipes() { + ModItems.itemMetaFood = new BaseItemMetaFood(); + BaseItemMetaFood.registerFoodsToOreDict(); + addCookingRecipes(); + addFoodDropsToMobs(); + } - RecipeUtils.addSmeltingRecipe(getMetaFoodStack(0), getMetaFoodStack(1), 0.4F); - RecipeUtils.addSmeltingRecipe(getMetaFoodStack(2), getMetaFoodStack(3), 0.35F); - RecipeUtils.addSmeltingRecipe(getMetaFoodStack(4), getMetaFoodStack(5), 0.35F); - RecipeUtils.addSmeltingRecipe(getMetaFoodStack(6), getMetaFoodStack(7), 0.35F); - - } - - private static void addFoodDropsToMobs() { + private static ItemStack getMetaFoodStack(int aID) { + return ItemUtils.simpleMetaStack(ModItems.itemMetaFood, aID, 1); + } - EntityUtils.registerDropsForMob(EntityVillager.class, getMetaFoodStack(0), 2, 1500); - EntityUtils.registerDropsForMob(EntityHorse.class, getMetaFoodStack(2), 4, 4000); - EntityUtils.registerDropsForMob(EntityWolf.class, getMetaFoodStack(4), 2, 4000); - EntityUtils.registerDropsForMob(EntityOcelot.class, getMetaFoodStack(6), 2, 4000); - EntityUtils.registerDropsForMob(EntityBlaze.class, getMetaFoodStack(8), 1, 500); - - } + private static void addCookingRecipes() { + RecipeUtils.addSmeltingRecipe(getMetaFoodStack(0), getMetaFoodStack(1), 0.4F); + RecipeUtils.addSmeltingRecipe(getMetaFoodStack(2), getMetaFoodStack(3), 0.35F); + RecipeUtils.addSmeltingRecipe(getMetaFoodStack(4), getMetaFoodStack(5), 0.35F); + RecipeUtils.addSmeltingRecipe(getMetaFoodStack(6), getMetaFoodStack(7), 0.35F); + } + + private static void addFoodDropsToMobs() { + + EntityUtils.registerDropsForMob(EntityVillager.class, getMetaFoodStack(0), 2, 1500); + EntityUtils.registerDropsForMob(EntityHorse.class, getMetaFoodStack(2), 4, 4000); + EntityUtils.registerDropsForMob(EntityWolf.class, getMetaFoodStack(4), 2, 4000); + EntityUtils.registerDropsForMob(EntityOcelot.class, getMetaFoodStack(6), 2, 4000); + EntityUtils.registerDropsForMob(EntityBlaze.class, getMetaFoodStack(8), 1, 500); + } } diff --git a/src/main/java/gtPlusPlus/core/item/init/ItemsMultiTools.java b/src/main/java/gtPlusPlus/core/item/init/ItemsMultiTools.java index 9f87408b56..2a5fa9107d 100644 --- a/src/main/java/gtPlusPlus/core/item/init/ItemsMultiTools.java +++ b/src/main/java/gtPlusPlus/core/item/init/ItemsMultiTools.java @@ -1,7 +1,6 @@ package gtPlusPlus.core.item.init; import gregtech.api.enums.Materials; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.CORE; @@ -12,63 +11,58 @@ import gtPlusPlus.core.util.minecraft.ItemUtils; public class ItemsMultiTools { - public static void load(){ - run(); - } - - private static void run(){ - - //Load Multitools - final boolean gtStyleTools = LoadedMods.Gregtech; - if (CORE.ConfigSwitches.enableMultiSizeTools){ - - //GT Materials - final Materials[] rm = Materials.values(); - for (final Materials m : rm){ - toolFactoryGT(m, gtStyleTools); - } - - //GT++ Materials - toolFactory(ALLOY.HASTELLOY_C276); - toolFactory(ALLOY.HASTELLOY_N); - toolFactory(ALLOY.HASTELLOY_W); - toolFactory(ALLOY.HASTELLOY_X); - toolFactory(ALLOY.INCOLOY_020); - toolFactory(ALLOY.INCOLOY_DS); - toolFactory(ALLOY.INCOLOY_MA956); - toolFactory(ALLOY.INCONEL_625); - toolFactory(ALLOY.INCONEL_690); - toolFactory(ALLOY.INCONEL_792); - toolFactory(ALLOY.LEAGRISIUM); - toolFactory(ALLOY.TANTALLOY_60); - toolFactory(ALLOY.TANTALLOY_61); - toolFactory(ALLOY.STABALLOY); - toolFactory(ALLOY.QUANTUM); - //toolFactory(ALLOY.BEDROCKIUM); - toolFactory(ALLOY.POTIN); - toolFactory(ALLOY.TUMBAGA); - toolFactory(ALLOY.TALONITE); - toolFactory(ALLOY.STELLITE); - toolFactory(ALLOY.TUNGSTEN_CARBIDE); - toolFactory(ALLOY.TANTALUM_CARBIDE); - + public static void load() { + run(); + } - } + private static void run() { - } + // Load Multitools + final boolean gtStyleTools = LoadedMods.Gregtech; + if (CORE.ConfigSwitches.enableMultiSizeTools) { + // GT Materials + final Materials[] rm = Materials.values(); + for (final Materials m : rm) { + toolFactoryGT(m, gtStyleTools); + } - private static boolean toolFactoryGT(final Materials m, final boolean b){ - ModItems.MP_GTMATERIAL = ItemUtils.generateMultiPick(b, m); - ModItems.MS_GTMATERIAL = ItemUtils.generateMultiShovel(b, m); - return true; - } + // GT++ Materials + toolFactory(ALLOY.HASTELLOY_C276); + toolFactory(ALLOY.HASTELLOY_N); + toolFactory(ALLOY.HASTELLOY_W); + toolFactory(ALLOY.HASTELLOY_X); + toolFactory(ALLOY.INCOLOY_020); + toolFactory(ALLOY.INCOLOY_DS); + toolFactory(ALLOY.INCOLOY_MA956); + toolFactory(ALLOY.INCONEL_625); + toolFactory(ALLOY.INCONEL_690); + toolFactory(ALLOY.INCONEL_792); + toolFactory(ALLOY.LEAGRISIUM); + toolFactory(ALLOY.TANTALLOY_60); + toolFactory(ALLOY.TANTALLOY_61); + toolFactory(ALLOY.STABALLOY); + toolFactory(ALLOY.QUANTUM); + // toolFactory(ALLOY.BEDROCKIUM); + toolFactory(ALLOY.POTIN); + toolFactory(ALLOY.TUMBAGA); + toolFactory(ALLOY.TALONITE); + toolFactory(ALLOY.STELLITE); + toolFactory(ALLOY.TUNGSTEN_CARBIDE); + toolFactory(ALLOY.TANTALUM_CARBIDE); + } + } - private static boolean toolFactory(final Material m){ - Logger.WARNING("Generating Multi-Tools for "+m.getLocalizedName()); - ModItems.MP_GTMATERIAL = ItemUtils.generateMultiPick(m); - ModItems.MS_GTMATERIAL = ItemUtils.generateMultiShovel(m); - return true; - } + private static boolean toolFactoryGT(final Materials m, final boolean b) { + ModItems.MP_GTMATERIAL = ItemUtils.generateMultiPick(b, m); + ModItems.MS_GTMATERIAL = ItemUtils.generateMultiShovel(b, m); + return true; + } + private static boolean toolFactory(final Material m) { + Logger.WARNING("Generating Multi-Tools for " + m.getLocalizedName()); + ModItems.MP_GTMATERIAL = ItemUtils.generateMultiPick(m); + ModItems.MS_GTMATERIAL = ItemUtils.generateMultiShovel(m); + return true; + } } diff --git a/src/main/java/gtPlusPlus/core/item/materials/DustDecayable.java b/src/main/java/gtPlusPlus/core/item/materials/DustDecayable.java index d42ac85012..a9c4adac97 100644 --- a/src/main/java/gtPlusPlus/core/item/materials/DustDecayable.java +++ b/src/main/java/gtPlusPlus/core/item/materials/DustDecayable.java @@ -2,8 +2,13 @@ package gtPlusPlus.core.item.materials; import static gtPlusPlus.core.util.minecraft.ItemUtils.getSimpleStack; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.core.handler.Recipes.DecayableRecipe; +import gtPlusPlus.core.item.base.BaseItemTickable; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.EntityUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; import java.util.List; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -11,87 +16,83 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import gregtech.api.util.GT_OreDictUnificator; -import gtPlusPlus.core.handler.Recipes.DecayableRecipe; -import gtPlusPlus.core.item.base.BaseItemTickable; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.EntityUtils; -import gtPlusPlus.core.util.minecraft.ItemUtils; - public class DustDecayable extends BaseItemTickable { - private final Item turnsIntoItem; - private final int radLevel; - - public DustDecayable(String unlocal, int colour, int maxTicks, String[] desc1, Item turnsInto, int radLevel) { - super(true, true, unlocal, colour, (maxTicks/1), desc1); - this.turnsIntoItem = turnsInto; - this.radLevel = radLevel; - GT_OreDictUnificator.registerOre(unlocal, ItemUtils.getSimpleStack(this)); - new DecayableRecipe(maxTicks, getSimpleStack(this), getSimpleStack(turnsInto)); - } + private final Item turnsIntoItem; + private final int radLevel; + + public DustDecayable(String unlocal, int colour, int maxTicks, String[] desc1, Item turnsInto, int radLevel) { + super(true, true, unlocal, colour, (maxTicks / 1), desc1); + this.turnsIntoItem = turnsInto; + this.radLevel = radLevel; + GT_OreDictUnificator.registerOre(unlocal, ItemUtils.getSimpleStack(this)); + new DecayableRecipe(maxTicks, getSimpleStack(this), getSimpleStack(turnsInto)); + } + + @Override + public void registerIcons(IIconRegister reg) { + String gt = "gregtech" + ":" + "materialicons/" + "NUCLEAR" + "/" + "dust"; + this.mIcon[0] = reg.registerIcon(gt); + String gt2 = "gregtech" + ":" + "materialicons/" + "NUCLEAR" + "/" + "dust" + "_OVERLAY"; + this.mIcon[1] = reg.registerIcon(gt2); + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { + super.addInformation(stack, player, list, bool); + if (this.radLevel > 0) { + list.add(CORE.GT_Tooltip_Radioactive); + } + } + + @Override + public void onUpdate( + final ItemStack iStack, + final World world, + final Entity entityHolding, + final int p_77663_4_, + final boolean p_77663_5_) { + if (world == null || iStack == null) { + return; + } + if (world.isRemote) { + return; + } + + if (entityHolding instanceof EntityPlayer) { + if (!((EntityPlayer) entityHolding).capabilities.isCreativeMode) { + EntityUtils.applyRadiationDamageToEntity(iStack.stackSize, this.radLevel, world, entityHolding); + } + } + boolean a1, a2; + + a1 = this.isTicking(world, iStack); + a2 = tickItemTag(world, iStack); - @Override - public void registerIcons(IIconRegister reg) { - String gt = "gregtech" + ":" + "materialicons/"+"NUCLEAR"+"/" + "dust"; - this.mIcon[0] = reg.registerIcon(gt); - String gt2 = "gregtech" + ":" + "materialicons/"+"NUCLEAR"+"/" + "dust" + "_OVERLAY"; - this.mIcon[1] = reg.registerIcon(gt2); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { - super.addInformation(stack, player, list, bool); - if (this.radLevel > 0) { - list.add(CORE.GT_Tooltip_Radioactive); - } - } - - @Override - public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, final boolean p_77663_5_) { - if (world == null || iStack == null) { - return; - } - if (world.isRemote) { - return; - } - - if (entityHolding instanceof EntityPlayer){ - if (!((EntityPlayer) entityHolding).capabilities.isCreativeMode){ - EntityUtils.applyRadiationDamageToEntity(iStack.stackSize, this.radLevel, world, entityHolding); - } - } - boolean a1, a2; - - a1 = this.isTicking(world, iStack); - a2 = tickItemTag(world, iStack); - - if (!a1 && !a2) { - if (entityHolding instanceof EntityPlayer){ - ItemStack replacement = ItemUtils.getSimpleStack(getDecayResult()); - //Logger.INFO("Replacing "+iStack.getDisplayName()+" with "+replacement.getDisplayName()+"."); - final ItemStack tempTransform = replacement; - if (iStack.stackSize > 1){ - int u = iStack.stackSize; - tempTransform.stackSize = u; - ((EntityPlayer) entityHolding).inventory.addItemStackToInventory((tempTransform)); - for (int l=0;l 1) { + int u = iStack.stackSize; + tempTransform.stackSize = u; + ((EntityPlayer) entityHolding).inventory.addItemStackToInventory((tempTransform)); + for (int l = 0; l < u; l++) { + ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); + } - } - else { - tempTransform.stackSize=1; - ((EntityPlayer) entityHolding).inventory.addItemStackToInventory((tempTransform)); - ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); - } - } - } - } + } else { + tempTransform.stackSize = 1; + ((EntityPlayer) entityHolding).inventory.addItemStackToInventory((tempTransform)); + ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); + } + } + } + } - public Item getDecayResult() { - return turnsIntoItem; - } - + public Item getDecayResult() { + return turnsIntoItem; + } } diff --git a/src/main/java/gtPlusPlus/core/item/materials/MaterialHandler.java b/src/main/java/gtPlusPlus/core/item/materials/MaterialHandler.java index 40fc6539e6..74c9115c3b 100644 --- a/src/main/java/gtPlusPlus/core/item/materials/MaterialHandler.java +++ b/src/main/java/gtPlusPlus/core/item/materials/MaterialHandler.java @@ -2,9 +2,6 @@ package gtPlusPlus.core.item.materials; public class MaterialHandler { - @SuppressWarnings("unused") - private String Staballoy; - - - + @SuppressWarnings("unused") + private String Staballoy; } diff --git a/src/main/java/gtPlusPlus/core/item/tool/misc/ConnectedBlockFinder.java b/src/main/java/gtPlusPlus/core/item/tool/misc/ConnectedBlockFinder.java index 555635741e..8c58c1b927 100644 --- a/src/main/java/gtPlusPlus/core/item/tool/misc/ConnectedBlockFinder.java +++ b/src/main/java/gtPlusPlus/core/item/tool/misc/ConnectedBlockFinder.java @@ -1,13 +1,14 @@ package gtPlusPlus.core.item.tool.misc; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.BaseItemWithDamageValue; +import java.util.HashSet; +import java.util.List; +import java.util.Set; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -16,127 +17,118 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; -import gtPlusPlus.api.objects.minecraft.BlockPos; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.item.base.BaseItemWithDamageValue; - -public class ConnectedBlockFinder extends BaseItemWithDamageValue{ - - public ConnectedBlockFinder() { - super("item.test.connector"); - this.setTextureName("stick"); - this.setMaxStackSize(1); - this.setMaxDamage(10000); - setCreativeTab(AddToCreativeTab.tabTools); - GameRegistry.registerItem(this, getUnlocalizedName()); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - list.add(EnumChatFormatting.GRAY+"Finds connected blocks, turns them to Glass once found."); - super.addInformation(stack, aPlayer, list, bool); - } - - @Override - public boolean doesContainerItemLeaveCraftingGrid(final ItemStack itemStack){ - return false; - } - - @Override - public boolean getShareTag(){ - return true; - } - - @Override - public boolean hasContainerItem(final ItemStack itemStack){ - return true; - } - @Override - public ItemStack getContainerItem(final ItemStack itemStack){ - return itemStack; - } - - @Override - @SideOnly(Side.CLIENT) - public EnumRarity getRarity(final ItemStack par1ItemStack){ - return EnumRarity.uncommon; - } - - @Override - public boolean hasEffect(final ItemStack par1ItemStack){ - return false; - } - - - @Override - public boolean onItemUse( - ItemStack stack, EntityPlayer player, World world, - int x, int y, int z, int side, - float hitX, float hitY, float hitZ) { - - BlockPos mStartPoint = new BlockPos(x,y,z, world); - Block mBlockType = world.getBlock(x, y, z); - int mBlockMeta = mBlockType.getDamageValue(world, x, y, z); - - //Return if Air. - if (world.isAirBlock(x, y, z)) { - return false; - } - - int breaker = 0; - Set mTotalIndex = new HashSet(); - - Set mFirstSearch = new HashSet(); - Set mSearch_A = new HashSet(); - - Set mSearch_B = new HashSet(); - Set mSearch_C = new HashSet(); - Set mSearch_D = new HashSet(); - - mFirstSearch.add(mStartPoint); - mTotalIndex.add(mStartPoint); - - - - - for (BlockPos G : mSearch_D) { - if (!world.isAirBlock(G.xPos, G.yPos, G.zPos)) { - world.setBlock(G.xPos, G.yPos, G.zPos, Blocks.diamond_ore); - } - } - - - - return super.onItemUse(stack, player, world, x, y, z, side, hitX, hitY, hitZ); - } - - public Set getValidNeighboursForSet(Set set){ - Set results = set; - for (BlockPos F : set) { - results.addAll(F.getValidNeighboursAndSelf()); - } - return results; - } - - public Set getExtraNeighboursForSet(Set set){ - Set results = set; - for (BlockPos F : set) { - results.addAll(F.getValidNeighboursAndSelf()); - } - return results; - } - - @Override - public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { - // TODO Auto-generated method stub - return super.onItemRightClick(p_77659_1_, p_77659_2_, p_77659_3_); - } - - - - - - - +public class ConnectedBlockFinder extends BaseItemWithDamageValue { + + public ConnectedBlockFinder() { + super("item.test.connector"); + this.setTextureName("stick"); + this.setMaxStackSize(1); + this.setMaxDamage(10000); + setCreativeTab(AddToCreativeTab.tabTools); + GameRegistry.registerItem(this, getUnlocalizedName()); + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add(EnumChatFormatting.GRAY + "Finds connected blocks, turns them to Glass once found."); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public boolean doesContainerItemLeaveCraftingGrid(final ItemStack itemStack) { + return false; + } + + @Override + public boolean getShareTag() { + return true; + } + + @Override + public boolean hasContainerItem(final ItemStack itemStack) { + return true; + } + + @Override + public ItemStack getContainerItem(final ItemStack itemStack) { + return itemStack; + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(final ItemStack par1ItemStack) { + return EnumRarity.uncommon; + } + + @Override + public boolean hasEffect(final ItemStack par1ItemStack) { + return false; + } + + @Override + public boolean onItemUse( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float hitX, + float hitY, + float hitZ) { + + BlockPos mStartPoint = new BlockPos(x, y, z, world); + Block mBlockType = world.getBlock(x, y, z); + int mBlockMeta = mBlockType.getDamageValue(world, x, y, z); + + // Return if Air. + if (world.isAirBlock(x, y, z)) { + return false; + } + + int breaker = 0; + Set mTotalIndex = new HashSet(); + + Set mFirstSearch = new HashSet(); + Set mSearch_A = new HashSet(); + + Set mSearch_B = new HashSet(); + Set mSearch_C = new HashSet(); + Set mSearch_D = new HashSet(); + + mFirstSearch.add(mStartPoint); + mTotalIndex.add(mStartPoint); + + for (BlockPos G : mSearch_D) { + if (!world.isAirBlock(G.xPos, G.yPos, G.zPos)) { + world.setBlock(G.xPos, G.yPos, G.zPos, Blocks.diamond_ore); + } + } + + return super.onItemUse(stack, player, world, x, y, z, side, hitX, hitY, hitZ); + } + + public Set getValidNeighboursForSet(Set set) { + Set results = set; + for (BlockPos F : set) { + results.addAll(F.getValidNeighboursAndSelf()); + } + return results; + } + + public Set getExtraNeighboursForSet(Set set) { + Set results = set; + for (BlockPos F : set) { + results.addAll(F.getValidNeighboursAndSelf()); + } + return results; + } + + @Override + public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { + // TODO Auto-generated method stub + return super.onItemRightClick(p_77659_1_, p_77659_2_, p_77659_3_); + } } diff --git a/src/main/java/gtPlusPlus/core/item/tool/misc/DebugScanner.java b/src/main/java/gtPlusPlus/core/item/tool/misc/DebugScanner.java index 0170df0dc7..a9272d8baa 100644 --- a/src/main/java/gtPlusPlus/core/item/tool/misc/DebugScanner.java +++ b/src/main/java/gtPlusPlus/core/item/tool/misc/DebugScanner.java @@ -15,90 +15,106 @@ import net.minecraft.world.World; public class DebugScanner extends CoreItem { - public DebugScanner() { - super("gtpp.debug.scanner", AddToCreativeTab.tabTools, 1, 0, - new String[] { - "Used to obtain information from GT/GT++ content", - "Right Click to use", - }, - EnumRarity.epic); - setTextureName(CORE.MODID + ":itemStickyRubber"); - } + public DebugScanner() { + super( + "gtpp.debug.scanner", + AddToCreativeTab.tabTools, + 1, + 0, + new String[] { + "Used to obtain information from GT/GT++ content", "Right Click to use", + }, + EnumRarity.epic); + setTextureName(CORE.MODID + ":itemStickyRubber"); + } - @Override - public boolean isDamageable() { - return false; - } + @Override + public boolean isDamageable() { + return false; + } - @Override - public boolean onItemUse(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int p_77648_4_, - int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { - // TODO Auto-generated method stub - return super.onItemUse(aStack, aPlayer, aWorld, p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_8_, - p_77648_9_, p_77648_10_); - } + @Override + public boolean onItemUse( + ItemStack aStack, + EntityPlayer aPlayer, + World aWorld, + int p_77648_4_, + int p_77648_5_, + int p_77648_6_, + int p_77648_7_, + float p_77648_8_, + float p_77648_9_, + float p_77648_10_) { + // TODO Auto-generated method stub + return super.onItemUse( + aStack, + aPlayer, + aWorld, + p_77648_4_, + p_77648_5_, + p_77648_6_, + p_77648_7_, + p_77648_8_, + p_77648_9_, + p_77648_10_); + } - @Override - public boolean isRepairable() { - return false; - } + @Override + public boolean isRepairable() { + return false; + } - @Override - public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { - // TODO Auto-generated method stub - return super.onItemRightClick(p_77659_1_, p_77659_2_, p_77659_3_); - } + @Override + public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { + // TODO Auto-generated method stub + return super.onItemRightClick(p_77659_1_, p_77659_2_, p_77659_3_); + } - @Override - public float getDigSpeed(ItemStack itemstack, Block block, int metadata) { - return 0f; - } + @Override + public float getDigSpeed(ItemStack itemstack, Block block, int metadata) { + return 0f; + } - @Override - public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { - if (entity != null && player != null) { - PlayerUtils.messagePlayer(player, "Entity ID: "+entity.getEntityId()); - PlayerUtils.messagePlayer(player, "UUID: "+entity.getUniqueID()); - PlayerUtils.messagePlayer(player, "Invulnerable? "+entity.isEntityInvulnerable()); - PlayerUtils.messagePlayer(player, "Invisible? "+entity.isInvisible()); - PlayerUtils.messagePlayer(player, "Age: "+entity.ticksExisted); - - if (entity instanceof EntityLivingBase) { - EntityLivingBase g = (EntityLivingBase) entity; - PlayerUtils.messagePlayer(player, "Health: "+g.getHealth()+"/"+g.getMaxHealth()); - PlayerUtils.messagePlayer(player, "On ground? "+g.onGround); - PlayerUtils.messagePlayer(player, "Child? "+g.isChild()); - } - if (entity instanceof EntityLiving) { - EntityLiving g = (EntityLiving) entity; - PlayerUtils.messagePlayer(player, "Can Loot? "+g.canPickUpLoot()); - - } - if (entity instanceof EntityPlayer) { - EntityPlayer y = (EntityPlayer) entity; - PlayerUtils.messagePlayer(player, "Experience: "+y.experience); - PlayerUtils.messagePlayer(player, "Name: "+y.getCommandSenderName()); - } - - } - return true; - } + @Override + public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { + if (entity != null && player != null) { + PlayerUtils.messagePlayer(player, "Entity ID: " + entity.getEntityId()); + PlayerUtils.messagePlayer(player, "UUID: " + entity.getUniqueID()); + PlayerUtils.messagePlayer(player, "Invulnerable? " + entity.isEntityInvulnerable()); + PlayerUtils.messagePlayer(player, "Invisible? " + entity.isInvisible()); + PlayerUtils.messagePlayer(player, "Age: " + entity.ticksExisted); - @Override - public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) { - return false; - } + if (entity instanceof EntityLivingBase) { + EntityLivingBase g = (EntityLivingBase) entity; + PlayerUtils.messagePlayer(player, "Health: " + g.getHealth() + "/" + g.getMaxHealth()); + PlayerUtils.messagePlayer(player, "On ground? " + g.onGround); + PlayerUtils.messagePlayer(player, "Child? " + g.isChild()); + } + if (entity instanceof EntityLiving) { + EntityLiving g = (EntityLiving) entity; + PlayerUtils.messagePlayer(player, "Can Loot? " + g.canPickUpLoot()); + } + if (entity instanceof EntityPlayer) { + EntityPlayer y = (EntityPlayer) entity; + PlayerUtils.messagePlayer(player, "Experience: " + y.experience); + PlayerUtils.messagePlayer(player, "Name: " + y.getCommandSenderName()); + } + } + return true; + } - @Override - public boolean showDurabilityBar(ItemStack stack) { - return true; - } + @Override + public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) { + return false; + } - @Override - public int getHarvestLevel(ItemStack stack, String toolClass) { - return 0; - } + @Override + public boolean showDurabilityBar(ItemStack stack) { + return true; + } - - + @Override + public int getHarvestLevel(ItemStack stack, String toolClass) { + return 0; + } } diff --git a/src/main/java/gtPlusPlus/core/item/tool/misc/FakeGregtechTool.java b/src/main/java/gtPlusPlus/core/item/tool/misc/FakeGregtechTool.java index 47856b44c0..ac63ef24f7 100644 --- a/src/main/java/gtPlusPlus/core/item/tool/misc/FakeGregtechTool.java +++ b/src/main/java/gtPlusPlus/core/item/tool/misc/FakeGregtechTool.java @@ -1,74 +1,69 @@ package gtPlusPlus.core.item.tool.misc; +import gregtech.api.enums.Materials; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.CoreItem; +import gtPlusPlus.core.util.Utils; import java.util.List; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -import gregtech.api.enums.Materials; - -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.item.base.CoreItem; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; - -public class FakeGregtechTool extends CoreItem{ - - public final int componentColour; - public Object extraData; +public class FakeGregtechTool extends CoreItem { - protected IIcon base[] = new IIcon[6]; - protected IIcon overlay[] = new IIcon[6]; + public final int componentColour; + public Object extraData; - public FakeGregtechTool() { - super("GregeriousT's Display Tool", AddToCreativeTab.tabTools, 1); - short[] tempCol = Materials.TungstenSteel.getRGBA(); - this.componentColour = Utils.rgbtoHexValue(tempCol[0], tempCol[1], tempCol[2]); - } + protected IIcon base[] = new IIcon[6]; + protected IIcon overlay[] = new IIcon[6]; - @Override - public void registerIcons(final IIconRegister i) { - //ScrewDriver - this.base[0] = i.registerIcon("gregtech" + ":" + "materialicons/METALLIC/" + "toolHeadScrewdriver"); - this.overlay[0] = i.registerIcon("gregtech" + ":" + "iconsets/" + "HANDLE_SCREWDRIVER"); - //Soldering iron - this.base[1] = i.registerIcon("gregtech" + ":" + "materialicons/METALLIC/" + "toolHeadSoldering"); - this.overlay[1] = i.registerIcon("gregtech" + ":" + "iconsets/" + "HANDLE_SOLDERING"); - //Mallet - this.base[2] = i.registerIcon("gregtech" + ":" + "materialicons/METALLIC/" + "handleMallet"); - this.overlay[2] = i.registerIcon("gregtech" + ":" + "materialicons/METALLIC/" + "toolHeadMallet"); - //Hammer - this.base[3] = i.registerIcon("gregtech" + ":" + "materialicons/METALLIC/" + "stick"); - this.overlay[3] = i.registerIcon("gregtech" + ":" + "materialicons/METALLIC/" + "toolHeadHammer"); - //Wrench - this.base[4] = i.registerIcon("gregtech" + ":" + "iconsets/" + "WRENCH"); - this.overlay[4] = i.registerIcon("gregtech" + ":" + "iconsets/" + "WRENCH_OVERLAY"); - //Crowbar - this.base[5] = i.registerIcon("gregtech" + ":" + "iconsets/" + "CROWBAR"); - this.overlay[5] = i.registerIcon("gregtech" + ":" + "iconsets/" + "CROWBAR_OVERLAY"); - } + public FakeGregtechTool() { + super("GregeriousT's Display Tool", AddToCreativeTab.tabTools, 1); + short[] tempCol = Materials.TungstenSteel.getRGBA(); + this.componentColour = Utils.rgbtoHexValue(tempCol[0], tempCol[1], tempCol[2]); + } - @Override - public int getColorFromItemStack(final ItemStack stack, final int renderPass) { - if (renderPass == 1){ - return Utils.rgbtoHexValue(230, 230, 230); - } - return this.componentColour; - } + @Override + public void registerIcons(final IIconRegister i) { + // ScrewDriver + this.base[0] = i.registerIcon("gregtech" + ":" + "materialicons/METALLIC/" + "toolHeadScrewdriver"); + this.overlay[0] = i.registerIcon("gregtech" + ":" + "iconsets/" + "HANDLE_SCREWDRIVER"); + // Soldering iron + this.base[1] = i.registerIcon("gregtech" + ":" + "materialicons/METALLIC/" + "toolHeadSoldering"); + this.overlay[1] = i.registerIcon("gregtech" + ":" + "iconsets/" + "HANDLE_SOLDERING"); + // Mallet + this.base[2] = i.registerIcon("gregtech" + ":" + "materialicons/METALLIC/" + "handleMallet"); + this.overlay[2] = i.registerIcon("gregtech" + ":" + "materialicons/METALLIC/" + "toolHeadMallet"); + // Hammer + this.base[3] = i.registerIcon("gregtech" + ":" + "materialicons/METALLIC/" + "stick"); + this.overlay[3] = i.registerIcon("gregtech" + ":" + "materialicons/METALLIC/" + "toolHeadHammer"); + // Wrench + this.base[4] = i.registerIcon("gregtech" + ":" + "iconsets/" + "WRENCH"); + this.overlay[4] = i.registerIcon("gregtech" + ":" + "iconsets/" + "WRENCH_OVERLAY"); + // Crowbar + this.base[5] = i.registerIcon("gregtech" + ":" + "iconsets/" + "CROWBAR"); + this.overlay[5] = i.registerIcon("gregtech" + ":" + "iconsets/" + "CROWBAR_OVERLAY"); + } - @Override - public boolean requiresMultipleRenderPasses() { - return true; - } + @Override + public int getColorFromItemStack(final ItemStack stack, final int renderPass) { + if (renderPass == 1) { + return Utils.rgbtoHexValue(230, 230, 230); + } + return this.componentColour; + } - @Override - public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < 6; i ++) { - list.add(new ItemStack(item, 1, i)); - } - } + @Override + public boolean requiresMultipleRenderPasses() { + return true; + } + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 6; i++) { + list.add(new ItemStack(item, 1, i)); + } + } } diff --git a/src/main/java/gtPlusPlus/core/item/tool/misc/GregtechPump.java b/src/main/java/gtPlusPlus/core/item/tool/misc/GregtechPump.java index bbb09b154c..91dfb88ea3 100644 --- a/src/main/java/gtPlusPlus/core/item/tool/misc/GregtechPump.java +++ b/src/main/java/gtPlusPlus/core/item/tool/misc/GregtechPump.java @@ -2,12 +2,6 @@ package gtPlusPlus.core.item.tool.misc; import static gregtech.api.enums.GT_Values.V; -import java.util.ArrayList; -import java.util.BitSet; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -37,6 +31,11 @@ import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; import ic2.api.item.IElectricItemManager; import ic2.api.item.ISpecialElectricItem; +import java.util.ArrayList; +import java.util.BitSet; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -60,1244 +59,1315 @@ import net.minecraftforge.fluids.IFluidTank; public class GregtechPump extends Item implements ISpecialElectricItem, IElectricItemManager, IFluidContainerItem { - /** - * Right Click Functions - */ - - @Override - public boolean onItemUse(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int a4, - float p_77648_8_, float p_77648_9_, float p_77648_10_) { - if (aStack == null || aPlayer == null || aWorld == null || aWorld.isRemote) { - return false; - } - if (!aWorld.isRemote && tryDrainTile(aStack, aWorld, aPlayer, aX, aY, aZ)) { - return true; - } else { - //return super.onItemUse(aStack, aPlayer, aWorld, aX, aY, aZ, a4, p_77648_8_, p_77648_9_, p_77648_10_); - return false; - } - } - - @Override - public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { - return p_77659_1_; - } - - /** - * GT Code - */ - - /* ---------- CONSTRUCTOR AND MEMBER VARIABLES ---------- */ - private final HashMap>> mItemBehaviors = new HashMap<>(); - public final short mOffset, mItemAmount; - public final BitSet mEnabledItems; - public final BitSet mVisibleItems; - /** The unlocalized name of this item. */ - private String unlocalizedName; - - private final HashMap mIconMap = new LinkedHashMap(); - private final HashMap rarity = new LinkedHashMap(); - private final HashMap descColour = new LinkedHashMap(); - private final HashMap itemName = new LinkedHashMap(); - private final HashMap itemDescription = new LinkedHashMap(); - private final HashMap hasEffect = new LinkedHashMap(); - - public final HashMap mElectricStats = new LinkedHashMap(); - public final HashMap mBurnValues = new LinkedHashMap(); - - public void registerPumpType(final int aID, final String aPumpName, final int aEuMax, final int aTier) { - ModItems.toolGregtechPump.registerItem(aID, // ID - aPumpName, // Name - aEuMax, // Eu Storage - (short) aTier, // Tier - "Can be used to remove fluids from GT machine input & output slots.", // Tooltip - aTier <= 0 ? EnumRarity.common : aTier == 1 ? EnumRarity.uncommon : aTier == 2 ? EnumRarity.rare : aTier == 3 ? EnumRarity.epic : EnumRarity.common, // Rarity - EnumChatFormatting.GRAY, // Desc colour - false // Effect? - ); - } - - public GregtechPump() { - this("MU-metatool.01", AddToCreativeTab.tabTools, (short) 1000, (short) 31766); - } - - public GregtechPump(final String unlocalizedName, final CreativeTabs creativeTab, final short aOffset, - final short aItemAmount) { - this.mEnabledItems = new BitSet(aItemAmount); - this.mVisibleItems = new BitSet(aItemAmount); - this.mOffset = (short) Math.min(32766, aOffset); - this.mItemAmount = (short) Math.min(aItemAmount, 32766 - this.mOffset); - this.setHasSubtypes(true); - this.setMaxDamage(0); - this.setUnlocalizedName(unlocalizedName); - this.setCreativeTab(creativeTab); - this.setMaxStackSize(1); - if (GameRegistry.findItem(CORE.MODID, unlocalizedName) == null) { - GameRegistry.registerItem(this, unlocalizedName); - } - - } - - public void registerItem(final int id, final String localizedName, final long euStorage, final int tier, - final String description) { - this.registerItem(id, localizedName, euStorage, (short) tier, description, EnumRarity.common, - EnumChatFormatting.GRAY, false); - } - - public void registerItem(final int id, final String localizedName, final long euStorage, final int tier, - final String description, final int burnTime) { - this.registerItem(id, localizedName, euStorage, (short) tier, description, EnumRarity.common, - EnumChatFormatting.GRAY, false); - this.setBurnValue(id, burnTime); - } - - public void registerItem(final int id, final String localizedName, final long euStorage, final short tier, - final String description, final EnumRarity regRarity, final EnumChatFormatting colour, - final boolean Effect) { - this.addItem(id, localizedName, EnumChatFormatting.YELLOW + "Electric", new Object[] {}); - if (euStorage > 0 && tier > 0) - this.setElectricStats(this.mOffset + id, euStorage, GT_Values.V[tier], tier, -3L, true); - this.rarity.put(id, regRarity); - this.itemName.put(id, localizedName); - this.itemDescription.put(id, description); - this.descColour.put(id, colour); - this.hasEffect.put(id, Effect); - } - - @Override - @SideOnly(Side.CLIENT) - public EnumRarity getRarity(final ItemStack par1ItemStack) { - int h = getCorrectMetaForItemstack(par1ItemStack); - if (this.rarity.get(h) != null) { - return this.rarity.get(h); - } - return EnumRarity.common; - } - - @Override - public boolean hasEffect(final ItemStack par1ItemStack) { - int h = getCorrectMetaForItemstack(par1ItemStack); - if (this.hasEffect.get(h) != null) { - return this.hasEffect.get(h); - } - return false; - } - - @SuppressWarnings({ "unchecked" }) - @Override - public void addInformation(final ItemStack aStack, final EntityPlayer aPlayer, List aList, final boolean aF3_H) { - // aList.add("Meta: "+(aStack.getItemDamage()-mOffset)); - - int aOffsetMeta = getCorrectMetaForItemstack(aStack); - - if ((this.descColour.get(aOffsetMeta) != null) - && (this.itemDescription.get(aOffsetMeta) != null)) { - aList.add(this.descColour.get(aOffsetMeta) - + this.itemDescription.get(aOffsetMeta)); - } - - - if (aOffsetMeta <= 3) { - FluidStack f = getFluid(aStack); - aList.add("Cannot drain any other standard fluid container block"); - aList.add("Cannot be emptied via RMB, use inside a tank with GUI"); - aList.add(EnumChatFormatting.DARK_GRAY+"This is technically just a fancy fluid cell"); - aList.add(EnumChatFormatting.BLUE + (f != null ? f.getLocalizedName() : "No Fluids Contained")); - aList.add(EnumChatFormatting.BLUE + (f != null ? ""+f.amount : ""+0) + "L" + " / " + getCapacity(aStack) + "L"); - } - - final Long[] tStats = this.getElectricStats(aStack); - if (tStats != null) { - if (tStats[3] > 0) { - aList.add(EnumChatFormatting.AQUA + "Contains " + GT_Utility.formatNumbers(tStats[3]) + " EU Tier: " - + (tStats[2] >= 0 ? tStats[2] : 0) + EnumChatFormatting.GRAY); - } else { - final long tCharge = this.getRealCharge(aStack); - if ((tStats[3] == -2) && (tCharge <= 0)) { - aList.add(EnumChatFormatting.AQUA + "Empty. You should recycle it properly." - + EnumChatFormatting.GRAY); - } else { - aList.add(EnumChatFormatting.AQUA + "" + GT_Utility.formatNumbers(tCharge) + " / " - + GT_Utility.formatNumbers(Math.abs(tStats[0])) + " EU - Voltage: " - + V[(int) (tStats[2] >= 0 ? tStats[2] < V.length ? tStats[2] : V.length - 1 : 1)] - + EnumChatFormatting.GRAY); - } - } - } - - final ArrayList> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); - if (tList != null) { - for (final IItemBehaviour tBehavior : tList) { - aList = tBehavior.getAdditionalToolTips(this, aList, aStack); - } - } - } - - @Override - public final Item getChargedItem(final ItemStack itemStack) { - return this; - } - - @Override - public final Item getEmptyItem(final ItemStack itemStack) { - return this; - } - - @Override - public final double getMaxCharge(final ItemStack aStack) { - final Long[] tStats = this.getElectricStats(aStack); - if (tStats == null) { - return 0; - } - return Math.abs(tStats[0]); - } - - @Override - public final double getTransferLimit(final ItemStack aStack) { - final Long[] tStats = this.getElectricStats(aStack); - if (tStats == null) { - return 0; - } - return Math.max(tStats[1], tStats[3]); - } - - @Override - public final int getTier(final ItemStack aStack) { - final Long[] tStats = this.getElectricStats(aStack); - return (int) (tStats == null ? Integer.MAX_VALUE : tStats[2]); - } - - @Override - public final double charge(final ItemStack aStack, final double aCharge, final int aTier, - final boolean aIgnoreTransferLimit, final boolean aSimulate) { - final Long[] tStats = this.getElectricStats(aStack); - if ((tStats == null) || (tStats[2] > aTier) - || !((tStats[3] == -1) || (tStats[3] == -3) || ((tStats[3] < 0) && (aCharge == Integer.MAX_VALUE))) - || (aStack.stackSize != 1)) { - return 0; - } - final long tChargeBefore = this.getRealCharge(aStack), tNewCharge = aCharge == Integer.MAX_VALUE - ? Long.MAX_VALUE - : Math.min(Math.abs(tStats[0]), - tChargeBefore + (aIgnoreTransferLimit ? (long) aCharge : Math.min(tStats[1], (long) aCharge))); - if (!aSimulate) { - this.setCharge(aStack, tNewCharge); - } - return tNewCharge - tChargeBefore; - } - - @Override - public final double discharge(final ItemStack aStack, final double aCharge, final int aTier, - final boolean aIgnoreTransferLimit, final boolean aBatteryAlike, final boolean aSimulate) { - final Long[] tStats = this.getElectricStats(aStack); - if ((tStats == null) || (tStats[2] > aTier)) { - return 0; - } - if (aBatteryAlike && !this.canProvideEnergy(aStack)) { - return 0; - } - if (tStats[3] > 0) { - if ((aCharge < tStats[3]) || (aStack.stackSize < 1)) { - return 0; - } - if (!aSimulate) { - aStack.stackSize--; - } - return tStats[3]; - } - final long tChargeBefore = this.getRealCharge(aStack), tNewCharge = Math.max(0, - tChargeBefore - (aIgnoreTransferLimit ? (long) aCharge : Math.min(tStats[1], (long) aCharge))); - if (!aSimulate) { - this.setCharge(aStack, tNewCharge); - } - return tChargeBefore - tNewCharge; - } - - @Override - public final double getCharge(final ItemStack aStack) { - return this.getRealCharge(aStack); - } - - @Override - public final boolean canUse(final ItemStack aStack, final double aAmount) { - return this.getRealCharge(aStack) >= aAmount; - } - - @Override - public final boolean use(final ItemStack aStack, final double aAmount, final EntityLivingBase aPlayer) { - this.chargeFromArmor(aStack, aPlayer); - if ((aPlayer instanceof EntityPlayer) && ((EntityPlayer) aPlayer).capabilities.isCreativeMode) { - return true; - } - final double tTransfer = this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, true); - if (tTransfer == aAmount) { - this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, false); - this.chargeFromArmor(aStack, aPlayer); - return true; - } - this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, false); - this.chargeFromArmor(aStack, aPlayer); - return false; - } - - @Override - public final boolean canProvideEnergy(final ItemStack aStack) { - final Long[] tStats = this.getElectricStats(aStack); - if (tStats == null) { - return false; - } - return (tStats[3] > 0) || ((aStack.stackSize == 1) && ((tStats[3] == -2) || (tStats[3] == -3))); - } - - @Override - public final void chargeFromArmor(final ItemStack aStack, final EntityLivingBase aPlayer) { - if ((aPlayer == null) || aPlayer.worldObj.isRemote) { - return; - } - for (int i = 1; i < 5; i++) { - final ItemStack tArmor = aPlayer.getEquipmentInSlot(i); - if (GT_ModHandler.isElectricItem(tArmor)) { - final IElectricItem tArmorItem = (IElectricItem) tArmor.getItem(); - if (tArmorItem.canProvideEnergy(tArmor) && (tArmorItem.getTier(tArmor) >= this.getTier(aStack))) { - final double tCharge = ElectricItem.manager.discharge(tArmor, - this.charge(aStack, Integer.MAX_VALUE - 1, Integer.MAX_VALUE, true, true), - Integer.MAX_VALUE, true, true, false); - if (tCharge > 0) { - this.charge(aStack, tCharge, Integer.MAX_VALUE, true, false); - if (aPlayer instanceof EntityPlayer) { - final Container tContainer = ((EntityPlayer) aPlayer).openContainer; - if (tContainer != null) { - tContainer.detectAndSendChanges(); - } - } - } - } - } - } - } - - public final long getRealCharge(final ItemStack aStack) { - final Long[] tStats = this.getElectricStats(aStack); - if (tStats == null) { - return 0; - } - if (tStats[3] > 0) { - return (int) (long) tStats[3]; - } - final NBTTagCompound tNBT = aStack.getTagCompound(); - return tNBT == null ? 0 : tNBT.getLong("GT.ItemCharge"); - } - - public final boolean setCharge(final ItemStack aStack, long aCharge) { - final Long[] tStats = this.getElectricStats(aStack); - if ((tStats == null) || (tStats[3] > 0)) { - return false; - } - NBTTagCompound tNBT = aStack.getTagCompound(); - if (tNBT == null) { - tNBT = new NBTTagCompound(); - } - tNBT.removeTag("GT.ItemCharge"); - aCharge = Math.min(tStats[0] < 0 ? Math.abs(tStats[0] / 2) : aCharge, Math.abs(tStats[0])); - if (aCharge > 0) { - aStack.setItemDamage(this.getChargedMetaData(aStack)); - tNBT.setLong("GT.ItemCharge", aCharge); - } else { - aStack.setItemDamage(this.getEmptyMetaData(aStack)); - } - if (tNBT.hasNoTags()) { - aStack.setTagCompound(null); - } else { - aStack.setTagCompound(tNBT); - } - this.isItemStackUsable(aStack); - return true; - } - - public short getChargedMetaData(final ItemStack aStack) { - return (short) aStack.getItemDamage(); - } - - public short getEmptyMetaData(final ItemStack aStack) { - return (short) aStack.getItemDamage(); - } - - public boolean isItemStackUsable(final ItemStack aStack) { - final ArrayList> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); - if (tList != null) { - for (final IItemBehaviour tBehavior : tList) { - if (!tBehavior.isItemStackUsable(this, aStack)) { - return false; - } - } - } - return true; - } - - @Override - public final String getToolTip(final ItemStack aStack) { - return null; - } // This has its own ToolTip Handler, no need to let the IC2 Handler screw us up - // at this Point - - @Override - public final IElectricItemManager getManager(final ItemStack aStack) { - return this; - } // We are our own Manager - - /** - * Sets the Furnace Burn Value for the Item. - * - * @param aMetaValue - * the Meta Value of the Item you want to set it to. [0 - 32765] - * @param aValue - * 200 = 1 Burn Process = 500 EU, max = 32767 (that is 81917.5 EU) - * @return the Item itself for convenience in constructing. - */ - public final GregtechPump setBurnValue(final int aMetaValue, final int aValue) { - if ((aMetaValue < 0) || (aValue < 0)) { - return this; - } - if (aValue == 0) { - this.mBurnValues.remove((short) aMetaValue); - } else { - this.mBurnValues.put((short) aMetaValue, aValue > Short.MAX_VALUE ? Short.MAX_VALUE : (short) aValue); - } - return this; - } - - /** - * @param aMetaValue - * the Meta Value of the Item you want to set it to. [0 - 32765] - * @param aMaxCharge - * Maximum Charge. (if this is == 0 it will remove the Electric - * Behavior) - * @param aTransferLimit - * Transfer Limit. - * @param aTier - * The electric Tier. - * @param aSpecialData - * If this Item has a Fixed Charge, like a SingleUse Battery (if > - * 0). Use -1 if you want to make this Battery chargeable (the use - * and canUse Functions will still discharge if you just use this) - * Use -2 if you want to make this Battery dischargeable. Use -3 if - * you want to make this Battery charge/discharge-able. - * @return the Item itself for convenience in constructing. - */ - public final GregtechPump setElectricStats(final int aMetaValue, final long aMaxCharge, final long aTransferLimit, - final long aTier, final long aSpecialData, final boolean aUseAnimations) { - if (aMetaValue < 0) { - return this; - } - if (aMaxCharge == 0) { - this.mElectricStats.remove((short) aMetaValue); - } else { - this.mElectricStats.put((short) aMetaValue, - new Long[] { aMaxCharge, Math.max(0, aTransferLimit), Math.max(-1, aTier), aSpecialData }); - } - return this; - } - - @SuppressWarnings({ "unchecked" }) - @Override - @SideOnly(Side.CLIENT) - public void getSubItems(final Item var1, final CreativeTabs aCreativeTab, final List aList) { - for (int i = 0, j = this.mEnabledItems.length(); i < j; i++) { - if (this.mVisibleItems.get(i) || (GT_Values.D1 && this.mEnabledItems.get(i))) { - final Long[] tStats = this.mElectricStats.get((short) (this.mOffset + i)); - if ((tStats != null) && (tStats[3] < 0)) { - final ItemStack tStack = new ItemStack(this, 1, this.mOffset + i); - this.setCharge(tStack, Math.abs(tStats[0])); - this.isItemStackUsable(tStack); - aList.add(tStack); - } - if ((tStats == null) || (tStats[3] != -2)) { - final ItemStack tStack = new ItemStack(this, 1, this.mOffset + i); - this.isItemStackUsable(tStack); - aList.add(tStack); - } - } - } - } - - @Override - @SideOnly(Side.CLIENT) - public final void registerIcons(final IIconRegister aIconRegister) { - for (short i = 0, j = (short) this.mEnabledItems.length(); i < j; i++) { - if (this.mEnabledItems.get(i)) { - mIconMap.put((int) i, aIconRegister.registerIcon(CORE.MODID + ":" + (this.getUnlocalizedName() + "/" + i))); - } - } - } - - @Override - public final IIcon getIconFromDamage(final int aMetaData) { - if (aMetaData < 0) { - return null; - } - if (aMetaData < this.mOffset) { - return mIconMap.get(0); - } - else { - int newMeta = aMetaData - this.mOffset; - newMeta = (Math.max(0, Math.min(3, newMeta))); - return mIconMap.get(newMeta); - } - } - - /** - * Sets the unlocalized name of this item to the string passed as the parameter" - */ - @Override - public Item setUnlocalizedName(final String p_77655_1_) { - this.unlocalizedName = p_77655_1_; - super.setUnlocalizedName(p_77655_1_); - return this; - } - - /** - * Returns the unlocalized name of this item. - */ - @Override - public String getUnlocalizedName() { - return this.unlocalizedName; - } - - public final Long[] getElectricStats(final ItemStack aStack) { - return this.mElectricStats.get((short) aStack.getItemDamage()); - } - - @Override - public int getItemEnchantability() { - return 0; - } - - @Override - public boolean isBookEnchantable(final ItemStack aStack, final ItemStack aBook) { - return false; - } - - @Override - public boolean getIsRepairable(final ItemStack aStack, final ItemStack aMaterial) { - return false; - } - - /** - * Adds a special Item Behaviour to the Item. - *

- * Note: the boolean Behaviours sometimes won't be executed if another boolean - * Behaviour returned true before. - * - * @param aMetaValue - * the Meta Value of the Item you want to add it to. [0 - 32765] - * @param aBehavior - * the Click Behavior you want to add. - * @return the Item itself for convenience in constructing. - */ - public final GregtechPump addItemBehavior(final int aMetaValue, final IItemBehaviour aBehavior) { - if ((aMetaValue < 0) || (aMetaValue >= 32766) || (aBehavior == null)) { - return this; - } - ArrayList> tList = this.mItemBehaviors.get((short) aMetaValue); - if (tList == null) { - tList = new ArrayList<>(1); - this.mItemBehaviors.put((short) aMetaValue, tList); - } - tList.add(aBehavior); - return this; - } - - /** - * This adds a Custom Item to the ending Range. - * - * @param aID - * The Id of the assigned Item [0 - mItemAmount] (The MetaData gets - * auto-shifted by +mOffset) - * @param aEnglish - * The Default Localized Name of the created Item - * @param aToolTip - * The Default ToolTip of the created Item, you can also insert null - * for having no ToolTip - * @param aFoodBehavior - * The Food Value of this Item. Can be null aswell. Just a - * convenience thing. - * @param aRandomData - * The OreDict Names you want to give the Item. Also used for TC - * Aspects and some other things. - * @return An ItemStack containing the newly created Item. - */ - @SuppressWarnings("unchecked") - public final ItemStack addItem(final int aID, final String aEnglish, String aToolTip, final Object... aRandomData) { - if (aToolTip == null) { - aToolTip = ""; - } - if ((aID >= 0) && (aID < this.mItemAmount)) { - final ItemStack rStack = new ItemStack(this, 1, this.mOffset + aID); - GT_ModHandler.registerBoxableItemToToolBox(rStack); - this.mEnabledItems.set(aID); - this.mVisibleItems.set(aID); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(rStack) + ".name", aEnglish); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(rStack) + ".tooltip", aToolTip); - final List tAspects = new ArrayList<>(); - // Important Stuff to do first - for (final Object tRandomData : aRandomData) { - if (tRandomData instanceof SubTag) { - if (tRandomData == SubTag.INVISIBLE) { - this.mVisibleItems.set(aID, false); - continue; - } - if (tRandomData == SubTag.NO_UNIFICATION) { - GT_OreDictUnificator.addToBlacklist(rStack); - continue; - } - } - } - // now check for the rest - for (final Object tRandomData : aRandomData) { - if (tRandomData != null) { - boolean tUseOreDict = true; - if (tRandomData instanceof IItemBehaviour) { - this.addItemBehavior(this.mOffset + aID, (IItemBehaviour) tRandomData); - tUseOreDict = false; - } - if (tRandomData instanceof IItemContainer) { - ((IItemContainer) tRandomData).set(rStack); - tUseOreDict = false; - } - if (tRandomData instanceof SubTag) { - continue; - } - if (tRandomData instanceof TC_AspectStack) { - ((TC_AspectStack) tRandomData).addToAspectList(tAspects); - continue; - } - if (tRandomData instanceof ItemData) { - if (GT_Utility.isStringValid(tRandomData)) { - GT_OreDictUnificator.registerOre(tRandomData, rStack); - } else { - GT_OreDictUnificator.addItemData(rStack, (ItemData) tRandomData); - } - continue; - } - if (tUseOreDict) { - GT_OreDictUnificator.registerOre(tRandomData, rStack); - continue; - } - } - } - if (GregTech_API.sThaumcraftCompat != null) { - GregTech_API.sThaumcraftCompat.registerThaumcraftAspectsToItem(rStack, tAspects, false); - } - return rStack; - } - return null; - } - - @Override - public String getItemStackDisplayName(final ItemStack aStack) { - int keyValue = (getCorrectMetaForItemstack(aStack)); - if (keyValue < 0 || keyValue > 3) { - keyValue = 0; - } - return this.itemName.get(keyValue); - } - - /** - * Fluid Handling - */ - - /* - * IFluidContainer Functions - */ - - public void emptyStoredFluid(ItemStack aStack) { - if (aStack.hasTagCompound()) { - NBTTagCompound t = aStack.getTagCompound(); - if (t.hasKey("mInit")) { - t.removeTag("mInit"); - } - if (t.hasKey("mFluid")) { - t.removeTag("mFluid"); - } - if (t.hasKey("mFluidAmount")) { - t.removeTag("mFluidAmount"); - } - } - } - - public void storeFluid(ItemStack aStack, FluidStack aFluid) { - if (aFluid == null) { - return; - } else { - String fluidname = aFluid.getFluid().getName(); - int amount = aFluid.amount; - if (fluidname != null && fluidname.length() > 0 && amount > 0) { - NBTUtils.setString(aStack, "mFluid", fluidname); - NBTUtils.setInteger(aStack, "mFluidAmount", amount); - } - } - } - - @Override - public FluidStack getFluid(ItemStack container) { - if (!container.hasTagCompound() || !container.getTagCompound().hasKey("mInit")) { - initNBT(container); - } - if (container.getTagCompound().hasKey("mInit") && container.getTagCompound().getBoolean("mInit")) { - String fluidname; - Integer amount = 0; - fluidname = NBTUtils.getString(container, "mFluid"); - amount = NBTUtils.getInteger(container, "mFluidAmount"); - if (fluidname != null && amount != null && amount > 0) { - return FluidUtils.getFluidStack(fluidname, amount); - } else { - return null; - } - } - return null; - } - - @Override - public int getCapacity(ItemStack container) { - if (!container.hasTagCompound() || !container.getTagCompound().hasKey("mInit")) { - initNBT(container); - } - if (container.getTagCompound().hasKey("mInit") && container.getTagCompound().getBoolean("mInit")) { - return container.getTagCompound().getInteger("mCapacity"); - } - int aMeta = this.getCorrectMetaForItemstack(container); - int aCapacity = (aMeta == 0 ? 2000 : (aMeta == 1 ? 8000 : (aMeta == 2 ? 32000 : 128000))); - return aCapacity; - } - - public int fill(ItemStack container, FluidStack resource) { - return fill(container, resource, true); - } - - @Override - public int fill(ItemStack container, FluidStack resource, boolean doFill) { - if (!doFill || resource == null) { - return 0; - } - - if (!container.hasTagCompound() || !container.getTagCompound().hasKey("mInit")) { - initNBT(container); - } - if (container.getTagCompound().hasKey("mInit") && container.getTagCompound().getBoolean("mInit")) { - String aStored; - int aStoredAmount = 0; - int aCapacity = getCapacity(container); - FluidStack aStoredFluid = getFluid(container); - if (aStoredFluid != null) { - aStored = aStoredFluid.getFluid().getName(); - aStoredAmount = aStoredFluid.amount; - if (aStoredAmount == aCapacity) { - return 0; - } - } - // Handle no stored fluid first - if (aStoredFluid == null) { - Logger.INFO("Pump is empty, filling with tank fluids."); - FluidStack toConsume; - int amountToConsume = 0; - if (resource.amount >= aCapacity) { - amountToConsume = aCapacity; - } else { - amountToConsume = resource.amount; - } - toConsume = FluidUtils.getFluidStack(resource, amountToConsume); - if (toConsume != null && amountToConsume > 0) { - storeFluid(container, toConsume); - return amountToConsume; - } - } else { - Logger.INFO("Pump is Partially full, filling with tank fluids."); - if (aStoredFluid.isFluidEqual(resource)) { - Logger.INFO("Found matching fluids."); - int aSpaceLeft = (aCapacity - aStoredAmount); - Logger.INFO( - "Capacity: " + aCapacity + " | Stored: " + aStoredAmount + " | Space left: " + aSpaceLeft); - FluidStack toConsume; - int amountToConsume = 0; - if (resource.amount >= aSpaceLeft) { - amountToConsume = aSpaceLeft; - Logger.INFO("More or equal fluid amount to pump container space."); - } else { - amountToConsume = resource.amount; - Logger.INFO("Less fluid than container space"); - } - Logger.INFO("Amount to consume: " + amountToConsume); - toConsume = FluidUtils.getFluidStack(resource, (aStoredAmount + amountToConsume)); - if (toConsume != null && amountToConsume > 0) { - Logger.INFO("Storing Fluid"); - storeFluid(container, toConsume); - return amountToConsume; - } else { - Logger.INFO("Not storing fluid"); - } - } else { - Logger.INFO("Fluids did not match."); - } - } - } - return 0; - } - - public FluidStack drain(ItemStack container, int drainAmt) { - return drain(container, drainAmt, true); - } - - @Override - public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain) { - if (!doDrain || maxDrain == 0) { - return null; - } - if (!container.hasTagCompound() || !container.getTagCompound().hasKey("mInit")) { - initNBT(container); - } - if (container.getTagCompound().hasKey("mInit") && container.getTagCompound().getBoolean("mInit")) { - - String aStored; - int aStoredAmount = 0; - FluidStack aStoredFluid = getFluid(container); - - if (aStoredFluid != null) { - aStored = aStoredFluid.getFluid().getName(); - aStoredAmount = aStoredFluid.amount; - } - // We cannot drain this if it's empty. - else if (aStoredFluid == null) { - return null; - } - - if (maxDrain >= aStoredAmount) { - emptyStoredFluid(container); - return aStoredFluid; - } else { - // Handle Partial removal - int amountRemaining = (aStoredAmount - maxDrain); - if (amountRemaining == 0) { - emptyStoredFluid(container); - } else { - FluidStack newAmount = FluidUtils.getFluidStack(aStoredFluid, amountRemaining); - FluidStack drained = FluidUtils.getFluidStack(aStoredFluid, maxDrain); - if (newAmount != null && drained != null) { - storeFluid(container, newAmount); - return drained; - } - } - } - } - return null; - } - - /* - * Handle ItemStack NBT - */ - - public void initNBT(ItemStack aStack) { - NBTTagCompound aNewNBT; - if (!aStack.hasTagCompound()) { - aNewNBT = new NBTTagCompound(); - } else { - aNewNBT = aStack.getTagCompound(); - } - - if (!aNewNBT.hasKey("mInit")) { - int aMeta = this.getCorrectMetaForItemstack(aStack); - aNewNBT.setInteger("mMeta", aMeta); - aNewNBT.setBoolean("mInit", true); - aNewNBT.setString("mFluid", "@@@@@"); - aNewNBT.setInteger("mFluidAmount", 0); - int aCapacity = (aMeta == 0 ? 2000 : (aMeta == 1 ? 8000 : (aMeta == 2 ? 32000 : 128000))); - aNewNBT.setInteger("mCapacity", aCapacity); - aStack.setTagCompound(aNewNBT); - } - } - - /** - * Tile Handling - */ - - /* - * Custom Fluid Handling for Tiles and GT Tiles. - */ - - public boolean tryDrainTile(ItemStack aStack, World aWorld, EntityPlayer aPlayer, int aX, int aY, int aZ) { - try { - if (aWorld.isRemote || aStack == null) { - return false; - } else { - int aTier = (aStack.getItemDamage() - 1000); - int removal; - if (aTier == 0) { - removal = 0; - } else if (aTier == 1) { - removal = 32; - } else if (aTier == 2) { - removal = 128; - } else if (aTier == 3) { - removal = 512; - } else { - removal = 8; - } - if (!canUse(aStack, removal) && aTier > 0) { - PlayerUtils.messagePlayer(aPlayer, "Not enough power."); - Logger.INFO("No Power"); - return false; - } - - final Block aBlock = aWorld.getBlock(aX, aY, aZ); - if (aBlock == null) { - return false; - } - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity == null) { - return false; - } else { - double aCharge = this.getCharge(aStack); - boolean didDrain = false; - if (aTier > 0 && aCharge > 0) { - if (discharge(aStack, removal, aTier, true, true, false) > 0) { - didDrain = true; - } - } else if (aTier == 0) { - didDrain = true; - } else { - didDrain = false; - } - - if (didDrain) { - if ((tTileEntity instanceof IGregTechTileEntity)) { - return this.drainTankGT(tTileEntity, aStack, aWorld, aPlayer, aX, aY, aZ); - } - //Try support Standard Fluid Tanks too (May disable if dupes appear again) - else if ((tTileEntity instanceof IFluidTank || tTileEntity instanceof IFluidHandler)) { - //return this.drainIFluidTank(tTileEntity, aStack, aWorld, aPlayer, aX, aY, aZ); - return false; - } - } - } - } - } catch (Throwable t) { - } - return false; - } - - /* - * Vanilla IFluidTank - */ - - public boolean drainIFluidTank(TileEntity tTileEntity, ItemStack aStack, World aWorld, EntityPlayer aPlayer, int aX, - int aY, int aZ) { - if (tTileEntity == null) { - Logger.INFO("Invalid Tile, somehow."); - return false; - } - if ((tTileEntity instanceof IFluidTank || tTileEntity instanceof IFluidHandler)) { - if (this.getFluid(aStack) == null || (this.getFluid(aStack) != null && this.getFluid(aStack).amount < this.getCapacity(aStack))) { - Logger.INFO("Trying to find Stored Fluid - Behaviour Class."); - FluidStack aStored = getStoredFluidOfVanillaTank(tTileEntity); - if (aStored != null) { - int mAmountInserted = fill(aStack, aStored); - FluidStack newStackRemainingInTank; - if (mAmountInserted > 0) { - if (mAmountInserted == aStored.amount) { - newStackRemainingInTank = null; - } else { - newStackRemainingInTank = FluidUtils.getFluidStack(aStored, (aStored.amount - mAmountInserted)); - } - boolean b = setStoredFluidOfVanillaTank(tTileEntity, newStackRemainingInTank); - Logger.INFO("Cleared Tank? " + b + " | mAmountInserted: " + mAmountInserted); - Logger.INFO("Returning " + b + " - drainTankVanilla."); - if (b) { - PlayerUtils.messagePlayer(aPlayer, "Drained "+mAmountInserted+"L of "+aStored.getLocalizedName()+"."); - } - return b; - } - } else { - Logger.INFO("Found no valid Fluidstack - drainTankVanilla."); - } - } - else { - Logger.INFO("Pump is full."); - } - } - Logger.INFO("Could not drain vanilla tank."); - return false; - } - - /* - * GT Tanks - */ - - public boolean drainTankGT(TileEntity tTileEntity, ItemStack aStack, World aWorld, EntityPlayer aPlayer, int aX, - int aY, int aZ) { - if (tTileEntity == null) { - return false; - } - if ((tTileEntity instanceof IGregTechTileEntity)) { - Logger.INFO("Right Clicking on GT Tile - drainTankGT."); - if (((IGregTechTileEntity) tTileEntity).getTimer() < 50L) { - Logger.INFO("Returning False - Behaviour Class. Timer < 50"); - return false; - } else if ((!aWorld.isRemote) && (!((IGregTechTileEntity) tTileEntity).isUseableByPlayer(aPlayer))) { - Logger.INFO("Returning True - drainTankGT. NotUsable()"); - return true; - } else { - if (this.getFluid(aStack) == null || (this.getFluid(aStack) != null && this.getFluid(aStack).amount < this.getCapacity(aStack))) { - Logger.INFO("Trying to find Stored Fluid - drainTankGT."); - FluidStack aStored = getStoredFluidOfGTMachine((IGregTechTileEntity) tTileEntity); - if (aStored != null) { - int mAmountInserted = fill(aStack, aStored); - FluidStack newStackRemainingInTank; - if (mAmountInserted > 0) { - if (mAmountInserted == aStored.amount) { - newStackRemainingInTank = null; - } else { - newStackRemainingInTank = FluidUtils.getFluidStack(aStored, (aStored.amount - mAmountInserted)); - } - boolean b = setStoredFluidOfGTMachine((IGregTechTileEntity) tTileEntity, newStackRemainingInTank); - Logger.INFO("Cleared Tank? " + b + " | mAmountInserted: " + mAmountInserted); - Logger.INFO("Returning " + b + " - drainTankGT."); - if (b) { - PlayerUtils.messagePlayer(aPlayer, "Drained "+mAmountInserted+"L of "+aStored.getLocalizedName()+"."); - } - return b; - } - } else { - Logger.INFO("Found no valid Fluidstack - drainTankGT."); - } - } - else { - Logger.INFO("Pump is full."); - } - } - } - Logger.INFO("Could not drain GT tank."); - return false; - } - - /* - * Vanilla Tanks - */ - - public FluidStack getStoredFluidOfVanillaTank(TileEntity aTileEntity) { - if (aTileEntity == null) { - return null; - } else if ((aTileEntity instanceof IFluidTank || aTileEntity instanceof IFluidHandler)) { - if (aTileEntity instanceof IFluidTank) { - return getStoredFluidOfVanillaTank((IFluidTank) aTileEntity); - } else { - return getStoredFluidOfVanillaTank((IFluidHandler) aTileEntity); - } - } else { - return null; - } - } - - public FluidStack getStoredFluidOfVanillaTank(IFluidTank aTileEntity) { - FluidStack f = aTileEntity.getFluid(); - Logger.INFO("Returning Fluid stack from tile. Found: " - + (f != null ? f.getLocalizedName() + " - " + f.amount + "L" : "Nothing")); - return f; - } - - public FluidStack getStoredFluidOfVanillaTank(IFluidHandler aTileEntity) { - if (aTileEntity instanceof IFluidTank) { - return getStoredFluidOfVanillaTank((IFluidTank) aTileEntity); - } - FluidStack f; - AutoMap m = new AutoMap(); - for (int i = 0; i < 6; i++) { - m.put(aTileEntity.getTankInfo(ForgeDirection.getOrientation(i))); - } - if (m.get(0) != null && m.get(0)[0] != null && m.get(0)[0].fluid != null) { - return m.get(0)[0].fluid; - } else { - return null; - } - } - - public boolean setStoredFluidOfVanillaTank(TileEntity aTileEntity, FluidStack aSetFluid) { - Logger.INFO("Trying to clear Tile's tank. - Behaviour Class. [1]"); - - if (aTileEntity == null) { - return false; - } - else if ((aTileEntity instanceof IFluidTank || aTileEntity instanceof IFluidHandler)) { - if (aTileEntity instanceof IFluidTank) { - Logger.INFO("Tile Was instanceof IFluidTank."); - FluidStack f = ((IFluidTank) aTileEntity).getFluid(); - if (aSetFluid == null) { - aSetFluid = f; - aSetFluid.amount = f.amount; - } - int toDrain = (f.amount - aSetFluid.amount); - FluidStack newStack; - if (toDrain <= 0) { - newStack = f; - } else { - newStack = ((IFluidTank) aTileEntity).drain(toDrain, true); - } - - if (newStack.isFluidEqual(aSetFluid) && newStack.amount == aSetFluid.amount) { - Logger.INFO("Removed fluid from vanilla IFluidTank successfully."); - return true; - } else { - Logger.INFO("Failed trying to remove fluid from vanilla IFluidTank."); - return false; - } - } - else { - - //Rewrite Fluid handling for Vanilla type tanks - if (!IFluidHandler.class.isInstance(aTileEntity)) { - Logger.INFO("Tile Was not an instance of IFluidHandler."); - return false; - } - - - IFluidHandler aTank = (IFluidHandler) aTileEntity; - FluidStack aTankContents = null; - FluidTankInfo[] a1 = aTank.getTankInfo(ForgeDirection.UNKNOWN); - if (a1 != null) { - if (a1[0] != null) { - aTankContents = a1[0].fluid; - Logger.INFO("Found Fluid in Tank. "+aTankContents.getLocalizedName()+" - "+aTankContents.amount); - } - } - if (aSetFluid == null) { - Logger.INFO("Setting fluid to tank contents, as we're going to empty it totally."); - aSetFluid = aTankContents.copy(); - } - else { - Logger.INFO("Setting fluid to tank contents, as we're going to empty it totally."); - } - Logger.INFO("Tile Was instance of IFluidHandler. Trying to Drain "+aSetFluid.getLocalizedName()+" - "+aSetFluid.amount); - - if (a1 == null || aTankContents == null) { - Logger.INFO("Tank is empty."); - return false; - } - //Found some Fluid in the tank - else { - FluidStack aDrainedStack = aTank.drain(ForgeDirection.UNKNOWN, aSetFluid, true); - if (aDrainedStack.isFluidStackIdentical(aSetFluid)) { - Logger.INFO("Drained!"); - return true; - } - else { - Logger.INFO("Partially Drained! This is probably an error."); - return true; - } - } - } - } else { - Logger.INFO("Bad Tank Tile to drain."); - return false; - } - - } - - /* - * GT Tanks - */ - - public FluidStack getStoredFluidOfGTMachine(IGregTechTileEntity aTileEntity) { - if (aTileEntity == null) { - return null; - } - final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - ; - if (aMetaTileEntity == null) { - return null; - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_BasicTank) { - Logger.INFO("Tile Was Instanceof BasicTank."); - return getStoredFluidOfGTMachine((GT_MetaTileEntity_BasicTank) aMetaTileEntity); - } else { - return null; - } - } - - public FluidStack getStoredFluidOfGTMachine(GT_MetaTileEntity_BasicTank aTileEntity) { - FluidStack f = aTileEntity.mFluid; - - //Let's see if this machine has output fluid too - /* - * if (f == null) { - * Logger.INFO("Could not find any input fluid, checking output if possible."); - * if (aTileEntity instanceof GT_MetaTileEntity_BasicMachine) { - * GT_MetaTileEntity_BasicMachine g = (GT_MetaTileEntity_BasicMachine) - * aTileEntity; - * Logger.INFO("Tile is a Basic Machine of some sort - "+g.mNEIName); if (g != - * null) { f = g.mOutputFluid; if (f != null) { - * Logger.INFO("Found output fluid! "+f.getLocalizedName()); } else { - * Logger.INFO("Did not find anything!"); f = g.getFluid(); if (f != null) { - * Logger.INFO("Found fluid! "+f.getLocalizedName()); } else { - * Logger.INFO("Did not find anything!"); f = g.getFluid(); } } } } } - */ - - Logger.INFO("Returning Fluid stack from tile. Found: " - + (f != null ? f.getLocalizedName() + " - " + f.amount + "L" : "Nothing")); - return f; - } - - public boolean setStoredFluidOfGTMachine(IGregTechTileEntity aTileEntity, FluidStack aSetFluid) { - Logger.INFO("Trying to clear Tile's tank. - Behaviour Class. [1]"); - if (aTileEntity == null) { - return false; - } - final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) { - return false; - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_BasicTank) { - Logger.INFO("Trying to clear Tile's tank. - Behaviour Class. [2]"); - return setStoredFluidOfGTMachine((GT_MetaTileEntity_BasicTank) aMetaTileEntity, aSetFluid); - } else { - return false; - } - } - - public boolean setStoredFluidOfGTMachine(GT_MetaTileEntity_BasicTank aTileEntity, FluidStack aSetFluid) { - try { - - //Try Handle Outputs First - /* - * if (aTileEntity.setDrainableStack(aSetFluid) != null) { return true; } - */ - - aTileEntity.mFluid = aSetFluid; - boolean b = aTileEntity.mFluid == aSetFluid; - Logger.INFO("Trying to set Tile's tank. - Behaviour Class. [3] " + b); - return b; - } catch (Throwable t) { - Logger.INFO("Trying to clear Tile's tank. FAILED - Behaviour Class. [x]"); - return false; - } - } - - - public int getCorrectMetaForItemstack(ItemStack aStack) { - if (aStack == null) { - return 0; - } - else { - if (aStack.getItemDamage() < this.mOffset) { - return 0; - } - else { - int newMeta = aStack.getItemDamage() - this.mOffset; - newMeta = (Math.max(0, Math.min(3, newMeta))); - return newMeta; - } - } - - - - - } - + /** + * Right Click Functions + */ + @Override + public boolean onItemUse( + ItemStack aStack, + EntityPlayer aPlayer, + World aWorld, + int aX, + int aY, + int aZ, + int a4, + float p_77648_8_, + float p_77648_9_, + float p_77648_10_) { + if (aStack == null || aPlayer == null || aWorld == null || aWorld.isRemote) { + return false; + } + if (!aWorld.isRemote && tryDrainTile(aStack, aWorld, aPlayer, aX, aY, aZ)) { + return true; + } else { + // return super.onItemUse(aStack, aPlayer, aWorld, aX, aY, aZ, a4, p_77648_8_, p_77648_9_, p_77648_10_); + return false; + } + } + + @Override + public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { + return p_77659_1_; + } + + /** + * GT Code + */ + + /* ---------- CONSTRUCTOR AND MEMBER VARIABLES ---------- */ + private final HashMap>> mItemBehaviors = new HashMap<>(); + + public final short mOffset, mItemAmount; + public final BitSet mEnabledItems; + public final BitSet mVisibleItems; + /** The unlocalized name of this item. */ + private String unlocalizedName; + + private final HashMap mIconMap = new LinkedHashMap(); + private final HashMap rarity = new LinkedHashMap(); + private final HashMap descColour = new LinkedHashMap(); + private final HashMap itemName = new LinkedHashMap(); + private final HashMap itemDescription = new LinkedHashMap(); + private final HashMap hasEffect = new LinkedHashMap(); + + public final HashMap mElectricStats = new LinkedHashMap(); + public final HashMap mBurnValues = new LinkedHashMap(); + + public void registerPumpType(final int aID, final String aPumpName, final int aEuMax, final int aTier) { + ModItems.toolGregtechPump.registerItem( + aID, // ID + aPumpName, // Name + aEuMax, // Eu Storage + (short) aTier, // Tier + "Can be used to remove fluids from GT machine input & output slots.", // Tooltip + aTier <= 0 + ? EnumRarity.common + : aTier == 1 + ? EnumRarity.uncommon + : aTier == 2 + ? EnumRarity.rare + : aTier == 3 ? EnumRarity.epic : EnumRarity.common, // Rarity + EnumChatFormatting.GRAY, // Desc colour + false // Effect? + ); + } + + public GregtechPump() { + this("MU-metatool.01", AddToCreativeTab.tabTools, (short) 1000, (short) 31766); + } + + public GregtechPump( + final String unlocalizedName, + final CreativeTabs creativeTab, + final short aOffset, + final short aItemAmount) { + this.mEnabledItems = new BitSet(aItemAmount); + this.mVisibleItems = new BitSet(aItemAmount); + this.mOffset = (short) Math.min(32766, aOffset); + this.mItemAmount = (short) Math.min(aItemAmount, 32766 - this.mOffset); + this.setHasSubtypes(true); + this.setMaxDamage(0); + this.setUnlocalizedName(unlocalizedName); + this.setCreativeTab(creativeTab); + this.setMaxStackSize(1); + if (GameRegistry.findItem(CORE.MODID, unlocalizedName) == null) { + GameRegistry.registerItem(this, unlocalizedName); + } + } + + public void registerItem( + final int id, final String localizedName, final long euStorage, final int tier, final String description) { + this.registerItem( + id, + localizedName, + euStorage, + (short) tier, + description, + EnumRarity.common, + EnumChatFormatting.GRAY, + false); + } + + public void registerItem( + final int id, + final String localizedName, + final long euStorage, + final int tier, + final String description, + final int burnTime) { + this.registerItem( + id, + localizedName, + euStorage, + (short) tier, + description, + EnumRarity.common, + EnumChatFormatting.GRAY, + false); + this.setBurnValue(id, burnTime); + } + + public void registerItem( + final int id, + final String localizedName, + final long euStorage, + final short tier, + final String description, + final EnumRarity regRarity, + final EnumChatFormatting colour, + final boolean Effect) { + this.addItem(id, localizedName, EnumChatFormatting.YELLOW + "Electric", new Object[] {}); + if (euStorage > 0 && tier > 0) + this.setElectricStats(this.mOffset + id, euStorage, GT_Values.V[tier], tier, -3L, true); + this.rarity.put(id, regRarity); + this.itemName.put(id, localizedName); + this.itemDescription.put(id, description); + this.descColour.put(id, colour); + this.hasEffect.put(id, Effect); + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(final ItemStack par1ItemStack) { + int h = getCorrectMetaForItemstack(par1ItemStack); + if (this.rarity.get(h) != null) { + return this.rarity.get(h); + } + return EnumRarity.common; + } + + @Override + public boolean hasEffect(final ItemStack par1ItemStack) { + int h = getCorrectMetaForItemstack(par1ItemStack); + if (this.hasEffect.get(h) != null) { + return this.hasEffect.get(h); + } + return false; + } + + @SuppressWarnings({"unchecked"}) + @Override + public void addInformation(final ItemStack aStack, final EntityPlayer aPlayer, List aList, final boolean aF3_H) { + // aList.add("Meta: "+(aStack.getItemDamage()-mOffset)); + + int aOffsetMeta = getCorrectMetaForItemstack(aStack); + + if ((this.descColour.get(aOffsetMeta) != null) && (this.itemDescription.get(aOffsetMeta) != null)) { + aList.add(this.descColour.get(aOffsetMeta) + this.itemDescription.get(aOffsetMeta)); + } + + if (aOffsetMeta <= 3) { + FluidStack f = getFluid(aStack); + aList.add("Cannot drain any other standard fluid container block"); + aList.add("Cannot be emptied via RMB, use inside a tank with GUI"); + aList.add(EnumChatFormatting.DARK_GRAY + "This is technically just a fancy fluid cell"); + aList.add(EnumChatFormatting.BLUE + (f != null ? f.getLocalizedName() : "No Fluids Contained")); + aList.add(EnumChatFormatting.BLUE + (f != null ? "" + f.amount : "" + 0) + "L" + " / " + getCapacity(aStack) + + "L"); + } + + final Long[] tStats = this.getElectricStats(aStack); + if (tStats != null) { + if (tStats[3] > 0) { + aList.add(EnumChatFormatting.AQUA + "Contains " + GT_Utility.formatNumbers(tStats[3]) + " EU Tier: " + + (tStats[2] >= 0 ? tStats[2] : 0) + EnumChatFormatting.GRAY); + } else { + final long tCharge = this.getRealCharge(aStack); + if ((tStats[3] == -2) && (tCharge <= 0)) { + aList.add(EnumChatFormatting.AQUA + "Empty. You should recycle it properly." + + EnumChatFormatting.GRAY); + } else { + aList.add(EnumChatFormatting.AQUA + "" + GT_Utility.formatNumbers(tCharge) + " / " + + GT_Utility.formatNumbers(Math.abs(tStats[0])) + " EU - Voltage: " + + V[(int) (tStats[2] >= 0 ? tStats[2] < V.length ? tStats[2] : V.length - 1 : 1)] + + EnumChatFormatting.GRAY); + } + } + } + + final ArrayList> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); + if (tList != null) { + for (final IItemBehaviour tBehavior : tList) { + aList = tBehavior.getAdditionalToolTips(this, aList, aStack); + } + } + } + + @Override + public final Item getChargedItem(final ItemStack itemStack) { + return this; + } + + @Override + public final Item getEmptyItem(final ItemStack itemStack) { + return this; + } + + @Override + public final double getMaxCharge(final ItemStack aStack) { + final Long[] tStats = this.getElectricStats(aStack); + if (tStats == null) { + return 0; + } + return Math.abs(tStats[0]); + } + + @Override + public final double getTransferLimit(final ItemStack aStack) { + final Long[] tStats = this.getElectricStats(aStack); + if (tStats == null) { + return 0; + } + return Math.max(tStats[1], tStats[3]); + } + + @Override + public final int getTier(final ItemStack aStack) { + final Long[] tStats = this.getElectricStats(aStack); + return (int) (tStats == null ? Integer.MAX_VALUE : tStats[2]); + } + + @Override + public final double charge( + final ItemStack aStack, + final double aCharge, + final int aTier, + final boolean aIgnoreTransferLimit, + final boolean aSimulate) { + final Long[] tStats = this.getElectricStats(aStack); + if ((tStats == null) + || (tStats[2] > aTier) + || !((tStats[3] == -1) || (tStats[3] == -3) || ((tStats[3] < 0) && (aCharge == Integer.MAX_VALUE))) + || (aStack.stackSize != 1)) { + return 0; + } + final long tChargeBefore = this.getRealCharge(aStack), + tNewCharge = + aCharge == Integer.MAX_VALUE + ? Long.MAX_VALUE + : Math.min( + Math.abs(tStats[0]), + tChargeBefore + + (aIgnoreTransferLimit + ? (long) aCharge + : Math.min(tStats[1], (long) aCharge))); + if (!aSimulate) { + this.setCharge(aStack, tNewCharge); + } + return tNewCharge - tChargeBefore; + } + + @Override + public final double discharge( + final ItemStack aStack, + final double aCharge, + final int aTier, + final boolean aIgnoreTransferLimit, + final boolean aBatteryAlike, + final boolean aSimulate) { + final Long[] tStats = this.getElectricStats(aStack); + if ((tStats == null) || (tStats[2] > aTier)) { + return 0; + } + if (aBatteryAlike && !this.canProvideEnergy(aStack)) { + return 0; + } + if (tStats[3] > 0) { + if ((aCharge < tStats[3]) || (aStack.stackSize < 1)) { + return 0; + } + if (!aSimulate) { + aStack.stackSize--; + } + return tStats[3]; + } + final long tChargeBefore = this.getRealCharge(aStack), + tNewCharge = + Math.max( + 0, + tChargeBefore + - (aIgnoreTransferLimit + ? (long) aCharge + : Math.min(tStats[1], (long) aCharge))); + if (!aSimulate) { + this.setCharge(aStack, tNewCharge); + } + return tChargeBefore - tNewCharge; + } + + @Override + public final double getCharge(final ItemStack aStack) { + return this.getRealCharge(aStack); + } + + @Override + public final boolean canUse(final ItemStack aStack, final double aAmount) { + return this.getRealCharge(aStack) >= aAmount; + } + + @Override + public final boolean use(final ItemStack aStack, final double aAmount, final EntityLivingBase aPlayer) { + this.chargeFromArmor(aStack, aPlayer); + if ((aPlayer instanceof EntityPlayer) && ((EntityPlayer) aPlayer).capabilities.isCreativeMode) { + return true; + } + final double tTransfer = this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, true); + if (tTransfer == aAmount) { + this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, false); + this.chargeFromArmor(aStack, aPlayer); + return true; + } + this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, false); + this.chargeFromArmor(aStack, aPlayer); + return false; + } + + @Override + public final boolean canProvideEnergy(final ItemStack aStack) { + final Long[] tStats = this.getElectricStats(aStack); + if (tStats == null) { + return false; + } + return (tStats[3] > 0) || ((aStack.stackSize == 1) && ((tStats[3] == -2) || (tStats[3] == -3))); + } + + @Override + public final void chargeFromArmor(final ItemStack aStack, final EntityLivingBase aPlayer) { + if ((aPlayer == null) || aPlayer.worldObj.isRemote) { + return; + } + for (int i = 1; i < 5; i++) { + final ItemStack tArmor = aPlayer.getEquipmentInSlot(i); + if (GT_ModHandler.isElectricItem(tArmor)) { + final IElectricItem tArmorItem = (IElectricItem) tArmor.getItem(); + if (tArmorItem.canProvideEnergy(tArmor) && (tArmorItem.getTier(tArmor) >= this.getTier(aStack))) { + final double tCharge = ElectricItem.manager.discharge( + tArmor, + this.charge(aStack, Integer.MAX_VALUE - 1, Integer.MAX_VALUE, true, true), + Integer.MAX_VALUE, + true, + true, + false); + if (tCharge > 0) { + this.charge(aStack, tCharge, Integer.MAX_VALUE, true, false); + if (aPlayer instanceof EntityPlayer) { + final Container tContainer = ((EntityPlayer) aPlayer).openContainer; + if (tContainer != null) { + tContainer.detectAndSendChanges(); + } + } + } + } + } + } + } + + public final long getRealCharge(final ItemStack aStack) { + final Long[] tStats = this.getElectricStats(aStack); + if (tStats == null) { + return 0; + } + if (tStats[3] > 0) { + return (int) (long) tStats[3]; + } + final NBTTagCompound tNBT = aStack.getTagCompound(); + return tNBT == null ? 0 : tNBT.getLong("GT.ItemCharge"); + } + + public final boolean setCharge(final ItemStack aStack, long aCharge) { + final Long[] tStats = this.getElectricStats(aStack); + if ((tStats == null) || (tStats[3] > 0)) { + return false; + } + NBTTagCompound tNBT = aStack.getTagCompound(); + if (tNBT == null) { + tNBT = new NBTTagCompound(); + } + tNBT.removeTag("GT.ItemCharge"); + aCharge = Math.min(tStats[0] < 0 ? Math.abs(tStats[0] / 2) : aCharge, Math.abs(tStats[0])); + if (aCharge > 0) { + aStack.setItemDamage(this.getChargedMetaData(aStack)); + tNBT.setLong("GT.ItemCharge", aCharge); + } else { + aStack.setItemDamage(this.getEmptyMetaData(aStack)); + } + if (tNBT.hasNoTags()) { + aStack.setTagCompound(null); + } else { + aStack.setTagCompound(tNBT); + } + this.isItemStackUsable(aStack); + return true; + } + + public short getChargedMetaData(final ItemStack aStack) { + return (short) aStack.getItemDamage(); + } + + public short getEmptyMetaData(final ItemStack aStack) { + return (short) aStack.getItemDamage(); + } + + public boolean isItemStackUsable(final ItemStack aStack) { + final ArrayList> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); + if (tList != null) { + for (final IItemBehaviour tBehavior : tList) { + if (!tBehavior.isItemStackUsable(this, aStack)) { + return false; + } + } + } + return true; + } + + @Override + public final String getToolTip(final ItemStack aStack) { + return null; + } // This has its own ToolTip Handler, no need to let the IC2 Handler screw us up + // at this Point + + @Override + public final IElectricItemManager getManager(final ItemStack aStack) { + return this; + } // We are our own Manager + + /** + * Sets the Furnace Burn Value for the Item. + * + * @param aMetaValue + * the Meta Value of the Item you want to set it to. [0 - 32765] + * @param aValue + * 200 = 1 Burn Process = 500 EU, max = 32767 (that is 81917.5 EU) + * @return the Item itself for convenience in constructing. + */ + public final GregtechPump setBurnValue(final int aMetaValue, final int aValue) { + if ((aMetaValue < 0) || (aValue < 0)) { + return this; + } + if (aValue == 0) { + this.mBurnValues.remove((short) aMetaValue); + } else { + this.mBurnValues.put((short) aMetaValue, aValue > Short.MAX_VALUE ? Short.MAX_VALUE : (short) aValue); + } + return this; + } + + /** + * @param aMetaValue + * the Meta Value of the Item you want to set it to. [0 - 32765] + * @param aMaxCharge + * Maximum Charge. (if this is == 0 it will remove the Electric + * Behavior) + * @param aTransferLimit + * Transfer Limit. + * @param aTier + * The electric Tier. + * @param aSpecialData + * If this Item has a Fixed Charge, like a SingleUse Battery (if > + * 0). Use -1 if you want to make this Battery chargeable (the use + * and canUse Functions will still discharge if you just use this) + * Use -2 if you want to make this Battery dischargeable. Use -3 if + * you want to make this Battery charge/discharge-able. + * @return the Item itself for convenience in constructing. + */ + public final GregtechPump setElectricStats( + final int aMetaValue, + final long aMaxCharge, + final long aTransferLimit, + final long aTier, + final long aSpecialData, + final boolean aUseAnimations) { + if (aMetaValue < 0) { + return this; + } + if (aMaxCharge == 0) { + this.mElectricStats.remove((short) aMetaValue); + } else { + this.mElectricStats.put( + (short) aMetaValue, + new Long[] {aMaxCharge, Math.max(0, aTransferLimit), Math.max(-1, aTier), aSpecialData}); + } + return this; + } + + @SuppressWarnings({"unchecked"}) + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(final Item var1, final CreativeTabs aCreativeTab, final List aList) { + for (int i = 0, j = this.mEnabledItems.length(); i < j; i++) { + if (this.mVisibleItems.get(i) || (GT_Values.D1 && this.mEnabledItems.get(i))) { + final Long[] tStats = this.mElectricStats.get((short) (this.mOffset + i)); + if ((tStats != null) && (tStats[3] < 0)) { + final ItemStack tStack = new ItemStack(this, 1, this.mOffset + i); + this.setCharge(tStack, Math.abs(tStats[0])); + this.isItemStackUsable(tStack); + aList.add(tStack); + } + if ((tStats == null) || (tStats[3] != -2)) { + final ItemStack tStack = new ItemStack(this, 1, this.mOffset + i); + this.isItemStackUsable(tStack); + aList.add(tStack); + } + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public final void registerIcons(final IIconRegister aIconRegister) { + for (short i = 0, j = (short) this.mEnabledItems.length(); i < j; i++) { + if (this.mEnabledItems.get(i)) { + mIconMap.put( + (int) i, aIconRegister.registerIcon(CORE.MODID + ":" + (this.getUnlocalizedName() + "/" + i))); + } + } + } + + @Override + public final IIcon getIconFromDamage(final int aMetaData) { + if (aMetaData < 0) { + return null; + } + if (aMetaData < this.mOffset) { + return mIconMap.get(0); + } else { + int newMeta = aMetaData - this.mOffset; + newMeta = (Math.max(0, Math.min(3, newMeta))); + return mIconMap.get(newMeta); + } + } + + /** + * Sets the unlocalized name of this item to the string passed as the parameter" + */ + @Override + public Item setUnlocalizedName(final String p_77655_1_) { + this.unlocalizedName = p_77655_1_; + super.setUnlocalizedName(p_77655_1_); + return this; + } + + /** + * Returns the unlocalized name of this item. + */ + @Override + public String getUnlocalizedName() { + return this.unlocalizedName; + } + + public final Long[] getElectricStats(final ItemStack aStack) { + return this.mElectricStats.get((short) aStack.getItemDamage()); + } + + @Override + public int getItemEnchantability() { + return 0; + } + + @Override + public boolean isBookEnchantable(final ItemStack aStack, final ItemStack aBook) { + return false; + } + + @Override + public boolean getIsRepairable(final ItemStack aStack, final ItemStack aMaterial) { + return false; + } + + /** + * Adds a special Item Behaviour to the Item. + *

+ * Note: the boolean Behaviours sometimes won't be executed if another boolean + * Behaviour returned true before. + * + * @param aMetaValue + * the Meta Value of the Item you want to add it to. [0 - 32765] + * @param aBehavior + * the Click Behavior you want to add. + * @return the Item itself for convenience in constructing. + */ + public final GregtechPump addItemBehavior(final int aMetaValue, final IItemBehaviour aBehavior) { + if ((aMetaValue < 0) || (aMetaValue >= 32766) || (aBehavior == null)) { + return this; + } + ArrayList> tList = this.mItemBehaviors.get((short) aMetaValue); + if (tList == null) { + tList = new ArrayList<>(1); + this.mItemBehaviors.put((short) aMetaValue, tList); + } + tList.add(aBehavior); + return this; + } + + /** + * This adds a Custom Item to the ending Range. + * + * @param aID + * The Id of the assigned Item [0 - mItemAmount] (The MetaData gets + * auto-shifted by +mOffset) + * @param aEnglish + * The Default Localized Name of the created Item + * @param aToolTip + * The Default ToolTip of the created Item, you can also insert null + * for having no ToolTip + * @param aFoodBehavior + * The Food Value of this Item. Can be null aswell. Just a + * convenience thing. + * @param aRandomData + * The OreDict Names you want to give the Item. Also used for TC + * Aspects and some other things. + * @return An ItemStack containing the newly created Item. + */ + @SuppressWarnings("unchecked") + public final ItemStack addItem(final int aID, final String aEnglish, String aToolTip, final Object... aRandomData) { + if (aToolTip == null) { + aToolTip = ""; + } + if ((aID >= 0) && (aID < this.mItemAmount)) { + final ItemStack rStack = new ItemStack(this, 1, this.mOffset + aID); + GT_ModHandler.registerBoxableItemToToolBox(rStack); + this.mEnabledItems.set(aID); + this.mVisibleItems.set(aID); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(rStack) + ".name", aEnglish); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(rStack) + ".tooltip", aToolTip); + final List tAspects = new ArrayList<>(); + // Important Stuff to do first + for (final Object tRandomData : aRandomData) { + if (tRandomData instanceof SubTag) { + if (tRandomData == SubTag.INVISIBLE) { + this.mVisibleItems.set(aID, false); + continue; + } + if (tRandomData == SubTag.NO_UNIFICATION) { + GT_OreDictUnificator.addToBlacklist(rStack); + continue; + } + } + } + // now check for the rest + for (final Object tRandomData : aRandomData) { + if (tRandomData != null) { + boolean tUseOreDict = true; + if (tRandomData instanceof IItemBehaviour) { + this.addItemBehavior(this.mOffset + aID, (IItemBehaviour) tRandomData); + tUseOreDict = false; + } + if (tRandomData instanceof IItemContainer) { + ((IItemContainer) tRandomData).set(rStack); + tUseOreDict = false; + } + if (tRandomData instanceof SubTag) { + continue; + } + if (tRandomData instanceof TC_AspectStack) { + ((TC_AspectStack) tRandomData).addToAspectList(tAspects); + continue; + } + if (tRandomData instanceof ItemData) { + if (GT_Utility.isStringValid(tRandomData)) { + GT_OreDictUnificator.registerOre(tRandomData, rStack); + } else { + GT_OreDictUnificator.addItemData(rStack, (ItemData) tRandomData); + } + continue; + } + if (tUseOreDict) { + GT_OreDictUnificator.registerOre(tRandomData, rStack); + continue; + } + } + } + if (GregTech_API.sThaumcraftCompat != null) { + GregTech_API.sThaumcraftCompat.registerThaumcraftAspectsToItem(rStack, tAspects, false); + } + return rStack; + } + return null; + } + + @Override + public String getItemStackDisplayName(final ItemStack aStack) { + int keyValue = (getCorrectMetaForItemstack(aStack)); + if (keyValue < 0 || keyValue > 3) { + keyValue = 0; + } + return this.itemName.get(keyValue); + } + + /** + * Fluid Handling + */ + + /* + * IFluidContainer Functions + */ + + public void emptyStoredFluid(ItemStack aStack) { + if (aStack.hasTagCompound()) { + NBTTagCompound t = aStack.getTagCompound(); + if (t.hasKey("mInit")) { + t.removeTag("mInit"); + } + if (t.hasKey("mFluid")) { + t.removeTag("mFluid"); + } + if (t.hasKey("mFluidAmount")) { + t.removeTag("mFluidAmount"); + } + } + } + + public void storeFluid(ItemStack aStack, FluidStack aFluid) { + if (aFluid == null) { + return; + } else { + String fluidname = aFluid.getFluid().getName(); + int amount = aFluid.amount; + if (fluidname != null && fluidname.length() > 0 && amount > 0) { + NBTUtils.setString(aStack, "mFluid", fluidname); + NBTUtils.setInteger(aStack, "mFluidAmount", amount); + } + } + } + + @Override + public FluidStack getFluid(ItemStack container) { + if (!container.hasTagCompound() || !container.getTagCompound().hasKey("mInit")) { + initNBT(container); + } + if (container.getTagCompound().hasKey("mInit") + && container.getTagCompound().getBoolean("mInit")) { + String fluidname; + Integer amount = 0; + fluidname = NBTUtils.getString(container, "mFluid"); + amount = NBTUtils.getInteger(container, "mFluidAmount"); + if (fluidname != null && amount != null && amount > 0) { + return FluidUtils.getFluidStack(fluidname, amount); + } else { + return null; + } + } + return null; + } + + @Override + public int getCapacity(ItemStack container) { + if (!container.hasTagCompound() || !container.getTagCompound().hasKey("mInit")) { + initNBT(container); + } + if (container.getTagCompound().hasKey("mInit") + && container.getTagCompound().getBoolean("mInit")) { + return container.getTagCompound().getInteger("mCapacity"); + } + int aMeta = this.getCorrectMetaForItemstack(container); + int aCapacity = (aMeta == 0 ? 2000 : (aMeta == 1 ? 8000 : (aMeta == 2 ? 32000 : 128000))); + return aCapacity; + } + + public int fill(ItemStack container, FluidStack resource) { + return fill(container, resource, true); + } + + @Override + public int fill(ItemStack container, FluidStack resource, boolean doFill) { + if (!doFill || resource == null) { + return 0; + } + + if (!container.hasTagCompound() || !container.getTagCompound().hasKey("mInit")) { + initNBT(container); + } + if (container.getTagCompound().hasKey("mInit") + && container.getTagCompound().getBoolean("mInit")) { + String aStored; + int aStoredAmount = 0; + int aCapacity = getCapacity(container); + FluidStack aStoredFluid = getFluid(container); + if (aStoredFluid != null) { + aStored = aStoredFluid.getFluid().getName(); + aStoredAmount = aStoredFluid.amount; + if (aStoredAmount == aCapacity) { + return 0; + } + } + // Handle no stored fluid first + if (aStoredFluid == null) { + Logger.INFO("Pump is empty, filling with tank fluids."); + FluidStack toConsume; + int amountToConsume = 0; + if (resource.amount >= aCapacity) { + amountToConsume = aCapacity; + } else { + amountToConsume = resource.amount; + } + toConsume = FluidUtils.getFluidStack(resource, amountToConsume); + if (toConsume != null && amountToConsume > 0) { + storeFluid(container, toConsume); + return amountToConsume; + } + } else { + Logger.INFO("Pump is Partially full, filling with tank fluids."); + if (aStoredFluid.isFluidEqual(resource)) { + Logger.INFO("Found matching fluids."); + int aSpaceLeft = (aCapacity - aStoredAmount); + Logger.INFO( + "Capacity: " + aCapacity + " | Stored: " + aStoredAmount + " | Space left: " + aSpaceLeft); + FluidStack toConsume; + int amountToConsume = 0; + if (resource.amount >= aSpaceLeft) { + amountToConsume = aSpaceLeft; + Logger.INFO("More or equal fluid amount to pump container space."); + } else { + amountToConsume = resource.amount; + Logger.INFO("Less fluid than container space"); + } + Logger.INFO("Amount to consume: " + amountToConsume); + toConsume = FluidUtils.getFluidStack(resource, (aStoredAmount + amountToConsume)); + if (toConsume != null && amountToConsume > 0) { + Logger.INFO("Storing Fluid"); + storeFluid(container, toConsume); + return amountToConsume; + } else { + Logger.INFO("Not storing fluid"); + } + } else { + Logger.INFO("Fluids did not match."); + } + } + } + return 0; + } + + public FluidStack drain(ItemStack container, int drainAmt) { + return drain(container, drainAmt, true); + } + + @Override + public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain) { + if (!doDrain || maxDrain == 0) { + return null; + } + if (!container.hasTagCompound() || !container.getTagCompound().hasKey("mInit")) { + initNBT(container); + } + if (container.getTagCompound().hasKey("mInit") + && container.getTagCompound().getBoolean("mInit")) { + + String aStored; + int aStoredAmount = 0; + FluidStack aStoredFluid = getFluid(container); + + if (aStoredFluid != null) { + aStored = aStoredFluid.getFluid().getName(); + aStoredAmount = aStoredFluid.amount; + } + // We cannot drain this if it's empty. + else if (aStoredFluid == null) { + return null; + } + + if (maxDrain >= aStoredAmount) { + emptyStoredFluid(container); + return aStoredFluid; + } else { + // Handle Partial removal + int amountRemaining = (aStoredAmount - maxDrain); + if (amountRemaining == 0) { + emptyStoredFluid(container); + } else { + FluidStack newAmount = FluidUtils.getFluidStack(aStoredFluid, amountRemaining); + FluidStack drained = FluidUtils.getFluidStack(aStoredFluid, maxDrain); + if (newAmount != null && drained != null) { + storeFluid(container, newAmount); + return drained; + } + } + } + } + return null; + } + + /* + * Handle ItemStack NBT + */ + + public void initNBT(ItemStack aStack) { + NBTTagCompound aNewNBT; + if (!aStack.hasTagCompound()) { + aNewNBT = new NBTTagCompound(); + } else { + aNewNBT = aStack.getTagCompound(); + } + + if (!aNewNBT.hasKey("mInit")) { + int aMeta = this.getCorrectMetaForItemstack(aStack); + aNewNBT.setInteger("mMeta", aMeta); + aNewNBT.setBoolean("mInit", true); + aNewNBT.setString("mFluid", "@@@@@"); + aNewNBT.setInteger("mFluidAmount", 0); + int aCapacity = (aMeta == 0 ? 2000 : (aMeta == 1 ? 8000 : (aMeta == 2 ? 32000 : 128000))); + aNewNBT.setInteger("mCapacity", aCapacity); + aStack.setTagCompound(aNewNBT); + } + } + + /** + * Tile Handling + */ + + /* + * Custom Fluid Handling for Tiles and GT Tiles. + */ + + public boolean tryDrainTile(ItemStack aStack, World aWorld, EntityPlayer aPlayer, int aX, int aY, int aZ) { + try { + if (aWorld.isRemote || aStack == null) { + return false; + } else { + int aTier = (aStack.getItemDamage() - 1000); + int removal; + if (aTier == 0) { + removal = 0; + } else if (aTier == 1) { + removal = 32; + } else if (aTier == 2) { + removal = 128; + } else if (aTier == 3) { + removal = 512; + } else { + removal = 8; + } + if (!canUse(aStack, removal) && aTier > 0) { + PlayerUtils.messagePlayer(aPlayer, "Not enough power."); + Logger.INFO("No Power"); + return false; + } + + final Block aBlock = aWorld.getBlock(aX, aY, aZ); + if (aBlock == null) { + return false; + } + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity == null) { + return false; + } else { + double aCharge = this.getCharge(aStack); + boolean didDrain = false; + if (aTier > 0 && aCharge > 0) { + if (discharge(aStack, removal, aTier, true, true, false) > 0) { + didDrain = true; + } + } else if (aTier == 0) { + didDrain = true; + } else { + didDrain = false; + } + + if (didDrain) { + if ((tTileEntity instanceof IGregTechTileEntity)) { + return this.drainTankGT(tTileEntity, aStack, aWorld, aPlayer, aX, aY, aZ); + } + // Try support Standard Fluid Tanks too (May disable if dupes appear again) + else if ((tTileEntity instanceof IFluidTank || tTileEntity instanceof IFluidHandler)) { + // return this.drainIFluidTank(tTileEntity, aStack, aWorld, aPlayer, aX, aY, aZ); + return false; + } + } + } + } + } catch (Throwable t) { + } + return false; + } + + /* + * Vanilla IFluidTank + */ + + public boolean drainIFluidTank( + TileEntity tTileEntity, ItemStack aStack, World aWorld, EntityPlayer aPlayer, int aX, int aY, int aZ) { + if (tTileEntity == null) { + Logger.INFO("Invalid Tile, somehow."); + return false; + } + if ((tTileEntity instanceof IFluidTank || tTileEntity instanceof IFluidHandler)) { + if (this.getFluid(aStack) == null + || (this.getFluid(aStack) != null && this.getFluid(aStack).amount < this.getCapacity(aStack))) { + Logger.INFO("Trying to find Stored Fluid - Behaviour Class."); + FluidStack aStored = getStoredFluidOfVanillaTank(tTileEntity); + if (aStored != null) { + int mAmountInserted = fill(aStack, aStored); + FluidStack newStackRemainingInTank; + if (mAmountInserted > 0) { + if (mAmountInserted == aStored.amount) { + newStackRemainingInTank = null; + } else { + newStackRemainingInTank = + FluidUtils.getFluidStack(aStored, (aStored.amount - mAmountInserted)); + } + boolean b = setStoredFluidOfVanillaTank(tTileEntity, newStackRemainingInTank); + Logger.INFO("Cleared Tank? " + b + " | mAmountInserted: " + mAmountInserted); + Logger.INFO("Returning " + b + " - drainTankVanilla."); + if (b) { + PlayerUtils.messagePlayer( + aPlayer, "Drained " + mAmountInserted + "L of " + aStored.getLocalizedName() + "."); + } + return b; + } + } else { + Logger.INFO("Found no valid Fluidstack - drainTankVanilla."); + } + } else { + Logger.INFO("Pump is full."); + } + } + Logger.INFO("Could not drain vanilla tank."); + return false; + } + + /* + * GT Tanks + */ + + public boolean drainTankGT( + TileEntity tTileEntity, ItemStack aStack, World aWorld, EntityPlayer aPlayer, int aX, int aY, int aZ) { + if (tTileEntity == null) { + return false; + } + if ((tTileEntity instanceof IGregTechTileEntity)) { + Logger.INFO("Right Clicking on GT Tile - drainTankGT."); + if (((IGregTechTileEntity) tTileEntity).getTimer() < 50L) { + Logger.INFO("Returning False - Behaviour Class. Timer < 50"); + return false; + } else if ((!aWorld.isRemote) && (!((IGregTechTileEntity) tTileEntity).isUseableByPlayer(aPlayer))) { + Logger.INFO("Returning True - drainTankGT. NotUsable()"); + return true; + } else { + if (this.getFluid(aStack) == null + || (this.getFluid(aStack) != null && this.getFluid(aStack).amount < this.getCapacity(aStack))) { + Logger.INFO("Trying to find Stored Fluid - drainTankGT."); + FluidStack aStored = getStoredFluidOfGTMachine((IGregTechTileEntity) tTileEntity); + if (aStored != null) { + int mAmountInserted = fill(aStack, aStored); + FluidStack newStackRemainingInTank; + if (mAmountInserted > 0) { + if (mAmountInserted == aStored.amount) { + newStackRemainingInTank = null; + } else { + newStackRemainingInTank = + FluidUtils.getFluidStack(aStored, (aStored.amount - mAmountInserted)); + } + boolean b = setStoredFluidOfGTMachine( + (IGregTechTileEntity) tTileEntity, newStackRemainingInTank); + Logger.INFO("Cleared Tank? " + b + " | mAmountInserted: " + mAmountInserted); + Logger.INFO("Returning " + b + " - drainTankGT."); + if (b) { + PlayerUtils.messagePlayer( + aPlayer, + "Drained " + mAmountInserted + "L of " + aStored.getLocalizedName() + "."); + } + return b; + } + } else { + Logger.INFO("Found no valid Fluidstack - drainTankGT."); + } + } else { + Logger.INFO("Pump is full."); + } + } + } + Logger.INFO("Could not drain GT tank."); + return false; + } + + /* + * Vanilla Tanks + */ + + public FluidStack getStoredFluidOfVanillaTank(TileEntity aTileEntity) { + if (aTileEntity == null) { + return null; + } else if ((aTileEntity instanceof IFluidTank || aTileEntity instanceof IFluidHandler)) { + if (aTileEntity instanceof IFluidTank) { + return getStoredFluidOfVanillaTank((IFluidTank) aTileEntity); + } else { + return getStoredFluidOfVanillaTank((IFluidHandler) aTileEntity); + } + } else { + return null; + } + } + + public FluidStack getStoredFluidOfVanillaTank(IFluidTank aTileEntity) { + FluidStack f = aTileEntity.getFluid(); + Logger.INFO("Returning Fluid stack from tile. Found: " + + (f != null ? f.getLocalizedName() + " - " + f.amount + "L" : "Nothing")); + return f; + } + + public FluidStack getStoredFluidOfVanillaTank(IFluidHandler aTileEntity) { + if (aTileEntity instanceof IFluidTank) { + return getStoredFluidOfVanillaTank((IFluidTank) aTileEntity); + } + FluidStack f; + AutoMap m = new AutoMap(); + for (int i = 0; i < 6; i++) { + m.put(aTileEntity.getTankInfo(ForgeDirection.getOrientation(i))); + } + if (m.get(0) != null && m.get(0)[0] != null && m.get(0)[0].fluid != null) { + return m.get(0)[0].fluid; + } else { + return null; + } + } + + public boolean setStoredFluidOfVanillaTank(TileEntity aTileEntity, FluidStack aSetFluid) { + Logger.INFO("Trying to clear Tile's tank. - Behaviour Class. [1]"); + + if (aTileEntity == null) { + return false; + } else if ((aTileEntity instanceof IFluidTank || aTileEntity instanceof IFluidHandler)) { + if (aTileEntity instanceof IFluidTank) { + Logger.INFO("Tile Was instanceof IFluidTank."); + FluidStack f = ((IFluidTank) aTileEntity).getFluid(); + if (aSetFluid == null) { + aSetFluid = f; + aSetFluid.amount = f.amount; + } + int toDrain = (f.amount - aSetFluid.amount); + FluidStack newStack; + if (toDrain <= 0) { + newStack = f; + } else { + newStack = ((IFluidTank) aTileEntity).drain(toDrain, true); + } + + if (newStack.isFluidEqual(aSetFluid) && newStack.amount == aSetFluid.amount) { + Logger.INFO("Removed fluid from vanilla IFluidTank successfully."); + return true; + } else { + Logger.INFO("Failed trying to remove fluid from vanilla IFluidTank."); + return false; + } + } else { + + // Rewrite Fluid handling for Vanilla type tanks + if (!IFluidHandler.class.isInstance(aTileEntity)) { + Logger.INFO("Tile Was not an instance of IFluidHandler."); + return false; + } + + IFluidHandler aTank = (IFluidHandler) aTileEntity; + FluidStack aTankContents = null; + FluidTankInfo[] a1 = aTank.getTankInfo(ForgeDirection.UNKNOWN); + if (a1 != null) { + if (a1[0] != null) { + aTankContents = a1[0].fluid; + Logger.INFO("Found Fluid in Tank. " + aTankContents.getLocalizedName() + " - " + + aTankContents.amount); + } + } + if (aSetFluid == null) { + Logger.INFO("Setting fluid to tank contents, as we're going to empty it totally."); + aSetFluid = aTankContents.copy(); + } else { + Logger.INFO("Setting fluid to tank contents, as we're going to empty it totally."); + } + Logger.INFO("Tile Was instance of IFluidHandler. Trying to Drain " + aSetFluid.getLocalizedName() + + " - " + aSetFluid.amount); + + if (a1 == null || aTankContents == null) { + Logger.INFO("Tank is empty."); + return false; + } + // Found some Fluid in the tank + else { + FluidStack aDrainedStack = aTank.drain(ForgeDirection.UNKNOWN, aSetFluid, true); + if (aDrainedStack.isFluidStackIdentical(aSetFluid)) { + Logger.INFO("Drained!"); + return true; + } else { + Logger.INFO("Partially Drained! This is probably an error."); + return true; + } + } + } + } else { + Logger.INFO("Bad Tank Tile to drain."); + return false; + } + } + + /* + * GT Tanks + */ + + public FluidStack getStoredFluidOfGTMachine(IGregTechTileEntity aTileEntity) { + if (aTileEntity == null) { + return null; + } + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + ; + if (aMetaTileEntity == null) { + return null; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_BasicTank) { + Logger.INFO("Tile Was Instanceof BasicTank."); + return getStoredFluidOfGTMachine((GT_MetaTileEntity_BasicTank) aMetaTileEntity); + } else { + return null; + } + } + + public FluidStack getStoredFluidOfGTMachine(GT_MetaTileEntity_BasicTank aTileEntity) { + FluidStack f = aTileEntity.mFluid; + + // Let's see if this machine has output fluid too + /* + * if (f == null) { + * Logger.INFO("Could not find any input fluid, checking output if possible."); + * if (aTileEntity instanceof GT_MetaTileEntity_BasicMachine) { + * GT_MetaTileEntity_BasicMachine g = (GT_MetaTileEntity_BasicMachine) + * aTileEntity; + * Logger.INFO("Tile is a Basic Machine of some sort - "+g.mNEIName); if (g != + * null) { f = g.mOutputFluid; if (f != null) { + * Logger.INFO("Found output fluid! "+f.getLocalizedName()); } else { + * Logger.INFO("Did not find anything!"); f = g.getFluid(); if (f != null) { + * Logger.INFO("Found fluid! "+f.getLocalizedName()); } else { + * Logger.INFO("Did not find anything!"); f = g.getFluid(); } } } } } + */ + + Logger.INFO("Returning Fluid stack from tile. Found: " + + (f != null ? f.getLocalizedName() + " - " + f.amount + "L" : "Nothing")); + return f; + } + + public boolean setStoredFluidOfGTMachine(IGregTechTileEntity aTileEntity, FluidStack aSetFluid) { + Logger.INFO("Trying to clear Tile's tank. - Behaviour Class. [1]"); + if (aTileEntity == null) { + return false; + } + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_BasicTank) { + Logger.INFO("Trying to clear Tile's tank. - Behaviour Class. [2]"); + return setStoredFluidOfGTMachine((GT_MetaTileEntity_BasicTank) aMetaTileEntity, aSetFluid); + } else { + return false; + } + } + + public boolean setStoredFluidOfGTMachine(GT_MetaTileEntity_BasicTank aTileEntity, FluidStack aSetFluid) { + try { + + // Try Handle Outputs First + /* + * if (aTileEntity.setDrainableStack(aSetFluid) != null) { return true; } + */ + + aTileEntity.mFluid = aSetFluid; + boolean b = aTileEntity.mFluid == aSetFluid; + Logger.INFO("Trying to set Tile's tank. - Behaviour Class. [3] " + b); + return b; + } catch (Throwable t) { + Logger.INFO("Trying to clear Tile's tank. FAILED - Behaviour Class. [x]"); + return false; + } + } + + public int getCorrectMetaForItemstack(ItemStack aStack) { + if (aStack == null) { + return 0; + } else { + if (aStack.getItemDamage() < this.mOffset) { + return 0; + } else { + int newMeta = aStack.getItemDamage() - this.mOffset; + newMeta = (Math.max(0, Math.min(3, newMeta))); + return newMeta; + } + } + } } diff --git a/src/main/java/gtPlusPlus/core/item/tool/misc/SandstoneHammer.java b/src/main/java/gtPlusPlus/core/item/tool/misc/SandstoneHammer.java index 555fc0f23f..3f4a754ab8 100644 --- a/src/main/java/gtPlusPlus/core/item/tool/misc/SandstoneHammer.java +++ b/src/main/java/gtPlusPlus/core/item/tool/misc/SandstoneHammer.java @@ -1,80 +1,71 @@ package gtPlusPlus.core.item.tool.misc; -import java.util.List; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.core.item.base.BaseItemWithDamageValue; +import gtPlusPlus.core.lib.CORE; +import java.util.List; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; -import gtPlusPlus.core.item.base.BaseItemWithDamageValue; -import gtPlusPlus.core.lib.CORE; - -public class SandstoneHammer extends BaseItemWithDamageValue{ - - /* (non-Javadoc) - * @see net.minecraft.item.Item#getColorFromItemStack(net.minecraft.item.ItemStack, int) - */ - @Override - public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { - //Figure Out Damage - - - return super.getColorFromItemStack(stack, HEX_OxFFFFFF); - } - - public SandstoneHammer(final String unlocalizedName) { - super(unlocalizedName); - this.setTextureName(CORE.MODID + ":" + unlocalizedName); - this.setMaxStackSize(1); - this.setMaxDamage(2500); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - list.add(EnumChatFormatting.GRAY+"Allows you to craft sand from cobble, or sandstone from sand."); - super.addInformation(stack, aPlayer, list, bool); - } - - @Override - public boolean doesContainerItemLeaveCraftingGrid(final ItemStack itemStack) - { - return false; - } - - @Override - public boolean getShareTag() - { - return true; - } - - @Override - public boolean hasContainerItem(final ItemStack itemStack) - { - return true; - } - @Override - public ItemStack getContainerItem(final ItemStack itemStack) - { - itemStack.setItemDamage(itemStack.getItemDamage() + 8); - - return itemStack; - } - - @Override - @SideOnly(Side.CLIENT) - public EnumRarity getRarity(final ItemStack par1ItemStack){ - return EnumRarity.uncommon; - } - - @Override - public boolean hasEffect(final ItemStack par1ItemStack){ - return false; - } - - +public class SandstoneHammer extends BaseItemWithDamageValue { + + /* (non-Javadoc) + * @see net.minecraft.item.Item#getColorFromItemStack(net.minecraft.item.ItemStack, int) + */ + @Override + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + // Figure Out Damage + + return super.getColorFromItemStack(stack, HEX_OxFFFFFF); + } + + public SandstoneHammer(final String unlocalizedName) { + super(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setMaxStackSize(1); + this.setMaxDamage(2500); + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add(EnumChatFormatting.GRAY + "Allows you to craft sand from cobble, or sandstone from sand."); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public boolean doesContainerItemLeaveCraftingGrid(final ItemStack itemStack) { + return false; + } + + @Override + public boolean getShareTag() { + return true; + } + + @Override + public boolean hasContainerItem(final ItemStack itemStack) { + return true; + } + + @Override + public ItemStack getContainerItem(final ItemStack itemStack) { + itemStack.setItemDamage(itemStack.getItemDamage() + 8); + + return itemStack; + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(final ItemStack par1ItemStack) { + return EnumRarity.uncommon; + } + + @Override + public boolean hasEffect(final ItemStack par1ItemStack) { + return false; + } } diff --git a/src/main/java/gtPlusPlus/core/item/tool/misc/box/AutoLunchBox.java b/src/main/java/gtPlusPlus/core/item/tool/misc/box/AutoLunchBox.java index baed16db03..7f4e971e5a 100644 --- a/src/main/java/gtPlusPlus/core/item/tool/misc/box/AutoLunchBox.java +++ b/src/main/java/gtPlusPlus/core/item/tool/misc/box/AutoLunchBox.java @@ -2,10 +2,16 @@ package gtPlusPlus.core.item.tool.misc.box; public class AutoLunchBox extends BaseBoxItem { - public final static int SLOTS = 9; - - public AutoLunchBox(String displayName) { - super(displayName, new String[] {"Stores 9 pieces of food", "Food will automatically be eaten from slot 1, through to "+gtPlusPlus.core.item.tool.misc.box.AutoLunchBox.SLOTS}, gtPlusPlus.core.item.tool.misc.box.AutoLunchBox.SLOTS); - } + public static final int SLOTS = 9; + public AutoLunchBox(String displayName) { + super( + displayName, + new String[] { + "Stores 9 pieces of food", + "Food will automatically be eaten from slot 1, through to " + + gtPlusPlus.core.item.tool.misc.box.AutoLunchBox.SLOTS + }, + gtPlusPlus.core.item.tool.misc.box.AutoLunchBox.SLOTS); + } } diff --git a/src/main/java/gtPlusPlus/core/item/tool/misc/box/BaseBoxItem.java b/src/main/java/gtPlusPlus/core/item/tool/misc/box/BaseBoxItem.java index 10a3ae5804..40fd5dfc7d 100644 --- a/src/main/java/gtPlusPlus/core/item/tool/misc/box/BaseBoxItem.java +++ b/src/main/java/gtPlusPlus/core/item/tool/misc/box/BaseBoxItem.java @@ -16,44 +16,54 @@ import net.minecraft.world.World; public class BaseBoxItem extends CoreItem { - private final int GUI; - - public BaseBoxItem(String displayName, String[] description, int GUI_ID) { - super("item." + Utils.sanitizeString(displayName), displayName, AddToCreativeTab.tabTools, 1, 0, - modifyDescriptionStringArray(description), EnumRarity.uncommon, EnumChatFormatting.GRAY, false, null); - GUI = GUI_ID; - } - - private static String[] modifyDescriptionStringArray(String[] array) { - String[] a = new String[array.length + 1]; - for (int b = 0; b < array.length; b++) { - a[b] = array[b]; - } - a[a.length - 1] = "Right Click to open"; - return a; - } - - // Without this method, your inventory will NOT work!!! - @Override - public int getMaxItemUseDuration(ItemStack stack) { - return 1; // return any value greater than zero - } - - @Override - public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) { - if (!world.isRemote) { - // If player not sneaking, open the inventory gui - if (!player.isSneaking()) { - player.openGui(GTplusplus.instance, GUI, world, (int) player.posX, (int) player.posY, - (int) player.posZ); - } - } - return itemstack; - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister iconRegister) { - this.itemIcon = iconRegister.registerIcon(CORE.MODID + ":" + this.getUnlocalizedName().substring(5)); - } + private final int GUI; + + public BaseBoxItem(String displayName, String[] description, int GUI_ID) { + super( + "item." + Utils.sanitizeString(displayName), + displayName, + AddToCreativeTab.tabTools, + 1, + 0, + modifyDescriptionStringArray(description), + EnumRarity.uncommon, + EnumChatFormatting.GRAY, + false, + null); + GUI = GUI_ID; + } + + private static String[] modifyDescriptionStringArray(String[] array) { + String[] a = new String[array.length + 1]; + for (int b = 0; b < array.length; b++) { + a[b] = array[b]; + } + a[a.length - 1] = "Right Click to open"; + return a; + } + + // Without this method, your inventory will NOT work!!! + @Override + public int getMaxItemUseDuration(ItemStack stack) { + return 1; // return any value greater than zero + } + + @Override + public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) { + if (!world.isRemote) { + // If player not sneaking, open the inventory gui + if (!player.isSneaking()) { + player.openGui( + GTplusplus.instance, GUI, world, (int) player.posX, (int) player.posY, (int) player.posZ); + } + } + return itemstack; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + this.itemIcon = iconRegister.registerIcon( + CORE.MODID + ":" + this.getUnlocalizedName().substring(5)); + } } diff --git a/src/main/java/gtPlusPlus/core/item/tool/misc/box/ContainerBoxBase.java b/src/main/java/gtPlusPlus/core/item/tool/misc/box/ContainerBoxBase.java index 035859c388..242b659462 100644 --- a/src/main/java/gtPlusPlus/core/item/tool/misc/box/ContainerBoxBase.java +++ b/src/main/java/gtPlusPlus/core/item/tool/misc/box/ContainerBoxBase.java @@ -2,9 +2,6 @@ package gtPlusPlus.core.item.tool.misc.box; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; - -import gregtech.api.enums.Materials; -import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Fluid; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; @@ -14,315 +11,322 @@ import net.minecraft.item.ItemStack; public class ContainerBoxBase extends Container { - /* - * Finally, in your Container class, you will need to check if the currently - * opened inventory's uniqueID is equal to the itemstack's uniqueID in the - * method 'transferStackInSlot' as well as check if the itemstack is the - * currently equipped item in the method 'slotClick'. In both cases, you'll need - * to prevent the itemstack from being moved or it will cause bad things to - * happen. - */ - - /** - * Step 3: Create a custom Container for your Inventory - */ - - /* - * There's a LOT of code in this one, but read through all of the comments - * carefully and it should become clear what everything does. As a bonus, one of - * my previous tutorials is included within! - * "How to Properly Override Shift-Clicking" is here and better than ever! At - * least in my opinion. If you're like me, and you find no end of frustration - * trying to figure out which f-ing index you should use for which slots in your - * container when overriding transferStackInSlot, or if your following the - * original tutorial, then read on. - */ - - /** - * The Item Inventory for this Container, only needed if you want to reference - * isUseableByPlayer - */ - private final CustomBoxInventory inventory; - /** - * Using these will make transferStackInSlot easier to understand and implement - * INV_START is the index of the first slot in the Player's Inventory, so our - * CustomBoxInventory's number of slots (e.g. 5 slots is array indices 0-4, so - * start at 5) Notice how we don't have to remember how many slots we made? We - * can just use CustomBoxInventory.INV_SIZE and if we ever change it, the - * Container updates automatically. - */ - private final int INV_START, INV_END, HOTBAR_START, HOTBAR_END; - - // If you're planning to add armor slots, put those first like this: - // ARMOR_START = CustomBoxInventory.INV_SIZE, ARMOR_END = ARMOR_START+3, - // INV_START = ARMOR_END+1, and then carry on like above. - - private Slot generateSlot(final Constructor aClazz, final IInventory base, final int id, final int x, - final int y) { - Slot aSlot; - try { - aSlot = (Slot) aClazz.newInstance(base, id, x, y); - if (aSlot != null) { - return aSlot; - } - } catch (InstantiationException | IllegalAccessException | IllegalArgumentException - | InvocationTargetException e) { - e.printStackTrace(); - } - return null; - } - - public ContainerBoxBase(EntityPlayer par1Player, InventoryPlayer inventoryPlayer, - CustomBoxInventory CustomBoxInventory, Class aClazz, int aSlotCount) { - - INV_START = aSlotCount; - INV_END = INV_START + 26; - HOTBAR_START = INV_END + 1; - HOTBAR_END = HOTBAR_START + 8; - - this.inventory = CustomBoxInventory; - try { - - Constructor constructor; - constructor = aClazz.getConstructor(IInventory.class, int.class, int.class, int.class); - - int i; - - // ITEM INVENTORY - you'll need to adjust the slot locations to match your - // texture file - // I have them set vertically in columns of 4 to the right of the player model - for (i = 0; i < CustomBoxInventory.INV_SIZE; ++i) { - // You can make a custom Slot if you need different behavior, - // such as only certain item types can be put into this slot - // We made a custom slot to prevent our inventory-storing item - // from being stored within itself, but if you want to allow that and - // you followed my advice at the end of the above step, then you - // could get away with using the vanilla Slot class - this.addSlotToContainer(generateSlot(constructor, this.getInventoryObject(), i, - 80 + (18 * (int) (i / 4)), 8 + (18 * (i % 4)))); - } - - // If you want, you can add ARMOR SLOTS here as well, but you need to - // make a public version of SlotArmor. I won't be doing that in this tutorial. - /* - * for (i = 0; i < 4; ++i) { // These are the standard positions for survival - * inventory layout this.addSlotToContainer(new SlotArmor(this.player, - * inventoryPlayer, inventoryPlayer.getSizeInventory() - 1 - i, 8, 8 + i * 18, - * i)); } - */ - - // PLAYER INVENTORY - uses default locations for standard inventory texture file - for (i = 0; i < 3; ++i) { - for (int j = 0; j < 9; ++j) { - this.addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); - } - } - - // PLAYER ACTION BAR - uses default locations for standard action bar texture - // file - for (i = 0; i < 9; ++i) { - this.addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142)); - } - - } catch (NoSuchMethodException | SecurityException e) { - e.printStackTrace(); - } - } - - @Override - public boolean canInteractWith(EntityPlayer entityplayer) { - // be sure to return the inventory's isUseableByPlayer method - // if you defined special behavior there: - return getInventoryObject().isUseableByPlayer(entityplayer); - } - - /** - * Called when a player shift-clicks on a slot. You must override this or you - * will crash when someone does that. - */ - public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int index) { - ItemStack itemstack = null; - Slot slot = (Slot) this.inventorySlots.get(index); - - if (slot != null && slot.getHasStack()) { - ItemStack itemstack1 = slot.getStack(); - itemstack = itemstack1.copy(); - - // If item is in our custom Inventory or armor slot - if (index < INV_START) { - // try to place in player inventory / action bar - if (!this.mergeItemStack(itemstack1, INV_START, HOTBAR_END + 1, true)) { - return null; - } - - slot.onSlotChange(itemstack1, itemstack); - } - // Item is in inventory / hotbar, try to place in custom inventory or armor - // slots - else { - /* - * If your inventory only stores certain instances of Items, you can implement - * shift-clicking to your inventory like this: - * - * // Check that the item is the right type if (itemstack1.getItem() instanceof - * ItemCustom) { // Try to merge into your custom inventory slots // We use - * 'CustomBoxInventory.INV_SIZE' instead of INV_START just in case // you also - * add armor or other custom slots if (!this.mergeItemStack(itemstack1, 0, - * CustomBoxInventory.INV_SIZE, false)) { return null; } } // If you added armor - * slots, check them here as well: // Item being shift-clicked is armor - try to - * put in armor slot if (itemstack1.getItem() instanceof ItemArmor) { int type = - * ((ItemArmor) itemstack1.getItem()).armorType; if - * (!this.mergeItemStack(itemstack1, ARMOR_START + type, ARMOR_START + type + 1, - * false)) { return null; } } Otherwise, you have basically 2 choices: 1. - * shift-clicking between player inventory and custom inventory 2. - * shift-clicking between action bar and inventory - * - * Be sure to choose only ONE of the following implementations!!! - */ - /** - * Implementation number 1: Shift-click into your custom inventory - */ - if (index >= INV_START) { - // place in custom inventory - if (!this.mergeItemStack(itemstack1, 0, INV_START, false)) { - return null; - } - } - - /** - * Implementation number 2: Shift-click items between action bar and inventory - */ - // item is in player's inventory, but not in action bar - if (index >= INV_START && index < HOTBAR_START) { - // place in action bar - if (!this.mergeItemStack(itemstack1, HOTBAR_START, HOTBAR_END + 1, false)) { - return null; - } - } - // item in action bar - place in player inventory - else if (index >= HOTBAR_START && index < HOTBAR_END + 1) { - if (!this.mergeItemStack(itemstack1, INV_START, INV_END + 1, false)) { - return null; - } - } - } - - if (itemstack1.stackSize == 0) { - slot.putStack((ItemStack) null); - } else { - slot.onSlotChanged(); - } - - if (itemstack1.stackSize == itemstack.stackSize) { - return null; - } - - slot.onPickupFromSlot(par1EntityPlayer, itemstack1); - } - - return itemstack; - } - - /** - * You should override this method to prevent the player from moving the stack - * that opened the inventory, otherwise if the player moves it, the inventory - * will not be able to save properly - */ - @Override - public ItemStack slotClick(int slot, int button, int flag, EntityPlayer player) { - // this will prevent the player from interacting with the item that opened the - // inventory: - if (slot >= 0 && getSlot(slot) != null && getSlot(slot).getStack() == player.getHeldItem()) { - return null; - } - return super.slotClick(slot, button, flag, player); - } - - /* - * Special note: If your custom inventory's stack limit is 1 and you allow - * shift-clicking itemstacks into it, you will need to override mergeStackInSlot - * to avoid losing all the items but one in a stack when you shift-click. - */ - /** - * Vanilla mergeItemStack method doesn't correctly handle inventories whose max - * stack size is 1 when you shift-click into the inventory. This is a modified - * method I wrote to handle such cases. Note you only need it if your slot / - * inventory's max stack size is 1 - */ - @Override - protected boolean mergeItemStack(ItemStack stack, int start, int end, boolean backwards) { - boolean flag1 = false; - int k = (backwards ? end - 1 : start); - Slot slot; - ItemStack itemstack1; - - if (stack.isStackable()) { - while (stack.stackSize > 0 && (!backwards && k < end || backwards && k >= start)) { - slot = (Slot) inventorySlots.get(k); - itemstack1 = slot.getStack(); - - if (!slot.isItemValid(stack)) { - k += (backwards ? -1 : 1); - continue; - } - - if (itemstack1 != null && itemstack1.getItem() == stack.getItem() - && (!stack.getHasSubtypes() || stack.getItemDamage() == itemstack1.getItemDamage()) - && ItemStack.areItemStackTagsEqual(stack, itemstack1)) { - int l = itemstack1.stackSize + stack.stackSize; - - if (l <= stack.getMaxStackSize() && l <= slot.getSlotStackLimit()) { - stack.stackSize = 0; - itemstack1.stackSize = l; - getInventoryObject().markDirty(); - flag1 = true; - } else if (itemstack1.stackSize < stack.getMaxStackSize() && l < slot.getSlotStackLimit()) { - stack.stackSize -= stack.getMaxStackSize() - itemstack1.stackSize; - itemstack1.stackSize = stack.getMaxStackSize(); - getInventoryObject().markDirty(); - flag1 = true; - } - } - - k += (backwards ? -1 : 1); - } - } - if (stack.stackSize > 0) { - k = (backwards ? end - 1 : start); - while (!backwards && k < end || backwards && k >= start) { - slot = (Slot) inventorySlots.get(k); - itemstack1 = slot.getStack(); - - if (!slot.isItemValid(stack)) { - k += (backwards ? -1 : 1); - continue; - } - - if (itemstack1 == null) { - int l = stack.stackSize; - if (l <= slot.getSlotStackLimit()) { - slot.putStack(stack.copy()); - stack.stackSize = 0; - getInventoryObject().markDirty(); - flag1 = true; - break; - } else { - putStackInSlot(k, - new ItemStack(stack.getItem(), slot.getSlotStackLimit(), stack.getItemDamage())); - stack.stackSize -= slot.getSlotStackLimit(); - getInventoryObject().markDirty(); - flag1 = true; - } - } - - k += (backwards ? -1 : 1); - } - } - - return flag1; - } - - public CustomBoxInventory getInventoryObject() { - return inventory; - } -} \ No newline at end of file + /* + * Finally, in your Container class, you will need to check if the currently + * opened inventory's uniqueID is equal to the itemstack's uniqueID in the + * method 'transferStackInSlot' as well as check if the itemstack is the + * currently equipped item in the method 'slotClick'. In both cases, you'll need + * to prevent the itemstack from being moved or it will cause bad things to + * happen. + */ + + /** + * Step 3: Create a custom Container for your Inventory + */ + + /* + * There's a LOT of code in this one, but read through all of the comments + * carefully and it should become clear what everything does. As a bonus, one of + * my previous tutorials is included within! + * "How to Properly Override Shift-Clicking" is here and better than ever! At + * least in my opinion. If you're like me, and you find no end of frustration + * trying to figure out which f-ing index you should use for which slots in your + * container when overriding transferStackInSlot, or if your following the + * original tutorial, then read on. + */ + + /** + * The Item Inventory for this Container, only needed if you want to reference + * isUseableByPlayer + */ + private final CustomBoxInventory inventory; + /** + * Using these will make transferStackInSlot easier to understand and implement + * INV_START is the index of the first slot in the Player's Inventory, so our + * CustomBoxInventory's number of slots (e.g. 5 slots is array indices 0-4, so + * start at 5) Notice how we don't have to remember how many slots we made? We + * can just use CustomBoxInventory.INV_SIZE and if we ever change it, the + * Container updates automatically. + */ + private final int INV_START, INV_END, HOTBAR_START, HOTBAR_END; + + // If you're planning to add armor slots, put those first like this: + // ARMOR_START = CustomBoxInventory.INV_SIZE, ARMOR_END = ARMOR_START+3, + // INV_START = ARMOR_END+1, and then carry on like above. + + private Slot generateSlot( + final Constructor aClazz, final IInventory base, final int id, final int x, final int y) { + Slot aSlot; + try { + aSlot = (Slot) aClazz.newInstance(base, id, x, y); + if (aSlot != null) { + return aSlot; + } + } catch (InstantiationException + | IllegalAccessException + | IllegalArgumentException + | InvocationTargetException e) { + e.printStackTrace(); + } + return null; + } + + public ContainerBoxBase( + EntityPlayer par1Player, + InventoryPlayer inventoryPlayer, + CustomBoxInventory CustomBoxInventory, + Class aClazz, + int aSlotCount) { + + INV_START = aSlotCount; + INV_END = INV_START + 26; + HOTBAR_START = INV_END + 1; + HOTBAR_END = HOTBAR_START + 8; + + this.inventory = CustomBoxInventory; + try { + + Constructor constructor; + constructor = aClazz.getConstructor(IInventory.class, int.class, int.class, int.class); + + int i; + + // ITEM INVENTORY - you'll need to adjust the slot locations to match your + // texture file + // I have them set vertically in columns of 4 to the right of the player model + for (i = 0; i < CustomBoxInventory.INV_SIZE; ++i) { + // You can make a custom Slot if you need different behavior, + // such as only certain item types can be put into this slot + // We made a custom slot to prevent our inventory-storing item + // from being stored within itself, but if you want to allow that and + // you followed my advice at the end of the above step, then you + // could get away with using the vanilla Slot class + this.addSlotToContainer(generateSlot( + constructor, this.getInventoryObject(), i, 80 + (18 * (int) (i / 4)), 8 + (18 * (i % 4)))); + } + + // If you want, you can add ARMOR SLOTS here as well, but you need to + // make a public version of SlotArmor. I won't be doing that in this tutorial. + /* + * for (i = 0; i < 4; ++i) { // These are the standard positions for survival + * inventory layout this.addSlotToContainer(new SlotArmor(this.player, + * inventoryPlayer, inventoryPlayer.getSizeInventory() - 1 - i, 8, 8 + i * 18, + * i)); } + */ + + // PLAYER INVENTORY - uses default locations for standard inventory texture file + for (i = 0; i < 3; ++i) { + for (int j = 0; j < 9; ++j) { + this.addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } + + // PLAYER ACTION BAR - uses default locations for standard action bar texture + // file + for (i = 0; i < 9; ++i) { + this.addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142)); + } + + } catch (NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + } + } + + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + // be sure to return the inventory's isUseableByPlayer method + // if you defined special behavior there: + return getInventoryObject().isUseableByPlayer(entityplayer); + } + + /** + * Called when a player shift-clicks on a slot. You must override this or you + * will crash when someone does that. + */ + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int index) { + ItemStack itemstack = null; + Slot slot = (Slot) this.inventorySlots.get(index); + + if (slot != null && slot.getHasStack()) { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + // If item is in our custom Inventory or armor slot + if (index < INV_START) { + // try to place in player inventory / action bar + if (!this.mergeItemStack(itemstack1, INV_START, HOTBAR_END + 1, true)) { + return null; + } + + slot.onSlotChange(itemstack1, itemstack); + } + // Item is in inventory / hotbar, try to place in custom inventory or armor + // slots + else { + /* + * If your inventory only stores certain instances of Items, you can implement + * shift-clicking to your inventory like this: + * + * // Check that the item is the right type if (itemstack1.getItem() instanceof + * ItemCustom) { // Try to merge into your custom inventory slots // We use + * 'CustomBoxInventory.INV_SIZE' instead of INV_START just in case // you also + * add armor or other custom slots if (!this.mergeItemStack(itemstack1, 0, + * CustomBoxInventory.INV_SIZE, false)) { return null; } } // If you added armor + * slots, check them here as well: // Item being shift-clicked is armor - try to + * put in armor slot if (itemstack1.getItem() instanceof ItemArmor) { int type = + * ((ItemArmor) itemstack1.getItem()).armorType; if + * (!this.mergeItemStack(itemstack1, ARMOR_START + type, ARMOR_START + type + 1, + * false)) { return null; } } Otherwise, you have basically 2 choices: 1. + * shift-clicking between player inventory and custom inventory 2. + * shift-clicking between action bar and inventory + * + * Be sure to choose only ONE of the following implementations!!! + */ + /** + * Implementation number 1: Shift-click into your custom inventory + */ + if (index >= INV_START) { + // place in custom inventory + if (!this.mergeItemStack(itemstack1, 0, INV_START, false)) { + return null; + } + } + + /** + * Implementation number 2: Shift-click items between action bar and inventory + */ + // item is in player's inventory, but not in action bar + if (index >= INV_START && index < HOTBAR_START) { + // place in action bar + if (!this.mergeItemStack(itemstack1, HOTBAR_START, HOTBAR_END + 1, false)) { + return null; + } + } + // item in action bar - place in player inventory + else if (index >= HOTBAR_START && index < HOTBAR_END + 1) { + if (!this.mergeItemStack(itemstack1, INV_START, INV_END + 1, false)) { + return null; + } + } + } + + if (itemstack1.stackSize == 0) { + slot.putStack((ItemStack) null); + } else { + slot.onSlotChanged(); + } + + if (itemstack1.stackSize == itemstack.stackSize) { + return null; + } + + slot.onPickupFromSlot(par1EntityPlayer, itemstack1); + } + + return itemstack; + } + + /** + * You should override this method to prevent the player from moving the stack + * that opened the inventory, otherwise if the player moves it, the inventory + * will not be able to save properly + */ + @Override + public ItemStack slotClick(int slot, int button, int flag, EntityPlayer player) { + // this will prevent the player from interacting with the item that opened the + // inventory: + if (slot >= 0 && getSlot(slot) != null && getSlot(slot).getStack() == player.getHeldItem()) { + return null; + } + return super.slotClick(slot, button, flag, player); + } + + /* + * Special note: If your custom inventory's stack limit is 1 and you allow + * shift-clicking itemstacks into it, you will need to override mergeStackInSlot + * to avoid losing all the items but one in a stack when you shift-click. + */ + /** + * Vanilla mergeItemStack method doesn't correctly handle inventories whose max + * stack size is 1 when you shift-click into the inventory. This is a modified + * method I wrote to handle such cases. Note you only need it if your slot / + * inventory's max stack size is 1 + */ + @Override + protected boolean mergeItemStack(ItemStack stack, int start, int end, boolean backwards) { + boolean flag1 = false; + int k = (backwards ? end - 1 : start); + Slot slot; + ItemStack itemstack1; + + if (stack.isStackable()) { + while (stack.stackSize > 0 && (!backwards && k < end || backwards && k >= start)) { + slot = (Slot) inventorySlots.get(k); + itemstack1 = slot.getStack(); + + if (!slot.isItemValid(stack)) { + k += (backwards ? -1 : 1); + continue; + } + + if (itemstack1 != null + && itemstack1.getItem() == stack.getItem() + && (!stack.getHasSubtypes() || stack.getItemDamage() == itemstack1.getItemDamage()) + && ItemStack.areItemStackTagsEqual(stack, itemstack1)) { + int l = itemstack1.stackSize + stack.stackSize; + + if (l <= stack.getMaxStackSize() && l <= slot.getSlotStackLimit()) { + stack.stackSize = 0; + itemstack1.stackSize = l; + getInventoryObject().markDirty(); + flag1 = true; + } else if (itemstack1.stackSize < stack.getMaxStackSize() && l < slot.getSlotStackLimit()) { + stack.stackSize -= stack.getMaxStackSize() - itemstack1.stackSize; + itemstack1.stackSize = stack.getMaxStackSize(); + getInventoryObject().markDirty(); + flag1 = true; + } + } + + k += (backwards ? -1 : 1); + } + } + if (stack.stackSize > 0) { + k = (backwards ? end - 1 : start); + while (!backwards && k < end || backwards && k >= start) { + slot = (Slot) inventorySlots.get(k); + itemstack1 = slot.getStack(); + + if (!slot.isItemValid(stack)) { + k += (backwards ? -1 : 1); + continue; + } + + if (itemstack1 == null) { + int l = stack.stackSize; + if (l <= slot.getSlotStackLimit()) { + slot.putStack(stack.copy()); + stack.stackSize = 0; + getInventoryObject().markDirty(); + flag1 = true; + break; + } else { + putStackInSlot( + k, new ItemStack(stack.getItem(), slot.getSlotStackLimit(), stack.getItemDamage())); + stack.stackSize -= slot.getSlotStackLimit(); + getInventoryObject().markDirty(); + flag1 = true; + } + } + + k += (backwards ? -1 : 1); + } + } + + return flag1; + } + + public CustomBoxInventory getInventoryObject() { + return inventory; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/tool/misc/box/CustomBoxInventory.java b/src/main/java/gtPlusPlus/core/item/tool/misc/box/CustomBoxInventory.java index 0737e463d8..ed5ebb41e3 100644 --- a/src/main/java/gtPlusPlus/core/item/tool/misc/box/CustomBoxInventory.java +++ b/src/main/java/gtPlusPlus/core/item/tool/misc/box/CustomBoxInventory.java @@ -1,7 +1,6 @@ package gtPlusPlus.core.item.tool.misc.box; import java.util.UUID; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -11,233 +10,207 @@ import net.minecraftforge.common.util.Constants; public abstract class CustomBoxInventory implements IInventory { - private final String name; - protected String uniqueID; - - /** Provides NBT Tag Compound to reference */ - private final ItemStack invItem; - - /** Defining your inventory size this way is handy */ - public final int INV_SIZE; - - /** Inventory's size must be same as number of slots you add to the Container class */ - private ItemStack[] inventory; - - /** - * @param itemstack - the ItemStack to which this inventory belongs - */ - public CustomBoxInventory(ItemStack stack, String name2){ - this(stack, name2, 8); - } - - /** - * @param itemstack - the ItemStack to which this inventory belongs - */ - public CustomBoxInventory(ItemStack stack, String name2, int slots) - { - invItem = stack; - name = name2; - INV_SIZE = slots; - inventory = new ItemStack[INV_SIZE]; - - /** initialize variable within the constructor: */ - uniqueID = ""; - - if (!stack.hasTagCompound()) - { - stack.setTagCompound(new NBTTagCompound()); - // no tag compound means the itemstack does not yet have a UUID, so assign one: - uniqueID = UUID.randomUUID().toString(); - } - - /** When reading from NBT: */ - if ("".equals(uniqueID)) - { - // try to read unique ID from NBT - uniqueID = stack.getTagCompound().getString("uniqueID"); - // if it's still "", assign a new one: - if ("".equals(uniqueID)) - { - uniqueID = UUID.randomUUID().toString(); - } - } - - /** Writing to NBT: */ - // just add this line: - stack.getTagCompound().setString("uniqueID", this.uniqueID); - - // note that it's okay to use stack instead of invItem right there - // both reference the same memory location, so whatever you change using - // either reference will change in the other - - // Read the inventory contents from NBT - readFromNBT(stack.getTagCompound()); - } - - @Override - public int getSizeInventory() - { - return inventory.length; - } - - @Override - public ItemStack getStackInSlot(int slot) - { - return inventory[slot]; - } - - @Override - public ItemStack decrStackSize(int slot, int amount) - { - ItemStack stack = getStackInSlot(slot); - if(stack != null) - { - if(stack.stackSize > amount) - { - stack = stack.splitStack(amount); - // Don't forget this line or your inventory will not be saved! - markDirty(); - } - else - { - // this method also calls onInventoryChanged, so we don't need to call it again - setInventorySlotContents(slot, null); - } - } - return stack; - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) - { - ItemStack stack = getStackInSlot(slot); - setInventorySlotContents(slot, null); - return stack; - } - - @Override - public void setInventorySlotContents(int slot, ItemStack stack) - { - inventory[slot] = stack; - - if (stack != null && stack.stackSize > getInventoryStackLimit()) - { - stack.stackSize = getInventoryStackLimit(); - } - - // Don't forget this line or your inventory will not be saved! - markDirty(); - } - - // 1.7.2+ renamed to getInventoryName - @Override - public String getInventoryName() - { - return name; - } - - // 1.7.2+ renamed to hasCustomInventoryName - @Override - public boolean hasCustomInventoryName() - { - return name.length() > 0; - } - - @Override - public int getInventoryStackLimit() - { - return 64; - } - - /** - * This is the method that will handle saving the inventory contents, as it is called (or should be called!) - * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also - * let you change things in your inventory without ever opening a Gui, if you want. - */ - // 1.7.2+ renamed to markDirty - @Override - public void markDirty() - { - for (int i = 0; i < getSizeInventory(); ++i) - { - if (getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0) { - inventory[i] = null; - } - } - - // This line here does the work: - writeToNBT(invItem.getTagCompound()); - } - - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) - { - return true; - } - - // 1.7.2+ renamed to openInventory(EntityPlayer player) - @Override - public void openInventory() {} - - // 1.7.2+ renamed to closeInventory(EntityPlayer player) - @Override - public void closeInventory() {} - - /** - * This method doesn't seem to do what it claims to do, as - * items can still be left-clicked and placed in the inventory - * even when this returns false - */ - @Override - public abstract boolean isItemValidForSlot(int slot, ItemStack itemstack); - - /** - * A custom method to read our inventory from an ItemStack's NBT compound - */ - public void readFromNBT(NBTTagCompound compound) - { - // Gets the custom taglist we wrote to this compound, if any - // 1.7.2+ change to compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND); - NBTTagList items = compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND); - - for (int i = 0; i < items.tagCount(); ++i) - { - // 1.7.2+ change to items.getCompoundTagAt(i) - NBTTagCompound item = (NBTTagCompound) items.getCompoundTagAt(i); - int slot = item.getInteger("Slot"); - - // Just double-checking that the saved slot index is within our inventory array bounds - if (slot >= 0 && slot < getSizeInventory()) { - inventory[slot] = ItemStack.loadItemStackFromNBT(item); - } - } - } - - /** - * A custom method to write our inventory to an ItemStack's NBT compound - */ - public void writeToNBT(NBTTagCompound tagcompound) - { - // Create a new NBT Tag List to store itemstacks as NBT Tags - NBTTagList items = new NBTTagList(); - - for (int i = 0; i < getSizeInventory(); ++i) - { - // Only write stacks that contain items - if (getStackInSlot(i) != null) - { - // Make a new NBT Tag Compound to write the itemstack and slot index to - NBTTagCompound item = new NBTTagCompound(); - item.setInteger("Slot", i); - // Writes the itemstack in slot(i) to the Tag Compound we just made - getStackInSlot(i).writeToNBT(item); - - // add the tag compound to our tag list - items.appendTag(item); - } - } - // Add the TagList to the ItemStack's Tag Compound with the name "ItemInventory" - tagcompound.setTag("ItemInventory", items); - } - + private final String name; + protected String uniqueID; + + /** Provides NBT Tag Compound to reference */ + private final ItemStack invItem; + + /** Defining your inventory size this way is handy */ + public final int INV_SIZE; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory; + + /** + * @param itemstack - the ItemStack to which this inventory belongs + */ + public CustomBoxInventory(ItemStack stack, String name2) { + this(stack, name2, 8); + } + + /** + * @param itemstack - the ItemStack to which this inventory belongs + */ + public CustomBoxInventory(ItemStack stack, String name2, int slots) { + invItem = stack; + name = name2; + INV_SIZE = slots; + inventory = new ItemStack[INV_SIZE]; + + /** initialize variable within the constructor: */ + uniqueID = ""; + + if (!stack.hasTagCompound()) { + stack.setTagCompound(new NBTTagCompound()); + // no tag compound means the itemstack does not yet have a UUID, so assign one: + uniqueID = UUID.randomUUID().toString(); + } + + /** When reading from NBT: */ + if ("".equals(uniqueID)) { + // try to read unique ID from NBT + uniqueID = stack.getTagCompound().getString("uniqueID"); + // if it's still "", assign a new one: + if ("".equals(uniqueID)) { + uniqueID = UUID.randomUUID().toString(); + } + } + + /** Writing to NBT: */ + // just add this line: + stack.getTagCompound().setString("uniqueID", this.uniqueID); + + // note that it's okay to use stack instead of invItem right there + // both reference the same memory location, so whatever you change using + // either reference will change in the other + + // Read the inventory contents from NBT + readFromNBT(stack.getTagCompound()); + } + + @Override + public int getSizeInventory() { + return inventory.length; + } + + @Override + public ItemStack getStackInSlot(int slot) { + return inventory[slot]; + } + + @Override + public ItemStack decrStackSize(int slot, int amount) { + ItemStack stack = getStackInSlot(slot); + if (stack != null) { + if (stack.stackSize > amount) { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + markDirty(); + } else { + // this method also calls onInventoryChanged, so we don't need to call it again + setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) { + ItemStack stack = getStackInSlot(slot); + setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack) { + inventory[slot] = stack; + + if (stack != null && stack.stackSize > getInventoryStackLimit()) { + stack.stackSize = getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() { + return name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() { + return name.length() > 0; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + /** + * This is the method that will handle saving the inventory contents, as it is called (or should be called!) + * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also + * let you change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() { + for (int i = 0; i < getSizeInventory(); ++i) { + if (getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0) { + inventory[i] = null; + } + } + + // This line here does the work: + writeToNBT(invItem.getTagCompound()); + } + + @Override + public boolean isUseableByPlayer(EntityPlayer entityplayer) { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as + * items can still be left-clicked and placed in the inventory + * even when this returns false + */ + @Override + public abstract boolean isItemValidForSlot(int slot, ItemStack itemstack); + + /** + * A custom method to read our inventory from an ItemStack's NBT compound + */ + public void readFromNBT(NBTTagCompound compound) { + // Gets the custom taglist we wrote to this compound, if any + // 1.7.2+ change to compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND); + NBTTagList items = compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND); + + for (int i = 0; i < items.tagCount(); ++i) { + // 1.7.2+ change to items.getCompoundTagAt(i) + NBTTagCompound item = (NBTTagCompound) items.getCompoundTagAt(i); + int slot = item.getInteger("Slot"); + + // Just double-checking that the saved slot index is within our inventory array bounds + if (slot >= 0 && slot < getSizeInventory()) { + inventory[slot] = ItemStack.loadItemStackFromNBT(item); + } + } + } + + /** + * A custom method to write our inventory to an ItemStack's NBT compound + */ + public void writeToNBT(NBTTagCompound tagcompound) { + // Create a new NBT Tag List to store itemstacks as NBT Tags + NBTTagList items = new NBTTagList(); + + for (int i = 0; i < getSizeInventory(); ++i) { + // Only write stacks that contain items + if (getStackInSlot(i) != null) { + // Make a new NBT Tag Compound to write the itemstack and slot index to + NBTTagCompound item = new NBTTagCompound(); + item.setInteger("Slot", i); + // Writes the itemstack in slot(i) to the Tag Compound we just made + getStackInSlot(i).writeToNBT(item); + + // add the tag compound to our tag list + items.appendTag(item); + } + } + // Add the TagList to the ItemStack's Tag Compound with the name "ItemInventory" + tagcompound.setTag("ItemInventory", items); + } } diff --git a/src/main/java/gtPlusPlus/core/item/tool/misc/box/MagicToolBag.java b/src/main/java/gtPlusPlus/core/item/tool/misc/box/MagicToolBag.java index 65b884bd51..9c5258f515 100644 --- a/src/main/java/gtPlusPlus/core/item/tool/misc/box/MagicToolBag.java +++ b/src/main/java/gtPlusPlus/core/item/tool/misc/box/MagicToolBag.java @@ -2,10 +2,14 @@ package gtPlusPlus.core.item.tool.misc.box; public class MagicToolBag extends BaseBoxItem { - public final static int SLOTS = 24; + public static final int SLOTS = 24; - public MagicToolBag(String displayName) { - super(displayName, new String[] {"Can store magic tools from TC, BM, etc", "Please ask for additional mod support on Github"}, gtPlusPlus.core.item.tool.misc.box.MagicToolBag.SLOTS); - } - + public MagicToolBag(String displayName) { + super( + displayName, + new String[] { + "Can store magic tools from TC, BM, etc", "Please ask for additional mod support on Github" + }, + gtPlusPlus.core.item.tool.misc.box.MagicToolBag.SLOTS); + } } diff --git a/src/main/java/gtPlusPlus/core/item/tool/misc/box/UniversalToolBox.java b/src/main/java/gtPlusPlus/core/item/tool/misc/box/UniversalToolBox.java index 92b1382e01..6ddc51ec49 100644 --- a/src/main/java/gtPlusPlus/core/item/tool/misc/box/UniversalToolBox.java +++ b/src/main/java/gtPlusPlus/core/item/tool/misc/box/UniversalToolBox.java @@ -4,10 +4,15 @@ import gtPlusPlus.core.handler.GuiHandler; public class UniversalToolBox extends BaseBoxItem { - public final static int SLOTS = 16; - - public UniversalToolBox(String displayName) { - super(displayName, new String[] {"Can store tools from Gregtech, IC2, BC, Forestry", "Please ask for additional mod support on Github"}, GuiHandler.GUI10); - } - + public static final int SLOTS = 16; + + public UniversalToolBox(String displayName) { + super( + displayName, + new String[] { + "Can store tools from Gregtech, IC2, BC, Forestry", + "Please ask for additional mod support on Github" + }, + GuiHandler.GUI10); + } } diff --git a/src/main/java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java b/src/main/java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java index 2c2441064b..ad5fa11160 100644 --- a/src/main/java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java +++ b/src/main/java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java @@ -1,11 +1,17 @@ package gtPlusPlus.core.item.tool.staballoy; -import java.util.List; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.RecipeUtils; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.enchantment.Enchantment; @@ -15,297 +21,296 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.data.Pair; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.minecraft.RecipeUtils; +public class MultiPickaxeBase extends StaballoyPickaxe { + + /* (non-Javadoc) + * @see net.minecraft.item.Item#getDurabilityForDisplay(net.minecraft.item.ItemStack) + */ + @Override + public double getDurabilityForDisplay(final ItemStack stack) { + if (super.getDurabilityForDisplay(stack) > 0) { + return super.getDurabilityForDisplay(stack); + } + return 0; + } + + protected boolean canBreak = true; + protected final int colour; + protected final String materialName; + protected final String displayName; + public boolean isValid = true; + private final Pair enchantment; + + public MultiPickaxeBase( + final String unlocalizedName, + final ToolMaterial material, + final long materialDurability, + final int colour, + final Object enchant) { + super(Utils.sanitizeString(unlocalizedName), material); + this.setUnlocalizedName(Utils.sanitizeString(unlocalizedName)); + // this.setTextureName(CORE.MODID + ":" + "itemPickaxe"); + this.setTextureName("minecraft" + ":" + "iron_pickaxe"); + this.setMaxStackSize(1); + if ((materialDurability * 3) <= Integer.MAX_VALUE) { + this.setMaxDamage((int) (materialDurability * 3)); + } else { + this.setMaxDamage(Integer.MAX_VALUE); + this.canBreak = false; + } + this.colour = colour; + this.materialName = material.name(); + this.displayName = unlocalizedName; + this.setCreativeTab(AddToCreativeTab.tabTools); + this.miningLevel = material.getHarvestLevel(); + + if (enchant != null) { + if (enchant instanceof Pair) { + this.enchantment = (Pair) enchant; + } else { + this.enchantment = null; + } + } else { + this.enchantment = null; + } + + try { + this.isValid = this.addRecipe(); + } catch (final Throwable e) { + } + if ((colour != 0) && this.isValid && (materialDurability > 10000)) { + if (GameRegistry.findItem(CORE.MODID, Utils.sanitizeString(unlocalizedName)) == null) { + GameRegistry.registerItem(this, Utils.sanitizeString(unlocalizedName)); + } + } + } + + /* + * + * + * + * Methods + * + * + * + */ + + private boolean addRecipe() { + + final String cleanName = Utils.sanitizeString(this.materialName); + + final String plateDense = "plateDense" + cleanName; + final String plateDouble = "plateDouble" + cleanName; + final String rodLong = "stickLong" + cleanName; + final String toolHammer = "craftingToolHardHammer"; + final String toolWrench = "craftingToolWrench"; + final String toolFile = "craftingToolFile"; + final String toolScrewDriver = "craftingToolScrewdriver"; + + if (null == ItemUtils.getItemStackOfAmountFromOreDictNoBroken(rodLong, 1)) { + Logger.WARNING("stickLong of " + cleanName + " does not exist."); + return false; + } + if (null == ItemUtils.getItemStackOfAmountFromOreDictNoBroken(plateDense, 1)) { + Logger.WARNING("plateDense of " + cleanName + " does not exist."); + if (null != ItemUtils.getItemStackOfAmountFromOreDictNoBroken(plateDouble, 1)) { + Logger.WARNING("plateDouble of " + cleanName + " does exist. Using it instead."); + RecipeUtils.recipeBuilder( + plateDouble, + plateDouble, + plateDouble, + toolFile, + rodLong, + toolHammer, + toolWrench, + rodLong, + toolScrewDriver, + ItemUtils.getSimpleStack(this)); + + return true; + } + Logger.WARNING("plateDouble of " + cleanName + " does not exist."); + return false; + } + + RecipeUtils.recipeBuilder( + plateDense, + plateDense, + plateDense, + toolFile, + rodLong, + toolHammer, + toolWrench, + rodLong, + toolScrewDriver, + ItemUtils.getSimpleStack(this)); + + return true; + } + + public final String getMaterialName() { + return this.materialName; + } + + @Override + public String getItemStackDisplayName(final ItemStack iStack) { + return this.displayName; + } + + @Override + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + if (this.colour == 0) { + return MathUtils.generateSingularRandomHexValue(); + } + return this.colour; + } + + private float calculateDurabilityLoss(final World world, final int X, final int Y, final int Z) { + float bDurabilityLoss = 0; + Boolean correctTool = false; + float bHardness = 0; + if (!world.isRemote) { + try { + final Block removalist = world.getBlock(X, Y, Z); + // Utils.LOG_WARNING(removalist.toString()); + + bHardness = removalist.getBlockHardness(world, X, Y, Z) * 100; + Logger.INFO("Hardness: " + bHardness); + + bDurabilityLoss = 100; + // Utils.LOG_WARNING("Durability Loss: "+bDurabilityLoss); + + correctTool = this.canPickaxeBlock(removalist, world, new int[] {X, Y, Z}); + Logger.WARNING("" + correctTool); + + if (!correctTool) { + return 0; + } + + } catch (final NullPointerException e) { + + } + } + return bDurabilityLoss; + } + + // Should clear up blocks quicker if I chain it. + /*@Override + public void removeBlockAndDropAsItem(World world, int X, int Y, int Z, ItemStack heldItem){ + localWorld = world; + try { + Block block = world.getBlock(X, Y, Z); + float dur = calculateDurabilityLoss(world, X, Y, Z); + Utils.LOG_WARNING(block.toString()); + String removalTool = ""; + removalTool = block.getHarvestTool(1); + + if (removalTool.equals("pickaxe") || UtilsMining.getBlockType(block, world, new int[]{X,Y,Z}, miningLevel)){ + if (canPickaxeBlock(block, world, new int[]{X,Y,Z})){ + if((block != Blocks.bedrock) && (block.getBlockHardness(world, X, Y, Z) != -1) && (block.getBlockHardness(world, X, Y, Z) <= 100) && (block != Blocks.water) && (block != Blocks.lava)){ + + if (heldItem.getItemDamage() <= (heldItem.getMaxDamage()-dur)){ + + block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0); + world.setBlockToAir(X, Y, Z); + + } + else { + return; + } + + } + } + else { + Utils.LOG_WARNING("Incorrect Tool for mining this block."); + } + } + } catch (NullPointerException e){ + + } + }*/ + + @Override + public void damageItem(final ItemStack item, final int damage, final EntityPlayer localPlayer) { + if (this.canBreak) { + item.damageItem(damage, localPlayer); + } + } + + @Override + public void setItemDamage(final ItemStack item, final int damage) { + if (this.canBreak) { + item.setItemDamage(damage - 1); + } + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(final ItemStack par1ItemStack) { + return EnumRarity.uncommon; + } + + @Override + public boolean hasEffect(final ItemStack par1ItemStack) { + return false; + } -public class MultiPickaxeBase extends StaballoyPickaxe{ - - /* (non-Javadoc) - * @see net.minecraft.item.Item#getDurabilityForDisplay(net.minecraft.item.ItemStack) - */ - @Override - public double getDurabilityForDisplay(final ItemStack stack) { - if (super.getDurabilityForDisplay(stack) > 0){ - return super.getDurabilityForDisplay(stack);} - return 0; - } - - protected boolean canBreak = true; - protected final int colour; - protected final String materialName; - protected final String displayName; - public boolean isValid = true; - private final Pair enchantment; - - public MultiPickaxeBase(final String unlocalizedName, final ToolMaterial material, final long materialDurability, final int colour, final Object enchant) { - super(Utils.sanitizeString(unlocalizedName), material); - this.setUnlocalizedName(Utils.sanitizeString(unlocalizedName)); - //this.setTextureName(CORE.MODID + ":" + "itemPickaxe"); - this.setTextureName("minecraft"+":"+"iron_pickaxe"); - this.setMaxStackSize(1); - if ((materialDurability*3) <= Integer.MAX_VALUE){ - this.setMaxDamage((int) (materialDurability*3)); - } - else { - this.setMaxDamage(Integer.MAX_VALUE); - this.canBreak = false; - } - this.colour = colour; - this.materialName = material.name(); - this.displayName = unlocalizedName; - this.setCreativeTab(AddToCreativeTab.tabTools); - this.miningLevel = material.getHarvestLevel(); - - - - if (enchant != null){ - if (enchant instanceof Pair){ - this.enchantment = (Pair) enchant; - } - else { - this.enchantment = null; - } - } - else { - this.enchantment = null; - } - - try {this.isValid = this.addRecipe();} catch (final Throwable e){} - if ((colour != 0) && this.isValid && (materialDurability > 10000)){ - if (GameRegistry.findItem(CORE.MODID, Utils.sanitizeString(unlocalizedName)) == null){ - GameRegistry.registerItem(this, Utils.sanitizeString(unlocalizedName)); - } - } - - } - - /* - * - * - * - * Methods - * - * - * - */ - - private boolean addRecipe(){ - - final String cleanName = Utils.sanitizeString(this.materialName); - - final String plateDense = "plateDense"+cleanName; - final String plateDouble = "plateDouble"+cleanName; - final String rodLong = "stickLong"+cleanName; - final String toolHammer = "craftingToolHardHammer"; - final String toolWrench = "craftingToolWrench"; - final String toolFile = "craftingToolFile"; - final String toolScrewDriver = "craftingToolScrewdriver"; - - if (null == ItemUtils.getItemStackOfAmountFromOreDictNoBroken(rodLong, 1)){ - Logger.WARNING("stickLong of "+cleanName+" does not exist."); - return false; - } - if (null == ItemUtils.getItemStackOfAmountFromOreDictNoBroken(plateDense, 1)){ - Logger.WARNING("plateDense of "+cleanName+" does not exist."); - if (null != ItemUtils.getItemStackOfAmountFromOreDictNoBroken(plateDouble, 1)){ - Logger.WARNING("plateDouble of "+cleanName+" does exist. Using it instead."); - RecipeUtils.recipeBuilder( - plateDouble, plateDouble, plateDouble, - toolFile, rodLong, toolHammer, - toolWrench, rodLong, toolScrewDriver, - ItemUtils.getSimpleStack(this)); - - return true; - } - Logger.WARNING("plateDouble of "+cleanName+" does not exist."); - return false; - } - - RecipeUtils.recipeBuilder( - plateDense, plateDense, plateDense, - toolFile, rodLong, toolHammer, - toolWrench, rodLong, toolScrewDriver, - ItemUtils.getSimpleStack(this)); - - return true; - } - - public final String getMaterialName() { - return this.materialName; - } - - @Override - public String getItemStackDisplayName(final ItemStack iStack) { - return this.displayName; - } - - @Override - public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { - if (this.colour == 0){ - return MathUtils.generateSingularRandomHexValue(); - } - return this.colour; - - } - - private float calculateDurabilityLoss(final World world, final int X, final int Y, final int Z){ - float bDurabilityLoss = 0; - Boolean correctTool = false; - float bHardness = 0; - if (!world.isRemote){ - try { - final Block removalist = world.getBlock(X, Y, Z); - //Utils.LOG_WARNING(removalist.toString()); - - bHardness = removalist.getBlockHardness(world, X, Y, Z)*100; - Logger.INFO("Hardness: "+bHardness); - - bDurabilityLoss = 100; - //Utils.LOG_WARNING("Durability Loss: "+bDurabilityLoss); - - correctTool = this.canPickaxeBlock(removalist, world, new int[]{X,Y,Z}); - Logger.WARNING(""+correctTool); - - if (!correctTool){ - return 0; - } - - } catch (final NullPointerException e){ - - } - } - return bDurabilityLoss; - } - - //Should clear up blocks quicker if I chain it. - /*@Override - public void removeBlockAndDropAsItem(World world, int X, int Y, int Z, ItemStack heldItem){ - localWorld = world; - try { - Block block = world.getBlock(X, Y, Z); - float dur = calculateDurabilityLoss(world, X, Y, Z); - Utils.LOG_WARNING(block.toString()); - String removalTool = ""; - removalTool = block.getHarvestTool(1); - - if (removalTool.equals("pickaxe") || UtilsMining.getBlockType(block, world, new int[]{X,Y,Z}, miningLevel)){ - if (canPickaxeBlock(block, world, new int[]{X,Y,Z})){ - if((block != Blocks.bedrock) && (block.getBlockHardness(world, X, Y, Z) != -1) && (block.getBlockHardness(world, X, Y, Z) <= 100) && (block != Blocks.water) && (block != Blocks.lava)){ - - if (heldItem.getItemDamage() <= (heldItem.getMaxDamage()-dur)){ - - block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0); - world.setBlockToAir(X, Y, Z); - - } - else { - return; - } - - } - } - else { - Utils.LOG_WARNING("Incorrect Tool for mining this block."); - } - } - } catch (NullPointerException e){ - - } - }*/ - - @Override - public void damageItem(final ItemStack item, final int damage, final EntityPlayer localPlayer){ - if (this.canBreak){ - item.damageItem(damage, localPlayer); - } - } - - @Override - public void setItemDamage(final ItemStack item, final int damage){ - if (this.canBreak){ - item.setItemDamage(damage-1); - } - } - - - @Override - @SideOnly(Side.CLIENT) - public EnumRarity getRarity(final ItemStack par1ItemStack){ - return EnumRarity.uncommon; - } - - @Override - public boolean hasEffect(final ItemStack par1ItemStack){ - return false; - } - - @Override - public void onCreated(final ItemStack mThisItem, final World mWorld, final EntityPlayer mPlayer) { - Enchantment enchant = null; - int enchantmentLevel = 0; - final Pair Y = this.enchantment; - if (Y != null){ - if (Y.getKey() != null){ - enchant = (Enchantment) this.enchantment.getKey(); - } - if (Y.getValue() != null){ - enchantmentLevel = ((Integer) this.enchantment.getValue()).intValue(); - } - } - final ItemStack itemToEnchant = mThisItem; - if ((enchant != null) && (enchantmentLevel != 0) && (enchantmentLevel >= 1)){ - itemToEnchant.addEnchantment(enchant, enchantmentLevel); - } - super.onCreated(itemToEnchant, mWorld, mPlayer); - } - - @Override - public void getSubItems(final Item mItem, final CreativeTabs mCreativeTab, final List mList) { - Enchantment enchant = null; - int enchantmentLevel = 0; - final Pair Y = this.enchantment; - if (Y != null){ - if (Y.getKey() != null){ - enchant = (Enchantment) this.enchantment.getKey(); - } - if (Y.getValue() != null){ - enchantmentLevel = ((Integer) this.enchantment.getValue()).intValue(); - } - } - - final Item thisItem = mItem; - final ItemStack itemToEnchant = ItemUtils.getSimpleStack(thisItem); - if ((enchant != null) && (enchantmentLevel != 0) && (enchantmentLevel >= 1)){ - itemToEnchant.addEnchantment(enchant, enchantmentLevel); - mList.add(itemToEnchant); - } - else { - mList.add(new ItemStack(thisItem, 1, 0)); - } - - } - - - /** - * - * Time to Override Minecraft stupid mechanics, allowing unbreakable stuff. - * - */ + @Override + public void onCreated(final ItemStack mThisItem, final World mWorld, final EntityPlayer mPlayer) { + Enchantment enchant = null; + int enchantmentLevel = 0; + final Pair Y = this.enchantment; + if (Y != null) { + if (Y.getKey() != null) { + enchant = (Enchantment) this.enchantment.getKey(); + } + if (Y.getValue() != null) { + enchantmentLevel = ((Integer) this.enchantment.getValue()).intValue(); + } + } + final ItemStack itemToEnchant = mThisItem; + if ((enchant != null) && (enchantmentLevel != 0) && (enchantmentLevel >= 1)) { + itemToEnchant.addEnchantment(enchant, enchantmentLevel); + } + super.onCreated(itemToEnchant, mWorld, mPlayer); + } + + @Override + public void getSubItems(final Item mItem, final CreativeTabs mCreativeTab, final List mList) { + Enchantment enchant = null; + int enchantmentLevel = 0; + final Pair Y = this.enchantment; + if (Y != null) { + if (Y.getKey() != null) { + enchant = (Enchantment) this.enchantment.getKey(); + } + if (Y.getValue() != null) { + enchantmentLevel = ((Integer) this.enchantment.getValue()).intValue(); + } + } + + final Item thisItem = mItem; + final ItemStack itemToEnchant = ItemUtils.getSimpleStack(thisItem); + if ((enchant != null) && (enchantmentLevel != 0) && (enchantmentLevel >= 1)) { + itemToEnchant.addEnchantment(enchant, enchantmentLevel); + mList.add(itemToEnchant); + } else { + mList.add(new ItemStack(thisItem, 1, 0)); + } + } + /** + * + * Time to Override Minecraft stupid mechanics, allowing unbreakable stuff. + * + */ @Override - public boolean isDamageable(){ - if (this.getMaxDamage() > 0 && !this.hasSubtypes){ - if (this.canBreak){ - return true; - } + public boolean isDamageable() { + if (this.getMaxDamage() > 0 && !this.hasSubtypes) { + if (this.canBreak) { + return true; + } } return false; } - } diff --git a/src/main/java/gtPlusPlus/core/item/tool/staballoy/MultiSpadeBase.java b/src/main/java/gtPlusPlus/core/item/tool/staballoy/MultiSpadeBase.java index d01b400fab..53d3152d84 100644 --- a/src/main/java/gtPlusPlus/core/item/tool/staballoy/MultiSpadeBase.java +++ b/src/main/java/gtPlusPlus/core/item/tool/staballoy/MultiSpadeBase.java @@ -3,124 +3,135 @@ package gtPlusPlus.core.item.tool.staballoy; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; - import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.RecipeUtils; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemStack; -public class MultiSpadeBase extends StaballoySpade{ - - /* (non-Javadoc) - * @see net.minecraft.item.Item#getDurabilityForDisplay(net.minecraft.item.ItemStack) - */ - @Override - public double getDurabilityForDisplay(final ItemStack stack) { - if (super.getDurabilityForDisplay(stack) > 0){ - return super.getDurabilityForDisplay(stack);} - return 0; - } - - protected final int colour; - protected final String materialName; - protected final String displayName; - public boolean isValid = true; - - public MultiSpadeBase(final String unlocalizedName, final ToolMaterial material, final int materialDurability, final int colour) { - super(Utils.sanitizeString(unlocalizedName), material); - this.setUnlocalizedName(Utils.sanitizeString(unlocalizedName)); - //this.setTextureName(CORE.MODID + ":" + "itemShovel"); - this.setTextureName("minecraft"+":"+"iron_shovel"); - this.setMaxStackSize(1); - this.setMaxDamage(materialDurability*3); - this.colour = colour; - this.materialName = material.name(); - this.displayName = unlocalizedName; - this.setCreativeTab(AddToCreativeTab.tabTools); - try { - this.isValid = this.addRecipe(); - } - catch (final Throwable e){} - if ((colour != 0) && this.isValid){ - if (GameRegistry.findItem(CORE.MODID, Utils.sanitizeString(unlocalizedName)) == null) { - GameRegistry.registerItem(this, Utils.sanitizeString(unlocalizedName)); - } - } - } - - private boolean addRecipe(){ - final String cleanName = Utils.sanitizeString(this.materialName); - final String plateDense = "plateDense"+cleanName; - final String plateDouble = "plateDouble"+cleanName; - final String rodLong = "stickLong"+cleanName; - final String toolHammer = "craftingToolHardHammer"; - final String toolWrench = "craftingToolWrench"; - final String toolFile = "craftingToolFile"; - final String toolScrewDriver = "craftingToolScrewdriver"; - - if (null == ItemUtils.getItemStackOfAmountFromOreDictNoBroken(rodLong, 1)){ - return false; - } - if (null == ItemUtils.getItemStackOfAmountFromOreDictNoBroken(plateDense, 1)){ - if (null != ItemUtils.getItemStackOfAmountFromOreDictNoBroken(plateDouble, 1)){ - RecipeUtils.recipeBuilder( - toolFile, plateDouble, toolHammer, - null, rodLong, null, - toolWrench, rodLong, toolScrewDriver, - ItemUtils.getSimpleStack(this)); - - return true; - } - return false; - } - - RecipeUtils.recipeBuilder( - toolFile, plateDense, toolHammer, - null, rodLong, null, - toolWrench, rodLong, toolScrewDriver, - ItemUtils.getSimpleStack(this)); - - return true; - } - - public final String getMaterialName() { - return this.materialName; - } - - @Override - public String getItemStackDisplayName(final ItemStack iStack) { - return this.displayName; - /*String name; - if (getUnlocalizedName().toLowerCase().contains("wood")){ - name = "Wooden"; - } - else { - } - return "Big "+name+" Spade";*/ - } - - @Override - public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { - if (this.colour == 0){ - return MathUtils.generateSingularRandomHexValue(); - } - return this.colour; - } - - @Override - @SideOnly(Side.CLIENT) - public EnumRarity getRarity(final ItemStack par1ItemStack){ - return EnumRarity.uncommon; - } - - @Override - public boolean hasEffect(final ItemStack par1ItemStack){ - return false; - } - +public class MultiSpadeBase extends StaballoySpade { + + /* (non-Javadoc) + * @see net.minecraft.item.Item#getDurabilityForDisplay(net.minecraft.item.ItemStack) + */ + @Override + public double getDurabilityForDisplay(final ItemStack stack) { + if (super.getDurabilityForDisplay(stack) > 0) { + return super.getDurabilityForDisplay(stack); + } + return 0; + } + + protected final int colour; + protected final String materialName; + protected final String displayName; + public boolean isValid = true; + + public MultiSpadeBase( + final String unlocalizedName, final ToolMaterial material, final int materialDurability, final int colour) { + super(Utils.sanitizeString(unlocalizedName), material); + this.setUnlocalizedName(Utils.sanitizeString(unlocalizedName)); + // this.setTextureName(CORE.MODID + ":" + "itemShovel"); + this.setTextureName("minecraft" + ":" + "iron_shovel"); + this.setMaxStackSize(1); + this.setMaxDamage(materialDurability * 3); + this.colour = colour; + this.materialName = material.name(); + this.displayName = unlocalizedName; + this.setCreativeTab(AddToCreativeTab.tabTools); + try { + this.isValid = this.addRecipe(); + } catch (final Throwable e) { + } + if ((colour != 0) && this.isValid) { + if (GameRegistry.findItem(CORE.MODID, Utils.sanitizeString(unlocalizedName)) == null) { + GameRegistry.registerItem(this, Utils.sanitizeString(unlocalizedName)); + } + } + } + + private boolean addRecipe() { + final String cleanName = Utils.sanitizeString(this.materialName); + final String plateDense = "plateDense" + cleanName; + final String plateDouble = "plateDouble" + cleanName; + final String rodLong = "stickLong" + cleanName; + final String toolHammer = "craftingToolHardHammer"; + final String toolWrench = "craftingToolWrench"; + final String toolFile = "craftingToolFile"; + final String toolScrewDriver = "craftingToolScrewdriver"; + + if (null == ItemUtils.getItemStackOfAmountFromOreDictNoBroken(rodLong, 1)) { + return false; + } + if (null == ItemUtils.getItemStackOfAmountFromOreDictNoBroken(plateDense, 1)) { + if (null != ItemUtils.getItemStackOfAmountFromOreDictNoBroken(plateDouble, 1)) { + RecipeUtils.recipeBuilder( + toolFile, + plateDouble, + toolHammer, + null, + rodLong, + null, + toolWrench, + rodLong, + toolScrewDriver, + ItemUtils.getSimpleStack(this)); + + return true; + } + return false; + } + + RecipeUtils.recipeBuilder( + toolFile, + plateDense, + toolHammer, + null, + rodLong, + null, + toolWrench, + rodLong, + toolScrewDriver, + ItemUtils.getSimpleStack(this)); + + return true; + } + + public final String getMaterialName() { + return this.materialName; + } + + @Override + public String getItemStackDisplayName(final ItemStack iStack) { + return this.displayName; + /*String name; + if (getUnlocalizedName().toLowerCase().contains("wood")){ + name = "Wooden"; + } + else { + } + return "Big "+name+" Spade";*/ + } + + @Override + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + if (this.colour == 0) { + return MathUtils.generateSingularRandomHexValue(); + } + return this.colour; + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(final ItemStack par1ItemStack) { + return EnumRarity.uncommon; + } + + @Override + public boolean hasEffect(final ItemStack par1ItemStack) { + return false; + } } diff --git a/src/main/java/gtPlusPlus/core/item/tool/staballoy/StaballoyAxe.java b/src/main/java/gtPlusPlus/core/item/tool/staballoy/StaballoyAxe.java index 153a417d7b..ec1c08dad8 100644 --- a/src/main/java/gtPlusPlus/core/item/tool/staballoy/StaballoyAxe.java +++ b/src/main/java/gtPlusPlus/core/item/tool/staballoy/StaballoyAxe.java @@ -1,10 +1,9 @@ package gtPlusPlus.core.item.tool.staballoy; -import java.util.List; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.core.lib.CORE; +import java.util.List; import net.minecraft.block.*; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.EntityLivingBase; @@ -16,330 +15,359 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; -import gtPlusPlus.core.lib.CORE; - -public class StaballoyAxe extends ItemAxe{ - public String mat; - - public StaballoyAxe(final String unlocalizedName, final ToolMaterial material) { - super(material); - this.setUnlocalizedName(unlocalizedName); - this.setTextureName(CORE.MODID + ":" + unlocalizedName); - } +public class StaballoyAxe extends ItemAxe { + public String mat; - // EXPLODE TREE - byte[] tre= new byte[32000]; - byte unchecked=0; - byte needcheck=1; - byte ignore =2; - byte harvest =3; + public StaballoyAxe(final String unlocalizedName, final ToolMaterial material) { + super(material); + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + } - private boolean setcheck(final int x, final int y, final int z) { - if((x<0) || (x>19) || (z<0) || (z>19) || (y<0) || (y>79)) { - return false; - } - final int o=x+(z*20)+(y*400); - if (this.tre[o]==this.unchecked) { - this.tre[o]=this.needcheck; - } - return true; - } + // EXPLODE TREE + byte[] tre = new byte[32000]; + byte unchecked = 0; + byte needcheck = 1; + byte ignore = 2; + byte harvest = 3; - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - list.add(EnumChatFormatting.GOLD+"Fells entire trees in a single swipe!.."); - list.add(EnumChatFormatting.GRAY+"Ask Alkalus for new trees to be supported."); - super.addInformation(stack, aPlayer, list, bool); - } + private boolean setcheck(final int x, final int y, final int z) { + if ((x < 0) || (x > 19) || (z < 0) || (z > 19) || (y < 0) || (y > 79)) { + return false; + } + final int o = x + (z * 20) + (y * 400); + if (this.tre[o] == this.unchecked) { + this.tre[o] = this.needcheck; + } + return true; + } - public static boolean canIgnore(final Block bit){ - if (bit instanceof BlockAir) { - return true; - } - if (bit instanceof BlockGrass) { - return true; - } - if (bit instanceof BlockSand) { - return true; - } - if (bit instanceof BlockDirt) { - return true; - } - if (bit instanceof BlockCocoa) { - return true; - } - if (bit instanceof BlockVine) { - return true; - } - if (bit instanceof BlockMushroom) { - return true; - } - if (bit instanceof BlockSnow) { - return true; - } - if (bit instanceof BlockSnowBlock) { - return true; - } - if (bit instanceof BlockFlower) { - return true; - } - if (bit instanceof BlockTallGrass) { - return true; - } - if (bit instanceof BlockDoublePlant) { - return true; - } + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add(EnumChatFormatting.GOLD + "Fells entire trees in a single swipe!.."); + list.add(EnumChatFormatting.GRAY + "Ask Alkalus for new trees to be supported."); + super.addInformation(stack, aPlayer, list, bool); + } - //LoonTools.log("Found uncuttable "+bit.getClass().getSimpleName()); - return false; - } + public static boolean canIgnore(final Block bit) { + if (bit instanceof BlockAir) { + return true; + } + if (bit instanceof BlockGrass) { + return true; + } + if (bit instanceof BlockSand) { + return true; + } + if (bit instanceof BlockDirt) { + return true; + } + if (bit instanceof BlockCocoa) { + return true; + } + if (bit instanceof BlockVine) { + return true; + } + if (bit instanceof BlockMushroom) { + return true; + } + if (bit instanceof BlockSnow) { + return true; + } + if (bit instanceof BlockSnowBlock) { + return true; + } + if (bit instanceof BlockFlower) { + return true; + } + if (bit instanceof BlockTallGrass) { + return true; + } + if (bit instanceof BlockDoublePlant) { + return true; + } - private int check(final World par1World, final int x, final int y, final int z, final int xo, final int yo,final int zo) { - int f=0; - final int o=x+(z*20)+(y*400); - if (this.tre[o]==this.needcheck){ - this.tre[o]=this.ignore; - final Block bit = par1World.getBlock(x+xo, y+yo, z+zo); - if ((bit instanceof BlockLog)||(bit instanceof BlockLeavesBase)||(bit instanceof BlockHugeMushroom) || (bit.getUnlocalizedName().toLowerCase().contains("log")) || (bit.getUnlocalizedName().toLowerCase().contains("wood"))){ - f=1; - this.tre[o]=this.harvest; - //if (bit instanceof BlockLog){ - // LoonTools.log("^ Found log @ "+x+xo+" "+y+yo+" "+z+zo+" "); - //} - for(int xb=-1;xb<2;xb++) { - for(int yb=-1;yb<2;yb++) { - for(int zb=-1;zb<2;zb++) { - if (!this.setcheck(x+xb,y+yb,z+zb)) { - return 3; - } - } - } - } - }else{ - if (!canIgnore(bit)) { - return 2; - } - } - } - return f; - } + // LoonTools.log("Found uncuttable "+bit.getClass().getSimpleName()); + return false; + } - public int checkTree(final World par1World,final int xo,final int yo,final int zo){ - boolean f; - for (f=true;f==true;){ - f=false; - for (int y=0;y<80;y++) { - for(int z=0;z<20;z++) { - for(int x=0;x<20;x++){ - final int r=this.check(par1World,x,y,z,xo,yo,zo); - if (r==3) { - return 3; - } - if (r==2) { - return 2; - } - if (r==1) { - f=true; - } - } - } - } + private int check( + final World par1World, final int x, final int y, final int z, final int xo, final int yo, final int zo) { + int f = 0; + final int o = x + (z * 20) + (y * 400); + if (this.tre[o] == this.needcheck) { + this.tre[o] = this.ignore; + final Block bit = par1World.getBlock(x + xo, y + yo, z + zo); + if ((bit instanceof BlockLog) + || (bit instanceof BlockLeavesBase) + || (bit instanceof BlockHugeMushroom) + || (bit.getUnlocalizedName().toLowerCase().contains("log")) + || (bit.getUnlocalizedName().toLowerCase().contains("wood"))) { + f = 1; + this.tre[o] = this.harvest; + // if (bit instanceof BlockLog){ + // LoonTools.log("^ Found log @ "+x+xo+" "+y+yo+" "+z+zo+" "); + // } + for (int xb = -1; xb < 2; xb++) { + for (int yb = -1; yb < 2; yb++) { + for (int zb = -1; zb < 2; zb++) { + if (!this.setcheck(x + xb, y + yb, z + zb)) { + return 3; + } + } + } + } + } else { + if (!canIgnore(bit)) { + return 2; + } + } + } + return f; + } - for (int y=79;y>=0;y--) { - for(int z=19;z>=0;z--) { - for(int x=19;x>=0;x--){ - final int r=this.check(par1World,x,y,z,xo,yo,zo); - if (r==2) { - return 3; - } - //if (r==2) return 2; - if (r==1) { - f=true; - } - } - } - } - } - return 1; - } + public int checkTree(final World par1World, final int xo, final int yo, final int zo) { + boolean f; + for (f = true; f == true; ) { + f = false; + for (int y = 0; y < 80; y++) { + for (int z = 0; z < 20; z++) { + for (int x = 0; x < 20; x++) { + final int r = this.check(par1World, x, y, z, xo, yo, zo); + if (r == 3) { + return 3; + } + if (r == 2) { + return 2; + } + if (r == 1) { + f = true; + } + } + } + } - private int check2(final World par1World, final int x, final int y, final int z, final int xo, final int yo,final int zo) { - int f=0; - final int o=x+(z*20)+(y*400); - if (this.tre[o]==this.needcheck){ - this.tre[o]=this.ignore; - final Block bit = par1World.getBlock(x+xo, y+yo, z+zo); - if (bit instanceof BlockLog){ - f=1; - this.tre[o]=this.harvest; - //if (bit instanceof BlockLog){ - // LoonTools.log("^ Found log @ "+x+xo+" "+y+yo+" "+z+zo+" "); - //} - for(int xb=-1;xb<2;xb++) { - for(int yb=-1;yb<2;yb++) { - for(int zb=-1;zb<2;zb++) { - if (!this.setcheck(x+xb,y+yb,z+zb)) { - return 3; - } - } - } - } - }else if (bit instanceof BlockLeavesBase){ - }else{ - if (!canIgnore(bit)) { - return 2; - } - } - } - return f; - } + for (int y = 79; y >= 0; y--) { + for (int z = 19; z >= 0; z--) { + for (int x = 19; x >= 0; x--) { + final int r = this.check(par1World, x, y, z, xo, yo, zo); + if (r == 2) { + return 3; + } + // if (r==2) return 2; + if (r == 1) { + f = true; + } + } + } + } + } + return 1; + } - public int checkTree2(final World par1World,final int xo,final int yo,final int zo){ - boolean f; - for (f=true;f==true;){ - f=false; - for (int y=0;y<80;y++) { - for(int z=0;z<20;z++) { - for(int x=0;x<20;x++){ - final int r=this.check2(par1World,x,y,z,xo,yo,zo); - if (r==3) { - return 3; - } - if (r==2) { - return 2; - } - if (r==1) { - f=true; - } - } - } - } + private int check2( + final World par1World, final int x, final int y, final int z, final int xo, final int yo, final int zo) { + int f = 0; + final int o = x + (z * 20) + (y * 400); + if (this.tre[o] == this.needcheck) { + this.tre[o] = this.ignore; + final Block bit = par1World.getBlock(x + xo, y + yo, z + zo); + if (bit instanceof BlockLog) { + f = 1; + this.tre[o] = this.harvest; + // if (bit instanceof BlockLog){ + // LoonTools.log("^ Found log @ "+x+xo+" "+y+yo+" "+z+zo+" "); + // } + for (int xb = -1; xb < 2; xb++) { + for (int yb = -1; yb < 2; yb++) { + for (int zb = -1; zb < 2; zb++) { + if (!this.setcheck(x + xb, y + yb, z + zb)) { + return 3; + } + } + } + } + } else if (bit instanceof BlockLeavesBase) { + } else { + if (!canIgnore(bit)) { + return 2; + } + } + } + return f; + } - for (int y=79;y>=0;y--) { - for(int z=19;z>=0;z--) { - for(int x=19;x>=0;x--){ - final int r=this.check2(par1World,x,y,z,xo,yo,zo); - if (r==2) { - return 3; - } - //if (r==2) return 2; - if (r==1) { - f=true; - } - } - } - } - } - return 1; - } + public int checkTree2(final World par1World, final int xo, final int yo, final int zo) { + boolean f; + for (f = true; f == true; ) { + f = false; + for (int y = 0; y < 80; y++) { + for (int z = 0; z < 20; z++) { + for (int x = 0; x < 20; x++) { + final int r = this.check2(par1World, x, y, z, xo, yo, zo); + if (r == 3) { + return 3; + } + if (r == 2) { + return 2; + } + if (r == 1) { + f = true; + } + } + } + } - public void exploadTree(final World par1World,final int xo,final int yo,final int zo, final EntityPlayer plr){ - for (int y=0;y<80;y++) { - for(int z=0;z<20;z++) { - for(int x=0;x<20;x++){ - final int o=x+(z*20)+(y*400); - if (this.tre[o]==this.harvest){ - final Block bit = par1World.getBlock(x+xo, y+yo, z+zo); - final int met = par1World.getBlockMetadata(x+xo, y+yo, z+zo); + for (int y = 79; y >= 0; y--) { + for (int z = 19; z >= 0; z--) { + for (int x = 19; x >= 0; x--) { + final int r = this.check2(par1World, x, y, z, xo, yo, zo); + if (r == 2) { + return 3; + } + // if (r==2) return 2; + if (r == 1) { + f = true; + } + } + } + } + } + return 1; + } - if ((bit instanceof BlockLog)||(bit instanceof BlockLeavesBase) || (bit.getUnlocalizedName().toLowerCase().contains("log")) || (bit.getUnlocalizedName().toLowerCase().contains("wood"))){ - bit.harvestBlock(par1World, plr, x+xo, y+yo, z+zo,met); - par1World.setBlockToAir(x+xo, y+yo, z+zo); - } - } - } - } - } - } + public void exploadTree(final World par1World, final int xo, final int yo, final int zo, final EntityPlayer plr) { + for (int y = 0; y < 80; y++) { + for (int z = 0; z < 20; z++) { + for (int x = 0; x < 20; x++) { + final int o = x + (z * 20) + (y * 400); + if (this.tre[o] == this.harvest) { + final Block bit = par1World.getBlock(x + xo, y + yo, z + zo); + final int met = par1World.getBlockMetadata(x + xo, y + yo, z + zo); - private static void breakMushroom(final World wld, final Block bit, final EntityPlayer plr, final boolean silk, final int x, final int y, final int z, final int met) { - if (silk){ - final ItemStack stk = null; //TODO - /*if (bit==Blocks.brown_mushroom_block) stk = new ItemStack(LoonToolItems.brown_mushroom_block,1,met); - else if (bit==Blocks.red_mushroom_block) stk = new ItemStack(LoonToolItems.red_mushroom_block,1,met); - else stk = new ItemStack(bit,1,met);*/ - final EntityItem entityitem = new EntityItem(wld, x+0.5, y+0.5, z+0.5, stk); - entityitem.delayBeforeCanPickup = 10; - wld.spawnEntityInWorld(entityitem); - }else{ - bit.harvestBlock(wld, plr, x, y, z, met); - } - wld.setBlockToAir(x, y, z); - } + if ((bit instanceof BlockLog) + || (bit instanceof BlockLeavesBase) + || (bit.getUnlocalizedName().toLowerCase().contains("log")) + || (bit.getUnlocalizedName().toLowerCase().contains("wood"))) { + bit.harvestBlock(par1World, plr, x + xo, y + yo, z + zo, met); + par1World.setBlockToAir(x + xo, y + yo, z + zo); + } + } + } + } + } + } - public void exploadMushroom(final World par1World,final int xo,final int yo,final int zo, final EntityPlayer plr, final boolean silk){ - for (int y=0;y<80;y++) { - for(int z=0;z<20;z++) { - for(int x=0;x<20;x++){ - final int o=x+(z*20)+(y*400); - if (this.tre[o]==this.harvest){ - final Block bit = par1World.getBlock(x+xo, y+yo, z+zo); - final int met = par1World.getBlockMetadata(x+xo, y+yo, z+zo); - if (bit instanceof BlockHugeMushroom){ - breakMushroom(par1World, bit, plr, silk, x+xo, y+yo, z+zo,met); - }else{ - bit.harvestBlock(par1World, plr, x+xo, y+yo, z+zo,met); - par1World.setBlockToAir(x+xo, y+yo, z+zo); - } - } - } - } - } - } + private static void breakMushroom( + final World wld, + final Block bit, + final EntityPlayer plr, + final boolean silk, + final int x, + final int y, + final int z, + final int met) { + if (silk) { + final ItemStack stk = null; // TODO + /*if (bit==Blocks.brown_mushroom_block) stk = new ItemStack(LoonToolItems.brown_mushroom_block,1,met); + else if (bit==Blocks.red_mushroom_block) stk = new ItemStack(LoonToolItems.red_mushroom_block,1,met); + else stk = new ItemStack(bit,1,met);*/ + final EntityItem entityitem = new EntityItem(wld, x + 0.5, y + 0.5, z + 0.5, stk); + entityitem.delayBeforeCanPickup = 10; + wld.spawnEntityInWorld(entityitem); + } else { + bit.harvestBlock(wld, plr, x, y, z, met); + } + wld.setBlockToAir(x, y, z); + } + public void exploadMushroom( + final World par1World, + final int xo, + final int yo, + final int zo, + final EntityPlayer plr, + final boolean silk) { + for (int y = 0; y < 80; y++) { + for (int z = 0; z < 20; z++) { + for (int x = 0; x < 20; x++) { + final int o = x + (z * 20) + (y * 400); + if (this.tre[o] == this.harvest) { + final Block bit = par1World.getBlock(x + xo, y + yo, z + zo); + final int met = par1World.getBlockMetadata(x + xo, y + yo, z + zo); + if (bit instanceof BlockHugeMushroom) { + breakMushroom(par1World, bit, plr, silk, x + xo, y + yo, z + zo, met); + } else { + bit.harvestBlock(par1World, plr, x + xo, y + yo, z + zo, met); + par1World.setBlockToAir(x + xo, y + yo, z + zo); + } + } + } + } + } + } - @Override - public boolean onBlockDestroyed(final ItemStack itm, final World wld,final Block blk, final int x, final int y,final int z, final EntityLivingBase plr) { - if (!wld.isRemote){ - final Block bit = wld.getBlock(x, y, z); - final boolean silk=EnchantmentHelper.getSilkTouchModifier(plr); - if ((bit instanceof BlockHugeMushroom)){ - for (int n=0;n<32000;n++) { - this.tre[n]=this.unchecked; - } - final int met = wld.getBlockMetadata(x, y, z); - breakMushroom(wld, bit, (EntityPlayer) plr, silk, x, y, z,met); - wld.setBlockToAir(x,y,z); - this.tre[2210]=this.needcheck; - if (this.checkTree(wld,x-10,y-4,z-10)==1){ - this.exploadMushroom(wld,x-10,y-4,z-10,(EntityPlayer) plr,silk); - } - } + @Override + public boolean onBlockDestroyed( + final ItemStack itm, + final World wld, + final Block blk, + final int x, + final int y, + final int z, + final EntityLivingBase plr) { + if (!wld.isRemote) { + final Block bit = wld.getBlock(x, y, z); + final boolean silk = EnchantmentHelper.getSilkTouchModifier(plr); + if ((bit instanceof BlockHugeMushroom)) { + for (int n = 0; n < 32000; n++) { + this.tre[n] = this.unchecked; + } + final int met = wld.getBlockMetadata(x, y, z); + breakMushroom(wld, bit, (EntityPlayer) plr, silk, x, y, z, met); + wld.setBlockToAir(x, y, z); + this.tre[2210] = this.needcheck; + if (this.checkTree(wld, x - 10, y - 4, z - 10) == 1) { + this.exploadMushroom(wld, x - 10, y - 4, z - 10, (EntityPlayer) plr, silk); + } + } - if ((bit instanceof BlockLog) || (bit.getUnlocalizedName().toLowerCase().contains("log")) || (bit.getUnlocalizedName().toLowerCase().contains("wood"))){ - //LoonTools.log("cutting tree @ "+x+" "+y+" "+z+" "); - for (int n=0;n<32000;n++) { - this.tre[n]=this.unchecked; - } - final int met = wld.getBlockMetadata(x, y, z); - bit.harvestBlock(wld, (EntityPlayer) plr, x, y, z,met); - wld.setBlockToAir(x,y,z); - this.tre[2210]=this.needcheck; - if (this.checkTree(wld,x-10,y-4,z-10)==1){ - this.exploadTree(wld,x-10,y-4,z-10,(EntityPlayer) plr); - }else{ - for (int n=0;n<32000;n++) { - this.tre[n]=this.unchecked; - } - this.tre[2210]=this.needcheck; - if (this.checkTree2(wld,x-10,y-4,z-10)==1){ - this.exploadTree(wld,x-10,y-4,z-10,(EntityPlayer) plr); - } - } - } - } - return super.onBlockDestroyed(itm, wld, blk, x, y, z, plr); - } + if ((bit instanceof BlockLog) + || (bit.getUnlocalizedName().toLowerCase().contains("log")) + || (bit.getUnlocalizedName().toLowerCase().contains("wood"))) { + // LoonTools.log("cutting tree @ "+x+" "+y+" "+z+" "); + for (int n = 0; n < 32000; n++) { + this.tre[n] = this.unchecked; + } + final int met = wld.getBlockMetadata(x, y, z); + bit.harvestBlock(wld, (EntityPlayer) plr, x, y, z, met); + wld.setBlockToAir(x, y, z); + this.tre[2210] = this.needcheck; + if (this.checkTree(wld, x - 10, y - 4, z - 10) == 1) { + this.exploadTree(wld, x - 10, y - 4, z - 10, (EntityPlayer) plr); + } else { + for (int n = 0; n < 32000; n++) { + this.tre[n] = this.unchecked; + } + this.tre[2210] = this.needcheck; + if (this.checkTree2(wld, x - 10, y - 4, z - 10) == 1) { + this.exploadTree(wld, x - 10, y - 4, z - 10, (EntityPlayer) plr); + } + } + } + } + return super.onBlockDestroyed(itm, wld, blk, x, y, z, plr); + } - @Override - @SideOnly(Side.CLIENT) - public EnumRarity getRarity(final ItemStack par1ItemStack){ - return EnumRarity.rare; - } + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(final ItemStack par1ItemStack) { + return EnumRarity.rare; + } - @Override - public boolean hasEffect(final ItemStack par1ItemStack){ - return true; - } -} \ No newline at end of file + @Override + public boolean hasEffect(final ItemStack par1ItemStack) { + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java b/src/main/java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java index 830c4994ba..873d9a843c 100644 --- a/src/main/java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java +++ b/src/main/java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java @@ -1,10 +1,11 @@ package gtPlusPlus.core.item.tool.staballoy; -import java.util.List; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.MiningUtils; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -18,445 +19,440 @@ import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.MiningUtils; - -public class StaballoyPickaxe extends ItemPickaxe{ - - /* (non-Javadoc) - * @see net.minecraft.item.Item#getDurabilityForDisplay(net.minecraft.item.ItemStack) - */ - @Override - public double getDurabilityForDisplay(final ItemStack stack) { - return (double)stack.getItemDamageForDisplay() / (double)stack.getMaxDamage(); - } - - /** - * Creates an NBT tag for this item if it doesn't have one. - * This also set some default values. - * @param rStack - * @return - */ - - private static boolean createNBT(ItemStack rStack){ - final NBTTagCompound tagMain = new NBTTagCompound(); - final NBTTagCompound tagNBT = new NBTTagCompound(); - - tagNBT.setBoolean("FACING_HORIZONTAL", true); - tagNBT.setString("FACING", "north"); - tagNBT.setString("lookingDirection", ""); - - tagMain.setTag("PickStats", tagNBT); - rStack.setTagCompound(tagMain); - return true; - } - - /* - * Is the player facing horizontally? - */ - - public static final boolean isFacingHorizontal(final ItemStack aStack) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("PickStats"); - if (aNBT != null) { - return aNBT.getBoolean("FACING_HORIZONTAL"); - } - } - else { - createNBT(aStack); - } - return true; - } - - public static final boolean setFacingHorizontal(final ItemStack aStack, final boolean aFacingHorizontal) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("PickStats"); - if (aNBT != null) { - aNBT.setBoolean("FACING_HORIZONTAL", aFacingHorizontal); - return true; - } - } - return false; - } - - /* - * Handles the Direction the player is facing - */ - - public static final String getFacingDirection(final ItemStack aStack) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("PickStats"); - if (aNBT != null) { - return aNBT.getString("FACING"); - } - } - else { - createNBT(aStack); - } - return "north"; - } - - public static final boolean setFacingDirection(final ItemStack aStack, final String aFacingHorizontal) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("PickStats"); - if (aNBT != null) { - aNBT.setString("FACING", aFacingHorizontal); - return true; - } - } - return false; - } - - /* - * The Looking Direction handlers - */ - - public static final String getLookingDirection(final ItemStack aStack) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("PickStats"); - if (aNBT != null) { - return aNBT.getString("lookingDirection"); - } - } - else { - createNBT(aStack); - } - return ""; - } - - public static final boolean setLookingDirection(final ItemStack aStack, final String aFacingHorizontal) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("PickStats"); - if (aNBT != null) { - aNBT.setString("lookingDirection", aFacingHorizontal); - return true; - } - } - return false; - } - - protected int miningLevel; - - /* - * - * - * - * Methods - * - * - * - */ - - @Override - public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer aPlayer) { - return super.onItemRightClick(stack, world, aPlayer); - } - - - - @Override - public boolean onBlockDestroyed(final ItemStack stack, final World world, final Block block, final int X, final int Y, final int Z, final EntityLivingBase entity) { - if (!world.isRemote){ - if (entity instanceof EntityPlayer) { - this.GetDestroyOrientation((EntityPlayer) entity, block, getLookingDirection(stack), world, X, Y, Z, stack); - } - } - return super.onBlockDestroyed(stack, world, block, X, Y, Z, entity); - } - - private float calculateDurabilityLoss(final World world, final int X, final int Y, final int Z){ - float bDurabilityLoss = 0; - Boolean correctTool = false; - float bHardness = 0; - if (!world.isRemote){ - try { - final Block removalist = world.getBlock(X, Y, Z); - //Utils.LOG_WARNING(removalist.toString()); - - bHardness = removalist.getBlockHardness(world, X, Y, Z); - Logger.WARNING("Hardness: "+bHardness); - - bDurabilityLoss = (bDurabilityLoss + bHardness); - //Utils.LOG_WARNING("Durability Loss: "+bDurabilityLoss); - - correctTool = this.canPickaxeBlock(removalist, world, new int[]{X,Y,Z}); - Logger.WARNING(""+correctTool); - - if (!correctTool){ - return 0; - } - - } catch (final NullPointerException e){ - - } - } - return 100; - } - - public Boolean canPickaxeBlock(final Block currentBlock, final World currentWorld, final int[] xyz){ - String correctTool = ""; - if (!currentWorld.isRemote){ - try { - correctTool = currentBlock.getHarvestTool(0); - if (MiningUtils.getBlockType(currentBlock, currentWorld, xyz, this.miningLevel) || correctTool.equals("pickaxe") || correctTool.equals("null")){ - //Utils.LOG_WARNING(correctTool); - return true;} - } catch (final NullPointerException e){ - return false;} - } - return false; - } - - private void GetDestroyOrientation(EntityPlayer entity, final Block block, final String FACING, final World world, final int X, final int Y, final int Z, final ItemStack heldItem){ - float DURABILITY_LOSS = 0; - if (!world.isRemote){ - - Logger.WARNING("hardness:"+block.getBlockHardness(world, X, Y, Z)); - if (FACING.equals("below") || FACING.equals("above")){ - DURABILITY_LOSS = 0; - for(int i = -1; i < 2; i++) { - for(int j = -1; j < 2; j++) { - final float dur = this.calculateDurabilityLoss(world, X + i, Y, Z + j); - DURABILITY_LOSS = (DURABILITY_LOSS + dur); - Logger.WARNING("Added Loss: "+dur); - this.removeBlockAndDropAsItem(world, X + i, Y, Z + j, heldItem); - } - } - } - - else if (FACING.equals("facingEast") || FACING.equals("facingWest")){ - DURABILITY_LOSS = 0; - for(int i = -1; i < 2; i++) { - for(int j = -1; j < 2; j++) { - final float dur = this.calculateDurabilityLoss(world, X, Y + i, Z + j); - DURABILITY_LOSS = (DURABILITY_LOSS + dur); - Logger.WARNING("Added Loss: "+dur); - this.removeBlockAndDropAsItem(world, X , Y + i, Z + j, heldItem); - } - } - } - - else if (FACING.equals("facingNorth") || FACING.equals("facingSouth")){ - DURABILITY_LOSS = 0; - for(int i = -1; i < 2; i++) { - for(int j = -1; j < 2; j++) { - final float dur = this.calculateDurabilityLoss(world, X + j, Y + i, Z); - DURABILITY_LOSS = (DURABILITY_LOSS + dur); - Logger.WARNING("Added Loss: "+dur); - this.removeBlockAndDropAsItem(world, X + j, Y + i, Z, heldItem); - } - } - } - - //int heldItemDurability = heldItem.getDamage(1); - Logger.WARNING("Total Loss: "+(int)DURABILITY_LOSS); - //heldItem.setDamage(heldStack, DURABILITY_LOSS); - //Utils.LOG_WARNING("|GID|Durability: "+heldItem.getItemDamage()); - //Utils.LOG_WARNING("Durability: "+heldStack.getDamage(heldStack)); - Logger.WARNING("1x: "+(heldItem.getItemDamage())); - final int itemdmg = heldItem.getItemDamage(); - final int maxdmg = heldItem.getMaxDamage(); - final int dodmg = (int)DURABILITY_LOSS; - final int durNow = maxdmg-itemdmg; - final int durLeft = (int) ((maxdmg-itemdmg)-DURABILITY_LOSS); - - Logger.WARNING( - "Current Damage: " + itemdmg - + " Max Damage: " + maxdmg - + " Durability to be lost: " + dodmg - + " Current Durability: " + durNow - + " Remaining Durability: " + durLeft - ); - - - //Break Tool - if (((durNow-dodmg) <= (99)) && (itemdmg != 0)){ - //TODO break tool - Logger.WARNING("Breaking Tool"); - heldItem.stackSize = 0; - } - //Do Damage - else { - //setItemDamage(heldItem, durLeft); - Logger.WARNING(""+(durNow-durLeft)); - this.damageItem(heldItem, (durNow-durLeft)-1, entity); - } - - - /*if (heldItem.getItemDamage() <= ((heldItem.getMaxDamage()-heldItem.getItemDamage())-DURABILITY_LOSS)){ - Utils.LOG_WARNING("2: "+DURABILITY_LOSS+" 3: "+((heldItem.getMaxDamage()-heldItem.getItemDamage())-DURABILITY_LOSS)); - setItemDamage(heldItem, (int) (heldItem.getMaxDamage()-(heldItem.getMaxDamage()-heldItem.getItemDamage())-DURABILITY_LOSS)); - } - else { - Utils.LOG_WARNING("3: "+( heldItem.getMaxDamage()-(heldItem.getMaxDamage()-heldItem.getItemDamage()))); - setItemDamage(heldItem, heldItem.getMaxDamage()-(heldItem.getMaxDamage()-heldItem.getItemDamage())); - }*/ - //Utils.LOG_WARNING("|GID|Durability: "+heldItem.getItemDamage()); - DURABILITY_LOSS = 0; - - } - } - - public void damageItem(final ItemStack item, final int damage, final EntityPlayer localPlayer){ - item.damageItem(damage, localPlayer); - } - - public void setItemDamage(final ItemStack item, final int damage){ - item.setItemDamage(damage-1); - } - - //Should clear up blocks quicker if I chain it. - public final void removeBlockAndDropAsItem(final World world, final int X, final int Y, final int Z, final ItemStack heldItem){ - try { - final Block block = world.getBlock(X, Y, Z); - final float dur = this.calculateDurabilityLoss(world, X, Y, Z); - Logger.WARNING(block.toString()); - String removalTool = ""; - removalTool = block.getHarvestTool(1); - - Logger.WARNING("Removing.1 "+removalTool); - /*if ((removalTool.equalsIgnoreCase("pickaxe") || removalTool.equalsIgnoreCase("null") || removalTool == null)){ - Utils.LOG_WARNING("Removing.2"); - if (UtilsMining.getBlockType(block, world, new int[]{X,Y,Z}, miningLevel)) { - Utils.LOG_WARNING("Removing.3"); */ - if (this.canPickaxeBlock(block, world, new int[]{X,Y,Z})){ - Logger.WARNING("Removing.4"); - - if (block == Blocks.air){ - return; - } - - if((block != Blocks.bedrock) && (block.getBlockHardness(world, X, Y, Z) >= 0) && (block.getBlockHardness(world, X, Y, Z) <= 100) && (block != Blocks.water) && (block != Blocks.lava)){ - - Logger.WARNING("Removing.5"); - if (heldItem.getItemDamage() <= (heldItem.getMaxDamage()-dur)){ - - if (X == 0 && Y == 0 && Z == 0){ - - } - else { - block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0); - world.setBlockToAir(X, Y, Z); - } - - } - - } - /*} - - }*/ - } - else { - Logger.WARNING("Incorrect Tool for mining this block."); - } - } catch (final NullPointerException e){ - - } - } - - public boolean checkFacing(final ItemStack aStack, final EntityPlayer aPlayer, final World world){ - if (aPlayer != null){ - final int direction = MathHelper.floor_double((aPlayer.rotationYaw * 4F) / 360F + 0.5D) & 3; - //Utils.LOG_WARNING("Player - F: "+direction); - //Utils.LOG_WARNING("Player - getLookVec(): "+localPlayer.getLookVec().yCoord); - - /*if (localPlayer.getLookVec().yCoord > 0){ - localPlayer.getLookVec().yCoord; - }*/ - - final MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, aPlayer, false); - if (movingobjectposition != null){ - final int sideHit = movingobjectposition.sideHit; - String playerStandingPosition = ""; - if (movingobjectposition != null) { - //System.out.println("Side Hit: "+movingobjectposition.sideHit); - } - - if (sideHit == 0){ - playerStandingPosition = "above"; - setFacingHorizontal(aStack, false); - } - else if (sideHit == 1){ - playerStandingPosition = "below"; - setFacingHorizontal(aStack, false); - } - else if (sideHit == 2){ - playerStandingPosition = "facingSouth"; - setFacingHorizontal(aStack, true); - } - else if (sideHit == 3){ - playerStandingPosition = "facingNorth"; - setFacingHorizontal(aStack, true); - } - else if (sideHit == 4){ - playerStandingPosition = "facingEast"; - setFacingHorizontal(aStack, true); - } - else if (sideHit == 5){ - playerStandingPosition = "facingWest"; - setFacingHorizontal(aStack, true); - } - setLookingDirection(aStack, playerStandingPosition); - - if (direction == 0){ - setFacingDirection(aStack, "south"); - } - else if (direction == 1){ - setFacingDirection(aStack, "west"); - } - else if (direction == 2){ - setFacingDirection(aStack, "north"); - } - else if (direction == 3){ - setFacingDirection(aStack, "east"); - } - } - - - return true; - } - return false; - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - list.add(EnumChatFormatting.GRAY+"Mines a 3x3 at 100 durability per block mined."); - list.add(EnumChatFormatting.GRAY+"Durability: "+(stack.getMaxDamage()-stack.getItemDamage())+"/"+stack.getMaxDamage()); - //super.addInformation(stack, aPlayer, list, bool); - } - - @Override - @SideOnly(Side.CLIENT) - public EnumRarity getRarity(final ItemStack par1ItemStack){ - return EnumRarity.rare; - } - - @Override - public boolean hasEffect(final ItemStack par1ItemStack){ - return true; - } - - - @Override - public boolean onBlockStartBreak(final ItemStack itemstack, final int X, final int Y, final int Z, final EntityPlayer aPlayer) { - this.checkFacing(itemstack, aPlayer, aPlayer.getEntityWorld()); - return super.onBlockStartBreak(itemstack, X, Y, Z, aPlayer); - } - - public StaballoyPickaxe(final String unlocalizedName, final ToolMaterial material) { - super(material); - this.setUnlocalizedName(unlocalizedName); - this.setTextureName(CORE.MODID + ":" + unlocalizedName); - this.setMaxStackSize(1); - this.setMaxDamage(3200); - this.miningLevel = 5; - } +public class StaballoyPickaxe extends ItemPickaxe { + + /* (non-Javadoc) + * @see net.minecraft.item.Item#getDurabilityForDisplay(net.minecraft.item.ItemStack) + */ + @Override + public double getDurabilityForDisplay(final ItemStack stack) { + return (double) stack.getItemDamageForDisplay() / (double) stack.getMaxDamage(); + } + + /** + * Creates an NBT tag for this item if it doesn't have one. + * This also set some default values. + * @param rStack + * @return + */ + private static boolean createNBT(ItemStack rStack) { + final NBTTagCompound tagMain = new NBTTagCompound(); + final NBTTagCompound tagNBT = new NBTTagCompound(); + + tagNBT.setBoolean("FACING_HORIZONTAL", true); + tagNBT.setString("FACING", "north"); + tagNBT.setString("lookingDirection", ""); + + tagMain.setTag("PickStats", tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + /* + * Is the player facing horizontally? + */ + + public static final boolean isFacingHorizontal(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("PickStats"); + if (aNBT != null) { + return aNBT.getBoolean("FACING_HORIZONTAL"); + } + } else { + createNBT(aStack); + } + return true; + } + + public static final boolean setFacingHorizontal(final ItemStack aStack, final boolean aFacingHorizontal) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("PickStats"); + if (aNBT != null) { + aNBT.setBoolean("FACING_HORIZONTAL", aFacingHorizontal); + return true; + } + } + return false; + } + + /* + * Handles the Direction the player is facing + */ + + public static final String getFacingDirection(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("PickStats"); + if (aNBT != null) { + return aNBT.getString("FACING"); + } + } else { + createNBT(aStack); + } + return "north"; + } + + public static final boolean setFacingDirection(final ItemStack aStack, final String aFacingHorizontal) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("PickStats"); + if (aNBT != null) { + aNBT.setString("FACING", aFacingHorizontal); + return true; + } + } + return false; + } + + /* + * The Looking Direction handlers + */ + + public static final String getLookingDirection(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("PickStats"); + if (aNBT != null) { + return aNBT.getString("lookingDirection"); + } + } else { + createNBT(aStack); + } + return ""; + } + + public static final boolean setLookingDirection(final ItemStack aStack, final String aFacingHorizontal) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("PickStats"); + if (aNBT != null) { + aNBT.setString("lookingDirection", aFacingHorizontal); + return true; + } + } + return false; + } + + protected int miningLevel; + + /* + * + * + * + * Methods + * + * + * + */ + + @Override + public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer aPlayer) { + return super.onItemRightClick(stack, world, aPlayer); + } + + @Override + public boolean onBlockDestroyed( + final ItemStack stack, + final World world, + final Block block, + final int X, + final int Y, + final int Z, + final EntityLivingBase entity) { + if (!world.isRemote) { + if (entity instanceof EntityPlayer) { + this.GetDestroyOrientation( + (EntityPlayer) entity, block, getLookingDirection(stack), world, X, Y, Z, stack); + } + } + return super.onBlockDestroyed(stack, world, block, X, Y, Z, entity); + } + + private float calculateDurabilityLoss(final World world, final int X, final int Y, final int Z) { + float bDurabilityLoss = 0; + Boolean correctTool = false; + float bHardness = 0; + if (!world.isRemote) { + try { + final Block removalist = world.getBlock(X, Y, Z); + // Utils.LOG_WARNING(removalist.toString()); + + bHardness = removalist.getBlockHardness(world, X, Y, Z); + Logger.WARNING("Hardness: " + bHardness); + + bDurabilityLoss = (bDurabilityLoss + bHardness); + // Utils.LOG_WARNING("Durability Loss: "+bDurabilityLoss); + + correctTool = this.canPickaxeBlock(removalist, world, new int[] {X, Y, Z}); + Logger.WARNING("" + correctTool); + + if (!correctTool) { + return 0; + } + + } catch (final NullPointerException e) { + + } + } + return 100; + } + + public Boolean canPickaxeBlock(final Block currentBlock, final World currentWorld, final int[] xyz) { + String correctTool = ""; + if (!currentWorld.isRemote) { + try { + correctTool = currentBlock.getHarvestTool(0); + if (MiningUtils.getBlockType(currentBlock, currentWorld, xyz, this.miningLevel) + || correctTool.equals("pickaxe") + || correctTool.equals("null")) { + // Utils.LOG_WARNING(correctTool); + return true; + } + } catch (final NullPointerException e) { + return false; + } + } + return false; + } + + private void GetDestroyOrientation( + EntityPlayer entity, + final Block block, + final String FACING, + final World world, + final int X, + final int Y, + final int Z, + final ItemStack heldItem) { + float DURABILITY_LOSS = 0; + if (!world.isRemote) { + + Logger.WARNING("hardness:" + block.getBlockHardness(world, X, Y, Z)); + if (FACING.equals("below") || FACING.equals("above")) { + DURABILITY_LOSS = 0; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + final float dur = this.calculateDurabilityLoss(world, X + i, Y, Z + j); + DURABILITY_LOSS = (DURABILITY_LOSS + dur); + Logger.WARNING("Added Loss: " + dur); + this.removeBlockAndDropAsItem(world, X + i, Y, Z + j, heldItem); + } + } + } else if (FACING.equals("facingEast") || FACING.equals("facingWest")) { + DURABILITY_LOSS = 0; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + final float dur = this.calculateDurabilityLoss(world, X, Y + i, Z + j); + DURABILITY_LOSS = (DURABILITY_LOSS + dur); + Logger.WARNING("Added Loss: " + dur); + this.removeBlockAndDropAsItem(world, X, Y + i, Z + j, heldItem); + } + } + } else if (FACING.equals("facingNorth") || FACING.equals("facingSouth")) { + DURABILITY_LOSS = 0; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + final float dur = this.calculateDurabilityLoss(world, X + j, Y + i, Z); + DURABILITY_LOSS = (DURABILITY_LOSS + dur); + Logger.WARNING("Added Loss: " + dur); + this.removeBlockAndDropAsItem(world, X + j, Y + i, Z, heldItem); + } + } + } + + // int heldItemDurability = heldItem.getDamage(1); + Logger.WARNING("Total Loss: " + (int) DURABILITY_LOSS); + // heldItem.setDamage(heldStack, DURABILITY_LOSS); + // Utils.LOG_WARNING("|GID|Durability: "+heldItem.getItemDamage()); + // Utils.LOG_WARNING("Durability: "+heldStack.getDamage(heldStack)); + Logger.WARNING("1x: " + (heldItem.getItemDamage())); + final int itemdmg = heldItem.getItemDamage(); + final int maxdmg = heldItem.getMaxDamage(); + final int dodmg = (int) DURABILITY_LOSS; + final int durNow = maxdmg - itemdmg; + final int durLeft = (int) ((maxdmg - itemdmg) - DURABILITY_LOSS); + + Logger.WARNING("Current Damage: " + itemdmg + + " Max Damage: " + maxdmg + + " Durability to be lost: " + dodmg + + " Current Durability: " + durNow + + " Remaining Durability: " + durLeft); + + // Break Tool + if (((durNow - dodmg) <= (99)) && (itemdmg != 0)) { + // TODO break tool + Logger.WARNING("Breaking Tool"); + heldItem.stackSize = 0; + } + // Do Damage + else { + // setItemDamage(heldItem, durLeft); + Logger.WARNING("" + (durNow - durLeft)); + this.damageItem(heldItem, (durNow - durLeft) - 1, entity); + } + + /*if (heldItem.getItemDamage() <= ((heldItem.getMaxDamage()-heldItem.getItemDamage())-DURABILITY_LOSS)){ + Utils.LOG_WARNING("2: "+DURABILITY_LOSS+" 3: "+((heldItem.getMaxDamage()-heldItem.getItemDamage())-DURABILITY_LOSS)); + setItemDamage(heldItem, (int) (heldItem.getMaxDamage()-(heldItem.getMaxDamage()-heldItem.getItemDamage())-DURABILITY_LOSS)); + } + else { + Utils.LOG_WARNING("3: "+( heldItem.getMaxDamage()-(heldItem.getMaxDamage()-heldItem.getItemDamage()))); + setItemDamage(heldItem, heldItem.getMaxDamage()-(heldItem.getMaxDamage()-heldItem.getItemDamage())); + }*/ + // Utils.LOG_WARNING("|GID|Durability: "+heldItem.getItemDamage()); + DURABILITY_LOSS = 0; + } + } + + public void damageItem(final ItemStack item, final int damage, final EntityPlayer localPlayer) { + item.damageItem(damage, localPlayer); + } + + public void setItemDamage(final ItemStack item, final int damage) { + item.setItemDamage(damage - 1); + } + + // Should clear up blocks quicker if I chain it. + public final void removeBlockAndDropAsItem( + final World world, final int X, final int Y, final int Z, final ItemStack heldItem) { + try { + final Block block = world.getBlock(X, Y, Z); + final float dur = this.calculateDurabilityLoss(world, X, Y, Z); + Logger.WARNING(block.toString()); + String removalTool = ""; + removalTool = block.getHarvestTool(1); + + Logger.WARNING("Removing.1 " + removalTool); + /*if ((removalTool.equalsIgnoreCase("pickaxe") || removalTool.equalsIgnoreCase("null") || removalTool == null)){ + Utils.LOG_WARNING("Removing.2"); + if (UtilsMining.getBlockType(block, world, new int[]{X,Y,Z}, miningLevel)) { + Utils.LOG_WARNING("Removing.3"); */ + if (this.canPickaxeBlock(block, world, new int[] {X, Y, Z})) { + Logger.WARNING("Removing.4"); + + if (block == Blocks.air) { + return; + } + + if ((block != Blocks.bedrock) + && (block.getBlockHardness(world, X, Y, Z) >= 0) + && (block.getBlockHardness(world, X, Y, Z) <= 100) + && (block != Blocks.water) + && (block != Blocks.lava)) { + + Logger.WARNING("Removing.5"); + if (heldItem.getItemDamage() <= (heldItem.getMaxDamage() - dur)) { + + if (X == 0 && Y == 0 && Z == 0) { + + } else { + block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0); + world.setBlockToAir(X, Y, Z); + } + } + } + /*} + + }*/ + } else { + Logger.WARNING("Incorrect Tool for mining this block."); + } + } catch (final NullPointerException e) { + + } + } + + public boolean checkFacing(final ItemStack aStack, final EntityPlayer aPlayer, final World world) { + if (aPlayer != null) { + final int direction = MathHelper.floor_double((aPlayer.rotationYaw * 4F) / 360F + 0.5D) & 3; + // Utils.LOG_WARNING("Player - F: "+direction); + // Utils.LOG_WARNING("Player - getLookVec(): "+localPlayer.getLookVec().yCoord); + + /*if (localPlayer.getLookVec().yCoord > 0){ + localPlayer.getLookVec().yCoord; + }*/ + + final MovingObjectPosition movingobjectposition = + this.getMovingObjectPositionFromPlayer(world, aPlayer, false); + if (movingobjectposition != null) { + final int sideHit = movingobjectposition.sideHit; + String playerStandingPosition = ""; + if (movingobjectposition != null) { + // System.out.println("Side Hit: "+movingobjectposition.sideHit); + } + + if (sideHit == 0) { + playerStandingPosition = "above"; + setFacingHorizontal(aStack, false); + } else if (sideHit == 1) { + playerStandingPosition = "below"; + setFacingHorizontal(aStack, false); + } else if (sideHit == 2) { + playerStandingPosition = "facingSouth"; + setFacingHorizontal(aStack, true); + } else if (sideHit == 3) { + playerStandingPosition = "facingNorth"; + setFacingHorizontal(aStack, true); + } else if (sideHit == 4) { + playerStandingPosition = "facingEast"; + setFacingHorizontal(aStack, true); + } else if (sideHit == 5) { + playerStandingPosition = "facingWest"; + setFacingHorizontal(aStack, true); + } + setLookingDirection(aStack, playerStandingPosition); + + if (direction == 0) { + setFacingDirection(aStack, "south"); + } else if (direction == 1) { + setFacingDirection(aStack, "west"); + } else if (direction == 2) { + setFacingDirection(aStack, "north"); + } else if (direction == 3) { + setFacingDirection(aStack, "east"); + } + } + + return true; + } + return false; + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add(EnumChatFormatting.GRAY + "Mines a 3x3 at 100 durability per block mined."); + list.add(EnumChatFormatting.GRAY + "Durability: " + (stack.getMaxDamage() - stack.getItemDamage()) + "/" + + stack.getMaxDamage()); + // super.addInformation(stack, aPlayer, list, bool); + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(final ItemStack par1ItemStack) { + return EnumRarity.rare; + } + + @Override + public boolean hasEffect(final ItemStack par1ItemStack) { + return true; + } + + @Override + public boolean onBlockStartBreak( + final ItemStack itemstack, final int X, final int Y, final int Z, final EntityPlayer aPlayer) { + this.checkFacing(itemstack, aPlayer, aPlayer.getEntityWorld()); + return super.onBlockStartBreak(itemstack, X, Y, Z, aPlayer); + } + + public StaballoyPickaxe(final String unlocalizedName, final ToolMaterial material) { + super(material); + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setMaxStackSize(1); + this.setMaxDamage(3200); + this.miningLevel = 5; + } } diff --git a/src/main/java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java b/src/main/java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java index 6265c9f0a3..6cad8cf5fc 100644 --- a/src/main/java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java +++ b/src/main/java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java @@ -1,10 +1,11 @@ package gtPlusPlus.core.item.tool.staballoy; -import java.util.List; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.MiningUtils; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -18,394 +19,396 @@ import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.MiningUtils; - -public class StaballoySpade extends ItemSpade{ - - /* (non-Javadoc) - * @see net.minecraft.item.Item#getDurabilityForDisplay(net.minecraft.item.ItemStack) - */ - @Override - public double getDurabilityForDisplay(final ItemStack stack) { - if (super.getDurabilityForDisplay(stack) > 0){ - return super.getDurabilityForDisplay(stack);} - return 0; - } - - - /** - * Creates an NBT tag for this item if it doesn't have one. - * This also set some default values. - * @param rStack - * @return - */ - - private static boolean createNBT(ItemStack rStack){ - final NBTTagCompound tagMain = new NBTTagCompound(); - final NBTTagCompound tagNBT = new NBTTagCompound(); - - tagNBT.setBoolean("FACING_HORIZONTAL", true); - tagNBT.setString("FACING", "north"); - tagNBT.setString("lookingDirection", ""); - - tagMain.setTag("PickStats", tagNBT); - rStack.setTagCompound(tagMain); - return true; - } - - /* - * Is the player facing horizontally? - */ - - public static final boolean isFacingHorizontal(final ItemStack aStack) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("PickStats"); - if (aNBT != null) { - return aNBT.getBoolean("FACING_HORIZONTAL"); - } - } - else { - createNBT(aStack); - } - return true; - } - - public static final boolean setFacingHorizontal(final ItemStack aStack, final boolean aFacingHorizontal) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("PickStats"); - if (aNBT != null) { - aNBT.setBoolean("FACING_HORIZONTAL", aFacingHorizontal); - return true; - } - } - return false; - } - - /* - * Handles the Direction the player is facing - */ - - public static final String getFacingDirection(final ItemStack aStack) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("PickStats"); - if (aNBT != null) { - return aNBT.getString("FACING"); - } - } - else { - createNBT(aStack); - } - return "north"; - } - - public static final boolean setFacingDirection(final ItemStack aStack, final String aFacingHorizontal) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("PickStats"); - if (aNBT != null) { - aNBT.setString("FACING", aFacingHorizontal); - return true; - } - } - return false; - } - - /* - * The Looking Direction handlers - */ - - public static final String getLookingDirection(final ItemStack aStack) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("PickStats"); - if (aNBT != null) { - return aNBT.getString("lookingDirection"); - } - } - else { - createNBT(aStack); - } - return ""; - } - - public static final boolean setLookingDirection(final ItemStack aStack, final String aFacingHorizontal) { - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag("PickStats"); - if (aNBT != null) { - aNBT.setString("lookingDirection", aFacingHorizontal); - return true; - } - } - return false; - } - - private int miningLevel; - - /* - * - * - * - * Methods - * - * - * - */ - - @Override - public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer aPlayer) { - return super.onItemRightClick(stack, world, aPlayer); - } - - - - @Override - public boolean onBlockDestroyed(final ItemStack stack, final World world, final Block block, final int X, final int Y, final int Z, final EntityLivingBase entity) { - if (!world.isRemote){ - if (entity instanceof EntityPlayer) { - this.GetDestroyOrientation((EntityPlayer) entity, getLookingDirection(stack), world, X, Y, Z, stack); - } - } - return super.onBlockDestroyed(stack, world, block, X, Y, Z, entity); - } - - public Boolean canPickaxeBlock(final Block currentBlock, final World currentWorld, final int[] xyz){ - String correctTool = ""; - if (!currentWorld.isRemote){ - try { - correctTool = currentBlock.getHarvestTool(0); - //Utils.LOG_WARNING(correctTool); - - Logger.WARNING("Tool for Block: "+correctTool+" | Current block: "+currentBlock.getLocalizedName()); - if (MiningUtils.getBlockType(currentBlock, currentWorld, xyz, this.miningLevel) || correctTool.equals("shovel")){ - return true;} - } catch (final NullPointerException e){ - return false;} - } - return false; - } - - private void GetDestroyOrientation(EntityPlayer player, final String FACING, final World world, final int X, final int Y, final int Z, final ItemStack heldItem){ - float DURABILITY_LOSS = 0; - if (!world.isRemote){ - - if (FACING.equals("below") || FACING.equals("above")){ - DURABILITY_LOSS = 0; - for(int i = -1; i < 2; i++) { - for(int j = -1; j < 2; j++) { - DURABILITY_LOSS = (DURABILITY_LOSS + this.removeBlockAndDropAsItem(world, X + i, Y, Z + j, heldItem)); - } - } - } - - else if (FACING.equals("facingEast") || FACING.equals("facingWest")){ - DURABILITY_LOSS = 0; - for(int i = -1; i < 2; i++) { - for(int j = -1; j < 2; j++) { - DURABILITY_LOSS = (DURABILITY_LOSS + this.removeBlockAndDropAsItem(world, X , Y + i, Z + j, heldItem)); - } - } - } - - else if (FACING.equals("facingNorth") || FACING.equals("facingSouth")){ - DURABILITY_LOSS = 0; - for(int i = -1; i < 2; i++) { - for(int j = -1; j < 2; j++) { - DURABILITY_LOSS = (DURABILITY_LOSS + this.removeBlockAndDropAsItem(world, X + j, Y + i, Z, heldItem)); - } - } - } - - //int heldItemDurability = heldItem.getDamage(1); - Logger.WARNING("Total Loss: "+(int)DURABILITY_LOSS); - //heldItem.setDamage(heldStack, DURABILITY_LOSS); - //Utils.LOG_WARNING("|GID|Durability: "+heldItem.getItemDamage()); - //Utils.LOG_WARNING("Durability: "+heldStack.getDamage(heldStack)); - Logger.WARNING("1x: "+(heldItem.getItemDamage())); - final int itemdmg = heldItem.getItemDamage(); - final int maxdmg = heldItem.getMaxDamage(); - final int dodmg = (int)DURABILITY_LOSS; - final int durNow = maxdmg-itemdmg; - final int durLeft = (int) ((maxdmg-itemdmg)-DURABILITY_LOSS); - - Logger.WARNING( - "Current Damage: " + itemdmg - + " Max Damage: " + maxdmg - + " Durability to be lost: " + dodmg - + " Current Durability: " + durNow - + " Remaining Durability: " + durLeft - ); - - - //Break Tool - if (((durNow-dodmg) <= (900)) && (itemdmg != 0)){ - //TODO break tool - Logger.WARNING("Breaking Tool"); - heldItem.stackSize = 0; - } - //Do Damage - else { - //setItemDamage(heldItem, durLeft); - Logger.WARNING(""+(durNow-durLeft)); - this.damageItem(heldItem, (durNow-durLeft)-1, player); - } - DURABILITY_LOSS = 0; - - } - } - - public void damageItem(final ItemStack item, final int damage, final EntityPlayer localPlayer){ - item.damageItem(damage, localPlayer); - } - - public void setItemDamage(final ItemStack item, final int damage){ - item.setItemDamage(damage-1); - } - - //Should clear up blocks quicker if I chain it. - public int removeBlockAndDropAsItem(final World world, final int X, final int Y, final int Z, final ItemStack heldItem){ - Logger.WARNING("Trying to drop/remove a block."); - try { - final Block block = world.getBlock(X, Y, Z); - Logger.WARNING(block.toString()); - String removalTool = ""; - removalTool = block.getHarvestTool(0); - if (removalTool != null){ - if (removalTool.equals("shovel")){ - if (this.canPickaxeBlock(block, world, new int[]{X,Y,Z})){ - if((block != Blocks.bedrock) && (block.getBlockHardness(world, X, Y, Z) != -1) && (block.getBlockHardness(world, X, Y, Z) <= 100) && (block != Blocks.water) && (block != Blocks.lava)){ - - final int itemdmg = heldItem.getItemDamage(); - final int maxdmg = heldItem.getMaxDamage(); - final int dodmg = 100; - final int durNow = maxdmg-itemdmg; - final int durLeft = (maxdmg-itemdmg)-100; - - if (((durNow-dodmg) <= (900)) && (itemdmg != 0)){ - //Do Nothing, Tool is useless. - return 0; - } - block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0); - world.setBlockToAir(X, Y, Z); - Logger.WARNING("Adding 100 damage to item."); - return 100; - } - Logger.WARNING("Incorrect Tool for mining this block. Wrong Block Water/lava/bedrock/blacklist"); - return 0; - } - Logger.WARNING("Incorrect Tool for mining this block. Cannot Shovel this block type."); - return 0; - } - Logger.WARNING("Incorrect Tool for mining this block. Blocks mining tool is now Shovel."); - return 0; - } - Logger.WARNING("Either the block was air or it declares an invalid mining tool."); - return 0; - } catch (final NullPointerException e){ - Logger.WARNING("Something Broke"); - e.printStackTrace(); - return 0; - } - } - - public boolean checkFacing(final ItemStack aStack, final EntityPlayer aPlayer, final World world){ - if (aPlayer != null){ - final int direction = MathHelper.floor_double((aPlayer.rotationYaw * 4F) / 360F + 0.5D) & 3; - //Utils.LOG_WARNING("Player - F: "+direction); - //Utils.LOG_WARNING("Player - getLookVec(): "+localPlayer.getLookVec().yCoord); - - /*if (localPlayer.getLookVec().yCoord > 0){ - localPlayer.getLookVec().yCoord; - }*/ - - final MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, aPlayer, false); - if (movingobjectposition != null){ - final int sideHit = movingobjectposition.sideHit; - String playerStandingPosition = ""; - if (movingobjectposition != null) { - //System.out.println("Side Hit: "+movingobjectposition.sideHit); - } - - if (sideHit == 0){ - playerStandingPosition = "above"; - setFacingHorizontal(aStack, false); - } - else if (sideHit == 1){ - playerStandingPosition = "below"; - setFacingHorizontal(aStack, false); - } - else if (sideHit == 2){ - playerStandingPosition = "facingSouth"; - setFacingHorizontal(aStack, true); - } - else if (sideHit == 3){ - playerStandingPosition = "facingNorth"; - setFacingHorizontal(aStack, true); - } - else if (sideHit == 4){ - playerStandingPosition = "facingEast"; - setFacingHorizontal(aStack, true); - } - else if (sideHit == 5){ - playerStandingPosition = "facingWest"; - setFacingHorizontal(aStack, true); - } - setLookingDirection(aStack, playerStandingPosition); - - if (direction == 0){ - setFacingDirection(aStack, "south"); - } - else if (direction == 1){ - setFacingDirection(aStack, "west"); - } - else if (direction == 2){ - setFacingDirection(aStack, "north"); - } - else if (direction == 3){ - setFacingDirection(aStack, "east"); - } - } - - - return true; - } - return false; - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - list.add(EnumChatFormatting.GOLD+"Spades a 3x3 area in the direction you are facing."); - super.addInformation(stack, aPlayer, list, bool); - } - - @Override - @SideOnly(Side.CLIENT) - public EnumRarity getRarity(final ItemStack par1ItemStack){ - return EnumRarity.rare; - } - - @Override - public boolean hasEffect(final ItemStack par1ItemStack){ - return true; - } - - - @Override - public boolean onBlockStartBreak(final ItemStack itemstack, final int X, final int Y, final int Z, final EntityPlayer aPlayer) { - this.checkFacing(itemstack, aPlayer, aPlayer.worldObj); - return super.onBlockStartBreak(itemstack, X, Y, Z, aPlayer); - } - public StaballoySpade(final String unlocalizedName, final ToolMaterial material) { - super(material); - this.setUnlocalizedName(unlocalizedName); - this.setTextureName(CORE.MODID + ":" + unlocalizedName); - this.setMaxStackSize(1); - this.setMaxDamage(3200); - } +public class StaballoySpade extends ItemSpade { + + /* (non-Javadoc) + * @see net.minecraft.item.Item#getDurabilityForDisplay(net.minecraft.item.ItemStack) + */ + @Override + public double getDurabilityForDisplay(final ItemStack stack) { + if (super.getDurabilityForDisplay(stack) > 0) { + return super.getDurabilityForDisplay(stack); + } + return 0; + } + + /** + * Creates an NBT tag for this item if it doesn't have one. + * This also set some default values. + * @param rStack + * @return + */ + private static boolean createNBT(ItemStack rStack) { + final NBTTagCompound tagMain = new NBTTagCompound(); + final NBTTagCompound tagNBT = new NBTTagCompound(); + + tagNBT.setBoolean("FACING_HORIZONTAL", true); + tagNBT.setString("FACING", "north"); + tagNBT.setString("lookingDirection", ""); + + tagMain.setTag("PickStats", tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + /* + * Is the player facing horizontally? + */ + + public static final boolean isFacingHorizontal(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("PickStats"); + if (aNBT != null) { + return aNBT.getBoolean("FACING_HORIZONTAL"); + } + } else { + createNBT(aStack); + } + return true; + } + + public static final boolean setFacingHorizontal(final ItemStack aStack, final boolean aFacingHorizontal) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("PickStats"); + if (aNBT != null) { + aNBT.setBoolean("FACING_HORIZONTAL", aFacingHorizontal); + return true; + } + } + return false; + } + + /* + * Handles the Direction the player is facing + */ + + public static final String getFacingDirection(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("PickStats"); + if (aNBT != null) { + return aNBT.getString("FACING"); + } + } else { + createNBT(aStack); + } + return "north"; + } + + public static final boolean setFacingDirection(final ItemStack aStack, final String aFacingHorizontal) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("PickStats"); + if (aNBT != null) { + aNBT.setString("FACING", aFacingHorizontal); + return true; + } + } + return false; + } + + /* + * The Looking Direction handlers + */ + + public static final String getLookingDirection(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("PickStats"); + if (aNBT != null) { + return aNBT.getString("lookingDirection"); + } + } else { + createNBT(aStack); + } + return ""; + } + + public static final boolean setLookingDirection(final ItemStack aStack, final String aFacingHorizontal) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag("PickStats"); + if (aNBT != null) { + aNBT.setString("lookingDirection", aFacingHorizontal); + return true; + } + } + return false; + } + + private int miningLevel; + + /* + * + * + * + * Methods + * + * + * + */ + + @Override + public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer aPlayer) { + return super.onItemRightClick(stack, world, aPlayer); + } + + @Override + public boolean onBlockDestroyed( + final ItemStack stack, + final World world, + final Block block, + final int X, + final int Y, + final int Z, + final EntityLivingBase entity) { + if (!world.isRemote) { + if (entity instanceof EntityPlayer) { + this.GetDestroyOrientation((EntityPlayer) entity, getLookingDirection(stack), world, X, Y, Z, stack); + } + } + return super.onBlockDestroyed(stack, world, block, X, Y, Z, entity); + } + + public Boolean canPickaxeBlock(final Block currentBlock, final World currentWorld, final int[] xyz) { + String correctTool = ""; + if (!currentWorld.isRemote) { + try { + correctTool = currentBlock.getHarvestTool(0); + // Utils.LOG_WARNING(correctTool); + + Logger.WARNING( + "Tool for Block: " + correctTool + " | Current block: " + currentBlock.getLocalizedName()); + if (MiningUtils.getBlockType(currentBlock, currentWorld, xyz, this.miningLevel) + || correctTool.equals("shovel")) { + return true; + } + } catch (final NullPointerException e) { + return false; + } + } + return false; + } + + private void GetDestroyOrientation( + EntityPlayer player, + final String FACING, + final World world, + final int X, + final int Y, + final int Z, + final ItemStack heldItem) { + float DURABILITY_LOSS = 0; + if (!world.isRemote) { + + if (FACING.equals("below") || FACING.equals("above")) { + DURABILITY_LOSS = 0; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + DURABILITY_LOSS = + (DURABILITY_LOSS + this.removeBlockAndDropAsItem(world, X + i, Y, Z + j, heldItem)); + } + } + } else if (FACING.equals("facingEast") || FACING.equals("facingWest")) { + DURABILITY_LOSS = 0; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + DURABILITY_LOSS = + (DURABILITY_LOSS + this.removeBlockAndDropAsItem(world, X, Y + i, Z + j, heldItem)); + } + } + } else if (FACING.equals("facingNorth") || FACING.equals("facingSouth")) { + DURABILITY_LOSS = 0; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + DURABILITY_LOSS = + (DURABILITY_LOSS + this.removeBlockAndDropAsItem(world, X + j, Y + i, Z, heldItem)); + } + } + } + + // int heldItemDurability = heldItem.getDamage(1); + Logger.WARNING("Total Loss: " + (int) DURABILITY_LOSS); + // heldItem.setDamage(heldStack, DURABILITY_LOSS); + // Utils.LOG_WARNING("|GID|Durability: "+heldItem.getItemDamage()); + // Utils.LOG_WARNING("Durability: "+heldStack.getDamage(heldStack)); + Logger.WARNING("1x: " + (heldItem.getItemDamage())); + final int itemdmg = heldItem.getItemDamage(); + final int maxdmg = heldItem.getMaxDamage(); + final int dodmg = (int) DURABILITY_LOSS; + final int durNow = maxdmg - itemdmg; + final int durLeft = (int) ((maxdmg - itemdmg) - DURABILITY_LOSS); + + Logger.WARNING("Current Damage: " + itemdmg + + " Max Damage: " + maxdmg + + " Durability to be lost: " + dodmg + + " Current Durability: " + durNow + + " Remaining Durability: " + durLeft); + + // Break Tool + if (((durNow - dodmg) <= (900)) && (itemdmg != 0)) { + // TODO break tool + Logger.WARNING("Breaking Tool"); + heldItem.stackSize = 0; + } + // Do Damage + else { + // setItemDamage(heldItem, durLeft); + Logger.WARNING("" + (durNow - durLeft)); + this.damageItem(heldItem, (durNow - durLeft) - 1, player); + } + DURABILITY_LOSS = 0; + } + } + + public void damageItem(final ItemStack item, final int damage, final EntityPlayer localPlayer) { + item.damageItem(damage, localPlayer); + } + + public void setItemDamage(final ItemStack item, final int damage) { + item.setItemDamage(damage - 1); + } + + // Should clear up blocks quicker if I chain it. + public int removeBlockAndDropAsItem( + final World world, final int X, final int Y, final int Z, final ItemStack heldItem) { + Logger.WARNING("Trying to drop/remove a block."); + try { + final Block block = world.getBlock(X, Y, Z); + Logger.WARNING(block.toString()); + String removalTool = ""; + removalTool = block.getHarvestTool(0); + if (removalTool != null) { + if (removalTool.equals("shovel")) { + if (this.canPickaxeBlock(block, world, new int[] {X, Y, Z})) { + if ((block != Blocks.bedrock) + && (block.getBlockHardness(world, X, Y, Z) != -1) + && (block.getBlockHardness(world, X, Y, Z) <= 100) + && (block != Blocks.water) + && (block != Blocks.lava)) { + + final int itemdmg = heldItem.getItemDamage(); + final int maxdmg = heldItem.getMaxDamage(); + final int dodmg = 100; + final int durNow = maxdmg - itemdmg; + final int durLeft = (maxdmg - itemdmg) - 100; + + if (((durNow - dodmg) <= (900)) && (itemdmg != 0)) { + // Do Nothing, Tool is useless. + return 0; + } + block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0); + world.setBlockToAir(X, Y, Z); + Logger.WARNING("Adding 100 damage to item."); + return 100; + } + Logger.WARNING( + "Incorrect Tool for mining this block. Wrong Block Water/lava/bedrock/blacklist"); + return 0; + } + Logger.WARNING("Incorrect Tool for mining this block. Cannot Shovel this block type."); + return 0; + } + Logger.WARNING("Incorrect Tool for mining this block. Blocks mining tool is now Shovel."); + return 0; + } + Logger.WARNING("Either the block was air or it declares an invalid mining tool."); + return 0; + } catch (final NullPointerException e) { + Logger.WARNING("Something Broke"); + e.printStackTrace(); + return 0; + } + } + + public boolean checkFacing(final ItemStack aStack, final EntityPlayer aPlayer, final World world) { + if (aPlayer != null) { + final int direction = MathHelper.floor_double((aPlayer.rotationYaw * 4F) / 360F + 0.5D) & 3; + // Utils.LOG_WARNING("Player - F: "+direction); + // Utils.LOG_WARNING("Player - getLookVec(): "+localPlayer.getLookVec().yCoord); + + /*if (localPlayer.getLookVec().yCoord > 0){ + localPlayer.getLookVec().yCoord; + }*/ + + final MovingObjectPosition movingobjectposition = + this.getMovingObjectPositionFromPlayer(world, aPlayer, false); + if (movingobjectposition != null) { + final int sideHit = movingobjectposition.sideHit; + String playerStandingPosition = ""; + if (movingobjectposition != null) { + // System.out.println("Side Hit: "+movingobjectposition.sideHit); + } + + if (sideHit == 0) { + playerStandingPosition = "above"; + setFacingHorizontal(aStack, false); + } else if (sideHit == 1) { + playerStandingPosition = "below"; + setFacingHorizontal(aStack, false); + } else if (sideHit == 2) { + playerStandingPosition = "facingSouth"; + setFacingHorizontal(aStack, true); + } else if (sideHit == 3) { + playerStandingPosition = "facingNorth"; + setFacingHorizontal(aStack, true); + } else if (sideHit == 4) { + playerStandingPosition = "facingEast"; + setFacingHorizontal(aStack, true); + } else if (sideHit == 5) { + playerStandingPosition = "facingWest"; + setFacingHorizontal(aStack, true); + } + setLookingDirection(aStack, playerStandingPosition); + + if (direction == 0) { + setFacingDirection(aStack, "south"); + } else if (direction == 1) { + setFacingDirection(aStack, "west"); + } else if (direction == 2) { + setFacingDirection(aStack, "north"); + } else if (direction == 3) { + setFacingDirection(aStack, "east"); + } + } + + return true; + } + return false; + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add(EnumChatFormatting.GOLD + "Spades a 3x3 area in the direction you are facing."); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(final ItemStack par1ItemStack) { + return EnumRarity.rare; + } + + @Override + public boolean hasEffect(final ItemStack par1ItemStack) { + return true; + } + + @Override + public boolean onBlockStartBreak( + final ItemStack itemstack, final int X, final int Y, final int Z, final EntityPlayer aPlayer) { + this.checkFacing(itemstack, aPlayer, aPlayer.worldObj); + return super.onBlockStartBreak(itemstack, X, Y, Z, aPlayer); + } + + public StaballoySpade(final String unlocalizedName, final ToolMaterial material) { + super(material); + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(CORE.MODID + ":" + unlocalizedName); + this.setMaxStackSize(1); + this.setMaxDamage(3200); + } } diff --git a/src/main/java/gtPlusPlus/core/item/wearable/WearableLoader.java b/src/main/java/gtPlusPlus/core/item/wearable/WearableLoader.java index 6912b4e771..8044b4364f 100644 --- a/src/main/java/gtPlusPlus/core/item/wearable/WearableLoader.java +++ b/src/main/java/gtPlusPlus/core/item/wearable/WearableLoader.java @@ -4,12 +4,11 @@ import gtPlusPlus.core.item.wearable.armour.ArmourLoader; public class WearableLoader { - public static void run() { - execute(); - } - - private static void execute() { - ArmourLoader.run(); - } - + public static void run() { + execute(); + } + + private static void execute() { + ArmourLoader.run(); + } } diff --git a/src/main/java/gtPlusPlus/core/item/wearable/armour/ArmourLoader.java b/src/main/java/gtPlusPlus/core/item/wearable/armour/ArmourLoader.java index 6918f2b048..2034d209e7 100644 --- a/src/main/java/gtPlusPlus/core/item/wearable/armour/ArmourLoader.java +++ b/src/main/java/gtPlusPlus/core/item/wearable/armour/ArmourLoader.java @@ -5,37 +5,35 @@ import gtPlusPlus.core.item.wearable.armour.tinfoil.ArmourTinFoilHat; import gtPlusPlus.core.lib.CORE; import net.minecraft.item.Item; import net.minecraft.item.ItemArmor.ArmorMaterial; - import net.minecraftforge.common.util.EnumHelper; public class ArmourLoader { - //Glass - public static Item ClearGlassChestplate; - public static Item ClearGlassBoots; - public static Item ClearGlassLeggings; - public static Item ClearGlassHelmet; - - //Tin Foil - public static Item TinFoilHat; - - public static ArmorMaterial ClearGlassArmour = EnumHelper.addArmorMaterial("ClearGlassArmor", 1, new int[] {1, 1, 1, 1}, 100); - public static ArmorMaterial TinFoilArmour = EnumHelper.addArmorMaterial("TINFOIL", 5, new int[]{1, 1, 1, 1}, 50); - - - public static void run() { - glassArmour(); - tinfoilArmour(); - } - - private static void glassArmour() { - //RenderingRegistry.addNewArmourRendererPrefix("ClearGlassArmor"); This needs to be client side only TODO - //ClearGlassHelmet = new ClearGlassArmor(2055, ClearGlassArmor, 5, 0).setUnlocalizedName("amethyst_helmet"); - } - - private static void tinfoilArmour() { - TinFoilHat = new ArmourTinFoilHat().setUnlocalizedName("itemHatTinFoil"); - GameRegistry.registerItem(TinFoilHat, "itemHatTinFoil", CORE.MODID); - } - + // Glass + public static Item ClearGlassChestplate; + public static Item ClearGlassBoots; + public static Item ClearGlassLeggings; + public static Item ClearGlassHelmet; + + // Tin Foil + public static Item TinFoilHat; + + public static ArmorMaterial ClearGlassArmour = + EnumHelper.addArmorMaterial("ClearGlassArmor", 1, new int[] {1, 1, 1, 1}, 100); + public static ArmorMaterial TinFoilArmour = EnumHelper.addArmorMaterial("TINFOIL", 5, new int[] {1, 1, 1, 1}, 50); + + public static void run() { + glassArmour(); + tinfoilArmour(); + } + + private static void glassArmour() { + // RenderingRegistry.addNewArmourRendererPrefix("ClearGlassArmor"); This needs to be client side only TODO + // ClearGlassHelmet = new ClearGlassArmor(2055, ClearGlassArmor, 5, 0).setUnlocalizedName("amethyst_helmet"); + } + + private static void tinfoilArmour() { + TinFoilHat = new ArmourTinFoilHat().setUnlocalizedName("itemHatTinFoil"); + GameRegistry.registerItem(TinFoilHat, "itemHatTinFoil", CORE.MODID); + } } diff --git a/src/main/java/gtPlusPlus/core/item/wearable/armour/base/BaseArmour.java b/src/main/java/gtPlusPlus/core/item/wearable/armour/base/BaseArmour.java index 0c6a547d34..e7ce975eca 100644 --- a/src/main/java/gtPlusPlus/core/item/wearable/armour/base/BaseArmour.java +++ b/src/main/java/gtPlusPlus/core/item/wearable/armour/base/BaseArmour.java @@ -4,8 +4,7 @@ import gtPlusPlus.core.item.wearable.base.BaseItemWearable; public abstract class BaseArmour extends BaseItemWearable { - public BaseArmour(ArmorMaterial material, int renderIndex, int armourType) { - super(material, renderIndex, armourType); - } - + public BaseArmour(ArmorMaterial material, int renderIndex, int armourType) { + super(material, renderIndex, armourType); + } } diff --git a/src/main/java/gtPlusPlus/core/item/wearable/armour/base/BaseArmourBoots.java b/src/main/java/gtPlusPlus/core/item/wearable/armour/base/BaseArmourBoots.java index 2ace8919d0..5191f9393c 100644 --- a/src/main/java/gtPlusPlus/core/item/wearable/armour/base/BaseArmourBoots.java +++ b/src/main/java/gtPlusPlus/core/item/wearable/armour/base/BaseArmourBoots.java @@ -2,9 +2,8 @@ package gtPlusPlus.core.item.wearable.armour.base; public abstract class BaseArmourBoots extends BaseArmour { - public BaseArmourBoots(ArmorMaterial material, int renderIndex) { - super(material, renderIndex, 3); - // TODO Auto-generated constructor stub - } - + public BaseArmourBoots(ArmorMaterial material, int renderIndex) { + super(material, renderIndex, 3); + // TODO Auto-generated constructor stub + } } diff --git a/src/main/java/gtPlusPlus/core/item/wearable/armour/base/BaseArmourChest.java b/src/main/java/gtPlusPlus/core/item/wearable/armour/base/BaseArmourChest.java index 16899c4229..eb55637ee4 100644 --- a/src/main/java/gtPlusPlus/core/item/wearable/armour/base/BaseArmourChest.java +++ b/src/main/java/gtPlusPlus/core/item/wearable/armour/base/BaseArmourChest.java @@ -2,9 +2,8 @@ package gtPlusPlus.core.item.wearable.armour.base; public abstract class BaseArmourChest extends BaseArmour { - public BaseArmourChest(ArmorMaterial material, int renderIndex) { - super(material, renderIndex, 1); - // TODO Auto-generated constructor stub - } - + public BaseArmourChest(ArmorMaterial material, int renderIndex) { + super(material, renderIndex, 1); + // TODO Auto-generated constructor stub + } } diff --git a/src/main/java/gtPlusPlus/core/item/wearable/armour/base/BaseArmourHelm.java b/src/main/java/gtPlusPlus/core/item/wearable/armour/base/BaseArmourHelm.java index c3676277eb..d121a90ade 100644 --- a/src/main/java/gtPlusPlus/core/item/wearable/armour/base/BaseArmourHelm.java +++ b/src/main/java/gtPlusPlus/core/item/wearable/armour/base/BaseArmourHelm.java @@ -2,9 +2,8 @@ package gtPlusPlus.core.item.wearable.armour.base; public abstract class BaseArmourHelm extends BaseArmour { - public BaseArmourHelm(ArmorMaterial material, int renderIndex) { - super(material, renderIndex, 0); - // TODO Auto-generated constructor stub - } - + public BaseArmourHelm(ArmorMaterial material, int renderIndex) { + super(material, renderIndex, 0); + // TODO Auto-generated constructor stub + } } diff --git a/src/main/java/gtPlusPlus/core/item/wearable/armour/base/BaseArmourLegs.java b/src/main/java/gtPlusPlus/core/item/wearable/armour/base/BaseArmourLegs.java index 9794a713ac..b376610427 100644 --- a/src/main/java/gtPlusPlus/core/item/wearable/armour/base/BaseArmourLegs.java +++ b/src/main/java/gtPlusPlus/core/item/wearable/armour/base/BaseArmourLegs.java @@ -2,9 +2,8 @@ package gtPlusPlus.core.item.wearable.armour.base; public abstract class BaseArmourLegs extends BaseArmour { - public BaseArmourLegs(ArmorMaterial material, int renderIndex) { - super(material, renderIndex, 2); - // TODO Auto-generated constructor stub - } - + public BaseArmourLegs(ArmorMaterial material, int renderIndex) { + super(material, renderIndex, 2); + // TODO Auto-generated constructor stub + } } diff --git a/src/main/java/gtPlusPlus/core/item/wearable/armour/hazmat/ArmourHazmat.java b/src/main/java/gtPlusPlus/core/item/wearable/armour/hazmat/ArmourHazmat.java index 9fd7bf7020..a1762a070c 100644 --- a/src/main/java/gtPlusPlus/core/item/wearable/armour/hazmat/ArmourHazmat.java +++ b/src/main/java/gtPlusPlus/core/item/wearable/armour/hazmat/ArmourHazmat.java @@ -1,12 +1,11 @@ package gtPlusPlus.core.item.wearable.armour.hazmat; -import java.util.List; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.core.item.wearable.armour.ArmourLoader; import gtPlusPlus.core.item.wearable.armour.base.BaseArmourHelm; import gtPlusPlus.core.lib.CORE; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -20,98 +19,93 @@ import net.minecraft.world.World; public class ArmourHazmat extends BaseArmourHelm { - public IIcon iconHelm; - - public ArmourHazmat() { - super(ArmourLoader.TinFoilArmour, 0); - } - - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister ir) { - this.iconHelm = ir.registerIcon(CORE.MODID + ":itemHatTinFoil"); - } - - @Override - public int getRenderIndex() { - return 0; - } - - @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { - return this.iconHelm; - } - - public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { - return CORE.MODID + ":textures/models/TinFoil.png"; - } - - public EnumRarity getRarity(ItemStack itemstack) { - return EnumRarity.rare; - } - - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return false; - } - - @Override - public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { - return super.getArmorDisplay(player, armor, slot); - } - - @Override - public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { - - } - - @SuppressWarnings({ "unchecked" }) - @Override - public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { - aList.add("DoomSquirter's protection against cosmic radiation!"); - aList.add("General paranoia makes the wearer unable to collect xp"); - aList.add("Movement speed is also reduced, to keep you safe"); - aList.add("This hat may also have other strange powers"); - } - - @Override - public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, - int slot) { - return new ArmorProperties(0, 0, 0); - } - - @Override - public boolean isDamageable() { - return false; - } - - @Override - public boolean itemInteractionForEntity(ItemStack p_111207_1_, EntityPlayer p_111207_2_, - EntityLivingBase p_111207_3_) { - return super.itemInteractionForEntity(p_111207_1_, p_111207_2_, p_111207_3_); - } - - @Override - public void onUpdate(ItemStack aStack, World aWorld, Entity aEntity, int p_77663_4_, boolean p_77663_5_) { - super.onUpdate(aStack, aWorld, aEntity, p_77663_4_, p_77663_5_); - } - - @Override - public boolean onEntityItemUpdate(EntityItem entityItem) { - return super.onEntityItemUpdate(entityItem); - } - - @Override - public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { - if (itemStack != null && player != null && world != null && !world.isRemote) { - if (player instanceof EntityPlayer) { - - } - } - super.onArmorTick(world, player, itemStack); - } - - @Override - public boolean showDurabilityBar(ItemStack stack) { - return false; - } - + public IIcon iconHelm; + + public ArmourHazmat() { + super(ArmourLoader.TinFoilArmour, 0); + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister ir) { + this.iconHelm = ir.registerIcon(CORE.MODID + ":itemHatTinFoil"); + } + + @Override + public int getRenderIndex() { + return 0; + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) { + return this.iconHelm; + } + + public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { + return CORE.MODID + ":textures/models/TinFoil.png"; + } + + public EnumRarity getRarity(ItemStack itemstack) { + return EnumRarity.rare; + } + + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return false; + } + + @Override + public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { + return super.getArmorDisplay(player, armor, slot); + } + + @Override + public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) {} + + @SuppressWarnings({"unchecked"}) + @Override + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { + aList.add("DoomSquirter's protection against cosmic radiation!"); + aList.add("General paranoia makes the wearer unable to collect xp"); + aList.add("Movement speed is also reduced, to keep you safe"); + aList.add("This hat may also have other strange powers"); + } + + @Override + public ArmorProperties getProperties( + EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) { + return new ArmorProperties(0, 0, 0); + } + + @Override + public boolean isDamageable() { + return false; + } + + @Override + public boolean itemInteractionForEntity( + ItemStack p_111207_1_, EntityPlayer p_111207_2_, EntityLivingBase p_111207_3_) { + return super.itemInteractionForEntity(p_111207_1_, p_111207_2_, p_111207_3_); + } + + @Override + public void onUpdate(ItemStack aStack, World aWorld, Entity aEntity, int p_77663_4_, boolean p_77663_5_) { + super.onUpdate(aStack, aWorld, aEntity, p_77663_4_, p_77663_5_); + } + + @Override + public boolean onEntityItemUpdate(EntityItem entityItem) { + return super.onEntityItemUpdate(entityItem); + } + + @Override + public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { + if (itemStack != null && player != null && world != null && !world.isRemote) { + if (player instanceof EntityPlayer) {} + } + super.onArmorTick(world, player, itemStack); + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } } diff --git a/src/main/java/gtPlusPlus/core/item/wearable/armour/tinfoil/ArmourTinFoilHat.java b/src/main/java/gtPlusPlus/core/item/wearable/armour/tinfoil/ArmourTinFoilHat.java index c1fe96efb5..532f9de530 100644 --- a/src/main/java/gtPlusPlus/core/item/wearable/armour/tinfoil/ArmourTinFoilHat.java +++ b/src/main/java/gtPlusPlus/core/item/wearable/armour/tinfoil/ArmourTinFoilHat.java @@ -1,14 +1,12 @@ package gtPlusPlus.core.item.wearable.armour.tinfoil; -import java.util.List; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.item.wearable.armour.ArmourLoader; import gtPlusPlus.core.item.wearable.armour.base.BaseArmourHelm; import gtPlusPlus.core.lib.CORE; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -33,151 +31,143 @@ import net.minecraft.world.World; public class ArmourTinFoilHat extends BaseArmourHelm { - public IIcon iconHelm; - - public ArmourTinFoilHat() { - super(ArmourLoader.TinFoilArmour, 0); - } - - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister ir) { - this.iconHelm = ir.registerIcon(CORE.MODID + ":itemHatTinFoil"); - } - - @Override - public int getRenderIndex() { - return 0; - } - - @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) { - return this.iconHelm; - } - - public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { - return CORE.MODID + ":textures/models/TinFoil.png"; - } - - public EnumRarity getRarity(ItemStack itemstack) { - return EnumRarity.uncommon; - } - - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return false; - } - - @Override - public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { - return super.getArmorDisplay(player, armor, slot); - } - - @Override - public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { - - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { - aList.add("DoomSquirter's protection against cosmic radiation!"); - aList.add("General paranoia makes the wearer unable to collect xp"); - aList.add("Movement speed is also reduced, to keep you safe"); - aList.add("This hat may also have other strange powers"); - } - - @Override - public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, - int slot) { - return new ArmorProperties(0, 0, 0); - } - - @Override - public boolean isDamageable() { - return false; - } - - @Override - public boolean itemInteractionForEntity(ItemStack p_111207_1_, EntityPlayer p_111207_2_, - EntityLivingBase p_111207_3_) { - return super.itemInteractionForEntity(p_111207_1_, p_111207_2_, p_111207_3_); - } - - @Override - public void onUpdate(ItemStack aStack, World aWorld, Entity aEntity, int p_77663_4_, boolean p_77663_5_) { - super.onUpdate(aStack, aWorld, aEntity, p_77663_4_, p_77663_5_); - } - - @Override - public boolean onEntityItemUpdate(EntityItem entityItem) { - return super.onEntityItemUpdate(entityItem); - } - - @Override - public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { - if (itemStack != null && player != null && world != null && !world.isRemote) { - if (player instanceof EntityPlayer) { - - // Apply Slow - if (!GT_Utility.getPotion(player, Potion.moveSlowdown.id)) { - player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 2, 1, true)); - } - - // Move Xp orbs away - try { - AxisAlignedBB box = player.boundingBox; - box.maxX = player.posX + 5; - box.maxY = player.posY + 5; - box.maxZ = player.posZ + 5; - box.minX = player.posX - 5; - box.minY = player.posY - 5; - box.minZ = player.posZ - 5; - @SuppressWarnings("unchecked") - List g = world.getEntitiesWithinAABBExcludingEntity(player, box); - if (g.size() > 0) { - for (Entity e : g) { - if (e != null) { - if ( - !EntityXPOrb.class.isInstance(e) && - !EntityBoat.class.isInstance(e) && - !EntitySnowball.class.isInstance(e) && - !EntityFireball.class.isInstance(e) && - !EntityEgg.class.isInstance(e) && - !EntityExpBottle.class.isInstance(e) && - !EntityEnderEye.class.isInstance(e) && - !EntityEnderPearl.class.isInstance(e) - ) { - continue; - } - else { - //Logger.INFO("Found "+e.getClass().getName()); - double distX = player.posX - e.posX; - double distZ = player.posZ - e.posZ; - double distY = e.posY + 1.5D - player.posY; - double dir = Math.atan2(distZ, distX); - double speed = 1F / e.getDistanceToEntity(player) * 0.5; - speed = -speed; - if (distY < 0) { - e.motionY += speed; - } - e.motionX = Math.cos(dir) * speed; - e.motionZ = Math.sin(dir) * speed; - } - - - } - } - } - } catch (Throwable t) { - } - } - } - - super.onArmorTick(world, player, itemStack); - } - - @Override - public boolean showDurabilityBar(ItemStack stack) { - return false; - } - + public IIcon iconHelm; + + public ArmourTinFoilHat() { + super(ArmourLoader.TinFoilArmour, 0); + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister ir) { + this.iconHelm = ir.registerIcon(CORE.MODID + ":itemHatTinFoil"); + } + + @Override + public int getRenderIndex() { + return 0; + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) { + return this.iconHelm; + } + + public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { + return CORE.MODID + ":textures/models/TinFoil.png"; + } + + public EnumRarity getRarity(ItemStack itemstack) { + return EnumRarity.uncommon; + } + + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + return false; + } + + @Override + public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { + return super.getArmorDisplay(player, armor, slot); + } + + @Override + public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) {} + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { + aList.add("DoomSquirter's protection against cosmic radiation!"); + aList.add("General paranoia makes the wearer unable to collect xp"); + aList.add("Movement speed is also reduced, to keep you safe"); + aList.add("This hat may also have other strange powers"); + } + + @Override + public ArmorProperties getProperties( + EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) { + return new ArmorProperties(0, 0, 0); + } + + @Override + public boolean isDamageable() { + return false; + } + + @Override + public boolean itemInteractionForEntity( + ItemStack p_111207_1_, EntityPlayer p_111207_2_, EntityLivingBase p_111207_3_) { + return super.itemInteractionForEntity(p_111207_1_, p_111207_2_, p_111207_3_); + } + + @Override + public void onUpdate(ItemStack aStack, World aWorld, Entity aEntity, int p_77663_4_, boolean p_77663_5_) { + super.onUpdate(aStack, aWorld, aEntity, p_77663_4_, p_77663_5_); + } + + @Override + public boolean onEntityItemUpdate(EntityItem entityItem) { + return super.onEntityItemUpdate(entityItem); + } + + @Override + public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { + if (itemStack != null && player != null && world != null && !world.isRemote) { + if (player instanceof EntityPlayer) { + + // Apply Slow + if (!GT_Utility.getPotion(player, Potion.moveSlowdown.id)) { + player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 2, 1, true)); + } + + // Move Xp orbs away + try { + AxisAlignedBB box = player.boundingBox; + box.maxX = player.posX + 5; + box.maxY = player.posY + 5; + box.maxZ = player.posZ + 5; + box.minX = player.posX - 5; + box.minY = player.posY - 5; + box.minZ = player.posZ - 5; + @SuppressWarnings("unchecked") + List g = world.getEntitiesWithinAABBExcludingEntity(player, box); + if (g.size() > 0) { + for (Entity e : g) { + if (e != null) { + if (!EntityXPOrb.class.isInstance(e) + && !EntityBoat.class.isInstance(e) + && !EntitySnowball.class.isInstance(e) + && !EntityFireball.class.isInstance(e) + && !EntityEgg.class.isInstance(e) + && !EntityExpBottle.class.isInstance(e) + && !EntityEnderEye.class.isInstance(e) + && !EntityEnderPearl.class.isInstance(e)) { + continue; + } else { + // Logger.INFO("Found "+e.getClass().getName()); + double distX = player.posX - e.posX; + double distZ = player.posZ - e.posZ; + double distY = e.posY + 1.5D - player.posY; + double dir = Math.atan2(distZ, distX); + double speed = 1F / e.getDistanceToEntity(player) * 0.5; + speed = -speed; + if (distY < 0) { + e.motionY += speed; + } + e.motionX = Math.cos(dir) * speed; + e.motionZ = Math.sin(dir) * speed; + } + } + } + } + } catch (Throwable t) { + } + } + } + + super.onArmorTick(world, player, itemStack); + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } } diff --git a/src/main/java/gtPlusPlus/core/item/wearable/base/BaseItemWearable.java b/src/main/java/gtPlusPlus/core/item/wearable/base/BaseItemWearable.java index f23079bc8b..8dca1e0ded 100644 --- a/src/main/java/gtPlusPlus/core/item/wearable/base/BaseItemWearable.java +++ b/src/main/java/gtPlusPlus/core/item/wearable/base/BaseItemWearable.java @@ -6,60 +6,56 @@ import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; - import net.minecraftforge.common.ISpecialArmor; public abstract class BaseItemWearable extends ItemArmor implements ISpecialArmor { - public BaseItemWearable(ArmorMaterial material, int renderIndex, int armourType) { - super(material, renderIndex, armourType); - } - - public abstract int getRenderIndex(); - - - - @Override - public abstract ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, - int slot); - - @Override - public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { - // TODO Auto-generated method stub - return 0; - } - - @Override - public abstract void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot); - - public void dyeArmour(ItemStack aArmour, int aColour) { - func_82813_b(aArmour, aColour); - } - - @Override - public void func_82813_b(ItemStack p_82813_1_, int p_82813_2_) { - NBTTagCompound nbttagcompound = p_82813_1_.getTagCompound(); - if (nbttagcompound == null) { - nbttagcompound = new NBTTagCompound(); - p_82813_1_.setTagCompound(nbttagcompound); - } - NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display"); - if (!nbttagcompound.hasKey("display", 10)) { - nbttagcompound.setTag("display", nbttagcompound1); - } - nbttagcompound1.setInteger("color", p_82813_2_); - } - - @Override - public void removeColor(ItemStack p_82815_1_) { - NBTTagCompound nbttagcompound = p_82815_1_.getTagCompound(); - if (nbttagcompound != null) { - NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display"); - if (nbttagcompound1.hasKey("color")) { - nbttagcompound1.removeTag("color"); - } - } - } - - + public BaseItemWearable(ArmorMaterial material, int renderIndex, int armourType) { + super(material, renderIndex, armourType); + } + + public abstract int getRenderIndex(); + + @Override + public abstract ArmorProperties getProperties( + EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot); + + @Override + public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { + // TODO Auto-generated method stub + return 0; + } + + @Override + public abstract void damageArmor( + EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot); + + public void dyeArmour(ItemStack aArmour, int aColour) { + func_82813_b(aArmour, aColour); + } + + @Override + public void func_82813_b(ItemStack p_82813_1_, int p_82813_2_) { + NBTTagCompound nbttagcompound = p_82813_1_.getTagCompound(); + if (nbttagcompound == null) { + nbttagcompound = new NBTTagCompound(); + p_82813_1_.setTagCompound(nbttagcompound); + } + NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display"); + if (!nbttagcompound.hasKey("display", 10)) { + nbttagcompound.setTag("display", nbttagcompound1); + } + nbttagcompound1.setInteger("color", p_82813_2_); + } + + @Override + public void removeColor(ItemStack p_82815_1_) { + NBTTagCompound nbttagcompound = p_82815_1_.getTagCompound(); + if (nbttagcompound != null) { + NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display"); + if (nbttagcompound1.hasKey("color")) { + nbttagcompound1.removeTag("color"); + } + } + } } diff --git a/src/main/java/gtPlusPlus/core/item/wearable/hazmat/ItemArmorHazmatEx.java b/src/main/java/gtPlusPlus/core/item/wearable/hazmat/ItemArmorHazmatEx.java index 1f8009e54a..c4923ccd67 100644 --- a/src/main/java/gtPlusPlus/core/item/wearable/hazmat/ItemArmorHazmatEx.java +++ b/src/main/java/gtPlusPlus/core/item/wearable/hazmat/ItemArmorHazmatEx.java @@ -10,22 +10,25 @@ import net.minecraft.item.ItemStack; public class ItemArmorHazmatEx extends ItemArmorHazmat { - public static void init() { - GregtechItemList.Armour_Hazmat_Advanced_Helmet.set(new ItemStack(new ItemArmorHazmatEx(CustomInternalName.aHazmatHelmetEx, 0))); - GregtechItemList.Armour_Hazmat_Advanced_Chest.set(new ItemStack(new ItemArmorHazmatEx(CustomInternalName.aHazmatChestEx, 1))); - GregtechItemList.Armour_Hazmat_Advanced_Legs.set(new ItemStack(new ItemArmorHazmatEx(CustomInternalName.aHazmatLegsEx, 2))); - GregtechItemList.Armour_Hazmat_Advanced_Boots.set(new ItemStack(new ItemArmorHazmatEx(CustomInternalName.aHazmatBootsEx, 3))); - } - - private ItemArmorHazmatEx(InternalName internalName, int type) { - super(internalName, type); - this.setMaxDamage(256); - } + public static void init() { + GregtechItemList.Armour_Hazmat_Advanced_Helmet.set( + new ItemStack(new ItemArmorHazmatEx(CustomInternalName.aHazmatHelmetEx, 0))); + GregtechItemList.Armour_Hazmat_Advanced_Chest.set( + new ItemStack(new ItemArmorHazmatEx(CustomInternalName.aHazmatChestEx, 1))); + GregtechItemList.Armour_Hazmat_Advanced_Legs.set( + new ItemStack(new ItemArmorHazmatEx(CustomInternalName.aHazmatLegsEx, 2))); + GregtechItemList.Armour_Hazmat_Advanced_Boots.set( + new ItemStack(new ItemArmorHazmatEx(CustomInternalName.aHazmatBootsEx, 3))); + } - @Override - public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { - int suffix = this.armorType == 2 ? 2 : 1; - return IC2.textureDomain + ":textures/armor/" + "hazmatEx_" + suffix + ".png"; - } - + private ItemArmorHazmatEx(InternalName internalName, int type) { + super(internalName, type); + this.setMaxDamage(256); + } + + @Override + public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { + int suffix = this.armorType == 2 ? 2 : 1; + return IC2.textureDomain + ":textures/armor/" + "hazmatEx_" + suffix + ".png"; + } } diff --git a/src/main/java/gtPlusPlus/core/lib/CORE.java b/src/main/java/gtPlusPlus/core/lib/CORE.java index 8cb6a938b5..5113755c33 100644 --- a/src/main/java/gtPlusPlus/core/lib/CORE.java +++ b/src/main/java/gtPlusPlus/core/lib/CORE.java @@ -1,10 +1,6 @@ package gtPlusPlus.core.lib; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; - import com.mojang.authlib.GameProfile; - import cpw.mods.fml.common.FMLCommonHandler; import gregtech.api.GregTech_API; import gtPlusPlus.api.objects.Logger; @@ -17,6 +13,8 @@ import gtPlusPlus.xmod.gregtech.api.interfaces.internal.IGregtech_RecipeAdder; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_TesseractGenerator; import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity_TesseractTerminal; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; @@ -28,346 +26,323 @@ import net.minecraftforge.common.util.FakePlayerFactory; public class CORE { - //import cpw.mods.fml.common.Optional; - - //Analytics handler - //public static SegmentAnalytics mHelper; - - public static Map PlayerCache; - - //Math Related - public static final float PI = (float) Math.PI; - public static volatile Random RANDOM = new XSTR(); - - //Env. Variables - public static Configuration Config; - - public static boolean DEVENV = false; - public static boolean NBT_PERSISTENCY_PATCH_APPLIED = false; - //Only can be set in Dev, no config or setting elsewhere. - public static final boolean LOAD_ALL_CONTENT = false;; - - //Mod Variables - - public static final String name = "GT++"; - public static final String MODID = "miscutils"; - public static final String VERSION = "GRADLETOKEN_VERSION"; - - //Tweakables - public static int EVERGLADES_ID = 227; - public static int EVERGLADESBIOME_ID = 238; - public static int AUSTRALIA_ID = 228; - public static int AUSTRALIA_BIOME_DESERT_1_ID = 239; - public static int AUSTRALIA_BIOME_DESERT_2_ID = 240; - public static int AUSTRALIA_BIOME_DESERT_3_ID = 241; - public static int AUSTRALIA_BIOME_PLAINS_ID = 242; - public static int AUSTRALIA_BIOME_OUTBACK_ID = 243; - public static int AUSTRALIA_BIOME_OCEAN_ID = 244; - public static int AUSTRALIA_BIOME_FOREST_ID = 245; - - //GT Vars; - public static final int GREG_FIRST_ID = 760; - public static final boolean MAIN_GREGTECH_5U_EXPERIMENTAL_FORK = Meta_GT_Proxy.areWeUsingGregtech5uExperimental(); - public static final int GREGTECH_API_VERSION = GregTech_API.VERSION; - public static int turbineCutoffBase = 75000; - - //GT++ Fake Player Profile - public static final GameProfile gameProfile = new GameProfile(UUID.nameUUIDFromBytes("gtplusplus.core".getBytes()), "[GT++]"); - public static final WeakHashMap fakePlayerCache = new WeakHashMap(); - //Tooltips; - public static final String GT_Tooltip = "Added by: " + EnumChatFormatting.DARK_GREEN+"Alkalus "+EnumChatFormatting.GRAY+"- "+EnumChatFormatting.RED+"[GT++]"; - public static final String GT_Tooltip_Builder = "" + EnumChatFormatting.DARK_GREEN+"Alkalus "+EnumChatFormatting.GRAY+"- "+EnumChatFormatting.RED+"[GT++]"; - public static final String GT_Tooltip_Radioactive = EnumChatFormatting.GRAY+"Warning: "+EnumChatFormatting.GREEN+"Radioactive! "+EnumChatFormatting.GOLD+" Avoid direct handling without hazmat protection."; - public static final String noItem = ""; - - //Because I want to be lazy Gregtech New Horizons Var. - public static boolean GTNH = false; - //Because I want to be lazy. Beyond Reality Classic Var. - public static boolean BRC = false; - - public static final String SEPERATOR = "/"; - - - /** - * Lists/Maps - */ - - //Burnables List - public static List> burnables = new ArrayList>(); - - - //TesseractMaps - public static final Map> sTesseractGeneratorOwnershipMap = new HashMap>(); - public static final Map> sTesseractTerminalOwnershipMap = new HashMap>(); - - //BookMap - public static final Map sBookList = new ConcurrentHashMap(); - - - - - /** - * Some Gregtech Material and Recipe Variables - */ - - @Deprecated - public static IGregtech_RecipeAdder sRecipeAdder; - public static IGregtech_RecipeAdder RA; - - public static final GT_Materials[] sMU_GeneratedMaterials = new GT_Materials[1000]; - - /** - * File Paths and Resource Paths - */ - - public static final String - TEX_DIR = "textures/", - TEX_DIR_GUI = TEX_DIR + "gui/", - TEX_DIR_ITEM = TEX_DIR + "items/", - TEX_DIR_BLOCK = TEX_DIR + "blocks/", - TEX_DIR_ENTITY = TEX_DIR + "entity/", - TEX_DIR_ASPECTS = TEX_DIR + "aspects/", - TEX_DIR_FLUIDS = TEX_DIR_BLOCK + "fluids/", - RES_PATH = MODID + ":" + TEX_DIR, - RES_PATH_GUI = MODID + ":" + TEX_DIR_GUI, - RES_PATH_ITEM = MODID + ":" + TEX_DIR_ITEM, - RES_PATH_BLOCK = MODID + ":" + TEX_DIR_BLOCK, - RES_PATH_ENTITY = MODID + ":" + TEX_DIR_ENTITY, - RES_PATH_ASPECTS = MODID + ":" + TEX_DIR_ASPECTS, - RES_PATH_FLUIDS = MODID + ":" + TEX_DIR_FLUIDS; - - - - - /** Used to create a {@link EntityPlayer} instance from {@link FakePlayerFactory}. - * If this instance already exists in the cache, we will return that instead. - * These instances are held via weak reference, if the world object is unloaded, they too will be removed. - * This is the suggested way to handle them, as suggested by Forge. - * - * @param world - The {@link World} object for which you want to check for in the cache. - * This object is used as a weak reference in a {@link WeakHashMap}. - * @return - An {@link EntityPlayerMP} instance, returned either from cache or created and cached prior to return. - */ - public static EntityPlayerMP getFakePlayer(World world) { - if (fakePlayerCache.get(world) == null) { - fakePlayerCache.put(world, FakePlayerFactory.get((WorldServer) world, CORE.gameProfile)); - } - return fakePlayerCache.get(world); - } - - - - - - - - - - - - - - - - - - /* - * Config Switch Class - */ - - public static class ConfigSwitches { - //Debug - public static boolean disableEnderIOIntegration = false; - public static boolean disableEnderIOIngotTooltips = false; - public static boolean MACHINE_INFO = true; - public static boolean showHiddenNEIItems = false; - public static boolean dumpItemAndBlockData = false; - - //Tools - public static boolean enableSkookumChoochers = true; - public static boolean enableMultiSizeTools = true; - - //Block Drops - public static int chanceToDropDrainedShard = 196; - public static int chanceToDropFluoriteOre = 32; - - //Machine Related - public static boolean enableAlternativeBatteryAlloy = false; - public static boolean enableThaumcraftShardUnification = false; - public static boolean disableIC2Recipes = false; - public static boolean enableAlternativeDivisionSigilRecipe = false; - public static int boilerSteamPerSecond = 750; - public static final boolean requireControlCores = false; - - //Feature Related - public static boolean enableCustomCapes = false; - public static boolean enableCustomCircuits = true; - public static boolean enableOldGTcircuits = false; - public static boolean disableZombieReinforcement = false; - public static int enableWatchdogBGM = CORE_Preloader.enableWatchdogBGM; - public static boolean hideUniversalCells = true; - - //GT Fixes - public static boolean enableNitroFix = false; - public static boolean enableSulfuricAcidFix = false; - public static boolean enableAnimatedTurbines = true; - public static boolean enableHarderRecipesForHighTierCasings = true; - - //Single Block Machines - public static boolean enableMachine_SolarGenerators = false; - public static boolean enableMachine_Safes = true; - public static boolean enableMachine_Dehydrators = true; - public static boolean enableMachine_SteamConverter = true; - public static boolean enableMachine_FluidTanks = true; - public static boolean enableMachine_RocketEngines = true; - public static boolean enableMachine_GeothermalEngines = true; - public static boolean enableMachine_WorldAccelerators = true; - public static boolean enableMachine_Tesseracts = true; - public static boolean enableMachine_SimpleWasher = true; - public static boolean enableMachine_Pollution = true; - public static boolean enableMachine_ComponentAssemblers = false; - public static boolean enableCustom_Pipes = true; - public static boolean enableCustom_Cables = true; - public static boolean enableMachine_RF_Convetor = false; - - //Multiblocks - public static boolean enableMultiblock_AlloyBlastSmelter = true; - public static boolean enableMultiblock_IndustrialCentrifuge = true; - public static boolean enableMultiblock_IndustrialCokeOven = true; - public static boolean enableMultiblock_IndustrialElectrolyzer = true; - public static boolean enableMultiblock_IndustrialMacerationStack = true; - public static boolean enableMultiblock_IndustrialPlatePress = true; - public static boolean enableMultiblock_IndustrialWireMill = true; - public static boolean enableMultiblock_IronBlastFurnace = true; - public static boolean enableMultiblock_MatterFabricator = true; - public static boolean enableMultiblock_MultiTank = true; - public static boolean enableMultiblock_PowerSubstation = true; - public static boolean enableMultiblock_LiquidFluorideThoriumReactor = true; - public static boolean enableMultiblock_NuclearFuelRefinery = true; - public static boolean enableMultiblock_TreeFarmer = true; - public static boolean enableMultiblock_IndustrialSifter = true; - public static boolean enableMultiblock_IndustrialThermalCentrifuge = true; - public static boolean enableMultiblock_IndustrialWashPlant = true; - public static boolean enableMultiblock_LargeAutoCrafter = true; - public static boolean enableMultiblock_ThermalBoiler = true; - public static boolean enableMultiblock_IndustrialCuttingMachine = true; - public static boolean enableMultiblock_IndustrialFishingPort = true; - public static boolean enableMultiblock_IndustrialExtrudingMachine = true; - public static boolean enableMultiblock_IndustrialMultiMachine = true; - public static boolean enableMultiblock_Cyclotron = true; - - //Visuals - public static boolean enableTreeFarmerParticles = true; - public static boolean useGregtechTextures = true; - - //Pollution - public static int pollutionPerSecondMultiPackager = 40; - public static int pollutionPerSecondMultiIndustrialAlloySmelter = 300; - public static int pollutionPerSecondMultiIndustrialArcFurnace = 2400; - public static int pollutionPerSecondMultiIndustrialCentrifuge = 300; - public static int pollutionPerSecondMultiIndustrialCokeOven = 80; - public static int pollutionPerSecondMultiIndustrialCuttingMachine = 160; - public static int pollutionPerSecondMultiIndustrialDehydrator = 500; - public static int pollutionPerSecondMultiIndustrialElectrolyzer = 300; - public static int pollutionPerSecondMultiIndustrialExtruder = 1000; - public static int pollutionPerSecondMultiIndustrialMacerator = 400; - public static int pollutionPerSecondMultiIndustrialMixer = 800; - public static int pollutionPerSecondMultiIndustrialMultiMachine_ModeMetal = 400; - public static int pollutionPerSecondMultiIndustrialMultiMachine_ModeFluid = 400; - public static int pollutionPerSecondMultiIndustrialMultiMachine_ModeMisc = 600; - public static int pollutionPerSecondMultiIndustrialPlatePress_ModeForming = 240; - public static int pollutionPerSecondMultiIndustrialPlatePress_ModeBending = 480; - public static int pollutionPerSecondMultiIndustrialForgeHammer = 250; - public static int pollutionPerSecondMultiIndustrialSifter = 40; - public static int pollutionPerSecondMultiIndustrialThermalCentrifuge = 1000; - public static int pollutionPerSecondMultiIndustrialVacuumFreezer = 500; - public static int pollutionPerSecondMultiIndustrialWashPlant_ModeChemBath = 400; - public static int pollutionPerSecondMultiIndustrialWashPlant_ModeWasher = 100; - public static int pollutionPerSecondMultiIndustrialWireMill = 100; - public static int pollutionPerSecondMultiIsaMill = 1280; - public static int pollutionPerSecondMultiAdvDistillationTower_ModeDistillery = 240; - public static int pollutionPerSecondMultiAdvDistillationTower_ModeDT = 480; - public static int pollutionPerSecondMultiAdvEBF = 500; - public static int pollutionPerSecondMultiAdvImplosion = 5000; - public static int pollutionPerSecondMultiABS = 200; - public static int pollutionPerSecondMultiCyclotron = 200; - public static int pollutionPerSecondMultiIndustrialFishingPond = 20; - public static int pollutionPerSecondMultiLargeRocketEngine; - public static int pollutionPerSecondMultiLargeSemiFluidGenerator = 1280; - public static int pollutionPerSecondMultiMassFabricator = 40; - public static int pollutionPerSecondMultiRefinery = 4000; - public static int pollutionPerSecondMultiGeneratorArray; - public static int pollutionPerSecondMultiTreeFarm = 100; - public static int pollutionPerSecondMultiFrothFlotationCell = 0; - public static int pollutionPerSecondMultiAutoCrafter = 500; - public static int pollutionPerSecondMultiThermalBoiler = 700; - public static int pollutionPerSecondMultiMolecularTransformer = 1000; - public static int pollutionPerSecondMultiAlgaePond = 0; - public static int pollutionPerSecondMultiIndustrialRockBreaker = 100; - public static int pollutionPerSecondMultiIndustrialChisel = 50; - //pollution single blocks - public static int basePollutionPerSecondSemiFluidGenerator = 40; - public static double[] pollutionReleasedByTierSemiFluidGenerator = new double[]{0,2.0,4.0,8.0}; - public static int basePollutionPerSecondBoiler = 35; - public static double[] pollutionReleasedByTierBoiler = new double[]{0,1.0,1.43, 1.86}; - public static int baseMinPollutionPerSecondRocketFuelGenerator = 250; - public static int baseMaxPollutionPerSecondRocketFuelGenerator = 2000; - public static double[] pollutionReleasedByTierRocketFuelGenerator = new double[]{0,0,0,0,1,2,3}; - public static int basePollutionPerSecondGeothermalGenerator = 100; - public static double[] pollutionReleasedByTierGeothermalGenerator = new double[]{0,0,0,0,1,1,1}; - - } - - public static class Everglades{ - public static final String MODID = "ToxicEverglades"; - public static final String NAME = "GT++ Toxic Everglades"; - public static final String VERSION = "GRADLETOKEN_VERSION"; - } - - public static class Australia{ - public static final String MODID = "Australia"; - public static final String NAME = "GT++ Australia"; - public static final String VERSION = "GRADLETOKEN_VERSION"; - } - - - public static final void crash() { - crash("Generic Crash"); - } - - public static final void crash(String aReason) { - try { - Logger.INFO("=========================================================="); - Logger.INFO("[GT++ CRASH]"); - Logger.INFO("=========================================================="); - Logger.INFO("Oooops..."); - Logger.INFO("This should only happy in a development environment or when something really bad happens."); - Logger.INFO("Reason: "+aReason); - Logger.INFO("=========================================================="); - Logger.INFO("Called from: "+ReflectionUtils.getMethodName(1)); - Logger.INFO(ReflectionUtils.getMethodName(2)); - Logger.INFO(ReflectionUtils.getMethodName(3)); - Logger.INFO(ReflectionUtils.getMethodName(4)); - Logger.INFO(ReflectionUtils.getMethodName(5)); - Logger.INFO(ReflectionUtils.getMethodName(6)); - Logger.INFO(ReflectionUtils.getMethodName(7)); - Logger.INFO(ReflectionUtils.getMethodName(8)); - Logger.INFO(ReflectionUtils.getMethodName(9)); - Logger.INFO(ReflectionUtils.getMethodName(10)); - Logger.INFO(ReflectionUtils.getMethodName(11)); - Logger.INFO(ReflectionUtils.getMethodName(12)); - Logger.INFO(ReflectionUtils.getMethodName(13)); - Logger.INFO(ReflectionUtils.getMethodName(14)); - Logger.INFO(ReflectionUtils.getMethodName(15)); - } - catch (Throwable t) { - t.printStackTrace(); - } - FMLCommonHandler.instance().exitJava(0, true); - } - - public static final void gc() { - System.gc(); - } - -} \ No newline at end of file + // import cpw.mods.fml.common.Optional; + + // Analytics handler + // public static SegmentAnalytics mHelper; + + public static Map PlayerCache; + + // Math Related + public static final float PI = (float) Math.PI; + public static volatile Random RANDOM = new XSTR(); + + // Env. Variables + public static Configuration Config; + + public static boolean DEVENV = false; + public static boolean NBT_PERSISTENCY_PATCH_APPLIED = false; + // Only can be set in Dev, no config or setting elsewhere. + public static final boolean LOAD_ALL_CONTENT = false; + ; + + // Mod Variables + + public static final String name = "GT++"; + public static final String MODID = "miscutils"; + public static final String VERSION = "GRADLETOKEN_VERSION"; + + // Tweakables + public static int EVERGLADES_ID = 227; + public static int EVERGLADESBIOME_ID = 238; + public static int AUSTRALIA_ID = 228; + public static int AUSTRALIA_BIOME_DESERT_1_ID = 239; + public static int AUSTRALIA_BIOME_DESERT_2_ID = 240; + public static int AUSTRALIA_BIOME_DESERT_3_ID = 241; + public static int AUSTRALIA_BIOME_PLAINS_ID = 242; + public static int AUSTRALIA_BIOME_OUTBACK_ID = 243; + public static int AUSTRALIA_BIOME_OCEAN_ID = 244; + public static int AUSTRALIA_BIOME_FOREST_ID = 245; + + // GT Vars; + public static final int GREG_FIRST_ID = 760; + public static final boolean MAIN_GREGTECH_5U_EXPERIMENTAL_FORK = Meta_GT_Proxy.areWeUsingGregtech5uExperimental(); + public static final int GREGTECH_API_VERSION = GregTech_API.VERSION; + public static int turbineCutoffBase = 75000; + + // GT++ Fake Player Profile + public static final GameProfile gameProfile = + new GameProfile(UUID.nameUUIDFromBytes("gtplusplus.core".getBytes()), "[GT++]"); + public static final WeakHashMap fakePlayerCache = new WeakHashMap(); + // Tooltips; + public static final String GT_Tooltip = "Added by: " + EnumChatFormatting.DARK_GREEN + "Alkalus " + + EnumChatFormatting.GRAY + "- " + EnumChatFormatting.RED + "[GT++]"; + public static final String GT_Tooltip_Builder = "" + EnumChatFormatting.DARK_GREEN + "Alkalus " + + EnumChatFormatting.GRAY + "- " + EnumChatFormatting.RED + "[GT++]"; + public static final String GT_Tooltip_Radioactive = EnumChatFormatting.GRAY + "Warning: " + EnumChatFormatting.GREEN + + "Radioactive! " + EnumChatFormatting.GOLD + " Avoid direct handling without hazmat protection."; + public static final String noItem = ""; + + // Because I want to be lazy Gregtech New Horizons Var. + public static boolean GTNH = false; + // Because I want to be lazy. Beyond Reality Classic Var. + public static boolean BRC = false; + + public static final String SEPERATOR = "/"; + + /** + * Lists/Maps + */ + + // Burnables List + public static List> burnables = new ArrayList>(); + + // TesseractMaps + public static final Map> sTesseractGeneratorOwnershipMap = + new HashMap>(); + public static final Map> sTesseractTerminalOwnershipMap = + new HashMap>(); + + // BookMap + public static final Map sBookList = new ConcurrentHashMap(); + + /** + * Some Gregtech Material and Recipe Variables + */ + @Deprecated + public static IGregtech_RecipeAdder sRecipeAdder; + + public static IGregtech_RecipeAdder RA; + + public static final GT_Materials[] sMU_GeneratedMaterials = new GT_Materials[1000]; + + /** + * File Paths and Resource Paths + */ + public static final String TEX_DIR = "textures/", + TEX_DIR_GUI = TEX_DIR + "gui/", + TEX_DIR_ITEM = TEX_DIR + "items/", + TEX_DIR_BLOCK = TEX_DIR + "blocks/", + TEX_DIR_ENTITY = TEX_DIR + "entity/", + TEX_DIR_ASPECTS = TEX_DIR + "aspects/", + TEX_DIR_FLUIDS = TEX_DIR_BLOCK + "fluids/", + RES_PATH = MODID + ":" + TEX_DIR, + RES_PATH_GUI = MODID + ":" + TEX_DIR_GUI, + RES_PATH_ITEM = MODID + ":" + TEX_DIR_ITEM, + RES_PATH_BLOCK = MODID + ":" + TEX_DIR_BLOCK, + RES_PATH_ENTITY = MODID + ":" + TEX_DIR_ENTITY, + RES_PATH_ASPECTS = MODID + ":" + TEX_DIR_ASPECTS, + RES_PATH_FLUIDS = MODID + ":" + TEX_DIR_FLUIDS; + + /** Used to create a {@link EntityPlayer} instance from {@link FakePlayerFactory}. + * If this instance already exists in the cache, we will return that instead. + * These instances are held via weak reference, if the world object is unloaded, they too will be removed. + * This is the suggested way to handle them, as suggested by Forge. + * + * @param world - The {@link World} object for which you want to check for in the cache. + * This object is used as a weak reference in a {@link WeakHashMap}. + * @return - An {@link EntityPlayerMP} instance, returned either from cache or created and cached prior to return. + */ + public static EntityPlayerMP getFakePlayer(World world) { + if (fakePlayerCache.get(world) == null) { + fakePlayerCache.put(world, FakePlayerFactory.get((WorldServer) world, CORE.gameProfile)); + } + return fakePlayerCache.get(world); + } + + /* + * Config Switch Class + */ + + public static class ConfigSwitches { + // Debug + public static boolean disableEnderIOIntegration = false; + public static boolean disableEnderIOIngotTooltips = false; + public static boolean MACHINE_INFO = true; + public static boolean showHiddenNEIItems = false; + public static boolean dumpItemAndBlockData = false; + + // Tools + public static boolean enableSkookumChoochers = true; + public static boolean enableMultiSizeTools = true; + + // Block Drops + public static int chanceToDropDrainedShard = 196; + public static int chanceToDropFluoriteOre = 32; + + // Machine Related + public static boolean enableAlternativeBatteryAlloy = false; + public static boolean enableThaumcraftShardUnification = false; + public static boolean disableIC2Recipes = false; + public static boolean enableAlternativeDivisionSigilRecipe = false; + public static int boilerSteamPerSecond = 750; + public static final boolean requireControlCores = false; + + // Feature Related + public static boolean enableCustomCapes = false; + public static boolean enableCustomCircuits = true; + public static boolean enableOldGTcircuits = false; + public static boolean disableZombieReinforcement = false; + public static int enableWatchdogBGM = CORE_Preloader.enableWatchdogBGM; + public static boolean hideUniversalCells = true; + + // GT Fixes + public static boolean enableNitroFix = false; + public static boolean enableSulfuricAcidFix = false; + public static boolean enableAnimatedTurbines = true; + public static boolean enableHarderRecipesForHighTierCasings = true; + + // Single Block Machines + public static boolean enableMachine_SolarGenerators = false; + public static boolean enableMachine_Safes = true; + public static boolean enableMachine_Dehydrators = true; + public static boolean enableMachine_SteamConverter = true; + public static boolean enableMachine_FluidTanks = true; + public static boolean enableMachine_RocketEngines = true; + public static boolean enableMachine_GeothermalEngines = true; + public static boolean enableMachine_WorldAccelerators = true; + public static boolean enableMachine_Tesseracts = true; + public static boolean enableMachine_SimpleWasher = true; + public static boolean enableMachine_Pollution = true; + public static boolean enableMachine_ComponentAssemblers = false; + public static boolean enableCustom_Pipes = true; + public static boolean enableCustom_Cables = true; + public static boolean enableMachine_RF_Convetor = false; + + // Multiblocks + public static boolean enableMultiblock_AlloyBlastSmelter = true; + public static boolean enableMultiblock_IndustrialCentrifuge = true; + public static boolean enableMultiblock_IndustrialCokeOven = true; + public static boolean enableMultiblock_IndustrialElectrolyzer = true; + public static boolean enableMultiblock_IndustrialMacerationStack = true; + public static boolean enableMultiblock_IndustrialPlatePress = true; + public static boolean enableMultiblock_IndustrialWireMill = true; + public static boolean enableMultiblock_IronBlastFurnace = true; + public static boolean enableMultiblock_MatterFabricator = true; + public static boolean enableMultiblock_MultiTank = true; + public static boolean enableMultiblock_PowerSubstation = true; + public static boolean enableMultiblock_LiquidFluorideThoriumReactor = true; + public static boolean enableMultiblock_NuclearFuelRefinery = true; + public static boolean enableMultiblock_TreeFarmer = true; + public static boolean enableMultiblock_IndustrialSifter = true; + public static boolean enableMultiblock_IndustrialThermalCentrifuge = true; + public static boolean enableMultiblock_IndustrialWashPlant = true; + public static boolean enableMultiblock_LargeAutoCrafter = true; + public static boolean enableMultiblock_ThermalBoiler = true; + public static boolean enableMultiblock_IndustrialCuttingMachine = true; + public static boolean enableMultiblock_IndustrialFishingPort = true; + public static boolean enableMultiblock_IndustrialExtrudingMachine = true; + public static boolean enableMultiblock_IndustrialMultiMachine = true; + public static boolean enableMultiblock_Cyclotron = true; + + // Visuals + public static boolean enableTreeFarmerParticles = true; + public static boolean useGregtechTextures = true; + + // Pollution + public static int pollutionPerSecondMultiPackager = 40; + public static int pollutionPerSecondMultiIndustrialAlloySmelter = 300; + public static int pollutionPerSecondMultiIndustrialArcFurnace = 2400; + public static int pollutionPerSecondMultiIndustrialCentrifuge = 300; + public static int pollutionPerSecondMultiIndustrialCokeOven = 80; + public static int pollutionPerSecondMultiIndustrialCuttingMachine = 160; + public static int pollutionPerSecondMultiIndustrialDehydrator = 500; + public static int pollutionPerSecondMultiIndustrialElectrolyzer = 300; + public static int pollutionPerSecondMultiIndustrialExtruder = 1000; + public static int pollutionPerSecondMultiIndustrialMacerator = 400; + public static int pollutionPerSecondMultiIndustrialMixer = 800; + public static int pollutionPerSecondMultiIndustrialMultiMachine_ModeMetal = 400; + public static int pollutionPerSecondMultiIndustrialMultiMachine_ModeFluid = 400; + public static int pollutionPerSecondMultiIndustrialMultiMachine_ModeMisc = 600; + public static int pollutionPerSecondMultiIndustrialPlatePress_ModeForming = 240; + public static int pollutionPerSecondMultiIndustrialPlatePress_ModeBending = 480; + public static int pollutionPerSecondMultiIndustrialForgeHammer = 250; + public static int pollutionPerSecondMultiIndustrialSifter = 40; + public static int pollutionPerSecondMultiIndustrialThermalCentrifuge = 1000; + public static int pollutionPerSecondMultiIndustrialVacuumFreezer = 500; + public static int pollutionPerSecondMultiIndustrialWashPlant_ModeChemBath = 400; + public static int pollutionPerSecondMultiIndustrialWashPlant_ModeWasher = 100; + public static int pollutionPerSecondMultiIndustrialWireMill = 100; + public static int pollutionPerSecondMultiIsaMill = 1280; + public static int pollutionPerSecondMultiAdvDistillationTower_ModeDistillery = 240; + public static int pollutionPerSecondMultiAdvDistillationTower_ModeDT = 480; + public static int pollutionPerSecondMultiAdvEBF = 500; + public static int pollutionPerSecondMultiAdvImplosion = 5000; + public static int pollutionPerSecondMultiABS = 200; + public static int pollutionPerSecondMultiCyclotron = 200; + public static int pollutionPerSecondMultiIndustrialFishingPond = 20; + public static int pollutionPerSecondMultiLargeRocketEngine; + public static int pollutionPerSecondMultiLargeSemiFluidGenerator = 1280; + public static int pollutionPerSecondMultiMassFabricator = 40; + public static int pollutionPerSecondMultiRefinery = 4000; + public static int pollutionPerSecondMultiGeneratorArray; + public static int pollutionPerSecondMultiTreeFarm = 100; + public static int pollutionPerSecondMultiFrothFlotationCell = 0; + public static int pollutionPerSecondMultiAutoCrafter = 500; + public static int pollutionPerSecondMultiThermalBoiler = 700; + public static int pollutionPerSecondMultiMolecularTransformer = 1000; + public static int pollutionPerSecondMultiAlgaePond = 0; + public static int pollutionPerSecondMultiIndustrialRockBreaker = 100; + public static int pollutionPerSecondMultiIndustrialChisel = 50; + // pollution single blocks + public static int basePollutionPerSecondSemiFluidGenerator = 40; + public static double[] pollutionReleasedByTierSemiFluidGenerator = new double[] {0, 2.0, 4.0, 8.0}; + public static int basePollutionPerSecondBoiler = 35; + public static double[] pollutionReleasedByTierBoiler = new double[] {0, 1.0, 1.43, 1.86}; + public static int baseMinPollutionPerSecondRocketFuelGenerator = 250; + public static int baseMaxPollutionPerSecondRocketFuelGenerator = 2000; + public static double[] pollutionReleasedByTierRocketFuelGenerator = new double[] {0, 0, 0, 0, 1, 2, 3}; + public static int basePollutionPerSecondGeothermalGenerator = 100; + public static double[] pollutionReleasedByTierGeothermalGenerator = new double[] {0, 0, 0, 0, 1, 1, 1}; + } + + public static class Everglades { + public static final String MODID = "ToxicEverglades"; + public static final String NAME = "GT++ Toxic Everglades"; + public static final String VERSION = "GRADLETOKEN_VERSION"; + } + + public static class Australia { + public static final String MODID = "Australia"; + public static final String NAME = "GT++ Australia"; + public static final String VERSION = "GRADLETOKEN_VERSION"; + } + + public static final void crash() { + crash("Generic Crash"); + } + + public static final void crash(String aReason) { + try { + Logger.INFO("=========================================================="); + Logger.INFO("[GT++ CRASH]"); + Logger.INFO("=========================================================="); + Logger.INFO("Oooops..."); + Logger.INFO("This should only happy in a development environment or when something really bad happens."); + Logger.INFO("Reason: " + aReason); + Logger.INFO("=========================================================="); + Logger.INFO("Called from: " + ReflectionUtils.getMethodName(1)); + Logger.INFO(ReflectionUtils.getMethodName(2)); + Logger.INFO(ReflectionUtils.getMethodName(3)); + Logger.INFO(ReflectionUtils.getMethodName(4)); + Logger.INFO(ReflectionUtils.getMethodName(5)); + Logger.INFO(ReflectionUtils.getMethodName(6)); + Logger.INFO(ReflectionUtils.getMethodName(7)); + Logger.INFO(ReflectionUtils.getMethodName(8)); + Logger.INFO(ReflectionUtils.getMethodName(9)); + Logger.INFO(ReflectionUtils.getMethodName(10)); + Logger.INFO(ReflectionUtils.getMethodName(11)); + Logger.INFO(ReflectionUtils.getMethodName(12)); + Logger.INFO(ReflectionUtils.getMethodName(13)); + Logger.INFO(ReflectionUtils.getMethodName(14)); + Logger.INFO(ReflectionUtils.getMethodName(15)); + } catch (Throwable t) { + t.printStackTrace(); + } + FMLCommonHandler.instance().exitJava(0, true); + } + + public static final void gc() { + System.gc(); + } +} diff --git a/src/main/java/gtPlusPlus/core/lib/LoadedMods.java b/src/main/java/gtPlusPlus/core/lib/LoadedMods.java index 94be6f4127..43822f868e 100644 --- a/src/main/java/gtPlusPlus/core/lib/LoadedMods.java +++ b/src/main/java/gtPlusPlus/core/lib/LoadedMods.java @@ -2,381 +2,382 @@ package gtPlusPlus.core.lib; import static gtPlusPlus.core.lib.CORE.*; -import java.util.HashMap; - import cpw.mods.fml.common.Loader; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE.ConfigSwitches; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechTextures; import gtPlusPlus.xmod.gregtech.recipes.GregtechRecipeAdder; +import java.util.HashMap; public class LoadedMods { - //Initialize Variables - public static boolean Gregtech = false; - public static boolean PlayerAPI = false; - public static boolean BuildCraft = false; - public static boolean EnderIO = false; - public static boolean Big_Reactors = false; - public static boolean IndustrialCraft2 = false; - public static boolean IndustrialCraft2Classic = false; - public static boolean Simply_Jetpacks = false; - public static boolean RFTools = false; - public static boolean Thaumcraft = false; - public static boolean ThaumicBases = false; - public static boolean Baubles = false; - public static boolean Extra_Utils = false; - public static boolean PneumaticCraft = false; - public static boolean MorePlanets = false; - public static boolean ForbiddenMagic = false; - public static boolean CompactWindmills = false; - public static boolean Railcraft = false; - public static boolean ImmersiveEngineering = false; - public static boolean Growthcraft = false; - public static boolean CoFHCore = false; - public static boolean Forestry = false; - public static boolean MagicBees = false; - public static boolean ExtraBees = false; - public static boolean Psychedelicraft = false; - public static boolean MiscUtils = true; //Dummy For MetaData Lookups in MT Wrapper - public static boolean ThermalFoundation = false; - public static boolean IHL = false; - public static boolean AdvancedSolarPanel = false; - public static boolean OpenComputers = false; //OpenComputers - public static boolean OpenBlocks = false; - public static boolean Computronics = false; //computronics - public static boolean DreamCraft = false; //GT: New Horizons - public static boolean BeyondRealityCore = false; //Beyond Reality - Probably Classic - public static boolean BiomesOPlenty = false; - public static boolean PamsHarvestcraft = false; - public static boolean GalacticraftCore = false; - public static boolean Mekanism = false; - public static boolean RedTech = false; //RedMage's Mod - public static boolean TecTech = false; //Technus' Mod - public static boolean KekzTech = false; //KekzDealers' Mod - public static boolean TiCon = false; - public static boolean StevesCarts = false; - public static boolean Witchery = false; - public static boolean Waila = false; - public static boolean CropsPlusPlus = false; //Barts Crop Mod - public static boolean Reliquary = false; - public static boolean SpiceOfLife = false; - public static boolean RemoteIO = false; - public static boolean BartWorks = false; - public static boolean GoodGenerator = false; - public static boolean ExtraTrees = false; + // Initialize Variables + public static boolean Gregtech = false; + public static boolean PlayerAPI = false; + public static boolean BuildCraft = false; + public static boolean EnderIO = false; + public static boolean Big_Reactors = false; + public static boolean IndustrialCraft2 = false; + public static boolean IndustrialCraft2Classic = false; + public static boolean Simply_Jetpacks = false; + public static boolean RFTools = false; + public static boolean Thaumcraft = false; + public static boolean ThaumicBases = false; + public static boolean Baubles = false; + public static boolean Extra_Utils = false; + public static boolean PneumaticCraft = false; + public static boolean MorePlanets = false; + public static boolean ForbiddenMagic = false; + public static boolean CompactWindmills = false; + public static boolean Railcraft = false; + public static boolean ImmersiveEngineering = false; + public static boolean Growthcraft = false; + public static boolean CoFHCore = false; + public static boolean Forestry = false; + public static boolean MagicBees = false; + public static boolean ExtraBees = false; + public static boolean Psychedelicraft = false; + public static boolean MiscUtils = true; // Dummy For MetaData Lookups in MT Wrapper + public static boolean ThermalFoundation = false; + public static boolean IHL = false; + public static boolean AdvancedSolarPanel = false; + public static boolean OpenComputers = false; // OpenComputers + public static boolean OpenBlocks = false; + public static boolean Computronics = false; // computronics + public static boolean DreamCraft = false; // GT: New Horizons + public static boolean BeyondRealityCore = false; // Beyond Reality - Probably Classic + public static boolean BiomesOPlenty = false; + public static boolean PamsHarvestcraft = false; + public static boolean GalacticraftCore = false; + public static boolean Mekanism = false; + public static boolean RedTech = false; // RedMage's Mod + public static boolean TecTech = false; // Technus' Mod + public static boolean KekzTech = false; // KekzDealers' Mod + public static boolean TiCon = false; + public static boolean StevesCarts = false; + public static boolean Witchery = false; + public static boolean Waila = false; + public static boolean CropsPlusPlus = false; // Barts Crop Mod + public static boolean Reliquary = false; + public static boolean SpiceOfLife = false; + public static boolean RemoteIO = false; + public static boolean BartWorks = false; + public static boolean GoodGenerator = false; + public static boolean ExtraTrees = false; - private static int totalMods; - @SuppressWarnings("deprecation") - public static void checkLoaded(){ - Logger.INFO("Looking for optional mod prereqs."); - if (isModLoaded("gregtech") ){ - Gregtech = true; - Logger.INFO("Components enabled for: Gregtech"); - if (Gregtech){ - try { - CORE.sRecipeAdder = CORE.RA = new GregtechRecipeAdder(); - Logger.INFO("Created Gregtech recipe handler."); - GregtechTextures.BlockIcons.VOID.name(); - GregtechTextures.ItemIcons.VOID.name(); - Logger.INFO("Created Gregtech texture handler."); - } catch (final NullPointerException e){ - Logger.INFO("Could NOT create a Gregtech recipe handler."); - } - } + private static int totalMods; - totalMods++; - } - if (isModLoaded("dreamcraft") || ReflectionUtils.doesClassExist("gregtech.api.util.GT_Multiblock_Tooltip_Builder")){ - DreamCraft = true; - GTNH = true; - Logger.INFO("Components enabled for: DreamCraft"); - Logger.INFO("Components enabled for: GT: New Horizons"); - totalMods++; - } - if (isModLoaded("beyondrealitycore")){ - BeyondRealityCore = true; - BRC = true; - Logger.INFO("Components enabled for: Beyond Reality"); - totalMods++; - } - if (isModLoaded("PlayerAPI")){ - PlayerAPI = true; - Logger.INFO("Components enabled for: PlayerAPI"); - totalMods++; - } - if (isModLoaded("berriespp")) { - CropsPlusPlus = true; - Logger.INFO("Components enabled for: Crops++"); - totalMods++; - } - if (isModLoaded("xreliquary")) { - Reliquary = true; - Logger.INFO("Components enabled for: Reliquary"); - totalMods++; - } - if (isModLoaded("TConstruct")){ - TiCon = true; - Logger.INFO("Components enabled for: Tinkers Construct"); - totalMods++; - } - if (isModLoaded("AdvancedSolarPanel")){ - AdvancedSolarPanel = true; - Logger.INFO("Components enabled for: Advanced Solar Panels"); - totalMods++; - } - if (isModLoaded("GoodGenerator")) { - GoodGenerator = true; - Logger.INFO("Components enabled for: GoodGenerator"); - totalMods++; - } - if (isModLoaded("bartworks")) { - BartWorks = true; - Logger.INFO("Components enabled for: BartWorks"); - totalMods++; - } - if (isModLoaded("BuildCraft")){ - BuildCraft = true; - Logger.INFO("Components enabled for: BuildCraft"); - totalMods++; - } - if ((isModLoaded("EnderIO")) && !ConfigSwitches.disableEnderIOIntegration){ - EnderIO = true; - Logger.INFO("Components enabled for: EnderIO"); - totalMods++; - } - if (isModLoaded("BigReactors")){ - Big_Reactors = true; - Logger.INFO("Components enabled for: Big Reactors"); - totalMods++; - } - if (isModLoaded("IC2")){ - IndustrialCraft2 = true; - Logger.INFO("Components enabled for: IndustrialCraft2"); - totalMods++; - } - if (isModLoaded("IC2-Classic-Spmod")){ - IndustrialCraft2Classic = true; - Logger.INFO("Components enabled for: IndustrialCraft2-Classic"); - totalMods++; - } - if (isModLoaded("simplyjetpacks")){ - Simply_Jetpacks = true; - Logger.INFO("Components enabled for: Simply Jetpacks"); - totalMods++; - } - if (isModLoaded("rftools")){ - RFTools = true; - Logger.INFO("Components enabled for: RFTools"); - totalMods++; - } - if (isModLoaded("StevesCarts")){ - StevesCarts = true; - Logger.INFO("Components enabled for: StevesCarts"); - totalMods++; - } - if (isModLoaded("OpenBlocks")){ - OpenBlocks = true; - Logger.INFO("Components enabled for: OpenBlocks"); - totalMods++; - } - if (isModLoaded("Thaumcraft")){ - Thaumcraft = true; - Logger.INFO("Components enabled for: Thaumcraft"); - totalMods++; - } - if (isModLoaded("thaumicbases")){ - ThaumicBases = true; - Logger.INFO("Components enabled for: Thaumic Bases"); - totalMods++; - } - if (isModLoaded("BiomesOPlenty")){ - BiomesOPlenty = true; - Logger.INFO("Components enabled for: BiomesOPlenty"); - totalMods++; - } - if (isModLoaded("ExtraUtilities")){ - Extra_Utils = true; - Logger.INFO("Components enabled for: Extra_Utils"); - totalMods++; - } - if (isModLoaded("harvestcraft")){ - PamsHarvestcraft = true; - Logger.INFO("Components enabled for: PamsHarvestcraft"); - totalMods++; - } - if (isModLoaded("PneumaticCraft")){ - PneumaticCraft = true; - Logger.INFO("Components enabled for: PneumaticCraft"); - totalMods++; - } - if (isModLoaded("MorePlanet")){ - MorePlanets = true; - Logger.INFO("Components enabled for: MorePlanets"); - totalMods++; - } - if (isModLoaded("ForbiddenMagic")){ - ForbiddenMagic = true; - Logger.INFO("Components enabled for: ForbiddenMagic"); - totalMods++; - } - if (isModLoaded("CompactWindmills")){ - CompactWindmills = true; - Logger.INFO("Components enabled for: CompactWindmills"); - totalMods++; - } - if (isModLoaded("Railcraft")){ - Railcraft = true; - Logger.INFO("Components enabled for: Railcraft"); - totalMods++; - } - if (isModLoaded("Waila")){ - Waila = true; - Logger.INFO("Components enabled for: WAILA"); - totalMods++; - } - if (isModLoaded("SpiceOfLife")){ - SpiceOfLife = true; - Logger.INFO("Components enabled for: Spice Of Life"); - totalMods++; - } - if (isModLoaded("Mekanism")){ - Mekanism = true; - Logger.INFO("Components enabled for: Mekanism - This feature is not configurable and balances Mekanism to suit GT."); - totalMods++; - } - if (isModLoaded("Growthcraft")){ - Logger.INFO("Growthcraft Version: "+getModVersion("Growthcraft")); - if (getModVersion("Growthcraft").equals("1.7.10-2.3.1")){ - //Load Growthcraft Compat - Growthcraft = true; - Logger.INFO("Components enabled for: Growthcraft"); - totalMods++; - } - else { - Growthcraft = false; - Logger.INFO("Growthcraft found, but the version was too new. I will update GC support eventually."); - } - } - if (isModLoaded("CoFHCore")){ - CoFHCore = true; - Logger.INFO("Components enabled for: CoFHCore"); - totalMods++; - } - if (isModLoaded("Forestry")){ - Forestry = true; - Logger.INFO("Components enabled for: Forestry"); - totalMods++; - } - if (isModLoaded("MagicBees")){ - MagicBees = true; - Logger.INFO("Components enabled for: MagicBees"); - totalMods++; - } - if (isModLoaded("psychedelicraft")){ - Psychedelicraft = true; - Logger.INFO("Components enabled for: Psychedelicraft"); - totalMods++; - } - if (isModLoaded("ImmersiveEngineering")){ - ImmersiveEngineering = true; - Logger.INFO("Components enabled for: ImmersiveEngineering"); - totalMods++; - } - if (isModLoaded("ExtraBees")){ - ExtraBees = true; - Logger.INFO("Components enabled for: ExtraBees"); - totalMods++; - } - if (isModLoaded("ThermalFoundation") == false){ - ThermalFoundation = false; - Logger.INFO("Components enabled for: ThermalFoundation - This feature will disable itself if you add TF."); - totalMods++; - } - else if (isModLoaded("ThermalFoundation")){ - ThermalFoundation = true; - Logger.INFO("Components disabled for: ThermalFoundation - This feature will enable itself if you remove TF."); - //totalMods++; - } - if (isModLoaded("ihl")){ - IHL = true; - Logger.INFO("Components enabled for: IHL"); - totalMods++; - } - if (isModLoaded("Baubles")){ - Baubles = true; - Logger.INFO("Components enabled for: Baubles"); - totalMods++; - } - if (isModLoaded("GalacticraftCore")){ - GalacticraftCore = true; - Logger.INFO("Components enabled for: Galacticraft Core"); - totalMods++; - } - if (isModLoaded("OpenComputers")){ - OpenComputers = true; - Logger.INFO("Components enabled for: OpenComputers"); - totalMods++; - } - if (isModLoaded("computronics")){ - Computronics = true; - Logger.INFO("Components disabled for: Computronics - This feature will enable itself if you remove Computronics."); - totalMods++; - } - else { - Logger.INFO("Components enabled for: Computronics - This feature will disable itself if you add Computronics."); - } - if (isModLoaded("GTRedtech")){ - RedTech = true; - Logger.INFO("Components enabled for: GTRedtech"); - totalMods++; - } - if (isModLoaded("tectech")){ - TecTech = true; - Logger.INFO("Components enabled for: TecTech"); - totalMods++; - } - if (isModLoaded("kekztech")){ - KekzTech = true; - Logger.INFO("Components enabled for: KekzTech"); - totalMods++; - } - if (isModLoaded("witchery")){ - Witchery = true; - Logger.INFO("Components enabled for: Witchery"); - totalMods++; - } - if (isModLoaded("RIO")){ - RemoteIO = true; - Logger.INFO("Components enabled for: RemoteIO"); - totalMods++; - } - if (isModLoaded("ExtraTrees")){ - ExtraTrees = true; - Logger.INFO("Components enabled for: ExtraTrees"); - totalMods++; - } - Logger.INFO("Content found for "+totalMods+" mods"); + @SuppressWarnings("deprecation") + public static void checkLoaded() { + Logger.INFO("Looking for optional mod prereqs."); + if (isModLoaded("gregtech")) { + Gregtech = true; + Logger.INFO("Components enabled for: Gregtech"); + if (Gregtech) { + try { + CORE.sRecipeAdder = CORE.RA = new GregtechRecipeAdder(); + Logger.INFO("Created Gregtech recipe handler."); + GregtechTextures.BlockIcons.VOID.name(); + GregtechTextures.ItemIcons.VOID.name(); + Logger.INFO("Created Gregtech texture handler."); + } catch (final NullPointerException e) { + Logger.INFO("Could NOT create a Gregtech recipe handler."); + } + } - } + totalMods++; + } + if (isModLoaded("dreamcraft") + || ReflectionUtils.doesClassExist("gregtech.api.util.GT_Multiblock_Tooltip_Builder")) { + DreamCraft = true; + GTNH = true; + Logger.INFO("Components enabled for: DreamCraft"); + Logger.INFO("Components enabled for: GT: New Horizons"); + totalMods++; + } + if (isModLoaded("beyondrealitycore")) { + BeyondRealityCore = true; + BRC = true; + Logger.INFO("Components enabled for: Beyond Reality"); + totalMods++; + } + if (isModLoaded("PlayerAPI")) { + PlayerAPI = true; + Logger.INFO("Components enabled for: PlayerAPI"); + totalMods++; + } + if (isModLoaded("berriespp")) { + CropsPlusPlus = true; + Logger.INFO("Components enabled for: Crops++"); + totalMods++; + } + if (isModLoaded("xreliquary")) { + Reliquary = true; + Logger.INFO("Components enabled for: Reliquary"); + totalMods++; + } + if (isModLoaded("TConstruct")) { + TiCon = true; + Logger.INFO("Components enabled for: Tinkers Construct"); + totalMods++; + } + if (isModLoaded("AdvancedSolarPanel")) { + AdvancedSolarPanel = true; + Logger.INFO("Components enabled for: Advanced Solar Panels"); + totalMods++; + } + if (isModLoaded("GoodGenerator")) { + GoodGenerator = true; + Logger.INFO("Components enabled for: GoodGenerator"); + totalMods++; + } + if (isModLoaded("bartworks")) { + BartWorks = true; + Logger.INFO("Components enabled for: BartWorks"); + totalMods++; + } + if (isModLoaded("BuildCraft")) { + BuildCraft = true; + Logger.INFO("Components enabled for: BuildCraft"); + totalMods++; + } + if ((isModLoaded("EnderIO")) && !ConfigSwitches.disableEnderIOIntegration) { + EnderIO = true; + Logger.INFO("Components enabled for: EnderIO"); + totalMods++; + } + if (isModLoaded("BigReactors")) { + Big_Reactors = true; + Logger.INFO("Components enabled for: Big Reactors"); + totalMods++; + } + if (isModLoaded("IC2")) { + IndustrialCraft2 = true; + Logger.INFO("Components enabled for: IndustrialCraft2"); + totalMods++; + } + if (isModLoaded("IC2-Classic-Spmod")) { + IndustrialCraft2Classic = true; + Logger.INFO("Components enabled for: IndustrialCraft2-Classic"); + totalMods++; + } + if (isModLoaded("simplyjetpacks")) { + Simply_Jetpacks = true; + Logger.INFO("Components enabled for: Simply Jetpacks"); + totalMods++; + } + if (isModLoaded("rftools")) { + RFTools = true; + Logger.INFO("Components enabled for: RFTools"); + totalMods++; + } + if (isModLoaded("StevesCarts")) { + StevesCarts = true; + Logger.INFO("Components enabled for: StevesCarts"); + totalMods++; + } + if (isModLoaded("OpenBlocks")) { + OpenBlocks = true; + Logger.INFO("Components enabled for: OpenBlocks"); + totalMods++; + } + if (isModLoaded("Thaumcraft")) { + Thaumcraft = true; + Logger.INFO("Components enabled for: Thaumcraft"); + totalMods++; + } + if (isModLoaded("thaumicbases")) { + ThaumicBases = true; + Logger.INFO("Components enabled for: Thaumic Bases"); + totalMods++; + } + if (isModLoaded("BiomesOPlenty")) { + BiomesOPlenty = true; + Logger.INFO("Components enabled for: BiomesOPlenty"); + totalMods++; + } + if (isModLoaded("ExtraUtilities")) { + Extra_Utils = true; + Logger.INFO("Components enabled for: Extra_Utils"); + totalMods++; + } + if (isModLoaded("harvestcraft")) { + PamsHarvestcraft = true; + Logger.INFO("Components enabled for: PamsHarvestcraft"); + totalMods++; + } + if (isModLoaded("PneumaticCraft")) { + PneumaticCraft = true; + Logger.INFO("Components enabled for: PneumaticCraft"); + totalMods++; + } + if (isModLoaded("MorePlanet")) { + MorePlanets = true; + Logger.INFO("Components enabled for: MorePlanets"); + totalMods++; + } + if (isModLoaded("ForbiddenMagic")) { + ForbiddenMagic = true; + Logger.INFO("Components enabled for: ForbiddenMagic"); + totalMods++; + } + if (isModLoaded("CompactWindmills")) { + CompactWindmills = true; + Logger.INFO("Components enabled for: CompactWindmills"); + totalMods++; + } + if (isModLoaded("Railcraft")) { + Railcraft = true; + Logger.INFO("Components enabled for: Railcraft"); + totalMods++; + } + if (isModLoaded("Waila")) { + Waila = true; + Logger.INFO("Components enabled for: WAILA"); + totalMods++; + } + if (isModLoaded("SpiceOfLife")) { + SpiceOfLife = true; + Logger.INFO("Components enabled for: Spice Of Life"); + totalMods++; + } + if (isModLoaded("Mekanism")) { + Mekanism = true; + Logger.INFO( + "Components enabled for: Mekanism - This feature is not configurable and balances Mekanism to suit GT."); + totalMods++; + } + if (isModLoaded("Growthcraft")) { + Logger.INFO("Growthcraft Version: " + getModVersion("Growthcraft")); + if (getModVersion("Growthcraft").equals("1.7.10-2.3.1")) { + // Load Growthcraft Compat + Growthcraft = true; + Logger.INFO("Components enabled for: Growthcraft"); + totalMods++; + } else { + Growthcraft = false; + Logger.INFO("Growthcraft found, but the version was too new. I will update GC support eventually."); + } + } + if (isModLoaded("CoFHCore")) { + CoFHCore = true; + Logger.INFO("Components enabled for: CoFHCore"); + totalMods++; + } + if (isModLoaded("Forestry")) { + Forestry = true; + Logger.INFO("Components enabled for: Forestry"); + totalMods++; + } + if (isModLoaded("MagicBees")) { + MagicBees = true; + Logger.INFO("Components enabled for: MagicBees"); + totalMods++; + } + if (isModLoaded("psychedelicraft")) { + Psychedelicraft = true; + Logger.INFO("Components enabled for: Psychedelicraft"); + totalMods++; + } + if (isModLoaded("ImmersiveEngineering")) { + ImmersiveEngineering = true; + Logger.INFO("Components enabled for: ImmersiveEngineering"); + totalMods++; + } + if (isModLoaded("ExtraBees")) { + ExtraBees = true; + Logger.INFO("Components enabled for: ExtraBees"); + totalMods++; + } + if (isModLoaded("ThermalFoundation") == false) { + ThermalFoundation = false; + Logger.INFO("Components enabled for: ThermalFoundation - This feature will disable itself if you add TF."); + totalMods++; + } else if (isModLoaded("ThermalFoundation")) { + ThermalFoundation = true; + Logger.INFO( + "Components disabled for: ThermalFoundation - This feature will enable itself if you remove TF."); + // totalMods++; + } + if (isModLoaded("ihl")) { + IHL = true; + Logger.INFO("Components enabled for: IHL"); + totalMods++; + } + if (isModLoaded("Baubles")) { + Baubles = true; + Logger.INFO("Components enabled for: Baubles"); + totalMods++; + } + if (isModLoaded("GalacticraftCore")) { + GalacticraftCore = true; + Logger.INFO("Components enabled for: Galacticraft Core"); + totalMods++; + } + if (isModLoaded("OpenComputers")) { + OpenComputers = true; + Logger.INFO("Components enabled for: OpenComputers"); + totalMods++; + } + if (isModLoaded("computronics")) { + Computronics = true; + Logger.INFO( + "Components disabled for: Computronics - This feature will enable itself if you remove Computronics."); + totalMods++; + } else { + Logger.INFO( + "Components enabled for: Computronics - This feature will disable itself if you add Computronics."); + } + if (isModLoaded("GTRedtech")) { + RedTech = true; + Logger.INFO("Components enabled for: GTRedtech"); + totalMods++; + } + if (isModLoaded("tectech")) { + TecTech = true; + Logger.INFO("Components enabled for: TecTech"); + totalMods++; + } + if (isModLoaded("kekztech")) { + KekzTech = true; + Logger.INFO("Components enabled for: KekzTech"); + totalMods++; + } + if (isModLoaded("witchery")) { + Witchery = true; + Logger.INFO("Components enabled for: Witchery"); + totalMods++; + } + if (isModLoaded("RIO")) { + RemoteIO = true; + Logger.INFO("Components enabled for: RemoteIO"); + totalMods++; + } + if (isModLoaded("ExtraTrees")) { + ExtraTrees = true; + Logger.INFO("Components enabled for: ExtraTrees"); + totalMods++; + } + Logger.INFO("Content found for " + totalMods + " mods"); + } - public static String getModVersion(final String modName){ - final String ver = cpw.mods.fml.common.FMLCommonHandler.instance().findContainerFor(modName).getVersion(); - return ver; - } - - private static final HashMap mLoadedModCache = new HashMap(); + public static String getModVersion(final String modName) { + final String ver = cpw.mods.fml.common.FMLCommonHandler.instance() + .findContainerFor(modName) + .getVersion(); + return ver; + } - public static boolean isModLoaded(String aModName) { - Boolean aResult = mLoadedModCache.get(aModName); - if (aResult == null) { - boolean aTemp = Loader.isModLoaded(aModName); - mLoadedModCache.put(aModName, aTemp); - aResult = aTemp; - } - return aResult; - } + private static final HashMap mLoadedModCache = new HashMap(); + public static boolean isModLoaded(String aModName) { + Boolean aResult = mLoadedModCache.get(aModName); + if (aResult == null) { + boolean aTemp = Loader.isModLoaded(aModName); + mLoadedModCache.put(aModName, aTemp); + aResult = aTemp; + } + return aResult; + } } diff --git a/src/main/java/gtPlusPlus/core/lib/VanillaColours.java b/src/main/java/gtPlusPlus/core/lib/VanillaColours.java index 9a7a82cb1f..19e9d1c735 100644 --- a/src/main/java/gtPlusPlus/core/lib/VanillaColours.java +++ b/src/main/java/gtPlusPlus/core/lib/VanillaColours.java @@ -3,26 +3,39 @@ package gtPlusPlus.core.lib; import gtPlusPlus.core.util.Utils; public enum VanillaColours { + BONE_MEAL(249, 255, 254), + INK_BLACK(29, 29, 33), + COCOA_BEANS(131, 84, 50), + LAPIS_LAZULI(60, 68, 170), + DYE_WHITE(249, 255, 254), + DYE_BLACK(29, 29, 33), + DYE_RED(176, 46, 38), + DYE_GREEN(94, 124, 22), + DYE_CYAN(22, 156, 156), + DYE_PINK(243, 139, 170), + DYE_LIME(128, 199, 31), + DYE_YELLOW(254, 216, 61), + DYE_ORANGE(249, 128, 29), + DYE_BROWN(131, 84, 50), + DYE_LIGHT_BLUE(58, 179, 218), + DYE_LIGHT_PURPLE(199, 78, 189), + DYE_LIGHT_GRAY(157, 157, 151), + DYE_DARK_BLUE(60, 68, 170), + DYE_DARK_PURPLE(137, 50, 184), + DYE_DARK_GRAY(71, 79, 82); + private final int r, g, b; - BONE_MEAL(249, 255, 254), INK_BLACK(29, 29, 33), COCOA_BEANS(131, 84, 50), LAPIS_LAZULI(60, 68, 170), - DYE_WHITE(249, 255, 254), DYE_BLACK(29, 29, 33), DYE_RED(176, 46, 38), DYE_GREEN(94, 124, 22), - DYE_CYAN(22, 156, 156), DYE_PINK(243, 139, 170), DYE_LIME(128, 199, 31), DYE_YELLOW(254, 216, 61), - DYE_ORANGE(249, 128, 29), DYE_BROWN(131, 84, 50), DYE_LIGHT_BLUE(58, 179, 218), DYE_LIGHT_PURPLE(199, 78, 189), - DYE_LIGHT_GRAY(157, 157, 151), DYE_DARK_BLUE(60, 68, 170), DYE_DARK_PURPLE(137, 50, 184), DYE_DARK_GRAY(71, 79, 82); + private VanillaColours(int aR, int aG, int aB) { + r = aR; + g = aG; + b = aB; + } - private final int r, g, b; + public short[] getAsShort() { + return new short[] {(short) r, (short) g, (short) b}; + } - private VanillaColours(int aR, int aG, int aB) { - r = aR; - g = aG; - b = aB; - } - - public short[] getAsShort() { - return new short[] { (short) r, (short) g, (short) b }; - } - - public int getAsInt() { - return Utils.rgbtoHexValue(r, g, b); - } + public int getAsInt() { + return Utils.rgbtoHexValue(r, g, b); + } } diff --git a/src/main/java/gtPlusPlus/core/material/ALLOY.java b/src/main/java/gtPlusPlus/core/material/ALLOY.java index 5283df8205..d4baa1dab1 100644 --- a/src/main/java/gtPlusPlus/core/material/ALLOY.java +++ b/src/main/java/gtPlusPlus/core/material/ALLOY.java @@ -1,1028 +1,993 @@ package gtPlusPlus.core.material; import gregtech.api.enums.Materials; - import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.util.minecraft.MaterialUtils; public final class ALLOY { - //Just some GT Alloys that I need within mine. - public static final Material BRONZE = MaterialUtils.generateMaterialFromGtENUM(Materials.Bronze); - public static final Material STEEL = MaterialUtils.generateMaterialFromGtENUM(Materials.Steel); - public static final Material STEEL_BLACK = MaterialUtils.generateMaterialFromGtENUM(Materials.BlackSteel); - public static final Material INVAR = MaterialUtils.generateMaterialFromGtENUM(Materials.Invar); - public static final Material KANTHAL = MaterialUtils.generateMaterialFromGtENUM(Materials.Kanthal); - public static final Material NICHROME = MaterialUtils.generateMaterialFromGtENUM(Materials.Nichrome); - public static final Material TUNGSTENSTEEL = MaterialUtils.generateMaterialFromGtENUM(Materials.TungstenSteel); - public static final Material STAINLESS_STEEL = MaterialUtils.generateMaterialFromGtENUM(Materials.StainlessSteel); - public static final Material OSMIRIDIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Osmiridium); - - public static final Material ENERGYCRYSTAL = new Material( - "Energy Crystal", //Material Name - MaterialState.SOLID, //State - new short[]{228, 255, 0, 0}, //Material Colour - 4660, //Melting Point in C - 5735, //Boiling Point in C - 90, //Protons - 40, //Neutrons - true, //Uses Blast furnace? - "⬟ ⯂ ⬢ ⬣ ⯃ ⯄", - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().AER, 5), - new MaterialStack(ELEMENT.getInstance().IGNIS, 5), - new MaterialStack(ELEMENT.getInstance().TERRA, 5), - new MaterialStack(ELEMENT.getInstance().AQUA, 5) - }); - - public static final Material BLOODSTEEL = new Material( - "Blood Steel", //Material Name - MaterialState.SOLID, //State - new short[]{142, 28, 0, 0}, //Material Colour - 2500, //Melting Point in C - 0, //Boiling Point in C - 100, //Protons - 100, //Neutrons - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ALLOY.STEEL, 5), - new MaterialStack(ELEMENT.getInstance().IGNIS, 5) - }); - - public static final Material STABALLOY = new Material( - "Staballoy", //Material Name - MaterialState.SOLID, //State - new short[]{68, 75, 66, 0}, //Material Colour - 3450, //Melting Point in C - -1, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().URANIUM238, 9), - new MaterialStack(ELEMENT.getInstance().TITANIUM, 1) - }); - - public static final Material TANTALLOY_60 = new Material( - "Tantalloy-60", //Material Name - MaterialState.SOLID, //State - new short[]{213, 231, 237, 0}, //Material Colour - 3025, //Melting Point in C - -1, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().TUNGSTEN, 4), - new MaterialStack(ELEMENT.getInstance().TANTALUM, 46) - }); - - public static final Material TANTALLOY_61 = new Material( - "Tantalloy-61", //Material Name - MaterialState.SOLID, //State - new short[]{193, 211, 217, 0}, //Material Colour - 3030, //Melting Point in C - -1, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ALLOY.TANTALLOY_60, 2), - new MaterialStack(ELEMENT.getInstance().TITANIUM, 12), - new MaterialStack(ELEMENT.getInstance().YTTRIUM, 8) - }); - - public static final Material TUMBAGA = new Material( - "Tumbaga", //Material Name - MaterialState.SOLID, //State - new short[]{255,178,15, 0}, //Material Colour - -1, - -1, - -1, - -1, - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().GOLD, 70), - new MaterialStack(ELEMENT.getInstance().COPPER, 30) - }); - - public static final Material POTIN = new Material( - "Potin", //Material Name - MaterialState.SOLID, //State - new short[]{201,151,129, 0}, //Material Colour - -1, - -1, - -1, - -1, - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().LEAD, 40), - new MaterialStack(ALLOY.BRONZE, 40), - new MaterialStack(ELEMENT.getInstance().TIN, 20) - }); - - /*public static final Material BEDROCKIUM = new Material( - "Bedrockium", //Material Name - new short[]{32, 32, 32, 0}, //Material Colour - 7735, //Melting Point in C - 0, //Boiling Point in C - 100, //Protons - 100, //Neutrons - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - null);*/ - - public static final Material INCONEL_625 = new Material( - "Inconel-625", //Material Name - MaterialState.SOLID, //State - new short[]{128, 200, 128, 0}, //Material Colour - 2425, //Melting Point in C - 3758, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().NICKEL, 3), - new MaterialStack(ELEMENT.getInstance().CHROMIUM, 7), - new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 10), - new MaterialStack(INVAR, 10), - new MaterialStack(NICHROME, 13) - }); - - public static final Material INCONEL_690 = new Material( - "Inconel-690", //Material Name - MaterialState.SOLID, //State - new short[]{118, 220, 138, 0}, //Material Colour - 3425, //Melting Point in C - 4895, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().CHROMIUM, 5), - new MaterialStack(ELEMENT.getInstance().NIOBIUM, 10), - new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 10), - new MaterialStack(NICHROME, 15) - }); - - public static final Material INCONEL_792 = new Material( - "Inconel-792", //Material Name - MaterialState.SOLID, //State - new short[]{108, 240, 118, 0}, //Material Colour - 3425, //Melting Point in C - 6200, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().NICKEL, 20), - new MaterialStack(ELEMENT.getInstance().NIOBIUM, 10), - new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 20), - new MaterialStack(NICHROME, 10) - }); - - public static final Material NITINOL_60 = new Material( - "Nitinol 60", //Material Name - MaterialState.SOLID, //State - null, //Material Colour - 5651, //Melting Point in C - 8975, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().NICKEL, 40), - new MaterialStack(ELEMENT.getInstance().TITANIUM, 60) - }); - - - public static final Material ZERON_100 = new Material( - "Zeron-100", //Material Name - MaterialState.SOLID, //State - new short[]{180, 180, 20, 0}, //Material Colour - 6100, - 9785, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().CHROMIUM, 26), - new MaterialStack(ELEMENT.getInstance().NICKEL, 6), - new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 4), - new MaterialStack(ELEMENT.getInstance().COPPER, 20), - new MaterialStack(ELEMENT.getInstance().TUNGSTEN, 4), - new MaterialStack(ALLOY.STEEL, 40) - }); - - public static final Material MARAGING250 = new Material( - "Maraging Steel 250", //Material Name - MaterialState.SOLID, //State - null, //Material Colour - 2413, //Melting Point in C - 4555, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ALLOY.STEEL, 64), - new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 4), - new MaterialStack(ELEMENT.getInstance().TITANIUM, 4), - new MaterialStack(ELEMENT.getInstance().NICKEL, 16), - new MaterialStack(ELEMENT.getInstance().COBALT, 8), - }); - - public static final Material MARAGING300 = new Material( - "Maraging Steel 300", //Material Name - MaterialState.SOLID, //State - null, //Material Colour - 2413, //Melting Point in C - 4555, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ALLOY.STEEL, 64), - new MaterialStack(ELEMENT.getInstance().TITANIUM, 4), - new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 4), - new MaterialStack(ELEMENT.getInstance().NICKEL, 16), - new MaterialStack(ELEMENT.getInstance().COBALT, 8), - }); - - public static final Material MARAGING350 = new Material( - "Maraging Steel 350", //Material Name - MaterialState.SOLID, //State - null, //Material Colour - 2413, //Melting Point in C - 4555, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ALLOY.STEEL, 64), - new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 4), - new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 4), - new MaterialStack(ELEMENT.getInstance().NICKEL, 16), - new MaterialStack(ELEMENT.getInstance().COBALT, 8), - }); - - public static final Material AQUATIC_STEEL = new Material( - "Watertight Steel", //Material Name - MaterialState.SOLID, //State - new short[] {120, 120, 180}, //Material Colour - 2673, //Melting Point in C - 4835, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ALLOY.STEEL, 60), - new MaterialStack(ELEMENT.getInstance().CARBON, 10), - new MaterialStack(ELEMENT.getInstance().MANGANESE, 5), - new MaterialStack(ELEMENT.getInstance().SILICON, 10), - new MaterialStack(ELEMENT.getInstance().PHOSPHORUS, 5), - new MaterialStack(ELEMENT.getInstance().SULFUR, 5), - new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 5) - }); - - public static final Material STELLITE = new Material( - "Stellite", //Material Name - MaterialState.SOLID, //State - null, //Material Colour - 4310, //Melting Point in C - 6250, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().COBALT, 35), - new MaterialStack(ELEMENT.getInstance().CHROMIUM, 35), - new MaterialStack(ELEMENT.getInstance().MANGANESE, 20), - new MaterialStack(ELEMENT.getInstance().TITANIUM, 10) - }); - - public static final Material TALONITE = new Material( - "Talonite", //Material Name - MaterialState.SOLID, //State - null, //Material Colour - 3454, //Melting Point in C - 5500, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().COBALT, 40), - new MaterialStack(ELEMENT.getInstance().CHROMIUM, 30), - new MaterialStack(ELEMENT.getInstance().PHOSPHORUS, 20), - new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 10) - }); - - public static final Material HASTELLOY_W = new Material( - "Hastelloy-W", //Material Name - MaterialState.SOLID, //State - null, //Material Colour - 3350, //Melting Point in C - 5755, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().IRON, 06), - new MaterialStack(ELEMENT.getInstance().COBALT, 2), - new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 24), - new MaterialStack(ELEMENT.getInstance().CHROMIUM, 6), - new MaterialStack(ELEMENT.getInstance().NICKEL, 62) - }); - - public static final Material HASTELLOY_X = new Material( - "Hastelloy-X", //Material Name - MaterialState.SOLID, //State - null, //Material Colour - 3350, //Melting Point in C - 5755, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().IRON, 18), - new MaterialStack(ELEMENT.getInstance().MANGANESE, 2), - new MaterialStack(ELEMENT.getInstance().SILICON, 2), - new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 8), - new MaterialStack(ELEMENT.getInstance().CHROMIUM, 22), - new MaterialStack(ELEMENT.getInstance().NICKEL, 48) - }); - - public static final Material HASTELLOY_N = new Material( - "Hastelloy-N", //Material Name - MaterialState.SOLID, //State - null, //Material Colour - 4350, //Melting Point in C - 6875, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().YTTRIUM, 8), - new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 16), - new MaterialStack(ELEMENT.getInstance().CHROMIUM, 8), - new MaterialStack(ELEMENT.getInstance().TITANIUM, 8), - new MaterialStack(ELEMENT.getInstance().NICKEL, 60) - }); - - public static final Material HASTELLOY_C276 = new Material( - "Hastelloy-C276", //Material Name - MaterialState.SOLID, //State - null, //Material Colour - 4350, //Melting Point in C - 6520, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().COBALT, 2), - new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 16), - new MaterialStack(ELEMENT.getInstance().TUNGSTEN, 2), - new MaterialStack(ELEMENT.getInstance().COPPER, 2), - new MaterialStack(ELEMENT.getInstance().CHROMIUM, 14), - new MaterialStack(ELEMENT.getInstance().NICKEL, 64) - }); - - public static final Material INCOLOY_020 = new Material( - "Incoloy-020", //Material Name - MaterialState.SOLID, //State - null, //Material Colour - 3425, //Melting Point in C - 5420, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().IRON, 40), - new MaterialStack(ELEMENT.getInstance().COPPER, 4), - new MaterialStack(ELEMENT.getInstance().CHROMIUM, 20), - new MaterialStack(ELEMENT.getInstance().NICKEL, 36) - }); - - public static final Material INCOLOY_DS = new Material( - "Incoloy-DS", //Material Name - MaterialState.SOLID, //State - null, //Material Colour - 3425, //Melting Point in C - 5420, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().IRON, 46), - new MaterialStack(ELEMENT.getInstance().COBALT, 18), - new MaterialStack(ELEMENT.getInstance().CHROMIUM, 18), - new MaterialStack(ELEMENT.getInstance().NICKEL, 18) - }); - - public static final Material INCOLOY_MA956 = new Material( - "Incoloy-MA956", //Material Name - MaterialState.SOLID, //State - null, //Material Colour - 4425, //Melting Point in C - 6875, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().IRON, 64), - new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 12), - new MaterialStack(ELEMENT.getInstance().CHROMIUM, 20), - new MaterialStack(ELEMENT.getInstance().YTTRIUM, 4) - }); - - public static final Material TUNGSTEN_CARBIDE = new Material( - "Tungsten Carbide", //Material Name - MaterialState.SOLID, //State - new short[]{44, 44, 44, 0}, //Material Colour - 3422, //Melting Point in C - -1, - -1, - -1, - true, //Uses Blast furnace? - false, //Generate cells - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().CARBON, 50), - new MaterialStack(ELEMENT.getInstance().TUNGSTEN, 50) - }); - - public static final Material TUNGSTEN_TITANIUM_CARBIDE = new Material( - "Tungsten Titanium Carbide", //Material Name - MaterialState.SOLID, //State - null, - 4422, //Melting Point in C - -1, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(TUNGSTEN_CARBIDE, 70), - new MaterialStack(ELEMENT.getInstance().TITANIUM, 30) - }); - - public static final Material SILICON_CARBIDE = new Material( - "Silicon Carbide", //Material Name - MaterialState.SOLID, //State - new short[]{40, 48, 36, 0}, //Material Colour - 1414, //Melting Point in C - -1, - -1, - -1, - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().SILICON, 50), - new MaterialStack(ELEMENT.getInstance().CARBON, 50) - }); - - public static final Material TANTALUM_CARBIDE = new Material( - "Tantalum Carbide", //Material Name - MaterialState.SOLID, //State - new short[]{139, 136, 120, 0}, //Material Colour - 2980, //Melting Point in C - -1, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().TANTALUM, 50), - new MaterialStack(ELEMENT.getInstance().CARBON, 50) - }); - - public static final Material ZIRCONIUM_CARBIDE = new Material( - "Zirconium Carbide", //Material Name - MaterialState.SOLID, //State - new short[]{222, 202, 180, 0}, //Material Colour - 1555, //Melting Point in C - -1, - -1, - -1, - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().ZIRCONIUM, 50), - new MaterialStack(ELEMENT.getInstance().CARBON, 50) - }); - - public static final Material NIOBIUM_CARBIDE = new Material( - "Niobium Carbide", //Material Name - MaterialState.SOLID, //State - new short[]{205, 197, 191, 0}, //Material Colour - 2477, //Melting Point in C - -1, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().NIOBIUM, 50), - new MaterialStack(ELEMENT.getInstance().CARBON, 50) - }); - - public static final Material ARCANITE = new Material( - "Arcanite", //Material Name - MaterialState.SOLID, //State - null, - 5666, //Melting Point in C - 9875, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().THORIUM232, 40), - new MaterialStack(ENERGYCRYSTAL, 40), - new MaterialStack(ELEMENT.getInstance().ORDO, 10), - new MaterialStack(ELEMENT.getInstance().PERDITIO, 10) - }); - - public static final Material LEAGRISIUM = new Material( - "Grisium", //Material Name - MaterialState.SOLID, //State - new short[]{53, 93, 106, 0}, //Material Colour - 3850, //Melting Point in C - 5550, //Boiling Point in C - 96, //Protons - 128, //Neutrons - true, //Uses Blast furnace? - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().TITANIUM, 18), - new MaterialStack(ELEMENT.getInstance().CARBON, 18), - new MaterialStack(ELEMENT.getInstance().POTASSIUM, 18), - new MaterialStack(ELEMENT.getInstance().LITHIUM, 18), - new MaterialStack(ELEMENT.getInstance().SULFUR, 18), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 10) - }); //Material Stacks with Percentage of required elements. - - public static final Material EGLIN_STEEL_BASE = new Material( - "Eglin Steel Base Compound", //Material Name - MaterialState.SOLID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, - -1, - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - - new MaterialStack(ELEMENT.getInstance().IRON, 12), - new MaterialStack(KANTHAL, 3), - new MaterialStack(INVAR, 15) - }); - - public static final Material EGLIN_STEEL = new Material( - "Eglin Steel", //Material Name - MaterialState.SOLID, //State - new short[]{139,69,19, 0}, //Material Colour - 1048, //Melting Point in C - 1973, //Boiling Point in C - -1, - -1, - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ALLOY.EGLIN_STEEL_BASE, 10), - new MaterialStack(ELEMENT.getInstance().SULFUR, 1), - new MaterialStack(ELEMENT.getInstance().SILICON, 4), - new MaterialStack(ELEMENT.getInstance().CARBON, 1) - }); - - public static final Material HG1223 = new Material( - "HG-1223", //Material Name - MaterialState.LIQUID, //State - new short[]{39,85,159, 0}, //Material Colour - 6357, //Melting Point in C - 8563, //Boiling Point in C - -1, - -1, - false, //Uses Blast furnace? - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().MERCURY, 1), - new MaterialStack(ELEMENT.getInstance().BARIUM, 2), - new MaterialStack(ELEMENT.getInstance().CALCIUM, 2), - new MaterialStack(ELEMENT.getInstance().COPPER, 3), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 8) - }); - - - public static final Material HS188A = new Material( - "HS188-A", //Material Name - MaterialState.SOLID, //State - null, //Material Colour - 4870, //Melting Point in C - 7550, //Boiling Point in C - -1, //Protons - -1, //Neutrons - true, //Uses Blast furnace? - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().COBALT, 20), - new MaterialStack(ELEMENT.getInstance().HAFNIUM, 20), - new MaterialStack(TALONITE, 16), - new MaterialStack(ELEMENT.getInstance().RHENIUM, 10), - new MaterialStack(NIOBIUM_CARBIDE, 10), - new MaterialStack(HASTELLOY_X, 8), - new MaterialStack(TUNGSTENSTEEL, 8), - new MaterialStack(ZIRCONIUM_CARBIDE, 8), - }); //Material Stacks with Percentage of required elements. - - /** - * Stargate Materials - #D2FFA9 210, 255, 170 - */ - - public static final Material TRINIUM_TITANIUM = new Material( - "Trinium Titanium Alloy", //Material Name - MaterialState.SOLID, //State - null, //Material Colour - 3750, //Melting Point in C - 7210, //Boiling Point in C - -1, - -1, - true, //Uses Blast furnace? - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().TRINIUM_REFINED, 3), - new MaterialStack(ELEMENT.getInstance().TITANIUM, 7) - }); - public static final Material TRINIUM_NAQUADAH = new Material( - "Trinium Naquadah Alloy", //Material Name - MaterialState.SOLID, //State - null, //Material Colour - 4200, //Melting Point in C - 7400, //Boiling Point in C - -1, - -1, - false, //Uses Blast furnace? - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().TRINIUM_REFINED, 5), - new MaterialStack(ELEMENT.getInstance().NAQUADAH, 9) - }); - public static final Material TRINIUM_NAQUADAH_CARBON = new Material( - "Trinium Naquadah Carbonite", //Material Name - MaterialState.SOLID, //State - null, //Material Colour - 6500, //Melting Point in C - 9000, //Boiling Point in C - -1, - -1, - true, //Uses Blast furnace? - new MaterialStack[]{ - new MaterialStack(TRINIUM_NAQUADAH, 9), - new MaterialStack(ELEMENT.getInstance().CARBON, 1) - }); - - public static final Material TRINIUM_REINFORCED_STEEL = new Material( - "Arceus Alloy 2B", //Material Name - MaterialState.SOLID, //State - new short[]{205, 197, 23, 0}, //Material Colour - 7555, //Melting Point in C - 12350, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().TRINIUM_REFINED, 30), - new MaterialStack(ALLOY.MARAGING350, 40), - new MaterialStack(ALLOY.TUNGSTENSTEEL, 20), - new MaterialStack(ALLOY.OSMIRIDIUM, 10), - new MaterialStack(ELEMENT.getInstance().STRONTIUM, 10) - }); - - - - /* - * Witchery Material - */ - - public static final Material KOBOLDITE = new Material( - "Koboldite", //Material Name - MaterialState.SOLID, //State - new short[]{80, 210, 255, 0}, //Material Colour - -1, //Melting Point in C - -1, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().NICKEL, 35), - new MaterialStack(ELEMENT.getInstance().THAUMIUM, 30), - new MaterialStack(ELEMENT.getInstance().IRON, 35) - }); - - - /* - * Top Tier Alloys - */ - - public static final Material HELICOPTER = new Material( - "HeLiCoPtEr", //Material Name - MaterialState.SOLID, //State - null, //Material Colour - 5763, - 8192, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().HELIUM, 20), - new MaterialStack(ELEMENT.getInstance().LITHIUM, 20), - new MaterialStack(ELEMENT.getInstance().COBALT, 20), - new MaterialStack(ELEMENT.getInstance().PLATINUM, 20), - new MaterialStack(ELEMENT.getInstance().ERBIUM, 20) - }); - - //0lafe Compound - public static final Material LAFIUM = new Material( - "Lafium Compound", //Material Name - MaterialState.SOLID, //State - null, //Material Colour - 6350, //Melting Point in C - 9865, //Boiling Point in C - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ALLOY.HASTELLOY_N, 8), - new MaterialStack(ELEMENT.getInstance().NAQUADAH, 4), - new MaterialStack(ELEMENT.getInstance().SAMARIUM, 2), - new MaterialStack(ELEMENT.getInstance().TUNGSTEN, 4), - new MaterialStack(ELEMENT.getInstance().ARGON, 2), - new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 6), - new MaterialStack(ELEMENT.getInstance().NICKEL, 8), - new MaterialStack(ELEMENT.getInstance().CARBON, 2) - }); - - //Cinobi Alloy - public static final Material CINOBITE = new Material( - "Cinobite A243", //Material Name - MaterialState.SOLID, //State - null, //Material Colour - 7350, //Melting Point in C - 12565, //Boiling Point in C - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ALLOY.ZERON_100, 16), - new MaterialStack(ELEMENT.getInstance().NAQUADRIA, 7), - new MaterialStack(ELEMENT.getInstance().GADOLINIUM, 5), - new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 3), - new MaterialStack(ELEMENT.getInstance().MERCURY, 2), - new MaterialStack(ELEMENT.getInstance().TIN, 2), - new MaterialStack(ELEMENT.getInstance().TITANIUM, 12), - new MaterialStack(ALLOY.OSMIRIDIUM, 6) - }); - - //Piky Alloy - public static final Material PIKYONIUM = new Material( - "Pikyonium 64B", //Material Name - MaterialState.SOLID, //State - new short[]{52, 103, 186, 0}, //Material Colour - 6850, //Melting Point in C - 11765, //Boiling Point in C - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ALLOY.INCONEL_792, 16), - new MaterialStack(ALLOY.EGLIN_STEEL, 10), - new MaterialStack(ELEMENT.getInstance().NAQUADAH_ENRICHED, 8), - new MaterialStack(ELEMENT.getInstance().CERIUM, 6), - new MaterialStack(ELEMENT.getInstance().ANTIMONY, 4), - new MaterialStack(ELEMENT.getInstance().PLATINUM, 4), - new MaterialStack(ELEMENT.getInstance().YTTERBIUM, 2), - new MaterialStack(ALLOY.TUNGSTENSTEEL, 8) - }); - - //Piky Alloy - public static final Material ABYSSAL = new Material( - "Abyssal Alloy", //Material Name - MaterialState.SOLID, //State - null, //Material Colour - 9650, //Melting Point in C - 13765, //Boiling Point in C - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ALLOY.STAINLESS_STEEL, 10), - new MaterialStack(ALLOY.TUNGSTEN_CARBIDE, 10), - new MaterialStack(ALLOY.NICHROME, 10), - new MaterialStack(ALLOY.BRONZE, 10), - new MaterialStack(ALLOY.INCOLOY_MA956, 10), - new MaterialStack(ELEMENT.getInstance().IODINE, 2), - new MaterialStack(ELEMENT.getInstance().RADON, 2), - new MaterialStack(ELEMENT.getInstance().GERMANIUM, 2), - }); - - //Alkalus Alloy - public static final Material LAURENIUM = new Material( - "Laurenium", //Material Name - MaterialState.SOLID, //State - new short[] {244, 168, 255, 0}, //Material Colour - 6825, //Melting Point in C - 11355, //Boiling Point in C - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ALLOY.EGLIN_STEEL, 40), - new MaterialStack(ELEMENT.getInstance().INDIUM, 10), - new MaterialStack(ELEMENT.getInstance().CHROMIUM, 20), - new MaterialStack(ELEMENT.getInstance().DYSPROSIUM, 5), - new MaterialStack(ELEMENT.getInstance().RHENIUM, 5), - }); - - - //Bot Alloy - public static final Material BOTMIUM = new Material( - "Botmium", //Material Name - MaterialState.SOLID, //State - new short[] {80, 160, 80, 0}, //Material Colour - 8220, //Melting Point in C - 10540, //Boiling Point in C - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ALLOY.NITINOL_60, 2), - new MaterialStack(ELEMENT.getInstance().OSMIUM, 12), - new MaterialStack(ELEMENT.getInstance().RUTHENIUM, 12), - new MaterialStack(ELEMENT.getInstance().THALLIUM, 6), - }); - - //Titansteel - public static final Material TITANSTEEL = new Material( - "Titansteel", //Material Name - MaterialState.SOLID, //State - null, //Material Colour - 8250, //Melting Point in C - 11765, //Boiling Point in C - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ALLOY.TUNGSTEN_TITANIUM_CARBIDE, 3), - new MaterialStack(ELEMENT.getInstance().IGNIS, 1), - new MaterialStack(ELEMENT.getInstance().TERRA, 1), - new MaterialStack(ELEMENT.getInstance().PERDITIO, 1), - }); - - - public static final Material OCTIRON = new Material( - "Octiron", //Material Name - MaterialState.SOLID, //State - null, - 9120, //Melting Point in C - 14200, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ARCANITE, 30), - new MaterialStack(TITANSTEEL, 30), - new MaterialStack(ENERGYCRYSTAL, 5), - new MaterialStack(STEEL_BLACK, 10), - new MaterialStack(ELEMENT.getInstance().THAUMIUM, 25) - }); - - - - public static final Material BLACK_TITANIUM = new Material( - "Black Titanium", //Material Name - MaterialState.SOLID, //State - null, //Material Colour - Materials.Titanium.mMeltingPoint*4, //Melting Point in C - Materials.Titanium.mMeltingPoint*16, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().TITANIUM, 55), - new MaterialStack(ELEMENT.getInstance().LANTHANUM, 12), - new MaterialStack(ELEMENT.getInstance().TUNGSTEN, 8), - new MaterialStack(ELEMENT.getInstance().COBALT, 6), - new MaterialStack(ELEMENT.getInstance().MANGANESE, 4), - new MaterialStack(ELEMENT.getInstance().PHOSPHORUS, 4), - new MaterialStack(ELEMENT.getInstance().PALLADIUM, 4), - new MaterialStack(ELEMENT.getInstance().NIOBIUM, 2), - new MaterialStack(ELEMENT.getInstance().ARGON, 5) - }); - - public static final Material BABBIT_ALLOY = new Material( - "Babbit Alloy", //Material Name - MaterialState.SOLID, //State - null, //Material Colour - 268, //Melting Point in C - 589, - -1, - -1, - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().TIN, 10), - new MaterialStack(ELEMENT.getInstance().LEAD, 72), - new MaterialStack(ELEMENT.getInstance().ANTIMONY, 16), - new MaterialStack(ELEMENT.getInstance().ARSENIC, 2) - }); - - public static final Material INDALLOY_140 = new Material( - "Indalloy 140", //Material Name - MaterialState.SOLID, //State - null, //Material Colour - 5200, //Melting Point in C - 6500, - -1, - -1, - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().BISMUTH, 47), - new MaterialStack(ELEMENT.getInstance().LEAD, 25), - new MaterialStack(ELEMENT.getInstance().TIN, 13), - new MaterialStack(ELEMENT.getInstance().CADMIUM, 10), - new MaterialStack(ELEMENT.getInstance().INDIUM, 5) - }); - - - - - - - - - - - - - - - - - //Quantum - public static final Material QUANTUM = new Material( - "Quantum", //Material Name - MaterialState.SOLID, //State - null, //Material Colour - 10500, //Melting Point in C - 25000, //Boiling Point in C - 150, //Protons - 200, //Neutrons - true, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ALLOY.STELLITE, 15), - new MaterialStack(ALLOY.ENERGYCRYSTAL, 5), - new MaterialStack(ALLOY.SILICON_CARBIDE, 5), - new MaterialStack(ELEMENT.getInstance().GALLIUM, 5), - new MaterialStack(ELEMENT.getInstance().AMERICIUM, 5), - new MaterialStack(ELEMENT.getInstance().PALLADIUM, 5), - new MaterialStack(ELEMENT.getInstance().BISMUTH, 5), - new MaterialStack(ELEMENT.getInstance().GERMANIUM, 5) - }); - - - + // Just some GT Alloys that I need within mine. + public static final Material BRONZE = MaterialUtils.generateMaterialFromGtENUM(Materials.Bronze); + public static final Material STEEL = MaterialUtils.generateMaterialFromGtENUM(Materials.Steel); + public static final Material STEEL_BLACK = MaterialUtils.generateMaterialFromGtENUM(Materials.BlackSteel); + public static final Material INVAR = MaterialUtils.generateMaterialFromGtENUM(Materials.Invar); + public static final Material KANTHAL = MaterialUtils.generateMaterialFromGtENUM(Materials.Kanthal); + public static final Material NICHROME = MaterialUtils.generateMaterialFromGtENUM(Materials.Nichrome); + public static final Material TUNGSTENSTEEL = MaterialUtils.generateMaterialFromGtENUM(Materials.TungstenSteel); + public static final Material STAINLESS_STEEL = MaterialUtils.generateMaterialFromGtENUM(Materials.StainlessSteel); + public static final Material OSMIRIDIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Osmiridium); + + public static final Material ENERGYCRYSTAL = new Material( + "Energy Crystal", // Material Name + MaterialState.SOLID, // State + new short[] {228, 255, 0, 0}, // Material Colour + 4660, // Melting Point in C + 5735, // Boiling Point in C + 90, // Protons + 40, // Neutrons + true, // Uses Blast furnace? + "⬟ ⯂ ⬢ ⬣ ⯃ ⯄", + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().AER, 5), + new MaterialStack(ELEMENT.getInstance().IGNIS, 5), + new MaterialStack(ELEMENT.getInstance().TERRA, 5), + new MaterialStack(ELEMENT.getInstance().AQUA, 5) + }); + + public static final Material BLOODSTEEL = new Material( + "Blood Steel", // Material Name + MaterialState.SOLID, // State + new short[] {142, 28, 0, 0}, // Material Colour + 2500, // Melting Point in C + 0, // Boiling Point in C + 100, // Protons + 100, // Neutrons + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] {new MaterialStack(ALLOY.STEEL, 5), new MaterialStack(ELEMENT.getInstance().IGNIS, 5)}); + + public static final Material STABALLOY = new Material( + "Staballoy", // Material Name + MaterialState.SOLID, // State + new short[] {68, 75, 66, 0}, // Material Colour + 3450, // Melting Point in C + -1, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().URANIUM238, 9), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 1) + }); + + public static final Material TANTALLOY_60 = new Material( + "Tantalloy-60", // Material Name + MaterialState.SOLID, // State + new short[] {213, 231, 237, 0}, // Material Colour + 3025, // Melting Point in C + -1, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().TUNGSTEN, 4), + new MaterialStack(ELEMENT.getInstance().TANTALUM, 46) + }); + + public static final Material TANTALLOY_61 = new Material( + "Tantalloy-61", // Material Name + MaterialState.SOLID, // State + new short[] {193, 211, 217, 0}, // Material Colour + 3030, // Melting Point in C + -1, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ALLOY.TANTALLOY_60, 2), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 12), + new MaterialStack(ELEMENT.getInstance().YTTRIUM, 8) + }); + + public static final Material TUMBAGA = new Material( + "Tumbaga", // Material Name + MaterialState.SOLID, // State + new short[] {255, 178, 15, 0}, // Material Colour + -1, + -1, + -1, + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().GOLD, 70), new MaterialStack(ELEMENT.getInstance().COPPER, 30) + }); + + public static final Material POTIN = new Material( + "Potin", // Material Name + MaterialState.SOLID, // State + new short[] {201, 151, 129, 0}, // Material Colour + -1, + -1, + -1, + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().LEAD, 40), + new MaterialStack(ALLOY.BRONZE, 40), + new MaterialStack(ELEMENT.getInstance().TIN, 20) + }); + + /*public static final Material BEDROCKIUM = new Material( + "Bedrockium", //Material Name + new short[]{32, 32, 32, 0}, //Material Colour + 7735, //Melting Point in C + 0, //Boiling Point in C + 100, //Protons + 100, //Neutrons + false, //Uses Blast furnace? + //Material Stacks with Percentage of required elements. + null);*/ + + public static final Material INCONEL_625 = new Material( + "Inconel-625", // Material Name + MaterialState.SOLID, // State + new short[] {128, 200, 128, 0}, // Material Colour + 2425, // Melting Point in C + 3758, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().NICKEL, 3), + new MaterialStack(ELEMENT.getInstance().CHROMIUM, 7), + new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 10), + new MaterialStack(INVAR, 10), + new MaterialStack(NICHROME, 13) + }); + + public static final Material INCONEL_690 = new Material( + "Inconel-690", // Material Name + MaterialState.SOLID, // State + new short[] {118, 220, 138, 0}, // Material Colour + 3425, // Melting Point in C + 4895, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().CHROMIUM, 5), + new MaterialStack(ELEMENT.getInstance().NIOBIUM, 10), + new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 10), + new MaterialStack(NICHROME, 15) + }); + + public static final Material INCONEL_792 = new Material( + "Inconel-792", // Material Name + MaterialState.SOLID, // State + new short[] {108, 240, 118, 0}, // Material Colour + 3425, // Melting Point in C + 6200, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().NICKEL, 20), + new MaterialStack(ELEMENT.getInstance().NIOBIUM, 10), + new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 20), + new MaterialStack(NICHROME, 10) + }); + + public static final Material NITINOL_60 = new Material( + "Nitinol 60", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 5651, // Melting Point in C + 8975, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().NICKEL, 40), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 60) + }); + + public static final Material ZERON_100 = new Material( + "Zeron-100", // Material Name + MaterialState.SOLID, // State + new short[] {180, 180, 20, 0}, // Material Colour + 6100, + 9785, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().CHROMIUM, 26), + new MaterialStack(ELEMENT.getInstance().NICKEL, 6), + new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 4), + new MaterialStack(ELEMENT.getInstance().COPPER, 20), + new MaterialStack(ELEMENT.getInstance().TUNGSTEN, 4), + new MaterialStack(ALLOY.STEEL, 40) + }); + + public static final Material MARAGING250 = new Material( + "Maraging Steel 250", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 2413, // Melting Point in C + 4555, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ALLOY.STEEL, 64), + new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 4), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 4), + new MaterialStack(ELEMENT.getInstance().NICKEL, 16), + new MaterialStack(ELEMENT.getInstance().COBALT, 8), + }); + + public static final Material MARAGING300 = new Material( + "Maraging Steel 300", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 2413, // Melting Point in C + 4555, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ALLOY.STEEL, 64), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 4), + new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 4), + new MaterialStack(ELEMENT.getInstance().NICKEL, 16), + new MaterialStack(ELEMENT.getInstance().COBALT, 8), + }); + + public static final Material MARAGING350 = new Material( + "Maraging Steel 350", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 2413, // Melting Point in C + 4555, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ALLOY.STEEL, 64), + new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 4), + new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 4), + new MaterialStack(ELEMENT.getInstance().NICKEL, 16), + new MaterialStack(ELEMENT.getInstance().COBALT, 8), + }); + + public static final Material AQUATIC_STEEL = new Material( + "Watertight Steel", // Material Name + MaterialState.SOLID, // State + new short[] {120, 120, 180}, // Material Colour + 2673, // Melting Point in C + 4835, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ALLOY.STEEL, 60), + new MaterialStack(ELEMENT.getInstance().CARBON, 10), + new MaterialStack(ELEMENT.getInstance().MANGANESE, 5), + new MaterialStack(ELEMENT.getInstance().SILICON, 10), + new MaterialStack(ELEMENT.getInstance().PHOSPHORUS, 5), + new MaterialStack(ELEMENT.getInstance().SULFUR, 5), + new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 5) + }); + + public static final Material STELLITE = new Material( + "Stellite", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 4310, // Melting Point in C + 6250, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().COBALT, 35), + new MaterialStack(ELEMENT.getInstance().CHROMIUM, 35), + new MaterialStack(ELEMENT.getInstance().MANGANESE, 20), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 10) + }); + + public static final Material TALONITE = new Material( + "Talonite", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 3454, // Melting Point in C + 5500, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().COBALT, 40), + new MaterialStack(ELEMENT.getInstance().CHROMIUM, 30), + new MaterialStack(ELEMENT.getInstance().PHOSPHORUS, 20), + new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 10) + }); + + public static final Material HASTELLOY_W = new Material( + "Hastelloy-W", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 3350, // Melting Point in C + 5755, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().IRON, 06), + new MaterialStack(ELEMENT.getInstance().COBALT, 2), + new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 24), + new MaterialStack(ELEMENT.getInstance().CHROMIUM, 6), + new MaterialStack(ELEMENT.getInstance().NICKEL, 62) + }); + + public static final Material HASTELLOY_X = new Material( + "Hastelloy-X", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 3350, // Melting Point in C + 5755, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().IRON, 18), + new MaterialStack(ELEMENT.getInstance().MANGANESE, 2), + new MaterialStack(ELEMENT.getInstance().SILICON, 2), + new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 8), + new MaterialStack(ELEMENT.getInstance().CHROMIUM, 22), + new MaterialStack(ELEMENT.getInstance().NICKEL, 48) + }); + + public static final Material HASTELLOY_N = new Material( + "Hastelloy-N", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 4350, // Melting Point in C + 6875, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().YTTRIUM, 8), + new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 16), + new MaterialStack(ELEMENT.getInstance().CHROMIUM, 8), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 8), + new MaterialStack(ELEMENT.getInstance().NICKEL, 60) + }); + + public static final Material HASTELLOY_C276 = new Material( + "Hastelloy-C276", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 4350, // Melting Point in C + 6520, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().COBALT, 2), + new MaterialStack(ELEMENT.getInstance().MOLYBDENUM, 16), + new MaterialStack(ELEMENT.getInstance().TUNGSTEN, 2), + new MaterialStack(ELEMENT.getInstance().COPPER, 2), + new MaterialStack(ELEMENT.getInstance().CHROMIUM, 14), + new MaterialStack(ELEMENT.getInstance().NICKEL, 64) + }); + + public static final Material INCOLOY_020 = new Material( + "Incoloy-020", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 3425, // Melting Point in C + 5420, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().IRON, 40), + new MaterialStack(ELEMENT.getInstance().COPPER, 4), + new MaterialStack(ELEMENT.getInstance().CHROMIUM, 20), + new MaterialStack(ELEMENT.getInstance().NICKEL, 36) + }); + + public static final Material INCOLOY_DS = new Material( + "Incoloy-DS", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 3425, // Melting Point in C + 5420, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().IRON, 46), + new MaterialStack(ELEMENT.getInstance().COBALT, 18), + new MaterialStack(ELEMENT.getInstance().CHROMIUM, 18), + new MaterialStack(ELEMENT.getInstance().NICKEL, 18) + }); + + public static final Material INCOLOY_MA956 = new Material( + "Incoloy-MA956", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 4425, // Melting Point in C + 6875, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().IRON, 64), + new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 12), + new MaterialStack(ELEMENT.getInstance().CHROMIUM, 20), + new MaterialStack(ELEMENT.getInstance().YTTRIUM, 4) + }); + + public static final Material TUNGSTEN_CARBIDE = new Material( + "Tungsten Carbide", // Material Name + MaterialState.SOLID, // State + new short[] {44, 44, 44, 0}, // Material Colour + 3422, // Melting Point in C + -1, + -1, + -1, + true, // Uses Blast furnace? + false, // Generate cells + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().CARBON, 50), + new MaterialStack(ELEMENT.getInstance().TUNGSTEN, 50) + }); + + public static final Material TUNGSTEN_TITANIUM_CARBIDE = new Material( + "Tungsten Titanium Carbide", // Material Name + MaterialState.SOLID, // State + null, + 4422, // Melting Point in C + -1, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(TUNGSTEN_CARBIDE, 70), new MaterialStack(ELEMENT.getInstance().TITANIUM, 30) + }); + + public static final Material SILICON_CARBIDE = new Material( + "Silicon Carbide", // Material Name + MaterialState.SOLID, // State + new short[] {40, 48, 36, 0}, // Material Colour + 1414, // Melting Point in C + -1, + -1, + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().SILICON, 50), + new MaterialStack(ELEMENT.getInstance().CARBON, 50) + }); + + public static final Material TANTALUM_CARBIDE = new Material( + "Tantalum Carbide", // Material Name + MaterialState.SOLID, // State + new short[] {139, 136, 120, 0}, // Material Colour + 2980, // Melting Point in C + -1, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().TANTALUM, 50), + new MaterialStack(ELEMENT.getInstance().CARBON, 50) + }); + + public static final Material ZIRCONIUM_CARBIDE = new Material( + "Zirconium Carbide", // Material Name + MaterialState.SOLID, // State + new short[] {222, 202, 180, 0}, // Material Colour + 1555, // Melting Point in C + -1, + -1, + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().ZIRCONIUM, 50), + new MaterialStack(ELEMENT.getInstance().CARBON, 50) + }); + + public static final Material NIOBIUM_CARBIDE = new Material( + "Niobium Carbide", // Material Name + MaterialState.SOLID, // State + new short[] {205, 197, 191, 0}, // Material Colour + 2477, // Melting Point in C + -1, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().NIOBIUM, 50), + new MaterialStack(ELEMENT.getInstance().CARBON, 50) + }); + + public static final Material ARCANITE = new Material( + "Arcanite", // Material Name + MaterialState.SOLID, // State + null, + 5666, // Melting Point in C + 9875, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().THORIUM232, 40), + new MaterialStack(ENERGYCRYSTAL, 40), + new MaterialStack(ELEMENT.getInstance().ORDO, 10), + new MaterialStack(ELEMENT.getInstance().PERDITIO, 10) + }); + + public static final Material LEAGRISIUM = new Material( + "Grisium", // Material Name + MaterialState.SOLID, // State + new short[] {53, 93, 106, 0}, // Material Colour + 3850, // Melting Point in C + 5550, // Boiling Point in C + 96, // Protons + 128, // Neutrons + true, // Uses Blast furnace? + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().TITANIUM, 18), + new MaterialStack(ELEMENT.getInstance().CARBON, 18), + new MaterialStack(ELEMENT.getInstance().POTASSIUM, 18), + new MaterialStack(ELEMENT.getInstance().LITHIUM, 18), + new MaterialStack(ELEMENT.getInstance().SULFUR, 18), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 10) + }); // Material Stacks with Percentage of required elements. + + public static final Material EGLIN_STEEL_BASE = new Material( + "Eglin Steel Base Compound", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().IRON, 12), + new MaterialStack(KANTHAL, 3), + new MaterialStack(INVAR, 15) + }); + + public static final Material EGLIN_STEEL = new Material( + "Eglin Steel", // Material Name + MaterialState.SOLID, // State + new short[] {139, 69, 19, 0}, // Material Colour + 1048, // Melting Point in C + 1973, // Boiling Point in C + -1, + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ALLOY.EGLIN_STEEL_BASE, 10), + new MaterialStack(ELEMENT.getInstance().SULFUR, 1), + new MaterialStack(ELEMENT.getInstance().SILICON, 4), + new MaterialStack(ELEMENT.getInstance().CARBON, 1) + }); + + public static final Material HG1223 = new Material( + "HG-1223", // Material Name + MaterialState.LIQUID, // State + new short[] {39, 85, 159, 0}, // Material Colour + 6357, // Melting Point in C + 8563, // Boiling Point in C + -1, + -1, + false, // Uses Blast furnace? + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().MERCURY, 1), + new MaterialStack(ELEMENT.getInstance().BARIUM, 2), + new MaterialStack(ELEMENT.getInstance().CALCIUM, 2), + new MaterialStack(ELEMENT.getInstance().COPPER, 3), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 8) + }); + + public static final Material HS188A = new Material( + "HS188-A", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 4870, // Melting Point in C + 7550, // Boiling Point in C + -1, // Protons + -1, // Neutrons + true, // Uses Blast furnace? + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().COBALT, 20), + new MaterialStack(ELEMENT.getInstance().HAFNIUM, 20), + new MaterialStack(TALONITE, 16), + new MaterialStack(ELEMENT.getInstance().RHENIUM, 10), + new MaterialStack(NIOBIUM_CARBIDE, 10), + new MaterialStack(HASTELLOY_X, 8), + new MaterialStack(TUNGSTENSTEEL, 8), + new MaterialStack(ZIRCONIUM_CARBIDE, 8), + }); // Material Stacks with Percentage of required elements. + + /** + * Stargate Materials - #D2FFA9 210, 255, 170 + */ + public static final Material TRINIUM_TITANIUM = new Material( + "Trinium Titanium Alloy", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 3750, // Melting Point in C + 7210, // Boiling Point in C + -1, + -1, + true, // Uses Blast furnace? + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().TRINIUM_REFINED, 3), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 7) + }); + + public static final Material TRINIUM_NAQUADAH = new Material( + "Trinium Naquadah Alloy", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 4200, // Melting Point in C + 7400, // Boiling Point in C + -1, + -1, + false, // Uses Blast furnace? + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().TRINIUM_REFINED, 5), + new MaterialStack(ELEMENT.getInstance().NAQUADAH, 9) + }); + public static final Material TRINIUM_NAQUADAH_CARBON = new Material( + "Trinium Naquadah Carbonite", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 6500, // Melting Point in C + 9000, // Boiling Point in C + -1, + -1, + true, // Uses Blast furnace? + new MaterialStack[] { + new MaterialStack(TRINIUM_NAQUADAH, 9), new MaterialStack(ELEMENT.getInstance().CARBON, 1) + }); + + public static final Material TRINIUM_REINFORCED_STEEL = new Material( + "Arceus Alloy 2B", // Material Name + MaterialState.SOLID, // State + new short[] {205, 197, 23, 0}, // Material Colour + 7555, // Melting Point in C + 12350, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().TRINIUM_REFINED, 30), + new MaterialStack(ALLOY.MARAGING350, 40), + new MaterialStack(ALLOY.TUNGSTENSTEEL, 20), + new MaterialStack(ALLOY.OSMIRIDIUM, 10), + new MaterialStack(ELEMENT.getInstance().STRONTIUM, 10) + }); + + /* + * Witchery Material + */ + + public static final Material KOBOLDITE = new Material( + "Koboldite", // Material Name + MaterialState.SOLID, // State + new short[] {80, 210, 255, 0}, // Material Colour + -1, // Melting Point in C + -1, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().NICKEL, 35), + new MaterialStack(ELEMENT.getInstance().THAUMIUM, 30), + new MaterialStack(ELEMENT.getInstance().IRON, 35) + }); + + /* + * Top Tier Alloys + */ + + public static final Material HELICOPTER = new Material( + "HeLiCoPtEr", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 5763, + 8192, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().HELIUM, 20), + new MaterialStack(ELEMENT.getInstance().LITHIUM, 20), + new MaterialStack(ELEMENT.getInstance().COBALT, 20), + new MaterialStack(ELEMENT.getInstance().PLATINUM, 20), + new MaterialStack(ELEMENT.getInstance().ERBIUM, 20) + }); + + // 0lafe Compound + public static final Material LAFIUM = new Material( + "Lafium Compound", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 6350, // Melting Point in C + 9865, // Boiling Point in C + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ALLOY.HASTELLOY_N, 8), + new MaterialStack(ELEMENT.getInstance().NAQUADAH, 4), + new MaterialStack(ELEMENT.getInstance().SAMARIUM, 2), + new MaterialStack(ELEMENT.getInstance().TUNGSTEN, 4), + new MaterialStack(ELEMENT.getInstance().ARGON, 2), + new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 6), + new MaterialStack(ELEMENT.getInstance().NICKEL, 8), + new MaterialStack(ELEMENT.getInstance().CARBON, 2) + }); + + // Cinobi Alloy + public static final Material CINOBITE = new Material( + "Cinobite A243", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 7350, // Melting Point in C + 12565, // Boiling Point in C + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ALLOY.ZERON_100, 16), + new MaterialStack(ELEMENT.getInstance().NAQUADRIA, 7), + new MaterialStack(ELEMENT.getInstance().GADOLINIUM, 5), + new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 3), + new MaterialStack(ELEMENT.getInstance().MERCURY, 2), + new MaterialStack(ELEMENT.getInstance().TIN, 2), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 12), + new MaterialStack(ALLOY.OSMIRIDIUM, 6) + }); + + // Piky Alloy + public static final Material PIKYONIUM = new Material( + "Pikyonium 64B", // Material Name + MaterialState.SOLID, // State + new short[] {52, 103, 186, 0}, // Material Colour + 6850, // Melting Point in C + 11765, // Boiling Point in C + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ALLOY.INCONEL_792, 16), + new MaterialStack(ALLOY.EGLIN_STEEL, 10), + new MaterialStack(ELEMENT.getInstance().NAQUADAH_ENRICHED, 8), + new MaterialStack(ELEMENT.getInstance().CERIUM, 6), + new MaterialStack(ELEMENT.getInstance().ANTIMONY, 4), + new MaterialStack(ELEMENT.getInstance().PLATINUM, 4), + new MaterialStack(ELEMENT.getInstance().YTTERBIUM, 2), + new MaterialStack(ALLOY.TUNGSTENSTEEL, 8) + }); + + // Piky Alloy + public static final Material ABYSSAL = new Material( + "Abyssal Alloy", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 9650, // Melting Point in C + 13765, // Boiling Point in C + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ALLOY.STAINLESS_STEEL, 10), + new MaterialStack(ALLOY.TUNGSTEN_CARBIDE, 10), + new MaterialStack(ALLOY.NICHROME, 10), + new MaterialStack(ALLOY.BRONZE, 10), + new MaterialStack(ALLOY.INCOLOY_MA956, 10), + new MaterialStack(ELEMENT.getInstance().IODINE, 2), + new MaterialStack(ELEMENT.getInstance().RADON, 2), + new MaterialStack(ELEMENT.getInstance().GERMANIUM, 2), + }); + + // Alkalus Alloy + public static final Material LAURENIUM = new Material( + "Laurenium", // Material Name + MaterialState.SOLID, // State + new short[] {244, 168, 255, 0}, // Material Colour + 6825, // Melting Point in C + 11355, // Boiling Point in C + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ALLOY.EGLIN_STEEL, 40), + new MaterialStack(ELEMENT.getInstance().INDIUM, 10), + new MaterialStack(ELEMENT.getInstance().CHROMIUM, 20), + new MaterialStack(ELEMENT.getInstance().DYSPROSIUM, 5), + new MaterialStack(ELEMENT.getInstance().RHENIUM, 5), + }); + + // Bot Alloy + public static final Material BOTMIUM = new Material( + "Botmium", // Material Name + MaterialState.SOLID, // State + new short[] {80, 160, 80, 0}, // Material Colour + 8220, // Melting Point in C + 10540, // Boiling Point in C + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ALLOY.NITINOL_60, 2), + new MaterialStack(ELEMENT.getInstance().OSMIUM, 12), + new MaterialStack(ELEMENT.getInstance().RUTHENIUM, 12), + new MaterialStack(ELEMENT.getInstance().THALLIUM, 6), + }); + + // Titansteel + public static final Material TITANSTEEL = new Material( + "Titansteel", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 8250, // Melting Point in C + 11765, // Boiling Point in C + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ALLOY.TUNGSTEN_TITANIUM_CARBIDE, 3), + new MaterialStack(ELEMENT.getInstance().IGNIS, 1), + new MaterialStack(ELEMENT.getInstance().TERRA, 1), + new MaterialStack(ELEMENT.getInstance().PERDITIO, 1), + }); + + public static final Material OCTIRON = new Material( + "Octiron", // Material Name + MaterialState.SOLID, // State + null, + 9120, // Melting Point in C + 14200, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ARCANITE, 30), + new MaterialStack(TITANSTEEL, 30), + new MaterialStack(ENERGYCRYSTAL, 5), + new MaterialStack(STEEL_BLACK, 10), + new MaterialStack(ELEMENT.getInstance().THAUMIUM, 25) + }); + + public static final Material BLACK_TITANIUM = new Material( + "Black Titanium", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + Materials.Titanium.mMeltingPoint * 4, // Melting Point in C + Materials.Titanium.mMeltingPoint * 16, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().TITANIUM, 55), + new MaterialStack(ELEMENT.getInstance().LANTHANUM, 12), + new MaterialStack(ELEMENT.getInstance().TUNGSTEN, 8), + new MaterialStack(ELEMENT.getInstance().COBALT, 6), + new MaterialStack(ELEMENT.getInstance().MANGANESE, 4), + new MaterialStack(ELEMENT.getInstance().PHOSPHORUS, 4), + new MaterialStack(ELEMENT.getInstance().PALLADIUM, 4), + new MaterialStack(ELEMENT.getInstance().NIOBIUM, 2), + new MaterialStack(ELEMENT.getInstance().ARGON, 5) + }); + + public static final Material BABBIT_ALLOY = new Material( + "Babbit Alloy", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 268, // Melting Point in C + 589, + -1, + -1, + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().TIN, 10), + new MaterialStack(ELEMENT.getInstance().LEAD, 72), + new MaterialStack(ELEMENT.getInstance().ANTIMONY, 16), + new MaterialStack(ELEMENT.getInstance().ARSENIC, 2) + }); + + public static final Material INDALLOY_140 = new Material( + "Indalloy 140", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 5200, // Melting Point in C + 6500, + -1, + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().BISMUTH, 47), + new MaterialStack(ELEMENT.getInstance().LEAD, 25), + new MaterialStack(ELEMENT.getInstance().TIN, 13), + new MaterialStack(ELEMENT.getInstance().CADMIUM, 10), + new MaterialStack(ELEMENT.getInstance().INDIUM, 5) + }); + + // Quantum + public static final Material QUANTUM = new Material( + "Quantum", // Material Name + MaterialState.SOLID, // State + null, // Material Colour + 10500, // Melting Point in C + 25000, // Boiling Point in C + 150, // Protons + 200, // Neutrons + true, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ALLOY.STELLITE, 15), + new MaterialStack(ALLOY.ENERGYCRYSTAL, 5), + new MaterialStack(ALLOY.SILICON_CARBIDE, 5), + new MaterialStack(ELEMENT.getInstance().GALLIUM, 5), + new MaterialStack(ELEMENT.getInstance().AMERICIUM, 5), + new MaterialStack(ELEMENT.getInstance().PALLADIUM, 5), + new MaterialStack(ELEMENT.getInstance().BISMUTH, 5), + new MaterialStack(ELEMENT.getInstance().GERMANIUM, 5) + }); } diff --git a/src/main/java/gtPlusPlus/core/material/ELEMENT.java b/src/main/java/gtPlusPlus/core/material/ELEMENT.java index 579fba73f5..23dd3d3a08 100644 --- a/src/main/java/gtPlusPlus/core/material/ELEMENT.java +++ b/src/main/java/gtPlusPlus/core/material/ELEMENT.java @@ -11,246 +11,933 @@ import gtPlusPlus.core.util.minecraft.MaterialUtils; public final class ELEMENT { - public static final String[] NAMES = new String[]{"Hydrogen", "Helium", "Lithium", "Beryllium", "Boron", "Carbon", "Nitrogen", "Oxygen", "Fluorine", "Neon", "Sodium", "Magnesium", "Aluminium", "Silicon", "Phosphorus", "Sulfur", "Chlorine", "Argon", "Potassium", "Calcium", "Scandium", "Titanium", "Vanadium", "Chromium", "Manganese", "Iron", "Cobalt", "Nickel", "Copper", "Zinc", "Gallium", "Germanium", "Arsenic", "Selenium", "Bromine", "Krypton", "Rubidium", "Strontium", "Yttrium", "Zirconium", "Niobium", "Molybdenum", "Technetium", "Ruthenium", "Rhodium", "Palladium", "Silver", "Cadmium", "Indium", "Tin", "Antimony", "Tellurium", "Iodine", "Xenon", "Caesium", "Barium", "Lanthanum", "Cerium", "Praseodymium", "Neodymium", "Promethium", "Samarium", "Europium", "Gadolinium", "Terbium", "Dysprosium", "Holmium", "Erbium", "Thulium", "Ytterbium", "Lutetium", "Hafnium", "Tantalum", "Tungsten", "Rhenium", "Osmium", "Iridium", "Platinum", "Gold", "Mercury", "Thallium", "Lead", "Bismuth", "Polonium", "Astatine", "Radon", "Francium", "Radium", "Actinium", "Thorium", "Protactinium", "Uranium", "Neptunium", "Plutonium", "Americium", "Curium", "Berkelium", "Californium", "Einsteinium", "Fermium", "Mendelevium", "Nobelium", "Lawrencium", "Rutherfordium", "Dubnium", "Seaborgium", "Bohrium", "Hassium", "Meitnerium", "Darmstadtium", "Roentgenium", "Copernicium", "Nihonium", "Flerovium", "Moscovium", "Livermorium", "Tennessine", "Oganesson"}; - - //First 50 Elements - public final Material HYDROGEN = MaterialUtils.generateMaterialFromGtENUM(Materials.Hydrogen); - public final Material HELIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Helium); - public final Material LITHIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Lithium); - public final Material BERYLLIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Beryllium); - public final Material BORON = MaterialUtils.generateMaterialFromGtENUM(Materials.Boron); - public final Material CARBON = MaterialUtils.generateMaterialFromGtENUM(Materials.Carbon); - public final Material NITROGEN = MaterialUtils.generateMaterialFromGtENUM(Materials.Nitrogen); - public final Material OXYGEN = MaterialUtils.generateMaterialFromGtENUM(Materials.Oxygen); - public final Material FLUORINE = MaterialUtils.generateMaterialFromGtENUM(Materials.Fluorine); - public final Material NEON = new Material("Neon", MaterialState.PURE_GAS, new short[]{240, 180, 30}, -248, -246, 10, 10, false, "Ne", 0);//Not a GT Inherited Material - public final Material SODIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Sodium); - public final Material MAGNESIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Magnesium); - public final Material ALUMINIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Aluminium); - public final Material ALUMINIUMOXIDE = MaterialUtils.generateMaterialFromGtENUM(Materials.Aluminiumoxide); - public final Material SILICON = MaterialUtils.generateMaterialFromGtENUM(Materials.Silicon); - public final Material SILICONDIOXIDE = MaterialUtils.generateMaterialFromGtENUM(Materials.SiliconDioxide); - public final Material PHOSPHORUS = MaterialUtils.generateMaterialFromGtENUM(Materials.Phosphor); - public final Material SULFUR = MaterialUtils.generateMaterialFromGtENUM(Materials.Sulfur); - public final Material CHLORINE = MaterialUtils.generateMaterialFromGtENUM(Materials.Chlorine); - public final Material ARGON = MaterialUtils.generateMaterialFromGtENUM(Materials.Argon); - public final Material POTASSIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Potassium); - public final Material CALCIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Calcium); - public final Material SCANDIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Scandium); - public final Material TITANIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Titanium); - public final Material VANADIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Vanadium); - public final Material CHROMIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Chrome); - public final Material MANGANESE = MaterialUtils.generateMaterialFromGtENUM(Materials.Manganese); - public final Material IRON = MaterialUtils.generateMaterialFromGtENUM(Materials.Iron); - public final Material COBALT = MaterialUtils.generateMaterialFromGtENUM(Materials.Cobalt); - public final Material NICKEL = MaterialUtils.generateMaterialFromGtENUM(Materials.Nickel); - public final Material COPPER = MaterialUtils.generateMaterialFromGtENUM(Materials.Copper); - public final Material ZINC = MaterialUtils.generateMaterialFromGtENUM(Materials.Zinc); - public final Material GALLIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Gallium); - public final Material GERMANIUM = new Material("Germanium", MaterialState.SOLID, new short[]{200, 200, 200}, 937, 2830, 32, 41, false, "Ge", 0);//Not a GT Inherited Material - public final Material ARSENIC = MaterialUtils.generateMaterialFromGtENUM(Materials.Arsenic); - public final Material SELENIUM = new Material("Selenium", MaterialState.SOLID, new short[]{190, 190, 190}, 217, 685, 34, 45, false, "Se", 0);//Not a GT Inherited Material - public final Material BROMINE = new Material("Bromine", MaterialState.PURE_LIQUID, new short[]{200, 25, 25}, -7, 58, 35, 45, false, "Br", 0);//Not a GT Inherited Material - public final Material KRYPTON = new Material("Krypton", MaterialState.PURE_GAS, new short[]{5, 200, 220}, -157, -153, 36, 48, false, "Kr", 0);//Not a GT Inherited Material - public final Material RUBIDIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Rubidium); - public final Material STRONTIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Strontium, new short[] {230, 210, 110}, TextureSet.SET_FLINT); - public final Material YTTRIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Yttrium); - public final Material ZIRCONIUM = new Material("Zirconium", MaterialState.SOLID, new short[]{255, 250, 205}, 1855, 4377, 40, 51, false, "Zr", 0);//Not a GT Inherited Material - public final Material NIOBIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Niobium); - public final Material MOLYBDENUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Molybdenum); - public final Material TECHNETIUM = new Material("Technetium", MaterialState.SOLID, TextureSets.NUCLEAR.get(), new short[]{220, 220, 220}, 2200, 4877, 43, 55, false, "Tc", 2);//Not a GT Inherited Material - public final Material RUTHENIUM = new Material("Ruthenium", MaterialState.SOLID, new short[]{220, 220, 220}, 2250, 3900, 44, 57, false, "Ru", 0);//Not a GT Inherited Material - public final Material RHODIUM = new Material("Rhodium", MaterialState.SOLID, new short[]{220, 220, 220}, 1966, 3727, 45, 58, false, "Rh", 0);//Not a GT Inherited Material - public final Material PALLADIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Palladium); - public final Material SILVER = MaterialUtils.generateMaterialFromGtENUM(Materials.Silver); - public final Material CADMIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Cadmium); - public final Material INDIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Indium); - public final Material TIN = MaterialUtils.generateMaterialFromGtENUM(Materials.Tin); - public final Material ANTIMONY = MaterialUtils.generateMaterialFromGtENUM(Materials.Antimony); - public final Material TELLURIUM = new Material("Tellurium", MaterialState.SOLID, new short[]{210, 210, 210}, 449, 989, 52, 76, false, "Te", 0);//Not a GT Inherited Material - public final Material IODINE = new Material("Iodine", MaterialState.SOLID, TextureSet.SET_SHINY, new short[]{96, 96, 96}, 114, 184, 53, 74, false, "I", 0);//Not a GT Inherited Material - public final Material XENON = new Material("Xenon", MaterialState.PURE_GAS, new short[]{5, 105, 210}, -111, -108, 54, 77, false, "Xe", 0);//Not a GT Inherited Material - public final Material CAESIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Caesium); - public final Material BARIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Barium); - public final Material LANTHANUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Lanthanum); - public final Material CERIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Cerium); - public final Material PRASEODYMIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Praseodymium); - public final Material NEODYMIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Neodymium); - public final Material PROMETHIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Promethium); - public final Material SAMARIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Samarium); - public final Material EUROPIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Europium); - public final Material GADOLINIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Gadolinium); - public final Material TERBIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Terbium); - public final Material DYSPROSIUM = new Material("Dysprosium", MaterialState.SOLID, new short[]{180, 180, 180}, 1412, 2562, 66, 97, false, "Dy", 0);//Not a GT Inherited Material - public final Material HOLMIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Holmium); - public final Material ERBIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Erbium); - public final Material THULIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Thulium); - public final Material YTTERBIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Ytterbium); - public final Material LUTETIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Lutetium); - public final Material HAFNIUM = new Material("Hafnium", MaterialState.SOLID, new short[]{128, 128, 128}, 2150, 5400, 72, 106, false, "Hf", 0);//Not a GT Inherited Material + public static final String[] NAMES = new String[] { + "Hydrogen", + "Helium", + "Lithium", + "Beryllium", + "Boron", + "Carbon", + "Nitrogen", + "Oxygen", + "Fluorine", + "Neon", + "Sodium", + "Magnesium", + "Aluminium", + "Silicon", + "Phosphorus", + "Sulfur", + "Chlorine", + "Argon", + "Potassium", + "Calcium", + "Scandium", + "Titanium", + "Vanadium", + "Chromium", + "Manganese", + "Iron", + "Cobalt", + "Nickel", + "Copper", + "Zinc", + "Gallium", + "Germanium", + "Arsenic", + "Selenium", + "Bromine", + "Krypton", + "Rubidium", + "Strontium", + "Yttrium", + "Zirconium", + "Niobium", + "Molybdenum", + "Technetium", + "Ruthenium", + "Rhodium", + "Palladium", + "Silver", + "Cadmium", + "Indium", + "Tin", + "Antimony", + "Tellurium", + "Iodine", + "Xenon", + "Caesium", + "Barium", + "Lanthanum", + "Cerium", + "Praseodymium", + "Neodymium", + "Promethium", + "Samarium", + "Europium", + "Gadolinium", + "Terbium", + "Dysprosium", + "Holmium", + "Erbium", + "Thulium", + "Ytterbium", + "Lutetium", + "Hafnium", + "Tantalum", + "Tungsten", + "Rhenium", + "Osmium", + "Iridium", + "Platinum", + "Gold", + "Mercury", + "Thallium", + "Lead", + "Bismuth", + "Polonium", + "Astatine", + "Radon", + "Francium", + "Radium", + "Actinium", + "Thorium", + "Protactinium", + "Uranium", + "Neptunium", + "Plutonium", + "Americium", + "Curium", + "Berkelium", + "Californium", + "Einsteinium", + "Fermium", + "Mendelevium", + "Nobelium", + "Lawrencium", + "Rutherfordium", + "Dubnium", + "Seaborgium", + "Bohrium", + "Hassium", + "Meitnerium", + "Darmstadtium", + "Roentgenium", + "Copernicium", + "Nihonium", + "Flerovium", + "Moscovium", + "Livermorium", + "Tennessine", + "Oganesson" + }; - //Second 50 elements - public final Material TANTALUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Tantalum); - public final Material TUNGSTEN = MaterialUtils.generateMaterialFromGtENUM(Materials.Tungsten); - public final Material RHENIUM = new Material("Rhenium", MaterialState.SOLID, new short[]{150, 150, 150}, 3180, 3627, 75, 111, false, "Re", 0);//Not a GT Inherited Material - public final Material OSMIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Osmium); - public final Material IRIDIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Iridium); - public final Material PLATINUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Platinum); - public final Material GOLD = MaterialUtils.generateMaterialFromGtENUM(Materials.Gold); - public final Material MERCURY = MaterialUtils.generateMaterialFromGtENUM(Materials.Mercury); //Mercury - public final Material THALLIUM = new Material("Thallium", MaterialState.SOLID, new short[]{175, 175, 175}, 304, 1457, 81, 123, false, "Tl", 0);//Not a GT Inherited Material - public final Material LEAD = MaterialUtils.generateMaterialFromGtENUM(Materials.Lead); - public final Material BISMUTH = MaterialUtils.generateMaterialFromGtENUM(Materials.Bismuth); - public final Material POLONIUM = new Material("Polonium", MaterialState.SOLID, TextureSets.NUCLEAR.get(), new short[]{180, 170, 180}, 254, 962, 84, 125, false, "Po", 1);//Not a GT Inherited Material - public final Material ASTATINE = new Material("Astatine", MaterialState.SOLID, TextureSets.NUCLEAR.get(), new short[]{170, 180, 170}, 302, 337, 85, 125, false, "At", 1);//Not a GT Inherited Material - public final Material RADON = MaterialUtils.generateMaterialFromGtENUM(Materials.Radon); - public final Material FRANCIUM = new Material("Francium", MaterialState.SOLID, TextureSets.NUCLEAR.get(), new short[]{170, 160, 170}, 27, 677, 87, 136, false, "Fr", 1);//Not a GT Inherited Material - public final Material RADIUM = new Material("Radium", MaterialState.SOLID, TextureSets.NUCLEAR.get(), new short[]{165, 165, 165}, 700, 1737, 88, 138, false, "Ra", 1);//Not a GT Inherited Material - public final Material ACTINIUM = new Material("Actinium", MaterialState.SOLID, TextureSets.NUCLEAR.get(), new short[]{150, 165, 165}, 1050, 3200, 89, 138, false, "Ac", 1);//Not a GT Inherited Material - public final Material THORIUM = new Material("Thorium", MaterialState.SOLID, Materials.Thorium.mRGBa, Materials.Thorium.mMeltingPoint, Materials.Thorium.mBlastFurnaceTemp, 90, 142, false, StringUtils.superscript("Th"), 1); - public final Material PROTACTINIUM = new Material("Protactinium", MaterialState.SOLID, TextureSets.NUCLEAR.get(), new short[]{190, 150, 170}, 1568, 4027, 91, 140, false, "Pa", 1);//Not a GT Inherited Material - public final Material URANIUM238 = MaterialUtils.generateMaterialFromGtENUM(Materials.Uranium); - public final Material URANIUM235 = MaterialUtils.generateMaterialFromGtENUM(Materials.Uranium235); - public final Material NEPTUNIUM = new Material("Neptunium", MaterialState.SOLID, TextureSets.NUCLEAR.get(), new short[]{200, 220, 205}, 640, 3902, 93, 144, false, "Np", 2);//Not a GT Inherited Material - public final Material PLUTONIUM244 = MaterialUtils.generateMaterialFromGtENUM(Materials.Plutonium); - public final Material PLUTONIUM241 = MaterialUtils.generateMaterialFromGtENUM(Materials.Plutonium241); - public final Material AMERICIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Americium); //Americium - public final Material CURIUM = new Material("Curium", MaterialState.SOLID, TextureSets.NUCLEAR.get(), new short[]{175, 85, 110}, 1340, 3110, 96, 151, false, "Cm", 3);//Not a GT Inherited Material - public final Material BERKELIUM = new Material("Berkelium", MaterialState.SOLID, TextureSets.NUCLEAR.get(), new short[]{110, 250, 85}, 985, 710, 97, 150, false, "Bk", 4);//Not a GT Inherited Material - public final Material CALIFORNIUM = new Material("Californium", MaterialState.SOLID, TextureSets.NUCLEAR.get(), new short[]{85, 110, 205}, 899, 1472, 98, 153, false, "Cf", 4);//Not a GT Inherited Material - public final Material EINSTEINIUM = new Material("Einsteinium", MaterialState.SOLID, TextureSets.NUCLEAR.get(), new short[]{255, 85, 110}, 860, 3500, 99, 153, false, "Es", 5);//Not a GT Inherited Material //Boiling Point is made up - public final Material FERMIUM = new Material("Fermium", MaterialState.LIQUID, TextureSets.NUCLEAR.get(), new short[]{75, 90, 25}, 1527, 3850, 100, 157, false, "Fm", 5);//Not a GT Inherited Material //Boiling Point is made up + // First 50 Elements + public final Material HYDROGEN = MaterialUtils.generateMaterialFromGtENUM(Materials.Hydrogen); + public final Material HELIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Helium); + public final Material LITHIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Lithium); + public final Material BERYLLIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Beryllium); + public final Material BORON = MaterialUtils.generateMaterialFromGtENUM(Materials.Boron); + public final Material CARBON = MaterialUtils.generateMaterialFromGtENUM(Materials.Carbon); + public final Material NITROGEN = MaterialUtils.generateMaterialFromGtENUM(Materials.Nitrogen); + public final Material OXYGEN = MaterialUtils.generateMaterialFromGtENUM(Materials.Oxygen); + public final Material FLUORINE = MaterialUtils.generateMaterialFromGtENUM(Materials.Fluorine); + public final Material NEON = new Material( + "Neon", + MaterialState.PURE_GAS, + new short[] {240, 180, 30}, + -248, + -246, + 10, + 10, + false, + "Ne", + 0); // Not a GT Inherited Material + public final Material SODIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Sodium); + public final Material MAGNESIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Magnesium); + public final Material ALUMINIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Aluminium); + public final Material ALUMINIUMOXIDE = MaterialUtils.generateMaterialFromGtENUM(Materials.Aluminiumoxide); + public final Material SILICON = MaterialUtils.generateMaterialFromGtENUM(Materials.Silicon); + public final Material SILICONDIOXIDE = MaterialUtils.generateMaterialFromGtENUM(Materials.SiliconDioxide); + public final Material PHOSPHORUS = MaterialUtils.generateMaterialFromGtENUM(Materials.Phosphor); + public final Material SULFUR = MaterialUtils.generateMaterialFromGtENUM(Materials.Sulfur); + public final Material CHLORINE = MaterialUtils.generateMaterialFromGtENUM(Materials.Chlorine); + public final Material ARGON = MaterialUtils.generateMaterialFromGtENUM(Materials.Argon); + public final Material POTASSIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Potassium); + public final Material CALCIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Calcium); + public final Material SCANDIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Scandium); + public final Material TITANIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Titanium); + public final Material VANADIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Vanadium); + public final Material CHROMIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Chrome); + public final Material MANGANESE = MaterialUtils.generateMaterialFromGtENUM(Materials.Manganese); + public final Material IRON = MaterialUtils.generateMaterialFromGtENUM(Materials.Iron); + public final Material COBALT = MaterialUtils.generateMaterialFromGtENUM(Materials.Cobalt); + public final Material NICKEL = MaterialUtils.generateMaterialFromGtENUM(Materials.Nickel); + public final Material COPPER = MaterialUtils.generateMaterialFromGtENUM(Materials.Copper); + public final Material ZINC = MaterialUtils.generateMaterialFromGtENUM(Materials.Zinc); + public final Material GALLIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Gallium); + public final Material GERMANIUM = new Material( + "Germanium", + MaterialState.SOLID, + new short[] {200, 200, 200}, + 937, + 2830, + 32, + 41, + false, + "Ge", + 0); // Not a GT Inherited Material + public final Material ARSENIC = MaterialUtils.generateMaterialFromGtENUM(Materials.Arsenic); + public final Material SELENIUM = new Material( + "Selenium", + MaterialState.SOLID, + new short[] {190, 190, 190}, + 217, + 685, + 34, + 45, + false, + "Se", + 0); // Not a GT Inherited Material + public final Material BROMINE = new Material( + "Bromine", + MaterialState.PURE_LIQUID, + new short[] {200, 25, 25}, + -7, + 58, + 35, + 45, + false, + "Br", + 0); // Not a GT Inherited Material + public final Material KRYPTON = new Material( + "Krypton", + MaterialState.PURE_GAS, + new short[] {5, 200, 220}, + -157, + -153, + 36, + 48, + false, + "Kr", + 0); // Not a GT Inherited Material + public final Material RUBIDIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Rubidium); + public final Material STRONTIUM = MaterialUtils.generateMaterialFromGtENUM( + Materials.Strontium, new short[] {230, 210, 110}, TextureSet.SET_FLINT); + public final Material YTTRIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Yttrium); + public final Material ZIRCONIUM = new Material( + "Zirconium", + MaterialState.SOLID, + new short[] {255, 250, 205}, + 1855, + 4377, + 40, + 51, + false, + "Zr", + 0); // Not a GT Inherited Material + public final Material NIOBIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Niobium); + public final Material MOLYBDENUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Molybdenum); + public final Material TECHNETIUM = new Material( + "Technetium", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + new short[] {220, 220, 220}, + 2200, + 4877, + 43, + 55, + false, + "Tc", + 2); // Not a GT Inherited Material + public final Material RUTHENIUM = new Material( + "Ruthenium", + MaterialState.SOLID, + new short[] {220, 220, 220}, + 2250, + 3900, + 44, + 57, + false, + "Ru", + 0); // Not a GT Inherited Material + public final Material RHODIUM = new Material( + "Rhodium", + MaterialState.SOLID, + new short[] {220, 220, 220}, + 1966, + 3727, + 45, + 58, + false, + "Rh", + 0); // Not a GT Inherited Material + public final Material PALLADIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Palladium); + public final Material SILVER = MaterialUtils.generateMaterialFromGtENUM(Materials.Silver); + public final Material CADMIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Cadmium); + public final Material INDIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Indium); + public final Material TIN = MaterialUtils.generateMaterialFromGtENUM(Materials.Tin); + public final Material ANTIMONY = MaterialUtils.generateMaterialFromGtENUM(Materials.Antimony); + public final Material TELLURIUM = new Material( + "Tellurium", + MaterialState.SOLID, + new short[] {210, 210, 210}, + 449, + 989, + 52, + 76, + false, + "Te", + 0); // Not a GT Inherited Material + public final Material IODINE = new Material( + "Iodine", + MaterialState.SOLID, + TextureSet.SET_SHINY, + new short[] {96, 96, 96}, + 114, + 184, + 53, + 74, + false, + "I", + 0); // Not a GT Inherited Material + public final Material XENON = new Material( + "Xenon", + MaterialState.PURE_GAS, + new short[] {5, 105, 210}, + -111, + -108, + 54, + 77, + false, + "Xe", + 0); // Not a GT Inherited Material + public final Material CAESIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Caesium); + public final Material BARIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Barium); + public final Material LANTHANUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Lanthanum); + public final Material CERIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Cerium); + public final Material PRASEODYMIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Praseodymium); + public final Material NEODYMIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Neodymium); + public final Material PROMETHIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Promethium); + public final Material SAMARIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Samarium); + public final Material EUROPIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Europium); + public final Material GADOLINIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Gadolinium); + public final Material TERBIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Terbium); + public final Material DYSPROSIUM = new Material( + "Dysprosium", + MaterialState.SOLID, + new short[] {180, 180, 180}, + 1412, + 2562, + 66, + 97, + false, + "Dy", + 0); // Not a GT Inherited Material + public final Material HOLMIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Holmium); + public final Material ERBIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Erbium); + public final Material THULIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Thulium); + public final Material YTTERBIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Ytterbium); + public final Material LUTETIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Lutetium); + public final Material HAFNIUM = new Material( + "Hafnium", + MaterialState.SOLID, + new short[] {128, 128, 128}, + 2150, + 5400, + 72, + 106, + false, + "Hf", + 0); // Not a GT Inherited Material - //Misc - public final Material AER = MaterialUtils.generateMaterialFromGtENUM(Materials.InfusedAir, TextureSets.GEM_A.get()); - public final Material IGNIS = MaterialUtils.generateMaterialFromGtENUM(Materials.InfusedFire, TextureSets.GEM_A.get()); - public final Material TERRA = MaterialUtils.generateMaterialFromGtENUM(Materials.InfusedEarth, TextureSets.GEM_A.get()); - public final Material AQUA = MaterialUtils.generateMaterialFromGtENUM(Materials.InfusedWater, TextureSets.GEM_A.get()); - public final Material PERDITIO = MaterialUtils.generateMaterialFromGtENUM(Materials.InfusedEntropy, TextureSets.GEM_A.get()); - public final Material ORDO = MaterialUtils.generateMaterialFromGtENUM(Materials.InfusedOrder, TextureSets.GEM_A.get()); - - //Fictional - public final Material YELLORIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Yellorium, new short[] {255, 242, 10}, TextureSets.NUCLEAR.get()); - public final Material NAQUADAH = MaterialUtils.generateMaterialFromGtENUM(Materials.Naquadah); - public final Material NAQUADAH_ENRICHED = MaterialUtils.generateMaterialFromGtENUM(Materials.NaquadahEnriched); - public final Material NAQUADRIA = MaterialUtils.generateMaterialFromGtENUM(Materials.Naquadria); - public final Material TRINIUM; - public final Material TRINIUM_REFINED; - //https://github.com/Blood-Asp/GT5-Unofficial/issues/609 - - - //Custom Isotopes - public final Material LITHIUM7 = new Material("Lithium 7", MaterialState.SOLID, TextureSet.SET_SHINY, Materials.Lithium.mRGBa, Materials.Lithium.mMeltingPoint, Materials.Lithium.mBlastFurnaceTemp, Materials.Lithium.getProtons(), Materials.Lithium.getNeutrons(), Materials.Lithium.mBlastFurnaceRequired, StringUtils.superscript("7Li"), 0, false);//Not a GT Inherited Material - public final Material URANIUM232 = new Material("Uranium 232", MaterialState.SOLID, TextureSets.NUCLEAR.get(), new short[]{88, 220, 103, 0}, 1132, 4131, 92, 140, false, StringUtils.superscript("232U"), 4);//Not a GT Inherited Material - public final Material URANIUM233 = new Material("Uranium 233", MaterialState.SOLID, TextureSets.NUCLEAR.get(), new short[]{73, 220, 83, 0}, 1132, 4131, 92, 141, false, StringUtils.superscript("233U"), 2);//Not a GT Inherited Material - public final Material THORIUM232 = new Material("Thorium 232", MaterialState.SOLID, TextureSets.NUCLEAR.get(), new short[]{15, 60, 15, 0}, Materials.Thorium.mMeltingPoint, Materials.Thorium.mBlastFurnaceTemp, 90, 142, false, StringUtils.superscript("232Th"), 1, true);//Not a GT Inherited Material - public final Material PLUTONIUM239 = new Material("Plutonium-239", MaterialState.SOLID, TextureSets.NUCLEAR.get(), Materials.Plutonium.mDurability, Materials.Plutonium.mRGBa, Materials.Plutonium.mMeltingPoint, Materials.Plutonium.mBlastFurnaceTemp, 94, 145, false, StringUtils.superscript("239Pu"), 4, true);//Not a GT Inherited Material - //RTG Fuels - public final Material PLUTONIUM238 = new Material("Plutonium-238", MaterialState.SOLID, TextureSets.NUCLEAR.get(), Materials.Plutonium241.mDurability, Materials.Plutonium241.mRGBa, Materials.Plutonium241.mMeltingPoint, Materials.Plutonium241.mBlastFurnaceTemp, 94, 144, false, StringUtils.superscript("238Pu"), 2, false);//Not a GT Inherited Material - public final Material STRONTIUM90 = new Material("Strontium-90", MaterialState.SOLID, TextureSets.NUCLEAR.get(), Materials.Strontium.mDurability, Materials.Strontium.mRGBa, Materials.Strontium.mMeltingPoint, Materials.Strontium.mBlastFurnaceTemp, 38, 52, false, StringUtils.superscript("90Sr"), 2, false);//Not a GT Inherited Material - public final Material POLONIUM210 = new Material("Polonium-210", MaterialState.SOLID, TextureSets.NUCLEAR.get(), POLONIUM.vDurability, POLONIUM.getRGBA(), POLONIUM.getMeltingPointK(), POLONIUM.getBoilingPointK(), 84, 126, false, StringUtils.superscript("210Po"), 2, false);//Not a GT Inherited Material - public final Material AMERICIUM241 = new Material("Americium-241", MaterialState.SOLID, TextureSets.NUCLEAR.get(), Materials.Americium.mDurability, Materials.Americium.mRGBa, Materials.Americium.mMeltingPoint, Materials.Americium.mBlastFurnaceTemp, 95, 146, false, StringUtils.superscript("241Am"), 2, false);//Not a GT Inherited Material + // Second 50 elements + public final Material TANTALUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Tantalum); + public final Material TUNGSTEN = MaterialUtils.generateMaterialFromGtENUM(Materials.Tungsten); + public final Material RHENIUM = new Material( + "Rhenium", + MaterialState.SOLID, + new short[] {150, 150, 150}, + 3180, + 3627, + 75, + 111, + false, + "Re", + 0); // Not a GT Inherited Material + public final Material OSMIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Osmium); + public final Material IRIDIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Iridium); + public final Material PLATINUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Platinum); + public final Material GOLD = MaterialUtils.generateMaterialFromGtENUM(Materials.Gold); + public final Material MERCURY = MaterialUtils.generateMaterialFromGtENUM(Materials.Mercury); // Mercury + public final Material THALLIUM = new Material( + "Thallium", + MaterialState.SOLID, + new short[] {175, 175, 175}, + 304, + 1457, + 81, + 123, + false, + "Tl", + 0); // Not a GT Inherited Material + public final Material LEAD = MaterialUtils.generateMaterialFromGtENUM(Materials.Lead); + public final Material BISMUTH = MaterialUtils.generateMaterialFromGtENUM(Materials.Bismuth); + public final Material POLONIUM = new Material( + "Polonium", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + new short[] {180, 170, 180}, + 254, + 962, + 84, + 125, + false, + "Po", + 1); // Not a GT Inherited Material + public final Material ASTATINE = new Material( + "Astatine", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + new short[] {170, 180, 170}, + 302, + 337, + 85, + 125, + false, + "At", + 1); // Not a GT Inherited Material + public final Material RADON = MaterialUtils.generateMaterialFromGtENUM(Materials.Radon); + public final Material FRANCIUM = new Material( + "Francium", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + new short[] {170, 160, 170}, + 27, + 677, + 87, + 136, + false, + "Fr", + 1); // Not a GT Inherited Material + public final Material RADIUM = new Material( + "Radium", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + new short[] {165, 165, 165}, + 700, + 1737, + 88, + 138, + false, + "Ra", + 1); // Not a GT Inherited Material + public final Material ACTINIUM = new Material( + "Actinium", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + new short[] {150, 165, 165}, + 1050, + 3200, + 89, + 138, + false, + "Ac", + 1); // Not a GT Inherited Material + public final Material THORIUM = new Material( + "Thorium", + MaterialState.SOLID, + Materials.Thorium.mRGBa, + Materials.Thorium.mMeltingPoint, + Materials.Thorium.mBlastFurnaceTemp, + 90, + 142, + false, + StringUtils.superscript("Th"), + 1); + public final Material PROTACTINIUM = new Material( + "Protactinium", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + new short[] {190, 150, 170}, + 1568, + 4027, + 91, + 140, + false, + "Pa", + 1); // Not a GT Inherited Material + public final Material URANIUM238 = MaterialUtils.generateMaterialFromGtENUM(Materials.Uranium); + public final Material URANIUM235 = MaterialUtils.generateMaterialFromGtENUM(Materials.Uranium235); + public final Material NEPTUNIUM = new Material( + "Neptunium", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + new short[] {200, 220, 205}, + 640, + 3902, + 93, + 144, + false, + "Np", + 2); // Not a GT Inherited Material + public final Material PLUTONIUM244 = MaterialUtils.generateMaterialFromGtENUM(Materials.Plutonium); + public final Material PLUTONIUM241 = MaterialUtils.generateMaterialFromGtENUM(Materials.Plutonium241); + public final Material AMERICIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Americium); // Americium + public final Material CURIUM = new Material( + "Curium", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + new short[] {175, 85, 110}, + 1340, + 3110, + 96, + 151, + false, + "Cm", + 3); // Not a GT Inherited Material + public final Material BERKELIUM = new Material( + "Berkelium", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + new short[] {110, 250, 85}, + 985, + 710, + 97, + 150, + false, + "Bk", + 4); // Not a GT Inherited Material + public final Material CALIFORNIUM = new Material( + "Californium", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + new short[] {85, 110, 205}, + 899, + 1472, + 98, + 153, + false, + "Cf", + 4); // Not a GT Inherited Material + public final Material EINSTEINIUM = new Material( + "Einsteinium", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + new short[] {255, 85, 110}, + 860, + 3500, + 99, + 153, + false, + "Es", + 5); // Not a GT Inherited Material //Boiling Point is made up + public final Material FERMIUM = new Material( + "Fermium", + MaterialState.LIQUID, + TextureSets.NUCLEAR.get(), + new short[] {75, 90, 25}, + 1527, + 3850, + 100, + 157, + false, + "Fm", + 5); // Not a GT Inherited Material //Boiling Point is made up - public final Material MAGIC = MaterialUtils.generateMaterialFromGtENUM(Materials.Magic, new short[] {10, 185, 140}); - public final Material THAUMIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Thaumium); - - static { - Logger.MATERIALS("Initialising Base Elements."); - } - - private static final ELEMENT INSTANCE = new ELEMENT(); + // Misc + public final Material AER = MaterialUtils.generateMaterialFromGtENUM(Materials.InfusedAir, TextureSets.GEM_A.get()); + public final Material IGNIS = + MaterialUtils.generateMaterialFromGtENUM(Materials.InfusedFire, TextureSets.GEM_A.get()); + public final Material TERRA = + MaterialUtils.generateMaterialFromGtENUM(Materials.InfusedEarth, TextureSets.GEM_A.get()); + public final Material AQUA = + MaterialUtils.generateMaterialFromGtENUM(Materials.InfusedWater, TextureSets.GEM_A.get()); + public final Material PERDITIO = + MaterialUtils.generateMaterialFromGtENUM(Materials.InfusedEntropy, TextureSets.GEM_A.get()); + public final Material ORDO = + MaterialUtils.generateMaterialFromGtENUM(Materials.InfusedOrder, TextureSets.GEM_A.get()); - public ELEMENT(){ - //GTNH Trinium Handling - if (CORE.GTNH){ - //yay - Materials a1 = MaterialUtils.getMaterial("Trinium"); - Materials a2 = Materials.valueOf("Trinium"); - Materials a3 = Materials.get("Trinium"); - Materials a4; - if (a1 == null) { - Logger.INFO("[Material] First attempt to find Trinium failed, using backup method."); - if (a2 == null) { - Logger.INFO("[Material] Fallback attempt to find Trinium failed, using second fallback."); - if (a3 == null) { - Logger.INFO("[Material] Fallback attempt to find Trinium failed, dumping materials."); - for (Materials m : Materials.values()) { - Logger.INFO("[Material] Found "+MaterialUtils.getMaterialName(m)); - } - a4 = null; - } - else { - Logger.INFO("[Material] a3 Found "+MaterialUtils.getMaterialName(a3)); - a4 = a3; - } - } - else { - Logger.INFO("[Material] a2 Found "+MaterialUtils.getMaterialName(a2)); - a4 = a2; - } - TRINIUM = MaterialUtils.generateMaterialFromGtENUM(a4); - } - else { - Logger.INFO("[Material] a1 Found "+MaterialUtils.getMaterialName(a1)); - TRINIUM = MaterialUtils.generateMaterialFromGtENUM(a1); - } - - TRINIUM_REFINED = TRINIUM; - - } - else { - TRINIUM = new Material("Trinium", MaterialState.SOLID, TextureSet.SET_FINE, new short[]{70, 110, 30}, 604, 4057, 181, 133, false, "Ke", 0, false);//Not a GT Inherited Material - TRINIUM_REFINED = new Material("Refined Trinium", MaterialState.SOLID, TextureSets.REFINED.get(), new short[]{210, 255, 170}, 4304, 14057, 181, 133, false, "Ke", 0, new MaterialStack[]{new MaterialStack(TRINIUM, 1)});//Not a GT Inherited Material - } - } + // Fictional + public final Material YELLORIUM = MaterialUtils.generateMaterialFromGtENUM( + Materials.Yellorium, new short[] {255, 242, 10}, TextureSets.NUCLEAR.get()); + public final Material NAQUADAH = MaterialUtils.generateMaterialFromGtENUM(Materials.Naquadah); + public final Material NAQUADAH_ENRICHED = MaterialUtils.generateMaterialFromGtENUM(Materials.NaquadahEnriched); + public final Material NAQUADRIA = MaterialUtils.generateMaterialFromGtENUM(Materials.Naquadria); + public final Material TRINIUM; + public final Material TRINIUM_REFINED; + // https://github.com/Blood-Asp/GT5-Unofficial/issues/609 - public static ELEMENT getInstance(){ - return INSTANCE; - } - - public static class STANDALONE { - - public static final Material CELESTIAL_TUNGSTEN = new Material("Celestial Tungsten", MaterialState.SOLID, TextureSets.REFINED.get(), new short[] {50, 50, 50, 2}, INSTANCE.TUNGSTEN.getMeltingPointC()+6500, INSTANCE.TUNGSTEN.getBoilingPointC()+7500, 160, 101, true, "✦◆✦", 0);//Not a GT Inherited Material - public static final Material ASTRAL_TITANIUM = new Material("Astral Titanium", MaterialState.SOLID, TextureSets.REFINED.get(), new short[] {220, 160, 240, 2}, INSTANCE.TITANIUM.getMeltingPointC()+7500, INSTANCE.TITANIUM.getBoilingPointC()+7500, 145, 133, true, "✧◇✧", 0);//Not a GT Inherited Material - public static final Material CHRONOMATIC_GLASS = new Material("Chromatic Glass", MaterialState.SOLID, new short[]{255, 255, 255, 3}, 9200, 17550, 40, 51, false, "⌘☯𓍰 𓍱 𓍲 𓍳 𓍴 𓍵 𓍶 𓍷 𓍸 ☯⌘ ", 0);//Not a GT Inherited Material - public static final Material ADVANCED_NITINOL = new Material("Advanced Nitinol", MaterialState.SOLID, TextureSets.ENRICHED.get(), ALLOY.NITINOL_60.getRGB(), 8400, 14377, 40, 51, true, "⚷⚙⚷ Ni4Ti6", 0);//Not a GT Inherited Material - public static final Material HYPOGEN = new Material("Hypogen", MaterialState.SOLID, TextureSets.NUCLEAR.get(), new short[]{220, 120, 75, 2}, 12255, 19377, 240, 251, true, "Hy⚶", 0);//Not a GT Inherited Material - public static final Material RHUGNOR = new Material("Rhugnor", MaterialState.SOLID, TextureSets.ENRICHED.get(), new short[]{190, 0, 255, 0}, 8750, 14757, 184, 142, true, "Fs⚶", 0);//Not a GT Inherited Material //funeris - public static final Material FORCE = new Material("Force", MaterialState.SOLID, TextureSets.ENRICHED.get(), new short[]{250, 250, 20, 0}, 4550, 6830, 63, 81, true, "Fc⚙", 0);//Not a GT Inherited Material - - - //Runescape materials - public static final Material BLACK_METAL = new Material("Black Metal", MaterialState.SOLID, TextureSet.SET_METALLIC, new short[] {5, 5, 5}, 2350, 4650, 24, 17, false, "҈", 0, new MaterialStack[]{new MaterialStack(getInstance().LEAD, 15), new MaterialStack(getInstance().MANGANESE, 25), new MaterialStack(getInstance().CARBON, 60)});//Not a GT Inherited Material - public static final Material WHITE_METAL = new Material("White Metal", MaterialState.SOLID, TextureSet.SET_METALLIC, new short[] {255, 255, 255}, 4560, 7580, 35, 41, false, "҉", 0, new MaterialStack[]{new MaterialStack(getInstance().COPPER, 5), new MaterialStack(getInstance().ANTIMONY, 10), new MaterialStack(getInstance().PLATINUM, 10), new MaterialStack(getInstance().TIN, 75)});//Not a GT Inherited Material - - public static final Material GRANITE = new Material( - "Ancient Granite", - MaterialState.SOLID, - TextureSet.SET_SAND, - new short[] {107, 107, 107}, - 500, - 2000, - 16, - 12, - false, - "«»", - 0, - false, - new MaterialStack[]{ - new MaterialStack(getInstance().OXYGEN, 16), - new MaterialStack(getInstance().IRON, 10), - new MaterialStack(getInstance().SILICONDIOXIDE, 10), - new MaterialStack(getInstance().ALUMINIUMOXIDE, 6), - new MaterialStack(getInstance().POTASSIUM, 6), - new MaterialStack(getInstance().CALCIUM, 4), - new MaterialStack(getInstance().SODIUM, 4), - new MaterialStack(getInstance().YTTERBIUM, 2) - });//Not a GT Inherited Material - - public static final Material RUNITE = new Material("Runite", MaterialState.SOLID, TextureSet.SET_FINE, new short[] {60, 200, 190}, 6750, 11550, 73, 87, true, "§", 0);//Not a GT Inherited Material - public static final Material DRAGON_METAL = new Material("Dragonblood", MaterialState.SOLID, TextureSet.SET_SHINY, new short[] {220, 40, 20, 2}, 10160, 17850, 96, 105, true, "۞", 0);//Not a GT Inherited Material - - } + // Custom Isotopes + public final Material LITHIUM7 = new Material( + "Lithium 7", + MaterialState.SOLID, + TextureSet.SET_SHINY, + Materials.Lithium.mRGBa, + Materials.Lithium.mMeltingPoint, + Materials.Lithium.mBlastFurnaceTemp, + Materials.Lithium.getProtons(), + Materials.Lithium.getNeutrons(), + Materials.Lithium.mBlastFurnaceRequired, + StringUtils.superscript("7Li"), + 0, + false); // Not a GT Inherited Material + public final Material URANIUM232 = new Material( + "Uranium 232", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + new short[] {88, 220, 103, 0}, + 1132, + 4131, + 92, + 140, + false, + StringUtils.superscript("232U"), + 4); // Not a GT Inherited Material + public final Material URANIUM233 = new Material( + "Uranium 233", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + new short[] {73, 220, 83, 0}, + 1132, + 4131, + 92, + 141, + false, + StringUtils.superscript("233U"), + 2); // Not a GT Inherited Material + public final Material THORIUM232 = new Material( + "Thorium 232", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + new short[] {15, 60, 15, 0}, + Materials.Thorium.mMeltingPoint, + Materials.Thorium.mBlastFurnaceTemp, + 90, + 142, + false, + StringUtils.superscript("232Th"), + 1, + true); // Not a GT Inherited Material + public final Material PLUTONIUM239 = new Material( + "Plutonium-239", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + Materials.Plutonium.mDurability, + Materials.Plutonium.mRGBa, + Materials.Plutonium.mMeltingPoint, + Materials.Plutonium.mBlastFurnaceTemp, + 94, + 145, + false, + StringUtils.superscript("239Pu"), + 4, + true); // Not a GT Inherited Material + // RTG Fuels + public final Material PLUTONIUM238 = new Material( + "Plutonium-238", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + Materials.Plutonium241.mDurability, + Materials.Plutonium241.mRGBa, + Materials.Plutonium241.mMeltingPoint, + Materials.Plutonium241.mBlastFurnaceTemp, + 94, + 144, + false, + StringUtils.superscript("238Pu"), + 2, + false); // Not a GT Inherited Material + public final Material STRONTIUM90 = new Material( + "Strontium-90", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + Materials.Strontium.mDurability, + Materials.Strontium.mRGBa, + Materials.Strontium.mMeltingPoint, + Materials.Strontium.mBlastFurnaceTemp, + 38, + 52, + false, + StringUtils.superscript("90Sr"), + 2, + false); // Not a GT Inherited Material + public final Material POLONIUM210 = new Material( + "Polonium-210", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + POLONIUM.vDurability, + POLONIUM.getRGBA(), + POLONIUM.getMeltingPointK(), + POLONIUM.getBoilingPointK(), + 84, + 126, + false, + StringUtils.superscript("210Po"), + 2, + false); // Not a GT Inherited Material + public final Material AMERICIUM241 = new Material( + "Americium-241", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + Materials.Americium.mDurability, + Materials.Americium.mRGBa, + Materials.Americium.mMeltingPoint, + Materials.Americium.mBlastFurnaceTemp, + 95, + 146, + false, + StringUtils.superscript("241Am"), + 2, + false); // Not a GT Inherited Material + public final Material MAGIC = MaterialUtils.generateMaterialFromGtENUM(Materials.Magic, new short[] {10, 185, 140}); + public final Material THAUMIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Thaumium); + static { + Logger.MATERIALS("Initialising Base Elements."); + } + + private static final ELEMENT INSTANCE = new ELEMENT(); + + public ELEMENT() { + // GTNH Trinium Handling + if (CORE.GTNH) { + // yay + Materials a1 = MaterialUtils.getMaterial("Trinium"); + Materials a2 = Materials.valueOf("Trinium"); + Materials a3 = Materials.get("Trinium"); + Materials a4; + if (a1 == null) { + Logger.INFO("[Material] First attempt to find Trinium failed, using backup method."); + if (a2 == null) { + Logger.INFO("[Material] Fallback attempt to find Trinium failed, using second fallback."); + if (a3 == null) { + Logger.INFO("[Material] Fallback attempt to find Trinium failed, dumping materials."); + for (Materials m : Materials.values()) { + Logger.INFO("[Material] Found " + MaterialUtils.getMaterialName(m)); + } + a4 = null; + } else { + Logger.INFO("[Material] a3 Found " + MaterialUtils.getMaterialName(a3)); + a4 = a3; + } + } else { + Logger.INFO("[Material] a2 Found " + MaterialUtils.getMaterialName(a2)); + a4 = a2; + } + TRINIUM = MaterialUtils.generateMaterialFromGtENUM(a4); + } else { + Logger.INFO("[Material] a1 Found " + MaterialUtils.getMaterialName(a1)); + TRINIUM = MaterialUtils.generateMaterialFromGtENUM(a1); + } + + TRINIUM_REFINED = TRINIUM; + + } else { + TRINIUM = new Material( + "Trinium", + MaterialState.SOLID, + TextureSet.SET_FINE, + new short[] {70, 110, 30}, + 604, + 4057, + 181, + 133, + false, + "Ke", + 0, + false); // Not a GT Inherited Material + TRINIUM_REFINED = new Material( + "Refined Trinium", + MaterialState.SOLID, + TextureSets.REFINED.get(), + new short[] {210, 255, 170}, + 4304, + 14057, + 181, + 133, + false, + "Ke", + 0, + new MaterialStack[] {new MaterialStack(TRINIUM, 1)}); // Not a GT Inherited Material + } + } + + public static ELEMENT getInstance() { + return INSTANCE; + } + + public static class STANDALONE { + + public static final Material CELESTIAL_TUNGSTEN = new Material( + "Celestial Tungsten", + MaterialState.SOLID, + TextureSets.REFINED.get(), + new short[] {50, 50, 50, 2}, + INSTANCE.TUNGSTEN.getMeltingPointC() + 6500, + INSTANCE.TUNGSTEN.getBoilingPointC() + 7500, + 160, + 101, + true, + "✦◆✦", + 0); // Not a GT Inherited Material + public static final Material ASTRAL_TITANIUM = new Material( + "Astral Titanium", + MaterialState.SOLID, + TextureSets.REFINED.get(), + new short[] {220, 160, 240, 2}, + INSTANCE.TITANIUM.getMeltingPointC() + 7500, + INSTANCE.TITANIUM.getBoilingPointC() + 7500, + 145, + 133, + true, + "✧◇✧", + 0); // Not a GT Inherited Material + public static final Material CHRONOMATIC_GLASS = new Material( + "Chromatic Glass", + MaterialState.SOLID, + new short[] {255, 255, 255, 3}, + 9200, + 17550, + 40, + 51, + false, + "⌘☯𓍰 𓍱 𓍲 𓍳 𓍴 𓍵 𓍶 𓍷 𓍸 ☯⌘ ", + 0); // Not a GT Inherited Material + public static final Material ADVANCED_NITINOL = new Material( + "Advanced Nitinol", + MaterialState.SOLID, + TextureSets.ENRICHED.get(), + ALLOY.NITINOL_60.getRGB(), + 8400, + 14377, + 40, + 51, + true, + "⚷⚙⚷ Ni4Ti6", + 0); // Not a GT Inherited Material + public static final Material HYPOGEN = new Material( + "Hypogen", + MaterialState.SOLID, + TextureSets.NUCLEAR.get(), + new short[] {220, 120, 75, 2}, + 12255, + 19377, + 240, + 251, + true, + "Hy⚶", + 0); // Not a GT Inherited Material + public static final Material RHUGNOR = new Material( + "Rhugnor", + MaterialState.SOLID, + TextureSets.ENRICHED.get(), + new short[] {190, 0, 255, 0}, + 8750, + 14757, + 184, + 142, + true, + "Fs⚶", + 0); // Not a GT Inherited Material //funeris + public static final Material FORCE = new Material( + "Force", + MaterialState.SOLID, + TextureSets.ENRICHED.get(), + new short[] {250, 250, 20, 0}, + 4550, + 6830, + 63, + 81, + true, + "Fc⚙", + 0); // Not a GT Inherited Material + + // Runescape materials + public static final Material BLACK_METAL = new Material( + "Black Metal", + MaterialState.SOLID, + TextureSet.SET_METALLIC, + new short[] {5, 5, 5}, + 2350, + 4650, + 24, + 17, + false, + "҈", + 0, + new MaterialStack[] { + new MaterialStack(getInstance().LEAD, 15), + new MaterialStack(getInstance().MANGANESE, 25), + new MaterialStack(getInstance().CARBON, 60) + }); // Not a GT Inherited Material + public static final Material WHITE_METAL = new Material( + "White Metal", + MaterialState.SOLID, + TextureSet.SET_METALLIC, + new short[] {255, 255, 255}, + 4560, + 7580, + 35, + 41, + false, + "҉", + 0, + new MaterialStack[] { + new MaterialStack(getInstance().COPPER, 5), + new MaterialStack(getInstance().ANTIMONY, 10), + new MaterialStack(getInstance().PLATINUM, 10), + new MaterialStack(getInstance().TIN, 75) + }); // Not a GT Inherited Material + + public static final Material GRANITE = new Material( + "Ancient Granite", + MaterialState.SOLID, + TextureSet.SET_SAND, + new short[] {107, 107, 107}, + 500, + 2000, + 16, + 12, + false, + "«»", + 0, + false, + new MaterialStack[] { + new MaterialStack(getInstance().OXYGEN, 16), + new MaterialStack(getInstance().IRON, 10), + new MaterialStack(getInstance().SILICONDIOXIDE, 10), + new MaterialStack(getInstance().ALUMINIUMOXIDE, 6), + new MaterialStack(getInstance().POTASSIUM, 6), + new MaterialStack(getInstance().CALCIUM, 4), + new MaterialStack(getInstance().SODIUM, 4), + new MaterialStack(getInstance().YTTERBIUM, 2) + }); // Not a GT Inherited Material + + public static final Material RUNITE = new Material( + "Runite", + MaterialState.SOLID, + TextureSet.SET_FINE, + new short[] {60, 200, 190}, + 6750, + 11550, + 73, + 87, + true, + "§", + 0); // Not a GT Inherited Material + public static final Material DRAGON_METAL = new Material( + "Dragonblood", + MaterialState.SOLID, + TextureSet.SET_SHINY, + new short[] {220, 40, 20, 2}, + 10160, + 17850, + 96, + 105, + true, + "۞", + 0); // Not a GT Inherited Material + } } diff --git a/src/main/java/gtPlusPlus/core/material/Ion.java b/src/main/java/gtPlusPlus/core/material/Ion.java index 2b5b113b92..37dc59f642 100644 --- a/src/main/java/gtPlusPlus/core/material/Ion.java +++ b/src/main/java/gtPlusPlus/core/material/Ion.java @@ -2,29 +2,29 @@ package gtPlusPlus.core.material; public class Ion { - private final Material mElement; - private final boolean mContainsPositiveCharge; - private final int mTotalIonization; + private final Material mElement; + private final boolean mContainsPositiveCharge; + private final int mTotalIonization; - public Ion(Material aMat, int chargeAmount) { - mElement = aMat; - mContainsPositiveCharge = (chargeAmount >= 0); - mTotalIonization = chargeAmount; - } - - public synchronized final Material getElement() { - return mElement; - } + public Ion(Material aMat, int chargeAmount) { + mElement = aMat; + mContainsPositiveCharge = (chargeAmount >= 0); + mTotalIonization = chargeAmount; + } - public synchronized final boolean containsPositiveCharge() { - return mContainsPositiveCharge; - } + public final synchronized Material getElement() { + return mElement; + } - public synchronized final int getTotalIonization() { - return mTotalIonization; - } - - public final boolean isNeutral() { - return mTotalIonization == 0; - } + public final synchronized boolean containsPositiveCharge() { + return mContainsPositiveCharge; + } + + public final synchronized int getTotalIonization() { + return mTotalIonization; + } + + public final boolean isNeutral() { + return mTotalIonization == 0; + } } diff --git a/src/main/java/gtPlusPlus/core/material/MISC_MATERIALS.java b/src/main/java/gtPlusPlus/core/material/MISC_MATERIALS.java index 1b681cd9fa..c70013bac3 100644 --- a/src/main/java/gtPlusPlus/core/material/MISC_MATERIALS.java +++ b/src/main/java/gtPlusPlus/core/material/MISC_MATERIALS.java @@ -7,600 +7,596 @@ import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.MaterialUtils; -public final class MISC_MATERIALS { - - /* - * Some of these materials purely exist as data objects, items will most likely be assigned seperately. - * Most are just compositions which will have dusts assigned to them. - */ - - public static void run() { - MaterialUtils.generateSpecialDustAndAssignToAMaterial(POTASSIUM_NITRATE, false); - MaterialUtils.generateSpecialDustAndAssignToAMaterial(SODIUM_NITRATE, false); - MaterialUtils.generateSpecialDustAndAssignToAMaterial(STRONTIUM_OXIDE, false); - MaterialUtils.generateSpecialDustAndAssignToAMaterial(STRONTIUM_HYDROXIDE, false); - MaterialUtils.generateSpecialDustAndAssignToAMaterial(CYANOACETIC_ACID, false); - MaterialUtils.generateSpecialDustAndAssignToAMaterial(SODIUM_CYANIDE, false); - MaterialUtils.generateSpecialDustAndAssignToAMaterial(CALCIUM_CHLORIDE, false); - MaterialUtils.generateSpecialDustAndAssignToAMaterial(COPPER_SULFATE, false); - MaterialUtils.generateSpecialDustAndAssignToAMaterial(COPPER_SULFATE_HYDRATED, false); - WATER.registerComponentForMaterial(FluidUtils.getWater(1000)); - } - - public static final Material POTASSIUM_NITRATE = new Material( - "Potassium Nitrate", - MaterialState.SOLID, //State - null, - null, - -1, - -1, - -1, - -1, - false, - "KNO3", - 0, - false, - new MaterialStack(ELEMENT.getInstance().POTASSIUM, 1), - new MaterialStack(ELEMENT.getInstance().NITROGEN, 1), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 3)); - public static final Material SODIUM_NITRATE = new Material( - "Sodium Nitrate", - MaterialState.SOLID, //State - null, - null, - -1, - -1, - -1, - -1, - false, - "NaNO3", - 0, - false, - new MaterialStack(ELEMENT.getInstance().SODIUM, 1), - new MaterialStack(ELEMENT.getInstance().NITROGEN, 1), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 3)); - - public static final Material SOLAR_SALT_COLD = new Material( - "Solar Salt (Cold)", - MaterialState.PURE_LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack(POTASSIUM_NITRATE, 4), - new MaterialStack(SODIUM_NITRATE, 6)); - - public static final Material SOLAR_SALT_HOT = new Material( - "Solar Salt (Hot)", - MaterialState.PURE_LIQUID, //State - new short[] {200, 25, 25}, //Material Colour - 1200, //Melting Point in C - 3300, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack(POTASSIUM_NITRATE, 4), - new MaterialStack(SODIUM_NITRATE, 6)); - - public static final Material STRONTIUM_OXIDE = new Material( - "Strontium Oxide", - MaterialState.SOLID, - TextureSet.SET_METALLIC, - null, - -1, - -1, - -1, - -1, - false, - "SrO", - 0, - false, - new MaterialStack(ELEMENT.getInstance().STRONTIUM, 1), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 1)); - - public static final Material SELENIUM_DIOXIDE = new Material( - "Selenium Dioxide", - MaterialState.PURE_LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack(ELEMENT.getInstance().SELENIUM, 1), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 2)); - - public static final Material SELENIOUS_ACID = new Material( - "Selenious Acid", - MaterialState.PURE_LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack(SELENIUM_DIOXIDE, 1), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 8), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 4)); - - public static final Material HYDROGEN_CYANIDE = new Material( - "Hydrogen Cyanide", - MaterialState.PURE_GAS, //State - null, //Material Colour - 4, //Melting Point in C - 26, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 1), - new MaterialStack(ELEMENT.getInstance().CARBON, 1), - new MaterialStack(ELEMENT.getInstance().NITROGEN, 1)); - - public static final Material CARBON_MONOXIDE = new Material( - "Carbon Monoxide", - MaterialState.PURE_GAS, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack(ELEMENT.getInstance().CARBON, 1), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 1)); - - public static final Material CARBON_DIOXIDE = new Material( - "Carbon Dioxide", - MaterialState.PURE_GAS, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack(ELEMENT.getInstance().CARBON, 1), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 2)); - - public static final Material WOODS_GLASS = new Material( - "Wood's Glass", //Material Name - MaterialState.SOLID, //State - TextureSets.GEM_A.get(), //Texture Set - new short[] {220, 60, 255}, //Material Colour - -1, - -1, - -1, - -1, - false, - "Si4Ba3Na2Ni", - 0, - false, - new MaterialStack(ELEMENT.getInstance().SILICON, 40), - new MaterialStack(ELEMENT.getInstance().BARIUM, 30), - new MaterialStack(ELEMENT.getInstance().SODIUM, 20), - new MaterialStack(ELEMENT.getInstance().NICKEL, 10)); - - - /* - * Rare Earth Materials - */ - - public static final Material RARE_EARTH_LOW = new Material( - "Rare Earth (I)", //Material Name - MaterialState.ORE, //State - TextureSets.GEM_A.get(), //Texture Set - null, //Material Colour - 1200, - 2500, - -1, - -1, - -1, //Radiation - new MaterialStack[]{ - new MaterialStack(ORES.GREENOCKITE, 1), - new MaterialStack(ORES.LANTHANITE_CE, 1), - new MaterialStack(ORES.AGARDITE_CD, 1), - new MaterialStack(ORES.YTTRIALITE, 1), - new MaterialStack(MaterialUtils.generateMaterialFromGtENUM(Materials.NetherQuartz), 1), - new MaterialStack(MaterialUtils.generateMaterialFromGtENUM(Materials.Galena), 1), - new MaterialStack(MaterialUtils.generateMaterialFromGtENUM(Materials.Chalcopyrite), 1), - new MaterialStack(ORES.CRYOLITE, 1), - new MaterialStack(ELEMENT.getInstance().YTTRIUM, 1) - }); - - public static final Material RARE_EARTH_MID = new Material( - "Rare Earth (II)", //Material Name - MaterialState.ORE, //State - TextureSets.ENRICHED.get(), //Texture Set - null, //Material Colour - 3500, - 5000, - -1, - -1, - -1, //Radiation - new MaterialStack[]{ - new MaterialStack(ORES.LANTHANITE_ND, 1), - new MaterialStack(ORES.AGARDITE_ND, 1), - new MaterialStack(ORES.YTTRIAITE, 1), - new MaterialStack(ORES.CROCROITE, 1), - new MaterialStack(ORES.NICHROMITE, 1), - new MaterialStack(ORES.ZIRCON, 1), - new MaterialStack(ELEMENT.STANDALONE.GRANITE, 1), - new MaterialStack(ELEMENT.STANDALONE.BLACK_METAL, 1), - new MaterialStack(ELEMENT.STANDALONE.RUNITE, 1) - }); - - public static final Material RARE_EARTH_HIGH = new Material( - "Rare Earth (III)", //Material Name - MaterialState.ORE, //State - TextureSets.REFINED.get(), //Texture Set - null, //Material Colour - 5200, - 7500, - -1, - -1, - -1, //Radiation - new MaterialStack[]{ - new MaterialStack(ORES.GADOLINITE_Y, 1), - new MaterialStack(ORES.LEPERSONNITE, 1), - new MaterialStack(ORES.FLORENCITE, 1), - new MaterialStack(ORES.FLUORCAPHITE, 1), - new MaterialStack(ORES.LAUTARITE, 1), - new MaterialStack(ORES.DEMICHELEITE_BR, 1), - new MaterialStack(ORES.ALBURNITE, 1), - new MaterialStack(ORES.SAMARSKITE_Y, 1), - new MaterialStack(ORES.AGARDITE_LA, 1), - }); - - public static final Material WATER = new Material( - "Water", - MaterialState.PURE_LIQUID, - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 2), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 1)); - - //OH - public static final Material HYDROXIDE = new Material( - "Hydroxide", //Material Name - MaterialState.PURE_LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack(ELEMENT.getInstance().OXYGEN, 1), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 1)); - - //NH3 - public static final Material AMMONIA = new Material( - "Ammonia", //Material Name - MaterialState.PURE_LIQUID, //State - null, //Material Colour - -77, //Melting Point in C - -33, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack(ELEMENT.getInstance().NITROGEN, 1), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 3)); - - //NH4 - public static final Material AMMONIUM = new Material( - "Ammonium", //Material Name - MaterialState.PURE_LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack(ELEMENT.getInstance().NITROGEN, 1), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 4)); - - - public static final Material HYDROGEN_CHLORIDE = new Material( - "Hydrogen Chloride", - MaterialState.PURE_GAS, - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 1), - new MaterialStack(ELEMENT.getInstance().CHLORINE, 1)); - - - public static final Material SODIUM_CHLORIDE = new Material( - "Sodium Chloride", - MaterialState.PURE_GAS, - new MaterialStack(ELEMENT.getInstance().SODIUM, 1), - new MaterialStack(ELEMENT.getInstance().CHLORINE, 1)); - - - public static final Material SODIUM_HYDROXIDE = new Material( - "Sodium Hydroxide", - MaterialState.PURE_GAS, - new MaterialStack(ELEMENT.getInstance().SODIUM, 1), - new MaterialStack(HYDROXIDE, 1)); - - public static final Material SALT_WATER = new Material( - "Salt Water", - MaterialState.PURE_LIQUID, - new MaterialStack(WATER, 3), - new MaterialStack(SODIUM_CHLORIDE, 1)); - - public static final Material BRINE = new Material( - "Brine", - MaterialState.PURE_LIQUID, - new MaterialStack(SALT_WATER, 1), - new MaterialStack(SODIUM_CHLORIDE, 2)); - - public static final Material STRONTIUM_HYDROXIDE = new Material( - "Strontium Hydroxide", - MaterialState.SOLID, - TextureSet.SET_METALLIC, - null, - -1, - -1, - -1, - -1, - false, - "Sr(OH)2", - 0, - false, - new MaterialStack(ELEMENT.getInstance().STRONTIUM, 1), - new MaterialStack(MISC_MATERIALS.HYDROXIDE, 2)); - - // Glue Chemicals - - public static final Material ACETIC_ANHYDRIDE = new Material( - "Acetic Anhydride", - MaterialState.PURE_LIQUID, //State - new short[] {250, 240, 110}, //Material Colour - -73, //Melting Point in C - 139, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - "(CH3CO)2O", - 0, - true, - new MaterialStack(ELEMENT.getInstance().CARBON, 4), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 6), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 3)); - - public static final Material CHLOROACETIC_ACID = new Material( - "Chloroacetic Acid", - MaterialState.PURE_LIQUID, //State - new short[] {230, 200, 90}, //Material Colour - 63, //Melting Point in C - 189, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - "ClCH2-COOH", - 0, - true, - new MaterialStack(ELEMENT.getInstance().CARBON, 2), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 3), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 2), - new MaterialStack(ELEMENT.getInstance().CHLORINE, 1)); - - public static final Material DICHLOROACETIC_ACID = new Material( - "Dichloroacetic Acid", - MaterialState.PURE_LIQUID, //State - new short[] {190, 160, 60}, //Material Colour - 13, //Melting Point in C - 194, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - "Cl2CH-COOH", - 0, - true, - new MaterialStack(ELEMENT.getInstance().CARBON, 2), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 2), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 2), - new MaterialStack(ELEMENT.getInstance().CHLORINE, 2)); - - public static final Material TRICHLOROACETIC_ACID = new Material( - "Trichloroacetic Acid", - MaterialState.PURE_LIQUID, //State - new short[] {120, 100, 30}, //Material Colour - 57, //Melting Point in C - 196, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - "Cl3C-COOH", - 0, - true, - new MaterialStack(ELEMENT.getInstance().CARBON, 2), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 1), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 2), - new MaterialStack(ELEMENT.getInstance().CHLORINE, 3)); - - public static final Material CHLOROACETIC_MIXTURE = new Material( - "Chloroacetic Mixture", - MaterialState.LIQUID, //State - null, - new short[] {210, 160, 10}, - 40, - 192, - -1, - -1, - false, - "Cl?H?C-COOH", - 0, - true, - new MaterialStack(ELEMENT.getInstance().CARBON, 6), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 6), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 6), - new MaterialStack(ELEMENT.getInstance().CHLORINE, 6)); - - public static final Material SODIUM_CYANIDE = new Material( - "Sodium Cyanide", - MaterialState.SOLID, //State - new short[] {180, 190, 255}, //Material Colour - 563, //Melting Point in C - 1496, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - "NaCN", - 0, - false, - new MaterialStack(ELEMENT.getInstance().SODIUM, 1), - new MaterialStack(ELEMENT.getInstance().CARBON, 1), - new MaterialStack(ELEMENT.getInstance().NITROGEN, 1)); - - public static final Material CALCIUM_CHLORIDE = new Material( - "Calcium Chloride", - MaterialState.SOLID, //State - new short[] {180, 190, 255}, //Material Colour - 563, //Melting Point in C - 1496, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - "CaCl2", - 0, - false, - new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), - new MaterialStack(ELEMENT.getInstance().CHLORINE, 2)); - - public static final Material CYANOACETIC_ACID = new Material( - "Cyanoacetic Acid", - MaterialState.SOLID, //State - new short[] {130, 130, 40}, //Material Colour - 66, //Melting Point in C - 108, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - "C3H3NO2", - 0, - false, - new MaterialStack(ELEMENT.getInstance().CARBON, 3), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 3), - new MaterialStack(ELEMENT.getInstance().NITROGEN, 1), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 2)); - - public static final Material SOLID_ACID_MIXTURE = new Material( - "Solid Acid Catalyst Mixture", - MaterialState.LIQUID, //State - new short[] {80, 40, 0}, //Material Colour - -10, //Melting Point in C - 337, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - "?H2SO4?", - 0, - true, - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 2), - new MaterialStack(ELEMENT.getInstance().SULFUR, 1), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 4)); - - public static final Material COPPER_SULFATE = new Material( - "Copper(II) Sulfate", - MaterialState.SOLID, //State - new short[] {200, 200, 200}, //Material Colour - 590, //Melting Point in C - 650, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - "CuSO4", - 0, - false, - new MaterialStack(ELEMENT.getInstance().COPPER, 1), - new MaterialStack(ELEMENT.getInstance().SULFUR, 1), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 4)); - - public static final Material COPPER_SULFATE_HYDRATED = new Material( - "Copper(II) Sulfate Pentahydrate", - MaterialState.SOLID, //State - new short[] {90, 170, 255}, //Material Colour - 590, //Melting Point in C - 650, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - "CuSO4∙(H2O)5", - 0, - false, - new MaterialStack(ELEMENT.getInstance().COPPER, 1), - new MaterialStack(ELEMENT.getInstance().SULFUR, 1), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 4)); - - public static final Material ETHYL_CYANOACETATE = new Material( - "Ethyl Cyanoacetate", - MaterialState.PURE_LIQUID, //State - new short[] {0, 75, 160}, //Material Colour - -22, //Melting Point in C - 210, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - "C5H7NO2", - 0, - true, - new MaterialStack(ELEMENT.getInstance().CARBON, 2), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 1), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 2), - new MaterialStack(ELEMENT.getInstance().CHLORINE, 3)); - - public static final Material CYANOACRYLATE_POLYMER = new Material( - "Cyanoacrylate Polymer", - MaterialState.LIQUID, //State - new short[] {140, 150, 160}, //Material Colour - -25, //Melting Point in C - 55, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - "(-C6H7NO2-)n", - 0, - true, - new MaterialStack(ELEMENT.getInstance().CARBON, 2), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 1), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 2), - new MaterialStack(ELEMENT.getInstance().CHLORINE, 3)); - - public static final Material ETHYL_CYANOACRYLATE = new Material( - "Ethyl Cyanoacrylate (Super Glue)", - MaterialState.PURE_LIQUID, //State - new short[] {170, 190, 200}, //Material Colour - -25, //Melting Point in C - 55, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - "C6H7NO2", - 0, - true, - new MaterialStack(ELEMENT.getInstance().CARBON, 2), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 1), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 2), - new MaterialStack(ELEMENT.getInstance().CHLORINE, 3)); - - public static final Material MUTATED_LIVING_SOLDER = new Material( - "Mutated Living Solder", - MaterialState.PURE_LIQUID, //State - new short[] {147, 109, 155}, //Material Colour - -200, //Melting Point in C - 500, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - "?Sn?Bi?", - 0, - true, - new MaterialStack(ELEMENT.getInstance().TIN, 1), - new MaterialStack(ELEMENT.getInstance().BISMUTH, 1)); +public final class MISC_MATERIALS { + + /* + * Some of these materials purely exist as data objects, items will most likely be assigned seperately. + * Most are just compositions which will have dusts assigned to them. + */ + + public static void run() { + MaterialUtils.generateSpecialDustAndAssignToAMaterial(POTASSIUM_NITRATE, false); + MaterialUtils.generateSpecialDustAndAssignToAMaterial(SODIUM_NITRATE, false); + MaterialUtils.generateSpecialDustAndAssignToAMaterial(STRONTIUM_OXIDE, false); + MaterialUtils.generateSpecialDustAndAssignToAMaterial(STRONTIUM_HYDROXIDE, false); + MaterialUtils.generateSpecialDustAndAssignToAMaterial(CYANOACETIC_ACID, false); + MaterialUtils.generateSpecialDustAndAssignToAMaterial(SODIUM_CYANIDE, false); + MaterialUtils.generateSpecialDustAndAssignToAMaterial(CALCIUM_CHLORIDE, false); + MaterialUtils.generateSpecialDustAndAssignToAMaterial(COPPER_SULFATE, false); + MaterialUtils.generateSpecialDustAndAssignToAMaterial(COPPER_SULFATE_HYDRATED, false); + WATER.registerComponentForMaterial(FluidUtils.getWater(1000)); + } + + public static final Material POTASSIUM_NITRATE = new Material( + "Potassium Nitrate", + MaterialState.SOLID, // State + null, + null, + -1, + -1, + -1, + -1, + false, + "KNO3", + 0, + false, + new MaterialStack(ELEMENT.getInstance().POTASSIUM, 1), + new MaterialStack(ELEMENT.getInstance().NITROGEN, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 3)); + public static final Material SODIUM_NITRATE = new Material( + "Sodium Nitrate", + MaterialState.SOLID, // State + null, + null, + -1, + -1, + -1, + -1, + false, + "NaNO3", + 0, + false, + new MaterialStack(ELEMENT.getInstance().SODIUM, 1), + new MaterialStack(ELEMENT.getInstance().NITROGEN, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 3)); + + public static final Material SOLAR_SALT_COLD = new Material( + "Solar Salt (Cold)", + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack(POTASSIUM_NITRATE, 4), + new MaterialStack(SODIUM_NITRATE, 6)); + + public static final Material SOLAR_SALT_HOT = new Material( + "Solar Salt (Hot)", + MaterialState.PURE_LIQUID, // State + new short[] {200, 25, 25}, // Material Colour + 1200, // Melting Point in C + 3300, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack(POTASSIUM_NITRATE, 4), + new MaterialStack(SODIUM_NITRATE, 6)); + + public static final Material STRONTIUM_OXIDE = new Material( + "Strontium Oxide", + MaterialState.SOLID, + TextureSet.SET_METALLIC, + null, + -1, + -1, + -1, + -1, + false, + "SrO", + 0, + false, + new MaterialStack(ELEMENT.getInstance().STRONTIUM, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 1)); + + public static final Material SELENIUM_DIOXIDE = new Material( + "Selenium Dioxide", + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack(ELEMENT.getInstance().SELENIUM, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 2)); + + public static final Material SELENIOUS_ACID = new Material( + "Selenious Acid", + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack(SELENIUM_DIOXIDE, 1), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 8), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 4)); + + public static final Material HYDROGEN_CYANIDE = new Material( + "Hydrogen Cyanide", + MaterialState.PURE_GAS, // State + null, // Material Colour + 4, // Melting Point in C + 26, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 1), + new MaterialStack(ELEMENT.getInstance().CARBON, 1), + new MaterialStack(ELEMENT.getInstance().NITROGEN, 1)); + + public static final Material CARBON_MONOXIDE = new Material( + "Carbon Monoxide", + MaterialState.PURE_GAS, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack(ELEMENT.getInstance().CARBON, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 1)); + + public static final Material CARBON_DIOXIDE = new Material( + "Carbon Dioxide", + MaterialState.PURE_GAS, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack(ELEMENT.getInstance().CARBON, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 2)); + + public static final Material WOODS_GLASS = new Material( + "Wood's Glass", // Material Name + MaterialState.SOLID, // State + TextureSets.GEM_A.get(), // Texture Set + new short[] {220, 60, 255}, // Material Colour + -1, + -1, + -1, + -1, + false, + "Si4Ba3Na2Ni", + 0, + false, + new MaterialStack(ELEMENT.getInstance().SILICON, 40), + new MaterialStack(ELEMENT.getInstance().BARIUM, 30), + new MaterialStack(ELEMENT.getInstance().SODIUM, 20), + new MaterialStack(ELEMENT.getInstance().NICKEL, 10)); + + /* + * Rare Earth Materials + */ + + public static final Material RARE_EARTH_LOW = new Material( + "Rare Earth (I)", // Material Name + MaterialState.ORE, // State + TextureSets.GEM_A.get(), // Texture Set + null, // Material Colour + 1200, + 2500, + -1, + -1, + -1, // Radiation + new MaterialStack[] { + new MaterialStack(ORES.GREENOCKITE, 1), + new MaterialStack(ORES.LANTHANITE_CE, 1), + new MaterialStack(ORES.AGARDITE_CD, 1), + new MaterialStack(ORES.YTTRIALITE, 1), + new MaterialStack(MaterialUtils.generateMaterialFromGtENUM(Materials.NetherQuartz), 1), + new MaterialStack(MaterialUtils.generateMaterialFromGtENUM(Materials.Galena), 1), + new MaterialStack(MaterialUtils.generateMaterialFromGtENUM(Materials.Chalcopyrite), 1), + new MaterialStack(ORES.CRYOLITE, 1), + new MaterialStack(ELEMENT.getInstance().YTTRIUM, 1) + }); + + public static final Material RARE_EARTH_MID = new Material( + "Rare Earth (II)", // Material Name + MaterialState.ORE, // State + TextureSets.ENRICHED.get(), // Texture Set + null, // Material Colour + 3500, + 5000, + -1, + -1, + -1, // Radiation + new MaterialStack[] { + new MaterialStack(ORES.LANTHANITE_ND, 1), + new MaterialStack(ORES.AGARDITE_ND, 1), + new MaterialStack(ORES.YTTRIAITE, 1), + new MaterialStack(ORES.CROCROITE, 1), + new MaterialStack(ORES.NICHROMITE, 1), + new MaterialStack(ORES.ZIRCON, 1), + new MaterialStack(ELEMENT.STANDALONE.GRANITE, 1), + new MaterialStack(ELEMENT.STANDALONE.BLACK_METAL, 1), + new MaterialStack(ELEMENT.STANDALONE.RUNITE, 1) + }); + + public static final Material RARE_EARTH_HIGH = new Material( + "Rare Earth (III)", // Material Name + MaterialState.ORE, // State + TextureSets.REFINED.get(), // Texture Set + null, // Material Colour + 5200, + 7500, + -1, + -1, + -1, // Radiation + new MaterialStack[] { + new MaterialStack(ORES.GADOLINITE_Y, 1), + new MaterialStack(ORES.LEPERSONNITE, 1), + new MaterialStack(ORES.FLORENCITE, 1), + new MaterialStack(ORES.FLUORCAPHITE, 1), + new MaterialStack(ORES.LAUTARITE, 1), + new MaterialStack(ORES.DEMICHELEITE_BR, 1), + new MaterialStack(ORES.ALBURNITE, 1), + new MaterialStack(ORES.SAMARSKITE_Y, 1), + new MaterialStack(ORES.AGARDITE_LA, 1), + }); + + public static final Material WATER = new Material( + "Water", + MaterialState.PURE_LIQUID, + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 2), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 1)); + + // OH + public static final Material HYDROXIDE = new Material( + "Hydroxide", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack(ELEMENT.getInstance().OXYGEN, 1), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 1)); + + // NH3 + public static final Material AMMONIA = new Material( + "Ammonia", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -77, // Melting Point in C + -33, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack(ELEMENT.getInstance().NITROGEN, 1), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 3)); + + // NH4 + public static final Material AMMONIUM = new Material( + "Ammonium", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack(ELEMENT.getInstance().NITROGEN, 1), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 4)); + + public static final Material HYDROGEN_CHLORIDE = new Material( + "Hydrogen Chloride", + MaterialState.PURE_GAS, + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 1), + new MaterialStack(ELEMENT.getInstance().CHLORINE, 1)); + + public static final Material SODIUM_CHLORIDE = new Material( + "Sodium Chloride", + MaterialState.PURE_GAS, + new MaterialStack(ELEMENT.getInstance().SODIUM, 1), + new MaterialStack(ELEMENT.getInstance().CHLORINE, 1)); + + public static final Material SODIUM_HYDROXIDE = new Material( + "Sodium Hydroxide", + MaterialState.PURE_GAS, + new MaterialStack(ELEMENT.getInstance().SODIUM, 1), + new MaterialStack(HYDROXIDE, 1)); + + public static final Material SALT_WATER = new Material( + "Salt Water", + MaterialState.PURE_LIQUID, + new MaterialStack(WATER, 3), + new MaterialStack(SODIUM_CHLORIDE, 1)); + + public static final Material BRINE = new Material( + "Brine", + MaterialState.PURE_LIQUID, + new MaterialStack(SALT_WATER, 1), + new MaterialStack(SODIUM_CHLORIDE, 2)); + + public static final Material STRONTIUM_HYDROXIDE = new Material( + "Strontium Hydroxide", + MaterialState.SOLID, + TextureSet.SET_METALLIC, + null, + -1, + -1, + -1, + -1, + false, + "Sr(OH)2", + 0, + false, + new MaterialStack(ELEMENT.getInstance().STRONTIUM, 1), + new MaterialStack(MISC_MATERIALS.HYDROXIDE, 2)); + + // Glue Chemicals + + public static final Material ACETIC_ANHYDRIDE = new Material( + "Acetic Anhydride", + MaterialState.PURE_LIQUID, // State + new short[] {250, 240, 110}, // Material Colour + -73, // Melting Point in C + 139, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + "(CH3CO)2O", + 0, + true, + new MaterialStack(ELEMENT.getInstance().CARBON, 4), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 6), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 3)); + + public static final Material CHLOROACETIC_ACID = new Material( + "Chloroacetic Acid", + MaterialState.PURE_LIQUID, // State + new short[] {230, 200, 90}, // Material Colour + 63, // Melting Point in C + 189, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + "ClCH2-COOH", + 0, + true, + new MaterialStack(ELEMENT.getInstance().CARBON, 2), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 3), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 2), + new MaterialStack(ELEMENT.getInstance().CHLORINE, 1)); + + public static final Material DICHLOROACETIC_ACID = new Material( + "Dichloroacetic Acid", + MaterialState.PURE_LIQUID, // State + new short[] {190, 160, 60}, // Material Colour + 13, // Melting Point in C + 194, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + "Cl2CH-COOH", + 0, + true, + new MaterialStack(ELEMENT.getInstance().CARBON, 2), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 2), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 2), + new MaterialStack(ELEMENT.getInstance().CHLORINE, 2)); + + public static final Material TRICHLOROACETIC_ACID = new Material( + "Trichloroacetic Acid", + MaterialState.PURE_LIQUID, // State + new short[] {120, 100, 30}, // Material Colour + 57, // Melting Point in C + 196, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + "Cl3C-COOH", + 0, + true, + new MaterialStack(ELEMENT.getInstance().CARBON, 2), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 2), + new MaterialStack(ELEMENT.getInstance().CHLORINE, 3)); + + public static final Material CHLOROACETIC_MIXTURE = new Material( + "Chloroacetic Mixture", + MaterialState.LIQUID, // State + null, + new short[] {210, 160, 10}, + 40, + 192, + -1, + -1, + false, + "Cl?H?C-COOH", + 0, + true, + new MaterialStack(ELEMENT.getInstance().CARBON, 6), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 6), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 6), + new MaterialStack(ELEMENT.getInstance().CHLORINE, 6)); + + public static final Material SODIUM_CYANIDE = new Material( + "Sodium Cyanide", + MaterialState.SOLID, // State + new short[] {180, 190, 255}, // Material Colour + 563, // Melting Point in C + 1496, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + "NaCN", + 0, + false, + new MaterialStack(ELEMENT.getInstance().SODIUM, 1), + new MaterialStack(ELEMENT.getInstance().CARBON, 1), + new MaterialStack(ELEMENT.getInstance().NITROGEN, 1)); + + public static final Material CALCIUM_CHLORIDE = new Material( + "Calcium Chloride", + MaterialState.SOLID, // State + new short[] {180, 190, 255}, // Material Colour + 563, // Melting Point in C + 1496, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + "CaCl2", + 0, + false, + new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), + new MaterialStack(ELEMENT.getInstance().CHLORINE, 2)); + + public static final Material CYANOACETIC_ACID = new Material( + "Cyanoacetic Acid", + MaterialState.SOLID, // State + new short[] {130, 130, 40}, // Material Colour + 66, // Melting Point in C + 108, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + "C3H3NO2", + 0, + false, + new MaterialStack(ELEMENT.getInstance().CARBON, 3), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 3), + new MaterialStack(ELEMENT.getInstance().NITROGEN, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 2)); + + public static final Material SOLID_ACID_MIXTURE = new Material( + "Solid Acid Catalyst Mixture", + MaterialState.LIQUID, // State + new short[] {80, 40, 0}, // Material Colour + -10, // Melting Point in C + 337, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + "?H2SO4?", + 0, + true, + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 2), + new MaterialStack(ELEMENT.getInstance().SULFUR, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 4)); + + public static final Material COPPER_SULFATE = new Material( + "Copper(II) Sulfate", + MaterialState.SOLID, // State + new short[] {200, 200, 200}, // Material Colour + 590, // Melting Point in C + 650, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + "CuSO4", + 0, + false, + new MaterialStack(ELEMENT.getInstance().COPPER, 1), + new MaterialStack(ELEMENT.getInstance().SULFUR, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 4)); + + public static final Material COPPER_SULFATE_HYDRATED = new Material( + "Copper(II) Sulfate Pentahydrate", + MaterialState.SOLID, // State + new short[] {90, 170, 255}, // Material Colour + 590, // Melting Point in C + 650, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + "CuSO4∙(H2O)5", + 0, + false, + new MaterialStack(ELEMENT.getInstance().COPPER, 1), + new MaterialStack(ELEMENT.getInstance().SULFUR, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 4)); + + public static final Material ETHYL_CYANOACETATE = new Material( + "Ethyl Cyanoacetate", + MaterialState.PURE_LIQUID, // State + new short[] {0, 75, 160}, // Material Colour + -22, // Melting Point in C + 210, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + "C5H7NO2", + 0, + true, + new MaterialStack(ELEMENT.getInstance().CARBON, 2), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 2), + new MaterialStack(ELEMENT.getInstance().CHLORINE, 3)); + + public static final Material CYANOACRYLATE_POLYMER = new Material( + "Cyanoacrylate Polymer", + MaterialState.LIQUID, // State + new short[] {140, 150, 160}, // Material Colour + -25, // Melting Point in C + 55, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + "(-C6H7NO2-)n", + 0, + true, + new MaterialStack(ELEMENT.getInstance().CARBON, 2), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 2), + new MaterialStack(ELEMENT.getInstance().CHLORINE, 3)); + + public static final Material ETHYL_CYANOACRYLATE = new Material( + "Ethyl Cyanoacrylate (Super Glue)", + MaterialState.PURE_LIQUID, // State + new short[] {170, 190, 200}, // Material Colour + -25, // Melting Point in C + 55, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + "C6H7NO2", + 0, + true, + new MaterialStack(ELEMENT.getInstance().CARBON, 2), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 2), + new MaterialStack(ELEMENT.getInstance().CHLORINE, 3)); + + public static final Material MUTATED_LIVING_SOLDER = new Material( + "Mutated Living Solder", + MaterialState.PURE_LIQUID, // State + new short[] {147, 109, 155}, // Material Colour + -200, // Melting Point in C + 500, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + "?Sn?Bi?", + 0, + true, + new MaterialStack(ELEMENT.getInstance().TIN, 1), + new MaterialStack(ELEMENT.getInstance().BISMUTH, 1)); } diff --git a/src/main/java/gtPlusPlus/core/material/Material.java b/src/main/java/gtPlusPlus/core/material/Material.java index 748db12590..7074bf5419 100644 --- a/src/main/java/gtPlusPlus/core/material/Material.java +++ b/src/main/java/gtPlusPlus/core/material/Material.java @@ -3,12 +3,6 @@ package gtPlusPlus.core.material; import static gregtech.api.enums.GT_Values.M; import static gtPlusPlus.core.util.math.MathUtils.safeCast_LongToInt; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.TextureSet; @@ -28,6 +22,11 @@ import gtPlusPlus.xmod.gregtech.api.enums.CustomOrePrefix; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechConduits; import gtPlusPlus.xmod.thaumcraft.objects.wrapper.aspect.TC_Aspect_Wrapper; import gtPlusPlus.xmod.tinkers.material.BaseTinkersMaterial; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.Item; @@ -37,1500 +36,1791 @@ import net.minecraftforge.fluids.FluidStack; public class Material { - public static final Set mMaterialMap = new HashSet(); - public static HashMap mMaterialCache = new HashMap(); - - public static final Map> mComponentMap = new HashMap>(); - - public static HashMap sChemicalFormula = new HashMap(); - - private String unlocalizedName; - private String localizedName; - - private MaterialState materialState; - private TextureSet textureSet; - - private Fluid mFluid; - private Fluid mPlasma; - - private boolean vGenerateCells; - - protected Object dataVar = MathUtils.generateSingularRandomHexValue(); - - private ArrayList vMaterialInput = new ArrayList<>(); - public long[] vSmallestRatio; - public short vComponentCount; - - private short[] RGBA; - - private boolean usesBlastFurnace; - public boolean isRadioactive; - public byte vRadiationLevel; - - private int meltingPointK; - private int boilingPointK; - private int meltingPointC; - private int boilingPointC; - private long vProtons; - private long vNeutrons; - private long vMass; - public int smallestStackSizeWhenProcessing; //Add a check for <=0 || > 64 - public int vTier; - public int vVoltageMultiplier; - public String vChemicalFormula; - public String vChemicalSymbol; - - public long vDurability; - public int vToolQuality; - public int vHarvestLevel; - - private TC_Aspect_Wrapper[] vAspects; - - public BaseTinkersMaterial vTiConHandler; - - public short werkstoffID; - - - public static AutoMap invalidMaterials = new AutoMap(); - - - public Material(final String materialName, final MaterialState defaultState, final MaterialStack... inputs){ - this(materialName, defaultState, null, inputs); - } - - public Material(final String materialName, final MaterialState defaultState, final short[] rgba, final MaterialStack... inputs){ - this(materialName, defaultState, null, 0, rgba, -1, -1, -1, -1, false, "", 0, false, false, inputs); - } - - public Material(final String materialName, final MaterialState defaultState, final short[] rgba, int radiationLevel, MaterialStack... materialStacks) { - this(materialName, defaultState, null, 0, rgba, -1, -1, -1, -1, false, "", radiationLevel, false, materialStacks); - } - - public Material(String materialName, MaterialState defaultState, short[] rgba, int j, int k, int l, int m, int radiationLevel, MaterialStack[] materialStacks){ - this(materialName, defaultState, null, 0, rgba, j, k, l, m, false, "", radiationLevel, false, materialStacks); - } - - public Material(String materialName, MaterialState defaultState, final TextureSet set, short[] rgba, int meltingPoint, int boilingPoint, int protons, int neutrons, int radiationLevel, MaterialStack[] materialStacks){ - this(materialName, defaultState, set, 0, rgba, meltingPoint, boilingPoint, protons, neutrons, false, "", radiationLevel, false, materialStacks); - } - - public Material(final String materialName, final MaterialState defaultState,final short[] rgba, final int meltingPoint, final int boilingPoint, final long protons, final long neutrons, final boolean blastFurnace, final MaterialStack... inputs){ - this(materialName, defaultState, 0, rgba, meltingPoint, boilingPoint, protons, neutrons, blastFurnace, "", 0, inputs); - } - - public Material(final String materialName, final MaterialState defaultState,final short[] rgba, final int meltingPoint, final int boilingPoint, final long protons, final long neutrons, final boolean blastFurnace, final String chemSymbol, final MaterialStack... inputs){ - this(materialName, defaultState, 0, rgba, meltingPoint, boilingPoint, protons, neutrons, blastFurnace, chemSymbol, 0, inputs); - } - - public Material(final String materialName, final MaterialState defaultState, final short[] rgba, final int meltingPoint, final int boilingPoint, final long protons, final long neutrons, final boolean blastFurnace, boolean generateCells, final MaterialStack... inputs){ - this(materialName, defaultState, null, 0, rgba, meltingPoint, boilingPoint, protons, neutrons, blastFurnace, "", 0, generateCells, true, inputs); - } - - public Material(final String materialName, final MaterialState defaultState,final short[] rgba, final int meltingPoint, final int boilingPoint, final long protons, final long neutrons, final boolean blastFurnace, final int radiationLevel, final MaterialStack... inputs){ - this(materialName, defaultState, 0, rgba, meltingPoint, boilingPoint, protons, neutrons, blastFurnace, "", radiationLevel, inputs); - } - - public Material(final String materialName, final MaterialState defaultState,final long durability, final short[] rgba, final int meltingPoint, final int boilingPoint, final long protons, final long neutrons, final boolean blastFurnace, final int radiationLevel, final MaterialStack... inputs){ - this(materialName, defaultState, durability, rgba, meltingPoint, boilingPoint, protons, neutrons, blastFurnace, "", radiationLevel, inputs); - } - - public Material(final String materialName, final MaterialState defaultState,final short[] rgba, final int meltingPoint, final int boilingPoint, final long protons, final long neutrons, final boolean blastFurnace, final String chemicalSymbol, final int radiationLevel, final MaterialStack... inputs){ - this(materialName, defaultState, 0, rgba, meltingPoint, boilingPoint, protons, neutrons, blastFurnace, chemicalSymbol, radiationLevel, inputs); - } - - public Material(final String materialName, final MaterialState defaultState,final short[] rgba, final int meltingPoint, final int boilingPoint, final long protons, final long neutrons, final boolean blastFurnace, final String chemicalSymbol, final int radiationLevel, boolean addCells,final MaterialStack... inputs) { - this (materialName, defaultState, null, 0, rgba, meltingPoint, boilingPoint, protons, neutrons, blastFurnace, chemicalSymbol, radiationLevel, addCells, true, inputs); - } - - public Material(final String materialName, final MaterialState defaultState, TextureSet textureSet,final short[] rgba, final int meltingPoint, final int boilingPoint, final long protons, final long neutrons, final boolean blastFurnace, final String chemicalSymbol, final int radiationLevel, final MaterialStack... inputs){ - this (materialName, defaultState, textureSet, 0, rgba, meltingPoint, boilingPoint, protons, neutrons, blastFurnace, chemicalSymbol, radiationLevel, true, true, inputs); - } - - public Material(final String materialName, final MaterialState defaultState, TextureSet textureSet,final short[] rgba, final int meltingPoint, final int boilingPoint, final long protons, final long neutrons, final boolean blastFurnace, final String chemicalSymbol, final int radiationLevel, boolean addCells,final MaterialStack... inputs) { - this (materialName, defaultState, textureSet, 0, rgba, meltingPoint, boilingPoint, protons, neutrons, blastFurnace, chemicalSymbol, radiationLevel, addCells, true, inputs); - } - - private Material(final String materialName, final MaterialState defaultState, final long durability, final short[] rgba, final int meltingPoint, final int boilingPoint, final long protons, final long neutrons, final boolean blastFurnace, final String chemicalSymbol, final int radiationLevel, final MaterialStack... inputs){ - this (materialName, defaultState, null, durability, rgba, meltingPoint, boilingPoint, protons, neutrons, blastFurnace, chemicalSymbol, radiationLevel, true, true, inputs); - } - - public Material(final String materialName, final MaterialState defaultState, final TextureSet set, final long durability, final short[] rgba, final int meltingPoint, final int boilingPoint, final long protons, final long neutrons, final boolean blastFurnace, final String chemicalSymbol, final int radiationLevel, boolean generateCells, final MaterialStack... inputs){ - this (materialName, defaultState, set, durability, rgba, meltingPoint, boilingPoint, protons, neutrons, blastFurnace, chemicalSymbol, radiationLevel, true, true, inputs); - } - - public Material(final String materialName, final MaterialState defaultState, final TextureSet set, final long durability, short[] rgba, final int meltingPoint, final int boilingPoint, final long protons, final long neutrons, final boolean blastFurnace, String chemicalSymbol, final int radiationLevel, boolean generateCells, boolean generateFluid, final MaterialStack... inputs){ - - if (mMaterialMap.add(this)) { - - } - - if (defaultState == MaterialState.ORE) { - rgba = null; - } - - mComponentMap.put(unlocalizedName, new HashMap()); - - try { - this.unlocalizedName = Utils.sanitizeString(materialName); - this.localizedName = materialName; - mMaterialCache.put(getLocalizedName().toLowerCase(), this); - Logger.INFO("Stored "+getLocalizedName()+" to cache with key: "+getLocalizedName().toLowerCase()); - - this.materialState = defaultState; - - Logger.MATERIALS(this.getLocalizedName()+" is "+defaultState.name()+"."); - - this.vGenerateCells = generateCells; - - //Add Components to an array. - if (inputs == null){ - this.vMaterialInput = null; - } - else { - if (inputs.length != 0){ - for (int i=0; i < inputs.length; i++){ - if (inputs[i] != null){ - this.vMaterialInput.add(i, inputs[i]); - } - } - } - } - - //set RGB - - if (rgba == null) { - if (vMaterialInput.size() > 0) { - - try { - Short[] mMixedRGB = new Short[3]; - AutoMap mMaterialSet = MaterialUtils.getCompoundMaterialsRecursively(this); - for (int mnh = 0; mnh < 3; mnh++) { - AutoMap aDataSet = new AutoMap(); - Set set4 = new HashSet(); - for (Material u : mMaterialSet) { - //if (u.getState() == MaterialState.ORE || u.getState() == MaterialState.SOLID) - set4.add(u); - } - for(Material e : set4){ - aDataSet.put(e.getRGB()[mnh]); - } - - Short aAverage = MathUtils.getShortAverage(aDataSet); - if (aAverage > Short.MAX_VALUE || aAverage < Short.MIN_VALUE || aAverage < 0 || aAverage > 255) { - if (aAverage > 255) { - while (aAverage > 255) { - aAverage = (short) (aAverage/2); - } - } - aAverage = (short) Math.max(Math.min(aAverage, 255), 0); - } - mMixedRGB[mnh] = aAverage; - } - - if (mMixedRGB != null && mMixedRGB[0] != null && mMixedRGB[1] != null && mMixedRGB[2] != null) { - this.RGBA = new short[] {mMixedRGB[0], mMixedRGB[1], mMixedRGB[2], 0}; - } - else { - this.RGBA = Materials.Steel.mRGBa; - } - } - catch (Throwable t) { - t.printStackTrace(); - this.RGBA = Materials.Steel.mRGBa; - } - } - else { - //Boring Grey Material - - int aValueForGen = this.getUnlocalizedName().hashCode(); - int hashSize = MathUtils.howManyPlaces(aValueForGen); - - String a = String.valueOf(aValueForGen); - String b = ""; - - if (hashSize < 9) { - int aSecondHash = this.materialState.hashCode(); - int hashSize2 = MathUtils.howManyPlaces(aSecondHash); - if (hashSize2 + hashSize >= 9) { - b = String.valueOf(aValueForGen); - } - else { - String c = b; - while (MathUtils.howManyPlaces(hashSize + c.length()) < 9) { - c = c + c.hashCode(); - } - b = c; - } - } - - String valueR; - if (b != null) { - valueR = a+b; - } - else { - valueR = a; - } - short fc[] = new short[3]; - int aIndex = 0; - for (char gg : valueR.toCharArray()) { - short ui = Short.parseShort(""+gg); - if (ui > 255 || ui < 0) { - if (ui > 255) { - while (ui > 255) { - ui = (short) (ui / 2); - } - } - else { - ui = 0; - } - } - fc[aIndex++] = ui; - - } - this.RGBA = fc; - } - } - else { - this.RGBA = rgba; - } - - //Set Melting/Boiling point, if value is -1 calculate it from compound inputs. - if (meltingPoint != -1){ - this.meltingPointC = meltingPoint; - } - else { - this.meltingPointC = this.calculateMeltingPoint(); - } - if (boilingPoint != -1){ - if (boilingPoint != 0){ - this.boilingPointC = boilingPoint; - } - else { - this.boilingPointC = meltingPoint*4; - } - } - else { - this.boilingPointC = this.calculateBoilingPoint(); - } - - this.meltingPointK = (int) MathUtils.celsiusToKelvin(this.meltingPointC); - this.boilingPointK = (int) MathUtils.celsiusToKelvin(this.boilingPointC); - - //Set Proton/Neutron count, if value is -1 calculate it from compound inputs. - if (protons != -1){ - this.vProtons = protons; - } - else { - this.vProtons = this.calculateProtons(); - } - if (boilingPoint != -1){ - this.vNeutrons = neutrons; - } - else { - this.vNeutrons = this.calculateNeutrons(); - } - - - this.vAspects = null; - - - this.vMass = this.getMass(); - - //Sets tool Durability - if (durability != 0){ - this.vDurability = durability; - } - else { - long aTempDura = 0; - for (MaterialStack g : this.getComposites()) { - if (g != null) { - aTempDura += safeCast_LongToInt(g.getStackMaterial().getMass() * 2000); - } - } - this.vDurability = aTempDura > 0 ? aTempDura : (this.getComposites().isEmpty() ? 51200 : 32000 * this.getComposites().size()); - } - - if ((this.vDurability >= 0) && (this.vDurability < 64000)){ - this.vToolQuality = 1; - this.vHarvestLevel = 2; - } - else if ((this.vDurability >= 64000) && (this.vDurability < 128000)){ - this.vToolQuality = 2; - this.vHarvestLevel = 2; - } - else if ((this.vDurability >= 128000) && (this.vDurability < 256000)){ - this.vToolQuality = 3; - this.vHarvestLevel = 2; - } - else if ((this.vDurability >= 256000) && (this.vDurability < 512000)){ - this.vToolQuality = 3; - this.vHarvestLevel = 3; - } - else if ((this.vDurability >= 512000) && (this.vDurability <= Integer.MAX_VALUE)){ - this.vToolQuality = 4; - this.vHarvestLevel = 4; - } - else { - this.vToolQuality = 1; - this.vHarvestLevel = 1; - } - - //Sets the Rad level - if (radiationLevel > 0){ - Logger.MATERIALS(this.getLocalizedName()+" is radioactive. Level: "+radiationLevel+"."); - this.isRadioactive = true; - this.vRadiationLevel = (byte) radiationLevel; - } - else { - if (vMaterialInput.size() > 0) { - AutoMap aDataSet = new AutoMap(); - for (MaterialStack m : this.vMaterialInput) { - aDataSet.put(m.getStackMaterial().vRadiationLevel); - } - byte aAverage = MathUtils.getByteAverage(aDataSet); - if (aAverage > 0) { - Logger.MATERIALS(this.getLocalizedName()+" is radioactive due to trace elements. Level: "+aAverage+"."); - this.isRadioactive = true; - this.vRadiationLevel = (byte) aAverage; - } - else { - Logger.MATERIALS(this.getLocalizedName()+" is not radioactive."); - this.isRadioactive = false; - this.vRadiationLevel = 0; - } - } - else { - Logger.MATERIALS(this.getLocalizedName()+" is not radioactive."); - this.isRadioactive = false; - this.vRadiationLevel = 0; - } - } - - /*if (vMaterialInput.size() > 0) { - AutoMap aDataSet = new AutoMap(); - - int bonus = 0; - bonus += this.vMaterialInput.size(); - bonus += MathUtils.roundToClosestInt(meltingPointC/1000); - - - - aDataSet.put(bonus); - - for (MaterialStack m : this.vMaterialInput) { - aDataSet.put(m.getStackMaterial().vTier); - } - int aAverage = MathUtils.getIntAverage(aDataSet); - if (aAverage > Integer.MAX_VALUE || aAverage < Integer.MIN_VALUE) { - aAverage = 0; - } - if (aAverage > 0) { - this.vTier = Math.min(aAverage, 10); - } - else { - this.vTier = MaterialUtils.getTierOfMaterial((int) MathUtils.celsiusToKelvin(meltingPoint)); - } - } - else { - this.vTier = MaterialUtils.getTierOfMaterial((int) MathUtils.celsiusToKelvin(meltingPoint)); - }*/ - this.vTier = MaterialUtils.getTierOfMaterial(meltingPoint); - - - //Sets the materials 'tier'. Will probably replace this logic. - - this.usesBlastFurnace = blastFurnace; - this.vVoltageMultiplier = MaterialUtils.getVoltageForTier(vTier); - - this.vComponentCount = this.getComponentCount(inputs); - this.vSmallestRatio = this.getSmallestRatio(this.vMaterialInput); - int tempSmallestSize = 0; - - if (this.vSmallestRatio != null){ - for (int v=0;v= 98 || this.getComposites().size() > 1 || this.getMeltingPointC() >= 3600) { - this.vTiConHandler = new BaseTinkersMaterial(this); - } - } - - sChemicalFormula.put(materialName.toLowerCase(), this.vChemicalFormula); - Logger.MATERIALS("Creating a Material instance for "+materialName); - Logger.MATERIALS("Formula: "+this.vChemicalFormula + " Smallest Stack: "+this.smallestStackSizeWhenProcessing+" Smallest Ratio:"+ratio); - Logger.MATERIALS("Protons: "+this.vProtons); - Logger.MATERIALS("Neutrons: "+this.vNeutrons); - Logger.MATERIALS("Mass: "+this.vMass+"/units"); - Logger.MATERIALS("Melting Point: "+this.meltingPointC+"C."); - Logger.MATERIALS("Boiling Point: "+this.boilingPointC+"C."); - } - catch (Throwable t){ - Logger.MATERIALS("Stack Trace for "+materialName); - t.printStackTrace(); - } - } - - private static void checkForCellAndGenerate(Material material) { - if (!material.vGenerateCells) { - return; - } - String aName = Utils.sanitizeString(material.unlocalizedName); - String aName2 = Utils.sanitizeString(material.unlocalizedName.toLowerCase()); - String aName3 = (material.localizedName == null) ? aName : material.localizedName; - ItemStack aTestCell1 = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+aName, 1); - ItemStack aTestCell2 = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+aName2, 1); - ItemStack aTestCell3 = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+aName3, 1); - if (aTestCell1 == null && aTestCell2 == null && aTestCell3 == null) { - Logger.INFO("Generating cell for "+ material.localizedName); - new BaseItemCell(material); - } - else { - if (aTestCell1 != null) { - Logger.INFO("Registering existing cell for "+ material.localizedName+", "+aName); - material.registerComponentForMaterial(OrePrefixes.cell, aTestCell1); - } - else if (aTestCell2 != null) { - Logger.INFO("Registering existing cell for "+ material.localizedName+", "+aName2); - material.registerComponentForMaterial(OrePrefixes.cell, aTestCell2); - } - else if (aTestCell3 != null) { - Logger.INFO("Registering existing cell for "+ material.localizedName+", "+aName3); - material.registerComponentForMaterial(OrePrefixes.cell, aTestCell3); - } - } - } - - public final TextureSet getTextureSet() { - synchronized(this) { - return textureSet; - } - } - - - public TextureSet setTextureSet(TextureSet set) { - return setTextureSet(set, vTier); - } - - public TextureSet setTextureSet(TextureSet set, int aTier) { - if (set != null) { - Logger.MATERIALS("Set textureset for "+this.localizedName+" to be "+set.mSetName+". This textureSet was supplied."); - return set; - } - - int aGem = 0; - int aShiny = 0; - TextureSet aSet = null; - - //Check Mixture Contents - for (MaterialStack m : this.getComposites()) { - - //Gems - if (m.getStackMaterial() == ELEMENT.getInstance().AER) { - aGem++; - } - else if (m.getStackMaterial() == ELEMENT.getInstance().AQUA) { - aGem++; - } - else if (m.getStackMaterial() == ELEMENT.getInstance().IGNIS) { - aGem++; - } - else if (m.getStackMaterial() == ELEMENT.getInstance().TERRA) { - aGem++; - } - else if (m.getStackMaterial() == ELEMENT.getInstance().MAGIC) { - aGem++; - } - //Shiny Materials - if (m.getStackMaterial() == ELEMENT.getInstance().GOLD) { - aShiny++; - } - else if (m.getStackMaterial() == ELEMENT.getInstance().SILVER) { - aShiny++; - } - else if (m.getStackMaterial() == ELEMENT.getInstance().PLATINUM) { - aShiny++; - } - else if (m.getStackMaterial() == ELEMENT.getInstance().AMERICIUM) { - aShiny++; - } - else if (m.getStackMaterial() == ELEMENT.getInstance().TITANIUM) { - aShiny++; - } - else if (m.getStackMaterial() == ELEMENT.getInstance().GERMANIUM) { - aShiny++; - } - else if (m.getStackMaterial() == ELEMENT.getInstance().GALLIUM) { - aShiny++; - } - else if (m.getStackMaterial() == ELEMENT.getInstance().MERCURY) { - aShiny++; - } - else if (m.getStackMaterial() == ELEMENT.getInstance().MAGIC) { - aShiny++; - } - else if (m.getStackMaterial() == ELEMENT.getInstance().SAMARIUM) { - aShiny++; - } - else if (m.getStackMaterial() == ELEMENT.getInstance().TANTALUM) { - aShiny++; - } - } - - if (aSet == null) { - if (aGem >= this.getComposites().size()/2) { - if (MathUtils.isNumberEven(aGem)) { - Logger.MATERIALS("Set textureset for "+this.localizedName+" to be "+TextureSet.SET_GEM_HORIZONTAL.mSetName+"."); - return TextureSet.SET_GEM_HORIZONTAL; - } - else { - Logger.MATERIALS("Set textureset for "+this.localizedName+" to be "+TextureSet.SET_GEM_VERTICAL.mSetName+"."); - return TextureSet.SET_GEM_VERTICAL; - } - } - } - - if (aSet == null) { - if (aShiny >= this.getComposites().size()/3) { - Logger.MATERIALS("Set textureset for "+this.localizedName+" to be "+TextureSet.SET_SHINY.mSetName+"."); - return TextureSet.SET_SHINY; - } - } - - // build hash table with count - AutoMap sets = new AutoMap(); - if (this.vMaterialInput != null) { - for (MaterialStack r : this.vMaterialInput) { - if (r.getStackMaterial().getTextureSet().mSetName.toLowerCase().contains("fluid")) { - sets.put(ELEMENT.getInstance().GOLD); - } - else { - sets.put(r.getStackMaterial()); - } - } - TextureSet mostUsedTypeTextureSet = MaterialUtils.getMostCommonTextureSet(new ArrayList(sets.values())); - if (mostUsedTypeTextureSet != null && mostUsedTypeTextureSet instanceof TextureSet) { - Logger.MATERIALS("Set textureset for "+this.localizedName+" to be "+mostUsedTypeTextureSet.mSetName+"."); - return mostUsedTypeTextureSet; - } - } - Logger.MATERIALS("Set textureset for "+this.localizedName+" to be "+Materials.Iron.mIconSet.mSetName+". [Fallback]"); - return Materials.Gold.mIconSet; - } - - public final String getLocalizedName(){ - if (this.localizedName != null) { - return this.localizedName; - } - return "ERROR BAD LOCALIZED NAME"; - } - - public final String getUnlocalizedName(){ - if (this.unlocalizedName != null) { - return this.unlocalizedName; - } - return "ERROR.BAD.UNLOCALIZED.NAME"; - } - - final public MaterialState getState(){ - return this.materialState; - } - - final public short[] getRGB(){ - if (this.RGBA != null) { - return this.RGBA; - } - return new short[] {255,0,0}; - } - - final public short[] getRGBA(){ - if (this.RGBA != null) { - if (this.RGBA.length == 4){ - return this.RGBA; - } - else { - return new short[]{this.RGBA[0], this.RGBA[1], this.RGBA[2], 0}; - } - } - return new short[] {255,0,0, 0}; - } - - final public int getRgbAsHex(){ - - final int returnValue = Utils.rgbtoHexValue(this.RGBA[0], this.RGBA[1], this.RGBA[2]); - if (returnValue == 0){ - return (int) this.dataVar; - } - return Utils.rgbtoHexValue(this.RGBA[0], this.RGBA[1], this.RGBA[2]); - } - - final public long getProtons() { - return this.vProtons; - } - - public final long getNeutrons() { - return this.vNeutrons; - } - - final public long getMass() { - return this.vProtons + this.vNeutrons; - } - - public final int getMeltingPointC() { - return this.meltingPointC; - } - - public final int getBoilingPointC() { - return this.boilingPointC; - } - - public final int getMeltingPointK() { - return this.meltingPointK; - } - - public final int getBoilingPointK() { - return this.boilingPointK; - } - - public final boolean requiresBlastFurnace(){ - return this.usesBlastFurnace; - } - - public final ItemStack getComponentByPrefix(OrePrefixes aPrefix, int stacksize) { - String aKey = aPrefix.name(); - Map g = mComponentMap.get(this.unlocalizedName); - if (g == null) { - Map aMap = new HashMap(); - mComponentMap.put(unlocalizedName, aMap); - g = aMap; - } - ItemStack i = g.get(aKey); - if (i != null) { - return ItemUtils.getSimpleStack(i, stacksize); - } - else { - // Try get a GT Material - Materials Erf = MaterialUtils.getMaterial(this.unlocalizedName); - if (Erf != null && !MaterialUtils.isNullGregtechMaterial(Erf)) { - ItemStack Erg = ItemUtils.getOrePrefixStack(aPrefix, Erf, stacksize); - if (Erg != null && ItemUtils.checkForInvalidItems(Erg)) { - Logger.MATERIALS("Found \"" + aKey + this.unlocalizedName + "\" using backup GT Materials option."); - g.put(aKey, Erg); - mComponentMap.put(unlocalizedName, g); - return Erg; - } - else { - // Try get a molten cell - if (aPrefix == OrePrefixes.cell) { - Erg = ItemUtils.getOrePrefixStack(OrePrefixes.cellMolten, Erf, stacksize); - if (Erg != null && ItemUtils.checkForInvalidItems(Erg)) { - Logger.MATERIALS("Found \"" + OrePrefixes.cellMolten.name() + this.unlocalizedName + "\" using backup GT Materials option."); - g.put(aKey, Erg); - mComponentMap.put(unlocalizedName, g); - return Erg; - } - } - } - } else { - ItemStack u = ItemUtils.getItemStackOfAmountFromOreDictNoBroken(aKey + this.unlocalizedName, stacksize); - if (u != null) { - g.put(aKey, u); - mComponentMap.put(unlocalizedName, g); - return u; - } - } - //Logger.MATERIALS("Unabled to find \"" + aKey + this.unlocalizedName + "\""); - return ItemUtils.getErrorStack(stacksize, (aKey + this.unlocalizedName+" x"+stacksize)); - } - - } - - final public Block getBlock(){ - Block b = Block.getBlockFromItem(getBlock(1).getItem()); - if (b == null) { - Logger.INFO("[ERROR] Tried to get invalid block for "+this.getLocalizedName()+", returning debug block instead."); - } - return b != null ? b : Blocks.lit_furnace; - } - - public final ItemStack getBlock(final int stacksize){ - ItemStack i = getComponentByPrefix(OrePrefixes.block, stacksize); - return i != null ? i : ItemUtils.getItemStackOfAmountFromOreDictNoBroken("block"+this.unlocalizedName, stacksize); - } - - public final ItemStack getDust(final int stacksize){ - ItemStack i = getComponentByPrefix(OrePrefixes.dust, stacksize); - return i != null ? i : ItemUtils.getGregtechDust("dust"+this.unlocalizedName, stacksize); - } - - public final ItemStack getSmallDust(final int stacksize){ - return getComponentByPrefix(OrePrefixes.dustSmall, stacksize); - } - - public final ItemStack getTinyDust(final int stacksize){ - return getComponentByPrefix(OrePrefixes.dustTiny, stacksize); - } - - public final ItemStack getIngot(final int stacksize){ - return getComponentByPrefix(OrePrefixes.ingot, stacksize); - } - - public final ItemStack getHotIngot(final int stacksize){ - return getComponentByPrefix(OrePrefixes.ingotHot, stacksize); - } - - public final ItemStack getPlate(final int stacksize){ - return getComponentByPrefix(OrePrefixes.plate, stacksize); - } - - public final ItemStack getPlateDouble(final int stacksize){ - return getComponentByPrefix(OrePrefixes.plateDouble, stacksize); - } - - public final ItemStack getGear(final int stacksize){ - return getComponentByPrefix(OrePrefixes.gearGt, stacksize); - } - - public final ItemStack getRod(final int stacksize){ - return getComponentByPrefix(OrePrefixes.stick, stacksize); - } - - public final ItemStack getLongRod(final int stacksize){ - return getComponentByPrefix(OrePrefixes.stickLong, stacksize); - } - - public final ItemStack getBolt(final int stacksize){ - return getComponentByPrefix(OrePrefixes.bolt, stacksize); - } - - public final ItemStack getScrew(final int stacksize){ - return getComponentByPrefix(OrePrefixes.screw, stacksize); - } - - public final ItemStack getFineWire(final int stacksize){ - return getComponentByPrefix(OrePrefixes.wireFine, stacksize); - } - - public final ItemStack getFoil(final int stacksize){ - return getComponentByPrefix(OrePrefixes.foil, stacksize); - } - - public final ItemStack getRing(final int stacksize){ - return getComponentByPrefix(OrePrefixes.ring, stacksize); - } - - public final ItemStack getRotor(final int stacksize){ - return getComponentByPrefix(OrePrefixes.rotor, stacksize); - } - - public final ItemStack getFrameBox(final int stacksize){ - return getComponentByPrefix(OrePrefixes.frameGt, stacksize); - } - - public final ItemStack getCell(final int stacksize){ - return getComponentByPrefix(OrePrefixes.cell, stacksize); - } - - public final ItemStack getPlasmaCell(final int stacksize){ - return getComponentByPrefix(OrePrefixes.cellPlasma, stacksize); - } - - public final ItemStack getNugget(final int stacksize){ - return getComponentByPrefix(OrePrefixes.nugget, stacksize); - } - - public final ItemStack getWire01(final int stacksize) { - return getComponentByPrefix(OrePrefixes.wireGt01, stacksize); - } - - public final ItemStack getWire02(final int stacksize) { - return getComponentByPrefix(OrePrefixes.wireGt02, stacksize); - } - - public final ItemStack getWire04(final int stacksize) { - return getComponentByPrefix(OrePrefixes.wireGt04, stacksize); - } - - public final ItemStack getWire08(final int stacksize) { - return getComponentByPrefix(OrePrefixes.wireGt08, stacksize); - } - - public final ItemStack getWire12(final int stacksize) { - return getComponentByPrefix(OrePrefixes.wireGt12, stacksize); - } - - public final ItemStack getWire16(final int stacksize) { - return getComponentByPrefix(OrePrefixes.wireGt16, stacksize); - } - - public final ItemStack getCable01(final int stacksize) { - return getComponentByPrefix(OrePrefixes.cableGt01, stacksize); - } - - public final ItemStack getCable02(final int stacksize) { - return getComponentByPrefix(OrePrefixes.cableGt02, stacksize); - } - - public final ItemStack getCable04(final int stacksize) { - return getComponentByPrefix(OrePrefixes.cableGt04, stacksize); - } - - public final ItemStack getCable08(final int stacksize) { - return getComponentByPrefix(OrePrefixes.cableGt08, stacksize); - } - - public final ItemStack getCable12(final int stacksize) { - return getComponentByPrefix(OrePrefixes.cableGt12, stacksize); - } - - public final ItemStack getCable16(final int stacksize) { - if (GregtechConduits.cableGt16 != null) { - return getComponentByPrefix(GregtechConduits.cableGt16, stacksize); - } - else { - return ItemUtils.getErrorStack(stacksize); - } - } - - /** - * Ore Components - * @return - */ - - public final ItemStack getOre(final int stacksize){ - return ItemUtils.getItemStackOfAmountFromOreDictNoBroken("ore"+Utils.sanitizeString(this.getUnlocalizedName()), stacksize); - } - public final Block getOreBlock(final int stacksize){ - //Logger.DEBUG_MATERIALS("Trying to get ore block for "+this.getLocalizedName()+". Looking for '"+"ore"+Utils.sanitizeString(this.getUnlocalizedName())+"'."); - try{ - ItemStack a1 = getOre(1); - Item a2 = a1.getItem(); - Block a3 = Block.getBlockFromItem(a2); - if (a3 != null) { - return a3; - } - - Block x = Block.getBlockFromItem(ItemUtils.getItemStackOfAmountFromOreDictNoBroken("ore"+Utils.sanitizeString(this.unlocalizedName), stacksize).getItem()); - if (x != null){ - return x; - } - } - catch (Throwable t){ - //t.printStackTrace(); - } - //Logger.MATERIALS("Failed getting the Ore Block for "+this.getLocalizedName()+"."); - return Blocks.stone; - } - public final ItemStack getCrushed(final int stacksize){ - return getComponentByPrefix(OrePrefixes.crushed, stacksize); - } - public final ItemStack getCrushedPurified(final int stacksize){ - return getComponentByPrefix(OrePrefixes.crushedPurified, stacksize); - } - public final ItemStack getCrushedCentrifuged(final int stacksize){ - return getComponentByPrefix(OrePrefixes.crushedCentrifuged, stacksize); - } - public final ItemStack getDustPurified(final int stacksize){ - return getComponentByPrefix(OrePrefixes.dustPure, stacksize); - } - public final ItemStack getDustImpure(final int stacksize){ - return getComponentByPrefix(OrePrefixes.dustImpure, stacksize); - } - public final ItemStack getMilled(final int stacksize){ - return getComponentByPrefix(CustomOrePrefix.milled.get(), stacksize); - } - - public final boolean hasSolidForm() { - if (ItemUtils.checkForInvalidItems(new ItemStack[] {getDust(1), getBlock(1), getTinyDust(1), getSmallDust(1)})) { - return true; - } - return false; - } - - final public ItemStack[] getMaterialComposites(){ - if (this.vMaterialInput != null && !this.vMaterialInput.isEmpty()){ - final ItemStack[] temp = new ItemStack[this.vMaterialInput.size()]; - for (int i=0;i getComposites(){ - return this.vMaterialInput; - } - - final public int[] getMaterialCompositeStackSizes(){ - if (!this.vMaterialInput.isEmpty()){ - final int[] temp = new int[this.vMaterialInput.size()]; - for (int i=0;i tempInput){ - if (tempInput != null){ - if (!tempInput.isEmpty()){ - Logger.MATERIALS("length: "+tempInput.size()); - Logger.MATERIALS("(inputs != null): "+(tempInput != null)); - //Utils.LOG_MATERIALS("length: "+inputs.length); - final long[] tempRatio = new long[tempInput.size()]; - for (int x=0;x 0){ - String tempRatioStringThing1 = ""; - for (int r=0;r tempInput = this.vMaterialInput; - if (tempInput != null){ - if (!tempInput.isEmpty()){ - String dummyFormula = ""; - final long[] dummyFormulaArray = this.getSmallestRatio(tempInput); - if (dummyFormulaArray != null){ - if (dummyFormulaArray.length >= 1){ - for (int e=0;e 1){ - - if (aChemFormula.length() > 3){ - dummyFormula = dummyFormula + "(" + aChemFormula + ")" + dummyFormulaArray[e]; - } - else { - dummyFormula = dummyFormula + aChemFormula + dummyFormulaArray[e]; - } - } - else if (dummyFormulaArray[e] == 1){ - if (aChemFormula.length() > 3){ - dummyFormula = dummyFormula + "(" +aChemFormula + ")"; - } - else { - dummyFormula = dummyFormula +aChemFormula; - } - } - else { - dummyFormula = dummyFormula + "??"; - } - } else { - dummyFormula = dummyFormula + "??"; - } - } else { - dummyFormula = dummyFormula + "??"; - } - } - } - return StringUtils.subscript(dummyFormula); - //return dummyFormula; - } - Logger.MATERIALS("dummyFormulaArray <= 0"); - } - Logger.MATERIALS("dummyFormulaArray == null"); - } - Logger.MATERIALS("tempInput.length <= 0"); - } - Logger.MATERIALS("tempInput == null"); - return "??"; - - } - - public final boolean queueFluidGeneration() { - return isFluidQueued = true; - } - - public final static void generateQueuedFluids() { - for (Material m : mMaterialMap) { - if (m.isFluidQueued) { - } - } - } - - //If we need a fluid, let's just queue it for later. - public boolean isFluidQueued = false; - - public final Fluid generateFluid(){ - if (this.materialState == MaterialState.ORE){ - return null; - } - - Fluid aGTBaseFluid = null; - - // Clean up Internal Fluid Generation - final Materials n1 = MaterialUtils.getMaterial(this.getLocalizedName(), Utils.sanitizeString(this.getLocalizedName())); - final Materials n2 = MaterialUtils.getMaterial(this.getUnlocalizedName(), Utils.sanitizeString(this.getUnlocalizedName())); - - FluidStack f1 = FluidUtils.getWildcardFluidStack(n1, 1); - FluidStack f2 = FluidUtils.getWildcardFluidStack(n2, 1); - FluidStack f3 = FluidUtils.getWildcardFluidStack(Utils.sanitizeString(this.getUnlocalizedName(), new char[] {'-', '_'}), 1); - FluidStack f4 = FluidUtils.getWildcardFluidStack(Utils.sanitizeString(this.getLocalizedName(), new char[] {'-', '_'}), 1); - - if (f1 != null) { - aGTBaseFluid = f1.getFluid(); - } - else if (f2 != null) { - aGTBaseFluid = f2.getFluid(); - } - else if (f3 != null) { - aGTBaseFluid = f3.getFluid(); - } - else if (f4 != null) { - aGTBaseFluid = f4.getFluid(); - } - - - ItemStack aFullCell = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+this.getUnlocalizedName(), 1); - ItemStack aFullCell2 = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+this.getLocalizedName(), 1); - ItemStack aFullCell3 = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+Utils.sanitizeString(this.getUnlocalizedName(), new char[] {'-', '_'}), 1); - ItemStack aFullCell4 = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+Utils.sanitizeString(this.getLocalizedName(), new char[] {'-', '_'}), 1); - - Logger.MATERIALS("Generating our own fluid."); - //Generate a Cell if we need to, but first validate all four searches are invalid - - if (!ItemUtils.checkForInvalidItems(new ItemStack[] {aFullCell, aFullCell2, aFullCell3, aFullCell4})){ - if (this.vGenerateCells){ - Item g = new BaseItemCell(this); - aFullCell = ItemUtils.getSimpleStack(g); - Logger.MATERIALS("Generated a cell for "+this.getUnlocalizedName()); - } - else { - Logger.MATERIALS("Did not generate a cell for "+this.getUnlocalizedName()); - } - } - else { - // One cell we searched for was valid, let's register it. - if (aFullCell != null) { - this.registerComponentForMaterial(ComponentTypes.CELL, aFullCell); - } - else if (aFullCell2 != null) { - this.registerComponentForMaterial(ComponentTypes.CELL, aFullCell2); - } - else if (aFullCell3 != null) { - this.registerComponentForMaterial(ComponentTypes.CELL, aFullCell3); - } - else if (aFullCell4 != null) { - this.registerComponentForMaterial(ComponentTypes.CELL, aFullCell4); - } - } - - // We found a GT fluid, let's use it. - // Good chance we registered the cell from this material too. - if (aGTBaseFluid != null) { - return aGTBaseFluid; - } - - // This fluid does not exist at all, time to generate it. - if (this.materialState == MaterialState.SOLID){ - return FluidUtils.addGTFluid( - this.getUnlocalizedName(), - "Molten "+this.getLocalizedName(), - this.RGBA, - 4, - this.getMeltingPointK(), - aFullCell, - ItemUtils.getEmptyCell(), - 1000, - this.vGenerateCells); - } - else if (this.materialState == MaterialState.LIQUID || this.materialState == MaterialState.PURE_LIQUID){ - return FluidUtils.addGTFluid( - this.getUnlocalizedName(), - this.getLocalizedName(), - this.RGBA, - 0, - this.getMeltingPointK(), - aFullCell, - ItemUtils.getEmptyCell(), - 1000, - this.vGenerateCells); - } - else if (this.materialState == MaterialState.GAS || this.materialState == MaterialState.PURE_GAS){ - return FluidUtils.generateGas(unlocalizedName, this.getLocalizedName(), getMeltingPointK(), getRGBA(), vGenerateCells); - /*return FluidUtils.addGTFluid( - this.getUnlocalizedName(), - this.getLocalizedName()+" Gas", - this.RGBA, - 2, - this.getMeltingPointK(), - aFullCell, - ItemUtils.getEmptyCell(), - 1000, - this.vGenerateCells);*/ - } - else { //Plasma - return this.generatePlasma(); - } - } - - public final Fluid generatePlasma(){ - if (this.materialState == MaterialState.ORE){ - return null; - } - final Materials isValid = tryFindGregtechMaterialEquivalent(); - - if (!this.vGenerateCells){ - return null; - } - if (isValid != null) { - for (Materials m : invalidMaterials.values()){ - if (isValid == m){ - return null; - } - } - if (isValid.mPlasma != null){ - Logger.MATERIALS("Using a pre-defined Plasma from GT."); - return isValid.mPlasma; - } - } - Logger.MATERIALS("Generating our own Plasma."); - return FluidUtils.addGTPlasma(this); - } - - - public Fluid getFluid() { - return mFluid; - } - - public Fluid getPlasma() { - return mPlasma; - } - - final public FluidStack getFluidStack(final int fluidAmount) { - if (this.mFluid == null){ - return null; - } - final FluidStack moltenFluid = new FluidStack(this.mFluid, fluidAmount); - return moltenFluid; - } - - final public boolean setFluid(Fluid aFluid) { - if (this.mFluid == null){ - this.mFluid = aFluid; - return true; - } - return false; - } - - - final public int calculateMeltingPoint(){ - try { - AutoMap aDataSet = new AutoMap(); - for (MaterialStack m : this.vMaterialInput) { - aDataSet.put(m.getStackMaterial().getMeltingPointC()); - } - long aAverage = MathUtils.getIntAverage(aDataSet); - return MathUtils.safeInt(aAverage); - } - catch (Throwable r){ - r.printStackTrace(); - return 500; - } - } - - final public int calculateBoilingPoint(){ - try { - - AutoMap aDataSet = new AutoMap(); - for (MaterialStack m : this.vMaterialInput) { - aDataSet.put(m.getStackMaterial().getBoilingPointC()); - } - long aAverage = MathUtils.getIntAverage(aDataSet); - return MathUtils.safeInt(aAverage); - } - catch (Throwable r){ - r.printStackTrace(); - return 2500; - } - } - - final public long calculateProtons(){ - try { - - AutoMap aDataSet = new AutoMap(); - for (MaterialStack m : this.vMaterialInput) { - aDataSet.put(m.getStackMaterial().getProtons()); - } - long aAverage = MathUtils.getLongAverage(aDataSet); - return MathUtils.safeInt(aAverage); - } - catch (Throwable r){ - r.printStackTrace(); - return 50; - } - } - - final public long calculateNeutrons(){ - try { - - AutoMap aDataSet = new AutoMap(); - for (MaterialStack m : this.vMaterialInput) { - aDataSet.put(m.getStackMaterial().getNeutrons()); - } - long aAverage = MathUtils.getLongAverage(aDataSet); - return MathUtils.safeInt(aAverage); - } - catch (Throwable r){ - r.printStackTrace(); - return 75; - } - } - - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (!Material.class.isInstance(obj)) { - return false; - } - Material aObj = (Material) obj; - if (aObj.unlocalizedName.equals(this.unlocalizedName)) { - if (aObj.localizedName.equals(this.localizedName)) { - return true; - } - } - return false; - } - - public boolean registerComponentForMaterial(FluidStack aStack) { - return registerComponentForMaterial(this, aStack); - } - - private static boolean registerComponentForMaterial(Material componentMaterial, FluidStack aStack) { - if (componentMaterial != null && aStack != null && componentMaterial.mFluid == null) { - componentMaterial.mFluid = aStack.getFluid(); - return true; - } - return false; - } - - public boolean registerComponentForMaterial(ComponentTypes aPrefix, ItemStack aStack) { - return registerComponentForMaterial(this, aPrefix.getGtOrePrefix(), aStack); - } - - public boolean registerComponentForMaterial(OrePrefixes aPrefix, ItemStack aStack) { - return registerComponentForMaterial(this, aPrefix, aStack); - } - - public static boolean registerComponentForMaterial(Material componentMaterial, ComponentTypes aPrefix, ItemStack aStack) { - return registerComponentForMaterial(componentMaterial, aPrefix.getGtOrePrefix(), aStack); - } - - public static boolean registerComponentForMaterial(Material componentMaterial, OrePrefixes aPrefix, ItemStack aStack) { - if (componentMaterial == null) { - return false; - } - //Register Component - Map aMap = Material.mComponentMap.get(componentMaterial.getUnlocalizedName()); - if (aMap == null) { - aMap = new HashMap(); - } - String aKey = aPrefix.name(); - ItemStack x = aMap.get(aKey); - if (x == null) { - aMap.put(aKey, aStack); - Logger.MATERIALS("Registering a material component. Item: ["+componentMaterial.getUnlocalizedName()+"] Map: ["+aKey+"]"); - Material.mComponentMap.put(componentMaterial.getUnlocalizedName(), aMap); - return true; - } - else { - //Bad - Logger.MATERIALS("Tried to double register a material component. "); - return false; - } - } - - public Materials tryFindGregtechMaterialEquivalent() { - return tryFindGregtechMaterialEquivalent(this); - } - - - public static Materials tryFindGregtechMaterialEquivalent(Material aMaterial) { - String aMaterialName = aMaterial.getLocalizedName(); - Materials aGregtechMaterial = Materials.get(aMaterialName); - if (aGregtechMaterial == null || MaterialUtils.isNullGregtechMaterial(aGregtechMaterial)) { - aMaterialName = aMaterialName.replace(" ", "_"); - aGregtechMaterial = Materials.get(aMaterialName); - if (aGregtechMaterial == null || MaterialUtils.isNullGregtechMaterial(aGregtechMaterial)) { - aMaterialName = aMaterialName.replace(" ", ""); - aGregtechMaterial = Materials.get(aMaterialName); - if (aGregtechMaterial == null || MaterialUtils.isNullGregtechMaterial(aGregtechMaterial)) { - return null; - } - else { - return aGregtechMaterial; - } - } - else { - return aGregtechMaterial; - } - } - else { - return aGregtechMaterial; - } - } - - public void setWerkstoffID(short werkstoffID) { - this.werkstoffID = werkstoffID; - } - -} \ No newline at end of file + public static final Set mMaterialMap = new HashSet(); + public static HashMap mMaterialCache = new HashMap(); + + public static final Map> mComponentMap = + new HashMap>(); + + public static HashMap sChemicalFormula = new HashMap(); + + private String unlocalizedName; + private String localizedName; + + private MaterialState materialState; + private TextureSet textureSet; + + private Fluid mFluid; + private Fluid mPlasma; + + private boolean vGenerateCells; + + protected Object dataVar = MathUtils.generateSingularRandomHexValue(); + + private ArrayList vMaterialInput = new ArrayList<>(); + public long[] vSmallestRatio; + public short vComponentCount; + + private short[] RGBA; + + private boolean usesBlastFurnace; + public boolean isRadioactive; + public byte vRadiationLevel; + + private int meltingPointK; + private int boilingPointK; + private int meltingPointC; + private int boilingPointC; + private long vProtons; + private long vNeutrons; + private long vMass; + public int smallestStackSizeWhenProcessing; // Add a check for <=0 || > 64 + public int vTier; + public int vVoltageMultiplier; + public String vChemicalFormula; + public String vChemicalSymbol; + + public long vDurability; + public int vToolQuality; + public int vHarvestLevel; + + private TC_Aspect_Wrapper[] vAspects; + + public BaseTinkersMaterial vTiConHandler; + + public short werkstoffID; + + public static AutoMap invalidMaterials = new AutoMap(); + + public Material(final String materialName, final MaterialState defaultState, final MaterialStack... inputs) { + this(materialName, defaultState, null, inputs); + } + + public Material( + final String materialName, + final MaterialState defaultState, + final short[] rgba, + final MaterialStack... inputs) { + this(materialName, defaultState, null, 0, rgba, -1, -1, -1, -1, false, "", 0, false, false, inputs); + } + + public Material( + final String materialName, + final MaterialState defaultState, + final short[] rgba, + int radiationLevel, + MaterialStack... materialStacks) { + this( + materialName, + defaultState, + null, + 0, + rgba, + -1, + -1, + -1, + -1, + false, + "", + radiationLevel, + false, + materialStacks); + } + + public Material( + String materialName, + MaterialState defaultState, + short[] rgba, + int j, + int k, + int l, + int m, + int radiationLevel, + MaterialStack[] materialStacks) { + this(materialName, defaultState, null, 0, rgba, j, k, l, m, false, "", radiationLevel, false, materialStacks); + } + + public Material( + String materialName, + MaterialState defaultState, + final TextureSet set, + short[] rgba, + int meltingPoint, + int boilingPoint, + int protons, + int neutrons, + int radiationLevel, + MaterialStack[] materialStacks) { + this( + materialName, + defaultState, + set, + 0, + rgba, + meltingPoint, + boilingPoint, + protons, + neutrons, + false, + "", + radiationLevel, + false, + materialStacks); + } + + public Material( + final String materialName, + final MaterialState defaultState, + final short[] rgba, + final int meltingPoint, + final int boilingPoint, + final long protons, + final long neutrons, + final boolean blastFurnace, + final MaterialStack... inputs) { + this( + materialName, + defaultState, + 0, + rgba, + meltingPoint, + boilingPoint, + protons, + neutrons, + blastFurnace, + "", + 0, + inputs); + } + + public Material( + final String materialName, + final MaterialState defaultState, + final short[] rgba, + final int meltingPoint, + final int boilingPoint, + final long protons, + final long neutrons, + final boolean blastFurnace, + final String chemSymbol, + final MaterialStack... inputs) { + this( + materialName, + defaultState, + 0, + rgba, + meltingPoint, + boilingPoint, + protons, + neutrons, + blastFurnace, + chemSymbol, + 0, + inputs); + } + + public Material( + final String materialName, + final MaterialState defaultState, + final short[] rgba, + final int meltingPoint, + final int boilingPoint, + final long protons, + final long neutrons, + final boolean blastFurnace, + boolean generateCells, + final MaterialStack... inputs) { + this( + materialName, + defaultState, + null, + 0, + rgba, + meltingPoint, + boilingPoint, + protons, + neutrons, + blastFurnace, + "", + 0, + generateCells, + true, + inputs); + } + + public Material( + final String materialName, + final MaterialState defaultState, + final short[] rgba, + final int meltingPoint, + final int boilingPoint, + final long protons, + final long neutrons, + final boolean blastFurnace, + final int radiationLevel, + final MaterialStack... inputs) { + this( + materialName, + defaultState, + 0, + rgba, + meltingPoint, + boilingPoint, + protons, + neutrons, + blastFurnace, + "", + radiationLevel, + inputs); + } + + public Material( + final String materialName, + final MaterialState defaultState, + final long durability, + final short[] rgba, + final int meltingPoint, + final int boilingPoint, + final long protons, + final long neutrons, + final boolean blastFurnace, + final int radiationLevel, + final MaterialStack... inputs) { + this( + materialName, + defaultState, + durability, + rgba, + meltingPoint, + boilingPoint, + protons, + neutrons, + blastFurnace, + "", + radiationLevel, + inputs); + } + + public Material( + final String materialName, + final MaterialState defaultState, + final short[] rgba, + final int meltingPoint, + final int boilingPoint, + final long protons, + final long neutrons, + final boolean blastFurnace, + final String chemicalSymbol, + final int radiationLevel, + final MaterialStack... inputs) { + this( + materialName, + defaultState, + 0, + rgba, + meltingPoint, + boilingPoint, + protons, + neutrons, + blastFurnace, + chemicalSymbol, + radiationLevel, + inputs); + } + + public Material( + final String materialName, + final MaterialState defaultState, + final short[] rgba, + final int meltingPoint, + final int boilingPoint, + final long protons, + final long neutrons, + final boolean blastFurnace, + final String chemicalSymbol, + final int radiationLevel, + boolean addCells, + final MaterialStack... inputs) { + this( + materialName, + defaultState, + null, + 0, + rgba, + meltingPoint, + boilingPoint, + protons, + neutrons, + blastFurnace, + chemicalSymbol, + radiationLevel, + addCells, + true, + inputs); + } + + public Material( + final String materialName, + final MaterialState defaultState, + TextureSet textureSet, + final short[] rgba, + final int meltingPoint, + final int boilingPoint, + final long protons, + final long neutrons, + final boolean blastFurnace, + final String chemicalSymbol, + final int radiationLevel, + final MaterialStack... inputs) { + this( + materialName, + defaultState, + textureSet, + 0, + rgba, + meltingPoint, + boilingPoint, + protons, + neutrons, + blastFurnace, + chemicalSymbol, + radiationLevel, + true, + true, + inputs); + } + + public Material( + final String materialName, + final MaterialState defaultState, + TextureSet textureSet, + final short[] rgba, + final int meltingPoint, + final int boilingPoint, + final long protons, + final long neutrons, + final boolean blastFurnace, + final String chemicalSymbol, + final int radiationLevel, + boolean addCells, + final MaterialStack... inputs) { + this( + materialName, + defaultState, + textureSet, + 0, + rgba, + meltingPoint, + boilingPoint, + protons, + neutrons, + blastFurnace, + chemicalSymbol, + radiationLevel, + addCells, + true, + inputs); + } + + private Material( + final String materialName, + final MaterialState defaultState, + final long durability, + final short[] rgba, + final int meltingPoint, + final int boilingPoint, + final long protons, + final long neutrons, + final boolean blastFurnace, + final String chemicalSymbol, + final int radiationLevel, + final MaterialStack... inputs) { + this( + materialName, + defaultState, + null, + durability, + rgba, + meltingPoint, + boilingPoint, + protons, + neutrons, + blastFurnace, + chemicalSymbol, + radiationLevel, + true, + true, + inputs); + } + + public Material( + final String materialName, + final MaterialState defaultState, + final TextureSet set, + final long durability, + final short[] rgba, + final int meltingPoint, + final int boilingPoint, + final long protons, + final long neutrons, + final boolean blastFurnace, + final String chemicalSymbol, + final int radiationLevel, + boolean generateCells, + final MaterialStack... inputs) { + this( + materialName, + defaultState, + set, + durability, + rgba, + meltingPoint, + boilingPoint, + protons, + neutrons, + blastFurnace, + chemicalSymbol, + radiationLevel, + true, + true, + inputs); + } + + public Material( + final String materialName, + final MaterialState defaultState, + final TextureSet set, + final long durability, + short[] rgba, + final int meltingPoint, + final int boilingPoint, + final long protons, + final long neutrons, + final boolean blastFurnace, + String chemicalSymbol, + final int radiationLevel, + boolean generateCells, + boolean generateFluid, + final MaterialStack... inputs) { + + if (mMaterialMap.add(this)) {} + + if (defaultState == MaterialState.ORE) { + rgba = null; + } + + mComponentMap.put(unlocalizedName, new HashMap()); + + try { + this.unlocalizedName = Utils.sanitizeString(materialName); + this.localizedName = materialName; + mMaterialCache.put(getLocalizedName().toLowerCase(), this); + Logger.INFO("Stored " + getLocalizedName() + " to cache with key: " + + getLocalizedName().toLowerCase()); + + this.materialState = defaultState; + + Logger.MATERIALS(this.getLocalizedName() + " is " + defaultState.name() + "."); + + this.vGenerateCells = generateCells; + + // Add Components to an array. + if (inputs == null) { + this.vMaterialInput = null; + } else { + if (inputs.length != 0) { + for (int i = 0; i < inputs.length; i++) { + if (inputs[i] != null) { + this.vMaterialInput.add(i, inputs[i]); + } + } + } + } + + // set RGB + + if (rgba == null) { + if (vMaterialInput.size() > 0) { + + try { + Short[] mMixedRGB = new Short[3]; + AutoMap mMaterialSet = MaterialUtils.getCompoundMaterialsRecursively(this); + for (int mnh = 0; mnh < 3; mnh++) { + AutoMap aDataSet = new AutoMap(); + Set set4 = new HashSet(); + for (Material u : mMaterialSet) { + // if (u.getState() == MaterialState.ORE || u.getState() == MaterialState.SOLID) + set4.add(u); + } + for (Material e : set4) { + aDataSet.put(e.getRGB()[mnh]); + } + + Short aAverage = MathUtils.getShortAverage(aDataSet); + if (aAverage > Short.MAX_VALUE + || aAverage < Short.MIN_VALUE + || aAverage < 0 + || aAverage > 255) { + if (aAverage > 255) { + while (aAverage > 255) { + aAverage = (short) (aAverage / 2); + } + } + aAverage = (short) Math.max(Math.min(aAverage, 255), 0); + } + mMixedRGB[mnh] = aAverage; + } + + if (mMixedRGB != null && mMixedRGB[0] != null && mMixedRGB[1] != null && mMixedRGB[2] != null) { + this.RGBA = new short[] {mMixedRGB[0], mMixedRGB[1], mMixedRGB[2], 0}; + } else { + this.RGBA = Materials.Steel.mRGBa; + } + } catch (Throwable t) { + t.printStackTrace(); + this.RGBA = Materials.Steel.mRGBa; + } + } else { + // Boring Grey Material + + int aValueForGen = this.getUnlocalizedName().hashCode(); + int hashSize = MathUtils.howManyPlaces(aValueForGen); + + String a = String.valueOf(aValueForGen); + String b = ""; + + if (hashSize < 9) { + int aSecondHash = this.materialState.hashCode(); + int hashSize2 = MathUtils.howManyPlaces(aSecondHash); + if (hashSize2 + hashSize >= 9) { + b = String.valueOf(aValueForGen); + } else { + String c = b; + while (MathUtils.howManyPlaces(hashSize + c.length()) < 9) { + c = c + c.hashCode(); + } + b = c; + } + } + + String valueR; + if (b != null) { + valueR = a + b; + } else { + valueR = a; + } + short fc[] = new short[3]; + int aIndex = 0; + for (char gg : valueR.toCharArray()) { + short ui = Short.parseShort("" + gg); + if (ui > 255 || ui < 0) { + if (ui > 255) { + while (ui > 255) { + ui = (short) (ui / 2); + } + } else { + ui = 0; + } + } + fc[aIndex++] = ui; + } + this.RGBA = fc; + } + } else { + this.RGBA = rgba; + } + + // Set Melting/Boiling point, if value is -1 calculate it from compound inputs. + if (meltingPoint != -1) { + this.meltingPointC = meltingPoint; + } else { + this.meltingPointC = this.calculateMeltingPoint(); + } + if (boilingPoint != -1) { + if (boilingPoint != 0) { + this.boilingPointC = boilingPoint; + } else { + this.boilingPointC = meltingPoint * 4; + } + } else { + this.boilingPointC = this.calculateBoilingPoint(); + } + + this.meltingPointK = (int) MathUtils.celsiusToKelvin(this.meltingPointC); + this.boilingPointK = (int) MathUtils.celsiusToKelvin(this.boilingPointC); + + // Set Proton/Neutron count, if value is -1 calculate it from compound inputs. + if (protons != -1) { + this.vProtons = protons; + } else { + this.vProtons = this.calculateProtons(); + } + if (boilingPoint != -1) { + this.vNeutrons = neutrons; + } else { + this.vNeutrons = this.calculateNeutrons(); + } + + this.vAspects = null; + + this.vMass = this.getMass(); + + // Sets tool Durability + if (durability != 0) { + this.vDurability = durability; + } else { + long aTempDura = 0; + for (MaterialStack g : this.getComposites()) { + if (g != null) { + aTempDura += safeCast_LongToInt(g.getStackMaterial().getMass() * 2000); + } + } + this.vDurability = aTempDura > 0 + ? aTempDura + : (this.getComposites().isEmpty() + ? 51200 + : 32000 * this.getComposites().size()); + } + + if ((this.vDurability >= 0) && (this.vDurability < 64000)) { + this.vToolQuality = 1; + this.vHarvestLevel = 2; + } else if ((this.vDurability >= 64000) && (this.vDurability < 128000)) { + this.vToolQuality = 2; + this.vHarvestLevel = 2; + } else if ((this.vDurability >= 128000) && (this.vDurability < 256000)) { + this.vToolQuality = 3; + this.vHarvestLevel = 2; + } else if ((this.vDurability >= 256000) && (this.vDurability < 512000)) { + this.vToolQuality = 3; + this.vHarvestLevel = 3; + } else if ((this.vDurability >= 512000) && (this.vDurability <= Integer.MAX_VALUE)) { + this.vToolQuality = 4; + this.vHarvestLevel = 4; + } else { + this.vToolQuality = 1; + this.vHarvestLevel = 1; + } + + // Sets the Rad level + if (radiationLevel > 0) { + Logger.MATERIALS(this.getLocalizedName() + " is radioactive. Level: " + radiationLevel + "."); + this.isRadioactive = true; + this.vRadiationLevel = (byte) radiationLevel; + } else { + if (vMaterialInput.size() > 0) { + AutoMap aDataSet = new AutoMap(); + for (MaterialStack m : this.vMaterialInput) { + aDataSet.put(m.getStackMaterial().vRadiationLevel); + } + byte aAverage = MathUtils.getByteAverage(aDataSet); + if (aAverage > 0) { + Logger.MATERIALS(this.getLocalizedName() + " is radioactive due to trace elements. Level: " + + aAverage + "."); + this.isRadioactive = true; + this.vRadiationLevel = (byte) aAverage; + } else { + Logger.MATERIALS(this.getLocalizedName() + " is not radioactive."); + this.isRadioactive = false; + this.vRadiationLevel = 0; + } + } else { + Logger.MATERIALS(this.getLocalizedName() + " is not radioactive."); + this.isRadioactive = false; + this.vRadiationLevel = 0; + } + } + + /*if (vMaterialInput.size() > 0) { + AutoMap aDataSet = new AutoMap(); + + int bonus = 0; + bonus += this.vMaterialInput.size(); + bonus += MathUtils.roundToClosestInt(meltingPointC/1000); + + + + aDataSet.put(bonus); + + for (MaterialStack m : this.vMaterialInput) { + aDataSet.put(m.getStackMaterial().vTier); + } + int aAverage = MathUtils.getIntAverage(aDataSet); + if (aAverage > Integer.MAX_VALUE || aAverage < Integer.MIN_VALUE) { + aAverage = 0; + } + if (aAverage > 0) { + this.vTier = Math.min(aAverage, 10); + } + else { + this.vTier = MaterialUtils.getTierOfMaterial((int) MathUtils.celsiusToKelvin(meltingPoint)); + } + } + else { + this.vTier = MaterialUtils.getTierOfMaterial((int) MathUtils.celsiusToKelvin(meltingPoint)); + }*/ + this.vTier = MaterialUtils.getTierOfMaterial(meltingPoint); + + // Sets the materials 'tier'. Will probably replace this logic. + + this.usesBlastFurnace = blastFurnace; + this.vVoltageMultiplier = MaterialUtils.getVoltageForTier(vTier); + + this.vComponentCount = this.getComponentCount(inputs); + this.vSmallestRatio = this.getSmallestRatio(this.vMaterialInput); + int tempSmallestSize = 0; + + if (this.vSmallestRatio != null) { + for (int v = 0; v < this.vSmallestRatio.length; v++) { + tempSmallestSize = (int) (tempSmallestSize + this.vSmallestRatio[v]); + } + this.smallestStackSizeWhenProcessing = tempSmallestSize; // Valid stacksizes + } else { + this.smallestStackSizeWhenProcessing = 1; // Valid stacksizes + } + + // Makes a Fancy Chemical Tooltip + + if (chemicalSymbol == null) { + chemicalSymbol = ""; + } + + this.vChemicalSymbol = chemicalSymbol; + if (this.vMaterialInput != null) { + this.vChemicalFormula = this.getToolTip(chemicalSymbol, OrePrefixes.dust.mMaterialAmount / M, true); + } else if (!this.vChemicalSymbol.equals("")) { + Logger.MATERIALS("materialInput is null, using a valid chemical symbol."); + this.vChemicalFormula = this.vChemicalSymbol; + } else { + Logger.MATERIALS("MaterialInput == null && chemicalSymbol probably equals nothing"); + this.vChemicalSymbol = "??"; + this.vChemicalFormula = "??"; + } + + if (generateFluid) { + final Materials aGregtechMaterial = tryFindGregtechMaterialEquivalent(); + FluidStack aTest = FluidUtils.getWildcardFluidStack(localizedName, 1); + if (aTest != null) { + this.mFluid = aTest.getFluid(); + checkForCellAndGenerate(this); + } else { + if (aGregtechMaterial != null && !MaterialUtils.isNullGregtechMaterial(aGregtechMaterial)) { + aTest = FluidUtils.getWildcardFluidStack(aGregtechMaterial, 1); + } + if (aTest != null) { + this.mFluid = aTest.getFluid(); + checkForCellAndGenerate(this); + } else { + mFluid = generateFluid(); + } + } + // Don't generate plasma for composites + if (this.getComposites().isEmpty()) { + this.mPlasma = this.generatePlasma(); + } + } else { + this.mFluid = null; + this.mPlasma = null; + } + String ratio = ""; + if (this.vSmallestRatio != null) { + for (int hu = 0; hu < this.vSmallestRatio.length; hu++) { + if (ratio.equals("")) { + ratio = String.valueOf(this.vSmallestRatio[hu]); + } else { + ratio = ratio + ":" + this.vSmallestRatio[hu]; + } + } + } + + this.textureSet = setTextureSet(set, vTier); + + if (LoadedMods.TiCon && this.materialState == MaterialState.SOLID) { + if (this.getProtons() >= 98 || this.getComposites().size() > 1 || this.getMeltingPointC() >= 3600) { + this.vTiConHandler = new BaseTinkersMaterial(this); + } + } + + sChemicalFormula.put(materialName.toLowerCase(), this.vChemicalFormula); + Logger.MATERIALS("Creating a Material instance for " + materialName); + Logger.MATERIALS("Formula: " + this.vChemicalFormula + " Smallest Stack: " + + this.smallestStackSizeWhenProcessing + " Smallest Ratio:" + ratio); + Logger.MATERIALS("Protons: " + this.vProtons); + Logger.MATERIALS("Neutrons: " + this.vNeutrons); + Logger.MATERIALS("Mass: " + this.vMass + "/units"); + Logger.MATERIALS("Melting Point: " + this.meltingPointC + "C."); + Logger.MATERIALS("Boiling Point: " + this.boilingPointC + "C."); + } catch (Throwable t) { + Logger.MATERIALS("Stack Trace for " + materialName); + t.printStackTrace(); + } + } + + private static void checkForCellAndGenerate(Material material) { + if (!material.vGenerateCells) { + return; + } + String aName = Utils.sanitizeString(material.unlocalizedName); + String aName2 = Utils.sanitizeString(material.unlocalizedName.toLowerCase()); + String aName3 = (material.localizedName == null) ? aName : material.localizedName; + ItemStack aTestCell1 = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell" + aName, 1); + ItemStack aTestCell2 = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell" + aName2, 1); + ItemStack aTestCell3 = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell" + aName3, 1); + if (aTestCell1 == null && aTestCell2 == null && aTestCell3 == null) { + Logger.INFO("Generating cell for " + material.localizedName); + new BaseItemCell(material); + } else { + if (aTestCell1 != null) { + Logger.INFO("Registering existing cell for " + material.localizedName + ", " + aName); + material.registerComponentForMaterial(OrePrefixes.cell, aTestCell1); + } else if (aTestCell2 != null) { + Logger.INFO("Registering existing cell for " + material.localizedName + ", " + aName2); + material.registerComponentForMaterial(OrePrefixes.cell, aTestCell2); + } else if (aTestCell3 != null) { + Logger.INFO("Registering existing cell for " + material.localizedName + ", " + aName3); + material.registerComponentForMaterial(OrePrefixes.cell, aTestCell3); + } + } + } + + public final TextureSet getTextureSet() { + synchronized (this) { + return textureSet; + } + } + + public TextureSet setTextureSet(TextureSet set) { + return setTextureSet(set, vTier); + } + + public TextureSet setTextureSet(TextureSet set, int aTier) { + if (set != null) { + Logger.MATERIALS("Set textureset for " + this.localizedName + " to be " + set.mSetName + + ". This textureSet was supplied."); + return set; + } + + int aGem = 0; + int aShiny = 0; + TextureSet aSet = null; + + // Check Mixture Contents + for (MaterialStack m : this.getComposites()) { + + // Gems + if (m.getStackMaterial() == ELEMENT.getInstance().AER) { + aGem++; + } else if (m.getStackMaterial() == ELEMENT.getInstance().AQUA) { + aGem++; + } else if (m.getStackMaterial() == ELEMENT.getInstance().IGNIS) { + aGem++; + } else if (m.getStackMaterial() == ELEMENT.getInstance().TERRA) { + aGem++; + } else if (m.getStackMaterial() == ELEMENT.getInstance().MAGIC) { + aGem++; + } + // Shiny Materials + if (m.getStackMaterial() == ELEMENT.getInstance().GOLD) { + aShiny++; + } else if (m.getStackMaterial() == ELEMENT.getInstance().SILVER) { + aShiny++; + } else if (m.getStackMaterial() == ELEMENT.getInstance().PLATINUM) { + aShiny++; + } else if (m.getStackMaterial() == ELEMENT.getInstance().AMERICIUM) { + aShiny++; + } else if (m.getStackMaterial() == ELEMENT.getInstance().TITANIUM) { + aShiny++; + } else if (m.getStackMaterial() == ELEMENT.getInstance().GERMANIUM) { + aShiny++; + } else if (m.getStackMaterial() == ELEMENT.getInstance().GALLIUM) { + aShiny++; + } else if (m.getStackMaterial() == ELEMENT.getInstance().MERCURY) { + aShiny++; + } else if (m.getStackMaterial() == ELEMENT.getInstance().MAGIC) { + aShiny++; + } else if (m.getStackMaterial() == ELEMENT.getInstance().SAMARIUM) { + aShiny++; + } else if (m.getStackMaterial() == ELEMENT.getInstance().TANTALUM) { + aShiny++; + } + } + + if (aSet == null) { + if (aGem >= this.getComposites().size() / 2) { + if (MathUtils.isNumberEven(aGem)) { + Logger.MATERIALS("Set textureset for " + this.localizedName + " to be " + + TextureSet.SET_GEM_HORIZONTAL.mSetName + "."); + return TextureSet.SET_GEM_HORIZONTAL; + } else { + Logger.MATERIALS("Set textureset for " + this.localizedName + " to be " + + TextureSet.SET_GEM_VERTICAL.mSetName + "."); + return TextureSet.SET_GEM_VERTICAL; + } + } + } + + if (aSet == null) { + if (aShiny >= this.getComposites().size() / 3) { + Logger.MATERIALS( + "Set textureset for " + this.localizedName + " to be " + TextureSet.SET_SHINY.mSetName + "."); + return TextureSet.SET_SHINY; + } + } + + // build hash table with count + AutoMap sets = new AutoMap(); + if (this.vMaterialInput != null) { + for (MaterialStack r : this.vMaterialInput) { + if (r.getStackMaterial().getTextureSet().mSetName.toLowerCase().contains("fluid")) { + sets.put(ELEMENT.getInstance().GOLD); + } else { + sets.put(r.getStackMaterial()); + } + } + TextureSet mostUsedTypeTextureSet = + MaterialUtils.getMostCommonTextureSet(new ArrayList(sets.values())); + if (mostUsedTypeTextureSet != null && mostUsedTypeTextureSet instanceof TextureSet) { + Logger.MATERIALS( + "Set textureset for " + this.localizedName + " to be " + mostUsedTypeTextureSet.mSetName + "."); + return mostUsedTypeTextureSet; + } + } + Logger.MATERIALS("Set textureset for " + this.localizedName + " to be " + Materials.Iron.mIconSet.mSetName + + ". [Fallback]"); + return Materials.Gold.mIconSet; + } + + public final String getLocalizedName() { + if (this.localizedName != null) { + return this.localizedName; + } + return "ERROR BAD LOCALIZED NAME"; + } + + public final String getUnlocalizedName() { + if (this.unlocalizedName != null) { + return this.unlocalizedName; + } + return "ERROR.BAD.UNLOCALIZED.NAME"; + } + + public final MaterialState getState() { + return this.materialState; + } + + public final short[] getRGB() { + if (this.RGBA != null) { + return this.RGBA; + } + return new short[] {255, 0, 0}; + } + + public final short[] getRGBA() { + if (this.RGBA != null) { + if (this.RGBA.length == 4) { + return this.RGBA; + } else { + return new short[] {this.RGBA[0], this.RGBA[1], this.RGBA[2], 0}; + } + } + return new short[] {255, 0, 0, 0}; + } + + public final int getRgbAsHex() { + + final int returnValue = Utils.rgbtoHexValue(this.RGBA[0], this.RGBA[1], this.RGBA[2]); + if (returnValue == 0) { + return (int) this.dataVar; + } + return Utils.rgbtoHexValue(this.RGBA[0], this.RGBA[1], this.RGBA[2]); + } + + public final long getProtons() { + return this.vProtons; + } + + public final long getNeutrons() { + return this.vNeutrons; + } + + public final long getMass() { + return this.vProtons + this.vNeutrons; + } + + public final int getMeltingPointC() { + return this.meltingPointC; + } + + public final int getBoilingPointC() { + return this.boilingPointC; + } + + public final int getMeltingPointK() { + return this.meltingPointK; + } + + public final int getBoilingPointK() { + return this.boilingPointK; + } + + public final boolean requiresBlastFurnace() { + return this.usesBlastFurnace; + } + + public final ItemStack getComponentByPrefix(OrePrefixes aPrefix, int stacksize) { + String aKey = aPrefix.name(); + Map g = mComponentMap.get(this.unlocalizedName); + if (g == null) { + Map aMap = new HashMap(); + mComponentMap.put(unlocalizedName, aMap); + g = aMap; + } + ItemStack i = g.get(aKey); + if (i != null) { + return ItemUtils.getSimpleStack(i, stacksize); + } else { + // Try get a GT Material + Materials Erf = MaterialUtils.getMaterial(this.unlocalizedName); + if (Erf != null && !MaterialUtils.isNullGregtechMaterial(Erf)) { + ItemStack Erg = ItemUtils.getOrePrefixStack(aPrefix, Erf, stacksize); + if (Erg != null && ItemUtils.checkForInvalidItems(Erg)) { + Logger.MATERIALS("Found \"" + aKey + this.unlocalizedName + "\" using backup GT Materials option."); + g.put(aKey, Erg); + mComponentMap.put(unlocalizedName, g); + return Erg; + } else { + // Try get a molten cell + if (aPrefix == OrePrefixes.cell) { + Erg = ItemUtils.getOrePrefixStack(OrePrefixes.cellMolten, Erf, stacksize); + if (Erg != null && ItemUtils.checkForInvalidItems(Erg)) { + Logger.MATERIALS("Found \"" + OrePrefixes.cellMolten.name() + this.unlocalizedName + + "\" using backup GT Materials option."); + g.put(aKey, Erg); + mComponentMap.put(unlocalizedName, g); + return Erg; + } + } + } + } else { + ItemStack u = ItemUtils.getItemStackOfAmountFromOreDictNoBroken(aKey + this.unlocalizedName, stacksize); + if (u != null) { + g.put(aKey, u); + mComponentMap.put(unlocalizedName, g); + return u; + } + } + // Logger.MATERIALS("Unabled to find \"" + aKey + this.unlocalizedName + "\""); + return ItemUtils.getErrorStack(stacksize, (aKey + this.unlocalizedName + " x" + stacksize)); + } + } + + public final Block getBlock() { + Block b = Block.getBlockFromItem(getBlock(1).getItem()); + if (b == null) { + Logger.INFO("[ERROR] Tried to get invalid block for " + this.getLocalizedName() + + ", returning debug block instead."); + } + return b != null ? b : Blocks.lit_furnace; + } + + public final ItemStack getBlock(final int stacksize) { + ItemStack i = getComponentByPrefix(OrePrefixes.block, stacksize); + return i != null + ? i + : ItemUtils.getItemStackOfAmountFromOreDictNoBroken("block" + this.unlocalizedName, stacksize); + } + + public final ItemStack getDust(final int stacksize) { + ItemStack i = getComponentByPrefix(OrePrefixes.dust, stacksize); + return i != null ? i : ItemUtils.getGregtechDust("dust" + this.unlocalizedName, stacksize); + } + + public final ItemStack getSmallDust(final int stacksize) { + return getComponentByPrefix(OrePrefixes.dustSmall, stacksize); + } + + public final ItemStack getTinyDust(final int stacksize) { + return getComponentByPrefix(OrePrefixes.dustTiny, stacksize); + } + + public final ItemStack getIngot(final int stacksize) { + return getComponentByPrefix(OrePrefixes.ingot, stacksize); + } + + public final ItemStack getHotIngot(final int stacksize) { + return getComponentByPrefix(OrePrefixes.ingotHot, stacksize); + } + + public final ItemStack getPlate(final int stacksize) { + return getComponentByPrefix(OrePrefixes.plate, stacksize); + } + + public final ItemStack getPlateDouble(final int stacksize) { + return getComponentByPrefix(OrePrefixes.plateDouble, stacksize); + } + + public final ItemStack getGear(final int stacksize) { + return getComponentByPrefix(OrePrefixes.gearGt, stacksize); + } + + public final ItemStack getRod(final int stacksize) { + return getComponentByPrefix(OrePrefixes.stick, stacksize); + } + + public final ItemStack getLongRod(final int stacksize) { + return getComponentByPrefix(OrePrefixes.stickLong, stacksize); + } + + public final ItemStack getBolt(final int stacksize) { + return getComponentByPrefix(OrePrefixes.bolt, stacksize); + } + + public final ItemStack getScrew(final int stacksize) { + return getComponentByPrefix(OrePrefixes.screw, stacksize); + } + + public final ItemStack getFineWire(final int stacksize) { + return getComponentByPrefix(OrePrefixes.wireFine, stacksize); + } + + public final ItemStack getFoil(final int stacksize) { + return getComponentByPrefix(OrePrefixes.foil, stacksize); + } + + public final ItemStack getRing(final int stacksize) { + return getComponentByPrefix(OrePrefixes.ring, stacksize); + } + + public final ItemStack getRotor(final int stacksize) { + return getComponentByPrefix(OrePrefixes.rotor, stacksize); + } + + public final ItemStack getFrameBox(final int stacksize) { + return getComponentByPrefix(OrePrefixes.frameGt, stacksize); + } + + public final ItemStack getCell(final int stacksize) { + return getComponentByPrefix(OrePrefixes.cell, stacksize); + } + + public final ItemStack getPlasmaCell(final int stacksize) { + return getComponentByPrefix(OrePrefixes.cellPlasma, stacksize); + } + + public final ItemStack getNugget(final int stacksize) { + return getComponentByPrefix(OrePrefixes.nugget, stacksize); + } + + public final ItemStack getWire01(final int stacksize) { + return getComponentByPrefix(OrePrefixes.wireGt01, stacksize); + } + + public final ItemStack getWire02(final int stacksize) { + return getComponentByPrefix(OrePrefixes.wireGt02, stacksize); + } + + public final ItemStack getWire04(final int stacksize) { + return getComponentByPrefix(OrePrefixes.wireGt04, stacksize); + } + + public final ItemStack getWire08(final int stacksize) { + return getComponentByPrefix(OrePrefixes.wireGt08, stacksize); + } + + public final ItemStack getWire12(final int stacksize) { + return getComponentByPrefix(OrePrefixes.wireGt12, stacksize); + } + + public final ItemStack getWire16(final int stacksize) { + return getComponentByPrefix(OrePrefixes.wireGt16, stacksize); + } + + public final ItemStack getCable01(final int stacksize) { + return getComponentByPrefix(OrePrefixes.cableGt01, stacksize); + } + + public final ItemStack getCable02(final int stacksize) { + return getComponentByPrefix(OrePrefixes.cableGt02, stacksize); + } + + public final ItemStack getCable04(final int stacksize) { + return getComponentByPrefix(OrePrefixes.cableGt04, stacksize); + } + + public final ItemStack getCable08(final int stacksize) { + return getComponentByPrefix(OrePrefixes.cableGt08, stacksize); + } + + public final ItemStack getCable12(final int stacksize) { + return getComponentByPrefix(OrePrefixes.cableGt12, stacksize); + } + + public final ItemStack getCable16(final int stacksize) { + if (GregtechConduits.cableGt16 != null) { + return getComponentByPrefix(GregtechConduits.cableGt16, stacksize); + } else { + return ItemUtils.getErrorStack(stacksize); + } + } + + /** + * Ore Components + * @return + */ + public final ItemStack getOre(final int stacksize) { + return ItemUtils.getItemStackOfAmountFromOreDictNoBroken( + "ore" + Utils.sanitizeString(this.getUnlocalizedName()), stacksize); + } + + public final Block getOreBlock(final int stacksize) { + // Logger.DEBUG_MATERIALS("Trying to get ore block for "+this.getLocalizedName()+". Looking for + // '"+"ore"+Utils.sanitizeString(this.getUnlocalizedName())+"'."); + try { + ItemStack a1 = getOre(1); + Item a2 = a1.getItem(); + Block a3 = Block.getBlockFromItem(a2); + if (a3 != null) { + return a3; + } + + Block x = Block.getBlockFromItem(ItemUtils.getItemStackOfAmountFromOreDictNoBroken( + "ore" + Utils.sanitizeString(this.unlocalizedName), stacksize) + .getItem()); + if (x != null) { + return x; + } + } catch (Throwable t) { + // t.printStackTrace(); + } + // Logger.MATERIALS("Failed getting the Ore Block for "+this.getLocalizedName()+"."); + return Blocks.stone; + } + + public final ItemStack getCrushed(final int stacksize) { + return getComponentByPrefix(OrePrefixes.crushed, stacksize); + } + + public final ItemStack getCrushedPurified(final int stacksize) { + return getComponentByPrefix(OrePrefixes.crushedPurified, stacksize); + } + + public final ItemStack getCrushedCentrifuged(final int stacksize) { + return getComponentByPrefix(OrePrefixes.crushedCentrifuged, stacksize); + } + + public final ItemStack getDustPurified(final int stacksize) { + return getComponentByPrefix(OrePrefixes.dustPure, stacksize); + } + + public final ItemStack getDustImpure(final int stacksize) { + return getComponentByPrefix(OrePrefixes.dustImpure, stacksize); + } + + public final ItemStack getMilled(final int stacksize) { + return getComponentByPrefix(CustomOrePrefix.milled.get(), stacksize); + } + + public final boolean hasSolidForm() { + if (ItemUtils.checkForInvalidItems( + new ItemStack[] {getDust(1), getBlock(1), getTinyDust(1), getSmallDust(1)})) { + return true; + } + return false; + } + + public final ItemStack[] getMaterialComposites() { + if (this.vMaterialInput != null && !this.vMaterialInput.isEmpty()) { + final ItemStack[] temp = new ItemStack[this.vMaterialInput.size()]; + for (int i = 0; i < this.vMaterialInput.size(); i++) { + // Utils.LOG_MATERIALS("i:"+i); + ItemStack testNull = null; + try { + testNull = this.vMaterialInput.get(i).getValidStack(); + } catch (final Throwable r) { + Logger.MATERIALS("Failed gathering material stack for " + this.localizedName + "."); + Logger.MATERIALS("What Failed: Length:" + this.vMaterialInput.size() + " current:" + i); + } + try { + if (testNull != null) { + // Utils.LOG_MATERIALS("not null"); + temp[i] = this.vMaterialInput.get(i).getValidStack(); + } + } catch (final Throwable r) { + Logger.MATERIALS("Failed setting slot " + i + ", using " + this.localizedName); + } + } + return temp; + } + return new ItemStack[] {}; + } + + public final ArrayList getComposites() { + return this.vMaterialInput; + } + + public final int[] getMaterialCompositeStackSizes() { + if (!this.vMaterialInput.isEmpty()) { + final int[] temp = new int[this.vMaterialInput.size()]; + for (int i = 0; i < this.vMaterialInput.size(); i++) { + if (this.vMaterialInput.get(i) != null) { + temp[i] = this.vMaterialInput.get(i).getDustStack().stackSize; + } else { + temp[i] = 0; + } + } + return temp; + } + return new int[] {}; + } + + private final short getComponentCount(final MaterialStack[] inputs) { + + if (inputs == null || inputs.length < 1) { + return 1; + } + int counterTemp = 0; + for (final MaterialStack m : inputs) { + if (m.getStackMaterial() != null) { + counterTemp++; + } + } + if (counterTemp != 0) { + return (short) counterTemp; + } else { + return 1; + } + } + + public final long[] getSmallestRatio(final ArrayList tempInput) { + if (tempInput != null) { + if (!tempInput.isEmpty()) { + Logger.MATERIALS("length: " + tempInput.size()); + Logger.MATERIALS("(inputs != null): " + (tempInput != null)); + // Utils.LOG_MATERIALS("length: "+inputs.length); + final long[] tempRatio = new long[tempInput.size()]; + for (int x = 0; x < tempInput.size(); x++) { + // tempPercentage = tempPercentage+inputs[x].percentageToUse; + // this.mMaterialList.add(inputs[x]); + if (tempInput.get(x) != null) { + tempRatio[x] = tempInput.get(x).getPartsPerOneHundred(); + } + } + + final long[] smallestRatio = MathUtils.simplifyNumbersToSmallestForm(tempRatio); + + if (smallestRatio.length > 0) { + String tempRatioStringThing1 = ""; + for (int r = 0; r < tempRatio.length; r++) { + tempRatioStringThing1 = tempRatioStringThing1 + tempRatio[r] + " : "; + } + Logger.MATERIALS("Default Ratio: " + tempRatioStringThing1); + + String tempRatioStringThing = ""; + int tempSmallestCraftingUseSize = 0; + for (int r = 0; r < smallestRatio.length; r++) { + tempRatioStringThing = tempRatioStringThing + smallestRatio[r] + " : "; + tempSmallestCraftingUseSize = (int) (tempSmallestCraftingUseSize + smallestRatio[r]); + } + // this.smallestStackSizeWhenProcessing = tempSmallestCraftingUseSize; + Logger.MATERIALS("Smallest Ratio: " + tempRatioStringThing); + return smallestRatio; + } + } + } + return new long[] {}; + } + + public final String getToolTip(final String chemSymbol, final long aMultiplier, final boolean aShowQuestionMarks) { + if (!aShowQuestionMarks && (this.vChemicalFormula.equals("?") || this.vChemicalFormula.equals("??"))) { + return ""; + } + Logger.MATERIALS("===============| Calculating Atomic Formula for " + this.localizedName + " |==============="); + if (!chemSymbol.equals("")) { + return chemSymbol; + } + final ArrayList tempInput = this.vMaterialInput; + if (tempInput != null) { + if (!tempInput.isEmpty()) { + String dummyFormula = ""; + final long[] dummyFormulaArray = this.getSmallestRatio(tempInput); + if (dummyFormulaArray != null) { + if (dummyFormulaArray.length >= 1) { + for (int e = 0; e < tempInput.size(); e++) { + MaterialStack g = tempInput.get(e); + if (g != null) { + if (g.getStackMaterial() != null) { + + String aChemSymbol = g.getStackMaterial().vChemicalSymbol; + String aChemFormula = g.getStackMaterial().vChemicalFormula; + + if (aChemSymbol == null) { + aChemSymbol = "??"; + } + if (aChemFormula == null) { + aChemFormula = "??"; + } + + if (!aChemSymbol.equals("??")) { + if (dummyFormulaArray[e] > 1) { + + if (aChemFormula.length() > 3) { + dummyFormula = + dummyFormula + "(" + aChemFormula + ")" + dummyFormulaArray[e]; + } else { + dummyFormula = dummyFormula + aChemFormula + dummyFormulaArray[e]; + } + } else if (dummyFormulaArray[e] == 1) { + if (aChemFormula.length() > 3) { + dummyFormula = dummyFormula + "(" + aChemFormula + ")"; + } else { + dummyFormula = dummyFormula + aChemFormula; + } + } else { + dummyFormula = dummyFormula + "??"; + } + } else { + dummyFormula = dummyFormula + "??"; + } + } else { + dummyFormula = dummyFormula + "??"; + } + } + } + return StringUtils.subscript(dummyFormula); + // return dummyFormula; + } + Logger.MATERIALS("dummyFormulaArray <= 0"); + } + Logger.MATERIALS("dummyFormulaArray == null"); + } + Logger.MATERIALS("tempInput.length <= 0"); + } + Logger.MATERIALS("tempInput == null"); + return "??"; + } + + public final boolean queueFluidGeneration() { + return isFluidQueued = true; + } + + public static final void generateQueuedFluids() { + for (Material m : mMaterialMap) { + if (m.isFluidQueued) {} + } + } + + // If we need a fluid, let's just queue it for later. + public boolean isFluidQueued = false; + + public final Fluid generateFluid() { + if (this.materialState == MaterialState.ORE) { + return null; + } + + Fluid aGTBaseFluid = null; + + // Clean up Internal Fluid Generation + final Materials n1 = + MaterialUtils.getMaterial(this.getLocalizedName(), Utils.sanitizeString(this.getLocalizedName())); + final Materials n2 = + MaterialUtils.getMaterial(this.getUnlocalizedName(), Utils.sanitizeString(this.getUnlocalizedName())); + + FluidStack f1 = FluidUtils.getWildcardFluidStack(n1, 1); + FluidStack f2 = FluidUtils.getWildcardFluidStack(n2, 1); + FluidStack f3 = FluidUtils.getWildcardFluidStack( + Utils.sanitizeString(this.getUnlocalizedName(), new char[] {'-', '_'}), 1); + FluidStack f4 = FluidUtils.getWildcardFluidStack( + Utils.sanitizeString(this.getLocalizedName(), new char[] {'-', '_'}), 1); + + if (f1 != null) { + aGTBaseFluid = f1.getFluid(); + } else if (f2 != null) { + aGTBaseFluid = f2.getFluid(); + } else if (f3 != null) { + aGTBaseFluid = f3.getFluid(); + } else if (f4 != null) { + aGTBaseFluid = f4.getFluid(); + } + + ItemStack aFullCell = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell" + this.getUnlocalizedName(), 1); + ItemStack aFullCell2 = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell" + this.getLocalizedName(), 1); + ItemStack aFullCell3 = ItemUtils.getItemStackOfAmountFromOreDictNoBroken( + "cell" + Utils.sanitizeString(this.getUnlocalizedName(), new char[] {'-', '_'}), 1); + ItemStack aFullCell4 = ItemUtils.getItemStackOfAmountFromOreDictNoBroken( + "cell" + Utils.sanitizeString(this.getLocalizedName(), new char[] {'-', '_'}), 1); + + Logger.MATERIALS("Generating our own fluid."); + // Generate a Cell if we need to, but first validate all four searches are invalid + + if (!ItemUtils.checkForInvalidItems(new ItemStack[] {aFullCell, aFullCell2, aFullCell3, aFullCell4})) { + if (this.vGenerateCells) { + Item g = new BaseItemCell(this); + aFullCell = ItemUtils.getSimpleStack(g); + Logger.MATERIALS("Generated a cell for " + this.getUnlocalizedName()); + } else { + Logger.MATERIALS("Did not generate a cell for " + this.getUnlocalizedName()); + } + } else { + // One cell we searched for was valid, let's register it. + if (aFullCell != null) { + this.registerComponentForMaterial(ComponentTypes.CELL, aFullCell); + } else if (aFullCell2 != null) { + this.registerComponentForMaterial(ComponentTypes.CELL, aFullCell2); + } else if (aFullCell3 != null) { + this.registerComponentForMaterial(ComponentTypes.CELL, aFullCell3); + } else if (aFullCell4 != null) { + this.registerComponentForMaterial(ComponentTypes.CELL, aFullCell4); + } + } + + // We found a GT fluid, let's use it. + // Good chance we registered the cell from this material too. + if (aGTBaseFluid != null) { + return aGTBaseFluid; + } + + // This fluid does not exist at all, time to generate it. + if (this.materialState == MaterialState.SOLID) { + return FluidUtils.addGTFluid( + this.getUnlocalizedName(), + "Molten " + this.getLocalizedName(), + this.RGBA, + 4, + this.getMeltingPointK(), + aFullCell, + ItemUtils.getEmptyCell(), + 1000, + this.vGenerateCells); + } else if (this.materialState == MaterialState.LIQUID || this.materialState == MaterialState.PURE_LIQUID) { + return FluidUtils.addGTFluid( + this.getUnlocalizedName(), + this.getLocalizedName(), + this.RGBA, + 0, + this.getMeltingPointK(), + aFullCell, + ItemUtils.getEmptyCell(), + 1000, + this.vGenerateCells); + } else if (this.materialState == MaterialState.GAS || this.materialState == MaterialState.PURE_GAS) { + return FluidUtils.generateGas( + unlocalizedName, this.getLocalizedName(), getMeltingPointK(), getRGBA(), vGenerateCells); + /*return FluidUtils.addGTFluid( + this.getUnlocalizedName(), + this.getLocalizedName()+" Gas", + this.RGBA, + 2, + this.getMeltingPointK(), + aFullCell, + ItemUtils.getEmptyCell(), + 1000, + this.vGenerateCells);*/ + } else { // Plasma + return this.generatePlasma(); + } + } + + public final Fluid generatePlasma() { + if (this.materialState == MaterialState.ORE) { + return null; + } + final Materials isValid = tryFindGregtechMaterialEquivalent(); + + if (!this.vGenerateCells) { + return null; + } + if (isValid != null) { + for (Materials m : invalidMaterials.values()) { + if (isValid == m) { + return null; + } + } + if (isValid.mPlasma != null) { + Logger.MATERIALS("Using a pre-defined Plasma from GT."); + return isValid.mPlasma; + } + } + Logger.MATERIALS("Generating our own Plasma."); + return FluidUtils.addGTPlasma(this); + } + + public Fluid getFluid() { + return mFluid; + } + + public Fluid getPlasma() { + return mPlasma; + } + + public final FluidStack getFluidStack(final int fluidAmount) { + if (this.mFluid == null) { + return null; + } + final FluidStack moltenFluid = new FluidStack(this.mFluid, fluidAmount); + return moltenFluid; + } + + public final boolean setFluid(Fluid aFluid) { + if (this.mFluid == null) { + this.mFluid = aFluid; + return true; + } + return false; + } + + public final int calculateMeltingPoint() { + try { + AutoMap aDataSet = new AutoMap(); + for (MaterialStack m : this.vMaterialInput) { + aDataSet.put(m.getStackMaterial().getMeltingPointC()); + } + long aAverage = MathUtils.getIntAverage(aDataSet); + return MathUtils.safeInt(aAverage); + } catch (Throwable r) { + r.printStackTrace(); + return 500; + } + } + + public final int calculateBoilingPoint() { + try { + + AutoMap aDataSet = new AutoMap(); + for (MaterialStack m : this.vMaterialInput) { + aDataSet.put(m.getStackMaterial().getBoilingPointC()); + } + long aAverage = MathUtils.getIntAverage(aDataSet); + return MathUtils.safeInt(aAverage); + } catch (Throwable r) { + r.printStackTrace(); + return 2500; + } + } + + public final long calculateProtons() { + try { + + AutoMap aDataSet = new AutoMap(); + for (MaterialStack m : this.vMaterialInput) { + aDataSet.put(m.getStackMaterial().getProtons()); + } + long aAverage = MathUtils.getLongAverage(aDataSet); + return MathUtils.safeInt(aAverage); + } catch (Throwable r) { + r.printStackTrace(); + return 50; + } + } + + public final long calculateNeutrons() { + try { + + AutoMap aDataSet = new AutoMap(); + for (MaterialStack m : this.vMaterialInput) { + aDataSet.put(m.getStackMaterial().getNeutrons()); + } + long aAverage = MathUtils.getLongAverage(aDataSet); + return MathUtils.safeInt(aAverage); + } catch (Throwable r) { + r.printStackTrace(); + return 75; + } + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (!Material.class.isInstance(obj)) { + return false; + } + Material aObj = (Material) obj; + if (aObj.unlocalizedName.equals(this.unlocalizedName)) { + if (aObj.localizedName.equals(this.localizedName)) { + return true; + } + } + return false; + } + + public boolean registerComponentForMaterial(FluidStack aStack) { + return registerComponentForMaterial(this, aStack); + } + + private static boolean registerComponentForMaterial(Material componentMaterial, FluidStack aStack) { + if (componentMaterial != null && aStack != null && componentMaterial.mFluid == null) { + componentMaterial.mFluid = aStack.getFluid(); + return true; + } + return false; + } + + public boolean registerComponentForMaterial(ComponentTypes aPrefix, ItemStack aStack) { + return registerComponentForMaterial(this, aPrefix.getGtOrePrefix(), aStack); + } + + public boolean registerComponentForMaterial(OrePrefixes aPrefix, ItemStack aStack) { + return registerComponentForMaterial(this, aPrefix, aStack); + } + + public static boolean registerComponentForMaterial( + Material componentMaterial, ComponentTypes aPrefix, ItemStack aStack) { + return registerComponentForMaterial(componentMaterial, aPrefix.getGtOrePrefix(), aStack); + } + + public static boolean registerComponentForMaterial( + Material componentMaterial, OrePrefixes aPrefix, ItemStack aStack) { + if (componentMaterial == null) { + return false; + } + // Register Component + Map aMap = Material.mComponentMap.get(componentMaterial.getUnlocalizedName()); + if (aMap == null) { + aMap = new HashMap(); + } + String aKey = aPrefix.name(); + ItemStack x = aMap.get(aKey); + if (x == null) { + aMap.put(aKey, aStack); + Logger.MATERIALS("Registering a material component. Item: [" + componentMaterial.getUnlocalizedName() + + "] Map: [" + aKey + "]"); + Material.mComponentMap.put(componentMaterial.getUnlocalizedName(), aMap); + return true; + } else { + // Bad + Logger.MATERIALS("Tried to double register a material component. "); + return false; + } + } + + public Materials tryFindGregtechMaterialEquivalent() { + return tryFindGregtechMaterialEquivalent(this); + } + + public static Materials tryFindGregtechMaterialEquivalent(Material aMaterial) { + String aMaterialName = aMaterial.getLocalizedName(); + Materials aGregtechMaterial = Materials.get(aMaterialName); + if (aGregtechMaterial == null || MaterialUtils.isNullGregtechMaterial(aGregtechMaterial)) { + aMaterialName = aMaterialName.replace(" ", "_"); + aGregtechMaterial = Materials.get(aMaterialName); + if (aGregtechMaterial == null || MaterialUtils.isNullGregtechMaterial(aGregtechMaterial)) { + aMaterialName = aMaterialName.replace(" ", ""); + aGregtechMaterial = Materials.get(aMaterialName); + if (aGregtechMaterial == null || MaterialUtils.isNullGregtechMaterial(aGregtechMaterial)) { + return null; + } else { + return aGregtechMaterial; + } + } else { + return aGregtechMaterial; + } + } else { + return aGregtechMaterial; + } + } + + public void setWerkstoffID(short werkstoffID) { + this.werkstoffID = werkstoffID; + } +} diff --git a/src/main/java/gtPlusPlus/core/material/MaterialGenerator.java b/src/main/java/gtPlusPlus/core/material/MaterialGenerator.java index aac3bc3e92..11a401f55a 100644 --- a/src/main/java/gtPlusPlus/core/material/MaterialGenerator.java +++ b/src/main/java/gtPlusPlus/core/material/MaterialGenerator.java @@ -1,10 +1,5 @@ package gtPlusPlus.core.material; -import java.util.Set; - -import gregtech.api.enums.GT_Values; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.util.GT_Utility; import gtPlusPlus.api.interfaces.RunnableWithInfo; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; @@ -54,6 +49,7 @@ import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Plasma; import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Plates; import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Recycling; import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_ShapedCrafting; +import java.util.Set; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -61,384 +57,385 @@ import net.minecraftforge.fluids.FluidStack; public class MaterialGenerator { - public static final AutoMap>> mRecipeMapsToGenerate = new AutoMap>>(); - - @SuppressWarnings("unused") - private static volatile Item temp; - @SuppressWarnings("unused") - private static volatile Block tempBlock; - - - public static boolean addFluidCannerRecipe(ItemStack aEmpty, ItemStack aFullContainer, FluidStack aFluidIn, FluidStack rFluidOut) { - return addFluidCannerRecipe(aEmpty, aFullContainer, aFluidIn, rFluidOut, null, null); - } - /** - * Called Reflectively from CORE.RA.addFluidCannerRecipe - * @return - */ - public static boolean addFluidCannerRecipe(ItemStack aEmpty, ItemStack aFullContainer, FluidStack aFluidIn, FluidStack rFluidOut, Integer aTime, Integer aEu) { - /*GT_Recipe r = new Recipe_GT( - true, - new ItemStack[] {aEmpty}, - new ItemStack[] {aFullContainer}, - null, - new int[] {}, - new FluidStack[] {rFluidIn}, - new FluidStack[] {rFluidOut}, - 0, 0, 0);*/ - //new RecipeGen_FluidCanning(r, false); - RecipeGen_FluidCanning g = new RecipeGen_FluidCanning(false, aEmpty, aFullContainer, aFluidIn, null, null, 0); - if (g != null && g.valid()) { - return true; - } - return false; - } - - public static void generate(final Material matInfo){ - generate(matInfo, true); - } - - - public static void generate(final Material matInfo, final boolean generateEverything){ - generate(matInfo, generateEverything, true); - } - - public static boolean generate(final Material matInfo, final boolean generateEverything, final boolean generateBlastSmelterRecipes){ - try { - final String unlocalizedName = matInfo.getUnlocalizedName(); - final String materialName = matInfo.getLocalizedName(); - final short[] C = matInfo.getRGBA(); - final int Colour = Utils.rgbtoHexValue(C[0], C[1], C[2]); - final boolean hotIngot = matInfo.requiresBlastFurnace(); - int materialTier = matInfo.vTier; //TODO - - if ((materialTier > 10) || (materialTier <= 0)){ - materialTier = 2; - } - - int sRadiation = 0; - if (ItemUtils.isRadioactive(materialName) || (matInfo.vRadiationLevel != 0)){ - sRadiation = matInfo.vRadiationLevel; - } - - if (matInfo.getState() == MaterialState.SOLID){ - if (generateEverything == true){ - if (sRadiation >= 1){ - tempBlock = new BlockBaseModular(matInfo,BlockTypes.STANDARD); - temp = new BaseItemIngot(matInfo); - - temp = new BaseItemDust(matInfo); - temp = new BaseItemNugget(matInfo); - temp = new BaseItemPlate(matInfo); - temp = new BaseItemRod(matInfo); - temp = new BaseItemRodLong(matInfo); - } - - else { - tempBlock = new BlockBaseModular(matInfo,BlockTypes.STANDARD); - tempBlock = new BlockBaseModular(matInfo,BlockTypes.FRAME); - temp = new BaseItemIngot(matInfo); - if (hotIngot){ - temp = new BaseItemIngotHot(matInfo); - } - temp = new BaseItemDust(matInfo); - temp = new BaseItemNugget(matInfo); - temp = new BaseItemPlate(matInfo); - temp = new BaseItemPlateDouble(matInfo); - temp = new BaseItemBolt(matInfo); - temp = new BaseItemRod(matInfo); - temp = new BaseItemRodLong(matInfo); - temp = new BaseItemRing(matInfo); - temp = new BaseItemScrew(matInfo); - temp = new BaseItemRotor(matInfo); - temp = new BaseItemGear(matInfo); - } - } else { - tempBlock = new BlockBaseModular(matInfo,BlockTypes.STANDARD); - - temp = new BaseItemIngot(matInfo); - temp = new BaseItemDust(matInfo); - temp = new BaseItemNugget(matInfo); - temp = new BaseItemPlate(matInfo); - temp = new BaseItemPlateDouble(matInfo); - } - } - else if (matInfo.getState() == MaterialState.LIQUID){ - if (generateEverything == true){ - tempBlock = new BlockBaseModular(matInfo,BlockTypes.STANDARD); - } - temp = new BaseItemIngot(matInfo); - temp = new BaseItemDust(matInfo); - temp = new BaseItemNugget(matInfo); - temp = new BaseItemPlate(matInfo); - temp = new BaseItemPlateDouble(matInfo); - } - else if (matInfo.getState() == MaterialState.GAS){ - temp = new BaseItemDust(matInfo); - FluidUtils.generateGas(unlocalizedName, materialName, matInfo.getMeltingPointK(), C, true); - } - else if (matInfo.getState() == MaterialState.PURE_GAS){ - FluidUtils.generateGas(unlocalizedName, materialName, matInfo.getMeltingPointK(), C, true); - return true; - } - else if (matInfo.getState() == MaterialState.PURE_LIQUID){ - FluidUtils.generateFluidNoPrefix(unlocalizedName, materialName, matInfo.getMeltingPointK(), C); - return true; - } - else if (matInfo.getState() == MaterialState.ORE){ - - } - - //Add A jillion Recipes - old code - new RecipeGen_AlloySmelter(matInfo); - new RecipeGen_Assembler(matInfo); - if (generateBlastSmelterRecipes){ - new RecipeGen_BlastSmelter(matInfo); - } - new RecipeGen_MetalRecipe(matInfo); - new RecipeGen_Extruder(matInfo); - new RecipeGen_Fluids(matInfo); - new RecipeGen_Plates(matInfo); - new RecipeGen_ShapedCrafting(matInfo); - new RecipeGen_MaterialProcessing(matInfo); - - new RecipeGen_DustGeneration(matInfo); - new RecipeGen_Recycling(matInfo); - new RecipeGen_Plasma(matInfo); - - return true; - - } catch (final Throwable t) - - { - Logger.MATERIALS(""+matInfo.getLocalizedName()+" failed to generate."); - return false; - } - } - - public static void generateDusts(final Material matInfo){ - final String unlocalizedName = matInfo.getUnlocalizedName(); - final String materialName = matInfo.getLocalizedName(); - final short[] C = matInfo.getRGBA(); - final int Colour = Utils.rgbtoHexValue(C[0], C[1], C[2]); - int materialTier = matInfo.vTier; //TODO - - if ((materialTier > 10) || (materialTier <= 0)){ - materialTier = 2; - } - - int sRadiation = 0; - if (ItemUtils.isRadioactive(materialName) || (matInfo.vRadiationLevel != 0)){ - sRadiation = matInfo.vRadiationLevel; - } - - if (matInfo.getState() == MaterialState.SOLID){ - temp = new BaseItemDust(matInfo); - } - - //Add A jillion Recipes - old code - try { - RecipeGen_DustGeneration.addMixerRecipe_Standalone(matInfo); - new RecipeGen_Fluids(matInfo); - new RecipeGen_MaterialProcessing(matInfo); - } - catch (Throwable t) { - Logger.MATERIALS("Failed to generate some recipes for "+materialName); - Logger.ERROR("Failed to generate some recipes for "+materialName); - t.printStackTrace(); - } - //RecipeGen_Recycling.generateRecipes(matInfo); - } - - public static void generateNuclearMaterial(final Material matInfo){ - generateNuclearMaterial(matInfo, true); - } - - - public static void generateNuclearDusts(final Material matInfo){ - generateNuclearDusts(matInfo, true); - } - - public static void generateNuclearDusts(final Material matInfo, boolean generateDehydratorRecipe){ - generateNuclearMaterial(matInfo, false, true, false, false, true); - if (generateDehydratorRecipe && matInfo.getFluid() != null && matInfo.getDust(0) != null) { - CORE.RA.addDehydratorRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(20) - }, - matInfo.getFluidStack(144), - null, - new ItemStack[] { - matInfo.getDust(1), - }, - new int[] { 10000 }, - 10*(matInfo.vVoltageMultiplier/5), // Time in ticks - matInfo.vVoltageMultiplier); // EU - } - else { - Logger.INFO("Nuclear Dehydrator: Did not generate recipe for "+matInfo.getLocalizedName()+" | Null Fluid? "+(matInfo.getFluid() == null)+" | Null Dust? "+(matInfo.getDust(0) == null)); - } - } - - public static void generateNuclearMaterial(final Material matInfo, final boolean generatePlates){ - generateNuclearMaterial(matInfo, true, true, true, generatePlates, true); - } - - public static void generateNuclearMaterial(final Material matInfo, final boolean generateBlock, - final boolean generateDusts, final boolean generateIngot, final boolean generatePlates, final boolean disableOptionalRecipes){ - try { - - if (generateBlock) { - tempBlock = new BlockBaseModular(matInfo,BlockTypes.STANDARD); - } - if (generateDusts) { - temp = new BaseItemDust(matInfo); - } - if (generateIngot) { - temp = new BaseItemIngot(matInfo); - temp = new BaseItemNugget(matInfo); - } - - if (generatePlates) { - temp = new BaseItemPlate(matInfo); - temp = new BaseItemPlateDouble(matInfo); - new RecipeGen_Plates(matInfo); - new RecipeGen_Extruder(matInfo); - new RecipeGen_Assembler(matInfo); - } - - if (!disableOptionalRecipes) { - new RecipeGen_ShapedCrafting(matInfo); - new RecipeGen_Fluids(matInfo); - new RecipeGen_MaterialProcessing(matInfo); - new RecipeGen_Recycling(matInfo); - } - - new RecipeGen_MetalRecipe(matInfo); - new RecipeGen_DustGeneration(matInfo, disableOptionalRecipes); - new RecipeGen_Plasma(matInfo); - - } catch (final Throwable t){ - Logger.MATERIALS(""+matInfo.getLocalizedName()+" failed to generate."); - } - } - - - public static void generateOreMaterial(final Material matInfo){ - generateOreMaterial(matInfo, true, true, true, matInfo.getRGBA()); - } - - @SuppressWarnings("unused") - public static void generateOreMaterial(final Material matInfo, boolean generateOre, boolean generateDust, boolean generateSmallTinyDusts, short[] customRGB){ - try { - - if (matInfo == null){ - Logger.DEBUG_MATERIALS("Invalid Material while constructing null material."); - return; - } - - final String unlocalizedName = matInfo.getUnlocalizedName(); - final String materialName = matInfo.getLocalizedName(); - final short[] C = customRGB; - final Integer Colour = Utils.rgbtoHexValue(C[0], C[1], C[2]); - - - if (Colour == null){ - Logger.DEBUG_MATERIALS("Invalid Material while constructing "+materialName+"."); - return; - } - - int sRadiation = 0; - if (matInfo.vRadiationLevel > 0){ - sRadiation = matInfo.vRadiationLevel; - } - - if (generateOre) { - tempBlock = new BlockBaseOre(matInfo, BlockTypes.ORE, Colour.intValue()); - } - - DustState aState = new DustState(generateDust, generateSmallTinyDusts, generateSmallTinyDusts); - - if (!aState.generatesDust()) { - if (aState.generatesSmallDust()) { - temp = new BaseItemComponent(matInfo, ComponentTypes.DUSTSMALL); - } - if (aState.generatesTinyDust()) { - temp = new BaseItemComponent(matInfo, ComponentTypes.DUSTTINY); - } - } - else { - temp = new BaseItemDust(aState, matInfo); - } - - temp = new BaseItemCrushedOre(matInfo); - temp = new BaseItemCentrifugedCrushedOre(matInfo); - temp = new BaseItemPurifiedCrushedOre(matInfo); - temp = new BaseItemImpureDust(matInfo); - temp = new BaseItemPurifiedDust(matInfo); - - Logger.MATERIALS("Generated all ore components for "+matInfo.getLocalizedName()+", now generating processing recipes."); - - if (matInfo == FLUORIDES.FLUORITE){ - new RecipeGen_Fluorite(matInfo); - } - else { - new RecipeGen_Ore(matInfo); - } - - } catch (final Throwable t){ - Logger.MATERIALS("[Error] "+(matInfo != null ? matInfo.getLocalizedName() : "Null Material")+" failed to generate."); - t.printStackTrace(); - } - } - - public static boolean generateOreMaterialWithAllExcessComponents(final Material matInfo){ - try { - if (matInfo == null){ - Logger.DEBUG_MATERIALS("Invalid Material while constructing null material."); - return false; - } - final short[] C = matInfo.getRGBA(); - final Integer Colour = Utils.rgbtoHexValue(C[0], C[1], C[2]); - - tempBlock = new BlockBaseOre(matInfo, BlockTypes.ORE, Colour.intValue()); - tempBlock = new BlockBaseModular(matInfo,BlockTypes.STANDARD); - temp = new BaseItemIngot(matInfo); - temp = new BaseItemDust(matInfo); - temp = new BaseItemNugget(matInfo); - temp = new BaseItemPlate(matInfo); - temp = new BaseItemPlateDouble(matInfo); - - - temp = new BaseItemCrushedOre(matInfo); - temp = new BaseItemCentrifugedCrushedOre(matInfo); - temp = new BaseItemPurifiedCrushedOre(matInfo); - temp = new BaseItemImpureDust(matInfo); - temp = new BaseItemPurifiedDust(matInfo); - - Logger.MATERIALS("Generated all ore & base components for "+matInfo.getLocalizedName()+", now generating processing recipes."); - - new RecipeGen_Ore(matInfo, true); - new RecipeGen_AlloySmelter(matInfo); - new RecipeGen_Assembler(matInfo); - new RecipeGen_BlastSmelter(matInfo); - new RecipeGen_MetalRecipe(matInfo); - new RecipeGen_Extruder(matInfo); - new RecipeGen_Fluids(matInfo); - new RecipeGen_Plates(matInfo); - new RecipeGen_ShapedCrafting(matInfo); - new RecipeGen_MaterialProcessing(matInfo); - new RecipeGen_DustGeneration(matInfo); - new RecipeGen_Recycling(matInfo); - return true; - } - catch (final Throwable t){ - Logger.MATERIALS(""+matInfo.getLocalizedName()+" failed to generate."); - t.printStackTrace(); - return false; - } - - } - - + public static final AutoMap>> mRecipeMapsToGenerate = + new AutoMap>>(); + + @SuppressWarnings("unused") + private static volatile Item temp; + + @SuppressWarnings("unused") + private static volatile Block tempBlock; + + public static boolean addFluidCannerRecipe( + ItemStack aEmpty, ItemStack aFullContainer, FluidStack aFluidIn, FluidStack rFluidOut) { + return addFluidCannerRecipe(aEmpty, aFullContainer, aFluidIn, rFluidOut, null, null); + } + /** + * Called Reflectively from CORE.RA.addFluidCannerRecipe + * @return + */ + public static boolean addFluidCannerRecipe( + ItemStack aEmpty, + ItemStack aFullContainer, + FluidStack aFluidIn, + FluidStack rFluidOut, + Integer aTime, + Integer aEu) { + /*GT_Recipe r = new Recipe_GT( + true, + new ItemStack[] {aEmpty}, + new ItemStack[] {aFullContainer}, + null, + new int[] {}, + new FluidStack[] {rFluidIn}, + new FluidStack[] {rFluidOut}, + 0, 0, 0);*/ + // new RecipeGen_FluidCanning(r, false); + RecipeGen_FluidCanning g = new RecipeGen_FluidCanning(false, aEmpty, aFullContainer, aFluidIn, null, null, 0); + if (g != null && g.valid()) { + return true; + } + return false; + } + + public static void generate(final Material matInfo) { + generate(matInfo, true); + } + + public static void generate(final Material matInfo, final boolean generateEverything) { + generate(matInfo, generateEverything, true); + } + + public static boolean generate( + final Material matInfo, final boolean generateEverything, final boolean generateBlastSmelterRecipes) { + try { + final String unlocalizedName = matInfo.getUnlocalizedName(); + final String materialName = matInfo.getLocalizedName(); + final short[] C = matInfo.getRGBA(); + final int Colour = Utils.rgbtoHexValue(C[0], C[1], C[2]); + final boolean hotIngot = matInfo.requiresBlastFurnace(); + int materialTier = matInfo.vTier; // TODO + + if ((materialTier > 10) || (materialTier <= 0)) { + materialTier = 2; + } + + int sRadiation = 0; + if (ItemUtils.isRadioactive(materialName) || (matInfo.vRadiationLevel != 0)) { + sRadiation = matInfo.vRadiationLevel; + } + + if (matInfo.getState() == MaterialState.SOLID) { + if (generateEverything == true) { + if (sRadiation >= 1) { + tempBlock = new BlockBaseModular(matInfo, BlockTypes.STANDARD); + temp = new BaseItemIngot(matInfo); + + temp = new BaseItemDust(matInfo); + temp = new BaseItemNugget(matInfo); + temp = new BaseItemPlate(matInfo); + temp = new BaseItemRod(matInfo); + temp = new BaseItemRodLong(matInfo); + } else { + tempBlock = new BlockBaseModular(matInfo, BlockTypes.STANDARD); + tempBlock = new BlockBaseModular(matInfo, BlockTypes.FRAME); + temp = new BaseItemIngot(matInfo); + if (hotIngot) { + temp = new BaseItemIngotHot(matInfo); + } + temp = new BaseItemDust(matInfo); + temp = new BaseItemNugget(matInfo); + temp = new BaseItemPlate(matInfo); + temp = new BaseItemPlateDouble(matInfo); + temp = new BaseItemBolt(matInfo); + temp = new BaseItemRod(matInfo); + temp = new BaseItemRodLong(matInfo); + temp = new BaseItemRing(matInfo); + temp = new BaseItemScrew(matInfo); + temp = new BaseItemRotor(matInfo); + temp = new BaseItemGear(matInfo); + } + } else { + tempBlock = new BlockBaseModular(matInfo, BlockTypes.STANDARD); + + temp = new BaseItemIngot(matInfo); + temp = new BaseItemDust(matInfo); + temp = new BaseItemNugget(matInfo); + temp = new BaseItemPlate(matInfo); + temp = new BaseItemPlateDouble(matInfo); + } + } else if (matInfo.getState() == MaterialState.LIQUID) { + if (generateEverything == true) { + tempBlock = new BlockBaseModular(matInfo, BlockTypes.STANDARD); + } + temp = new BaseItemIngot(matInfo); + temp = new BaseItemDust(matInfo); + temp = new BaseItemNugget(matInfo); + temp = new BaseItemPlate(matInfo); + temp = new BaseItemPlateDouble(matInfo); + } else if (matInfo.getState() == MaterialState.GAS) { + temp = new BaseItemDust(matInfo); + FluidUtils.generateGas(unlocalizedName, materialName, matInfo.getMeltingPointK(), C, true); + } else if (matInfo.getState() == MaterialState.PURE_GAS) { + FluidUtils.generateGas(unlocalizedName, materialName, matInfo.getMeltingPointK(), C, true); + return true; + } else if (matInfo.getState() == MaterialState.PURE_LIQUID) { + FluidUtils.generateFluidNoPrefix(unlocalizedName, materialName, matInfo.getMeltingPointK(), C); + return true; + } else if (matInfo.getState() == MaterialState.ORE) { + + } + + // Add A jillion Recipes - old code + new RecipeGen_AlloySmelter(matInfo); + new RecipeGen_Assembler(matInfo); + if (generateBlastSmelterRecipes) { + new RecipeGen_BlastSmelter(matInfo); + } + new RecipeGen_MetalRecipe(matInfo); + new RecipeGen_Extruder(matInfo); + new RecipeGen_Fluids(matInfo); + new RecipeGen_Plates(matInfo); + new RecipeGen_ShapedCrafting(matInfo); + new RecipeGen_MaterialProcessing(matInfo); + + new RecipeGen_DustGeneration(matInfo); + new RecipeGen_Recycling(matInfo); + new RecipeGen_Plasma(matInfo); + + return true; + + } catch (final Throwable t) { + + Logger.MATERIALS("" + matInfo.getLocalizedName() + " failed to generate."); + return false; + } + } + + public static void generateDusts(final Material matInfo) { + final String unlocalizedName = matInfo.getUnlocalizedName(); + final String materialName = matInfo.getLocalizedName(); + final short[] C = matInfo.getRGBA(); + final int Colour = Utils.rgbtoHexValue(C[0], C[1], C[2]); + int materialTier = matInfo.vTier; // TODO + + if ((materialTier > 10) || (materialTier <= 0)) { + materialTier = 2; + } + + int sRadiation = 0; + if (ItemUtils.isRadioactive(materialName) || (matInfo.vRadiationLevel != 0)) { + sRadiation = matInfo.vRadiationLevel; + } + + if (matInfo.getState() == MaterialState.SOLID) { + temp = new BaseItemDust(matInfo); + } + + // Add A jillion Recipes - old code + try { + RecipeGen_DustGeneration.addMixerRecipe_Standalone(matInfo); + new RecipeGen_Fluids(matInfo); + new RecipeGen_MaterialProcessing(matInfo); + } catch (Throwable t) { + Logger.MATERIALS("Failed to generate some recipes for " + materialName); + Logger.ERROR("Failed to generate some recipes for " + materialName); + t.printStackTrace(); + } + // RecipeGen_Recycling.generateRecipes(matInfo); + } + + public static void generateNuclearMaterial(final Material matInfo) { + generateNuclearMaterial(matInfo, true); + } + + public static void generateNuclearDusts(final Material matInfo) { + generateNuclearDusts(matInfo, true); + } + + public static void generateNuclearDusts(final Material matInfo, boolean generateDehydratorRecipe) { + generateNuclearMaterial(matInfo, false, true, false, false, true); + if (generateDehydratorRecipe && matInfo.getFluid() != null && matInfo.getDust(0) != null) { + CORE.RA.addDehydratorRecipe( + new ItemStack[] {CI.getNumberedAdvancedCircuit(20)}, + matInfo.getFluidStack(144), + null, + new ItemStack[] { + matInfo.getDust(1), + }, + new int[] {10000}, + 10 * (matInfo.vVoltageMultiplier / 5), // Time in ticks + matInfo.vVoltageMultiplier); // EU + } else { + Logger.INFO( + "Nuclear Dehydrator: Did not generate recipe for " + matInfo.getLocalizedName() + " | Null Fluid? " + + (matInfo.getFluid() == null) + " | Null Dust? " + (matInfo.getDust(0) == null)); + } + } + + public static void generateNuclearMaterial(final Material matInfo, final boolean generatePlates) { + generateNuclearMaterial(matInfo, true, true, true, generatePlates, true); + } + + public static void generateNuclearMaterial( + final Material matInfo, + final boolean generateBlock, + final boolean generateDusts, + final boolean generateIngot, + final boolean generatePlates, + final boolean disableOptionalRecipes) { + try { + + if (generateBlock) { + tempBlock = new BlockBaseModular(matInfo, BlockTypes.STANDARD); + } + if (generateDusts) { + temp = new BaseItemDust(matInfo); + } + if (generateIngot) { + temp = new BaseItemIngot(matInfo); + temp = new BaseItemNugget(matInfo); + } + + if (generatePlates) { + temp = new BaseItemPlate(matInfo); + temp = new BaseItemPlateDouble(matInfo); + new RecipeGen_Plates(matInfo); + new RecipeGen_Extruder(matInfo); + new RecipeGen_Assembler(matInfo); + } + + if (!disableOptionalRecipes) { + new RecipeGen_ShapedCrafting(matInfo); + new RecipeGen_Fluids(matInfo); + new RecipeGen_MaterialProcessing(matInfo); + new RecipeGen_Recycling(matInfo); + } + + new RecipeGen_MetalRecipe(matInfo); + new RecipeGen_DustGeneration(matInfo, disableOptionalRecipes); + new RecipeGen_Plasma(matInfo); + + } catch (final Throwable t) { + Logger.MATERIALS("" + matInfo.getLocalizedName() + " failed to generate."); + } + } + + public static void generateOreMaterial(final Material matInfo) { + generateOreMaterial(matInfo, true, true, true, matInfo.getRGBA()); + } + + @SuppressWarnings("unused") + public static void generateOreMaterial( + final Material matInfo, + boolean generateOre, + boolean generateDust, + boolean generateSmallTinyDusts, + short[] customRGB) { + try { + + if (matInfo == null) { + Logger.DEBUG_MATERIALS("Invalid Material while constructing null material."); + return; + } + + final String unlocalizedName = matInfo.getUnlocalizedName(); + final String materialName = matInfo.getLocalizedName(); + final short[] C = customRGB; + final Integer Colour = Utils.rgbtoHexValue(C[0], C[1], C[2]); + + if (Colour == null) { + Logger.DEBUG_MATERIALS("Invalid Material while constructing " + materialName + "."); + return; + } + + int sRadiation = 0; + if (matInfo.vRadiationLevel > 0) { + sRadiation = matInfo.vRadiationLevel; + } + + if (generateOre) { + tempBlock = new BlockBaseOre(matInfo, BlockTypes.ORE, Colour.intValue()); + } + + DustState aState = new DustState(generateDust, generateSmallTinyDusts, generateSmallTinyDusts); + + if (!aState.generatesDust()) { + if (aState.generatesSmallDust()) { + temp = new BaseItemComponent(matInfo, ComponentTypes.DUSTSMALL); + } + if (aState.generatesTinyDust()) { + temp = new BaseItemComponent(matInfo, ComponentTypes.DUSTTINY); + } + } else { + temp = new BaseItemDust(aState, matInfo); + } + + temp = new BaseItemCrushedOre(matInfo); + temp = new BaseItemCentrifugedCrushedOre(matInfo); + temp = new BaseItemPurifiedCrushedOre(matInfo); + temp = new BaseItemImpureDust(matInfo); + temp = new BaseItemPurifiedDust(matInfo); + + Logger.MATERIALS("Generated all ore components for " + matInfo.getLocalizedName() + + ", now generating processing recipes."); + + if (matInfo == FLUORIDES.FLUORITE) { + new RecipeGen_Fluorite(matInfo); + } else { + new RecipeGen_Ore(matInfo); + } + + } catch (final Throwable t) { + Logger.MATERIALS("[Error] " + (matInfo != null ? matInfo.getLocalizedName() : "Null Material") + + " failed to generate."); + t.printStackTrace(); + } + } + + public static boolean generateOreMaterialWithAllExcessComponents(final Material matInfo) { + try { + if (matInfo == null) { + Logger.DEBUG_MATERIALS("Invalid Material while constructing null material."); + return false; + } + final short[] C = matInfo.getRGBA(); + final Integer Colour = Utils.rgbtoHexValue(C[0], C[1], C[2]); + + tempBlock = new BlockBaseOre(matInfo, BlockTypes.ORE, Colour.intValue()); + tempBlock = new BlockBaseModular(matInfo, BlockTypes.STANDARD); + temp = new BaseItemIngot(matInfo); + temp = new BaseItemDust(matInfo); + temp = new BaseItemNugget(matInfo); + temp = new BaseItemPlate(matInfo); + temp = new BaseItemPlateDouble(matInfo); + + temp = new BaseItemCrushedOre(matInfo); + temp = new BaseItemCentrifugedCrushedOre(matInfo); + temp = new BaseItemPurifiedCrushedOre(matInfo); + temp = new BaseItemImpureDust(matInfo); + temp = new BaseItemPurifiedDust(matInfo); + + Logger.MATERIALS("Generated all ore & base components for " + matInfo.getLocalizedName() + + ", now generating processing recipes."); + + new RecipeGen_Ore(matInfo, true); + new RecipeGen_AlloySmelter(matInfo); + new RecipeGen_Assembler(matInfo); + new RecipeGen_BlastSmelter(matInfo); + new RecipeGen_MetalRecipe(matInfo); + new RecipeGen_Extruder(matInfo); + new RecipeGen_Fluids(matInfo); + new RecipeGen_Plates(matInfo); + new RecipeGen_ShapedCrafting(matInfo); + new RecipeGen_MaterialProcessing(matInfo); + new RecipeGen_DustGeneration(matInfo); + new RecipeGen_Recycling(matInfo); + return true; + } catch (final Throwable t) { + Logger.MATERIALS("" + matInfo.getLocalizedName() + " failed to generate."); + t.printStackTrace(); + return false; + } + } } diff --git a/src/main/java/gtPlusPlus/core/material/MaterialStack.java b/src/main/java/gtPlusPlus/core/material/MaterialStack.java index 145b217d6e..0e05b9b3b3 100644 --- a/src/main/java/gtPlusPlus/core/material/MaterialStack.java +++ b/src/main/java/gtPlusPlus/core/material/MaterialStack.java @@ -1,121 +1,113 @@ package gtPlusPlus.core.material; -import java.math.BigDecimal; -import java.math.RoundingMode; - import gregtech.api.enums.OrePrefixes; -import gtPlusPlus.xmod.bartworks.BW_Utils; -import net.minecraft.item.ItemStack; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.bartworks.BW_Utils; +import java.math.BigDecimal; +import java.math.RoundingMode; +import net.minecraft.item.ItemStack; public class MaterialStack { - private final transient int[] vAmount; - private final Material stackMaterial; - private final double vPercentageToUse; - - public MaterialStack(final Material inputs, final double partOutOf100){ - this.stackMaterial = inputs; - //Logger.INFO("Tried getting MaterialStack for "+inputs.getLocalizedName()); - this.vPercentageToUse = partOutOf100; - this.vAmount = this.math(partOutOf100); - } - - private int[] math(final double val){ - double i; - //Cast to a BigDecimal to round it. - final BigDecimal bd = new BigDecimal(val).setScale(2, RoundingMode.HALF_EVEN); - i = bd.doubleValue(); - //Split the string into xx.xx - final String[] arr=String.valueOf(i).split("\\."); - final int[] intArr=new int[2]; - intArr[0]=Integer.parseInt(arr[0]); - intArr[1]=Integer.parseInt(arr[1]); - return intArr; - } - - public ItemStack getValidStack(){ - if (this.stackMaterial.getDust(1) == null){ - //if (this.stackMaterial.getCell(1) == null){ - return null; - //} - //return this.stackMaterial.getCell(this.vAmount[0]); - } - return this.stackMaterial.getDust(this.vAmount[0]); - } - - public ItemStack getDustStack(){ - return this.stackMaterial.getDust(this.vAmount[0]); - } - - public ItemStack getDustStack(final int amount){ - return this.stackMaterial.getDust(amount); - } - - public ItemStack getUnificatedDustStack(final int amount) { - if (this.stackMaterial.werkstoffID != 0) { - ItemStack stack = BW_Utils.getCorrespondingItemStack(OrePrefixes.dust, this.stackMaterial.werkstoffID, amount); - if (stack != null) { - return stack; - } - } - return getDustStack(amount); - } - - public Material getStackMaterial(){ - if (this.stackMaterial == null){ - Logger.MATERIALS("Tried getStackMaterial, got an invalid material."); - Logger.MATERIALS(ReflectionUtils.getMethodName(0)); - Logger.MATERIALS(ReflectionUtils.getMethodName(1)); - Logger.MATERIALS(ReflectionUtils.getMethodName(2)); - Logger.MATERIALS(ReflectionUtils.getMethodName(3)); - return null; - } - return this.stackMaterial; - } - - public double getvPercentageToUse(){ - return this.vPercentageToUse; - } - - public long[] getSmallestStackSizes(){ - return this.stackMaterial.getSmallestRatio(this.stackMaterial.getComposites()); - } - - public int getPartsPerOneHundred(){ - if (this.vAmount != null){ - if ((this.vAmount[0] >= 1) && (this.vAmount[0] <= 100)){ - return this.vAmount[0]; - } - } - return 100; - } - public ItemStack getLeftOverStacksFromDecimalValue(){ - final int temp = this.vAmount[1]; - int getCount; - if ((temp >= 25) && (temp <=99)){ - getCount = temp/25; - return this.stackMaterial.getSmallDust(getCount); - } - else if ((temp >= 11) && (temp <= 24)){ - getCount = temp/11; - return this.stackMaterial.getTinyDust(getCount); - } - else { - return null; - } - } - - public ItemStack[] getValidItemStacks(){ - return ItemUtils.validItemsForOreDict(this.stackMaterial.getUnlocalizedName()); - } - - - - - - + private final transient int[] vAmount; + private final Material stackMaterial; + private final double vPercentageToUse; + + public MaterialStack(final Material inputs, final double partOutOf100) { + this.stackMaterial = inputs; + // Logger.INFO("Tried getting MaterialStack for "+inputs.getLocalizedName()); + this.vPercentageToUse = partOutOf100; + this.vAmount = this.math(partOutOf100); + } + + private int[] math(final double val) { + double i; + // Cast to a BigDecimal to round it. + final BigDecimal bd = new BigDecimal(val).setScale(2, RoundingMode.HALF_EVEN); + i = bd.doubleValue(); + // Split the string into xx.xx + final String[] arr = String.valueOf(i).split("\\."); + final int[] intArr = new int[2]; + intArr[0] = Integer.parseInt(arr[0]); + intArr[1] = Integer.parseInt(arr[1]); + return intArr; + } + + public ItemStack getValidStack() { + if (this.stackMaterial.getDust(1) == null) { + // if (this.stackMaterial.getCell(1) == null){ + return null; + // } + // return this.stackMaterial.getCell(this.vAmount[0]); + } + return this.stackMaterial.getDust(this.vAmount[0]); + } + + public ItemStack getDustStack() { + return this.stackMaterial.getDust(this.vAmount[0]); + } + + public ItemStack getDustStack(final int amount) { + return this.stackMaterial.getDust(amount); + } + + public ItemStack getUnificatedDustStack(final int amount) { + if (this.stackMaterial.werkstoffID != 0) { + ItemStack stack = + BW_Utils.getCorrespondingItemStack(OrePrefixes.dust, this.stackMaterial.werkstoffID, amount); + if (stack != null) { + return stack; + } + } + return getDustStack(amount); + } + + public Material getStackMaterial() { + if (this.stackMaterial == null) { + Logger.MATERIALS("Tried getStackMaterial, got an invalid material."); + Logger.MATERIALS(ReflectionUtils.getMethodName(0)); + Logger.MATERIALS(ReflectionUtils.getMethodName(1)); + Logger.MATERIALS(ReflectionUtils.getMethodName(2)); + Logger.MATERIALS(ReflectionUtils.getMethodName(3)); + return null; + } + return this.stackMaterial; + } + + public double getvPercentageToUse() { + return this.vPercentageToUse; + } + + public long[] getSmallestStackSizes() { + return this.stackMaterial.getSmallestRatio(this.stackMaterial.getComposites()); + } + + public int getPartsPerOneHundred() { + if (this.vAmount != null) { + if ((this.vAmount[0] >= 1) && (this.vAmount[0] <= 100)) { + return this.vAmount[0]; + } + } + return 100; + } + + public ItemStack getLeftOverStacksFromDecimalValue() { + final int temp = this.vAmount[1]; + int getCount; + if ((temp >= 25) && (temp <= 99)) { + getCount = temp / 25; + return this.stackMaterial.getSmallDust(getCount); + } else if ((temp >= 11) && (temp <= 24)) { + getCount = temp / 11; + return this.stackMaterial.getTinyDust(getCount); + } else { + return null; + } + } + + public ItemStack[] getValidItemStacks() { + return ItemUtils.validItemsForOreDict(this.stackMaterial.getUnlocalizedName()); + } } diff --git a/src/main/java/gtPlusPlus/core/material/NONMATERIAL.java b/src/main/java/gtPlusPlus/core/material/NONMATERIAL.java index 7ab72d50bc..180bb15888 100644 --- a/src/main/java/gtPlusPlus/core/material/NONMATERIAL.java +++ b/src/main/java/gtPlusPlus/core/material/NONMATERIAL.java @@ -5,40 +5,38 @@ import gregtech.api.enums.TextureSet; import gtPlusPlus.core.util.minecraft.MaterialUtils; public class NONMATERIAL { - - //Soul Sand - public static final Material SOULSAND = MaterialUtils.generateMaterialFromGtENUM(Materials.SoulSand); - - //Redstone - public static final Material REDSTONE = MaterialUtils.generateMaterialFromGtENUM(Materials.Redstone); - - //Glowstone Dust - public static final Material GLOWSTONE = MaterialUtils.generateMaterialFromGtENUM(Materials.Glowstone); - - //Enderpearl - public static final Material ENDERPEARL = MaterialUtils.generateMaterialFromGtENUM(Materials.EnderPearl); - - //Raw Flesh - public static final Material MEAT = MaterialUtils.generateMaterialFromGtENUM(Materials.MeatRaw); - - //Clay - public static final Material CLAY = MaterialUtils.generateMaterialFromGtENUM(Materials.Clay); - - //Wrought Iron - public static final Material WROUGHT_IRON = MaterialUtils.generateMaterialFromGtENUM(Materials.WroughtIron); - - //PTFE - public static final Material PTFE = MaterialUtils.generateMaterialFromGtENUM(MaterialUtils.getMaterial("Polytetrafluoroethylene", "Plastic")); - - //Plastic - public static final Material PLASTIC = MaterialUtils.generateMaterialFromGtENUM(MaterialUtils.getMaterial("Plastic", "Rubber")); - - - static { - MEAT.setTextureSet(TextureSet.SET_ROUGH); - CLAY.setTextureSet(TextureSet.SET_ROUGH); - } - - - + + // Soul Sand + public static final Material SOULSAND = MaterialUtils.generateMaterialFromGtENUM(Materials.SoulSand); + + // Redstone + public static final Material REDSTONE = MaterialUtils.generateMaterialFromGtENUM(Materials.Redstone); + + // Glowstone Dust + public static final Material GLOWSTONE = MaterialUtils.generateMaterialFromGtENUM(Materials.Glowstone); + + // Enderpearl + public static final Material ENDERPEARL = MaterialUtils.generateMaterialFromGtENUM(Materials.EnderPearl); + + // Raw Flesh + public static final Material MEAT = MaterialUtils.generateMaterialFromGtENUM(Materials.MeatRaw); + + // Clay + public static final Material CLAY = MaterialUtils.generateMaterialFromGtENUM(Materials.Clay); + + // Wrought Iron + public static final Material WROUGHT_IRON = MaterialUtils.generateMaterialFromGtENUM(Materials.WroughtIron); + + // PTFE + public static final Material PTFE = + MaterialUtils.generateMaterialFromGtENUM(MaterialUtils.getMaterial("Polytetrafluoroethylene", "Plastic")); + + // Plastic + public static final Material PLASTIC = + MaterialUtils.generateMaterialFromGtENUM(MaterialUtils.getMaterial("Plastic", "Rubber")); + + static { + MEAT.setTextureSet(TextureSet.SET_ROUGH); + CLAY.setTextureSet(TextureSet.SET_ROUGH); + } } diff --git a/src/main/java/gtPlusPlus/core/material/ORES.java b/src/main/java/gtPlusPlus/core/material/ORES.java index 82757b2ee6..a5776a6d5a 100644 --- a/src/main/java/gtPlusPlus/core/material/ORES.java +++ b/src/main/java/gtPlusPlus/core/material/ORES.java @@ -6,845 +6,838 @@ import gtPlusPlus.core.material.state.MaterialState; public final class ORES { - public static final Material AGARDITE_CD = new Material( - "Agardite (Cd)", //Material Name - MaterialState.ORE, //State - TextureSet.SET_METALLIC, //Texture Set - new short[]{170, 188, 33, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{// (CdCa)Cu7(AsO2)4(O2H)5·3H2O - new MaterialStack(ELEMENT.getInstance().CADMIUM, 1), - new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), - new MaterialStack(ELEMENT.getInstance().COPPER, 7), - new MaterialStack(ELEMENT.getInstance().ARSENIC, 4), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 21), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 11) - }); - - public static final Material AGARDITE_LA = new Material( - "Agardite (La)", //Material Name - MaterialState.ORE, //State - TextureSet.SET_FINE, //Texture Set - new short[]{206, 232, 9, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{// (LaCa)Cu5(AsO6)2(OH)4·3H2O - new MaterialStack(ELEMENT.getInstance().LANTHANUM, 1), - new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), - new MaterialStack(ELEMENT.getInstance().COPPER, 5), - new MaterialStack(ELEMENT.getInstance().ARSENIC, 2), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 19), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 10) - }); - - public static final Material AGARDITE_ND = new Material( - "Agardite (Nd)", //Material Name - MaterialState.ORE, //State - TextureSet.SET_METALLIC, //Texture Set - new short[]{225, 244, 78, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{// (NdCa)Cu6(As3O3)2(O2H)6·3H2O - new MaterialStack(ELEMENT.getInstance().NEODYMIUM, 1), - new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), - new MaterialStack(ELEMENT.getInstance().COPPER, 6), - new MaterialStack(ELEMENT.getInstance().ARSENIC, 6), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 21), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 12) - }); - - public static final Material AGARDITE_Y = new Material( - "Agardite (Y)", //Material Name - MaterialState.ORE, //State - TextureSet.SET_METALLIC, //Texture Set - new short[]{210, 232, 44, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{// (YCa)Cu5(As2O4)3(OH)6·3H2O - new MaterialStack(ELEMENT.getInstance().YTTRIUM, 1), - new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), - new MaterialStack(ELEMENT.getInstance().COPPER, 5), - new MaterialStack(ELEMENT.getInstance().ARSENIC, 6), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 21), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 12) - }); - - //Alburnite - //Ag8GeTe2S4 - public static final Material ALBURNITE = new Material( - "Alburnite", //Material Name - MaterialState.ORE, //State - TextureSet.SET_METALLIC, //Texture Set - new short[]{16, 5, 105, 0}, //Material Colour - -1, - -1, - -1, - -1, - 0, //Radiation - new MaterialStack[]{// Na3AlF6 - new MaterialStack(ELEMENT.getInstance().GOLD, 8), - new MaterialStack(ELEMENT.getInstance().GERMANIUM, 1), - new MaterialStack(ELEMENT.getInstance().TELLURIUM, 2), - new MaterialStack(ELEMENT.getInstance().SULFUR, 4) - }); - - public static final Material CERITE = new Material( - "Cerite", //Material Name - MaterialState.ORE, //State - TextureSets.REFINED.get(), //Texture Set - new short[]{68, 13, 0, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{// (Ce,La,Ca)9(Mg,Fe+3)(SiO4)6(SiO3OH)(OH)3 - new MaterialStack(ELEMENT.getInstance().CERIUM, 9), - new MaterialStack(ELEMENT.getInstance().LANTHANUM, 9), - new MaterialStack(ELEMENT.getInstance().CALCIUM, 9), - new MaterialStack(ELEMENT.getInstance().MAGNESIUM, 3), - new MaterialStack(ELEMENT.getInstance().IRON, 3), - new MaterialStack(ELEMENT.getInstance().SILICON, 7), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 20), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 4) - }); - - //Comancheite - //Hg55N24(NH2,OH)4(Cl,Br)34 - public static final Material COMANCHEITE = new Material( - "Comancheite", //Material Name - MaterialState.ORE, //State - TextureSets.REFINED.get(), //Texture Set - new short[]{65, 205, 105, 0}, //Material Colour - -1, - -1, - -1, - -1, - 0, //Radiation - new MaterialStack[]{// Na3AlF6 - new MaterialStack(ELEMENT.getInstance().MERCURY, 54/4), - new MaterialStack(ELEMENT.getInstance().NITROGEN, 28/4), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 12/4), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 8/4), - new MaterialStack(ELEMENT.getInstance().CHLORINE, 34/4), - new MaterialStack(ELEMENT.getInstance().BROMINE, 34/4) - }); - - public static final Material CROCROITE = new Material( - "Crocoite", //Material Name - MaterialState.ORE, //State - TextureSet.SET_GEM_VERTICAL, //Texture Set - new short[]{255, 143, 84, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().LEAD, 2), - new MaterialStack(ELEMENT.getInstance().CHROMIUM, 2), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 3), - new MaterialStack(ELEMENT.getInstance().CAESIUM, 1), - }); - - public static final Material CRYOLITE = new Material( - "Cryolite (F)", //Material Name - MaterialState.ORE, //State - TextureSet.SET_SHINY, //Texture Set - new short[]{205, 205, 255, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{// Na3AlF6 - new MaterialStack(ELEMENT.getInstance().SODIUM, 3), - new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 1), - new MaterialStack(ELEMENT.getInstance().FLUORINE, 6) - }); - - //Demicheleite-(Br) - // BiSBr - public static final Material DEMICHELEITE_BR = new Material( - "Demicheleite (Br)", //Material Name - MaterialState.ORE, //State - TextureSet.SET_SHINY, //Texture Set - new short[]{165, 75, 75, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{// Na3AlF6 - new MaterialStack(ELEMENT.getInstance().BISMUTH, 13), - new MaterialStack(ELEMENT.getInstance().SULFUR, 11), - new MaterialStack(ELEMENT.getInstance().BROMINE, 1) - }); - - public static final Material FLORENCITE = new Material( - "Florencite", //Material Name - MaterialState.ORE, //State - TextureSet.SET_METALLIC, //Texture Set - new short[]{249, 249, 124, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{// SmAl3(PO4)2(OH)6 - new MaterialStack(ELEMENT.getInstance().SAMARIUM, 1), - new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 3), - new MaterialStack(ELEMENT.getInstance().PHOSPHORUS, 1), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 10), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 6) - }); - - public static final Material FLUORCAPHITE = new Material( - "Fluorcaphite", //Material Name - MaterialState.ORE, //State - TextureSet.SET_FINE, //Texture Set - new short[]{255, 255, 30, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{// (Ca,Sr,Ce,Na)5(PO4)3F - new MaterialStack(ELEMENT.getInstance().CALCIUM, 5), - new MaterialStack(MISC_MATERIALS.STRONTIUM_OXIDE, 5), - new MaterialStack(ELEMENT.getInstance().CERIUM, 5), - new MaterialStack(ELEMENT.getInstance().SODIUM, 5), - new MaterialStack(ELEMENT.getInstance().PHOSPHORUS, 3), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 12), - new MaterialStack(ELEMENT.getInstance().FLUORINE, 6), - }); - - //Gadolinite_Ce - public static final Material GADOLINITE_CE = new Material( - "Gadolinite (Ce)", //Material Name - MaterialState.ORE, //State - TextureSets.REFINED.get(), //Texture Set - new short[]{15, 159, 59, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().CERIUM, 4), - new MaterialStack(ELEMENT.getInstance().ERBIUM, 2), - new MaterialStack(ELEMENT.getInstance().LANTHANUM, 2), - new MaterialStack(ELEMENT.getInstance().NEODYMIUM, 2), - new MaterialStack(ELEMENT.getInstance().YTTRIUM, 2), - new MaterialStack(ELEMENT.getInstance().GADOLINIUM, 1), - new MaterialStack(ELEMENT.getInstance().BERYLLIUM, 2), - new MaterialStack(ELEMENT.getInstance().SILICON, 7), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 14), - }); - - //Gadolinite_Y - public static final Material GADOLINITE_Y = new Material( - "Gadolinite (Y)", //Material Name - MaterialState.ORE, //State - TextureSets.REFINED.get(), //Texture Set - new short[]{35, 189, 99, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().CERIUM, 2), - new MaterialStack(ELEMENT.getInstance().ERBIUM, 2), - new MaterialStack(ELEMENT.getInstance().LANTHANUM, 2), - new MaterialStack(ELEMENT.getInstance().NEODYMIUM, 2), - new MaterialStack(ELEMENT.getInstance().YTTRIUM, 4), - new MaterialStack(ELEMENT.getInstance().GADOLINIUM, 2), - new MaterialStack(ELEMENT.getInstance().BERYLLIUM, 3), - new MaterialStack(ELEMENT.getInstance().SILICON, 4), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 9), - }); - - public static final Material GEIKIELITE = new Material( - "Geikielite", //Material Name - MaterialState.ORE, //State - TextureSets.GEM_A.get(), //Texture Set - new short[]{187, 193, 204, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().MAGNESIUM, 1), - new MaterialStack(ELEMENT.getInstance().TITANIUM, 1), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 3) - }); - - public static final Material GREENOCKITE = new Material( - "Greenockite", //Material Name - MaterialState.ORE, //State - TextureSets.GEM_A.get(), //Texture Set - new short[]{110, 193, 25, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().CADMIUM, 2), - new MaterialStack(ELEMENT.getInstance().SULFUR, 2), - }); - - public static final Material HIBONITE = new Material( - "Hibonite", //Material Name - MaterialState.ORE, //State - TextureSet.SET_METALLIC, //Texture Set - new short[]{58, 31, 0, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{// ((Ca,Ce)(Al,Ti,Mg)12O19) - new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), - new MaterialStack(ELEMENT.getInstance().CERIUM, 1), - new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 12), - new MaterialStack(ELEMENT.getInstance().TITANIUM, 12), - new MaterialStack(ELEMENT.getInstance().MAGNESIUM, 12), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 19), - }); - - //Honeaite - //Au3TlTe2 - public static final Material HONEAITE = new Material( - "Honeaite", //Material Name - MaterialState.ORE, //State - TextureSet.SET_FINE, //Texture Set - new short[]{165, 165, 5, 0}, //Material Colour - -1, - -1, - -1, - -1, - 0, //Radiation - new MaterialStack[]{// Na3AlF6 - new MaterialStack(ELEMENT.getInstance().GOLD, 3), - new MaterialStack(ELEMENT.getInstance().THALLIUM, 1), - new MaterialStack(ELEMENT.getInstance().TELLURIUM, 2) - }); - - //Irarsite - //(Ir,Ru,Rh,Pt)AsS - public static final Material IRARSITE = new Material( - "Irarsite", //Material Name - MaterialState.ORE, //State - TextureSets.ENRICHED.get(), //Texture Set - new short[]{125, 105, 105, 0}, //Material Colour - -1, - -1, - -1, - -1, - 0, //Radiation - new MaterialStack[]{// Na3AlF6 - new MaterialStack(ELEMENT.getInstance().IRIDIUM, 1), - new MaterialStack(ELEMENT.getInstance().RUTHENIUM, 1), - new MaterialStack(ELEMENT.getInstance().RHODIUM, 1), - new MaterialStack(ELEMENT.getInstance().PLATINUM, 1), - new MaterialStack(ELEMENT.getInstance().ARSENIC, 1), - new MaterialStack(ELEMENT.getInstance().SULFUR, 1), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 1) - }); - - //Kashinite - //(Ir,Rh)2S3 - public static final Material KASHINITE = new Material( - "Kashinite", //Material Name - MaterialState.ORE, //State - TextureSet.SET_SHINY, //Texture Set - new short[]{75, 105, 75, 0}, //Material Colour - -1, - -1, - -1, - -1, - 0, //Radiation - new MaterialStack[]{// Na3AlF6 - new MaterialStack(ELEMENT.getInstance().IRIDIUM, 2), - new MaterialStack(ELEMENT.getInstance().RHODIUM, 2), - new MaterialStack(ELEMENT.getInstance().SULFUR, 3) - }); - - // Tl(Cl,Br) - public static final Material LAFOSSAITE = new Material( - "Lafossaite", //Material Name - MaterialState.ORE, //State - TextureSets.REFINED.get(), //Texture Set - new short[]{165, 105, 205, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{// Na3AlF6 - new MaterialStack(ELEMENT.getInstance().CHLORINE, 1), - new MaterialStack(ELEMENT.getInstance().BROMINE, 1), - new MaterialStack(ELEMENT.getInstance().THALLIUM, 1) - }); - - public static final Material LANTHANITE_CE = new Material( - "Lanthanite (Ce)", //Material Name - MaterialState.ORE, //State - TextureSet.SET_METALLIC, //Texture Set - new short[]{186, 113, 179, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{// (Ce)2(CO3)3·8(H2O) - new MaterialStack(ELEMENT.getInstance().CERIUM, 2), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 3), - new MaterialStack(ELEMENT.getInstance().CALCIUM, 3), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 2), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 1), - }); - - public static final Material LANTHANITE_LA = new Material( - "Lanthanite (La)", //Material Name - MaterialState.ORE, //State - TextureSets.REFINED.get(), //Texture Set - new short[]{219, 160, 214, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{// (La)2(CO3)3·8(H2O) - new MaterialStack(ELEMENT.getInstance().LANTHANUM, 2), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 3), - new MaterialStack(ELEMENT.getInstance().CALCIUM, 3), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 2), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 1), - }); - - public static final Material LANTHANITE_ND = new Material( - "Lanthanite (Nd)", //Material Name - MaterialState.ORE, //State - TextureSet.SET_METALLIC, //Texture Set - new short[]{153, 76, 145, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{// (Nd)2(CO3)3·8(H2O) - new MaterialStack(ELEMENT.getInstance().NEODYMIUM, 2), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 3), - new MaterialStack(ELEMENT.getInstance().CALCIUM, 3), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 2), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 1), - }); - - //Iodine Source - public static final Material LAUTARITE = new Material( - "Lautarite", //Material Name - MaterialState.ORE, //State - TextureSet.SET_FINE, //Texture Set - new short[]{165, 105, 205, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{// Na3AlF6 - new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), - new MaterialStack(ELEMENT.getInstance().IODINE, 2), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 6) - }); - - public static final Material LEPERSONNITE = new Material( - "Lepersonnite", //Material Name - MaterialState.ORE, //State - TextureSet.SET_EMERALD, //Texture Set - new short[]{175, 175, 20, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), - new MaterialStack(ELEMENT.getInstance().YTTERBIUM, 3), - new MaterialStack(ELEMENT.getInstance().GADOLINIUM, 2), - new MaterialStack(ELEMENT.getInstance().DYSPROSIUM, 2), - new MaterialStack(ELEMENT.getInstance().URANIUM235, 2), - new MaterialStack(ELEMENT.getInstance().OXYGEN,29), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 24) - }); - - //Miessiite - //Pd11Te2Se2 - public static final Material MIESSIITE = new Material( - "Miessiite", //Material Name - MaterialState.ORE, //State - TextureSet.SET_FINE, //Texture Set - new short[]{75, 75, 75, 0}, //Material Colour - -1, - -1, - -1, - -1, - 0, //Radiation - new MaterialStack[]{// Na3AlF6 - new MaterialStack(ELEMENT.getInstance().PALLADIUM, 11), - new MaterialStack(ELEMENT.getInstance().TELLURIUM, 2), - new MaterialStack(ELEMENT.getInstance().SELENIUM, 2) - }); - - public static final Material NICHROMITE = new Material( - "Nichromite", //Material Name - MaterialState.ORE, //State - TextureSet.SET_METALLIC, //Texture Set - new short[]{22, 19, 19, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().NICKEL, 1), - new MaterialStack(ELEMENT.getInstance().COBALT, 1), - new MaterialStack(ELEMENT.getInstance().IRON, 3), - new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 2), - new MaterialStack(ELEMENT.getInstance().CHROMIUM, 2), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 8) - }); - - //Perroudite - //Hg5Ag4S5(I,Br)2Cl2 - public static final Material PERROUDITE = new Material( - "Perroudite", //Material Name - MaterialState.ORE, //State - TextureSet.SET_METALLIC, //Texture Set - new short[]{77, 165, 174, 0}, //Material Colour - -1, - -1, - -1, - -1, - 0, //Radiation - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().SULFUR, 5), - new MaterialStack(ELEMENT.getInstance().SILVER, 4), - new MaterialStack(ELEMENT.getInstance().IODINE, 2), - new MaterialStack(ELEMENT.getInstance().MERCURY, 5), - new MaterialStack(ELEMENT.getInstance().BROMINE, 2), - new MaterialStack(ELEMENT.getInstance().CHLORINE, 2) - }); - - public static final Material POLYCRASE = new Material( - "Polycrase", //Material Name - MaterialState.ORE, //State - TextureSet.SET_ROUGH, //Texture Set - new short[]{51, 0, 11, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().YTTRIUM, 1), - new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), - new MaterialStack(ELEMENT.getInstance().CERIUM, 1), - new MaterialStack(ELEMENT.getInstance().URANIUM235, 1), - new MaterialStack(ELEMENT.getInstance().THORIUM, 1), - new MaterialStack(ELEMENT.getInstance().TITANIUM, 2), - new MaterialStack(ELEMENT.getInstance().NIOBIUM, 2), - new MaterialStack(ELEMENT.getInstance().TANTALUM, 2), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 6) - }); - - //Radiobarite - //Radium, Barium, Barite? - public static final Material RADIOBARITE = new Material( - "Barite (Rd)", //Material Name - MaterialState.ORE, //State - TextureSet.SET_FLINT, //Texture Set - new short[]{205, 205, 205, 0}, //Material Colour - -1, - -1, - -1, - -1, - 0, //Radiation - new MaterialStack[]{// Na3AlF6 - new MaterialStack(ELEMENT.getInstance().BARIUM, 32), - new MaterialStack(ELEMENT.getInstance().RADIUM, 1), - new MaterialStack(ELEMENT.getInstance().SULFUR, 16), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 15) - }); - - //Samarskite_Y - public static final Material SAMARSKITE_Y = new Material( - "Samarskite (Y)", //Material Name - MaterialState.ORE, //State - TextureSets.ENRICHED.get(), //Texture Set - new short[]{65, 163, 164, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().YTTRIUM, 2), //Y not YT/YB - new MaterialStack(ELEMENT.getInstance().IRON, 10), - new MaterialStack(ELEMENT.getInstance().URANIUM235, 2), - new MaterialStack(ELEMENT.getInstance().THORIUM, 3), - new MaterialStack(ELEMENT.getInstance().NIOBIUM, 2), - new MaterialStack(ELEMENT.getInstance().TANTALUM, 3) - }); - - //Samarskite_YB - public static final Material SAMARSKITE_YB = new Material( - "Samarskite (Yb)", //Material Name - MaterialState.ORE, //State - TextureSets.ENRICHED.get(), //Texture Set - new short[]{95, 193, 194, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().YTTERBIUM, 2), //Y not YT/YB - new MaterialStack(ELEMENT.getInstance().IRON, 9), - new MaterialStack(ELEMENT.getInstance().URANIUM235, 3), - new MaterialStack(ELEMENT.getInstance().THORIUM, 2), - new MaterialStack(ELEMENT.getInstance().NIOBIUM, 3), - new MaterialStack(ELEMENT.getInstance().TANTALUM, 2) - }); - - public static final Material TITANITE = new Material( - "Titanite", //Material Name - MaterialState.ORE, //State - TextureSet.SET_METALLIC, //Texture Set - new short[]{184, 198, 105, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().CALCIUM, 2), - new MaterialStack(ELEMENT.getInstance().TITANIUM, 2), - new MaterialStack(ELEMENT.getInstance().SILICON, 2), - new MaterialStack(ELEMENT.getInstance().THORIUM, 1), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 10) - }); - - public static final Material XENOTIME = new Material( - "Xenotime", //Material Name - MaterialState.ORE, //State - TextureSet.SET_OPAL, //Texture Set - new short[]{235, 89, 199, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().YTTRIUM, 2), - new MaterialStack(ELEMENT.getInstance().YTTERBIUM, 2), - new MaterialStack(ELEMENT.getInstance().ERBIUM, 2), - new MaterialStack(ELEMENT.getInstance().EUROPIUM, 1), - new MaterialStack(ELEMENT.getInstance().PHOSPHORUS, 2), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 8) - }); - - public static final Material YTTRIAITE = new Material( //TODO - "Yttriaite", //Material Name - MaterialState.ORE, //State - TextureSet.SET_METALLIC, //Texture Set - new short[]{255, 143, 84, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().YTTRIUM, 1), //Y not YT/YB - new MaterialStack(ELEMENT.getInstance().OXYGEN, 3), - new MaterialStack(ELEMENT.getInstance().IRON, 4), - new MaterialStack(ELEMENT.getInstance().TIN, 1), - new MaterialStack(ELEMENT.getInstance().NITROGEN, 2) - }); - - public static final Material YTTRIALITE = new Material( - "Yttrialite", //Material Name - MaterialState.ORE, //State - TextureSet.SET_RUBY, //Texture Set - new short[]{35, 189, 99, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().YTTRIUM, 2), - new MaterialStack(ELEMENT.getInstance().THORIUM, 2), - new MaterialStack(ELEMENT.getInstance().SILICON, 2), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 7), - }); - - public static final Material YTTROCERITE = new Material( - "Yttrocerite", //Material Name - MaterialState.ORE, //State - TextureSet.SET_DIAMOND, //Texture Set - new short[]{35, 19, 199, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().CERIUM, 1), - new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), - new MaterialStack(ELEMENT.getInstance().FLUORINE, 5), - new MaterialStack(ELEMENT.getInstance().YTTRIUM, 1), - }); - - public static final Material ZIMBABWEITE = new Material( - "Zimbabweite", //Material Name - MaterialState.ORE, //State - TextureSet.SET_FINE, //Texture Set - new short[]{193, 187, 131, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().CALCIUM, 2), - new MaterialStack(ELEMENT.getInstance().POTASSIUM, 2), - new MaterialStack(ELEMENT.getInstance().LEAD, 1), - new MaterialStack(ELEMENT.getInstance().ARSENIC, 4), - new MaterialStack(ELEMENT.getInstance().NIOBIUM, 4), - new MaterialStack(ELEMENT.getInstance().TANTALUM, 4), - new MaterialStack(ELEMENT.getInstance().TITANIUM, 4), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 18) - }); - - public static final Material ZIRCON = new Material( - "Zircon", //Material Name - MaterialState.ORE, //State - TextureSets.GEM_A.get(), //Texture Set - new short[]{195, 19, 19, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().ZIRCONIUM, 1), - new MaterialStack(ELEMENT.getInstance().SILICON, 1), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 4), - }); - - public static final Material ZIRCONILITE = new Material( - "Zirconolite", //Material Name - MaterialState.ORE, //State - TextureSet.SET_FINE, //Texture Set - new short[]{45, 26, 0, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().CALCIUM, 2), - new MaterialStack(ELEMENT.getInstance().ZIRCONIUM, 2), - new MaterialStack(ELEMENT.getInstance().TITANIUM, 4), - new MaterialStack(ELEMENT.getInstance().CERIUM, 1), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 14) - }); - - public static final Material ZIRCOPHYLLITE = new Material( - "Zircophyllite", //Material Name - MaterialState.ORE, //State - TextureSets.REFINED.get(), //Texture Set - new short[]{30, 0, 6, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().POTASSIUM, 3), - new MaterialStack(ELEMENT.getInstance().SODIUM, 3), - new MaterialStack(ELEMENT.getInstance().MANGANESE, 7), - new MaterialStack(ELEMENT.getInstance().IRON, 7), - new MaterialStack(ELEMENT.getInstance().ZIRCONIUM, 2), - new MaterialStack(ELEMENT.getInstance().TITANIUM, 2), - new MaterialStack(ELEMENT.getInstance().NIOBIUM, 2), - new MaterialStack(ELEMENT.getInstance().SILICON, 8), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 13), - new MaterialStack(ELEMENT.getInstance().FLUORINE, 7), - }); - - - public static final Material ZIRKELITE = new Material( - "Zirkelite", //Material Name - MaterialState.ORE, //State - TextureSets.GEM_A.get(), //Texture Set - new short[]{229, 208, 48, 0}, //Material Colour - -1, - -1, - -1, - -1, - -1, //Radiation - new MaterialStack[]{// (Ca,Th,Ce)Zr(Ti,Nb)2O7 - new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), - new MaterialStack(ELEMENT.getInstance().THORIUM, 1), - new MaterialStack(ELEMENT.getInstance().CERIUM, 1), - new MaterialStack(ELEMENT.getInstance().ZIRCONIUM, 1), - new MaterialStack(ELEMENT.getInstance().TITANIUM, 2), - new MaterialStack(ELEMENT.getInstance().NIOBIUM, 2), - new MaterialStack(ELEMENT.getInstance().OXYGEN, 7) - }); - - public static final Material DEEP_EARTH_REACTOR_FUEL_DEPOSIT = new Material( - "Radioactive Mineral Mix", //Material Name - MaterialState.ORE, //State - TextureSets.NUCLEAR.get(), //Texture Set - null, //Material Colour - -1, - -1, - -1, - -1, - 4, //Radiation - new MaterialStack[]{// Na3AlF6 - new MaterialStack(ELEMENT.getInstance().RADON, 2), - new MaterialStack(ELEMENT.getInstance().RADIUM, 1), - new MaterialStack(ELEMENT.getInstance().URANIUM235, 1), - new MaterialStack(ELEMENT.getInstance().URANIUM238, 10), - new MaterialStack(ELEMENT.getInstance().THORIUM, 25), - new MaterialStack(ELEMENT.getInstance().THORIUM232, 4), - new MaterialStack(FLUORCAPHITE, 6), - new MaterialStack(SAMARSKITE_Y, 8), - new MaterialStack(TITANITE, 4) - }); - - + public static final Material AGARDITE_CD = new Material( + "Agardite (Cd)", // Material Name + MaterialState.ORE, // State + TextureSet.SET_METALLIC, // Texture Set + new short[] {170, 188, 33, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // (CdCa)Cu7(AsO2)4(O2H)5·3H2O + new MaterialStack(ELEMENT.getInstance().CADMIUM, 1), + new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), + new MaterialStack(ELEMENT.getInstance().COPPER, 7), + new MaterialStack(ELEMENT.getInstance().ARSENIC, 4), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 21), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 11) + }); + public static final Material AGARDITE_LA = new Material( + "Agardite (La)", // Material Name + MaterialState.ORE, // State + TextureSet.SET_FINE, // Texture Set + new short[] {206, 232, 9, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // (LaCa)Cu5(AsO6)2(OH)4·3H2O + new MaterialStack(ELEMENT.getInstance().LANTHANUM, 1), + new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), + new MaterialStack(ELEMENT.getInstance().COPPER, 5), + new MaterialStack(ELEMENT.getInstance().ARSENIC, 2), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 19), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 10) + }); + public static final Material AGARDITE_ND = new Material( + "Agardite (Nd)", // Material Name + MaterialState.ORE, // State + TextureSet.SET_METALLIC, // Texture Set + new short[] {225, 244, 78, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // (NdCa)Cu6(As3O3)2(O2H)6·3H2O + new MaterialStack(ELEMENT.getInstance().NEODYMIUM, 1), + new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), + new MaterialStack(ELEMENT.getInstance().COPPER, 6), + new MaterialStack(ELEMENT.getInstance().ARSENIC, 6), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 21), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 12) + }); + public static final Material AGARDITE_Y = new Material( + "Agardite (Y)", // Material Name + MaterialState.ORE, // State + TextureSet.SET_METALLIC, // Texture Set + new short[] {210, 232, 44, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // (YCa)Cu5(As2O4)3(OH)6·3H2O + new MaterialStack(ELEMENT.getInstance().YTTRIUM, 1), + new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), + new MaterialStack(ELEMENT.getInstance().COPPER, 5), + new MaterialStack(ELEMENT.getInstance().ARSENIC, 6), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 21), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 12) + }); + + // Alburnite + // Ag8GeTe2S4 + public static final Material ALBURNITE = new Material( + "Alburnite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_METALLIC, // Texture Set + new short[] {16, 5, 105, 0}, // Material Colour + -1, + -1, + -1, + -1, + 0, // Radiation + new MaterialStack[] { // Na3AlF6 + new MaterialStack(ELEMENT.getInstance().GOLD, 8), + new MaterialStack(ELEMENT.getInstance().GERMANIUM, 1), + new MaterialStack(ELEMENT.getInstance().TELLURIUM, 2), + new MaterialStack(ELEMENT.getInstance().SULFUR, 4) + }); + + public static final Material CERITE = new Material( + "Cerite", // Material Name + MaterialState.ORE, // State + TextureSets.REFINED.get(), // Texture Set + new short[] {68, 13, 0, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // (Ce,La,Ca)9(Mg,Fe+3)(SiO4)6(SiO3OH)(OH)3 + new MaterialStack(ELEMENT.getInstance().CERIUM, 9), + new MaterialStack(ELEMENT.getInstance().LANTHANUM, 9), + new MaterialStack(ELEMENT.getInstance().CALCIUM, 9), + new MaterialStack(ELEMENT.getInstance().MAGNESIUM, 3), + new MaterialStack(ELEMENT.getInstance().IRON, 3), + new MaterialStack(ELEMENT.getInstance().SILICON, 7), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 20), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 4) + }); + + // Comancheite + // Hg55N24(NH2,OH)4(Cl,Br)34 + public static final Material COMANCHEITE = new Material( + "Comancheite", // Material Name + MaterialState.ORE, // State + TextureSets.REFINED.get(), // Texture Set + new short[] {65, 205, 105, 0}, // Material Colour + -1, + -1, + -1, + -1, + 0, // Radiation + new MaterialStack[] { // Na3AlF6 + new MaterialStack(ELEMENT.getInstance().MERCURY, 54 / 4), + new MaterialStack(ELEMENT.getInstance().NITROGEN, 28 / 4), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 12 / 4), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 8 / 4), + new MaterialStack(ELEMENT.getInstance().CHLORINE, 34 / 4), + new MaterialStack(ELEMENT.getInstance().BROMINE, 34 / 4) + }); + + public static final Material CROCROITE = new Material( + "Crocoite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_GEM_VERTICAL, // Texture Set + new short[] {255, 143, 84, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().LEAD, 2), + new MaterialStack(ELEMENT.getInstance().CHROMIUM, 2), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 3), + new MaterialStack(ELEMENT.getInstance().CAESIUM, 1), + }); + + public static final Material CRYOLITE = new Material( + "Cryolite (F)", // Material Name + MaterialState.ORE, // State + TextureSet.SET_SHINY, // Texture Set + new short[] {205, 205, 255, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // Na3AlF6 + new MaterialStack(ELEMENT.getInstance().SODIUM, 3), + new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 6) + }); + + // Demicheleite-(Br) + // BiSBr + public static final Material DEMICHELEITE_BR = new Material( + "Demicheleite (Br)", // Material Name + MaterialState.ORE, // State + TextureSet.SET_SHINY, // Texture Set + new short[] {165, 75, 75, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // Na3AlF6 + new MaterialStack(ELEMENT.getInstance().BISMUTH, 13), + new MaterialStack(ELEMENT.getInstance().SULFUR, 11), + new MaterialStack(ELEMENT.getInstance().BROMINE, 1) + }); + + public static final Material FLORENCITE = new Material( + "Florencite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_METALLIC, // Texture Set + new short[] {249, 249, 124, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // SmAl3(PO4)2(OH)6 + new MaterialStack(ELEMENT.getInstance().SAMARIUM, 1), + new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 3), + new MaterialStack(ELEMENT.getInstance().PHOSPHORUS, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 10), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 6) + }); + + public static final Material FLUORCAPHITE = new Material( + "Fluorcaphite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_FINE, // Texture Set + new short[] {255, 255, 30, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // (Ca,Sr,Ce,Na)5(PO4)3F + new MaterialStack(ELEMENT.getInstance().CALCIUM, 5), + new MaterialStack(MISC_MATERIALS.STRONTIUM_OXIDE, 5), + new MaterialStack(ELEMENT.getInstance().CERIUM, 5), + new MaterialStack(ELEMENT.getInstance().SODIUM, 5), + new MaterialStack(ELEMENT.getInstance().PHOSPHORUS, 3), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 12), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 6), + }); + + // Gadolinite_Ce + public static final Material GADOLINITE_CE = new Material( + "Gadolinite (Ce)", // Material Name + MaterialState.ORE, // State + TextureSets.REFINED.get(), // Texture Set + new short[] {15, 159, 59, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().CERIUM, 4), + new MaterialStack(ELEMENT.getInstance().ERBIUM, 2), + new MaterialStack(ELEMENT.getInstance().LANTHANUM, 2), + new MaterialStack(ELEMENT.getInstance().NEODYMIUM, 2), + new MaterialStack(ELEMENT.getInstance().YTTRIUM, 2), + new MaterialStack(ELEMENT.getInstance().GADOLINIUM, 1), + new MaterialStack(ELEMENT.getInstance().BERYLLIUM, 2), + new MaterialStack(ELEMENT.getInstance().SILICON, 7), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 14), + }); + + // Gadolinite_Y + public static final Material GADOLINITE_Y = new Material( + "Gadolinite (Y)", // Material Name + MaterialState.ORE, // State + TextureSets.REFINED.get(), // Texture Set + new short[] {35, 189, 99, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().CERIUM, 2), + new MaterialStack(ELEMENT.getInstance().ERBIUM, 2), + new MaterialStack(ELEMENT.getInstance().LANTHANUM, 2), + new MaterialStack(ELEMENT.getInstance().NEODYMIUM, 2), + new MaterialStack(ELEMENT.getInstance().YTTRIUM, 4), + new MaterialStack(ELEMENT.getInstance().GADOLINIUM, 2), + new MaterialStack(ELEMENT.getInstance().BERYLLIUM, 3), + new MaterialStack(ELEMENT.getInstance().SILICON, 4), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 9), + }); + + public static final Material GEIKIELITE = new Material( + "Geikielite", // Material Name + MaterialState.ORE, // State + TextureSets.GEM_A.get(), // Texture Set + new short[] {187, 193, 204, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().MAGNESIUM, 1), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 3) + }); + + public static final Material GREENOCKITE = new Material( + "Greenockite", // Material Name + MaterialState.ORE, // State + TextureSets.GEM_A.get(), // Texture Set + new short[] {110, 193, 25, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().CADMIUM, 2), new MaterialStack(ELEMENT.getInstance().SULFUR, 2), + }); + + public static final Material HIBONITE = new Material( + "Hibonite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_METALLIC, // Texture Set + new short[] {58, 31, 0, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // ((Ca,Ce)(Al,Ti,Mg)12O19) + new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), + new MaterialStack(ELEMENT.getInstance().CERIUM, 1), + new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 12), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 12), + new MaterialStack(ELEMENT.getInstance().MAGNESIUM, 12), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 19), + }); + + // Honeaite + // Au3TlTe2 + public static final Material HONEAITE = new Material( + "Honeaite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_FINE, // Texture Set + new short[] {165, 165, 5, 0}, // Material Colour + -1, + -1, + -1, + -1, + 0, // Radiation + new MaterialStack[] { // Na3AlF6 + new MaterialStack(ELEMENT.getInstance().GOLD, 3), + new MaterialStack(ELEMENT.getInstance().THALLIUM, 1), + new MaterialStack(ELEMENT.getInstance().TELLURIUM, 2) + }); + + // Irarsite + // (Ir,Ru,Rh,Pt)AsS + public static final Material IRARSITE = new Material( + "Irarsite", // Material Name + MaterialState.ORE, // State + TextureSets.ENRICHED.get(), // Texture Set + new short[] {125, 105, 105, 0}, // Material Colour + -1, + -1, + -1, + -1, + 0, // Radiation + new MaterialStack[] { // Na3AlF6 + new MaterialStack(ELEMENT.getInstance().IRIDIUM, 1), + new MaterialStack(ELEMENT.getInstance().RUTHENIUM, 1), + new MaterialStack(ELEMENT.getInstance().RHODIUM, 1), + new MaterialStack(ELEMENT.getInstance().PLATINUM, 1), + new MaterialStack(ELEMENT.getInstance().ARSENIC, 1), + new MaterialStack(ELEMENT.getInstance().SULFUR, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 1) + }); + + // Kashinite + // (Ir,Rh)2S3 + public static final Material KASHINITE = new Material( + "Kashinite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_SHINY, // Texture Set + new short[] {75, 105, 75, 0}, // Material Colour + -1, + -1, + -1, + -1, + 0, // Radiation + new MaterialStack[] { // Na3AlF6 + new MaterialStack(ELEMENT.getInstance().IRIDIUM, 2), + new MaterialStack(ELEMENT.getInstance().RHODIUM, 2), + new MaterialStack(ELEMENT.getInstance().SULFUR, 3) + }); + + // Tl(Cl,Br) + public static final Material LAFOSSAITE = new Material( + "Lafossaite", // Material Name + MaterialState.ORE, // State + TextureSets.REFINED.get(), // Texture Set + new short[] {165, 105, 205, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // Na3AlF6 + new MaterialStack(ELEMENT.getInstance().CHLORINE, 1), + new MaterialStack(ELEMENT.getInstance().BROMINE, 1), + new MaterialStack(ELEMENT.getInstance().THALLIUM, 1) + }); + + public static final Material LANTHANITE_CE = new Material( + "Lanthanite (Ce)", // Material Name + MaterialState.ORE, // State + TextureSet.SET_METALLIC, // Texture Set + new short[] {186, 113, 179, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // (Ce)2(CO3)3·8(H2O) + new MaterialStack(ELEMENT.getInstance().CERIUM, 2), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 3), + new MaterialStack(ELEMENT.getInstance().CALCIUM, 3), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 2), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 1), + }); + + public static final Material LANTHANITE_LA = new Material( + "Lanthanite (La)", // Material Name + MaterialState.ORE, // State + TextureSets.REFINED.get(), // Texture Set + new short[] {219, 160, 214, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // (La)2(CO3)3·8(H2O) + new MaterialStack(ELEMENT.getInstance().LANTHANUM, 2), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 3), + new MaterialStack(ELEMENT.getInstance().CALCIUM, 3), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 2), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 1), + }); + + public static final Material LANTHANITE_ND = new Material( + "Lanthanite (Nd)", // Material Name + MaterialState.ORE, // State + TextureSet.SET_METALLIC, // Texture Set + new short[] {153, 76, 145, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // (Nd)2(CO3)3·8(H2O) + new MaterialStack(ELEMENT.getInstance().NEODYMIUM, 2), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 3), + new MaterialStack(ELEMENT.getInstance().CALCIUM, 3), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 2), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 1), + }); + + // Iodine Source + public static final Material LAUTARITE = new Material( + "Lautarite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_FINE, // Texture Set + new short[] {165, 105, 205, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // Na3AlF6 + new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), + new MaterialStack(ELEMENT.getInstance().IODINE, 2), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 6) + }); + + public static final Material LEPERSONNITE = new Material( + "Lepersonnite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_EMERALD, // Texture Set + new short[] {175, 175, 20, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), + new MaterialStack(ELEMENT.getInstance().YTTERBIUM, 3), + new MaterialStack(ELEMENT.getInstance().GADOLINIUM, 2), + new MaterialStack(ELEMENT.getInstance().DYSPROSIUM, 2), + new MaterialStack(ELEMENT.getInstance().URANIUM235, 2), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 29), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 24) + }); + + // Miessiite + // Pd11Te2Se2 + public static final Material MIESSIITE = new Material( + "Miessiite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_FINE, // Texture Set + new short[] {75, 75, 75, 0}, // Material Colour + -1, + -1, + -1, + -1, + 0, // Radiation + new MaterialStack[] { // Na3AlF6 + new MaterialStack(ELEMENT.getInstance().PALLADIUM, 11), + new MaterialStack(ELEMENT.getInstance().TELLURIUM, 2), + new MaterialStack(ELEMENT.getInstance().SELENIUM, 2) + }); + + public static final Material NICHROMITE = new Material( + "Nichromite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_METALLIC, // Texture Set + new short[] {22, 19, 19, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().NICKEL, 1), + new MaterialStack(ELEMENT.getInstance().COBALT, 1), + new MaterialStack(ELEMENT.getInstance().IRON, 3), + new MaterialStack(ELEMENT.getInstance().ALUMINIUM, 2), + new MaterialStack(ELEMENT.getInstance().CHROMIUM, 2), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 8) + }); + + // Perroudite + // Hg5Ag4S5(I,Br)2Cl2 + public static final Material PERROUDITE = new Material( + "Perroudite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_METALLIC, // Texture Set + new short[] {77, 165, 174, 0}, // Material Colour + -1, + -1, + -1, + -1, + 0, // Radiation + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().SULFUR, 5), + new MaterialStack(ELEMENT.getInstance().SILVER, 4), + new MaterialStack(ELEMENT.getInstance().IODINE, 2), + new MaterialStack(ELEMENT.getInstance().MERCURY, 5), + new MaterialStack(ELEMENT.getInstance().BROMINE, 2), + new MaterialStack(ELEMENT.getInstance().CHLORINE, 2) + }); + + public static final Material POLYCRASE = new Material( + "Polycrase", // Material Name + MaterialState.ORE, // State + TextureSet.SET_ROUGH, // Texture Set + new short[] {51, 0, 11, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().YTTRIUM, 1), + new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), + new MaterialStack(ELEMENT.getInstance().CERIUM, 1), + new MaterialStack(ELEMENT.getInstance().URANIUM235, 1), + new MaterialStack(ELEMENT.getInstance().THORIUM, 1), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 2), + new MaterialStack(ELEMENT.getInstance().NIOBIUM, 2), + new MaterialStack(ELEMENT.getInstance().TANTALUM, 2), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 6) + }); + + // Radiobarite + // Radium, Barium, Barite? + public static final Material RADIOBARITE = new Material( + "Barite (Rd)", // Material Name + MaterialState.ORE, // State + TextureSet.SET_FLINT, // Texture Set + new short[] {205, 205, 205, 0}, // Material Colour + -1, + -1, + -1, + -1, + 0, // Radiation + new MaterialStack[] { // Na3AlF6 + new MaterialStack(ELEMENT.getInstance().BARIUM, 32), + new MaterialStack(ELEMENT.getInstance().RADIUM, 1), + new MaterialStack(ELEMENT.getInstance().SULFUR, 16), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 15) + }); + + // Samarskite_Y + public static final Material SAMARSKITE_Y = new Material( + "Samarskite (Y)", // Material Name + MaterialState.ORE, // State + TextureSets.ENRICHED.get(), // Texture Set + new short[] {65, 163, 164, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().YTTRIUM, 2), // Y not YT/YB + new MaterialStack(ELEMENT.getInstance().IRON, 10), + new MaterialStack(ELEMENT.getInstance().URANIUM235, 2), + new MaterialStack(ELEMENT.getInstance().THORIUM, 3), + new MaterialStack(ELEMENT.getInstance().NIOBIUM, 2), + new MaterialStack(ELEMENT.getInstance().TANTALUM, 3) + }); + + // Samarskite_YB + public static final Material SAMARSKITE_YB = new Material( + "Samarskite (Yb)", // Material Name + MaterialState.ORE, // State + TextureSets.ENRICHED.get(), // Texture Set + new short[] {95, 193, 194, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().YTTERBIUM, 2), // Y not YT/YB + new MaterialStack(ELEMENT.getInstance().IRON, 9), + new MaterialStack(ELEMENT.getInstance().URANIUM235, 3), + new MaterialStack(ELEMENT.getInstance().THORIUM, 2), + new MaterialStack(ELEMENT.getInstance().NIOBIUM, 3), + new MaterialStack(ELEMENT.getInstance().TANTALUM, 2) + }); + + public static final Material TITANITE = new Material( + "Titanite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_METALLIC, // Texture Set + new short[] {184, 198, 105, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().CALCIUM, 2), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 2), + new MaterialStack(ELEMENT.getInstance().SILICON, 2), + new MaterialStack(ELEMENT.getInstance().THORIUM, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 10) + }); + + public static final Material XENOTIME = new Material( + "Xenotime", // Material Name + MaterialState.ORE, // State + TextureSet.SET_OPAL, // Texture Set + new short[] {235, 89, 199, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().YTTRIUM, 2), + new MaterialStack(ELEMENT.getInstance().YTTERBIUM, 2), + new MaterialStack(ELEMENT.getInstance().ERBIUM, 2), + new MaterialStack(ELEMENT.getInstance().EUROPIUM, 1), + new MaterialStack(ELEMENT.getInstance().PHOSPHORUS, 2), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 8) + }); + + public static final Material YTTRIAITE = new Material( // TODO + "Yttriaite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_METALLIC, // Texture Set + new short[] {255, 143, 84, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().YTTRIUM, 1), // Y not YT/YB + new MaterialStack(ELEMENT.getInstance().OXYGEN, 3), + new MaterialStack(ELEMENT.getInstance().IRON, 4), + new MaterialStack(ELEMENT.getInstance().TIN, 1), + new MaterialStack(ELEMENT.getInstance().NITROGEN, 2) + }); + + public static final Material YTTRIALITE = new Material( + "Yttrialite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_RUBY, // Texture Set + new short[] {35, 189, 99, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().YTTRIUM, 2), + new MaterialStack(ELEMENT.getInstance().THORIUM, 2), + new MaterialStack(ELEMENT.getInstance().SILICON, 2), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 7), + }); + + public static final Material YTTROCERITE = new Material( + "Yttrocerite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_DIAMOND, // Texture Set + new short[] {35, 19, 199, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().CERIUM, 1), + new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 5), + new MaterialStack(ELEMENT.getInstance().YTTRIUM, 1), + }); + + public static final Material ZIMBABWEITE = new Material( + "Zimbabweite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_FINE, // Texture Set + new short[] {193, 187, 131, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().CALCIUM, 2), + new MaterialStack(ELEMENT.getInstance().POTASSIUM, 2), + new MaterialStack(ELEMENT.getInstance().LEAD, 1), + new MaterialStack(ELEMENT.getInstance().ARSENIC, 4), + new MaterialStack(ELEMENT.getInstance().NIOBIUM, 4), + new MaterialStack(ELEMENT.getInstance().TANTALUM, 4), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 4), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 18) + }); + + public static final Material ZIRCON = new Material( + "Zircon", // Material Name + MaterialState.ORE, // State + TextureSets.GEM_A.get(), // Texture Set + new short[] {195, 19, 19, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().ZIRCONIUM, 1), + new MaterialStack(ELEMENT.getInstance().SILICON, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 4), + }); + + public static final Material ZIRCONILITE = new Material( + "Zirconolite", // Material Name + MaterialState.ORE, // State + TextureSet.SET_FINE, // Texture Set + new short[] {45, 26, 0, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().CALCIUM, 2), + new MaterialStack(ELEMENT.getInstance().ZIRCONIUM, 2), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 4), + new MaterialStack(ELEMENT.getInstance().CERIUM, 1), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 14) + }); + + public static final Material ZIRCOPHYLLITE = new Material( + "Zircophyllite", // Material Name + MaterialState.ORE, // State + TextureSets.REFINED.get(), // Texture Set + new short[] {30, 0, 6, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().POTASSIUM, 3), + new MaterialStack(ELEMENT.getInstance().SODIUM, 3), + new MaterialStack(ELEMENT.getInstance().MANGANESE, 7), + new MaterialStack(ELEMENT.getInstance().IRON, 7), + new MaterialStack(ELEMENT.getInstance().ZIRCONIUM, 2), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 2), + new MaterialStack(ELEMENT.getInstance().NIOBIUM, 2), + new MaterialStack(ELEMENT.getInstance().SILICON, 8), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 13), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 7), + }); + + public static final Material ZIRKELITE = new Material( + "Zirkelite", // Material Name + MaterialState.ORE, // State + TextureSets.GEM_A.get(), // Texture Set + new short[] {229, 208, 48, 0}, // Material Colour + -1, + -1, + -1, + -1, + -1, // Radiation + new MaterialStack[] { // (Ca,Th,Ce)Zr(Ti,Nb)2O7 + new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), + new MaterialStack(ELEMENT.getInstance().THORIUM, 1), + new MaterialStack(ELEMENT.getInstance().CERIUM, 1), + new MaterialStack(ELEMENT.getInstance().ZIRCONIUM, 1), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 2), + new MaterialStack(ELEMENT.getInstance().NIOBIUM, 2), + new MaterialStack(ELEMENT.getInstance().OXYGEN, 7) + }); + + public static final Material DEEP_EARTH_REACTOR_FUEL_DEPOSIT = new Material( + "Radioactive Mineral Mix", // Material Name + MaterialState.ORE, // State + TextureSets.NUCLEAR.get(), // Texture Set + null, // Material Colour + -1, + -1, + -1, + -1, + 4, // Radiation + new MaterialStack[] { // Na3AlF6 + new MaterialStack(ELEMENT.getInstance().RADON, 2), + new MaterialStack(ELEMENT.getInstance().RADIUM, 1), + new MaterialStack(ELEMENT.getInstance().URANIUM235, 1), + new MaterialStack(ELEMENT.getInstance().URANIUM238, 10), + new MaterialStack(ELEMENT.getInstance().THORIUM, 25), + new MaterialStack(ELEMENT.getInstance().THORIUM232, 4), + new MaterialStack(FLUORCAPHITE, 6), + new MaterialStack(SAMARSKITE_Y, 8), + new MaterialStack(TITANITE, 4) + }); } diff --git a/src/main/java/gtPlusPlus/core/material/Particle.java b/src/main/java/gtPlusPlus/core/material/Particle.java index e93129ec58..7067052cb5 100644 --- a/src/main/java/gtPlusPlus/core/material/Particle.java +++ b/src/main/java/gtPlusPlus/core/material/Particle.java @@ -9,145 +9,143 @@ import net.minecraft.item.ItemStack; public class Particle { - public static final Particle GRAVITON; - - public static final Particle UP; - public static final Particle DOWN; - public static final Particle CHARM; - public static final Particle STRANGE; - public static final Particle TOP; - public static final Particle BOTTOM; - - public static final Particle ELECTRON; - public static final Particle ELECTRON_NEUTRINO; - public static final Particle MUON; - public static final Particle MUON_NEUTRINO; - public static final Particle TAU; - public static final Particle TAU_NEUTRINO; - - public static final Particle GLUON; - public static final Particle PHOTON; - public static final Particle Z_BOSON; - public static final Particle W_BOSON; - public static final Particle HIGGS_BOSON; - - public static final Particle PROTON; - public static final Particle NEUTRON; - public static final Particle LAMBDA; - public static final Particle OMEGA; - - public static final Particle PION; - public static final Particle ETA_MESON; - - public static final Particle UNKNOWN; - - public static final AutoMap aMap = new AutoMap(); - - static { - - /* - * Standard Model of Physics - */ - - //I exist, because I must. - GRAVITON = new Particle(ElementaryGroup.BOSON, "Graviton"); - - //Quarks - UP = new Particle(ElementaryGroup.QUARK, "Up"); - DOWN = new Particle(ElementaryGroup.QUARK, "Down"); - CHARM = new Particle(ElementaryGroup.QUARK, "Charm"); - STRANGE = new Particle(ElementaryGroup.QUARK, "Strange"); - TOP = new Particle(ElementaryGroup.QUARK, "Top"); - BOTTOM = new Particle(ElementaryGroup.QUARK, "Bottom"); - - //Leptons - ELECTRON = new Particle(ElementaryGroup.LEPTON, "Electron"); - MUON = new Particle(ElementaryGroup.LEPTON, "Muon"); - TAU = new Particle(ElementaryGroup.LEPTON, "Tau"); - ELECTRON_NEUTRINO = new Particle(ElementaryGroup.LEPTON, "Electron Neutrino"); - MUON_NEUTRINO = new Particle(ElementaryGroup.LEPTON, "Muon Neutrino"); - TAU_NEUTRINO = new Particle(ElementaryGroup.LEPTON, "Tau Neutrino"); - - //Bosons - GLUON = new Particle(ElementaryGroup.BOSON, "Gluon"); - PHOTON = new Particle(ElementaryGroup.BOSON, "Photon"); - Z_BOSON = new Particle(ElementaryGroup.BOSON, "Z Boson"); - W_BOSON = new Particle(ElementaryGroup.BOSON, "W Boson"); - HIGGS_BOSON = new Particle(ElementaryGroup.BOSON, "Higgs Boson"); - - /* - * Composite Particles - */ - - //Baryons - PROTON = new Particle(ElementaryGroup.BARYON, "Proton", new Particle[] {UP, UP, DOWN}); - NEUTRON = new Particle(ElementaryGroup.BARYON, "Neutron", new Particle[] {UP, DOWN, DOWN}); - LAMBDA = new Particle(ElementaryGroup.BARYON, "Lambda", new Particle[] {UP, DOWN, STRANGE}); - OMEGA = new Particle(ElementaryGroup.BARYON, "Omega", new Particle[] {STRANGE, STRANGE, STRANGE}); - - //Mesons - PION = new Particle(ElementaryGroup.MESON, "Pion", new Particle[] {MUON, MUON_NEUTRINO}); - ETA_MESON = new Particle(ElementaryGroup.MESON, "ETA Meson", new Particle[] {PION, PION, PION}); - - - //Wildcard - UNKNOWN = new Particle(ElementaryGroup.UNKNOWN, "Unknown"); - - } - - public static enum ElementaryGroup { - QUARK, - LEPTON, - BOSON, - BARYON, - MESON, - UNKNOWN; - } - - public final ElementaryGroup mParticleType; - public final String mParticleName; - public final Particle[] mComposition; - - public Particle(ElementaryGroup aParticleType, String aParticleName) { - this(aParticleType, aParticleName, null); - } - - public Particle(ElementaryGroup aParticleType, String aParticleName, Particle[] aComposition) { - mParticleType = aParticleType; - mParticleName = aParticleName; - mComposition = aComposition == null ? new Particle[] {this} : aComposition; - aMap.put(this); - } - - - public static ItemStack getIon(String aElementName, int aCharge) { - for (String g : gtPlusPlus.core.item.chemistry.IonParticles.NameToMetaMap.keySet()) { - if (g.toLowerCase().equals(Utils.sanitizeString(aElementName.toLowerCase()))){ - Integer meta = gtPlusPlus.core.item.chemistry.IonParticles.NameToMetaMap.get(Utils.sanitizeString(aElementName.toLowerCase())); - if (meta == null) { - meta = 0; - } - ItemStack aIon = ItemUtils.simpleMetaStack(ModItems.itemIonParticleBase, meta, 1); - if (aCharge != 0) { - IonParticles.setChargeState(aIon, aCharge); - } - return aIon; - } - } - return null; - } - - public static ItemStack getBaseParticle(Particle aParticle) { - String aPartName = Utils.sanitizeString(aParticle.mParticleName.toLowerCase()); - for (String g : gtPlusPlus.core.item.chemistry.StandardBaseParticles.NameToMetaMap.keySet()) { - if (g.toLowerCase().equals(aPartName)){ - Integer meta = gtPlusPlus.core.item.chemistry.StandardBaseParticles.NameToMetaMap.get(aPartName); - if (meta == null) { - meta = 0; - } - return ItemUtils.simpleMetaStack(ModItems.itemStandarParticleBase, meta, 1); - } - } - return null; - } + public static final Particle GRAVITON; + + public static final Particle UP; + public static final Particle DOWN; + public static final Particle CHARM; + public static final Particle STRANGE; + public static final Particle TOP; + public static final Particle BOTTOM; + + public static final Particle ELECTRON; + public static final Particle ELECTRON_NEUTRINO; + public static final Particle MUON; + public static final Particle MUON_NEUTRINO; + public static final Particle TAU; + public static final Particle TAU_NEUTRINO; + + public static final Particle GLUON; + public static final Particle PHOTON; + public static final Particle Z_BOSON; + public static final Particle W_BOSON; + public static final Particle HIGGS_BOSON; + + public static final Particle PROTON; + public static final Particle NEUTRON; + public static final Particle LAMBDA; + public static final Particle OMEGA; + + public static final Particle PION; + public static final Particle ETA_MESON; + + public static final Particle UNKNOWN; + + public static final AutoMap aMap = new AutoMap(); + + static { + + /* + * Standard Model of Physics + */ + + // I exist, because I must. + GRAVITON = new Particle(ElementaryGroup.BOSON, "Graviton"); + + // Quarks + UP = new Particle(ElementaryGroup.QUARK, "Up"); + DOWN = new Particle(ElementaryGroup.QUARK, "Down"); + CHARM = new Particle(ElementaryGroup.QUARK, "Charm"); + STRANGE = new Particle(ElementaryGroup.QUARK, "Strange"); + TOP = new Particle(ElementaryGroup.QUARK, "Top"); + BOTTOM = new Particle(ElementaryGroup.QUARK, "Bottom"); + + // Leptons + ELECTRON = new Particle(ElementaryGroup.LEPTON, "Electron"); + MUON = new Particle(ElementaryGroup.LEPTON, "Muon"); + TAU = new Particle(ElementaryGroup.LEPTON, "Tau"); + ELECTRON_NEUTRINO = new Particle(ElementaryGroup.LEPTON, "Electron Neutrino"); + MUON_NEUTRINO = new Particle(ElementaryGroup.LEPTON, "Muon Neutrino"); + TAU_NEUTRINO = new Particle(ElementaryGroup.LEPTON, "Tau Neutrino"); + + // Bosons + GLUON = new Particle(ElementaryGroup.BOSON, "Gluon"); + PHOTON = new Particle(ElementaryGroup.BOSON, "Photon"); + Z_BOSON = new Particle(ElementaryGroup.BOSON, "Z Boson"); + W_BOSON = new Particle(ElementaryGroup.BOSON, "W Boson"); + HIGGS_BOSON = new Particle(ElementaryGroup.BOSON, "Higgs Boson"); + + /* + * Composite Particles + */ + + // Baryons + PROTON = new Particle(ElementaryGroup.BARYON, "Proton", new Particle[] {UP, UP, DOWN}); + NEUTRON = new Particle(ElementaryGroup.BARYON, "Neutron", new Particle[] {UP, DOWN, DOWN}); + LAMBDA = new Particle(ElementaryGroup.BARYON, "Lambda", new Particle[] {UP, DOWN, STRANGE}); + OMEGA = new Particle(ElementaryGroup.BARYON, "Omega", new Particle[] {STRANGE, STRANGE, STRANGE}); + + // Mesons + PION = new Particle(ElementaryGroup.MESON, "Pion", new Particle[] {MUON, MUON_NEUTRINO}); + ETA_MESON = new Particle(ElementaryGroup.MESON, "ETA Meson", new Particle[] {PION, PION, PION}); + + // Wildcard + UNKNOWN = new Particle(ElementaryGroup.UNKNOWN, "Unknown"); + } + + public static enum ElementaryGroup { + QUARK, + LEPTON, + BOSON, + BARYON, + MESON, + UNKNOWN; + } + + public final ElementaryGroup mParticleType; + public final String mParticleName; + public final Particle[] mComposition; + + public Particle(ElementaryGroup aParticleType, String aParticleName) { + this(aParticleType, aParticleName, null); + } + + public Particle(ElementaryGroup aParticleType, String aParticleName, Particle[] aComposition) { + mParticleType = aParticleType; + mParticleName = aParticleName; + mComposition = aComposition == null ? new Particle[] {this} : aComposition; + aMap.put(this); + } + + public static ItemStack getIon(String aElementName, int aCharge) { + for (String g : gtPlusPlus.core.item.chemistry.IonParticles.NameToMetaMap.keySet()) { + if (g.toLowerCase().equals(Utils.sanitizeString(aElementName.toLowerCase()))) { + Integer meta = gtPlusPlus.core.item.chemistry.IonParticles.NameToMetaMap.get( + Utils.sanitizeString(aElementName.toLowerCase())); + if (meta == null) { + meta = 0; + } + ItemStack aIon = ItemUtils.simpleMetaStack(ModItems.itemIonParticleBase, meta, 1); + if (aCharge != 0) { + IonParticles.setChargeState(aIon, aCharge); + } + return aIon; + } + } + return null; + } + + public static ItemStack getBaseParticle(Particle aParticle) { + String aPartName = Utils.sanitizeString(aParticle.mParticleName.toLowerCase()); + for (String g : gtPlusPlus.core.item.chemistry.StandardBaseParticles.NameToMetaMap.keySet()) { + if (g.toLowerCase().equals(aPartName)) { + Integer meta = gtPlusPlus.core.item.chemistry.StandardBaseParticles.NameToMetaMap.get(aPartName); + if (meta == null) { + meta = 0; + } + return ItemUtils.simpleMetaStack(ModItems.itemStandarParticleBase, meta, 1); + } + } + return null; + } } diff --git a/src/main/java/gtPlusPlus/core/material/gregtech/CustomGTMaterials.java b/src/main/java/gtPlusPlus/core/material/gregtech/CustomGTMaterials.java index 20aebb80ed..dc70ccfe7a 100644 --- a/src/main/java/gtPlusPlus/core/material/gregtech/CustomGTMaterials.java +++ b/src/main/java/gtPlusPlus/core/material/gregtech/CustomGTMaterials.java @@ -2,78 +2,80 @@ package gtPlusPlus.core.material.gregtech; public class CustomGTMaterials { - //public static Materials Fireclay = new MaterialBuilder(626, TextureSet.SET_ROUGH, "Fireclay").addDustItems().setRGB(173, 160, 155).setColor(Dyes.dyeBrown).setMaterialList(new MaterialStack(Brick, 1)).constructMaterial(); - - /**int aMetaItemSubID, - * TextureSet aIconSet, - * float aToolSpeed, - * int aDurability, - * int aToolQuality, - * boolean aUnificatable, - * String aName, String aDefaultLocalName, - * String aConfigSection, - * boolean aCustomOre, - * String aCustomID) { - - **/ - - /*public static List Custom_GT_Materials = new ArrayList(); - - public static Materials Zirconium = materialBuilder_Element(1232, TextureSet.SET_METALLIC, 6.0F, 256, 2, 1|2|8|32|64|128, 200, 200, 200, 0, "Zirconium", "Zirconium", 0, 0, 1811, 0, false, false, 3, 1, 1, Dyes.dyeLightGray, Element.Zr, Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.METALLUM, 3))); - public static Materials Geikielite = materialBuilder(1234, TextureSet.SET_SHINY, new int[]{1,2,3}, "Geikielite", Dyes.dyeBlack, Arrays.asList(new MaterialStack(Titanium, 1), new MaterialStack(Magnesium, 1), new MaterialStack(Oxygen, 3))); - public static Materials Zirconolite = materialBuilder(1235, TextureSet.SET_METALLIC, new int[]{1,2,3}, "Zirconolite", Dyes.dyeBlack, Arrays.asList(new MaterialStack(Calcium, 1), new MaterialStack(Zirconium, 1), new MaterialStack(Titanium, 2), new MaterialStack(Oxygen, 7))); - - public static final void run(){ - Utils.LOG_INFO("[Custom] Trying to initialise custom materials."); - } - - private final static boolean registerMaterial(Materials r){ - Custom_GT_Materials.add(r); - Utils.LOG_INFO("[Custom] Registered new Gregtech material - "+r.mName); - return true; - } - - public final static Materials materialBuilder(int ID, TextureSet texture, int[] rgb, String materialName, Dyes dyeColour, List composition){ - Materials newMat = new Materials( - ID, - texture, - 1.0F, - 0, - 2, - 1 |8 , - rgb[0], rgb[1], rgb[2], 0, - materialName, materialName, - 0, 0, -1, 0, false, false, 3, 1, 1, - dyeColour, - 1, - composition - ); - registerMaterial(newMat); - return newMat; - } - - public final static Materials materialBuilder_Element( - int ID, TextureSet texture, - float a, int b, int c, - int d, int r2, int g2, int b2, int a2, - String materialName, String e, - int f, int g, int h, int i, - boolean j, boolean k, - int l, int m, int n, - Dyes dyeColour, Element o, - List aspects){ - Materials newMat = new Materials( - ID, texture, - a, b, c, - d, r2, g2, b2, a2, - materialName, e, - f, g, h, i, j, k, l, m, n, - dyeColour, o, - aspects - ); - registerMaterial(newMat); - return newMat; - } -*/ + // public static Materials Fireclay = new MaterialBuilder(626, TextureSet.SET_ROUGH, + // "Fireclay").addDustItems().setRGB(173, 160, 155).setColor(Dyes.dyeBrown).setMaterialList(new MaterialStack(Brick, + // 1)).constructMaterial(); + + /**int aMetaItemSubID, + * TextureSet aIconSet, + * float aToolSpeed, + * int aDurability, + * int aToolQuality, + * boolean aUnificatable, + * String aName, String aDefaultLocalName, + * String aConfigSection, + * boolean aCustomOre, + * String aCustomID) { + * + **/ + + /*public static List Custom_GT_Materials = new ArrayList(); + + public static Materials Zirconium = materialBuilder_Element(1232, TextureSet.SET_METALLIC, 6.0F, 256, 2, 1|2|8|32|64|128, 200, 200, 200, 0, "Zirconium", "Zirconium", 0, 0, 1811, 0, false, false, 3, 1, 1, Dyes.dyeLightGray, Element.Zr, Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.METALLUM, 3))); + public static Materials Geikielite = materialBuilder(1234, TextureSet.SET_SHINY, new int[]{1,2,3}, "Geikielite", Dyes.dyeBlack, Arrays.asList(new MaterialStack(Titanium, 1), new MaterialStack(Magnesium, 1), new MaterialStack(Oxygen, 3))); + public static Materials Zirconolite = materialBuilder(1235, TextureSet.SET_METALLIC, new int[]{1,2,3}, "Zirconolite", Dyes.dyeBlack, Arrays.asList(new MaterialStack(Calcium, 1), new MaterialStack(Zirconium, 1), new MaterialStack(Titanium, 2), new MaterialStack(Oxygen, 7))); + + public static final void run(){ + Utils.LOG_INFO("[Custom] Trying to initialise custom materials."); + } + + private final static boolean registerMaterial(Materials r){ + Custom_GT_Materials.add(r); + Utils.LOG_INFO("[Custom] Registered new Gregtech material - "+r.mName); + return true; + } + + public final static Materials materialBuilder(int ID, TextureSet texture, int[] rgb, String materialName, Dyes dyeColour, List composition){ + Materials newMat = new Materials( + ID, + texture, + 1.0F, + 0, + 2, + 1 |8 , + rgb[0], rgb[1], rgb[2], 0, + materialName, materialName, + 0, 0, -1, 0, false, false, 3, 1, 1, + dyeColour, + 1, + composition + ); + registerMaterial(newMat); + return newMat; + } + + public final static Materials materialBuilder_Element( + int ID, TextureSet texture, + float a, int b, int c, + int d, int r2, int g2, int b2, int a2, + String materialName, String e, + int f, int g, int h, int i, + boolean j, boolean k, + int l, int m, int n, + Dyes dyeColour, Element o, + List aspects){ + Materials newMat = new Materials( + ID, texture, + a, b, c, + d, r2, g2, b2, a2, + materialName, e, + f, g, h, i, j, k, l, m, n, + dyeColour, o, + aspects + ); + registerMaterial(newMat); + return newMat; + } + */ } diff --git a/src/main/java/gtPlusPlus/core/material/nuclear/FLUORIDES.java b/src/main/java/gtPlusPlus/core/material/nuclear/FLUORIDES.java index d5c6e4a6bf..55e2b95535 100644 --- a/src/main/java/gtPlusPlus/core/material/nuclear/FLUORIDES.java +++ b/src/main/java/gtPlusPlus/core/material/nuclear/FLUORIDES.java @@ -9,276 +9,270 @@ import gtPlusPlus.core.material.state.MaterialState; public class FLUORIDES { - public static final Material FLUORITE = new Material( - "Fluorite (F)", //Material Name - MaterialState.ORE, //State - null, //Material Colour - Materials.Fluorine.mMeltingPoint, //Melting Point in C - Materials.Fluorine.mBlastFurnaceTemp, //Boiling Point in C - -1, //Protons - -1, //Neutrons - false, //Uses Blast furnace? - false, //Generate cells - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().CALCIUM, 16), - new MaterialStack(ELEMENT.getInstance().FLUORINE, 32), - new MaterialStack(ELEMENT.getInstance().IRON, 4), - new MaterialStack(ELEMENT.getInstance().CARBON, 2) - }); + public static final Material FLUORITE = new Material( + "Fluorite (F)", // Material Name + MaterialState.ORE, // State + null, // Material Colour + Materials.Fluorine.mMeltingPoint, // Melting Point in C + Materials.Fluorine.mBlastFurnaceTemp, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + false, // Generate cells + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().CALCIUM, 16), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 32), + new MaterialStack(ELEMENT.getInstance().IRON, 4), + new MaterialStack(ELEMENT.getInstance().CARBON, 2) + }); - //ThF4 - public static final Material THORIUM_TETRAFLUORIDE = new Material( - "Thorium Tetrafluoride", //Material Name - MaterialState.LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, //Neutrons - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().THORIUM232, 1), - new MaterialStack(ELEMENT.getInstance().FLUORINE, 4) - }); + // ThF4 + public static final Material THORIUM_TETRAFLUORIDE = new Material( + "Thorium Tetrafluoride", // Material Name + MaterialState.LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().THORIUM232, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 4) + }); - //ThF6 - public static final Material THORIUM_HEXAFLUORIDE = new Material( - "Thorium Hexafluoride", //Material Name - MaterialState.LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, //Neutrons - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().THORIUM232, 1), - new MaterialStack(ELEMENT.getInstance().THORIUM, 1), - new MaterialStack(ELEMENT.getInstance().FLUORINE, 12) - }); + // ThF6 + public static final Material THORIUM_HEXAFLUORIDE = new Material( + "Thorium Hexafluoride", // Material Name + MaterialState.LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().THORIUM232, 1), + new MaterialStack(ELEMENT.getInstance().THORIUM, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 12) + }); - //UF4 - public static final Material URANIUM_TETRAFLUORIDE = new Material( - "Uranium Tetrafluoride", //Material Name - MaterialState.LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, //Neutrons - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().URANIUM233, 1), - new MaterialStack(ELEMENT.getInstance().FLUORINE, 4) - }); + // UF4 + public static final Material URANIUM_TETRAFLUORIDE = new Material( + "Uranium Tetrafluoride", // Material Name + MaterialState.LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().URANIUM233, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 4) + }); - //UF6 - public static final Material URANIUM_HEXAFLUORIDE = new Material( - "Uranium Hexafluoride", //Material Name - MaterialState.LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, //Neutrons - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(FLUORIDES.URANIUM_TETRAFLUORIDE, 1), - new MaterialStack(ELEMENT.getInstance().FLUORINE, 2) - }); + // UF6 + public static final Material URANIUM_HEXAFLUORIDE = new Material( + "Uranium Hexafluoride", // Material Name + MaterialState.LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(FLUORIDES.URANIUM_TETRAFLUORIDE, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 2) + }); - //ZrF4 - - public static final Material ZIRCONIUM_TETRAFLUORIDE = new Material( - "Zirconium Tetrafluoride", //Material Name - MaterialState.LIQUID, //State - null, //Texture Set (Autogenerated) - 0, - null, //Material Colour - -1, - -1, - -1, - -1, - false, - "ZrF4", - -1, - true, - false, - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().ZIRCONIUM, 1), - new MaterialStack(ELEMENT.getInstance().FLUORINE, 4) - }); - + // ZrF4 - -/* public static final Material ZIRCONIUM_TETRAFLUORIDE = new Material( - "Zirconium Tetrafluoride", //Material Name - MaterialState.LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, //Neutrons - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().ZIRCONIUM, 1), - new MaterialStack(ELEMENT.getInstance().FLUORINE, 4) - });*/ + public static final Material ZIRCONIUM_TETRAFLUORIDE = new Material( + "Zirconium Tetrafluoride", // Material Name + MaterialState.LIQUID, // State + null, // Texture Set (Autogenerated) + 0, + null, // Material Colour + -1, + -1, + -1, + -1, + false, + "ZrF4", + -1, + true, + false, + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().ZIRCONIUM, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 4) + }); - //BeF2 - public static final Material BERYLLIUM_FLUORIDE = new Material( - "Beryllium Fluoride", //Material Name - MaterialState.LIQUID, //State - null, //Material Colour - -1, - -1, - -1, - -1, - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().BERYLLIUM, 1), - new MaterialStack(ELEMENT.getInstance().FLUORINE, 2) - }); + /* public static final Material ZIRCONIUM_TETRAFLUORIDE = new Material( + "Zirconium Tetrafluoride", //Material Name + MaterialState.LIQUID, //State + null, //Material Colour + -1, //Melting Point in C + -1, //Boiling Point in C + -1, //Protons + -1, //Neutrons + false, //Uses Blast furnace? + //Material Stacks with Percentage of required elements. + new MaterialStack[]{ + new MaterialStack(ELEMENT.getInstance().ZIRCONIUM, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 4) + });*/ - //LiF - public static final Material LITHIUM_FLUORIDE = new Material( - "Lithium Fluoride", //Material Name - MaterialState.LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, //Neutrons - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().LITHIUM7, 1), - new MaterialStack(ELEMENT.getInstance().FLUORINE, 1) - }); + // BeF2 + public static final Material BERYLLIUM_FLUORIDE = new Material( + "Beryllium Fluoride", // Material Name + MaterialState.LIQUID, // State + null, // Material Colour + -1, + -1, + -1, + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().BERYLLIUM, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 2) + }); + // LiF + public static final Material LITHIUM_FLUORIDE = new Material( + "Lithium Fluoride", // Material Name + MaterialState.LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().LITHIUM7, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 1) + }); - //LFTR sub components - - //(NH4)HF2 - public static final Material AMMONIUM_BIFLUORIDE = new Material( - "Ammonium Bifluoride", //Material Name - MaterialState.PURE_LIQUID, //State - null, //Material Colour - 126, //Melting Point in C - 240, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(MISC_MATERIALS.AMMONIUM, 1), - new MaterialStack(ELEMENT.getInstance().HYDROGEN, 1), - new MaterialStack(ELEMENT.getInstance().FLUORINE, 2) - }); - - //Be(OH)2 - public static final Material BERYLLIUM_HYDROXIDE = new Material( - "Beryllium Hydroxide", //Material Name - MaterialState.PURE_LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, //Neutrons - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().BERYLLIUM, 1), - new MaterialStack(MISC_MATERIALS.HYDROXIDE, 2) - }); - - // (NH4)2Be(OH)2 / (NH4)2BeF4 - public static final Material AMMONIUM_TETRAFLUOROBERYLLATE = new Material( - "Ammonium Tetrafluoroberyllate", //Material Name - MaterialState.PURE_LIQUID, //State - null, //Material Colour - 280, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(MISC_MATERIALS.AMMONIUM, 2), - new MaterialStack(FLUORIDES.BERYLLIUM_HYDROXIDE, 1) - }); - - - - //LFTR Output - public static final Material NEPTUNIUM_HEXAFLUORIDE = new Material( - "Neptunium Hexafluoride", //Material Name - MaterialState.GAS, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, //Neutrons - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().NEPTUNIUM, 1), - new MaterialStack(ELEMENT.getInstance().FLUORINE, 6) - }); + // LFTR sub components - public static final Material TECHNETIUM_HEXAFLUORIDE = new Material( - "Technetium Hexafluoride", //Material Name - MaterialState.GAS, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, //Neutrons - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().TECHNETIUM, 1), - new MaterialStack(ELEMENT.getInstance().FLUORINE, 6) - }); + // (NH4)HF2 + public static final Material AMMONIUM_BIFLUORIDE = new Material( + "Ammonium Bifluoride", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + 126, // Melting Point in C + 240, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(MISC_MATERIALS.AMMONIUM, 1), + new MaterialStack(ELEMENT.getInstance().HYDROGEN, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 2) + }); - public static final Material SELENIUM_HEXAFLUORIDE = new Material( - "Selenium Hexafluoride", //Material Name - MaterialState.GAS, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, //Neutrons - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().SELENIUM, 1), - new MaterialStack(ELEMENT.getInstance().FLUORINE, 6) - }); - - public static final Material SODIUM_FLUORIDE = new Material( - "Sodium Fluoride", //Material Name - MaterialState.PURE_LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, //Neutrons - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().SODIUM, 1), - new MaterialStack(ELEMENT.getInstance().FLUORINE, 1) - }); + // Be(OH)2 + public static final Material BERYLLIUM_HYDROXIDE = new Material( + "Beryllium Hydroxide", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().BERYLLIUM, 1), new MaterialStack(MISC_MATERIALS.HYDROXIDE, 2) + }); - private static final FLUORIDES INSTANCE = new FLUORIDES(); - public static FLUORIDES getInstance(){return INSTANCE;} + // (NH4)2Be(OH)2 / (NH4)2BeF4 + public static final Material AMMONIUM_TETRAFLUOROBERYLLATE = new Material( + "Ammonium Tetrafluoroberyllate", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + 280, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(MISC_MATERIALS.AMMONIUM, 2), new MaterialStack(FLUORIDES.BERYLLIUM_HYDROXIDE, 1) + }); + // LFTR Output + public static final Material NEPTUNIUM_HEXAFLUORIDE = new Material( + "Neptunium Hexafluoride", // Material Name + MaterialState.GAS, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().NEPTUNIUM, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 6) + }); + + public static final Material TECHNETIUM_HEXAFLUORIDE = new Material( + "Technetium Hexafluoride", // Material Name + MaterialState.GAS, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().TECHNETIUM, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 6) + }); + + public static final Material SELENIUM_HEXAFLUORIDE = new Material( + "Selenium Hexafluoride", // Material Name + MaterialState.GAS, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().SELENIUM, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 6) + }); + + public static final Material SODIUM_FLUORIDE = new Material( + "Sodium Fluoride", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().SODIUM, 1), new MaterialStack(ELEMENT.getInstance().FLUORINE, 1) + }); + + private static final FLUORIDES INSTANCE = new FLUORIDES(); + + public static FLUORIDES getInstance() { + return INSTANCE; + } } diff --git a/src/main/java/gtPlusPlus/core/material/nuclear/NUCLIDE.java b/src/main/java/gtPlusPlus/core/material/nuclear/NUCLIDE.java index eaa5a87d09..549d3b4a88 100644 --- a/src/main/java/gtPlusPlus/core/material/nuclear/NUCLIDE.java +++ b/src/main/java/gtPlusPlus/core/material/nuclear/NUCLIDE.java @@ -7,370 +7,342 @@ import gtPlusPlus.core.material.MaterialStack; import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.util.data.StringUtils; - public final class NUCLIDE { - public static final Material Li2BeF4 = new Material( - "Lithium Tetrafluoroberyllate (LFTB)", //Material Name - MaterialState.LIQUID, //State - TextureSets.NUCLEAR.get(), - null, //Material Colour - 566, //Melting Point in C - 870, //Boiling Point in C - -1, //Protons - -1, //Neutrons - false, //Uses Blast furnace? - StringUtils.subscript(StringUtils.superscript("7")+"Li2BeF4"), //Chemical Formula - 4, //Radioactivity Level - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 2), - new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 1) - }); - - public static final Material LiFBeF2ThF4UF4 = new Material( - "LFTR Fuel 3", //Material Name - MaterialState.LIQUID, //State - TextureSets.NUCLEAR.get(), - null, //Material Colour - 566, //Melting Point in C - 870, //Boiling Point in C - -1, //Protons - -1, //Neutrons - false, //Uses Blast furnace? - StringUtils.subscript(StringUtils.superscript("7")+"LiFBeF2ThF4UF4"), //Chemical Formula - 5, //Radioactivity Level - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 65), - new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 28), - new MaterialStack(FLUORIDES.THORIUM_TETRAFLUORIDE, 1), - new MaterialStack(FLUORIDES.URANIUM_TETRAFLUORIDE, 1) - }); - - public static final Material LiFBeF2ZrF4UF4 = new Material( - "LFTR Fuel 2", //Material Name - MaterialState.LIQUID, //State - TextureSets.NUCLEAR.get(), - null, //Material Colour - 650, //Melting Point in C - 940, //Boiling Point in C - -1, //Protons - -1, //Neutrons - false, //Uses Blast furnace? - StringUtils.subscript(StringUtils.superscript("7")+"LiFBeF2ZrF4UF4"), //Chemical Formula - 5, //Radioactivity Level - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 65), - new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 28), - new MaterialStack(FLUORIDES.ZIRCONIUM_TETRAFLUORIDE, 5), - new MaterialStack(FLUORIDES.URANIUM_TETRAFLUORIDE, 2) - }); + public static final Material Li2BeF4 = new Material( + "Lithium Tetrafluoroberyllate (LFTB)", // Material Name + MaterialState.LIQUID, // State + TextureSets.NUCLEAR.get(), + null, // Material Colour + 566, // Melting Point in C + 870, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript(StringUtils.superscript("7") + "Li2BeF4"), // Chemical Formula + 4, // Radioactivity Level + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 2), new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 1) + }); + + public static final Material LiFBeF2ThF4UF4 = new Material( + "LFTR Fuel 3", // Material Name + MaterialState.LIQUID, // State + TextureSets.NUCLEAR.get(), + null, // Material Colour + 566, // Melting Point in C + 870, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript(StringUtils.superscript("7") + "LiFBeF2ThF4UF4"), // Chemical Formula + 5, // Radioactivity Level + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 65), + new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 28), + new MaterialStack(FLUORIDES.THORIUM_TETRAFLUORIDE, 1), + new MaterialStack(FLUORIDES.URANIUM_TETRAFLUORIDE, 1) + }); + + public static final Material LiFBeF2ZrF4UF4 = new Material( + "LFTR Fuel 2", // Material Name + MaterialState.LIQUID, // State + TextureSets.NUCLEAR.get(), + null, // Material Colour + 650, // Melting Point in C + 940, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript(StringUtils.superscript("7") + "LiFBeF2ZrF4UF4"), // Chemical Formula + 5, // Radioactivity Level + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 65), + new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 28), + new MaterialStack(FLUORIDES.ZIRCONIUM_TETRAFLUORIDE, 5), + new MaterialStack(FLUORIDES.URANIUM_TETRAFLUORIDE, 2) + }); + + public static final Material LiFBeF2ZrF4U235 = new Material( + "LFTR Fuel 1", // Material Name + MaterialState.LIQUID, // State + TextureSets.NUCLEAR.get(), + null, // Material Colour + 590, // Melting Point in C + 890, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript(StringUtils.superscript("7") + "LiFBeF2ZrF4") + + StringUtils.superscript("235U"), // Chemical Formula + 5, // Radioactivity Level + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 55), + new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 25), + new MaterialStack(FLUORIDES.ZIRCONIUM_TETRAFLUORIDE, 6), + new MaterialStack(ELEMENT.getInstance().URANIUM235, 14) + }); + + // Misc + public static final Material BurntLftrFuel_MK1 = new Material( + "Burnt Reactor Fuel I", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript(StringUtils.superscript("7") + "LiBeF2UF4FP"), // Chemical Formula + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().LITHIUM, 1), + new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 1), + new MaterialStack(FLUORIDES.URANIUM_TETRAFLUORIDE, 1), + new MaterialStack(ELEMENT.getInstance().PROTACTINIUM, 1) + }); + + public static final Material BurntLftrFuel_MK2 = new Material( + "Burnt Reactor Fuel II", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript(StringUtils.superscript("7") + "LiBeF2UF4FP"), // Chemical Formula + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().LITHIUM, 1), + new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 1), + new MaterialStack(FLUORIDES.URANIUM_TETRAFLUORIDE, 1), + new MaterialStack(ELEMENT.getInstance().PROTACTINIUM, 1) + }); + + // LFTR Core Fluids + public static final Material LiFBeF2UF4FP = new Material( + "Uranium Depleted Molten Salt (U Salt)", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript(StringUtils.superscript("7") + "LiFBeF2UF4FP"), // Chemical Formula + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 1), + new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 1), + new MaterialStack(FLUORIDES.URANIUM_TETRAFLUORIDE, 1), + new MaterialStack(ELEMENT.getInstance().PROTACTINIUM, 1) + }); + + public static final Material Sparged_LiFBeF2UF4FP = new Material( + "Helium Sparged U Salt", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript(StringUtils.superscript("7") + "LiFBeF2UF4FP"), // Chemical Formula + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 1), + new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 1), + new MaterialStack(FLUORIDES.URANIUM_TETRAFLUORIDE, 1), + new MaterialStack(ELEMENT.getInstance().PROTACTINIUM, 1) + }); + + public static final Material UF6F2FP = new Material( + "Phosphorous Uranium Hexafluoride (P-UF6)", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript("UF6F2FP"), // Chemical Formula + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(FLUORIDES.URANIUM_HEXAFLUORIDE, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 3), + new MaterialStack(ELEMENT.getInstance().PHOSPHORUS, 1) + }); + + public static final Material LiFBeF2 = new Material( + "Stable Molten Salt Base", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript(StringUtils.superscript("7") + "LiFBeF2"), // Chemical Formula + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 1), new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 1) + }); + + public static final Material LiFBeF2UF4 = new Material( + "LFTR Fuel Base", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript(StringUtils.superscript("7") + "LiFBeF2UF4"), // Chemical Formula + // Material Stacks with Percentage of required elements. + new MaterialStack[] {new MaterialStack(LiFBeF2, 1), new MaterialStack(FLUORIDES.URANIUM_TETRAFLUORIDE, 1)}); + + // LFTR Blanket Fluids + + // Tier 1 Fuel blanket output + public static final Material LiFThF4 = new Material( + "Thorium Depleted Molten Salt (T Salt)", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript(StringUtils.superscript("7") + "LiFThF4"), // Chemical Formula + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 1), new MaterialStack(FLUORIDES.THORIUM_TETRAFLUORIDE, 1) + }); + + // Tier 2 Fuel blanket output + public static final Material LiFBeF2ThF4 = new Material( + "Thorium-Beryllium Depleted Molten Salt (TB Salt)", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript(StringUtils.superscript("7") + "LiFBeF2ThF4"), // Chemical Formula + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 1), + new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 1), + new MaterialStack(FLUORIDES.THORIUM_TETRAFLUORIDE, 1) + }); + + // Tier 1 Fuel blanket output + public static final Material Sparged_LiFThF4 = new Material( + "Fluorine Sparged T Salt", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript(StringUtils.superscript("7") + "LiFThF4"), // Chemical Formula + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 1), new MaterialStack(FLUORIDES.THORIUM_TETRAFLUORIDE, 1) + }); - public static final Material LiFBeF2ZrF4U235 = new Material( - "LFTR Fuel 1", //Material Name - MaterialState.LIQUID, //State - TextureSets.NUCLEAR.get(), - null, //Material Colour - 590, //Melting Point in C - 890, //Boiling Point in C - -1, //Protons - -1, //Neutrons - false, //Uses Blast furnace? - StringUtils.subscript(StringUtils.superscript("7")+"LiFBeF2ZrF4")+StringUtils.superscript("235U"), //Chemical Formula - 5, //Radioactivity Level - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 55), - new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 25), - new MaterialStack(FLUORIDES.ZIRCONIUM_TETRAFLUORIDE, 6), - new MaterialStack(ELEMENT.getInstance().URANIUM235, 14) - }); - - // Misc - public static final Material BurntLftrFuel_MK1 = new Material( - "Burnt Reactor Fuel I", //Material Name - MaterialState.PURE_LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, //Neutrons - false, //Uses Blast furnace? - StringUtils.subscript(StringUtils.superscript("7")+"LiBeF2UF4FP"), //Chemical Formula - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().LITHIUM, 1), - new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 1), - new MaterialStack(FLUORIDES.URANIUM_TETRAFLUORIDE, 1), - new MaterialStack(ELEMENT.getInstance().PROTACTINIUM, 1) - }); - - public static final Material BurntLftrFuel_MK2 = new Material( - "Burnt Reactor Fuel II", //Material Name - MaterialState.PURE_LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, //Neutrons - false, //Uses Blast furnace? - StringUtils.subscript(StringUtils.superscript("7")+"LiBeF2UF4FP"), //Chemical Formula - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().LITHIUM, 1), - new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 1), - new MaterialStack(FLUORIDES.URANIUM_TETRAFLUORIDE, 1), - new MaterialStack(ELEMENT.getInstance().PROTACTINIUM, 1) - }); - - - - // LFTR Core Fluids - public static final Material LiFBeF2UF4FP = new Material( - "Uranium Depleted Molten Salt (U Salt)", //Material Name - MaterialState.PURE_LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, //Neutrons - false, //Uses Blast furnace? - StringUtils.subscript(StringUtils.superscript("7")+"LiFBeF2UF4FP"), //Chemical Formula - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 1), - new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 1), - new MaterialStack(FLUORIDES.URANIUM_TETRAFLUORIDE, 1), - new MaterialStack(ELEMENT.getInstance().PROTACTINIUM, 1) - }); - - public static final Material Sparged_LiFBeF2UF4FP = new Material( - "Helium Sparged U Salt", //Material Name - MaterialState.PURE_LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, //Neutrons - false, //Uses Blast furnace? - StringUtils.subscript(StringUtils.superscript("7")+"LiFBeF2UF4FP"), //Chemical Formula - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 1), - new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 1), - new MaterialStack(FLUORIDES.URANIUM_TETRAFLUORIDE, 1), - new MaterialStack(ELEMENT.getInstance().PROTACTINIUM, 1) - }); - - public static final Material UF6F2FP = new Material( - "Phosphorous Uranium Hexafluoride (P-UF6)", //Material Name - MaterialState.PURE_LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, //Neutrons - false, //Uses Blast furnace? - StringUtils.subscript("UF6F2FP"), //Chemical Formula - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(FLUORIDES.URANIUM_HEXAFLUORIDE, 1), - new MaterialStack(ELEMENT.getInstance().FLUORINE, 3), - new MaterialStack(ELEMENT.getInstance().PHOSPHORUS, 1) - }); - - public static final Material LiFBeF2 = new Material( - "Stable Molten Salt Base", //Material Name - MaterialState.PURE_LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, //Neutrons - false, //Uses Blast furnace? - StringUtils.subscript(StringUtils.superscript("7")+"LiFBeF2"), //Chemical Formula - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 1), - new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 1) - }); - - public static final Material LiFBeF2UF4 = new Material( - "LFTR Fuel Base", //Material Name - MaterialState.PURE_LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, //Neutrons - false, //Uses Blast furnace? - StringUtils.subscript(StringUtils.superscript("7")+"LiFBeF2UF4"), //Chemical Formula - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(LiFBeF2, 1), - new MaterialStack(FLUORIDES.URANIUM_TETRAFLUORIDE, 1) - }); - - - - - - - // LFTR Blanket Fluids + // Tier 2 Fuel blanket output + public static final Material Sparged_LiFBeF2ThF4 = new Material( + "Fluorine Sparged TB Salt", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript(StringUtils.superscript("7") + "LiFBeF2ThF4"), // Chemical Formula + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 1), + new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 1), + new MaterialStack(FLUORIDES.THORIUM_TETRAFLUORIDE, 1) + }); - // Tier 1 Fuel blanket output - public static final Material LiFThF4 = new Material( - "Thorium Depleted Molten Salt (T Salt)", //Material Name - MaterialState.PURE_LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, //Neutrons - false, //Uses Blast furnace? - StringUtils.subscript(StringUtils.superscript("7")+"LiFThF4"), //Chemical Formula - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 1), - new MaterialStack(FLUORIDES.THORIUM_TETRAFLUORIDE, 1) - }); - - // Tier 2 Fuel blanket output - public static final Material LiFBeF2ThF4 = new Material( - "Thorium-Beryllium Depleted Molten Salt (TB Salt)", //Material Name - MaterialState.PURE_LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, //Neutrons - false, //Uses Blast furnace? - StringUtils.subscript(StringUtils.superscript("7")+"LiFBeF2ThF4"), //Chemical Formula - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 1), - new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 1), - new MaterialStack(FLUORIDES.THORIUM_TETRAFLUORIDE, 1) - }); - - // Tier 1 Fuel blanket output - public static final Material Sparged_LiFThF4 = new Material( - "Fluorine Sparged T Salt", //Material Name - MaterialState.PURE_LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, //Neutrons - false, //Uses Blast furnace? - StringUtils.subscript(StringUtils.superscript("7")+"LiFThF4"), //Chemical Formula - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 1), - new MaterialStack(FLUORIDES.THORIUM_TETRAFLUORIDE, 1) - }); - - // Tier 2 Fuel blanket output - public static final Material Sparged_LiFBeF2ThF4 = new Material( - "Fluorine Sparged TB Salt", //Material Name - MaterialState.PURE_LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, //Neutrons - false, //Uses Blast furnace? - StringUtils.subscript(StringUtils.superscript("7")+"LiFBeF2ThF4"), //Chemical Formula - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(FLUORIDES.LITHIUM_FLUORIDE, 1), - new MaterialStack(FLUORIDES.BERYLLIUM_FLUORIDE, 1), - new MaterialStack(FLUORIDES.THORIUM_TETRAFLUORIDE, 1) - }); - - public static final Material UF6F2 = new Material( - "Fluorinated Uranium Hexafluoride (F-UF6)", //Material Name - MaterialState.PURE_LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, //Neutrons - false, //Uses Blast furnace? - StringUtils.subscript("UF6F2"), //Chemical Formula - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(FLUORIDES.URANIUM_HEXAFLUORIDE, 1), - new MaterialStack(ELEMENT.getInstance().FLUORINE, 2) - }); - - - - - - - - - - - + public static final Material UF6F2 = new Material( + "Fluorinated Uranium Hexafluoride (F-UF6)", // Material Name + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, // Neutrons + false, // Uses Blast furnace? + StringUtils.subscript("UF6F2"), // Chemical Formula + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(FLUORIDES.URANIUM_HEXAFLUORIDE, 1), + new MaterialStack(ELEMENT.getInstance().FLUORINE, 2) + }); - // Secondary material is molten metal - public static final Material NAQ_FUEL_T1 = new Material( - "Naquadah Fuel", - MaterialState.PURE_LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().NAQUADAH, 2), - new MaterialStack(ELEMENT.getInstance().TANTALUM, 3) - }); + // Secondary material is molten metal + public static final Material NAQ_FUEL_T1 = new Material( + "Naquadah Fuel", + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().NAQUADAH, 2), + new MaterialStack(ELEMENT.getInstance().TANTALUM, 3) + }); - // Secondary material is a plasma - public static final Material NAQ_FUEL_T2 = new Material( - "Enriched Naquadah Fuel", - MaterialState.PURE_LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().NAQUADAH_ENRICHED, 2), - new MaterialStack(ELEMENT.getInstance().TITANIUM, 3) - }); - - // Secondary material is a plasma - public static final Material NAQ_FUEL_T3 = new Material( - "Naquadria Fuel", - MaterialState.PURE_LIQUID, //State - null, //Material Colour - -1, //Melting Point in C - -1, //Boiling Point in C - -1, //Protons - -1, - false, //Uses Blast furnace? - //Material Stacks with Percentage of required elements. - new MaterialStack[]{ - new MaterialStack(ELEMENT.getInstance().NAQUADRIA, 2), - new MaterialStack(ELEMENT.getInstance().AMERICIUM, 3) - }); - + // Secondary material is a plasma + public static final Material NAQ_FUEL_T2 = new Material( + "Enriched Naquadah Fuel", + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().NAQUADAH_ENRICHED, 2), + new MaterialStack(ELEMENT.getInstance().TITANIUM, 3) + }); + // Secondary material is a plasma + public static final Material NAQ_FUEL_T3 = new Material( + "Naquadria Fuel", + MaterialState.PURE_LIQUID, // State + null, // Material Colour + -1, // Melting Point in C + -1, // Boiling Point in C + -1, // Protons + -1, + false, // Uses Blast furnace? + // Material Stacks with Percentage of required elements. + new MaterialStack[] { + new MaterialStack(ELEMENT.getInstance().NAQUADRIA, 2), + new MaterialStack(ELEMENT.getInstance().AMERICIUM, 3) + }); - private static final NUCLIDE INSTANCE = new NUCLIDE(); - - public static NUCLIDE getInstance(){ - return INSTANCE; - } + private static final NUCLIDE INSTANCE = new NUCLIDE(); + public static NUCLIDE getInstance() { + return INSTANCE; + } } diff --git a/src/main/java/gtPlusPlus/core/material/state/MaterialState.java b/src/main/java/gtPlusPlus/core/material/state/MaterialState.java index 460fe019dc..5b48907656 100644 --- a/src/main/java/gtPlusPlus/core/material/state/MaterialState.java +++ b/src/main/java/gtPlusPlus/core/material/state/MaterialState.java @@ -1,18 +1,20 @@ package gtPlusPlus.core.material.state; public enum MaterialState { - SOLID(0), - LIQUID(1), - GAS(2), - PLASMA(3), - PURE_LIQUID(4), - ORE(5), - PURE_GAS(6); - private int STATE; - private MaterialState (final int State){ - this.STATE = State; - } - public int ID() { - return this.STATE; - } + SOLID(0), + LIQUID(1), + GAS(2), + PLASMA(3), + PURE_LIQUID(4), + ORE(5), + PURE_GAS(6); + private int STATE; + + private MaterialState(final int State) { + this.STATE = State; + } + + public int ID() { + return this.STATE; + } } diff --git a/src/main/java/gtPlusPlus/core/network/handler/AbstractClientMessageHandler.java b/src/main/java/gtPlusPlus/core/network/handler/AbstractClientMessageHandler.java index b7ced2f7e9..548809261f 100644 --- a/src/main/java/gtPlusPlus/core/network/handler/AbstractClientMessageHandler.java +++ b/src/main/java/gtPlusPlus/core/network/handler/AbstractClientMessageHandler.java @@ -5,9 +5,8 @@ import cpw.mods.fml.common.network.simpleimpl.MessageContext; import net.minecraft.entity.player.EntityPlayer; public abstract class AbstractClientMessageHandler extends AbstractMessageHandler { - - public final IMessage handleServerMessage(EntityPlayer player, T message, MessageContext ctx) { - return null; - } - + + public final IMessage handleServerMessage(EntityPlayer player, T message, MessageContext ctx) { + return null; + } } diff --git a/src/main/java/gtPlusPlus/core/network/handler/AbstractMessageHandler.java b/src/main/java/gtPlusPlus/core/network/handler/AbstractMessageHandler.java index ca350f220f..3c60855c97 100644 --- a/src/main/java/gtPlusPlus/core/network/handler/AbstractMessageHandler.java +++ b/src/main/java/gtPlusPlus/core/network/handler/AbstractMessageHandler.java @@ -8,30 +8,27 @@ import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.GTplusplus; import net.minecraft.entity.player.EntityPlayer; -public abstract class AbstractMessageHandler implements IMessageHandler -{ - /** - * Handle a message received on the client side - * @return a message to send back to the Server, or null if no reply is necessary - */ - @SideOnly(Side.CLIENT) - public abstract IMessage handleClientMessage(EntityPlayer player, T message, MessageContext ctx); - - /** - * Handle a message received on the server side - * @return a message to send back to the Client, or null if no reply is necessary - */ - public abstract IMessage handleServerMessage(EntityPlayer player, T message, MessageContext ctx); - - @Override - public IMessage onMessage(T message, MessageContext ctx) { - if (ctx.side.isClient()) { - return handleClientMessage(GTplusplus.proxy.getPlayerEntity(ctx), message, ctx); - } else { - // server side proxy will return the server side EntityPlayer - return handleServerMessage(GTplusplus.proxy.getPlayerEntity(ctx), message, ctx); - } - } +public abstract class AbstractMessageHandler implements IMessageHandler { + /** + * Handle a message received on the client side + * @return a message to send back to the Server, or null if no reply is necessary + */ + @SideOnly(Side.CLIENT) + public abstract IMessage handleClientMessage(EntityPlayer player, T message, MessageContext ctx); + /** + * Handle a message received on the server side + * @return a message to send back to the Client, or null if no reply is necessary + */ + public abstract IMessage handleServerMessage(EntityPlayer player, T message, MessageContext ctx); + @Override + public IMessage onMessage(T message, MessageContext ctx) { + if (ctx.side.isClient()) { + return handleClientMessage(GTplusplus.proxy.getPlayerEntity(ctx), message, ctx); + } else { + // server side proxy will return the server side EntityPlayer + return handleServerMessage(GTplusplus.proxy.getPlayerEntity(ctx), message, ctx); + } + } } diff --git a/src/main/java/gtPlusPlus/core/network/handler/AbstractServerMessageHandler.java b/src/main/java/gtPlusPlus/core/network/handler/AbstractServerMessageHandler.java index d49e6cf350..1529c636ec 100644 --- a/src/main/java/gtPlusPlus/core/network/handler/AbstractServerMessageHandler.java +++ b/src/main/java/gtPlusPlus/core/network/handler/AbstractServerMessageHandler.java @@ -6,8 +6,7 @@ import net.minecraft.entity.player.EntityPlayer; public abstract class AbstractServerMessageHandler extends AbstractMessageHandler { - public final IMessage handleClientMessage(EntityPlayer player, T message, MessageContext ctx) { - return null; - } - + public final IMessage handleClientMessage(EntityPlayer player, T message, MessageContext ctx) { + return null; + } } diff --git a/src/main/java/gtPlusPlus/core/network/packet/AbstractPacket.java b/src/main/java/gtPlusPlus/core/network/packet/AbstractPacket.java index d6368e3d9e..ef43795206 100644 --- a/src/main/java/gtPlusPlus/core/network/packet/AbstractPacket.java +++ b/src/main/java/gtPlusPlus/core/network/packet/AbstractPacket.java @@ -4,6 +4,5 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage; public interface AbstractPacket extends IMessage { - public abstract String getPacketName(); - + public abstract String getPacketName(); } diff --git a/src/main/java/gtPlusPlus/core/network/packet/Packet_VolumetricFlaskGui.java b/src/main/java/gtPlusPlus/core/network/packet/Packet_VolumetricFlaskGui.java index 609ea729b7..87c9018a94 100644 --- a/src/main/java/gtPlusPlus/core/network/packet/Packet_VolumetricFlaskGui.java +++ b/src/main/java/gtPlusPlus/core/network/packet/Packet_VolumetricFlaskGui.java @@ -12,117 +12,115 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -public class Packet_VolumetricFlaskGui extends AbstractServerMessageHandler implements AbstractPacket { - - private int x; - private int y; - private int z; - private int flaskValue; - - public Packet_VolumetricFlaskGui() { - - } - - public Packet_VolumetricFlaskGui(TileEntityVolumetricFlaskSetter tile, int aCustomValue) { - x = tile.xCoord; - y = tile.yCoord; - z = tile.zCoord; - flaskValue = aCustomValue; - Logger.INFO("Created Packet with values ("+x+", "+y+", "+z+" | "+flaskValue+")"); - } - - @Override - public void toBytes(ByteBuf buf) { - buf.writeInt(x); - buf.writeInt(y); - buf.writeInt(z); - buf.writeInt(flaskValue); - Logger.INFO("Writing to byte buffer."); - } - - @Override - public void fromBytes(ByteBuf buf) { - x = buf.readInt(); - y = buf.readInt(); - z = buf.readInt(); - flaskValue = buf.readInt(); - Logger.INFO("Reading from byte buffer."); - } - - public int getX() { - return x; - } - - public void setX(int x) { - this.x = x; - } - - public int getY() { - return y; - } - - public void setY(int y) { - this.y = y; - } - - public int getZ() { - return z; - } - - public void setZ(int z) { - this.z = z; - } - - public int getCustomValue() { - return flaskValue; - } - - public void setCustomValue(int aVal) { - this.flaskValue = aVal; - } - - protected TileEntityVolumetricFlaskSetter getTileEntity(Packet_VolumetricFlaskGui message, MessageContext ctx) { - Logger.INFO("Trying to get tile."); - World worldObj = getWorld(ctx); - if(worldObj == null) { - Logger.INFO("Bad world object."); - return null; - } - TileEntity te = worldObj.getTileEntity(message.getX(), message.getY(), message.getZ()); - if(te == null) { - Logger.INFO("Bad Tile."); - return null; - } - if(te instanceof TileEntityVolumetricFlaskSetter) { - Logger.INFO("Found Tile."); - return (TileEntityVolumetricFlaskSetter) te; - } - Logger.INFO("Error."); - return null; - } - - protected World getWorld(MessageContext ctx) { - if(ctx.side == Side.SERVER) { - return ctx.getServerHandler().playerEntity.worldObj; - } else { - return GTplusplus.proxy.getClientWorld(); - } - } - - @Override - public IMessage handleServerMessage(EntityPlayer player, Packet_VolumetricFlaskGui message, MessageContext ctx) { - TileEntityVolumetricFlaskSetter te = getTileEntity(message, ctx); - if(te != null) { - Logger.INFO("Setting value on tile. "+message.getCustomValue()); - te.setCustomValue(message.getCustomValue()); - //return new Packet_VolumetricFlaskGui2(te, message.getCustomValue()); - } - return null; - } - - @Override - public String getPacketName() { - return "Packet_VoluemtricFlaskSetter_ToServer"; - } - +public class Packet_VolumetricFlaskGui extends AbstractServerMessageHandler + implements AbstractPacket { + + private int x; + private int y; + private int z; + private int flaskValue; + + public Packet_VolumetricFlaskGui() {} + + public Packet_VolumetricFlaskGui(TileEntityVolumetricFlaskSetter tile, int aCustomValue) { + x = tile.xCoord; + y = tile.yCoord; + z = tile.zCoord; + flaskValue = aCustomValue; + Logger.INFO("Created Packet with values (" + x + ", " + y + ", " + z + " | " + flaskValue + ")"); + } + + @Override + public void toBytes(ByteBuf buf) { + buf.writeInt(x); + buf.writeInt(y); + buf.writeInt(z); + buf.writeInt(flaskValue); + Logger.INFO("Writing to byte buffer."); + } + + @Override + public void fromBytes(ByteBuf buf) { + x = buf.readInt(); + y = buf.readInt(); + z = buf.readInt(); + flaskValue = buf.readInt(); + Logger.INFO("Reading from byte buffer."); + } + + public int getX() { + return x; + } + + public void setX(int x) { + this.x = x; + } + + public int getY() { + return y; + } + + public void setY(int y) { + this.y = y; + } + + public int getZ() { + return z; + } + + public void setZ(int z) { + this.z = z; + } + + public int getCustomValue() { + return flaskValue; + } + + public void setCustomValue(int aVal) { + this.flaskValue = aVal; + } + + protected TileEntityVolumetricFlaskSetter getTileEntity(Packet_VolumetricFlaskGui message, MessageContext ctx) { + Logger.INFO("Trying to get tile."); + World worldObj = getWorld(ctx); + if (worldObj == null) { + Logger.INFO("Bad world object."); + return null; + } + TileEntity te = worldObj.getTileEntity(message.getX(), message.getY(), message.getZ()); + if (te == null) { + Logger.INFO("Bad Tile."); + return null; + } + if (te instanceof TileEntityVolumetricFlaskSetter) { + Logger.INFO("Found Tile."); + return (TileEntityVolumetricFlaskSetter) te; + } + Logger.INFO("Error."); + return null; + } + + protected World getWorld(MessageContext ctx) { + if (ctx.side == Side.SERVER) { + return ctx.getServerHandler().playerEntity.worldObj; + } else { + return GTplusplus.proxy.getClientWorld(); + } + } + + @Override + public IMessage handleServerMessage(EntityPlayer player, Packet_VolumetricFlaskGui message, MessageContext ctx) { + TileEntityVolumetricFlaskSetter te = getTileEntity(message, ctx); + if (te != null) { + Logger.INFO("Setting value on tile. " + message.getCustomValue()); + te.setCustomValue(message.getCustomValue()); + // return new Packet_VolumetricFlaskGui2(te, message.getCustomValue()); + } + return null; + } + + @Override + public String getPacketName() { + return "Packet_VoluemtricFlaskSetter_ToServer"; + } } diff --git a/src/main/java/gtPlusPlus/core/network/packet/Packet_VolumetricFlaskGui2.java b/src/main/java/gtPlusPlus/core/network/packet/Packet_VolumetricFlaskGui2.java index bc6e6149d8..350b72bbca 100644 --- a/src/main/java/gtPlusPlus/core/network/packet/Packet_VolumetricFlaskGui2.java +++ b/src/main/java/gtPlusPlus/core/network/packet/Packet_VolumetricFlaskGui2.java @@ -12,116 +12,114 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -public class Packet_VolumetricFlaskGui2 extends AbstractClientMessageHandler implements AbstractPacket { - - private int x; - private int y; - private int z; - private int flaskValue; - - public Packet_VolumetricFlaskGui2() { - - } - - public Packet_VolumetricFlaskGui2(TileEntityVolumetricFlaskSetter tile, int aCustomValue) { - x = tile.xCoord; - y = tile.yCoord; - z = tile.zCoord; - flaskValue = aCustomValue; - Logger.INFO("Created Packet with values ("+x+", "+y+", "+z+" | "+flaskValue+")"); - } - - @Override - public void toBytes(ByteBuf buf) { - buf.writeInt(x); - buf.writeInt(y); - buf.writeInt(z); - buf.writeInt(flaskValue); - Logger.INFO("Writing to byte buffer."); - } - - @Override - public void fromBytes(ByteBuf buf) { - x = buf.readInt(); - y = buf.readInt(); - z = buf.readInt(); - flaskValue = buf.readInt(); - Logger.INFO("Reading from byte buffer."); - } - - public int getX() { - return x; - } - - public void setX(int x) { - this.x = x; - } - - public int getY() { - return y; - } - - public void setY(int y) { - this.y = y; - } - - public int getZ() { - return z; - } - - public void setZ(int z) { - this.z = z; - } - - public int getCustomValue() { - return flaskValue; - } - - public void setCustomValue(int aVal) { - this.flaskValue = aVal; - } - - protected TileEntityVolumetricFlaskSetter getTileEntity(Packet_VolumetricFlaskGui2 message, MessageContext ctx) { - Logger.INFO("Trying to get tile."); - World worldObj = getWorld(ctx); - if(worldObj == null) { - Logger.INFO("Bad world object."); - return null; - } - TileEntity te = worldObj.getTileEntity(message.getX(), message.getY(), message.getZ()); - if(te == null) { - Logger.INFO("Bad Tile."); - return null; - } - if(te instanceof TileEntityVolumetricFlaskSetter) { - Logger.INFO("Found Tile."); - return (TileEntityVolumetricFlaskSetter) te; - } - Logger.INFO("Error."); - return null; - } - - protected World getWorld(MessageContext ctx) { - if(ctx.side == Side.SERVER) { - return ctx.getServerHandler().playerEntity.worldObj; - } else { - return GTplusplus.proxy.getClientWorld(); - } - } - - @Override - public String getPacketName() { - return "Packet_VoluemtricFlaskSetter_ToClient"; - } - - @Override - public IMessage handleClientMessage(EntityPlayer player, Packet_VolumetricFlaskGui2 message, MessageContext ctx) { - TileEntityVolumetricFlaskSetter te = getTileEntity(message, ctx); - if(te != null) { - Logger.INFO("Setting value on tile. "+message.getCustomValue()); - te.setCustomValue(message.getCustomValue()); - } - return null; - } - +public class Packet_VolumetricFlaskGui2 extends AbstractClientMessageHandler + implements AbstractPacket { + + private int x; + private int y; + private int z; + private int flaskValue; + + public Packet_VolumetricFlaskGui2() {} + + public Packet_VolumetricFlaskGui2(TileEntityVolumetricFlaskSetter tile, int aCustomValue) { + x = tile.xCoord; + y = tile.yCoord; + z = tile.zCoord; + flaskValue = aCustomValue; + Logger.INFO("Created Packet with values (" + x + ", " + y + ", " + z + " | " + flaskValue + ")"); + } + + @Override + public void toBytes(ByteBuf buf) { + buf.writeInt(x); + buf.writeInt(y); + buf.writeInt(z); + buf.writeInt(flaskValue); + Logger.INFO("Writing to byte buffer."); + } + + @Override + public void fromBytes(ByteBuf buf) { + x = buf.readInt(); + y = buf.readInt(); + z = buf.readInt(); + flaskValue = buf.readInt(); + Logger.INFO("Reading from byte buffer."); + } + + public int getX() { + return x; + } + + public void setX(int x) { + this.x = x; + } + + public int getY() { + return y; + } + + public void setY(int y) { + this.y = y; + } + + public int getZ() { + return z; + } + + public void setZ(int z) { + this.z = z; + } + + public int getCustomValue() { + return flaskValue; + } + + public void setCustomValue(int aVal) { + this.flaskValue = aVal; + } + + protected TileEntityVolumetricFlaskSetter getTileEntity(Packet_VolumetricFlaskGui2 message, MessageContext ctx) { + Logger.INFO("Trying to get tile."); + World worldObj = getWorld(ctx); + if (worldObj == null) { + Logger.INFO("Bad world object."); + return null; + } + TileEntity te = worldObj.getTileEntity(message.getX(), message.getY(), message.getZ()); + if (te == null) { + Logger.INFO("Bad Tile."); + return null; + } + if (te instanceof TileEntityVolumetricFlaskSetter) { + Logger.INFO("Found Tile."); + return (TileEntityVolumetricFlaskSetter) te; + } + Logger.INFO("Error."); + return null; + } + + protected World getWorld(MessageContext ctx) { + if (ctx.side == Side.SERVER) { + return ctx.getServerHandler().playerEntity.worldObj; + } else { + return GTplusplus.proxy.getClientWorld(); + } + } + + @Override + public String getPacketName() { + return "Packet_VoluemtricFlaskSetter_ToClient"; + } + + @Override + public IMessage handleClientMessage(EntityPlayer player, Packet_VolumetricFlaskGui2 message, MessageContext ctx) { + TileEntityVolumetricFlaskSetter te = getTileEntity(message, ctx); + if (te != null) { + Logger.INFO("Setting value on tile. " + message.getCustomValue()); + te.setCustomValue(message.getCustomValue()); + } + return null; + } } diff --git a/src/main/java/gtPlusPlus/core/players/FakeFarmer.java b/src/main/java/gtPlusPlus/core/players/FakeFarmer.java index ef9ee3c3e7..ad47cce495 100644 --- a/src/main/java/gtPlusPlus/core/players/FakeFarmer.java +++ b/src/main/java/gtPlusPlus/core/players/FakeFarmer.java @@ -1,11 +1,8 @@ package gtPlusPlus.core.players; -import java.util.UUID; - import com.mojang.authlib.GameProfile; - import cpw.mods.fml.common.FMLCommonHandler; - +import java.util.UUID; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; @@ -19,68 +16,66 @@ import net.minecraft.world.World; import net.minecraft.world.WorldServer; public class FakeFarmer extends EntityPlayerMP { - private static final UUID uuid = UUID.fromString("c1ddfd7f-120a-4437-8b64-38660d3ec62d"); - - private static GameProfile FAKE_PROFILE = new GameProfile(uuid, "[GT_Farm_Manager]"); - - public FakeFarmer(final WorldServer world) { - super(FMLCommonHandler.instance().getMinecraftServerInstance(), world, FAKE_PROFILE, new ItemInWorldManager(world)); - } - - @Override - public boolean canCommandSenderUseCommand(final int i, final String s) { - return false; - } - - @Override - public ChunkCoordinates getPlayerCoordinates() { - return new ChunkCoordinates(0, 0, 0); - } - - @Override - public void addChatComponentMessage(final IChatComponent chatmessagecomponent) { - } - - @Override - public void addChatMessage(final IChatComponent p_145747_1_) { - } - - @Override - public void addStat(final StatBase par1StatBase, final int par2) { - } - - @Override - public void openGui(final Object mod, final int modGuiId, final World world, final int x, final int y, final int z) { - } - - @Override - public boolean isEntityInvulnerable() { - return true; - } - - @Override - public boolean canAttackPlayer(final EntityPlayer player) { - return false; - } - - @Override - public void onDeath(final DamageSource source) { - } - - @Override - public void onUpdate() { - } - - @Override - public void travelToDimension(final int dim) { - } - - @Override - public void func_147100_a(final C15PacketClientSettings pkt) { - } - - @Override - public boolean canPlayerEdit(final int par1, final int par2, final int par3, final int par4, final ItemStack par5ItemStack) { - return true; - } -} \ No newline at end of file + private static final UUID uuid = UUID.fromString("c1ddfd7f-120a-4437-8b64-38660d3ec62d"); + + private static GameProfile FAKE_PROFILE = new GameProfile(uuid, "[GT_Farm_Manager]"); + + public FakeFarmer(final WorldServer world) { + super( + FMLCommonHandler.instance().getMinecraftServerInstance(), + world, + FAKE_PROFILE, + new ItemInWorldManager(world)); + } + + @Override + public boolean canCommandSenderUseCommand(final int i, final String s) { + return false; + } + + @Override + public ChunkCoordinates getPlayerCoordinates() { + return new ChunkCoordinates(0, 0, 0); + } + + @Override + public void addChatComponentMessage(final IChatComponent chatmessagecomponent) {} + + @Override + public void addChatMessage(final IChatComponent p_145747_1_) {} + + @Override + public void addStat(final StatBase par1StatBase, final int par2) {} + + @Override + public void openGui( + final Object mod, final int modGuiId, final World world, final int x, final int y, final int z) {} + + @Override + public boolean isEntityInvulnerable() { + return true; + } + + @Override + public boolean canAttackPlayer(final EntityPlayer player) { + return false; + } + + @Override + public void onDeath(final DamageSource source) {} + + @Override + public void onUpdate() {} + + @Override + public void travelToDimension(final int dim) {} + + @Override + public void func_147100_a(final C15PacketClientSettings pkt) {} + + @Override + public boolean canPlayerEdit( + final int par1, final int par2, final int par3, final int par4, final ItemStack par5ItemStack) { + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/potion/GtPotionEffect.java b/src/main/java/gtPlusPlus/core/potion/GtPotionEffect.java index fa31f68389..65e7d20af0 100644 --- a/src/main/java/gtPlusPlus/core/potion/GtPotionEffect.java +++ b/src/main/java/gtPlusPlus/core/potion/GtPotionEffect.java @@ -3,9 +3,8 @@ package gtPlusPlus.core.potion; import net.minecraft.potion.PotionEffect; public class GtPotionEffect extends PotionEffect { - - public GtPotionEffect(int aPotionID, int aDurationInSecs, int aLevel) { - super(aPotionID, aDurationInSecs * 20, aLevel, false); - } + public GtPotionEffect(int aPotionID, int aDurationInSecs, int aLevel) { + super(aPotionID, aDurationInSecs * 20, aLevel, false); + } } diff --git a/src/main/java/gtPlusPlus/core/proxy/ClientProxy.java b/src/main/java/gtPlusPlus/core/proxy/ClientProxy.java index 6c940adc1d..fbc057f472 100644 --- a/src/main/java/gtPlusPlus/core/proxy/ClientProxy.java +++ b/src/main/java/gtPlusPlus/core/proxy/ClientProxy.java @@ -1,7 +1,5 @@ package gtPlusPlus.core.proxy; -import java.util.ArrayList; - import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; @@ -36,6 +34,7 @@ import gtPlusPlus.core.util.minecraft.particles.EntityParticleFXMysterious; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import gtPlusPlus.xmod.gregtech.common.render.*; import ic2.core.item.ItemFluidCell; +import java.util.ArrayList; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.entity.RenderFireball; @@ -49,241 +48,224 @@ import net.minecraftforge.client.IItemRenderer; import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.fluids.*; -public class ClientProxy extends CommonProxy implements Runnable{ - - private final GTPP_CapeRenderer mCapeRenderer; - @SideOnly(Side.CLIENT) - public static boolean mFancyGraphics = false; - - public ClientProxy(){ - mCapeRenderer = new GTPP_CapeRenderer(); - //Get Graphics Mode. - mFancyGraphics = Minecraft.isFancyGraphicsEnabled(); - } - - @SubscribeEvent - public void receiveRenderSpecialsEvent(net.minecraftforge.client.event.RenderPlayerEvent.Specials.Pre aEvent) { - if (ConfigSwitches.enableCustomCapes){ - mCapeRenderer.receiveRenderSpecialsEvent(aEvent); - } - } - - @SideOnly(Side.CLIENT) - public static String playerName = ""; - - @Override - public void preInit(final FMLPreInitializationEvent e) { - super.preInit(e); - if (ConfigSwitches.enableCustomCapes){ - onPreLoad(); - } - //Do this weird things for textures. - GTplusplus.loadTextures(); - //We boot up the sneak manager. - if (LoadedMods.PlayerAPI){ - this.init_PlayerAPI_PRE(); - } - } - - @Override - public void init(final FMLInitializationEvent e) { - if (LoadedMods.PlayerAPI){ - this.init_PlayerAPI_INIT(); - } - - /** - * Custom Block Renderers - */ - new CustomOreBlockRenderer(); - new CustomItemBlockRenderer(); - new GTPP_Render_MachineBlock(); - - if (Meta_GT_Proxy.sDoesVolumetricFlaskExist) { - new GTPP_FlaskRenderer(); - } - - super.init(e); - } - - @Override - public void postInit(final FMLPostInitializationEvent e) { - super.postInit(e); - } - - @Override - public void registerRenderThings(){ - - // Standard GT++ - - /** - * Entities - */ - - RenderingRegistry.registerEntityRenderingHandler(EntityPrimedMiningExplosive.class, new RenderMiningExplosivesPrimed()); - RenderingRegistry.registerEntityRenderingHandler(EntitySickBlaze.class, new RenderSickBlaze()); - RenderingRegistry.registerEntityRenderingHandler(EntityStaballoyConstruct.class, new RenderStaballoyConstruct()); - RenderingRegistry.registerEntityRenderingHandler(EntityToxinballSmall.class, new RenderToxinball(1F)); - RenderingRegistry.registerEntityRenderingHandler(EntitySulfuricAcidPotion.class, new RenderSnowball(ModItems.itemSulfuricPotion)); - RenderingRegistry.registerEntityRenderingHandler(EntityHydrofluoricAcidPotion.class, new RenderSnowball(ModItems.itemHydrofluoricPotion)); - RenderingRegistry.registerEntityRenderingHandler(EntityTeslaTowerLightning.class, new RenderPlasmaBolt()); - RenderingRegistry.registerEntityRenderingHandler(EntityGiantChickenBase.class, new RenderGiantChicken(new ModelGiantChicken(), 1f)); - RenderingRegistry.registerEntityRenderingHandler(EntityBatKing.class, new RenderBatKing()); - RenderingRegistry.registerEntityRenderingHandler(EntityThrowableBomb.class, new RenderSnowball(ModItems.itemBomb, 1)); - RenderingRegistry.registerEntityRenderingHandler(EntityLightningAttack.class, new RenderFireball(1F)); - - /** - * Tiles - */ - - Logger.INFO("Registering Custom Renderer for the Fire Pit."); - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFirepit.class, new FirepitRender()); - Logger.INFO("Registering Custom Renderer for the Lead Lined Chest."); - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDecayablesChest.class, new RenderDecayChest()); - Logger.INFO("Registering Custom Renderer for the Egg Box."); - //ClientRegistry.bindTileEntitySpecialRenderer(TileEntityEggBox.class, ModelEggBox.getRenderer()); - - - //GT++ Australia - - /** - * Entities - */ - - RenderingRegistry.registerEntityRenderingHandler(EntityAustralianSpiderBase.class, new RenderAustralianSpider()); - RenderingRegistry.registerEntityRenderingHandler(EntityBoar.class, new RenderBoar(new ModelBoar(), new ModelBoar(0.5F), 0.7F)); - RenderingRegistry.registerEntityRenderingHandler(EntityDingo.class, new RenderDingo(new ModelDingo(), new ModelDingo(), 0.5F)); - RenderingRegistry.registerEntityRenderingHandler(EntityOctopus.class, new RenderOctopus(new ModelOctopus(), 0.7F)); - - - - - - - - /** - * Items - */ - for (Pair sItemRenderMappings : mItemRenderMappings) { - MinecraftForgeClient.registerItemRenderer(sItemRenderMappings.getKey(), sItemRenderMappings.getValue()); - } - - } - - @Override - public int addArmor(final String armor){ - return RenderingRegistry.addNewArmourRendererPrefix(armor); - } - - @Override - public void generateMysteriousParticles(final Entity theEntity) - { - final double motionX = theEntity.worldObj.rand.nextGaussian() * 0.02D; - final double motionY = theEntity.worldObj.rand.nextGaussian() * 0.02D; - final double motionZ = theEntity.worldObj.rand.nextGaussian() * 0.02D; - final EntityFX particleMysterious = new EntityParticleFXMysterious( - - theEntity.worldObj, - (theEntity.posX + (theEntity.worldObj.rand.nextFloat() * theEntity.width - - * 2.0F)) - theEntity.width, - theEntity.posY + 0.5D + (theEntity.worldObj.rand.nextFloat() - - * theEntity.height), - (theEntity.posZ + (theEntity.worldObj.rand.nextFloat() * theEntity.width - - * 2.0F)) - theEntity.width, - - motionX, - - motionY, - - motionZ); - Minecraft.getMinecraft().effectRenderer.addEffect(particleMysterious); - } - - @Override - public void serverStarting(final FMLServerStartingEvent e) - { - - } - - @Optional.Method(modid = "PlayerAPI") - private void init_PlayerAPI_PRE(){ - //Register player instance - COMPAT_PlayerAPI.clientProxy.initPre(); - } - - @Optional.Method(modid = "PlayerAPI") - private void init_PlayerAPI_INIT(){ - //Register player instance - COMPAT_PlayerAPI.clientProxy.Init(); - } - - - - public void onPreLoad() { - /*if (ConfigSwitches.enableCustomCapes){ - String arr$[] = { - "draknyte1", "fobius" - }; - int len$ = arr$.length; - for (int i$ = 0; i$ < len$; i$++) { - String tName = arr$[i$]; - mCapeList.add(tName.toLowerCase()); - } - (new Thread(this)).start(); - }*/ - } - - @Override - public void run() { - /*try { - if (ConfigSwitches.enableCustomCapes){ - Logger.INFO("GT++ Mod: Downloading Cape List."); - @SuppressWarnings("resource") - Scanner tScanner = new Scanner(new URL("https://github.com/draknyte1/GTplusplus/blob/master/SupporterList.txt").openStream()); - while (tScanner.hasNextLine()) { - String tName = tScanner.nextLine(); - if (!this.mCapeList.contains(tName.toLowerCase())) { - this.mCapeList.add(tName.toLowerCase()); - } - } - } - } catch (Throwable e) { - Logger.INFO("Failed to download GT++ cape list."); - }*/ - } - - @Override - public void onLoadComplete(FMLLoadCompleteEvent event) { - GTplusplus.tryPatchTurbineTextures(); - if (CORE.ConfigSwitches.hideUniversalCells) { - hideUniversalCells(); - } - super.onLoadComplete(event); - } - - public void hideUniversalCells() { - ArrayList itemList = new ArrayList(); - for (Fluid fluid : FluidRegistry.getRegisteredFluids().values()) { - if (fluid == null) { - continue; - } - itemList.add(ItemFluidCell.getUniversalFluidCell(new FluidStack(fluid, 2147483647))); - } - for (ItemStack aCell : itemList) { - codechicken.nei.api.API.hideItem(aCell); - } - } - - @Override - public World getClientWorld() { - return FMLClientHandler.instance().getClient().theWorld; - } - - @Override - public EntityPlayer getPlayerEntity(MessageContext ctx) { - return (ctx.side.isClient() ? Minecraft.getMinecraft().thePlayer : super.getPlayerEntity(ctx)); - } - +public class ClientProxy extends CommonProxy implements Runnable { + + private final GTPP_CapeRenderer mCapeRenderer; + + @SideOnly(Side.CLIENT) + public static boolean mFancyGraphics = false; + + public ClientProxy() { + mCapeRenderer = new GTPP_CapeRenderer(); + // Get Graphics Mode. + mFancyGraphics = Minecraft.isFancyGraphicsEnabled(); + } + + @SubscribeEvent + public void receiveRenderSpecialsEvent(net.minecraftforge.client.event.RenderPlayerEvent.Specials.Pre aEvent) { + if (ConfigSwitches.enableCustomCapes) { + mCapeRenderer.receiveRenderSpecialsEvent(aEvent); + } + } + + @SideOnly(Side.CLIENT) + public static String playerName = ""; + + @Override + public void preInit(final FMLPreInitializationEvent e) { + super.preInit(e); + if (ConfigSwitches.enableCustomCapes) { + onPreLoad(); + } + // Do this weird things for textures. + GTplusplus.loadTextures(); + // We boot up the sneak manager. + if (LoadedMods.PlayerAPI) { + this.init_PlayerAPI_PRE(); + } + } + + @Override + public void init(final FMLInitializationEvent e) { + if (LoadedMods.PlayerAPI) { + this.init_PlayerAPI_INIT(); + } + + /** + * Custom Block Renderers + */ + new CustomOreBlockRenderer(); + new CustomItemBlockRenderer(); + new GTPP_Render_MachineBlock(); + + if (Meta_GT_Proxy.sDoesVolumetricFlaskExist) { + new GTPP_FlaskRenderer(); + } + + super.init(e); + } + + @Override + public void postInit(final FMLPostInitializationEvent e) { + super.postInit(e); + } + + @Override + public void registerRenderThings() { + + // Standard GT++ + + /** + * Entities + */ + RenderingRegistry.registerEntityRenderingHandler( + EntityPrimedMiningExplosive.class, new RenderMiningExplosivesPrimed()); + RenderingRegistry.registerEntityRenderingHandler(EntitySickBlaze.class, new RenderSickBlaze()); + RenderingRegistry.registerEntityRenderingHandler( + EntityStaballoyConstruct.class, new RenderStaballoyConstruct()); + RenderingRegistry.registerEntityRenderingHandler(EntityToxinballSmall.class, new RenderToxinball(1F)); + RenderingRegistry.registerEntityRenderingHandler( + EntitySulfuricAcidPotion.class, new RenderSnowball(ModItems.itemSulfuricPotion)); + RenderingRegistry.registerEntityRenderingHandler( + EntityHydrofluoricAcidPotion.class, new RenderSnowball(ModItems.itemHydrofluoricPotion)); + RenderingRegistry.registerEntityRenderingHandler(EntityTeslaTowerLightning.class, new RenderPlasmaBolt()); + RenderingRegistry.registerEntityRenderingHandler( + EntityGiantChickenBase.class, new RenderGiantChicken(new ModelGiantChicken(), 1f)); + RenderingRegistry.registerEntityRenderingHandler(EntityBatKing.class, new RenderBatKing()); + RenderingRegistry.registerEntityRenderingHandler( + EntityThrowableBomb.class, new RenderSnowball(ModItems.itemBomb, 1)); + RenderingRegistry.registerEntityRenderingHandler(EntityLightningAttack.class, new RenderFireball(1F)); + + /** + * Tiles + */ + Logger.INFO("Registering Custom Renderer for the Fire Pit."); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFirepit.class, new FirepitRender()); + Logger.INFO("Registering Custom Renderer for the Lead Lined Chest."); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDecayablesChest.class, new RenderDecayChest()); + Logger.INFO("Registering Custom Renderer for the Egg Box."); + // ClientRegistry.bindTileEntitySpecialRenderer(TileEntityEggBox.class, ModelEggBox.getRenderer()); + + // GT++ Australia + + /** + * Entities + */ + RenderingRegistry.registerEntityRenderingHandler( + EntityAustralianSpiderBase.class, new RenderAustralianSpider()); + RenderingRegistry.registerEntityRenderingHandler( + EntityBoar.class, new RenderBoar(new ModelBoar(), new ModelBoar(0.5F), 0.7F)); + RenderingRegistry.registerEntityRenderingHandler( + EntityDingo.class, new RenderDingo(new ModelDingo(), new ModelDingo(), 0.5F)); + RenderingRegistry.registerEntityRenderingHandler( + EntityOctopus.class, new RenderOctopus(new ModelOctopus(), 0.7F)); + + /** + * Items + */ + for (Pair sItemRenderMappings : mItemRenderMappings) { + MinecraftForgeClient.registerItemRenderer(sItemRenderMappings.getKey(), sItemRenderMappings.getValue()); + } + } + + @Override + public int addArmor(final String armor) { + return RenderingRegistry.addNewArmourRendererPrefix(armor); + } + + @Override + public void generateMysteriousParticles(final Entity theEntity) { + final double motionX = theEntity.worldObj.rand.nextGaussian() * 0.02D; + final double motionY = theEntity.worldObj.rand.nextGaussian() * 0.02D; + final double motionZ = theEntity.worldObj.rand.nextGaussian() * 0.02D; + final EntityFX particleMysterious = new EntityParticleFXMysterious( + theEntity.worldObj, + (theEntity.posX + (theEntity.worldObj.rand.nextFloat() * theEntity.width * 2.0F)) - theEntity.width, + theEntity.posY + 0.5D + (theEntity.worldObj.rand.nextFloat() * theEntity.height), + (theEntity.posZ + (theEntity.worldObj.rand.nextFloat() * theEntity.width * 2.0F)) - theEntity.width, + motionX, + motionY, + motionZ); + Minecraft.getMinecraft().effectRenderer.addEffect(particleMysterious); + } + + @Override + public void serverStarting(final FMLServerStartingEvent e) {} + + @Optional.Method(modid = "PlayerAPI") + private void init_PlayerAPI_PRE() { + // Register player instance + COMPAT_PlayerAPI.clientProxy.initPre(); + } + + @Optional.Method(modid = "PlayerAPI") + private void init_PlayerAPI_INIT() { + // Register player instance + COMPAT_PlayerAPI.clientProxy.Init(); + } + + public void onPreLoad() { + /*if (ConfigSwitches.enableCustomCapes){ + String arr$[] = { + "draknyte1", "fobius" + }; + int len$ = arr$.length; + for (int i$ = 0; i$ < len$; i$++) { + String tName = arr$[i$]; + mCapeList.add(tName.toLowerCase()); + } + (new Thread(this)).start(); + }*/ + } + + @Override + public void run() { + /*try { + if (ConfigSwitches.enableCustomCapes){ + Logger.INFO("GT++ Mod: Downloading Cape List."); + @SuppressWarnings("resource") + Scanner tScanner = new Scanner(new URL("https://github.com/draknyte1/GTplusplus/blob/master/SupporterList.txt").openStream()); + while (tScanner.hasNextLine()) { + String tName = tScanner.nextLine(); + if (!this.mCapeList.contains(tName.toLowerCase())) { + this.mCapeList.add(tName.toLowerCase()); + } + } + } + } catch (Throwable e) { + Logger.INFO("Failed to download GT++ cape list."); + }*/ + } + + @Override + public void onLoadComplete(FMLLoadCompleteEvent event) { + GTplusplus.tryPatchTurbineTextures(); + if (CORE.ConfigSwitches.hideUniversalCells) { + hideUniversalCells(); + } + super.onLoadComplete(event); + } + + public void hideUniversalCells() { + ArrayList itemList = new ArrayList(); + for (Fluid fluid : FluidRegistry.getRegisteredFluids().values()) { + if (fluid == null) { + continue; + } + itemList.add(ItemFluidCell.getUniversalFluidCell(new FluidStack(fluid, 2147483647))); + } + for (ItemStack aCell : itemList) { + codechicken.nei.api.API.hideItem(aCell); + } + } + + @Override + public World getClientWorld() { + return FMLClientHandler.instance().getClient().theWorld; + } + + @Override + public EntityPlayer getPlayerEntity(MessageContext ctx) { + return (ctx.side.isClient() ? Minecraft.getMinecraft().thePlayer : super.getPlayerEntity(ctx)); + } } diff --git a/src/main/java/gtPlusPlus/core/proxy/ServerProxy.java b/src/main/java/gtPlusPlus/core/proxy/ServerProxy.java index 8aeeb70191..ed1674cb3a 100644 --- a/src/main/java/gtPlusPlus/core/proxy/ServerProxy.java +++ b/src/main/java/gtPlusPlus/core/proxy/ServerProxy.java @@ -3,27 +3,25 @@ package gtPlusPlus.core.proxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; - import gtPlusPlus.core.common.CommonProxy; -public class ServerProxy extends CommonProxy{ - - @Override - public void preInit(final FMLPreInitializationEvent e) { - // TODO Auto-generated method stub - super.preInit(e); - } +public class ServerProxy extends CommonProxy { - @Override - public void init(final FMLInitializationEvent e) { - // TODO Auto-generated method stub - super.init(e); - } + @Override + public void preInit(final FMLPreInitializationEvent e) { + // TODO Auto-generated method stub + super.preInit(e); + } - @Override - public void postInit(final FMLPostInitializationEvent e) { - // TODO Auto-generated method stub - super.postInit(e); - } + @Override + public void init(final FMLInitializationEvent e) { + // TODO Auto-generated method stub + super.init(e); + } + @Override + public void postInit(final FMLPostInitializationEvent e) { + // TODO Auto-generated method stub + super.postInit(e); + } } diff --git a/src/main/java/gtPlusPlus/core/recipe/Gregtech_Recipe_Adder.java b/src/main/java/gtPlusPlus/core/recipe/Gregtech_Recipe_Adder.java index b5fc9c3995..9348584e34 100644 --- a/src/main/java/gtPlusPlus/core/recipe/Gregtech_Recipe_Adder.java +++ b/src/main/java/gtPlusPlus/core/recipe/Gregtech_Recipe_Adder.java @@ -1,100 +1,109 @@ package gtPlusPlus.core.recipe; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - import gregtech.api.enums.GT_Values; import gregtech.api.util.GT_ModHandler; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; public class Gregtech_Recipe_Adder { - private static int euT; - private static int ticks; - private static ItemStack inputStack1; - private static ItemStack inputStack2; - private static ItemStack outputStack1; - private static ItemStack outputStack2; - - public static void addRecipe( - final Item maceratorInput, final int maceratorInputAmount1, - final Item maceratorOutput, final int maceratorOutputAmount1, - final Item compressorInput, final int compressorInputAmount1, - final Item compressorOutput, final int compressorOutputAmount1, - final Item blastFurnaceInput, final int blastFurnaceInputAmount1, - final Item blastFurnaceOutput, final int blastFurnaceOutputAmount1, - final Item blastFurnaceInput2, final int blastFurnaceInputAmount2, - final Item blastFurnaceOutput2, final int blastFurnaceOutputAmount2, - final Item smeltingInput, final int smeltingInputAmount1, - final Item smeltingOutput, final int smeltingOutputAmount1, - - final int euPerTick, final int timeInTicks, - final boolean addMaceratorRecipe, final boolean addCompressorRecipe, final boolean addBlastFurnaceRecipe, final int blastFurnaceTemp, final boolean addSmeltingRecipe, final boolean addMixerRecipe){ - euT = euPerTick; - ticks = timeInTicks; - - resetVars(); - if (addMaceratorRecipe){ - inputStack1 = ItemUtils.getSimpleStack(maceratorInput, maceratorInputAmount1); - outputStack1 = ItemUtils.getSimpleStack(maceratorOutput, maceratorOutputAmount1); - addMaceratorRecipe(inputStack1, outputStack1); - } - resetVars(); - if (addCompressorRecipe){ - inputStack1 = ItemUtils.getSimpleStack(compressorInput, compressorInputAmount1); - outputStack1 = ItemUtils.getSimpleStack(compressorOutput, compressorOutputAmount1); - addCompressorRecipe(inputStack1, outputStack1); - } - resetVars(); - if (addBlastFurnaceRecipe){ - inputStack1 = ItemUtils.getSimpleStack(blastFurnaceInput, blastFurnaceInputAmount1); - inputStack2 = ItemUtils.getSimpleStack(blastFurnaceInput2, blastFurnaceInputAmount2); - outputStack1 = ItemUtils.getSimpleStack(blastFurnaceOutput, blastFurnaceOutputAmount1); - outputStack2 = ItemUtils.getSimpleStack(blastFurnaceOutput2, blastFurnaceOutputAmount2); - addBlastFurnaceRecipe(inputStack1, inputStack2, outputStack1, outputStack2, blastFurnaceTemp); - } - resetVars(); - if (addSmeltingRecipe){ - inputStack1 = ItemUtils.getSimpleStack(smeltingInput, smeltingInputAmount1); - outputStack1 = ItemUtils.getSimpleStack(smeltingOutput, smeltingOutputAmount1); - addSmeltingRecipe(inputStack1, outputStack1); - } - resetVars(); + private static int euT; + private static int ticks; + private static ItemStack inputStack1; + private static ItemStack inputStack2; + private static ItemStack outputStack1; + private static ItemStack outputStack2; - } + public static void addRecipe( + final Item maceratorInput, + final int maceratorInputAmount1, + final Item maceratorOutput, + final int maceratorOutputAmount1, + final Item compressorInput, + final int compressorInputAmount1, + final Item compressorOutput, + final int compressorOutputAmount1, + final Item blastFurnaceInput, + final int blastFurnaceInputAmount1, + final Item blastFurnaceOutput, + final int blastFurnaceOutputAmount1, + final Item blastFurnaceInput2, + final int blastFurnaceInputAmount2, + final Item blastFurnaceOutput2, + final int blastFurnaceOutputAmount2, + final Item smeltingInput, + final int smeltingInputAmount1, + final Item smeltingOutput, + final int smeltingOutputAmount1, + final int euPerTick, + final int timeInTicks, + final boolean addMaceratorRecipe, + final boolean addCompressorRecipe, + final boolean addBlastFurnaceRecipe, + final int blastFurnaceTemp, + final boolean addSmeltingRecipe, + final boolean addMixerRecipe) { + euT = euPerTick; + ticks = timeInTicks; - private static void resetVars(){ - inputStack1 = null; - inputStack2 = null; - outputStack1 = null; - outputStack2 = null; - } + resetVars(); + if (addMaceratorRecipe) { + inputStack1 = ItemUtils.getSimpleStack(maceratorInput, maceratorInputAmount1); + outputStack1 = ItemUtils.getSimpleStack(maceratorOutput, maceratorOutputAmount1); + addMaceratorRecipe(inputStack1, outputStack1); + } + resetVars(); + if (addCompressorRecipe) { + inputStack1 = ItemUtils.getSimpleStack(compressorInput, compressorInputAmount1); + outputStack1 = ItemUtils.getSimpleStack(compressorOutput, compressorOutputAmount1); + addCompressorRecipe(inputStack1, outputStack1); + } + resetVars(); + if (addBlastFurnaceRecipe) { + inputStack1 = ItemUtils.getSimpleStack(blastFurnaceInput, blastFurnaceInputAmount1); + inputStack2 = ItemUtils.getSimpleStack(blastFurnaceInput2, blastFurnaceInputAmount2); + outputStack1 = ItemUtils.getSimpleStack(blastFurnaceOutput, blastFurnaceOutputAmount1); + outputStack2 = ItemUtils.getSimpleStack(blastFurnaceOutput2, blastFurnaceOutputAmount2); + addBlastFurnaceRecipe(inputStack1, inputStack2, outputStack1, outputStack2, blastFurnaceTemp); + } + resetVars(); + if (addSmeltingRecipe) { + inputStack1 = ItemUtils.getSimpleStack(smeltingInput, smeltingInputAmount1); + outputStack1 = ItemUtils.getSimpleStack(smeltingOutput, smeltingOutputAmount1); + addSmeltingRecipe(inputStack1, outputStack1); + } + resetVars(); + } - private static void addMaceratorRecipe(final ItemStack input1, final ItemStack output1){ - GT_ModHandler.addPulverisationRecipe(input1, output1); - } + private static void resetVars() { + inputStack1 = null; + inputStack2 = null; + outputStack1 = null; + outputStack2 = null; + } - private static void addCompressorRecipe(final ItemStack input1, final ItemStack output1){ - GT_ModHandler.addCompressionRecipe(input1, output1); - } + private static void addMaceratorRecipe(final ItemStack input1, final ItemStack output1) { + GT_ModHandler.addPulverisationRecipe(input1, output1); + } - private static void addBlastFurnaceRecipe(final ItemStack input1, final ItemStack input2, final ItemStack output1, final ItemStack output2, final int tempRequired){ - Logger.INFO("Registering Blast Furnace Recipes."); - GT_Values.RA.addBlastRecipe( - input1, - input2, - GT_Values.NF, GT_Values.NF, - output1, - output2, - ticks, - euT, - tempRequired); - } + private static void addCompressorRecipe(final ItemStack input1, final ItemStack output1) { + GT_ModHandler.addCompressionRecipe(input1, output1); + } - private static void addSmeltingRecipe(final ItemStack input1, final ItemStack output1){ - GT_ModHandler.addSmeltingRecipe(input1, output1); - } + private static void addBlastFurnaceRecipe( + final ItemStack input1, + final ItemStack input2, + final ItemStack output1, + final ItemStack output2, + final int tempRequired) { + Logger.INFO("Registering Blast Furnace Recipes."); + GT_Values.RA.addBlastRecipe( + input1, input2, GT_Values.NF, GT_Values.NF, output1, output2, ticks, euT, tempRequired); + } + private static void addSmeltingRecipe(final ItemStack input1, final ItemStack output1) { + GT_ModHandler.addSmeltingRecipe(input1, output1); + } } diff --git a/src/main/java/gtPlusPlus/core/recipe/LOADER_Machine_Components.java b/src/main/java/gtPlusPlus/core/recipe/LOADER_Machine_Components.java index c77db21800..07622ee65b 100644 --- a/src/main/java/gtPlusPlus/core/recipe/LOADER_Machine_Components.java +++ b/src/main/java/gtPlusPlus/core/recipe/LOADER_Machine_Components.java @@ -1,7 +1,6 @@ package gtPlusPlus.core.recipe; import gregtech.api.enums.ItemList; - import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.minecraft.ItemUtils; @@ -9,233 +8,241 @@ import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; public class LOADER_Machine_Components { - public static void initialise(){ - - registerDefaultComponents(); - - if (!CORE.GTNH){ - if(CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ - registerGTExperimentalComponents(); - } - else { - registerGTStandardComponents(); - } - } - else { - registerGTNHComponents(); - } - } - - private static void registerDefaultComponents(){ - //Machine Components - CI.electricMotor_LV = ItemList.Electric_Motor_LV.get(1); - CI.electricMotor_MV = ItemList.Electric_Motor_MV.get(1); - CI.electricMotor_HV = ItemList.Electric_Motor_HV.get(1); - CI.electricMotor_EV = ItemList.Electric_Motor_EV.get(1); - CI.electricMotor_IV = ItemList.Electric_Motor_IV.get(1); - CI.electricPump_LV = ItemList.Electric_Pump_LV.get(1); - CI.electricPump_MV = ItemList.Electric_Pump_MV.get(1); - CI.electricPump_HV = ItemList.Electric_Pump_HV.get(1); - CI.electricPump_EV = ItemList.Electric_Pump_EV.get(1); - CI.electricPump_IV = ItemList.Electric_Pump_IV.get(1); - CI.electricPiston_LV = ItemList.Electric_Piston_LV.get(1); - CI.electricPiston_MV = ItemList.Electric_Piston_MV.get(1); - CI.electricPiston_HV = ItemList.Electric_Piston_HV.get(1); - CI.electricPiston_EV = ItemList.Electric_Piston_EV.get(1); - CI.electricPiston_IV = ItemList.Electric_Piston_IV.get(1); - CI.robotArm_LV = ItemList.Robot_Arm_LV.get(1); - CI.robotArm_MV = ItemList.Robot_Arm_MV.get(1); - CI.robotArm_HV = ItemList.Robot_Arm_HV.get(1); - CI.robotArm_EV = ItemList.Robot_Arm_EV.get(1); - CI.robotArm_IV = ItemList.Robot_Arm_IV.get(1); - CI.conveyorModule_LV = ItemList.Conveyor_Module_LV.get(1); - CI.conveyorModule_MV = ItemList.Conveyor_Module_MV.get(1); - CI.conveyorModule_HV = ItemList.Conveyor_Module_HV.get(1); - CI.conveyorModule_EV = ItemList.Conveyor_Module_EV.get(1); - CI.conveyorModule_IV = ItemList.Conveyor_Module_IV.get(1); - CI.emitter_LV = ItemList.Emitter_LV.get(1); - CI.emitter_MV = ItemList.Emitter_MV.get(1); - CI.emitter_HV = ItemList.Emitter_HV.get(1); - CI.emitter_EV = ItemList.Emitter_EV.get(1); - CI.emitter_IV = ItemList.Emitter_IV.get(1); - CI.fieldGenerator_LV = ItemList.Field_Generator_LV.get(1); - CI.fieldGenerator_MV = ItemList.Field_Generator_MV.get(1); - CI.fieldGenerator_HV = ItemList.Field_Generator_HV.get(1); - CI.fieldGenerator_EV = ItemList.Field_Generator_EV.get(1); - CI.fieldGenerator_IV = ItemList.Field_Generator_IV.get(1); - CI.sensor_LV = ItemList.Sensor_LV.get(1); - CI.sensor_MV = ItemList.Sensor_MV.get(1); - CI.sensor_HV = ItemList.Sensor_HV.get(1); - CI.sensor_EV = ItemList.Sensor_EV.get(1); - CI.sensor_IV = ItemList.Sensor_IV.get(1); - if(CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - CI.fluidRegulator_LV = ItemUtils.getValueOfItemList("FluidRegulator_LV", ItemList.Pump_LV).get(1); - CI.fluidRegulator_MV = ItemUtils.getValueOfItemList("FluidRegulator_MV", ItemList.Pump_MV).get(1); - CI.fluidRegulator_HV = ItemUtils.getValueOfItemList("FluidRegulator_HV", ItemList.Pump_HV).get(1); - CI.fluidRegulator_EV = ItemUtils.getValueOfItemList("FluidRegulator_EV", ItemList.Pump_EV).get(1); - CI.fluidRegulator_IV = ItemUtils.getValueOfItemList("FluidRegulator_IV", ItemList.Pump_IV).get(1); - } - } - - private static void registerGTExperimentalComponents(){ - //GT++ Machine Components - CI.electricMotor_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32606, 1); - CI.electricMotor_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32607, 1); - CI.electricMotor_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32608, 1); - CI.electricPump_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32620, 1); - CI.electricPump_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32621, 1); - CI.electricPump_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32622, 1); - CI.electricPiston_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32645, 1); - CI.electricPiston_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32646, 1); - CI.electricPiston_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32647, 1); - CI.robotArm_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32655, 1); - CI.robotArm_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32656, 1); - CI.robotArm_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32657, 1); - CI.conveyorModule_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32636, 1); - CI.conveyorModule_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32637, 1); - CI.conveyorModule_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32638, 1); - CI.emitter_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32685, 1); - CI.emitter_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32686, 1); - CI.emitter_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32687, 1); - CI.fieldGenerator_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32675, 1); - CI.fieldGenerator_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32676, 1); - CI.fieldGenerator_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32677, 1); - CI.sensor_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32695, 1); - CI.sensor_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32696, 1); - CI.sensor_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32697, 1); - - if(CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - CI.fluidRegulator_LuV = ItemUtils.getValueOfItemList("FluidRegulator_LuV", ItemList.Pump_LuV).get(1); - CI.fluidRegulator_ZPM = ItemUtils.getValueOfItemList("FluidRegulator_ZPM", ItemList.Pump_ZPM).get(1); - CI.fluidRegulator_UV = ItemUtils.getValueOfItemList("FluidRegulator_UV", ItemList.Pump_UV).get(1); - } - - registerComponentsULV(); - registerComponentsMAX(); - } - - private static void registerGTStandardComponents(){ - CI.electricMotor_LuV = GregtechItemList.Electric_Motor_LuV.get(1); - CI.electricMotor_ZPM = GregtechItemList.Electric_Motor_ZPM.get(1); - CI.electricMotor_UV = GregtechItemList.Electric_Motor_UV.get(1); - CI.electricMotor_MAX = GregtechItemList.Electric_Motor_MAX.get(1); - CI.electricPump_LuV = GregtechItemList.Electric_Pump_LuV.get(1); - CI.electricPump_ZPM = GregtechItemList.Electric_Pump_ZPM.get(1); - CI.electricPump_UV = GregtechItemList.Electric_Pump_UV.get(1); - CI.electricPump_MAX = GregtechItemList.Electric_Pump_MAX.get(1); - CI.electricPiston_LuV = GregtechItemList.Electric_Piston_LuV.get(1); - CI.electricPiston_ZPM = GregtechItemList.Electric_Piston_ZPM.get(1); - CI.electricPiston_UV = GregtechItemList.Electric_Piston_UV.get(1); - CI.electricPiston_MAX = GregtechItemList.Electric_Piston_MAX.get(1); - CI.robotArm_LuV = GregtechItemList.Robot_Arm_LuV.get(1); - CI.robotArm_ZPM = GregtechItemList.Robot_Arm_ZPM.get(1); - CI.robotArm_UV = GregtechItemList.Robot_Arm_UV.get(1); - CI.robotArm_MAX = GregtechItemList.Robot_Arm_MAX.get(1); - CI.conveyorModule_LuV = GregtechItemList.Conveyor_Module_LuV.get(1); - CI.conveyorModule_ZPM = GregtechItemList.Conveyor_Module_ZPM.get(1); - CI.conveyorModule_UV = GregtechItemList.Conveyor_Module_UV.get(1); - CI.conveyorModule_MAX = GregtechItemList.Conveyor_Module_MAX.get(1); - CI.emitter_LuV = GregtechItemList.Emitter_LuV.get(1); - CI.emitter_ZPM = GregtechItemList.Emitter_ZPM.get(1); - CI.emitter_UV = GregtechItemList.Emitter_UV.get(1); - CI.emitter_MAX = GregtechItemList.Emitter_MAX.get(1); - CI.fieldGenerator_LuV = GregtechItemList.Field_Generator_LuV.get(1); - CI.fieldGenerator_ZPM = GregtechItemList.Field_Generator_ZPM.get(1); - CI.fieldGenerator_UV = GregtechItemList.Field_Generator_UV.get(1); - CI.fieldGenerator_MAX = GregtechItemList.Field_Generator_MAX.get(1); - CI.sensor_LuV = GregtechItemList.Sensor_LuV.get(1); - CI.sensor_ZPM = GregtechItemList.Sensor_ZPM.get(1); - CI.sensor_UV = GregtechItemList.Sensor_UV.get(1); - CI.sensor_MAX = GregtechItemList.Sensor_MAX.get(1); - - if(CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - CI.fluidRegulator_LuV = ItemUtils.getValueOfItemList("FluidRegulator_LuV", ItemList.Pump_LuV).get(1); - CI.fluidRegulator_ZPM = ItemUtils.getValueOfItemList("FluidRegulator_ZPM", ItemList.Pump_ZPM).get(1); - CI.fluidRegulator_UV = ItemUtils.getValueOfItemList("FluidRegulator_UV", ItemList.Pump_UV).get(1); - } - - registerComponentsULV(); - } - - private static void registerGTNHComponents(){ - //Machine Components - CI.electricMotor_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32606, 1); - CI.electricMotor_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32607, 1); - CI.electricMotor_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32608, 1); - - CI.electricPump_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32615, 1); - CI.electricPump_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32616, 1); - CI.electricPump_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32617, 1); - - CI.electricPiston_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32645, 1); - CI.electricPiston_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32646, 1); - CI.electricPiston_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32647, 1); - - CI.robotArm_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32655, 1); - CI.robotArm_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32656, 1); - CI.robotArm_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32657, 1); - - CI.conveyorModule_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32635, 1); - CI.conveyorModule_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32636, 1); - CI.conveyorModule_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32637, 1); - - CI.emitter_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32685, 1); - CI.emitter_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32686, 1); - CI.emitter_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32687, 1); - - CI.fieldGenerator_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32675, 1); - CI.fieldGenerator_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32676, 1); - CI.fieldGenerator_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32677, 1); - - CI.sensor_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32695, 1); - CI.sensor_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32696, 1); - CI.sensor_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32697, 1); - - if(CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - CI.fluidRegulator_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32665, 1); - CI.fluidRegulator_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32666, 1); - CI.fluidRegulator_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32667, 1); - } - - // Thanks 0lafe - CI.electricMotor_MAX = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32596, 1); - CI.electricPump_MAX = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32618, 1); - CI.electricPiston_MAX = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32648, 1); - CI.robotArm_MAX = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32658, 1); - CI.conveyorModule_MAX = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32638, 1); - CI.emitter_MAX = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32688, 1); - CI.fieldGenerator_MAX = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32678, 1); - CI.sensor_MAX = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32698, 1); - - registerComponentsULV(); - } - - private static boolean registerComponentsULV(){ - - CI.electricMotor_ULV = GregtechItemList.Electric_Motor_ULV.get(1); - CI.electricPump_ULV = GregtechItemList.Electric_Pump_ULV.get(1); - CI.electricPiston_ULV = GregtechItemList.Electric_Piston_ULV.get(1); - CI.robotArm_ULV = GregtechItemList.Robot_Arm_ULV.get(1); - CI.conveyorModule_ULV = GregtechItemList.Conveyor_Module_ULV.get(1); - CI.emitter_ULV = GregtechItemList.Emitter_ULV.get(1); - CI.fieldGenerator_ULV = GregtechItemList.Field_Generator_ULV.get(1); - CI.sensor_ULV = GregtechItemList.Sensor_ULV.get(1); - return true; - } - - private static boolean registerComponentsMAX() { - - // Max Tier Components Blood Never added... Useless, lol. - CI.electricMotor_MAX = GregtechItemList.Electric_Motor_MAX.get(1); - CI.electricPump_MAX = GregtechItemList.Electric_Pump_MAX.get(1); - CI.electricPiston_MAX = GregtechItemList.Electric_Piston_MAX.get(1); - CI.robotArm_MAX = GregtechItemList.Robot_Arm_MAX.get(1); - CI.conveyorModule_MAX = GregtechItemList.Conveyor_Module_MAX.get(1); - CI.emitter_MAX = GregtechItemList.Emitter_MAX.get(1); - CI.fieldGenerator_MAX = GregtechItemList.Field_Generator_MAX.get(1); - CI.sensor_MAX = GregtechItemList.Sensor_MAX.get(1); - - return true; - } - + public static void initialise() { + + registerDefaultComponents(); + + if (!CORE.GTNH) { + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + registerGTExperimentalComponents(); + } else { + registerGTStandardComponents(); + } + } else { + registerGTNHComponents(); + } + } + + private static void registerDefaultComponents() { + // Machine Components + CI.electricMotor_LV = ItemList.Electric_Motor_LV.get(1); + CI.electricMotor_MV = ItemList.Electric_Motor_MV.get(1); + CI.electricMotor_HV = ItemList.Electric_Motor_HV.get(1); + CI.electricMotor_EV = ItemList.Electric_Motor_EV.get(1); + CI.electricMotor_IV = ItemList.Electric_Motor_IV.get(1); + CI.electricPump_LV = ItemList.Electric_Pump_LV.get(1); + CI.electricPump_MV = ItemList.Electric_Pump_MV.get(1); + CI.electricPump_HV = ItemList.Electric_Pump_HV.get(1); + CI.electricPump_EV = ItemList.Electric_Pump_EV.get(1); + CI.electricPump_IV = ItemList.Electric_Pump_IV.get(1); + CI.electricPiston_LV = ItemList.Electric_Piston_LV.get(1); + CI.electricPiston_MV = ItemList.Electric_Piston_MV.get(1); + CI.electricPiston_HV = ItemList.Electric_Piston_HV.get(1); + CI.electricPiston_EV = ItemList.Electric_Piston_EV.get(1); + CI.electricPiston_IV = ItemList.Electric_Piston_IV.get(1); + CI.robotArm_LV = ItemList.Robot_Arm_LV.get(1); + CI.robotArm_MV = ItemList.Robot_Arm_MV.get(1); + CI.robotArm_HV = ItemList.Robot_Arm_HV.get(1); + CI.robotArm_EV = ItemList.Robot_Arm_EV.get(1); + CI.robotArm_IV = ItemList.Robot_Arm_IV.get(1); + CI.conveyorModule_LV = ItemList.Conveyor_Module_LV.get(1); + CI.conveyorModule_MV = ItemList.Conveyor_Module_MV.get(1); + CI.conveyorModule_HV = ItemList.Conveyor_Module_HV.get(1); + CI.conveyorModule_EV = ItemList.Conveyor_Module_EV.get(1); + CI.conveyorModule_IV = ItemList.Conveyor_Module_IV.get(1); + CI.emitter_LV = ItemList.Emitter_LV.get(1); + CI.emitter_MV = ItemList.Emitter_MV.get(1); + CI.emitter_HV = ItemList.Emitter_HV.get(1); + CI.emitter_EV = ItemList.Emitter_EV.get(1); + CI.emitter_IV = ItemList.Emitter_IV.get(1); + CI.fieldGenerator_LV = ItemList.Field_Generator_LV.get(1); + CI.fieldGenerator_MV = ItemList.Field_Generator_MV.get(1); + CI.fieldGenerator_HV = ItemList.Field_Generator_HV.get(1); + CI.fieldGenerator_EV = ItemList.Field_Generator_EV.get(1); + CI.fieldGenerator_IV = ItemList.Field_Generator_IV.get(1); + CI.sensor_LV = ItemList.Sensor_LV.get(1); + CI.sensor_MV = ItemList.Sensor_MV.get(1); + CI.sensor_HV = ItemList.Sensor_HV.get(1); + CI.sensor_EV = ItemList.Sensor_EV.get(1); + CI.sensor_IV = ItemList.Sensor_IV.get(1); + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + CI.fluidRegulator_LV = ItemUtils.getValueOfItemList("FluidRegulator_LV", ItemList.Pump_LV) + .get(1); + CI.fluidRegulator_MV = ItemUtils.getValueOfItemList("FluidRegulator_MV", ItemList.Pump_MV) + .get(1); + CI.fluidRegulator_HV = ItemUtils.getValueOfItemList("FluidRegulator_HV", ItemList.Pump_HV) + .get(1); + CI.fluidRegulator_EV = ItemUtils.getValueOfItemList("FluidRegulator_EV", ItemList.Pump_EV) + .get(1); + CI.fluidRegulator_IV = ItemUtils.getValueOfItemList("FluidRegulator_IV", ItemList.Pump_IV) + .get(1); + } + } + + private static void registerGTExperimentalComponents() { + // GT++ Machine Components + CI.electricMotor_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32606, 1); + CI.electricMotor_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32607, 1); + CI.electricMotor_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32608, 1); + CI.electricPump_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32620, 1); + CI.electricPump_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32621, 1); + CI.electricPump_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32622, 1); + CI.electricPiston_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32645, 1); + CI.electricPiston_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32646, 1); + CI.electricPiston_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32647, 1); + CI.robotArm_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32655, 1); + CI.robotArm_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32656, 1); + CI.robotArm_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32657, 1); + CI.conveyorModule_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32636, 1); + CI.conveyorModule_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32637, 1); + CI.conveyorModule_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32638, 1); + CI.emitter_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32685, 1); + CI.emitter_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32686, 1); + CI.emitter_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32687, 1); + CI.fieldGenerator_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32675, 1); + CI.fieldGenerator_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32676, 1); + CI.fieldGenerator_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32677, 1); + CI.sensor_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32695, 1); + CI.sensor_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32696, 1); + CI.sensor_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32697, 1); + + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + CI.fluidRegulator_LuV = ItemUtils.getValueOfItemList("FluidRegulator_LuV", ItemList.Pump_LuV) + .get(1); + CI.fluidRegulator_ZPM = ItemUtils.getValueOfItemList("FluidRegulator_ZPM", ItemList.Pump_ZPM) + .get(1); + CI.fluidRegulator_UV = ItemUtils.getValueOfItemList("FluidRegulator_UV", ItemList.Pump_UV) + .get(1); + } + + registerComponentsULV(); + registerComponentsMAX(); + } + + private static void registerGTStandardComponents() { + CI.electricMotor_LuV = GregtechItemList.Electric_Motor_LuV.get(1); + CI.electricMotor_ZPM = GregtechItemList.Electric_Motor_ZPM.get(1); + CI.electricMotor_UV = GregtechItemList.Electric_Motor_UV.get(1); + CI.electricMotor_MAX = GregtechItemList.Electric_Motor_MAX.get(1); + CI.electricPump_LuV = GregtechItemList.Electric_Pump_LuV.get(1); + CI.electricPump_ZPM = GregtechItemList.Electric_Pump_ZPM.get(1); + CI.electricPump_UV = GregtechItemList.Electric_Pump_UV.get(1); + CI.electricPump_MAX = GregtechItemList.Electric_Pump_MAX.get(1); + CI.electricPiston_LuV = GregtechItemList.Electric_Piston_LuV.get(1); + CI.electricPiston_ZPM = GregtechItemList.Electric_Piston_ZPM.get(1); + CI.electricPiston_UV = GregtechItemList.Electric_Piston_UV.get(1); + CI.electricPiston_MAX = GregtechItemList.Electric_Piston_MAX.get(1); + CI.robotArm_LuV = GregtechItemList.Robot_Arm_LuV.get(1); + CI.robotArm_ZPM = GregtechItemList.Robot_Arm_ZPM.get(1); + CI.robotArm_UV = GregtechItemList.Robot_Arm_UV.get(1); + CI.robotArm_MAX = GregtechItemList.Robot_Arm_MAX.get(1); + CI.conveyorModule_LuV = GregtechItemList.Conveyor_Module_LuV.get(1); + CI.conveyorModule_ZPM = GregtechItemList.Conveyor_Module_ZPM.get(1); + CI.conveyorModule_UV = GregtechItemList.Conveyor_Module_UV.get(1); + CI.conveyorModule_MAX = GregtechItemList.Conveyor_Module_MAX.get(1); + CI.emitter_LuV = GregtechItemList.Emitter_LuV.get(1); + CI.emitter_ZPM = GregtechItemList.Emitter_ZPM.get(1); + CI.emitter_UV = GregtechItemList.Emitter_UV.get(1); + CI.emitter_MAX = GregtechItemList.Emitter_MAX.get(1); + CI.fieldGenerator_LuV = GregtechItemList.Field_Generator_LuV.get(1); + CI.fieldGenerator_ZPM = GregtechItemList.Field_Generator_ZPM.get(1); + CI.fieldGenerator_UV = GregtechItemList.Field_Generator_UV.get(1); + CI.fieldGenerator_MAX = GregtechItemList.Field_Generator_MAX.get(1); + CI.sensor_LuV = GregtechItemList.Sensor_LuV.get(1); + CI.sensor_ZPM = GregtechItemList.Sensor_ZPM.get(1); + CI.sensor_UV = GregtechItemList.Sensor_UV.get(1); + CI.sensor_MAX = GregtechItemList.Sensor_MAX.get(1); + + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + CI.fluidRegulator_LuV = ItemUtils.getValueOfItemList("FluidRegulator_LuV", ItemList.Pump_LuV) + .get(1); + CI.fluidRegulator_ZPM = ItemUtils.getValueOfItemList("FluidRegulator_ZPM", ItemList.Pump_ZPM) + .get(1); + CI.fluidRegulator_UV = ItemUtils.getValueOfItemList("FluidRegulator_UV", ItemList.Pump_UV) + .get(1); + } + + registerComponentsULV(); + } + + private static void registerGTNHComponents() { + // Machine Components + CI.electricMotor_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32606, 1); + CI.electricMotor_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32607, 1); + CI.electricMotor_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32608, 1); + + CI.electricPump_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32615, 1); + CI.electricPump_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32616, 1); + CI.electricPump_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32617, 1); + + CI.electricPiston_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32645, 1); + CI.electricPiston_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32646, 1); + CI.electricPiston_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32647, 1); + + CI.robotArm_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32655, 1); + CI.robotArm_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32656, 1); + CI.robotArm_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32657, 1); + + CI.conveyorModule_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32635, 1); + CI.conveyorModule_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32636, 1); + CI.conveyorModule_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32637, 1); + + CI.emitter_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32685, 1); + CI.emitter_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32686, 1); + CI.emitter_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32687, 1); + + CI.fieldGenerator_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32675, 1); + CI.fieldGenerator_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32676, 1); + CI.fieldGenerator_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32677, 1); + + CI.sensor_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32695, 1); + CI.sensor_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32696, 1); + CI.sensor_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32697, 1); + + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + CI.fluidRegulator_LuV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32665, 1); + CI.fluidRegulator_ZPM = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32666, 1); + CI.fluidRegulator_UV = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32667, 1); + } + + // Thanks 0lafe + CI.electricMotor_MAX = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32596, 1); + CI.electricPump_MAX = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32618, 1); + CI.electricPiston_MAX = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32648, 1); + CI.robotArm_MAX = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32658, 1); + CI.conveyorModule_MAX = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32638, 1); + CI.emitter_MAX = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32688, 1); + CI.fieldGenerator_MAX = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32678, 1); + CI.sensor_MAX = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32698, 1); + + registerComponentsULV(); + } + + private static boolean registerComponentsULV() { + + CI.electricMotor_ULV = GregtechItemList.Electric_Motor_ULV.get(1); + CI.electricPump_ULV = GregtechItemList.Electric_Pump_ULV.get(1); + CI.electricPiston_ULV = GregtechItemList.Electric_Piston_ULV.get(1); + CI.robotArm_ULV = GregtechItemList.Robot_Arm_ULV.get(1); + CI.conveyorModule_ULV = GregtechItemList.Conveyor_Module_ULV.get(1); + CI.emitter_ULV = GregtechItemList.Emitter_ULV.get(1); + CI.fieldGenerator_ULV = GregtechItemList.Field_Generator_ULV.get(1); + CI.sensor_ULV = GregtechItemList.Sensor_ULV.get(1); + return true; + } + + private static boolean registerComponentsMAX() { + + // Max Tier Components Blood Never added... Useless, lol. + CI.electricMotor_MAX = GregtechItemList.Electric_Motor_MAX.get(1); + CI.electricPump_MAX = GregtechItemList.Electric_Pump_MAX.get(1); + CI.electricPiston_MAX = GregtechItemList.Electric_Piston_MAX.get(1); + CI.robotArm_MAX = GregtechItemList.Robot_Arm_MAX.get(1); + CI.conveyorModule_MAX = GregtechItemList.Conveyor_Module_MAX.get(1); + CI.emitter_MAX = GregtechItemList.Emitter_MAX.get(1); + CI.fieldGenerator_MAX = GregtechItemList.Field_Generator_MAX.get(1); + CI.sensor_MAX = GregtechItemList.Sensor_MAX.get(1); + + return true; + } } diff --git a/src/main/java/gtPlusPlus/core/recipe/RECIPES_Extruder.java b/src/main/java/gtPlusPlus/core/recipe/RECIPES_Extruder.java index 455beb2fd0..122a35f3a6 100644 --- a/src/main/java/gtPlusPlus/core/recipe/RECIPES_Extruder.java +++ b/src/main/java/gtPlusPlus/core/recipe/RECIPES_Extruder.java @@ -1,47 +1,56 @@ package gtPlusPlus.core.recipe; -import net.minecraft.item.ItemStack; - import gregtech.api.enums.*; import gregtech.api.interfaces.IOreRecipeRegistrator; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; - import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import net.minecraft.item.ItemStack; public class RECIPES_Extruder implements IOreRecipeRegistrator { - - public RECIPES_Extruder() { - OrePrefixes.ingot.add((IOreRecipeRegistrator) this); - OrePrefixes.dust.add((IOreRecipeRegistrator) this); - } - public void registerOre(final OrePrefixes aPrefix, final Materials aMaterial, final String aOreDictName, - final String aModName, final ItemStack aStack) { - if (!CORE.GTNH && ((aMaterial == Materials.Glass || aMaterial == Materials.WroughtIron - || GT_OreDictUnificator.get(OrePrefixes.ingot, (Object) aMaterial, 1L) != null) - && !aMaterial.contains(SubTag.NO_SMELTING))) { - final long aMaterialMass = aMaterial.getMass(); - final int tAmount = (int) (aPrefix.mMaterialAmount / 3628800L); - if (tAmount > 0 && tAmount <= 64 && aPrefix.mMaterialAmount % 3628800L == 0L) { - int tVoltageMultiplier = (aMaterial.mBlastFurnaceTemp >= 2800) ? 64 : 16; - if (aMaterial.contains(SubTag.NO_SMASHING)) { - tVoltageMultiplier /= 4; - } else if (aPrefix.name().startsWith(OrePrefixes.dust.name())) { - return; - } - - GT_Values.RA.addExtruderRecipe(GT_Utility.copyAmount(1L, new Object[]{aStack}), - GregtechItemList.Shape_Extruder_SmallGear.get(0L, new Object[0]), - GT_OreDictUnificator.get(OrePrefixes.gearGtSmall, (Object) aMaterial.mSmeltInto, (long) tAmount), - ((int) Math.max(aMaterialMass * 5L * tAmount, tAmount)/4), 8 * tVoltageMultiplier); - GT_Values.RA.addAlloySmelterRecipe(GT_Utility.copyAmount(2L, new Object[]{aStack}), - ItemList.Shape_Mold_Gear_Small.get(0L, new Object[0]), - GT_OreDictUnificator.get(OrePrefixes.gearGtSmall, (Object) aMaterial.mSmeltInto, (long) tAmount), - ((int) Math.max(aMaterialMass * 10L * tAmount, tAmount)/4), 2 * tVoltageMultiplier); - - } - } - } -} \ No newline at end of file + public RECIPES_Extruder() { + OrePrefixes.ingot.add((IOreRecipeRegistrator) this); + OrePrefixes.dust.add((IOreRecipeRegistrator) this); + } + + public void registerOre( + final OrePrefixes aPrefix, + final Materials aMaterial, + final String aOreDictName, + final String aModName, + final ItemStack aStack) { + if (!CORE.GTNH + && ((aMaterial == Materials.Glass + || aMaterial == Materials.WroughtIron + || GT_OreDictUnificator.get(OrePrefixes.ingot, (Object) aMaterial, 1L) != null) + && !aMaterial.contains(SubTag.NO_SMELTING))) { + final long aMaterialMass = aMaterial.getMass(); + final int tAmount = (int) (aPrefix.mMaterialAmount / 3628800L); + if (tAmount > 0 && tAmount <= 64 && aPrefix.mMaterialAmount % 3628800L == 0L) { + int tVoltageMultiplier = (aMaterial.mBlastFurnaceTemp >= 2800) ? 64 : 16; + if (aMaterial.contains(SubTag.NO_SMASHING)) { + tVoltageMultiplier /= 4; + } else if (aPrefix.name().startsWith(OrePrefixes.dust.name())) { + return; + } + + GT_Values.RA.addExtruderRecipe( + GT_Utility.copyAmount(1L, new Object[] {aStack}), + GregtechItemList.Shape_Extruder_SmallGear.get(0L, new Object[0]), + GT_OreDictUnificator.get( + OrePrefixes.gearGtSmall, (Object) aMaterial.mSmeltInto, (long) tAmount), + ((int) Math.max(aMaterialMass * 5L * tAmount, tAmount) / 4), + 8 * tVoltageMultiplier); + GT_Values.RA.addAlloySmelterRecipe( + GT_Utility.copyAmount(2L, new Object[] {aStack}), + ItemList.Shape_Mold_Gear_Small.get(0L, new Object[0]), + GT_OreDictUnificator.get( + OrePrefixes.gearGtSmall, (Object) aMaterial.mSmeltInto, (long) tAmount), + ((int) Math.max(aMaterialMass * 10L * tAmount, tAmount) / 4), + 2 * tVoltageMultiplier); + } + } + } +} diff --git a/src/main/java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/main/java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index 771b82ccdb..f1c4aab409 100644 --- a/src/main/java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/main/java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -1,5 +1,7 @@ package gtPlusPlus.core.recipe; +import static gtPlusPlus.core.lib.CORE.GTNH; + import cpw.mods.fml.common.Loader; import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; @@ -26,2404 +28,2456 @@ import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.MaterialUtils; import gtPlusPlus.core.util.reflect.AddGregtechRecipe; -import gtPlusPlus.everglades.dimension.Dimension_Everglades; import gtPlusPlus.xmod.bop.blocks.BOP_Block_Registrator; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import java.util.ArrayList; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; -import java.util.ArrayList; - -import static gtPlusPlus.core.lib.CORE.GTNH; - public class RECIPES_GREGTECH { - public static void run() { - Logger.INFO("Loading Recipes through GregAPI for Industrial Multiblocks."); - execute(); - } - - private static void execute() { - cokeOvenRecipes(); - electrolyzerRecipes(); - assemblerRecipes(); - fluidcannerRecipes(); - distilleryRecipes(); - extractorRecipes(); - fluidExtractorRecipes(); - chemicalBathRecipes(); - chemicalReactorRecipes(); - dehydratorRecipes(); - blastFurnaceRecipes(); - - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - largeChemReactorRecipes(); - fusionRecipes(); - } - - fissionFuelRecipes(); - autoclaveRecipes(); - compressorRecipes(); - mixerRecipes(); - macerationRecipes(); - centrifugeRecipes(); - benderRecipes(); - cyclotronRecipes(); - blastSmelterRecipes(); - //advancedMixerRecipes(); - sifterRecipes(); - electroMagneticSeperatorRecipes(); - extruderRecipes(); - cuttingSawRecipes(); - breweryRecipes(); - laserEngraverRecipes(); - assemblyLineRecipes(); - latheRecipes(); - vacuumFreezerRecipes(); - fluidheaterRecipes(); - chemplantRecipes(); - packagerRecipes(); - alloySmelterRecipes(); - implosionRecipes(); - - - /** - * Special Recipe handlers - */ - RECIPES_SeleniumProcessing.init(); - RECIPES_RareEarthProcessing.init(); - - addFuels(); - } - - private static void alloySmelterRecipes() { - - //Wood's Glass Laser Lens - GT_Values.RA.addAlloySmelterRecipe( - MISC_MATERIALS.WOODS_GLASS.getDust(5), - ItemList.Shape_Mold_Ball.get(0), - GregtechItemList.Laser_Lens_WoodsGlass.get(1), - 20 * 300, - MaterialUtils.getVoltageForTier(3)); - - } - - - private static void packagerRecipes() { - - - } - - private static void implosionRecipes() { - - //GT_Values.RA.addImplosionRecipe( - //ItemUtils.getSimpleStack(ModItems.itemSunnariumBit, 9), - //16, - //ItemUtils.getSimpleStack(AdvancedSolarPanel.itemSunnariumPart, 1), - //GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Glowstone, 8)); - - } - - private static void chemplantRecipes() { - - //This is subsequently absorbed in water to form nitric acid and nitric oxide. - //3 NO2 (g) + H2O (l) → 2 HNO3 (aq) + NO (g) (ΔH = −117 kJ/mol) - //The nitric oxide is cycled back for reoxidation. Alternatively, if the last step is carried out in air: - //4 NO2 (g) + O2 (g) + 2 H2O (l) → 4 HNO3 (aq) - - // Advanced method for Nitric Acid Production - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(17), - CI.getPinkCatalyst(0), - }, - new FluidStack[] { - FluidUtils.getFluidStack(GenericChem.Nitrogen_Dioxide, 4000), - FluidUtils.getAir(4000), - FluidUtils.getWater(2000), - }, - new ItemStack[] { - - }, - new FluidStack[] { - FluidUtils.getFluidStack("nitricacid", 4000), - }, - 10 * 20, - 480, - 3); - - // Advanced recipe for Fluorine Production - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(17), - CI.getPurpleCatalyst(0), - ItemUtils.getSimpleStack(Blocks.sandstone, 64), - ItemUtils.getSimpleStack(Blocks.sandstone, 64) - }, - new FluidStack[] { - FluidUtils.getFluidStack("nitricacid", 4000), - FluidUtils.getAir(8000) - }, - new ItemStack[] { - FLUORIDES.FLUORITE.getOre(8), - FLUORIDES.FLUORITE.getOre(4), - FLUORIDES.FLUORITE.getOre(4), - FLUORIDES.FLUORITE.getOre(4), - }, - new FluidStack[] { - - }, - new int[] { - 0, 2500, 2000, 1500 - }, - 10 * 20, - 1024, - 5); - - // Advanced recipe for Fluorine Production - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(17), - CI.getPurpleCatalyst(0), - ItemUtils.getSimpleStack(Blocks.sand, 64), - ItemUtils.getSimpleStack(Blocks.sand, 64) - }, - new FluidStack[] { - FluidUtils.getFluidStack("nitricacid", 5000), - FluidUtils.getAir(12000) - }, - new ItemStack[] { - FLUORIDES.FLUORITE.getOre(4), - FLUORIDES.FLUORITE.getOre(2), - FLUORIDES.FLUORITE.getOre(2), - FLUORIDES.FLUORITE.getOre(2), - }, - new FluidStack[] { - - }, - new int[] { - 7500, 1500, 1000, 500 - }, - 10 * 20, - 1024, - 5); - - //3NO2 + H2O = 2HNO3 + NO - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(16), - CI.getPinkCatalyst(0), - }, - new FluidStack[] { - FluidUtils.getFluidStack(GenericChem.Nitrogen_Dioxide, 3000), - FluidUtils.getDistilledWater(1000) - }, - new ItemStack[] { - - }, - new FluidStack[] { - FluidUtils.getFluidStack("nitricacid", 2000), - FluidUtils.getFluidStack(GenericChem.Nitric_Oxide, 1000), - }, - 10 * 20, - 480, - 2); - - // Produce Boric Acid - //Na2B4O7·10H2O + 2HCl = 4B(OH)3 + 2NaCl + 5H2O - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(21), - ItemUtils.getItemStackOfAmountFromOreDict("dustBorax", 23), - }, - new FluidStack[] { - FluidUtils.getFluidStack(GenericChem.HydrochloricAcid, 2000) - }, - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("dustSalt", 4), - }, - new FluidStack[] { - FluidUtils.getFluidStack("boricacid", 4000), - FluidUtils.getWater(5000) - }, - 20 * 30, - MaterialUtils.getVoltageForTier(3), - 3); - - // Produce Th232 - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(22), - ELEMENT.getInstance().THORIUM.getDust(16) - }, - new FluidStack[] { - FluidUtils.getDistilledWater(2000), - FluidUtils.getFluidStack("boricacid", 1500) - }, - new ItemStack[] { - ELEMENT.getInstance().THORIUM.getSmallDust(32), - ELEMENT.getInstance().THORIUM232.getDust(2), - ELEMENT.getInstance().THORIUM232.getSmallDust(2), - ELEMENT.getInstance().URANIUM232.getDust(1), - }, - new FluidStack[] { - - }, - new int[] { - 0, 0, 1000, 250 - }, - 20 * 300, - MaterialUtils.getVoltageForTier(4), - 4); - - // Modify Sapling into Pine Sapling - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedBioCircuit(6), - ItemUtils.getSimpleStack(Blocks.sapling, 32) - }, - new FluidStack[] { - FluidUtils.getFluidStack("fluid.geneticmutagen", 2000), - FluidUtils.getDistilledWater(8000) - }, - new ItemStack[] { - ItemUtils.getSimpleStack(BOP_Block_Registrator.sapling_Pine, 16) - }, - new FluidStack[] { - - }, - 120 * 20, - 64, - 2); - - - // Convert GT++ Plutonium239 into normal Plutonium - if (Materials.Plutonium.mDefaultLocalName.equals("Plutonium 239")) { - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(16), - ELEMENT.getInstance().PLUTONIUM239.getDust(1) - }, - new FluidStack[] { - - }, - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("dustPlutonium", 1) - }, - new FluidStack[] { - - }, - 5 * 20, - 1, - 2); - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(16), - ELEMENT.getInstance().PLUTONIUM239.getSmallDust(1) - }, - new FluidStack[] { - - }, - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("dustSmallPlutonium", 1) - }, - new FluidStack[] { - - }, - 5 * 20, - 1, - 2); - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(16), - ELEMENT.getInstance().PLUTONIUM239.getTinyDust(1) - }, - new FluidStack[] { - - }, - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("dustTinyPlutonium", 1) - }, - new FluidStack[] { - - }, - 5 * 20, - 1, - 2); - } - - int aLaureniumTier = ALLOY.LAURENIUM.vTier; - // Adding Recipes for Casings - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(12), - CI.getTieredMachineCasing(aLaureniumTier-1), - ALLOY.LAURENIUM.getPlate(8), - CI.getGear(aLaureniumTier, 2) - }, - new FluidStack[] { - CI.getTieredFluid(aLaureniumTier, 2 * 144), - CI.getAlternativeTieredFluid(aLaureniumTier-1, 4 * 144), - CI.getTertiaryTieredFluid(aLaureniumTier-2, 6 * 144) - }, - new ItemStack[] { - GregtechItemList.Casing_Machine_Custom_3.get(1) - }, - new FluidStack[] { - - }, - 20 * 20, - MaterialUtils.getVoltageForTier(aLaureniumTier-2), - 5); - - int aBotmiumTier = ALLOY.BOTMIUM.vTier; - // Adding Recipes for Casings - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(12), - CI.getTieredMachineCasing(aBotmiumTier-1), - ALLOY.BOTMIUM.getPlate(8), - CI.getGear(aBotmiumTier, 2) - }, - new FluidStack[] { - CI.getTieredFluid(aBotmiumTier, 2 * 144), - CI.getAlternativeTieredFluid(aBotmiumTier-1, 4 * 144), - CI.getTertiaryTieredFluid(aBotmiumTier-2, 6 * 144) - }, - new ItemStack[] { - GregtechItemList.Casing_Machine_Custom_4.get(1) - }, - new FluidStack[] { - - }, - 20 * 20, - MaterialUtils.getVoltageForTier(aBotmiumTier-2), - 6); - - - //Refine GT HF into GT++ HF - if (FluidUtils.doesHydrofluoricAcidGtExist()) { - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(22), - }, - new FluidStack[] { - FluidUtils.getHydrofluoricAcid(2000), - FluidUtils.getHydrofluoricAcidGT(5000) - }, - new ItemStack[] { - - }, - new FluidStack[] { - FluidUtils.getHydrofluoricAcid(4500) - }, - 30 * 20, - 480, - 3); - } - - } - - private static void fluidheaterRecipes() { - GT_Values.RA.addFluidHeaterRecipe(CI.getNumberedCircuit(20), FluidUtils.getWater(1000), FluidUtils.getHotWater(1000), 30, 30); - } - - private static void vacuumFreezerRecipes() { - GT_Values.RA.addVacuumFreezerRecipe(GregtechItemList.Bomb_Cast_Molten.get(1), GregtechItemList.Bomb_Cast_Set.get(1), 20 * 30); - } - - private static void latheRecipes() { - - GT_Values.RA.addLatheRecipe( - ALLOY.EGLIN_STEEL.getBlock(1), - GregtechItemList.Bomb_Cast_Mold.get(1), - null, - 20 * 60 * 15, - 120); - - GT_Values.RA.addLatheRecipe( - GregtechItemList.Bomb_Cast_Set.get(1), - GregtechItemList.Bomb_Cast_Broken.get(2), - ItemUtils.getSimpleStack(ModItems.itemBombCasing, 2), - 20 * 60 * 5, - 30); - - } - - private static void fusionRecipes() { - - /** - * Adds a Fusion reactor Recipe - * - * @param aInput1 = first Input (not null, and respects StackSize) - * @param aInput2 = second Input (not null, and respects StackSize) - * @param aOutput = Output of the Fusion (can be null, and respects StackSize) - * @param aFusionDurationInTicks = How many ticks the Fusion lasts (must be > 0) - * @param aFusionEnergyPerTick = The EU generated per Tick (can even be negative!) - * @param aEnergyNeededForStartingFusion = EU needed for heating the Reactor up (must be >= 0) - */ - - //Hydrogen Plasma - /*CORE.RA.addFusionReactorRecipe( - Particle.getIon("Hydrogen", 0), - Particle.getIon("Hydrogen", 0), - Materials.Hydrogen.getPlasma(1), - 5000, - 16, - 4096, - 40000000);*/ - - - //Hypogen Creation - GT_Values.RA.addFusionReactorRecipe( - ELEMENT.STANDALONE.DRAGON_METAL.getFluidStack(144), - ELEMENT.STANDALONE.RHUGNOR.getFluidStack(288), - ELEMENT.STANDALONE.HYPOGEN.getFluidStack(36), - 2048 * 4, - MaterialUtils.getVoltageForTier(9), - 600000000 * 2); - - //Rhugnor - GT_Values.RA.addFusionReactorRecipe( - MaterialUtils.getMaterial("Infinity", "Neutronium").getMolten(144), - ALLOY.QUANTUM.getFluidStack(288), - ELEMENT.STANDALONE.RHUGNOR.getFluidStack(144), - 512, - MaterialUtils.getVoltageForTier(8), - 2000000000); - - } - - private static void assemblyLineRecipes() { - - - - ItemStack[] aCoilWire = new ItemStack[] { - ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 0, GTNH ? 64 : 32), - ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 1, GTNH ? 64 : 32), - ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 2, GTNH ? 64 : 32), - ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 3, GTNH ? 64 : 32), - }; - - - - - //Containment Casings - CORE.RA.addAssemblylineRecipe( - ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_1_CONTAINMENT, 1), - 20 * 60 * 30, - new Object[] { - ItemList.Field_Generator_IV.get(GTNH ? 32 : 16), - ItemList.Electric_Motor_EV.get(GTNH ? 64 : 32), - ItemList.Energy_LapotronicOrb.get(GTNH ? 32 : 16), - CI.getTieredComponent(OrePrefixes.cableGt12, 7, GTNH ? 32 : 16), - CI.getTieredComponent(OrePrefixes.wireGt16, 6, GTNH ? 64 : 32), - ItemUtils.getOrePrefixStack(OrePrefixes.plate, Materials.Naquadria, GTNH ? 64 : 16), - ELEMENT.getInstance().GADOLINIUM.getDust(GTNH ? 32 : 8), - ELEMENT.getInstance().SAMARIUM.getDust(GTNH ? 16 : 4), - ALLOY.ARCANITE.getGear(GTNH ? 8 : 2), - new Object[] {CI.getTieredCircuitOreDictName(5), 64}, - new Object[] {CI.getTieredCircuitOreDictName(6), 32}, - new Object[] {CI.getTieredCircuitOreDictName(7), 16}, - GregtechItemList.Laser_Lens_Special.get(1), - aCoilWire[3] - }, - new FluidStack[] { - ALLOY.NITINOL_60.getFluidStack(144 * 9 * (GTNH ? 4 : 2)), - ALLOY.ENERGYCRYSTAL.getFluidStack(144 * 9 * (GTNH ? 8 : 4)), - ALLOY.TUMBAGA.getFluidStack(144 * 9 * (GTNH ? 32 : 8)), - ALLOY.NICHROME.getFluidStack(144 * 1 * (GTNH ? 16 : 4)), - }, - ItemUtils.getSimpleStack(ModBlocks.blockCasings3Misc, 15, 32), - 20 * 60 * 10 * (GTNH ? 2 : 1), - (int) MaterialUtils.getVoltageForTier(6)); - - //Slow Fusion Controller - /*CORE.RA.addAssemblylineRecipe( - GregtechItemList.COMET_Cyclotron.get(1), - 20 * 60 * 30, - new ItemStack[] { - CI.getFieldGenerator(6, GTNH ? 32 : 8), - ItemList.Electric_Motor_EV.get(GTNH ? 32 : 8), - ItemList.Tool_Scanner.get(GTNH ? 4 : 2), - CI.getTieredComponent(OrePrefixes.cableGt12, 6, GTNH ? 32 : 16), - CI.getTieredComponent(OrePrefixes.wireGt16, 5, GTNH ? 64 : 32), - CI.getTieredComponent(OrePrefixes.plate, 6, GTNH ? 64 : 32), - ELEMENT.getInstance().GADOLINIUM.getDust(GTNH ? 32 : 8), - ELEMENT.getInstance().SAMARIUM.getDust(GTNH ? 16 : 4), - ALLOY.INCOLOY_MA956.getGear(GTNH ? 8 : 2), - CI.getTieredComponent(OrePrefixes.circuit, 5, GTNH ? 64 : 32), - CI.getTieredComponent(OrePrefixes.circuit, 6, GTNH ? 32 : 16), - CI.getTieredComponent(OrePrefixes.circuit, 7, GTNH ? 16 : 8) - }, - new FluidStack[] { - CI.getTieredFluid(6, 144 * 9 * (GTNH ? 8 : 4)), - CI.getTertiaryTieredFluid(6, 144 * 9 * (GTNH ? 8 : 4)), - CI.getAlternativeTieredFluid(6, 144 * 9 * (GTNH ? 8 : 4)), - CI.getTieredFluid(5, 144 * 9 * (GTNH ? 16 : 8)), - }, - GregtechItemList.Miniature_Fusion.get(1), - 20 * 60 * 5 * (GTNH ? 2 : 1), - (int) MaterialUtils.getVoltageForTier(7));*/ - - - //Plasma Tank - /*CORE.RA.addAssemblylineRecipe( - ItemUtils.getOrePrefixStack(OrePrefixes.pipeMedium, Materials.Superconductor, 1), - 20 * 60 * 5, - new ItemStack[] { - CI.getTieredComponent(OrePrefixes.plate, 5, GTNH ? 32 : 16), - CI.getTieredComponent(OrePrefixes.circuit, 5, GTNH ? 16 : 4), - CI.getTieredComponent(OrePrefixes.pipeHuge, 5, GTNH ? 16 : 4), - CI.getTieredComponent(OrePrefixes.cableGt08, 7, GTNH ? 32 : 16), - CI.getTieredComponent(OrePrefixes.gearGt, 6, GTNH ? 8 : 4), - aCoilWire[2] - }, - new FluidStack[] { - CI.getTieredFluid(4, 144 * 9 * (GTNH ? 16 : 8)), - CI.getTertiaryTieredFluid(4, 144 * 9 * (GTNH ? 16 : 8)), - CI.getAlternativeTieredFluid(4, 144 * 9 * (GTNH ? 16 : 8)), - - }, - GregtechItemList.Plasma_Tank.get(1), - 20 * 60 * 1 * (GTNH ? 2 : 1), - (int) MaterialUtils.getVoltageForTier(5));*/ - - // Turbine Automation Port - CORE.RA.addAssemblylineRecipe( - ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_8_TURBINE_AUTOMATION, 1), - 20 * 60 * 60 * 24, - new Object[] { - CI.getTieredMachineHull(8, 4), - CI.getConveyor(8, GTNH ? 24 : 12), - CI.getElectricMotor(7, GTNH ? 32 : 16), - CI.getElectricPiston(7, GTNH ? 16 : 4), - CI.getEnergyCore(6, GTNH ? 8 : 2), - CI.getPlate(8, GTNH ? 24 : 12), - CI.getTieredComponent(OrePrefixes.screw, 8, GTNH ? 48 : 24), - CI.getTieredComponent(OrePrefixes.bolt, 7, GTNH ? 32 : 16), - CI.getTieredComponent(OrePrefixes.rod, 6, GTNH ? 12 : 6), - new Object[] {CI.getTieredCircuitOreDictName(7), 20}, - CI.getTieredComponent(OrePrefixes.rotor, 6, GTNH ? 16 : 8), - }, - new FluidStack[] { - CI.getTieredFluid(8, 144 * 32), - CI.getAlternativeTieredFluid(7, 144 * 16), - CI.getTertiaryTieredFluid(7, 144 * 16), - ALLOY.BABBIT_ALLOY.getFluidStack(128 * 144), - ALLOY.ZERON_100.getFluidStack(144 * 64) - - }, - GregtechItemList.Hatch_Input_TurbineHousing.get(4), - 20 * 60 * 60 * (GTNH ? 2 : 1), - (int) MaterialUtils.getVoltageForTier(8)); - - - /* - * Contianment casings - */ - - ItemStack[] aGemCasings = new ItemStack[] { - GregtechItemList.Battery_Casing_Gem_1.get(1), - GregtechItemList.Battery_Casing_Gem_2.get(1), - GregtechItemList.Battery_Casing_Gem_3.get(1), - GregtechItemList.Battery_Casing_Gem_4.get(1), - }; - ItemStack[] aResearch = new ItemStack[] { - Particle.getBaseParticle(Particle.UNKNOWN), - GregtechItemList.Battery_Casing_Gem_1.get(1), - GregtechItemList.Battery_Casing_Gem_2.get(1), - GregtechItemList.Battery_Casing_Gem_3.get(1), - }; - - int aCasingSlot = 0; - for (int j = 6; j < 10; j++) { - CORE.RA.addAssemblylineRecipe( - aResearch[aCasingSlot], - 20 * 60 * 60, - new ItemStack[] { - CI.getTieredComponent(OrePrefixes.plate, j-1,16), - CI.getTieredComponent(OrePrefixes.cableGt08, j+1,(GTNH ? 32 : 16)), - CI.getTieredComponent(OrePrefixes.gearGt, j-1, 4), - aCoilWire[aCasingSlot] - }, - new FluidStack[] { - CI.getTieredFluid(j, 144 *(GTNH ? 8 : 4)), - CI.getTertiaryTieredFluid(j-2, 144 * (GTNH ? 16 : 8)), - CI.getAlternativeTieredFluid(j, 144 * (GTNH ? 16 : 12)), - - }, - aGemCasings[aCasingSlot++], - 20 * 60 * 1 * (GTNH ? 2 : 1), - (int) MaterialUtils.getVoltageForTier(j)); - } - - /* - * Gem Battery Recipes - */ - - ItemStack[] aGemBatteries = new ItemStack[] { - GregtechItemList.Battery_Gem_1.get(1), - GregtechItemList.Battery_Gem_2.get(1), - GregtechItemList.Battery_Gem_3.get(1), - GregtechItemList.Battery_Gem_4.get(1), - }; - - ItemStack[] aExoticInputs = new ItemStack[] { - Particle.getBaseParticle(Particle.PROTON), - Particle.getBaseParticle(Particle.ELECTRON), - Particle.getBaseParticle(Particle.CHARM), - Particle.getBaseParticle(Particle.GRAVITON) - }; - aCasingSlot = 0; - for (int j = 6; j < 10; j++) { - CORE.RA.addAssemblylineRecipe( - aExoticInputs[aCasingSlot], - 20 * 60 * 60 * 5, - new Object[] { - aGemCasings[aCasingSlot], - ItemUtils.getSimpleStack(aExoticInputs[aCasingSlot], 16), - CI.getTieredComponent(OrePrefixes.plate, j, 16), - new Object[] {CI.getTieredCircuitOreDictName(j), 8}, - CI.getTieredComponent(OrePrefixes.wireGt16, j+1, GTNH ? 32 : 16), - CI.getTieredComponent(OrePrefixes.bolt, j, GTNH ? 8 : 4), - CI.getTieredComponent(OrePrefixes.screw, j-1, GTNH ? 8 : 4), - }, - new FluidStack[] { - CI.getTieredFluid(j, 144 * 1 * (GTNH ? 16 : 8)), - CI.getTertiaryTieredFluid(j-2, 144 * 2 * (GTNH ? 16 : 8)), - CI.getAlternativeTieredFluid(j, 144 * (GTNH ? 16 : 8)), - CI.getTertiaryTieredFluid(j-1, 144 * (GTNH ? 16 : 8)), - }, - aGemBatteries[aCasingSlot++], - 20 * 60 * 1 * (GTNH ? 2 : 1), - (int) MaterialUtils.getVoltageForTier(j)); - } - - - if (LoadedMods.Baubles) { - //Nano Healer - CORE.RA.addAssemblylineRecipe( - ItemUtils.simpleMetaStack(Items.golden_apple, 1, 1), - 20 * 60 * 10, - new Object[] { - ItemUtils.getSimpleStack(aGemCasings[2], GTNH ? 4 : 2), - CI.getTieredComponent(OrePrefixes.plate, 8, GTNH ? 32 : 16), - new Object[] {CI.getTieredCircuitOreDictName(7), 16}, - CI.getTieredComponent(OrePrefixes.cableGt02, 7, GTNH ? 16 : 8), - CI.getTieredComponent(OrePrefixes.gearGt, 6, GTNH ? 6 : 3), - CI.getTieredComponent(OrePrefixes.screw, 7, GTNH ? 16 : 8), - CI.getTieredComponent(OrePrefixes.bolt, 5, GTNH ? 24 : 12), - CI.getTieredComponent(OrePrefixes.frameGt, 4, GTNH ? 12 : 6), - aCoilWire[3] - }, - new FluidStack[] { - CI.getTieredFluid(7, 144 * 18 * (GTNH ? 16 : 8)), - CI.getTertiaryTieredFluid(7, 144 * 18 * (GTNH ? 16 : 8)), - CI.getAlternativeTieredFluid(6, 144 * 18 * (GTNH ? 16 : 8)), - CI.getAlternativeTieredFluid(7, 144 * 18 * (GTNH ? 16 : 8)), - - }, - ItemUtils.getItemStackFromFQRN("miscutils:personalHealingDevice", 1), - 20 * 60 * 30 * (GTNH ? 2 : 1), - (int) MaterialUtils.getVoltageForTier(7)); - - - - //Charge Pack LuV-UV - - ItemStack[] aChargeResearch = new ItemStack[] { - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore7", 1), - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore8", 1), - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore9", 1), - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore10", 1), - }; - - ItemStack[] aChargeOutputs = new ItemStack[] { - ItemUtils.getSimpleStack(ModItems.itemChargePack_High_1, 1), - ItemUtils.getSimpleStack(ModItems.itemChargePack_High_2, 1), - ItemUtils.getSimpleStack(ModItems.itemChargePack_High_3, 1), - ItemUtils.getSimpleStack(ModItems.itemChargePack_High_4, 1), - }; - - int aCurrSlot = 0; - for (int h = 6; h < 10; h++) { - CORE.RA.addAssemblylineRecipe( - aChargeResearch[aCurrSlot], - 20 * 60 * 10 * (aCurrSlot + 1), - new Object[] { - ItemUtils.getSimpleStack(aGemBatteries[aCurrSlot],2), - aCoilWire[aCurrSlot], - CI.getTieredComponent(OrePrefixes.plate, h, 8), - new Object[] {CI.getTieredCircuitOreDictName(h), 4}, - new Object[] {CI.getTieredCircuitOreDictName(h-1), 8}, - CI.getTieredComponent(OrePrefixes.cableGt12, h-1, 16), - CI.getTieredComponent(OrePrefixes.screw, h, GTNH ? 16 : 8), - CI.getTieredComponent(OrePrefixes.bolt, h-2, GTNH ? 32 : 16), - CI.getFieldGenerator(h, 1), - }, - new FluidStack[] { - CI.getTieredFluid(h, 144 * 4 * (GTNH ? 8 : 4)), - CI.getTertiaryTieredFluid(h-1, 144 * 4 * (GTNH ? 8 : 4)), - CI.getAlternativeTieredFluid(h-1, 144 * 4 * (GTNH ? 8 : 4)), - CI.getAlternativeTieredFluid(h-2, 144 * 4 * (GTNH ? 8 : 4)), - }, - aChargeOutputs[aCurrSlot], - 20 * 60 * 30 * (GTNH ? 2 : 1) * (aCurrSlot+1), - (int) MaterialUtils.getVoltageForTier(h)); - aCurrSlot++; - } - - //Cloaking device - CORE.RA.addAssemblylineRecipe( - ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_9_CLOAKING, 1), - 20 * 60 * 10, - new Object[] { - ItemUtils.getSimpleStack(aGemCasings[3], GTNH ? 4 : 2), - CI.getTieredComponent(OrePrefixes.plate, 8, GTNH ? 32 : 16), - new Object[] {CI.getTieredCircuitOreDictName(7), 16}, - CI.getTieredComponent(OrePrefixes.cableGt04, 8, GTNH ? 16 : 8), - CI.getTieredComponent(OrePrefixes.gearGt, 7, GTNH ? 6 : 3), - CI.getTieredComponent(OrePrefixes.screw, 8, GTNH ? 16 : 8), - CI.getTieredComponent(OrePrefixes.bolt, 7, GTNH ? 24 : 12), - CI.getTieredComponent(OrePrefixes.frameGt, 5, GTNH ? 12 : 6), - aCoilWire[3] - }, - new FluidStack[] { - CI.getTieredFluid(8, 144 * 18 * (GTNH ? 16 : 8)), - CI.getTertiaryTieredFluid(8, 144 * 18 * (GTNH ? 16 : 8)), - CI.getAlternativeTieredFluid(7, 144 * 18 * (GTNH ? 16 : 8)), - CI.getAlternativeTieredFluid(8, 144 * 18 * (GTNH ? 16 : 8)), - - }, - ItemUtils.getItemStackFromFQRN("miscutils:personalCloakingDevice", 1), - 20 * 60 * 30 * (GTNH ? 2 : 1), - (int) MaterialUtils.getVoltageForTier(8)); - } - - - - - - - - - - } - - private static void laserEngraverRecipes() { - - // Laser Sensors and Emitters together - GregtechItemList[] aTransParts = new GregtechItemList[] { - GregtechItemList.TransmissionComponent_ULV, - GregtechItemList.TransmissionComponent_LV, - GregtechItemList.TransmissionComponent_MV, - GregtechItemList.TransmissionComponent_HV, - GregtechItemList.TransmissionComponent_EV, - GregtechItemList.TransmissionComponent_IV, - GregtechItemList.TransmissionComponent_LuV, - GregtechItemList.TransmissionComponent_ZPM, - GregtechItemList.TransmissionComponent_UV, - GregtechItemList.TransmissionComponent_MAX, - }; - for (int i=0;i<10;i++) { - GT_Values.RA.addLaserEngraverRecipe( - CI.getEmitter(i, 2), - CI.getSensor(i, 2), - aTransParts[i].get(1), - 20 * 5, - MaterialUtils.getVoltageForTier(i)); - GT_Recipe.GT_Recipe_Map.sDisassemblerRecipes.addRecipe( - false, - new ItemStack[]{aTransParts[i].get(1)}, - new ItemStack[]{CI.getEmitter(i, 2), CI.getSensor(i, 2)}, - null, - null, - new FluidStack[]{GT_Values.NF}, - new FluidStack[]{GT_Values.NF}, - Math.max(300 >> Math.max(i-1, 0), 1), - MaterialUtils.getVoltageForTier(i), - 0 - ); - } - - - - GT_Values.RA.addLaserEngraverRecipe( - GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Tungsten, 6L), - GregtechItemList.Laser_Lens_Special.get(0), - ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN.getDust(1), - 20 * 60 * 3, - MaterialUtils.getVoltageForTier(ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN.vTier)); - - GT_Values.RA.addLaserEngraverRecipe( - GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Titanium, 8L), - GregtechItemList.Laser_Lens_Special.get(0), - ELEMENT.STANDALONE.ASTRAL_TITANIUM.getDust(1), - 20 * 60 * 2, - MaterialUtils.getVoltageForTier(ELEMENT.STANDALONE.ASTRAL_TITANIUM.vTier)); - - GT_Values.RA.addLaserEngraverRecipe( - ALLOY.NITINOL_60.getBlock(2), - GregtechItemList.Laser_Lens_Special.get(0), - ELEMENT.STANDALONE.ADVANCED_NITINOL.getBlock(1), - 20 * 60 * 1, - MaterialUtils.getVoltageForTier(ELEMENT.STANDALONE.ADVANCED_NITINOL.vTier)); - - GT_Values.RA.addLaserEngraverRecipe( - GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Glass, 64L), - GregtechItemList.Laser_Lens_Special.get(0), - ELEMENT.STANDALONE.CHRONOMATIC_GLASS.getDust(1), - 20 * 60 * 5, - MaterialUtils.getVoltageForTier(ELEMENT.STANDALONE.CHRONOMATIC_GLASS.vTier)); - - - GT_Values.RA.addLaserEngraverRecipe( - CI.getFieldGenerator(6, 1), - CI.getEmitter(7, 2), - ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_1_CONTAINMENT, 1), - 20 * 60 * 5, - MaterialUtils.getVoltageForTier(5)); - - // Distillus Upgrade Chip - GT_Values.RA.addLaserEngraverRecipe( - GregtechItemList.Laser_Lens_WoodsGlass.get(0), - ItemUtils.simpleMetaStack(AgriculturalChem.mBioCircuit, 20, 1), - GregtechItemList.Distillus_Upgrade_Chip.get(1), - 20 * 60 * 5, - MaterialUtils.getVoltageForTier(5)); - - //GT_Values.RA.addLaserEngraverRecipe( - //GregtechItemList.Laser_Lens_WoodsGlass.get(0), - //ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 8, 1), - //ItemUtils.getSimpleStack(ModItems.itemSunnariumBit, 3), - //20 * 60 * 5, - //MaterialUtils.getVoltageForTier(3)); - - - } - - private static void breweryRecipes() { - CORE.RA.addBrewingRecipe(14, EnchantingUtils.getMobEssence(100), EnchantingUtils.getLiquidXP(1332), 100, 120, false); - CORE.RA.addBrewingRecipe(14, EnchantingUtils.getLiquidXP(1332), EnchantingUtils.getMobEssence(100), 100, 120, false); - CORE.RA.addBrewingRecipe(ItemUtils.getSimpleStack(BOP_Block_Registrator.sapling_Rainforest), FluidUtils.getFluidStack("water", 100), FluidUtils.getFluidStack("biomass", 100), 1200, 3, false); - CORE.RA.addBrewingRecipe(ItemUtils.getSimpleStack(BOP_Block_Registrator.sapling_Rainforest), FluidUtils.getFluidStack("honey", 100), FluidUtils.getFluidStack("biomass", 150), 1200, 3, false); - CORE.RA.addBrewingRecipe(ItemUtils.getSimpleStack(BOP_Block_Registrator.sapling_Rainforest), FluidUtils.getFluidStack("juice", 100), FluidUtils.getFluidStack("biomass", 150), 1200, 3, false); - } - - private static void cuttingSawRecipes() { - GT_Values.RA.addCutterRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("blockMeatRaw", 1), //Input - ItemUtils.getItemStackOfAmountFromOreDict("plateMeatRaw", 9), //Output - null, - 16, //Time - 8); //EU - } - - private static void electrolyzerRecipes() { - GT_Values.RA.addElectrolyzerRecipe( - ItemUtils.getSimpleStack(ModItems.dustDecayedRadium226, 1), - null, - null, - FluidUtils.getFluidStack("radon", !GTNH ? 500 : 144), - null, - null, - null, - null, - null, - null, - new int[]{}, - 20*90, - 240); - } - - private static void extruderRecipes() { - // Osmium Credits - if (GT_Values.RA.addExtruderRecipe(ItemUtils.getItemStackOfAmountFromOreDict("blockOsmium", 1), - ItemList.Shape_Mold_Credit.get(0), ItemList.Credit_Greg_Osmium.get(1), - (int) Math.max(Materials.Osmium.getMass() * 2L * 20, 1), 1024)) { - Logger.WARNING("Extruder Recipe: Osmium Credit - Success"); - } - else { - Logger.WARNING("Extruder Recipe: Osmium Credit - Failed"); - } - } - - private static void blastSmelterRecipes() { - - if (!GTNH) { - // Trinium - CORE.RA.addBlastSmelterRecipe( - new ItemStack[] { - ItemUtils.getGregtechCircuit(8), - ELEMENT.getInstance().BISMUTH.getDust(8), - ELEMENT.getInstance().IRON.getDust(64), - ELEMENT.getInstance().CARBON.getDust(16), - ELEMENT.getInstance().GOLD.getDust(16), - ELEMENT.getInstance().SILVER.getDust(16), - ELEMENT.getInstance().OSMIUM.getDust(4), - ELEMENT.getInstance().IRIDIUM.getDust(4), - ELEMENT.getInstance().CERIUM.getDust(8) - }, - FluidUtils.getFluidStack("molten.trinium", 136 * 144), 0, 20 * 3000, - 2040*4); - } - - //Eglin Steel - CORE.RA.addBlastSmelterRecipe( - new ItemStack[] { - ItemUtils.getGregtechCircuit(6), - ELEMENT.getInstance().IRON.getDust(4), - ALLOY.KANTHAL.getDust(1), - ALLOY.INVAR.getDust(5), - ELEMENT.getInstance().SULFUR.getDust(1), - ELEMENT.getInstance().CARBON.getDust(1), - ELEMENT.getInstance().SILICON.getDust(4) - }, - ALLOY.EGLIN_STEEL.getFluidStack(16 * 144), - 0, - 20 * 45, - 120); - - //HG1223 - CORE.RA.addBlastSmelterRecipe( - new ItemStack[] { - ItemUtils.getGregtechCircuit(5), - ELEMENT.getInstance().MERCURY.getCell(1), - ELEMENT.getInstance().BARIUM.getDust(2), - ELEMENT.getInstance().CALCIUM.getDust(2), - ELEMENT.getInstance().COPPER.getDust(3), - }, - ELEMENT.getInstance().OXYGEN.getFluidStack(8000), - ALLOY.HG1223.getFluidStack(16 * 144), - new ItemStack[] { - CI.emptyCells(1) - }, - new int[] {10000}, //Output Chance - 20 * 120, - 30720); - - //NITINOL_60 - CORE.RA.addBlastSmelterRecipe( - new ItemStack[] { - ItemUtils.getGregtechCircuit(2), - ELEMENT.getInstance().TITANIUM.getDust(3), - ELEMENT.getInstance().NICKEL.getDust(2) - }, - ALLOY.NITINOL_60.getFluidStack(5 * 144), - 0, - 20 * 75, - 7680); - - //INDALLOY_140 - CORE.RA.addBlastSmelterRecipe( - new ItemStack[] { - ItemUtils.getGregtechCircuit(5), - ELEMENT.getInstance().BISMUTH.getDust(47), - ELEMENT.getInstance().LEAD.getDust(25), - ELEMENT.getInstance().TIN.getDust(13), - ELEMENT.getInstance().CADMIUM.getDust(10), - ELEMENT.getInstance().INDIUM.getDust(5) - - }, - ALLOY.INDALLOY_140.getFluidStack(100 * 144), - 0, - 20 * 40, - 7680); - - // Germanium Roasting - CORE.RA.addBlastSmelterRecipe( - new ItemStack[] { - ItemUtils.getGregtechCircuit(15), - ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedSphalerite", 8), - ELEMENT.getInstance().CARBON.getDust(32), - }, - Materials.SulfuricAcid.getFluid(2000), - ELEMENT.getInstance().GERMANIUM.getFluidStack(288), - 0, - 20 * 300, - 4000); - - // Ruthenium Roasting - CORE.RA.addBlastSmelterRecipe( - new ItemStack[] { - ItemUtils.getGregtechCircuit(19), - ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedIridium", 8), - ELEMENT.getInstance().CARBON.getDust(32), - }, - Materials.SulfuricAcid.getFluid(2000), - ELEMENT.getInstance().RUTHENIUM.getFluidStack(288), - 0, - 20 * 300, - 8000); - CORE.RA.addBlastSmelterRecipe( - new ItemStack[] { - ItemUtils.getGregtechCircuit(19), - ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedOsmium", 8), - ELEMENT.getInstance().CARBON.getDust(32), - }, - Materials.SulfuricAcid.getFluid(2000), - ELEMENT.getInstance().RUTHENIUM.getFluidStack(288), - 0, - 20 * 300, - 8000); - CORE.RA.addBlastSmelterRecipe( - new ItemStack[] { - ItemUtils.getGregtechCircuit(19), - ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedPlatinum", 8), - ELEMENT.getInstance().CARBON.getDust(32), - }, - Materials.SulfuricAcid.getFluid(2000), - ELEMENT.getInstance().RUTHENIUM.getFluidStack(288), - 0, - 20 * 300, - 8000); - CORE.RA.addBlastSmelterRecipe( - new ItemStack[] { - ItemUtils.getGregtechCircuit(19), - ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedCooperite", 8), - ELEMENT.getInstance().CARBON.getDust(32), - }, - Materials.SulfuricAcid.getFluid(8000), - ELEMENT.getInstance().RUTHENIUM.getFluidStack(144), - 0, - 20 * 300, - 8000); - - // Rhenium Roasting - CORE.RA.addBlastSmelterRecipe( - new ItemStack[] { - ItemUtils.getGregtechCircuit(20), - ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedScheelite", 8), - ELEMENT.getInstance().CARBON.getDust(32), - }, - Materials.SulfuricAcid.getFluid(10000), - ELEMENT.getInstance().RHENIUM.getFluidStack(144), - 0, - 20 * 300, - 4000); - CORE.RA.addBlastSmelterRecipe( - new ItemStack[] { - ItemUtils.getGregtechCircuit(20), - ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedMolybdenite", 8), - ELEMENT.getInstance().CARBON.getDust(32), - }, - Materials.SulfuricAcid.getFluid(7500), - ELEMENT.getInstance().RHENIUM.getFluidStack(144), - 0, - 20 * 300, - 4000); - CORE.RA.addBlastSmelterRecipe( - new ItemStack[] { - ItemUtils.getGregtechCircuit(20), - ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedMolybdenum", 8), - ELEMENT.getInstance().CARBON.getDust(32), - }, - Materials.SulfuricAcid.getFluid(5000), - ELEMENT.getInstance().RHENIUM.getFluidStack(288), - 0, - 20 * 300, - 4000); - - //Thallium Roasting - CORE.RA.addBlastSmelterRecipe( - new ItemStack[] { - ItemUtils.getGregtechCircuit(21), - ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedIron", 12), - ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedPyrite", 16), - ELEMENT.getInstance().CARBON.getDust(64), - }, - Materials.SulfuricAcid.getFluid(5000), - ELEMENT.getInstance().THALLIUM.getFluidStack(288+144), - 0, - 20 * 300, - 8000); - - - - //Strontium processing - CORE.RA.addBlastSmelterRecipe( - new ItemStack[] { - ItemUtils.getGregtechCircuit(21), - MISC_MATERIALS.STRONTIUM_OXIDE.getDust(8), - ELEMENT.getInstance().ALUMINIUM.getDust(8), - }, - null, - ELEMENT.getInstance().OXYGEN.getFluidStack(8000), - new ItemStack[] { - ELEMENT.getInstance().ALUMINIUM.getIngot(8), - ELEMENT.getInstance().STRONTIUM.getIngot(8) - }, - new int[] {10000, 10000}, //Output Chance - 20 * 120, - 480*4); - - } - - private static void fluidcannerRecipes() { - // Sulfuric Acid - CORE.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(Items.glass_bottle), - ItemUtils.getSimpleStack(ModItems.itemSulfuricPotion), FluidUtils.getFluidStack("sulfuricacid", 250), - null); - CORE.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemSulfuricPotion), - ItemUtils.getSimpleStack(Items.glass_bottle), null, FluidUtils.getFluidStack("sulfuricacid", 250)); - - - - // Hydrofluoric Acid - boolean addedGtExtraction = false; - // Try use Internal GT Fluid first - if (Utils.getGregtechVersionAsInt() >= 50929) { - // Hydrofluoric Acid - CORE.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(Items.glass_bottle), - ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), - FluidUtils.getFluidStack("hydrofluoricacid_gt5u", 250), null); - addedGtExtraction = CORE.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), - ItemUtils.getSimpleStack(Items.glass_bottle), null, FluidUtils.getFluidStack("hydrofluoricacid_gt5u", 250)); - } - //Add a Fill recipe for GT++ Acid - CORE.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(Items.glass_bottle), - ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), - FluidUtils.getFluidStack("hydrofluoricacid", 125), null); - //Add an empty recipe, but only if we didn't for the standard GT HF. Prevents Fluid transformation exploits. - if (!addedGtExtraction) { - CORE.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), ItemUtils.getSimpleStack(Items.glass_bottle), null, FluidUtils.getFluidStack("hydrofluoricacid", 125)); - } - - //Gelid Cryotheum - CORE.RA.addFluidExtractionRecipe(ItemUtils.getItemStackOfAmountFromOreDict("dustCryotheum", 1), FluidUtils.getFluidStack("cryotheum", 250), 200, 240); - - //Ender Fluid - CORE.RA.addFluidExtractionRecipe(ItemUtils.getSimpleStack(Items.ender_pearl), FluidUtils.getFluidStack("ender", 250), 100, 30); - - //Blazing Pyrotheum - CORE.RA.addFluidExtractionRecipe(ItemUtils.getItemStackOfAmountFromOreDict("dustPyrotheum", 1), FluidUtils.getFluidStack("pyrotheum", 250), 200, 240); - - - } - - private static void cokeOvenRecipes() { - Logger.INFO("Loading Recipes for Industrial Coking Oven."); - // Wood to Charcoal - //Try use all woods found - ArrayList aLogData = OreDictionary.getOres("logWood"); - if (aLogData.isEmpty()) { - AddGregtechRecipe.addCokeAndPyrolyseRecipes(GT_OreDictUnificator.get(OrePrefixes.log, Materials.Wood, 20L), 20, - GT_ModHandler.getSteam(1000), GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Charcoal, 24L), - FluidUtils.getFluidStack("fluid.coalgas", 1440), 60, 30); } - else { - for (ItemStack stack : aLogData) { - AddGregtechRecipe.addCokeAndPyrolyseRecipes(ItemUtils.getSimpleStack(stack, 20), 20, - GT_ModHandler.getSteam(1000), GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Charcoal, 24L), - FluidUtils.getFluidStack("fluid.coalgas", 1440), 60, 30); - } - } - - // Coal to Coke - AddGregtechRecipe.addCokeAndPyrolyseRecipes(GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Coal, 16L), 22, - GT_ModHandler.getSteam(1000), ItemUtils.getItemStackOfAmountFromOreDict("fuelCoke", 10), - FluidUtils.getFluidStack("fluid.coalgas", 2880), 30, 120); - - // Coke & Coal - CORE.RA.addCokeOvenRecipe(GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Coal, 12L), - ItemUtils.getItemStackOfAmountFromOreDict("fuelCoke", 6), GT_ModHandler.getSteam(2000), - FluidUtils.getFluidStack("fluid.coalgas", 5040), - ItemUtils.getItemStackOfAmountFromOreDict("fuelCoke", 14), 60 * 20, 240); - - } - - private static void matterFabRecipes() { - Logger.INFO("Loading Recipes for Matter Fabricator."); - - try { - - CORE.RA.addMatterFabricatorRecipe(Materials.UUAmplifier.getFluid(1L), // Fluid - // Input - Materials.UUMatter.getFluid(1L), // Fluid Output - 800, // Time in ticks - 32); // EU - } - catch (final NullPointerException e) { - Logger.INFO("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE"); - } - try { - - CORE.RA.addMatterFabricatorRecipe(null, // Fluid Input - Materials.UUMatter.getFluid(1L), // Fluid Output - 3200, // Time in ticks - 32); // EU - } - catch (final NullPointerException e) { - Logger.INFO("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE"); - } - - } - - private static void dehydratorRecipes() { - Logger.INFO("Loading Recipes for Chemical Dehydrator."); - - - ItemStack cropGrape = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cropGrape", 1); - ItemStack foodRaisins = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("foodRaisins", 1); - - if (cropGrape != null && foodRaisins != null) - CORE.RA.addDehydratorRecipe(new ItemStack[] { - CI.getNumberedBioCircuit(20), - cropGrape - }, // Item - null, // Fluid input (slot 1) - null, // Fluid output (slot 2) - new ItemStack[] { - foodRaisins - }, // Output - new int[] { 10000 }, - 10, // Time in ticks - 2); // EU - - - - // Process Waste Water - CORE.RA.addDehydratorRecipe( - new ItemStack[] { - CI.getNumberedBioCircuit(21) - }, - FluidUtils.getFluidStack("fluid.sludge", 1000), - FluidUtils.getFluidStack("nitricacid", 10), - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("dustTinyIron", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustTinyCopper", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustTinyTin", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustTinyNickel", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustTinyCobalt", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustTinyAluminium", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustTinySilver", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustTinyGold", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustTinyIridium", 1) }, - new int[] { 10, 5, 5, 4, 4, 3, 2, 2, 1 }, - 2 * 20, - 500); // EU - - //C8H10 = C8H8 + 2H - CORE.RA.addDehydratorRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(18), - CI.emptyCells(3) - }, - FluidUtils.getFluidStack("fluid.ethylbenzene", 1000), - null, - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("cellStyrene", 1), - ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 2) - }, - new int[] {10000, 10000}, - 3 * 20, - 30); - - /* - * Try Add custom Recipe for drying leather - */ - if (LoadedMods.PamsHarvestcraft && Loader.isModLoaded("Backpack")) { - ItemStack aLeather1, aLeather2; - aLeather1 = ItemUtils.getCorrectStacktype("harvestcraft:hardenedleatherItem", 1); - aLeather2 = ItemUtils.getCorrectStacktype("Backpack:tannedLeather", 1); - CORE.RA.addDehydratorRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(18), - aLeather1 - }, - FluidUtils.getFluidStack("fluid.ethylbenzene", 1000), - null, - new ItemStack[] { - aLeather2 - }, - new int[] {10000}, - 5 * 20, - 180); - } - //Alternative ACETIC ANHYDRIDE recipe for Kevlar Line - //2C2H4O2 = C4H6O3 + H2O - CORE.RA.addDehydratorRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(18), - CI.emptyCells(1) - }, - FluidUtils.getFluidStack("aceticacid", 2000), - MISC_MATERIALS.ACETIC_ANHYDRIDE.getFluidStack(1000), - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("cellWater", 1), - }, - new int[] {10000}, - 30 * 20, - 480); - } - private static void largeChemReactorRecipes() { - //Styrene - //C8H10 = C8H8 + 2H - CORE.RA.addMultiblockChemicalRecipe( - new ItemStack[]{CI.getNumberedCircuit(24)}, - new FluidStack[]{ - FluidUtils.getFluidStack("fluid.ethylbenzene", 1000) - }, - new FluidStack[]{ - MaterialUtils.getMaterial("Styrene").getFluid(1000), - Materials.Hydrogen.getGas(2000) - }, - null, - 30, - 30); - //Short-cut Styrene - //C6H6 + C2H4 = C8H8 + 2H - CORE.RA.addMultiblockChemicalRecipe( - new ItemStack[]{CI.getNumberedCircuit(24)}, - new FluidStack[]{ - MaterialUtils.getMaterial("Ethylene").getGas(500), - MaterialUtils.getMaterial("Benzene").getFluid(500) - }, - new FluidStack[]{ - MaterialUtils.getMaterial("Styrene").getFluid(500), - Materials.Hydrogen.getGas(1000) - }, - null, - 240, - 120); - } - - private static void fissionFuelRecipes() { - try { - - } - catch (final NullPointerException e) { - Logger.INFO("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE"); - } - } - - private static void assemblerRecipes() { - // ItemUtils.getSimpleStack(GregtechItemList.Casing_Vanadium_Redox.get(1) - addAR(ItemUtils.getItemStackOfAmountFromOreDict("plateVanadium", 32), - ItemUtils.getItemStackOfAmountFromOreDict("frameGtVanadiumSteel", 8), - FluidUtils.getFluidStack("oxygen", 8000), - ItemUtils.simpleMetaStack(ModItems.itemHalfCompleteCasings, 0, 4), 16, 60); - addAR(ItemUtils.simpleMetaStack(ModItems.itemHalfCompleteCasings, 0, 2), - ItemUtils.getItemStackOfAmountFromOreDict("plateVanadiumGallium", 8), - FluidUtils.getFluidStack("molten.tantalum", 144 * 4), - ItemUtils.simpleMetaStack(ModItems.itemHalfCompleteCasings, 1, 8), 32, 120); - - /* - addAR(ItemUtils.simpleMetaStack(ModItems.itemHalfCompleteCasings, 1, 1), - ItemUtils.getItemStackOfAmountFromOreDict("plateDenseLead", 4), FluidUtils.getFluidStack("oxygen", 16000), - ItemUtils.getSimpleStack(GregtechItemList.Casing_Vanadium_Redox.get(1), 1), 64, 240); - */ - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - ItemUtils.simpleMetaStack(ModItems.itemHalfCompleteCasings, 1, 1), - ItemUtils.getItemStackOfAmountFromOreDict("plateDenseLead", 4), - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(3), 4), - ItemUtils.getItemStackOfAmountFromOreDict("wireGt01SuperconductorHV", 2) - }, - FluidUtils.getFluidStack("oxygen", 16000), - ItemUtils.getSimpleStack(GregtechItemList.Casing_Vanadium_Redox.get(1), 1), - 64, - 240 - ); - - //Tier 2-6 - ItemStack T1 = GregtechItemList.Casing_Vanadium_Redox.get(1); - ItemStack T2 = GregtechItemList.Casing_Vanadium_Redox_IV.get(1); - ItemStack T3 = GregtechItemList.Casing_Vanadium_Redox_LuV.get(1); - ItemStack T4 = GregtechItemList.Casing_Vanadium_Redox_ZPM.get(1); - ItemStack T5 = GregtechItemList.Casing_Vanadium_Redox_UV.get(1); - ItemStack T6 = GregtechItemList.Casing_Vanadium_Redox_MAX.get(1); - - - /* - addAR(T1, - ItemUtils.getItemStackOfAmountFromOreDict("plateDenseTitanium", 4), - FluidUtils.getFluidStack("nitrogen", 16000), - T2, 120, 2000); - */ - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - T1, - ItemUtils.getItemStackOfAmountFromOreDict("plateDenseTitanium", 4), - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(4), 4), - ItemUtils.getItemStackOfAmountFromOreDict("wireGt01SuperconductorEV", 2) - }, - FluidUtils.getFluidStack("nitrogen", 16000), - T2, - 120, - 2000 - ); - - - /* - addAR(T2, - ItemUtils.getItemStackOfAmountFromOreDict("plateDenseTungstenSteel", 4), - FluidUtils.getFluidStack("helium", 8000), - T3, 250, 8000); - */ - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - T2, - ItemUtils.getItemStackOfAmountFromOreDict("plateDenseTungstenSteel", 4), - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(5), 4), - ItemUtils.getItemStackOfAmountFromOreDict("wireGt01SuperconductorIV", 2) - }, - FluidUtils.getFluidStack("helium", 8000), - T3, - 250, - 8000 - ); - /* - addAR(T3, - ItemUtils.getItemStackOfAmountFromOreDict("plateAlloyIridium", 16), - FluidUtils.getFluidStack("argon", 4000), - T4, 500, 32000); - */ - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - T3, - ItemUtils.getItemStackOfAmountFromOreDict("plateAlloyIridium", 16), - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(6), 4), - ItemUtils.getItemStackOfAmountFromOreDict("wireGt01SuperconductorLuV", 2) - }, - FluidUtils.getFluidStack("argon", 4000), - T4, - 500, - 32000 - ); - /* - addAR(T4, - ItemUtils.getItemStackOfAmountFromOreDict("plateDenseNaquadah", 4), - FluidUtils.getFluidStack("radon", 4000), - T5, 1000, 128000); - */ - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - T4, - ItemUtils.getItemStackOfAmountFromOreDict("plateDenseNaquadah", 4), - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(7), 4), - ItemUtils.getItemStackOfAmountFromOreDict("wireGt01SuperconductorZPM", 2) - }, - FluidUtils.getFluidStack("radon", 4000), - T5, - 1000, - 128000 - ); - /* - addAR(T5, - ItemUtils.getItemStackOfAmountFromOreDict("plateDenseAmericium", 4), - FluidUtils.getFluidStack("krypton", 500), - T6, 2000, 512000); - */ - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - T5, - ItemUtils.getItemStackOfAmountFromOreDict("plateDenseAmericium", 4), - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(8), 4), - ItemUtils.getItemStackOfAmountFromOreDict("wireGt01SuperconductorUV", 2) - }, - FluidUtils.getFluidStack("krypton", 500), - T6, - 2000, - 512000 - ); - - addAR(ItemUtils.getItemStackOfAmountFromOreDict( - "dustClay", 32), - GregtechItemList.Bomb_Cast_Mold.get(0), - FluidUtils.getWater(4000), - GregtechItemList.Bomb_Cast.get(4), - 30, 120); - addAR(ItemUtils.getSimpleStack(Items.redstone, 32), - ItemUtils.getSimpleStack(ModItems.itemRope, 16), - Materials.Glue.getFluid(500), - ItemUtils.getSimpleStack(ModItems.itemDetCable, 24), - 30, - 120); - - - /*addAR(ItemUtils.getItemStackOfAmountFromOreDict("plateIncoloy020", 16), - ItemUtils.getItemStackOfAmountFromOreDict("frameGtIncoloyMA956", 4), null, - GregtechItemList.Casing_Power_SubStation.get(4), 80, 120);*/ - - - /*CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - GregtechItemList.Casing_Multi_Use.get(1), - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(6), 1), - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(4), 8), - CI.sensor_HV, - CI.emitter_HV, - CI.fieldGenerator_HV, - }, - null, - ItemUtils.getSimpleStack(Dimension_Everglades.blockPortalFrame), - 20*20, - 2048); - - */ - - CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] {ItemUtils.getSimpleStack(ModItems.itemRope, 6)}, null, ItemUtils.getSimpleStack(ModBlocks.blockNet, 2), 1*20, 8); - CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] {ItemUtils.getSimpleStack(CI.explosiveITNT, 2), ItemUtils.getSimpleStack(CI.explosiveTNT, 4), ELEMENT.getInstance().SULFUR.getDust(2), ELEMENT.getInstance().IRON.getFrameBox(1)}, null, ItemUtils.getSimpleStack(ModBlocks.blockMiningExplosive, 3), 5*20, 60); - CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] {ItemUtils.getSimpleStack(Items.nether_star), ItemUtils.getItemStackOfAmountFromOreDict("plateTungstenSteel", 8), ItemUtils.getItemStackOfAmountFromOreDict("stickBlackSteel", 8)}, null, ItemUtils.getSimpleStack(ModBlocks.blockWitherGuard, 64), 30*20, 500); - - ItemStack aFluidReg1 = ItemUtils.getValueOfItemList("FluidRegulator_LV", ItemList.Pump_LV).get(1); - ItemStack aFluidReg2 = ItemUtils.getValueOfItemList("FluidRegulator_MV", ItemList.Pump_MV).get(1); - ItemStack aFluidReg3 = ItemUtils.getValueOfItemList("FluidRegulator_HV", ItemList.Pump_HV).get(1); - ItemStack aFluidReg4 = ItemUtils.getValueOfItemList("FluidRegulator_EV", ItemList.Pump_EV).get(1); - - CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - aFluidReg1, - CI.electricMotor_LV, - CI.getTieredComponent(OrePrefixes.bolt, 1, GTNH ? 8 : 4), - ItemUtils.getItemStackOfAmountFromOreDict("ringBrass", 1), - ItemUtils.getItemStackOfAmountFromOreDict("stickBrass", 1), - ItemUtils.getItemStackOfAmountFromOreDict("plateSteel", 2) - }, null, ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 1, 1), 10*20, 30); - CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - aFluidReg2, - CI.electricMotor_MV, - CI.getTieredComponent(OrePrefixes.bolt, 2, GTNH ? 8 : 4), - ItemUtils.getItemStackOfAmountFromOreDict("ringInvar", 1), - ItemUtils.getItemStackOfAmountFromOreDict("stickInvar", 1), - ItemUtils.getItemStackOfAmountFromOreDict("plateAluminium", 2) - }, null, ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 2, 1), 10*20*2, 120); - CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - aFluidReg3, - CI.electricMotor_HV, - CI.getTieredComponent(OrePrefixes.bolt, 3, GTNH ? 8 : 4), - ItemUtils.getItemStackOfAmountFromOreDict("ringChrome", 1), - ItemUtils.getItemStackOfAmountFromOreDict("stickChrome", 1), - ItemUtils.getItemStackOfAmountFromOreDict("plateStainlessSteel", 2) - }, null, ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 3, 1), 10*20*3, 480); - - CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - aFluidReg4, - CI.electricMotor_EV, - CI.getTieredComponent(OrePrefixes.bolt, 4, GTNH ? 8 : 4), - ItemUtils.getItemStackOfAmountFromOreDict("ringTitanium", 1), - ItemUtils.getItemStackOfAmountFromOreDict("stickTitanium", 1), - ItemUtils.getItemStackOfAmountFromOreDict("plateTungstenSteel", 2) - }, null, ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 4, 1), 10*20*4, 1960); - - GT_Values.RA.addAssemblerRecipe(ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 1, 1), CI.getNumberedCircuit(20), ItemUtils.simpleMetaStack(ModItems.toolGregtechPump, 1000, 1), 30, 30); - GT_Values.RA.addAssemblerRecipe(ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 2, 1), CI.getNumberedCircuit(20), ItemUtils.simpleMetaStack(ModItems.toolGregtechPump, 1001, 1), 120, 120); - GT_Values.RA.addAssemblerRecipe(ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 3, 1), CI.getNumberedCircuit(20), ItemUtils.simpleMetaStack(ModItems.toolGregtechPump, 1002, 1), 480, 480); - GT_Values.RA.addAssemblerRecipe(ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 4, 1), CI.getNumberedCircuit(20), ItemUtils.simpleMetaStack(ModItems.toolGregtechPump, 1003, 1), 1820, 1820); - - //Low tier Charge Packs - - final ItemStack[] aPackBatteries = new ItemStack[] { - ItemList.Battery_RE_LV_Lithium.get(4), - ItemList.Battery_RE_MV_Lithium.get(4), - ItemList.Battery_RE_HV_Lithium.get(4), - GregtechItemList.Battery_RE_EV_Lithium.get(4), - ItemList.Energy_LapotronicOrb.get(4), - }; - final ItemStack[] aPackPlates = new ItemStack[] { - CI.getPlate(1,8), - CI.getPlate(2,8), - CI.getPlate(3,8), - CI.getPlate(4,8), - CI.getPlate(5,8), - }; - final ItemStack[] aPackWire = new ItemStack[] { - CI.getTieredComponent(OrePrefixes.wireGt02, 1,6), - CI.getTieredComponent(OrePrefixes.wireGt04, 2,6), - CI.getTieredComponent(OrePrefixes.wireGt08, 3,6), - CI.getTieredComponent(OrePrefixes.wireGt12, 4,6), - CI.getTieredComponent(OrePrefixes.wireGt16, 5,6), - }; - final ItemStack[] aPackCircuit = new ItemStack[] { - CI.getTieredComponent(OrePrefixes.circuit, 1,4), - CI.getTieredComponent(OrePrefixes.circuit, 2,4), - CI.getTieredComponent(OrePrefixes.circuit, 3,4), - CI.getTieredComponent(OrePrefixes.circuit, 4,4), - CI.getTieredComponent(OrePrefixes.circuit, 5,4), - }; - final ItemStack[] aPackRing = new ItemStack[] { - CI.getTieredComponent(OrePrefixes.ring, 1,12), - CI.getTieredComponent(OrePrefixes.ring, 2,12), - CI.getTieredComponent(OrePrefixes.ring, 3,12), - CI.getTieredComponent(OrePrefixes.ring, 4,12), - CI.getTieredComponent(OrePrefixes.ring, 5,12), - }; - final ItemStack[] aPackOutput = new ItemStack[] { - ItemUtils.getSimpleStack(ModItems.itemChargePack_Low_1), - ItemUtils.getSimpleStack(ModItems.itemChargePack_Low_2), - ItemUtils.getSimpleStack(ModItems.itemChargePack_Low_3), - ItemUtils.getSimpleStack(ModItems.itemChargePack_Low_4), - ItemUtils.getSimpleStack(ModItems.itemChargePack_Low_5) - }; - - for (int i = 1; i < 6; i++) { - - int aAS = i-1; - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - aPackPlates[aAS], - aPackRing[aAS], - aPackWire[aAS], - aPackCircuit[aAS], - aPackBatteries[aAS], - CI.getSensor(i, GTNH ? 4 : 2), - }, - CI.getTieredFluid(i, (144 * (GTNH ? 4 : 2))), - aPackOutput[aAS], - 30 * 20 * i, - (int) GT_Values.V[i]); - } - - - if (!GTNH) { - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.WroughtIron, 1L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.WroughtIron, 2L), GregtechItemList.Fluid_Cell_1L.get(1L, new Object[0]), 50, 32); - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Bronze, 1L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Bronze, 2L), GregtechItemList.Fluid_Cell_16L.get(1L, new Object[0]), 50, 32); - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Brass, 1L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Brass, 2L), GregtechItemList.Fluid_Cell_36L.get(1L, new Object[0]), 75, 32); - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Invar, 1L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Invar, 2L), GregtechItemList.Fluid_Cell_144L.get(1L, new Object[0]), 75, 32); - - } else { - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.WroughtIron, 8L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.WroughtIron, 4L), GregtechItemList.Fluid_Cell_1L.get(1L, new Object[0]), 50, 32); - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Bronze, 8L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Bronze, 4L), GregtechItemList.Fluid_Cell_16L.get(1L, new Object[0]), 50, 32); - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Brass, 8L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Brass, 4L), GregtechItemList.Fluid_Cell_36L.get(1L, new Object[0]), 75, 32); - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Invar, 8L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Invar, 4L), GregtechItemList.Fluid_Cell_144L.get(1L, new Object[0]), 75, 32); - } - } - - - if (LoadedMods.Baubles) { - - // Turbine Housing Research Page - CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - ItemUtils.getGregtechCircuit(17), - ItemUtils.getItemStackOfAmountFromOreDict("plateTrinium", GTNH ? 64 : 32), - CI.getSensor(6, GTNH ? 6 : 3), - CI.getBolt(7, GTNH ? 64 : 32), - ItemUtils.getItemStackOfAmountFromOreDict("wireFinePlatinum", GTNH ? 64 : 32), - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(7), GTNH ? 12 : 6) - }, - CI.getAlternativeTieredFluid(7, 144 * 32), - ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_8_TURBINE_AUTOMATION, 1), - 20 * 60 * 5, - (int) GT_Values.V[6]); - - // Cloaking Device Research Page - CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - ItemUtils.getGregtechCircuit(17), - ItemUtils.getSimpleStack(ModItems.itemCircuitLFTR, 4), - CI.getFieldGenerator(6, GTNH ? 16 : 8), - ItemUtils.getItemStackOfAmountFromOreDict("wireFinePalladium", GTNH ? 32 : 16), - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(6), GTNH ? 12 : 6) - }, - CI.getAlternativeTieredFluid(7, 144 * 32), - ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_9_CLOAKING, 1), - 20 * 60 * 10, - (int) GT_Values.V[7]); - - // Supreme Pizza Gloves - CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - ItemUtils.getGregtechCircuit(19), - ItemUtils.getSimpleStack(ModItems.itemRope, GTNH ? 32 : 16), - ItemUtils.getItemStackOfAmountFromOreDict("gearGtSmallWroughtIron", GTNH ? 8 : 4), - ItemUtils.getItemStackOfAmountFromOreDict("wireFineCopper", GTNH ? 32 : 16), - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(1), GTNH ? 2 : 1) - }, - FluidUtils.getFluidStack("molten.rubber", 2000), - ItemUtils.getSimpleStack(ModItems.itemPersonalFireProofDevice), - 20 * 60 * 5, - 30); - } - - } - - private static boolean addAR(final ItemStack inputA, final ItemStack inputB, final FluidStack inputFluidA, - final ItemStack outputA, final int seconds, final int voltage) { - // return GT_Values.RA.addAssemblerRecipe(inputA, inputB, outputA, - // seconds*20, voltage); - return GT_Values.RA.addAssemblerRecipe(inputA, inputB, inputFluidA, outputA, seconds * 20, voltage); - } - - private static void distilleryRecipes() { - Logger.INFO("Registering Distillery/Distillation Tower Recipes."); - GT_Values.RA.addDistilleryRecipe(ItemList.Circuit_Integrated.getWithDamage(0L, 4L, new Object[0]), - FluidUtils.getFluidStack("air", 1000), FluidUtils.getFluidStack("helium", 1), 400, 30, false); - GT_Values.RA.addDistillationTowerRecipe(FluidUtils.getFluidStack("air", 20000), - FluidUtils.getFluidStackArray("helium", 25), ItemUtils.getSimpleStack(ModItems.itemHydrogenBlob, 1), - 200, 60); - - // Apatite Distillation - /* - * so if you dissolve aparite in sulphuric acid you'll get a mixture of - * SO2, H2O, HF and HCl - */ - final FluidStack[] apatiteOutput = { - FluidUtils.getFluidStack("sulfurousacid", 3800), - FluidUtils.getFluidStack("hydrogenchloride", 1000), - FluidUtils.getFluidStack("hydrofluoricacid", 400) }; - GT_Values.RA.addDistillationTowerRecipe( - FluidUtils.getFluidStack("sulfuricapatite", 5200), - apatiteOutput, null, - 45 * 20, - 120); - - final FluidStack[] sulfurousacidOutput = { - FluidUtils.getFluidStack("sulfurdioxide", 500), - FluidUtils.getFluidStack("water", 500) }; - GT_Values.RA.addDistillationTowerRecipe( - FluidUtils.getFluidStack("sulfurousacid", 1000), - sulfurousacidOutput, - null, - 10 * 20, - 60); - - if (!GTNH) { - final FluidStack[] sulfurdioxideOutput = { - FluidUtils.getFluidStack("oxygen", 2000) - }; - GT_Values.RA.addDistillationTowerRecipe( - FluidUtils.getFluidStack("sulfurdioxide", 144 * 3), - sulfurdioxideOutput, - ItemUtils.getItemStackOfAmountFromOreDict("dustSulfur", 1), - 5 * 20, - 30); - } - } - - private static void addFuels() { - Logger.INFO("Registering New Fuels."); - - if (!GTNH) { - GT_Values.RA.addFuel(ItemUtils.simpleMetaStack("EnderIO:bucketFire_water", 0, 1), null, 120, 0); - GT_Values.RA.addFuel(ItemUtils.simpleMetaStack("EnderIO:bucketRocket_fuel", 0, 1), null, 112, 0); - GT_Values.RA.addFuel(ItemUtils.simpleMetaStack("EnderIO:bucketHootch", 0, 1), null, 36, 0); - } - - HotFuel.addNewHotFuel(FluidUtils.getLava(83), FluidUtils.getPahoehoeLava(83), - new ItemStack[] { ItemUtils.getItemStackOfAmountFromOreDict("nuggetCopper", 1), - ItemUtils.getItemStackOfAmountFromOreDict("nuggetTin", 1), - ItemUtils.getItemStackOfAmountFromOreDict("nuggetGold", 1), - ItemUtils.getItemStackOfAmountFromOreDict("nuggetSilver", 1), - ItemUtils.getItemStackOfAmountFromOreDict("nuggetTantalum", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustSmallTungstate", 1), - ItemUtils.getSimpleStack(Blocks.obsidian) }, - new int[] { 2000, 1000, 250, 250, 250, 250, 500 }, 0); - - HotFuel.addNewHotFuel(FluidUtils.getPahoehoeLava(83), GT_Values.NF, - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("nuggetBronze", 1), - ItemUtils.getItemStackOfAmountFromOreDict("nuggetElectrum", 1), - ItemUtils.getItemStackOfAmountFromOreDict("nuggetTantalum", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustSmallTungstate", 1), - ItemUtils.getSimpleStack(Blocks.obsidian) }, - new int[] { 750, 250, 250, 250, 1850 }, 0); - - HotFuel.addNewHotFuel( - MISC_MATERIALS.SOLAR_SALT_HOT.getFluidStack(1000), - MISC_MATERIALS.SOLAR_SALT_COLD.getFluidStack(1000), - FluidUtils.getSuperHeatedSteam(10000), - 0); - - /* - * HotFuel.addNewHotFuel( FluidUtils.getFluidStack("ic2hotcoolant", - * 100), GT_Values.NF, new ItemStack[]{}, new int[]{}, 0); - */ - - ThermalFuel.addSteamTurbineFuel(FluidUtils.getFluidStack("steam", 1024)); - - // CORE.RA.addFuel(UtilsItems.simpleMetaStack("EnderIO:bucketRocket_fuel", - // 0, 1), null, 112, 0); - GT_Values.RA.addFuel(ItemUtils.getSimpleStack(Items.lava_bucket), null, 32, 2); - GT_Values.RA.addFuel(ItemUtils.getIC2Cell(2), null, 32, 2); - GT_Values.RA.addFuel(ItemUtils.getIC2Cell(11), null, 24, 2); - // System.exit(1); - } - - private static void extractorRecipes() { - Logger.INFO("Registering Extractor Recipes."); - GT_ModHandler.addExtractionRecipe(GregtechItemList.Battery_RE_EV_Sodium.get(1L, new Object[0]), - ItemList.Battery_Hull_HV.get(4L, new Object[0])); - GT_ModHandler.addExtractionRecipe(GregtechItemList.Battery_RE_EV_Cadmium.get(1L, new Object[0]), - ItemList.Battery_Hull_HV.get(4L, new Object[0])); - GT_ModHandler.addExtractionRecipe(GregtechItemList.Battery_RE_EV_Lithium.get(1L, new Object[0]), - ItemList.Battery_Hull_HV.get(4L, new Object[0])); - } - - private static void fluidExtractorRecipes() { - - } - - private static void chemicalBathRecipes() { - - } - - private static void centrifugeRecipes() { - - GT_Values.RA.addCentrifugeRecipe( - CI.getNumberedAdvancedCircuit(2), - MISC_MATERIALS.SOLAR_SALT_COLD.getCell(5), - null, - null, - MISC_MATERIALS.SODIUM_NITRATE.getDust(15), - MISC_MATERIALS.POTASSIUM_NITRATE.getDust(10), - CI.emptyCells(5), - null, - null, - null, - null, - 20 * 30, - 120); - - } - - private static void mixerRecipes() { - - //S + 2O = SO2 - GT_Values.RA.addMixerRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("dustSulfur", 1), - null, - null, - null, - FluidUtils.getFluidStack("oxygen", 2000), - FluidUtils.getFluidStack("sulfurdioxide", 1000), - null, - 600, - 60); - - GT_Values.RA.addMixerRecipe( - CI.getNumberedAdvancedCircuit(2), - CI.emptyCells(5), - MISC_MATERIALS.SODIUM_NITRATE.getDust(15), - MISC_MATERIALS.POTASSIUM_NITRATE.getDust(10), - null, - null, - MISC_MATERIALS.SOLAR_SALT_COLD.getCell(5), - 20 * 10, - 120); - - } - - private static void chemicalReactorRecipes() { - - //Bombs - GT_Values.RA.addChemicalRecipe( - ItemUtils.getSimpleStack(ModItems.itemBombCasing, 4), - ItemUtils.getSimpleStack(RocketFuels.Ammonium_Nitrate_Dust, 8), - Materials.Fuel.getFluid(1000), - null, - ItemUtils.getSimpleStack(ModItems.itemBombUnf, 4), - 300 * 20); - - GT_Values.RA.addChemicalRecipe( - ItemUtils.getSimpleStack(ModItems.itemBombUnf, 4), - ItemUtils.getSimpleStack(ModItems.itemDetCable, 4), - FluidUtils.getFluidStack(RocketFuels.Kerosene, 100), - null, - ItemUtils.getSimpleStack(ModItems.itemBomb, 4), - 10 * 20); - - GT_Values.RA.addChemicalRecipe( - CI.getNumberedAdvancedCircuit(21), - ItemUtils.getItemStackOfAmountFromOreDict("dustApatite", 32), - FluidUtils.getFluidStack("sulfuricacid", 4000), - FluidUtils.getFluidStack("sulfuricapatite", 8000), - ItemUtils.getItemStackOfAmountFromOreDict("dustSmallSulfur", 8), - 20 * 20); - - //KOH + HNO3 = KNO3 + H2O - GT_Values.RA.addChemicalRecipe( - ItemUtils.getSimpleStack(GenericChem.mPotassiumHydroxide, 3), - CI.getNumberedAdvancedCircuit(1), - Materials.NitricAcid.getFluid(1000), - Materials.Water.getFluid(1000), - MISC_MATERIALS.POTASSIUM_NITRATE.getDust(5), - 100, - 30); - - //Na2CO3 + 2HNO3 = 2NaNO3 + CO2 + H2O - GT_Values.RA.addChemicalRecipe( - ItemUtils.getSimpleStack(AgriculturalChem.mSodiumCarbonate, 6), - CI.getNumberedAdvancedCircuit(1), - Materials.NitricAcid.getFluid(2000), - Materials.CarbonDioxide.getGas(1000), - MISC_MATERIALS.SODIUM_NITRATE.getDust(10), - 100, - 30); - - } - - private static void blastFurnaceRecipes() { - - //public boolean addBlastRecipe( - //ItemStack aInput1, ItemStack aInput2, - //FluidStack aFluidInput, FluidStack aFluidOutput, - //ItemStack aOutput1, ItemStack aOutput2, - //int aDuration, int aEUt, int aLevel) - - //Synthetic Graphite - GT_Values.RA.addBlastRecipe( - CI.getNumberedCircuit(22), - ALLOY.SILICON_CARBIDE.getDust(16), - ELEMENT.getInstance().NITROGEN.getFluidStack(4000), - GT_Values.NF, - ItemUtils.getItemStackOfAmountFromOreDict("dustGraphite", 8), - ItemUtils.getItemStackOfAmountFromOreDict("dustSmallSilicon", 8), - 60 * 20, - MaterialUtils.getVoltageForTier(GTNH ? 5 : 4), - 4500); - - //Bomb Casings - GT_Values.RA.addBlastRecipe( - GregtechItemList.Bomb_Cast.get(4), - ALLOY.STEEL.getDust(16), - ELEMENT.getInstance().OXYGEN.getFluidStack(2000), - GT_Values.NF, - GregtechItemList.Bomb_Cast_Molten.get(4), - null, - 4 * 60 * 20, - MaterialUtils.getVoltageForTier(GTNH ? 3 : 2), - 2800); - - //Krypton Processing - if (ModItems.itemHotTitaniumIngot != null) { - GT_Values.RA.addBlastRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("ingotTitanium", 1), - CI.getNumberedCircuit(16), - GT_Values.NF, - GT_Values.NF, - ItemUtils.getItemStackOfAmountFromOreDict("ingotHotTitanium", 1), - null, - 10 * 20, - 500, - Materials.Titanium.mBlastFurnaceTemp); - } - - } - - private static void autoclaveRecipes() { - - } - - private static void benderRecipes() { - if (CORE.ConfigSwitches.enableMultiblock_PowerSubstation) { - GT_Values.RA.addBenderRecipe(ItemUtils.getItemStackOfAmountFromOreDict("ingotVanadium", 1), - ItemUtils.getItemStackOfAmountFromOreDict("plateVanadium", 1), 8, 16); - } - } - - private static void compressorRecipes() { - GT_ModHandler.addCompressionRecipe(ItemUtils.getItemStackOfAmountFromOreDict("dustClay", 1), - ItemUtils.getItemStackOfAmountFromOreDict("plateClay", 1)); - GT_ModHandler.addCompressionRecipe(ItemUtils.getItemStackOfAmountFromOreDict("dustMeatRaw", 1), - ItemUtils.getItemStackOfAmountFromOreDict("plateMeatRaw", 1)); - GT_ModHandler.addCompressionRecipe(ItemUtils.getItemStackOfAmountFromOreDict("dustMeatRaw", 9), - ItemUtils.getItemStackOfAmountFromOreDict("blockMeatRaw", 1)); - CORE.RA.addCompressorRecipe(ItemList.FusionComputer_UV.get(9), GregtechItemList.Compressed_Fusion_Reactor.get(1), (int) GT_Values.V[7], (int) GT_Values.V[8]); - } - - private static void macerationRecipes() { - - GT_ModHandler.addPulverisationRecipe(ItemUtils.getItemStackOfAmountFromOreDict("blockMeatRaw", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustMeatRaw", 9)); - - GT_ModHandler.addPulverisationRecipe(GregtechItemList.Bomb_Cast_Broken.get(1), - ItemUtils.getItemStackOfAmountFromOreDict("dustClay", 3)); - - if (ItemUtils.simpleMetaStack("chisel:limestone", 0, 1) != null) { - GT_ModHandler.addPulverisationRecipe(ItemUtils.getItemStackOfAmountFromOreDict("limestone", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustCalcite", 4)); - } - - } - - private static void cyclotronRecipes() { - - // Polonium - CORE.RA.addCyclotronRecipe(CI.getNumberedCircuit(1), FluidUtils.getFluidStack("molten.bismuth", 1), - new ItemStack[] { GregtechItemList.Pellet_RTG_PO210.get(1) }, null, new int[] { 100 }, 20 * 300 * 100, 2040 * 4, - 500 * 20); - - // Americium - CORE.RA.addCyclotronRecipe(CI.getNumberedCircuit(1), FluidUtils.getFluidStack("molten.americium", 1), - new ItemStack[] { GregtechItemList.Pellet_RTG_AM241.get(4) }, null, new int[] { 2500 }, 20 * 300 * 100, 1020 * 4, - 500 * 20); //PO Special Value - - // Strontium u235 - CORE.RA.addCyclotronRecipe(CI.getNumberedCircuit(1), FluidUtils.getFluidStack("molten.uranium235", 10), - new ItemStack[] { GregtechItemList.Pellet_RTG_SR90.get(1) }, null, new int[] { 570 }, 20 * 300 * 100, 1020 * 4, - 500 * 20); //PO Special Value - - // Strontium u233 - CORE.RA.addCyclotronRecipe(CI.getNumberedCircuit(1), FluidUtils.getFluidStack("molten.uranium233", 10), - new ItemStack[] { GregtechItemList.Pellet_RTG_SR90.get(1) }, null, new int[] { 660 }, 20 * 300 * 100, 1020 * 4, - 500 * 20); //PO Special Value - - // Strontium pu239 - CORE.RA.addCyclotronRecipe(CI.getNumberedCircuit(1), FluidUtils.getFluidStack("molten.plutonium239", 10), - new ItemStack[] { GregtechItemList.Pellet_RTG_SR90.get(1) }, null, new int[] { 220 }, 20 * 300 * 100, 1020 * 4, - 500 * 20); //PO Special Value - - // Plutonium - CORE.RA.addCyclotronRecipe(CI.getNumberedCircuit(1), FluidUtils.getFluidStack("molten.plutonium238", 1), - new ItemStack[] { GregtechItemList.Pellet_RTG_PU238.get(2) }, null, new int[] { 780 }, 20 * 300 * 100, 1020 * 4, - 500 * 20); //PO Special Value - - // Neptunium - CORE.RA.addCyclotronRecipe(new ItemStack[] {ELEMENT.getInstance().URANIUM238.getDust(1) }, FluidUtils.getFluidStack("deuterium", 400), - new ItemStack[] {ItemUtils.getSimpleStack(ModItems.dustNeptunium238)}, null, new int[] { 500 }, 20 * 5, 500 * 4, - 500 * 20); //PO Special Value - - - /** - * Particle Science - */ - - - // Quark Smash - CORE.RA.addCyclotronRecipe( - CI.getNumberedCircuit(3), - FluidUtils.getFluidStack("plasma.hydrogen", 100), - new ItemStack[] { - Particle.getBaseParticle(Particle.UP), - Particle.getBaseParticle(Particle.DOWN), - Particle.getBaseParticle(Particle.CHARM), - Particle.getBaseParticle(Particle.STRANGE), - Particle.getBaseParticle(Particle.TOP), - Particle.getBaseParticle(Particle.BOTTOM), - }, - null, - new int[] { 50, 50, 50, 50, 50, 50 }, - 20 * 300 * 9, - (int) MaterialUtils.getVoltageForTier(7), - 750 * 20); - - // Lepton Smash - CORE.RA.addCyclotronRecipe( - CI.getNumberedCircuit(6), - FluidUtils.getFluidStack("plasma.helium", 1500), - new ItemStack[] { - Particle.getBaseParticle(Particle.ELECTRON), - Particle.getBaseParticle(Particle.MUON), - Particle.getBaseParticle(Particle.TAU), - Particle.getBaseParticle(Particle.ELECTRON_NEUTRINO), - Particle.getBaseParticle(Particle.MUON_NEUTRINO), - Particle.getBaseParticle(Particle.TAU_NEUTRINO), - }, - null, - new int[] { 600, 40, 20, 15, 10, 5 }, - 20 * 300 * 8, - (int) MaterialUtils.getVoltageForTier(7), - 750 * 20); - - // Boson Smash - CORE.RA.addCyclotronRecipe( - CI.getNumberedCircuit(9), - FluidUtils.getFluidStack("plasma.helium", 1500), - new ItemStack[] { - Particle.getBaseParticle(Particle.GLUON), - Particle.getBaseParticle(Particle.PHOTON), - Particle.getBaseParticle(Particle.Z_BOSON), - Particle.getBaseParticle(Particle.W_BOSON), - Particle.getBaseParticle(Particle.HIGGS_BOSON), - }, - null, - new int[] { 160, 260, 150, 150, 1 }, - 20 * 300 * 6, - (int) MaterialUtils.getVoltageForTier(7), - 750 * 20); - - - // Mixed Smash 1 - CORE.RA.addCyclotronRecipe( - CI.getNumberedCircuit(12), - FluidUtils.getFluidStack("plasma.beryllium", 2500), - new ItemStack[] { - Particle.getBaseParticle(Particle.GRAVITON), - Particle.getBaseParticle(Particle.ETA_MESON), - Particle.getBaseParticle(Particle.PION), - Particle.getBaseParticle(Particle.PROTON), - Particle.getBaseParticle(Particle.NEUTRON), - Particle.getBaseParticle(Particle.LAMBDA), - Particle.getBaseParticle(Particle.OMEGA), - Particle.getBaseParticle(Particle.HIGGS_BOSON), - }, - null, - new int[] { 10, 20, 20, 10, 10, 5, 5, 2 }, - 17 * 247 * 32, - (int) MaterialUtils.getVoltageForTier(8), - 750 * 20); - - // Graviton Smash - CORE.RA.addCyclotronRecipe( - CI.getNumberedCircuit(15), - FluidUtils.getFluidStack("plasma.hydrogen", GTNH ? 50 : 10), - new ItemStack[] { - Particle.getBaseParticle(Particle.GRAVITON), - Particle.getBaseParticle(Particle.UNKNOWN) - }, - null, - new int[] {15, 100}, - 20 * (GTNH ? 90 : 30), - (int) MaterialUtils.getVoltageForTier(6), - 1000 * 20); - - FluidStack aPlasma = Materials.Duranium.getMolten(GTNH ? 40 : 10); - FluidStack aPlasma_NULL = Materials._NULL.getPlasma(1); - - if (aPlasma == null || aPlasma.isFluidEqual(aPlasma_NULL)) { - aPlasma = Materials.Americium.getMolten(GTNH ? 20 : 5); - } - - // Quantum Anomaly - CORE.RA.addCyclotronRecipe( - new ItemStack[] { - CI.getNumberedCircuit(24), - Particle.getBaseParticle(Particle.UNKNOWN), - }, - aPlasma, - new ItemStack[] { - GregtechItemList.Laser_Lens_Special.get(1) - }, - null, - new int[] {100}, - 20 * (GTNH ? 25 : 60), - (int) MaterialUtils.getVoltageForTier(8), - 500 * 20); - - /* - * Ions - */ - - int IonCount = 2; - int tenCountA = (GTNH ? 2 : 1); - int tenCountB = 0; - for (String y : IonParticles.MetaToNameMap.values()) { - if (y.toLowerCase().contains("hydrogen")) { - continue; - } - FluidStack aPlasma2 = FluidUtils.getFluidStack("plasma."+y.toLowerCase(), 2); - Materials aTestMat = MaterialUtils.getMaterial(y); - FluidStack aPlasma3 = aTestMat != null ? aTestMat.getPlasma(2) : aPlasma2; - - // Ionize Plasma - if ((aPlasma2 != null && !aPlasma2.isFluidEqual(aPlasma_NULL)) || (aPlasma3 != null && !aPlasma3.isFluidEqual(aPlasma_NULL))) { - CORE.RA.addCyclotronRecipe( - CI.getNumberedCircuit(1+(tenCountA-1)), - aPlasma2 != null ? aPlasma2 : aPlasma3, - new ItemStack[] { - Particle.getIon(y, 1), - Particle.getIon(y, 2), - Particle.getIon(y, 3), - Particle.getIon(y, -1), - Particle.getIon(y, -2), - Particle.getIon(y, -3), - Particle.getIon(y, 1), - Particle.getIon(y, 2), - Particle.getIon(y, -1), - }, - null, - new int[] { 275, 250, 225, 275, 250, 225, 275, 250, 275}, - 20 * 20 * (IonCount++) * tenCountA, - (int) MaterialUtils.getVoltageForTier(7), - 1500 * 20 * tenCountA); - } - else { - Logger.INFO("Plasma for "+y+" does not exist, please report this to Alkalus."); - } - - if (tenCountB == 12) { - tenCountB = 0; - tenCountA++; - } - else { - tenCountB++; - } - } - - // Generate Hydrogen Ion Recipe - CORE.RA.addCyclotronRecipe( - CI.getNumberedCircuit(24), - FluidUtils.getWildcardFluidStack("hydrogen", 1000), - new ItemStack[] { - Particle.getIon("Hydrogen", 1), - Particle.getIon("Hydrogen", 2), - Particle.getIon("Hydrogen", 3), - Particle.getIon("Hydrogen", 1), - Particle.getIon("Hydrogen", 2), - Particle.getIon("Hydrogen", 3), - Particle.getIon("Hydrogen", -1), - Particle.getIon("Hydrogen", -2), - Particle.getIon("Hydrogen", -3) - }, - null, - new int[] { 500, 500, 500, 500, 500, 500, 500, 500, 500 }, - 20 * 20, - (int) MaterialUtils.getVoltageForTier(6), - 2500); - - // Generate Hydrogen Plasma Recipe - CORE.RA.addCyclotronRecipe( - new ItemStack[] { - Particle.getIon("Hydrogen", 0), - ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 1) - }, - null, - new ItemStack[] { - Particle.getBaseParticle(Particle.PROTON), - Particle.getBaseParticle(Particle.NEUTRON), - Particle.getBaseParticle(Particle.ELECTRON), - Particle.getBaseParticle(Particle.UNKNOWN), - Particle.getBaseParticle(Particle.UNKNOWN), - Particle.getBaseParticle(Particle.UNKNOWN), - CI.emptyCells(1) - }, - FluidUtils.getFluidStack("plasma.hydrogen", 100), - new int[] { 1250, 1250, 1250, 750, 750, 750, 10000 }, - 20 * 60 * 2, - (int) MaterialUtils.getVoltageForTier(6), - 750 * 20); - - CORE.RA.addCyclotronRecipe( - new ItemStack[] { - CI.getNumberedCircuit(21), - Particle.getIon("Hydrogen", 0), - }, - FluidUtils.getFluidStack("hydrogen", 1000), - new ItemStack[] { - Particle.getBaseParticle(Particle.PROTON), - Particle.getBaseParticle(Particle.NEUTRON), - Particle.getBaseParticle(Particle.ELECTRON), - Particle.getBaseParticle(Particle.UNKNOWN), - Particle.getBaseParticle(Particle.UNKNOWN), - Particle.getBaseParticle(Particle.UNKNOWN), - }, - FluidUtils.getFluidStack("plasma.hydrogen", 100), - new int[] { 1250, 1250, 1250, 750, 750, 750 }, - 20 * 60 * 2, - (int) MaterialUtils.getVoltageForTier(6), - 750 * 20); - - - // Generate Protons Easily - CORE.RA.addCyclotronRecipe( - new ItemStack[] { - CI.getNumberedCircuit(20), - Particle.getIon("Hydrogen", 0) - }, - FluidUtils.getWildcardFluidStack("hydrogen", 100), - new ItemStack[] { - Particle.getBaseParticle(Particle.PROTON), - Particle.getBaseParticle(Particle.PROTON), - Particle.getBaseParticle(Particle.PROTON), - Particle.getBaseParticle(Particle.PROTON), - Particle.getBaseParticle(Particle.PROTON), - Particle.getBaseParticle(Particle.PROTON), - Particle.getBaseParticle(Particle.PROTON), - Particle.getBaseParticle(Particle.PROTON), - Particle.getBaseParticle(Particle.PROTON), - }, - null, - new int[] { 750, 750, 750, 750, 750, 750, 750, 750, 750 }, - 20 * 20, - (int) MaterialUtils.getVoltageForTier(6), - 1500); - - CORE.RA.addCyclotronRecipe( - new ItemStack[] { - CI.getNumberedCircuit(22), - Particle.getBaseParticle(Particle.UNKNOWN), - }, - FluidUtils.getWildcardFluidStack("hydrogen", 100), - new ItemStack[] { - Particle.getBaseParticle(Particle.PROTON), - Particle.getBaseParticle(Particle.PROTON), - Particle.getBaseParticle(Particle.PROTON), - Particle.getBaseParticle(Particle.PROTON), - Particle.getBaseParticle(Particle.PROTON), - Particle.getBaseParticle(Particle.PROTON), - Particle.getBaseParticle(Particle.PROTON), - Particle.getBaseParticle(Particle.PROTON), - Particle.getBaseParticle(Particle.PROTON), - }, - null, - new int[] { 375, 375, 375, 375, 375, 375, 375, 375, 375 }, - 20 * 20, - (int) MaterialUtils.getVoltageForTier(6), - 1500); - - - //Create Strange Dust - CORE.RA.addCyclotronRecipe( - new ItemStack[] { - ELEMENT.getInstance().PLUTONIUM238.getDust(1), - Particle.getBaseParticle(Particle.UNKNOWN), - Particle.getBaseParticle(Particle.UNKNOWN), - Particle.getBaseParticle(Particle.UNKNOWN), - Particle.getBaseParticle(Particle.UNKNOWN), - Particle.getBaseParticle(Particle.UNKNOWN), - Particle.getBaseParticle(Particle.UNKNOWN), - Particle.getBaseParticle(Particle.UNKNOWN), - Particle.getBaseParticle(Particle.UNKNOWN), - }, - FluidUtils.getFluidStack(FluidUtils.getWildcardFluidStack("ender", 1000), 1000), - new ItemStack[] { - ORES.DEEP_EARTH_REACTOR_FUEL_DEPOSIT.getDust(1) - }, - null, - new int[] { 2500 }, - 20 * 60 * 15, - (int) MaterialUtils.getVoltageForTier(7), - 250); - - } - - private static void sifterRecipes() { - - } - - private static void electroMagneticSeperatorRecipes() { - - if (!GTNH) { - // Trinium - GT_Values.RA.addElectromagneticSeparatorRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedNaquadah", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustNaquadah", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustSmallNaquadahEnriched", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustSmallTrinium", 1), new int[] { 10000, 2500, 5000 }, - 20 * 20, 24); - - // Trinium - GT_Values.RA.addElectromagneticSeparatorRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedIridium", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustIridium", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustSmallOsmium", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustSmallTrinium", 1), new int[] { 10000, 2500, 5000 }, - 20 * 20, 24); - - // Trinium - GT_Values.RA.addElectromagneticSeparatorRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedWulfenite", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustWulfenite", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustSmallTrinium", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustSmallTrinium", 1), new int[] { 10000, 3000, 3000 }, - 20 * 20, 24); - } - - } - - private static void advancedMixerRecipes() { - // HgBa2Ca2Cu3O8 - /*CORE.RA.addMixerRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("cellMercury", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustBarium", 2), - ItemUtils.getItemStackOfAmountFromOreDict("dustCalcium", 2), - ItemUtils.getItemStackOfAmountFromOreDict("dustCopper", 3), - FluidUtils.getFluidStack("oxygen", 8000), - null, CI.emptyCells(1), ALLOY.HG1223.getDust(16), null, null, - 30 * 20, 500); */ - - } - + public static void run() { + Logger.INFO("Loading Recipes through GregAPI for Industrial Multiblocks."); + execute(); + } + + private static void execute() { + cokeOvenRecipes(); + electrolyzerRecipes(); + assemblerRecipes(); + fluidcannerRecipes(); + distilleryRecipes(); + extractorRecipes(); + fluidExtractorRecipes(); + chemicalBathRecipes(); + chemicalReactorRecipes(); + dehydratorRecipes(); + blastFurnaceRecipes(); + + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + largeChemReactorRecipes(); + fusionRecipes(); + } + + fissionFuelRecipes(); + autoclaveRecipes(); + compressorRecipes(); + mixerRecipes(); + macerationRecipes(); + centrifugeRecipes(); + benderRecipes(); + cyclotronRecipes(); + blastSmelterRecipes(); + // advancedMixerRecipes(); + sifterRecipes(); + electroMagneticSeperatorRecipes(); + extruderRecipes(); + cuttingSawRecipes(); + breweryRecipes(); + laserEngraverRecipes(); + assemblyLineRecipes(); + latheRecipes(); + vacuumFreezerRecipes(); + fluidheaterRecipes(); + chemplantRecipes(); + packagerRecipes(); + alloySmelterRecipes(); + implosionRecipes(); + + /** + * Special Recipe handlers + */ + RECIPES_SeleniumProcessing.init(); + RECIPES_RareEarthProcessing.init(); + + addFuels(); + } + + private static void alloySmelterRecipes() { + + // Wood's Glass Laser Lens + GT_Values.RA.addAlloySmelterRecipe( + MISC_MATERIALS.WOODS_GLASS.getDust(5), + ItemList.Shape_Mold_Ball.get(0), + GregtechItemList.Laser_Lens_WoodsGlass.get(1), + 20 * 300, + MaterialUtils.getVoltageForTier(3)); + } + + private static void packagerRecipes() {} + + private static void implosionRecipes() { + + // GT_Values.RA.addImplosionRecipe( + // ItemUtils.getSimpleStack(ModItems.itemSunnariumBit, 9), + // 16, + // ItemUtils.getSimpleStack(AdvancedSolarPanel.itemSunnariumPart, 1), + // GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Glowstone, 8)); + + } + + private static void chemplantRecipes() { + + // This is subsequently absorbed in water to form nitric acid and nitric oxide. + // 3 NO2 (g) + H2O (l) → 2 HNO3 (aq) + NO (g) (ΔH = −117 kJ/mol) + // The nitric oxide is cycled back for reoxidation. Alternatively, if the last step is carried out in air: + // 4 NO2 (g) + O2 (g) + 2 H2O (l) → 4 HNO3 (aq) + + // Advanced method for Nitric Acid Production + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(17), CI.getPinkCatalyst(0), + }, + new FluidStack[] { + FluidUtils.getFluidStack(GenericChem.Nitrogen_Dioxide, 4000), + FluidUtils.getAir(4000), + FluidUtils.getWater(2000), + }, + new ItemStack[] {}, + new FluidStack[] { + FluidUtils.getFluidStack("nitricacid", 4000), + }, + 10 * 20, + 480, + 3); + + // Advanced recipe for Fluorine Production + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(17), + CI.getPurpleCatalyst(0), + ItemUtils.getSimpleStack(Blocks.sandstone, 64), + ItemUtils.getSimpleStack(Blocks.sandstone, 64) + }, + new FluidStack[] {FluidUtils.getFluidStack("nitricacid", 4000), FluidUtils.getAir(8000)}, + new ItemStack[] { + FLUORIDES.FLUORITE.getOre(8), + FLUORIDES.FLUORITE.getOre(4), + FLUORIDES.FLUORITE.getOre(4), + FLUORIDES.FLUORITE.getOre(4), + }, + new FluidStack[] {}, + new int[] {0, 2500, 2000, 1500}, + 10 * 20, + 1024, + 5); + + // Advanced recipe for Fluorine Production + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(17), + CI.getPurpleCatalyst(0), + ItemUtils.getSimpleStack(Blocks.sand, 64), + ItemUtils.getSimpleStack(Blocks.sand, 64) + }, + new FluidStack[] {FluidUtils.getFluidStack("nitricacid", 5000), FluidUtils.getAir(12000)}, + new ItemStack[] { + FLUORIDES.FLUORITE.getOre(4), + FLUORIDES.FLUORITE.getOre(2), + FLUORIDES.FLUORITE.getOre(2), + FLUORIDES.FLUORITE.getOre(2), + }, + new FluidStack[] {}, + new int[] {7500, 1500, 1000, 500}, + 10 * 20, + 1024, + 5); + + // 3NO2 + H2O = 2HNO3 + NO + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(16), CI.getPinkCatalyst(0), + }, + new FluidStack[] { + FluidUtils.getFluidStack(GenericChem.Nitrogen_Dioxide, 3000), FluidUtils.getDistilledWater(1000) + }, + new ItemStack[] {}, + new FluidStack[] { + FluidUtils.getFluidStack("nitricacid", 2000), + FluidUtils.getFluidStack(GenericChem.Nitric_Oxide, 1000), + }, + 10 * 20, + 480, + 2); + + // Produce Boric Acid + // Na2B4O7·10H2O + 2HCl = 4B(OH)3 + 2NaCl + 5H2O + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(21), ItemUtils.getItemStackOfAmountFromOreDict("dustBorax", 23), + }, + new FluidStack[] {FluidUtils.getFluidStack(GenericChem.HydrochloricAcid, 2000)}, + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("dustSalt", 4), + }, + new FluidStack[] {FluidUtils.getFluidStack("boricacid", 4000), FluidUtils.getWater(5000)}, + 20 * 30, + MaterialUtils.getVoltageForTier(3), + 3); + + // Produce Th232 + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(22), + ELEMENT.getInstance().THORIUM.getDust(16) + }, + new FluidStack[] {FluidUtils.getDistilledWater(2000), FluidUtils.getFluidStack("boricacid", 1500)}, + new ItemStack[] { + ELEMENT.getInstance().THORIUM.getSmallDust(32), + ELEMENT.getInstance().THORIUM232.getDust(2), + ELEMENT.getInstance().THORIUM232.getSmallDust(2), + ELEMENT.getInstance().URANIUM232.getDust(1), + }, + new FluidStack[] {}, + new int[] {0, 0, 1000, 250}, + 20 * 300, + MaterialUtils.getVoltageForTier(4), + 4); + + // Modify Sapling into Pine Sapling + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] {CI.getNumberedBioCircuit(6), ItemUtils.getSimpleStack(Blocks.sapling, 32)}, + new FluidStack[] { + FluidUtils.getFluidStack("fluid.geneticmutagen", 2000), FluidUtils.getDistilledWater(8000) + }, + new ItemStack[] {ItemUtils.getSimpleStack(BOP_Block_Registrator.sapling_Pine, 16)}, + new FluidStack[] {}, + 120 * 20, + 64, + 2); + + // Convert GT++ Plutonium239 into normal Plutonium + if (Materials.Plutonium.mDefaultLocalName.equals("Plutonium 239")) { + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(16), + ELEMENT.getInstance().PLUTONIUM239.getDust(1) + }, + new FluidStack[] {}, + new ItemStack[] {ItemUtils.getItemStackOfAmountFromOreDict("dustPlutonium", 1)}, + new FluidStack[] {}, + 5 * 20, + 1, + 2); + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(16), + ELEMENT.getInstance().PLUTONIUM239.getSmallDust(1) + }, + new FluidStack[] {}, + new ItemStack[] {ItemUtils.getItemStackOfAmountFromOreDict("dustSmallPlutonium", 1)}, + new FluidStack[] {}, + 5 * 20, + 1, + 2); + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(16), + ELEMENT.getInstance().PLUTONIUM239.getTinyDust(1) + }, + new FluidStack[] {}, + new ItemStack[] {ItemUtils.getItemStackOfAmountFromOreDict("dustTinyPlutonium", 1)}, + new FluidStack[] {}, + 5 * 20, + 1, + 2); + } + + int aLaureniumTier = ALLOY.LAURENIUM.vTier; + // Adding Recipes for Casings + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(12), + CI.getTieredMachineCasing(aLaureniumTier - 1), + ALLOY.LAURENIUM.getPlate(8), + CI.getGear(aLaureniumTier, 2) + }, + new FluidStack[] { + CI.getTieredFluid(aLaureniumTier, 2 * 144), + CI.getAlternativeTieredFluid(aLaureniumTier - 1, 4 * 144), + CI.getTertiaryTieredFluid(aLaureniumTier - 2, 6 * 144) + }, + new ItemStack[] {GregtechItemList.Casing_Machine_Custom_3.get(1)}, + new FluidStack[] {}, + 20 * 20, + MaterialUtils.getVoltageForTier(aLaureniumTier - 2), + 5); + + int aBotmiumTier = ALLOY.BOTMIUM.vTier; + // Adding Recipes for Casings + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(12), + CI.getTieredMachineCasing(aBotmiumTier - 1), + ALLOY.BOTMIUM.getPlate(8), + CI.getGear(aBotmiumTier, 2) + }, + new FluidStack[] { + CI.getTieredFluid(aBotmiumTier, 2 * 144), + CI.getAlternativeTieredFluid(aBotmiumTier - 1, 4 * 144), + CI.getTertiaryTieredFluid(aBotmiumTier - 2, 6 * 144) + }, + new ItemStack[] {GregtechItemList.Casing_Machine_Custom_4.get(1)}, + new FluidStack[] {}, + 20 * 20, + MaterialUtils.getVoltageForTier(aBotmiumTier - 2), + 6); + + // Refine GT HF into GT++ HF + if (FluidUtils.doesHydrofluoricAcidGtExist()) { + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(22), + }, + new FluidStack[] {FluidUtils.getHydrofluoricAcid(2000), FluidUtils.getHydrofluoricAcidGT(5000)}, + new ItemStack[] {}, + new FluidStack[] {FluidUtils.getHydrofluoricAcid(4500)}, + 30 * 20, + 480, + 3); + } + } + + private static void fluidheaterRecipes() { + GT_Values.RA.addFluidHeaterRecipe( + CI.getNumberedCircuit(20), FluidUtils.getWater(1000), FluidUtils.getHotWater(1000), 30, 30); + } + + private static void vacuumFreezerRecipes() { + GT_Values.RA.addVacuumFreezerRecipe( + GregtechItemList.Bomb_Cast_Molten.get(1), GregtechItemList.Bomb_Cast_Set.get(1), 20 * 30); + } + + private static void latheRecipes() { + + GT_Values.RA.addLatheRecipe( + ALLOY.EGLIN_STEEL.getBlock(1), GregtechItemList.Bomb_Cast_Mold.get(1), null, 20 * 60 * 15, 120); + + GT_Values.RA.addLatheRecipe( + GregtechItemList.Bomb_Cast_Set.get(1), + GregtechItemList.Bomb_Cast_Broken.get(2), + ItemUtils.getSimpleStack(ModItems.itemBombCasing, 2), + 20 * 60 * 5, + 30); + } + + private static void fusionRecipes() { + + /** + * Adds a Fusion reactor Recipe + * + * @param aInput1 = first Input (not null, and respects StackSize) + * @param aInput2 = second Input (not null, and respects StackSize) + * @param aOutput = Output of the Fusion (can be null, and respects StackSize) + * @param aFusionDurationInTicks = How many ticks the Fusion lasts (must be > 0) + * @param aFusionEnergyPerTick = The EU generated per Tick (can even be negative!) + * @param aEnergyNeededForStartingFusion = EU needed for heating the Reactor up (must be >= 0) + */ + + // Hydrogen Plasma + /*CORE.RA.addFusionReactorRecipe( + Particle.getIon("Hydrogen", 0), + Particle.getIon("Hydrogen", 0), + Materials.Hydrogen.getPlasma(1), + 5000, + 16, + 4096, + 40000000);*/ + + // Hypogen Creation + GT_Values.RA.addFusionReactorRecipe( + ELEMENT.STANDALONE.DRAGON_METAL.getFluidStack(144), + ELEMENT.STANDALONE.RHUGNOR.getFluidStack(288), + ELEMENT.STANDALONE.HYPOGEN.getFluidStack(36), + 2048 * 4, + MaterialUtils.getVoltageForTier(9), + 600000000 * 2); + + // Rhugnor + GT_Values.RA.addFusionReactorRecipe( + MaterialUtils.getMaterial("Infinity", "Neutronium").getMolten(144), + ALLOY.QUANTUM.getFluidStack(288), + ELEMENT.STANDALONE.RHUGNOR.getFluidStack(144), + 512, + MaterialUtils.getVoltageForTier(8), + 2000000000); + } + + private static void assemblyLineRecipes() { + + ItemStack[] aCoilWire = new ItemStack[] { + ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 0, GTNH ? 64 : 32), + ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 1, GTNH ? 64 : 32), + ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 2, GTNH ? 64 : 32), + ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 3, GTNH ? 64 : 32), + }; + + // Containment Casings + CORE.RA.addAssemblylineRecipe( + ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_1_CONTAINMENT, 1), + 20 * 60 * 30, + new Object[] { + ItemList.Field_Generator_IV.get(GTNH ? 32 : 16), + ItemList.Electric_Motor_EV.get(GTNH ? 64 : 32), + ItemList.Energy_LapotronicOrb.get(GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.cableGt12, 7, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.wireGt16, 6, GTNH ? 64 : 32), + ItemUtils.getOrePrefixStack(OrePrefixes.plate, Materials.Naquadria, GTNH ? 64 : 16), + ELEMENT.getInstance().GADOLINIUM.getDust(GTNH ? 32 : 8), + ELEMENT.getInstance().SAMARIUM.getDust(GTNH ? 16 : 4), + ALLOY.ARCANITE.getGear(GTNH ? 8 : 2), + new Object[] {CI.getTieredCircuitOreDictName(5), 64}, + new Object[] {CI.getTieredCircuitOreDictName(6), 32}, + new Object[] {CI.getTieredCircuitOreDictName(7), 16}, + GregtechItemList.Laser_Lens_Special.get(1), + aCoilWire[3] + }, + new FluidStack[] { + ALLOY.NITINOL_60.getFluidStack(144 * 9 * (GTNH ? 4 : 2)), + ALLOY.ENERGYCRYSTAL.getFluidStack(144 * 9 * (GTNH ? 8 : 4)), + ALLOY.TUMBAGA.getFluidStack(144 * 9 * (GTNH ? 32 : 8)), + ALLOY.NICHROME.getFluidStack(144 * 1 * (GTNH ? 16 : 4)), + }, + ItemUtils.getSimpleStack(ModBlocks.blockCasings3Misc, 15, 32), + 20 * 60 * 10 * (GTNH ? 2 : 1), + (int) MaterialUtils.getVoltageForTier(6)); + + // Slow Fusion Controller + /*CORE.RA.addAssemblylineRecipe( + GregtechItemList.COMET_Cyclotron.get(1), + 20 * 60 * 30, + new ItemStack[] { + CI.getFieldGenerator(6, GTNH ? 32 : 8), + ItemList.Electric_Motor_EV.get(GTNH ? 32 : 8), + ItemList.Tool_Scanner.get(GTNH ? 4 : 2), + CI.getTieredComponent(OrePrefixes.cableGt12, 6, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.wireGt16, 5, GTNH ? 64 : 32), + CI.getTieredComponent(OrePrefixes.plate, 6, GTNH ? 64 : 32), + ELEMENT.getInstance().GADOLINIUM.getDust(GTNH ? 32 : 8), + ELEMENT.getInstance().SAMARIUM.getDust(GTNH ? 16 : 4), + ALLOY.INCOLOY_MA956.getGear(GTNH ? 8 : 2), + CI.getTieredComponent(OrePrefixes.circuit, 5, GTNH ? 64 : 32), + CI.getTieredComponent(OrePrefixes.circuit, 6, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.circuit, 7, GTNH ? 16 : 8) + }, + new FluidStack[] { + CI.getTieredFluid(6, 144 * 9 * (GTNH ? 8 : 4)), + CI.getTertiaryTieredFluid(6, 144 * 9 * (GTNH ? 8 : 4)), + CI.getAlternativeTieredFluid(6, 144 * 9 * (GTNH ? 8 : 4)), + CI.getTieredFluid(5, 144 * 9 * (GTNH ? 16 : 8)), + }, + GregtechItemList.Miniature_Fusion.get(1), + 20 * 60 * 5 * (GTNH ? 2 : 1), + (int) MaterialUtils.getVoltageForTier(7));*/ + + // Plasma Tank + /*CORE.RA.addAssemblylineRecipe( + ItemUtils.getOrePrefixStack(OrePrefixes.pipeMedium, Materials.Superconductor, 1), + 20 * 60 * 5, + new ItemStack[] { + CI.getTieredComponent(OrePrefixes.plate, 5, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.circuit, 5, GTNH ? 16 : 4), + CI.getTieredComponent(OrePrefixes.pipeHuge, 5, GTNH ? 16 : 4), + CI.getTieredComponent(OrePrefixes.cableGt08, 7, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.gearGt, 6, GTNH ? 8 : 4), + aCoilWire[2] + }, + new FluidStack[] { + CI.getTieredFluid(4, 144 * 9 * (GTNH ? 16 : 8)), + CI.getTertiaryTieredFluid(4, 144 * 9 * (GTNH ? 16 : 8)), + CI.getAlternativeTieredFluid(4, 144 * 9 * (GTNH ? 16 : 8)), + + }, + GregtechItemList.Plasma_Tank.get(1), + 20 * 60 * 1 * (GTNH ? 2 : 1), + (int) MaterialUtils.getVoltageForTier(5));*/ + + // Turbine Automation Port + CORE.RA.addAssemblylineRecipe( + ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_8_TURBINE_AUTOMATION, 1), + 20 * 60 * 60 * 24, + new Object[] { + CI.getTieredMachineHull(8, 4), + CI.getConveyor(8, GTNH ? 24 : 12), + CI.getElectricMotor(7, GTNH ? 32 : 16), + CI.getElectricPiston(7, GTNH ? 16 : 4), + CI.getEnergyCore(6, GTNH ? 8 : 2), + CI.getPlate(8, GTNH ? 24 : 12), + CI.getTieredComponent(OrePrefixes.screw, 8, GTNH ? 48 : 24), + CI.getTieredComponent(OrePrefixes.bolt, 7, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.rod, 6, GTNH ? 12 : 6), + new Object[] {CI.getTieredCircuitOreDictName(7), 20}, + CI.getTieredComponent(OrePrefixes.rotor, 6, GTNH ? 16 : 8), + }, + new FluidStack[] { + CI.getTieredFluid(8, 144 * 32), + CI.getAlternativeTieredFluid(7, 144 * 16), + CI.getTertiaryTieredFluid(7, 144 * 16), + ALLOY.BABBIT_ALLOY.getFluidStack(128 * 144), + ALLOY.ZERON_100.getFluidStack(144 * 64) + }, + GregtechItemList.Hatch_Input_TurbineHousing.get(4), + 20 * 60 * 60 * (GTNH ? 2 : 1), + (int) MaterialUtils.getVoltageForTier(8)); + + /* + * Contianment casings + */ + + ItemStack[] aGemCasings = new ItemStack[] { + GregtechItemList.Battery_Casing_Gem_1.get(1), + GregtechItemList.Battery_Casing_Gem_2.get(1), + GregtechItemList.Battery_Casing_Gem_3.get(1), + GregtechItemList.Battery_Casing_Gem_4.get(1), + }; + ItemStack[] aResearch = new ItemStack[] { + Particle.getBaseParticle(Particle.UNKNOWN), + GregtechItemList.Battery_Casing_Gem_1.get(1), + GregtechItemList.Battery_Casing_Gem_2.get(1), + GregtechItemList.Battery_Casing_Gem_3.get(1), + }; + + int aCasingSlot = 0; + for (int j = 6; j < 10; j++) { + CORE.RA.addAssemblylineRecipe( + aResearch[aCasingSlot], + 20 * 60 * 60, + new ItemStack[] { + CI.getTieredComponent(OrePrefixes.plate, j - 1, 16), + CI.getTieredComponent(OrePrefixes.cableGt08, j + 1, (GTNH ? 32 : 16)), + CI.getTieredComponent(OrePrefixes.gearGt, j - 1, 4), + aCoilWire[aCasingSlot] + }, + new FluidStack[] { + CI.getTieredFluid(j, 144 * (GTNH ? 8 : 4)), + CI.getTertiaryTieredFluid(j - 2, 144 * (GTNH ? 16 : 8)), + CI.getAlternativeTieredFluid(j, 144 * (GTNH ? 16 : 12)), + }, + aGemCasings[aCasingSlot++], + 20 * 60 * 1 * (GTNH ? 2 : 1), + (int) MaterialUtils.getVoltageForTier(j)); + } + + /* + * Gem Battery Recipes + */ + + ItemStack[] aGemBatteries = new ItemStack[] { + GregtechItemList.Battery_Gem_1.get(1), + GregtechItemList.Battery_Gem_2.get(1), + GregtechItemList.Battery_Gem_3.get(1), + GregtechItemList.Battery_Gem_4.get(1), + }; + + ItemStack[] aExoticInputs = new ItemStack[] { + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.ELECTRON), + Particle.getBaseParticle(Particle.CHARM), + Particle.getBaseParticle(Particle.GRAVITON) + }; + aCasingSlot = 0; + for (int j = 6; j < 10; j++) { + CORE.RA.addAssemblylineRecipe( + aExoticInputs[aCasingSlot], + 20 * 60 * 60 * 5, + new Object[] { + aGemCasings[aCasingSlot], + ItemUtils.getSimpleStack(aExoticInputs[aCasingSlot], 16), + CI.getTieredComponent(OrePrefixes.plate, j, 16), + new Object[] {CI.getTieredCircuitOreDictName(j), 8}, + CI.getTieredComponent(OrePrefixes.wireGt16, j + 1, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.bolt, j, GTNH ? 8 : 4), + CI.getTieredComponent(OrePrefixes.screw, j - 1, GTNH ? 8 : 4), + }, + new FluidStack[] { + CI.getTieredFluid(j, 144 * 1 * (GTNH ? 16 : 8)), + CI.getTertiaryTieredFluid(j - 2, 144 * 2 * (GTNH ? 16 : 8)), + CI.getAlternativeTieredFluid(j, 144 * (GTNH ? 16 : 8)), + CI.getTertiaryTieredFluid(j - 1, 144 * (GTNH ? 16 : 8)), + }, + aGemBatteries[aCasingSlot++], + 20 * 60 * 1 * (GTNH ? 2 : 1), + (int) MaterialUtils.getVoltageForTier(j)); + } + + if (LoadedMods.Baubles) { + // Nano Healer + CORE.RA.addAssemblylineRecipe( + ItemUtils.simpleMetaStack(Items.golden_apple, 1, 1), + 20 * 60 * 10, + new Object[] { + ItemUtils.getSimpleStack(aGemCasings[2], GTNH ? 4 : 2), + CI.getTieredComponent(OrePrefixes.plate, 8, GTNH ? 32 : 16), + new Object[] {CI.getTieredCircuitOreDictName(7), 16}, + CI.getTieredComponent(OrePrefixes.cableGt02, 7, GTNH ? 16 : 8), + CI.getTieredComponent(OrePrefixes.gearGt, 6, GTNH ? 6 : 3), + CI.getTieredComponent(OrePrefixes.screw, 7, GTNH ? 16 : 8), + CI.getTieredComponent(OrePrefixes.bolt, 5, GTNH ? 24 : 12), + CI.getTieredComponent(OrePrefixes.frameGt, 4, GTNH ? 12 : 6), + aCoilWire[3] + }, + new FluidStack[] { + CI.getTieredFluid(7, 144 * 18 * (GTNH ? 16 : 8)), + CI.getTertiaryTieredFluid(7, 144 * 18 * (GTNH ? 16 : 8)), + CI.getAlternativeTieredFluid(6, 144 * 18 * (GTNH ? 16 : 8)), + CI.getAlternativeTieredFluid(7, 144 * 18 * (GTNH ? 16 : 8)), + }, + ItemUtils.getItemStackFromFQRN("miscutils:personalHealingDevice", 1), + 20 * 60 * 30 * (GTNH ? 2 : 1), + (int) MaterialUtils.getVoltageForTier(7)); + + // Charge Pack LuV-UV + + ItemStack[] aChargeResearch = new ItemStack[] { + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore7", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore8", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore9", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore10", 1), + }; + + ItemStack[] aChargeOutputs = new ItemStack[] { + ItemUtils.getSimpleStack(ModItems.itemChargePack_High_1, 1), + ItemUtils.getSimpleStack(ModItems.itemChargePack_High_2, 1), + ItemUtils.getSimpleStack(ModItems.itemChargePack_High_3, 1), + ItemUtils.getSimpleStack(ModItems.itemChargePack_High_4, 1), + }; + + int aCurrSlot = 0; + for (int h = 6; h < 10; h++) { + CORE.RA.addAssemblylineRecipe( + aChargeResearch[aCurrSlot], + 20 * 60 * 10 * (aCurrSlot + 1), + new Object[] { + ItemUtils.getSimpleStack(aGemBatteries[aCurrSlot], 2), + aCoilWire[aCurrSlot], + CI.getTieredComponent(OrePrefixes.plate, h, 8), + new Object[] {CI.getTieredCircuitOreDictName(h), 4}, + new Object[] {CI.getTieredCircuitOreDictName(h - 1), 8}, + CI.getTieredComponent(OrePrefixes.cableGt12, h - 1, 16), + CI.getTieredComponent(OrePrefixes.screw, h, GTNH ? 16 : 8), + CI.getTieredComponent(OrePrefixes.bolt, h - 2, GTNH ? 32 : 16), + CI.getFieldGenerator(h, 1), + }, + new FluidStack[] { + CI.getTieredFluid(h, 144 * 4 * (GTNH ? 8 : 4)), + CI.getTertiaryTieredFluid(h - 1, 144 * 4 * (GTNH ? 8 : 4)), + CI.getAlternativeTieredFluid(h - 1, 144 * 4 * (GTNH ? 8 : 4)), + CI.getAlternativeTieredFluid(h - 2, 144 * 4 * (GTNH ? 8 : 4)), + }, + aChargeOutputs[aCurrSlot], + 20 * 60 * 30 * (GTNH ? 2 : 1) * (aCurrSlot + 1), + (int) MaterialUtils.getVoltageForTier(h)); + aCurrSlot++; + } + + // Cloaking device + CORE.RA.addAssemblylineRecipe( + ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_9_CLOAKING, 1), + 20 * 60 * 10, + new Object[] { + ItemUtils.getSimpleStack(aGemCasings[3], GTNH ? 4 : 2), + CI.getTieredComponent(OrePrefixes.plate, 8, GTNH ? 32 : 16), + new Object[] {CI.getTieredCircuitOreDictName(7), 16}, + CI.getTieredComponent(OrePrefixes.cableGt04, 8, GTNH ? 16 : 8), + CI.getTieredComponent(OrePrefixes.gearGt, 7, GTNH ? 6 : 3), + CI.getTieredComponent(OrePrefixes.screw, 8, GTNH ? 16 : 8), + CI.getTieredComponent(OrePrefixes.bolt, 7, GTNH ? 24 : 12), + CI.getTieredComponent(OrePrefixes.frameGt, 5, GTNH ? 12 : 6), + aCoilWire[3] + }, + new FluidStack[] { + CI.getTieredFluid(8, 144 * 18 * (GTNH ? 16 : 8)), + CI.getTertiaryTieredFluid(8, 144 * 18 * (GTNH ? 16 : 8)), + CI.getAlternativeTieredFluid(7, 144 * 18 * (GTNH ? 16 : 8)), + CI.getAlternativeTieredFluid(8, 144 * 18 * (GTNH ? 16 : 8)), + }, + ItemUtils.getItemStackFromFQRN("miscutils:personalCloakingDevice", 1), + 20 * 60 * 30 * (GTNH ? 2 : 1), + (int) MaterialUtils.getVoltageForTier(8)); + } + } + + private static void laserEngraverRecipes() { + + // Laser Sensors and Emitters together + GregtechItemList[] aTransParts = new GregtechItemList[] { + GregtechItemList.TransmissionComponent_ULV, + GregtechItemList.TransmissionComponent_LV, + GregtechItemList.TransmissionComponent_MV, + GregtechItemList.TransmissionComponent_HV, + GregtechItemList.TransmissionComponent_EV, + GregtechItemList.TransmissionComponent_IV, + GregtechItemList.TransmissionComponent_LuV, + GregtechItemList.TransmissionComponent_ZPM, + GregtechItemList.TransmissionComponent_UV, + GregtechItemList.TransmissionComponent_MAX, + }; + for (int i = 0; i < 10; i++) { + GT_Values.RA.addLaserEngraverRecipe( + CI.getEmitter(i, 2), + CI.getSensor(i, 2), + aTransParts[i].get(1), + 20 * 5, + MaterialUtils.getVoltageForTier(i)); + GT_Recipe.GT_Recipe_Map.sDisassemblerRecipes.addRecipe( + false, + new ItemStack[] {aTransParts[i].get(1)}, + new ItemStack[] {CI.getEmitter(i, 2), CI.getSensor(i, 2)}, + null, + null, + new FluidStack[] {GT_Values.NF}, + new FluidStack[] {GT_Values.NF}, + Math.max(300 >> Math.max(i - 1, 0), 1), + MaterialUtils.getVoltageForTier(i), + 0); + } + + GT_Values.RA.addLaserEngraverRecipe( + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Tungsten, 6L), + GregtechItemList.Laser_Lens_Special.get(0), + ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN.getDust(1), + 20 * 60 * 3, + MaterialUtils.getVoltageForTier(ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN.vTier)); + + GT_Values.RA.addLaserEngraverRecipe( + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Titanium, 8L), + GregtechItemList.Laser_Lens_Special.get(0), + ELEMENT.STANDALONE.ASTRAL_TITANIUM.getDust(1), + 20 * 60 * 2, + MaterialUtils.getVoltageForTier(ELEMENT.STANDALONE.ASTRAL_TITANIUM.vTier)); + + GT_Values.RA.addLaserEngraverRecipe( + ALLOY.NITINOL_60.getBlock(2), + GregtechItemList.Laser_Lens_Special.get(0), + ELEMENT.STANDALONE.ADVANCED_NITINOL.getBlock(1), + 20 * 60 * 1, + MaterialUtils.getVoltageForTier(ELEMENT.STANDALONE.ADVANCED_NITINOL.vTier)); + + GT_Values.RA.addLaserEngraverRecipe( + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Glass, 64L), + GregtechItemList.Laser_Lens_Special.get(0), + ELEMENT.STANDALONE.CHRONOMATIC_GLASS.getDust(1), + 20 * 60 * 5, + MaterialUtils.getVoltageForTier(ELEMENT.STANDALONE.CHRONOMATIC_GLASS.vTier)); + + GT_Values.RA.addLaserEngraverRecipe( + CI.getFieldGenerator(6, 1), + CI.getEmitter(7, 2), + ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_1_CONTAINMENT, 1), + 20 * 60 * 5, + MaterialUtils.getVoltageForTier(5)); + + // Distillus Upgrade Chip + GT_Values.RA.addLaserEngraverRecipe( + GregtechItemList.Laser_Lens_WoodsGlass.get(0), + ItemUtils.simpleMetaStack(AgriculturalChem.mBioCircuit, 20, 1), + GregtechItemList.Distillus_Upgrade_Chip.get(1), + 20 * 60 * 5, + MaterialUtils.getVoltageForTier(5)); + + // GT_Values.RA.addLaserEngraverRecipe( + // GregtechItemList.Laser_Lens_WoodsGlass.get(0), + // ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 8, 1), + // ItemUtils.getSimpleStack(ModItems.itemSunnariumBit, 3), + // 20 * 60 * 5, + // MaterialUtils.getVoltageForTier(3)); + + } + + private static void breweryRecipes() { + CORE.RA.addBrewingRecipe( + 14, EnchantingUtils.getMobEssence(100), EnchantingUtils.getLiquidXP(1332), 100, 120, false); + CORE.RA.addBrewingRecipe( + 14, EnchantingUtils.getLiquidXP(1332), EnchantingUtils.getMobEssence(100), 100, 120, false); + CORE.RA.addBrewingRecipe( + ItemUtils.getSimpleStack(BOP_Block_Registrator.sapling_Rainforest), + FluidUtils.getFluidStack("water", 100), + FluidUtils.getFluidStack("biomass", 100), + 1200, + 3, + false); + CORE.RA.addBrewingRecipe( + ItemUtils.getSimpleStack(BOP_Block_Registrator.sapling_Rainforest), + FluidUtils.getFluidStack("honey", 100), + FluidUtils.getFluidStack("biomass", 150), + 1200, + 3, + false); + CORE.RA.addBrewingRecipe( + ItemUtils.getSimpleStack(BOP_Block_Registrator.sapling_Rainforest), + FluidUtils.getFluidStack("juice", 100), + FluidUtils.getFluidStack("biomass", 150), + 1200, + 3, + false); + } + + private static void cuttingSawRecipes() { + GT_Values.RA.addCutterRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("blockMeatRaw", 1), // Input + ItemUtils.getItemStackOfAmountFromOreDict("plateMeatRaw", 9), // Output + null, + 16, // Time + 8); // EU + } + + private static void electrolyzerRecipes() { + GT_Values.RA.addElectrolyzerRecipe( + ItemUtils.getSimpleStack(ModItems.dustDecayedRadium226, 1), + null, + null, + FluidUtils.getFluidStack("radon", !GTNH ? 500 : 144), + null, + null, + null, + null, + null, + null, + new int[] {}, + 20 * 90, + 240); + } + + private static void extruderRecipes() { + // Osmium Credits + if (GT_Values.RA.addExtruderRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("blockOsmium", 1), + ItemList.Shape_Mold_Credit.get(0), + ItemList.Credit_Greg_Osmium.get(1), + (int) Math.max(Materials.Osmium.getMass() * 2L * 20, 1), + 1024)) { + Logger.WARNING("Extruder Recipe: Osmium Credit - Success"); + } else { + Logger.WARNING("Extruder Recipe: Osmium Credit - Failed"); + } + } + + private static void blastSmelterRecipes() { + + if (!GTNH) { + // Trinium + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { + ItemUtils.getGregtechCircuit(8), + ELEMENT.getInstance().BISMUTH.getDust(8), + ELEMENT.getInstance().IRON.getDust(64), + ELEMENT.getInstance().CARBON.getDust(16), + ELEMENT.getInstance().GOLD.getDust(16), + ELEMENT.getInstance().SILVER.getDust(16), + ELEMENT.getInstance().OSMIUM.getDust(4), + ELEMENT.getInstance().IRIDIUM.getDust(4), + ELEMENT.getInstance().CERIUM.getDust(8) + }, + FluidUtils.getFluidStack("molten.trinium", 136 * 144), + 0, + 20 * 3000, + 2040 * 4); + } + + // Eglin Steel + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { + ItemUtils.getGregtechCircuit(6), + ELEMENT.getInstance().IRON.getDust(4), + ALLOY.KANTHAL.getDust(1), + ALLOY.INVAR.getDust(5), + ELEMENT.getInstance().SULFUR.getDust(1), + ELEMENT.getInstance().CARBON.getDust(1), + ELEMENT.getInstance().SILICON.getDust(4) + }, + ALLOY.EGLIN_STEEL.getFluidStack(16 * 144), + 0, + 20 * 45, + 120); + + // HG1223 + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { + ItemUtils.getGregtechCircuit(5), + ELEMENT.getInstance().MERCURY.getCell(1), + ELEMENT.getInstance().BARIUM.getDust(2), + ELEMENT.getInstance().CALCIUM.getDust(2), + ELEMENT.getInstance().COPPER.getDust(3), + }, + ELEMENT.getInstance().OXYGEN.getFluidStack(8000), + ALLOY.HG1223.getFluidStack(16 * 144), + new ItemStack[] {CI.emptyCells(1)}, + new int[] {10000}, // Output Chance + 20 * 120, + 30720); + + // NITINOL_60 + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { + ItemUtils.getGregtechCircuit(2), + ELEMENT.getInstance().TITANIUM.getDust(3), + ELEMENT.getInstance().NICKEL.getDust(2) + }, + ALLOY.NITINOL_60.getFluidStack(5 * 144), + 0, + 20 * 75, + 7680); + + // INDALLOY_140 + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { + ItemUtils.getGregtechCircuit(5), + ELEMENT.getInstance().BISMUTH.getDust(47), + ELEMENT.getInstance().LEAD.getDust(25), + ELEMENT.getInstance().TIN.getDust(13), + ELEMENT.getInstance().CADMIUM.getDust(10), + ELEMENT.getInstance().INDIUM.getDust(5) + }, + ALLOY.INDALLOY_140.getFluidStack(100 * 144), + 0, + 20 * 40, + 7680); + + // Germanium Roasting + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { + ItemUtils.getGregtechCircuit(15), + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedSphalerite", 8), + ELEMENT.getInstance().CARBON.getDust(32), + }, + Materials.SulfuricAcid.getFluid(2000), + ELEMENT.getInstance().GERMANIUM.getFluidStack(288), + 0, + 20 * 300, + 4000); + + // Ruthenium Roasting + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { + ItemUtils.getGregtechCircuit(19), + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedIridium", 8), + ELEMENT.getInstance().CARBON.getDust(32), + }, + Materials.SulfuricAcid.getFluid(2000), + ELEMENT.getInstance().RUTHENIUM.getFluidStack(288), + 0, + 20 * 300, + 8000); + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { + ItemUtils.getGregtechCircuit(19), + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedOsmium", 8), + ELEMENT.getInstance().CARBON.getDust(32), + }, + Materials.SulfuricAcid.getFluid(2000), + ELEMENT.getInstance().RUTHENIUM.getFluidStack(288), + 0, + 20 * 300, + 8000); + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { + ItemUtils.getGregtechCircuit(19), + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedPlatinum", 8), + ELEMENT.getInstance().CARBON.getDust(32), + }, + Materials.SulfuricAcid.getFluid(2000), + ELEMENT.getInstance().RUTHENIUM.getFluidStack(288), + 0, + 20 * 300, + 8000); + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { + ItemUtils.getGregtechCircuit(19), + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedCooperite", 8), + ELEMENT.getInstance().CARBON.getDust(32), + }, + Materials.SulfuricAcid.getFluid(8000), + ELEMENT.getInstance().RUTHENIUM.getFluidStack(144), + 0, + 20 * 300, + 8000); + + // Rhenium Roasting + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { + ItemUtils.getGregtechCircuit(20), + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedScheelite", 8), + ELEMENT.getInstance().CARBON.getDust(32), + }, + Materials.SulfuricAcid.getFluid(10000), + ELEMENT.getInstance().RHENIUM.getFluidStack(144), + 0, + 20 * 300, + 4000); + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { + ItemUtils.getGregtechCircuit(20), + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedMolybdenite", 8), + ELEMENT.getInstance().CARBON.getDust(32), + }, + Materials.SulfuricAcid.getFluid(7500), + ELEMENT.getInstance().RHENIUM.getFluidStack(144), + 0, + 20 * 300, + 4000); + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { + ItemUtils.getGregtechCircuit(20), + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedMolybdenum", 8), + ELEMENT.getInstance().CARBON.getDust(32), + }, + Materials.SulfuricAcid.getFluid(5000), + ELEMENT.getInstance().RHENIUM.getFluidStack(288), + 0, + 20 * 300, + 4000); + + // Thallium Roasting + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { + ItemUtils.getGregtechCircuit(21), + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedIron", 12), + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedPyrite", 16), + ELEMENT.getInstance().CARBON.getDust(64), + }, + Materials.SulfuricAcid.getFluid(5000), + ELEMENT.getInstance().THALLIUM.getFluidStack(288 + 144), + 0, + 20 * 300, + 8000); + + // Strontium processing + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { + ItemUtils.getGregtechCircuit(21), + MISC_MATERIALS.STRONTIUM_OXIDE.getDust(8), + ELEMENT.getInstance().ALUMINIUM.getDust(8), + }, + null, + ELEMENT.getInstance().OXYGEN.getFluidStack(8000), + new ItemStack[] { + ELEMENT.getInstance().ALUMINIUM.getIngot(8), + ELEMENT.getInstance().STRONTIUM.getIngot(8) + }, + new int[] {10000, 10000}, // Output Chance + 20 * 120, + 480 * 4); + } + + private static void fluidcannerRecipes() { + // Sulfuric Acid + CORE.RA.addFluidCannerRecipe( + ItemUtils.getSimpleStack(Items.glass_bottle), + ItemUtils.getSimpleStack(ModItems.itemSulfuricPotion), + FluidUtils.getFluidStack("sulfuricacid", 250), + null); + CORE.RA.addFluidCannerRecipe( + ItemUtils.getSimpleStack(ModItems.itemSulfuricPotion), + ItemUtils.getSimpleStack(Items.glass_bottle), + null, + FluidUtils.getFluidStack("sulfuricacid", 250)); + + // Hydrofluoric Acid + boolean addedGtExtraction = false; + // Try use Internal GT Fluid first + if (Utils.getGregtechVersionAsInt() >= 50929) { + // Hydrofluoric Acid + CORE.RA.addFluidCannerRecipe( + ItemUtils.getSimpleStack(Items.glass_bottle), + ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), + FluidUtils.getFluidStack("hydrofluoricacid_gt5u", 250), + null); + addedGtExtraction = CORE.RA.addFluidCannerRecipe( + ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), + ItemUtils.getSimpleStack(Items.glass_bottle), + null, + FluidUtils.getFluidStack("hydrofluoricacid_gt5u", 250)); + } + // Add a Fill recipe for GT++ Acid + CORE.RA.addFluidCannerRecipe( + ItemUtils.getSimpleStack(Items.glass_bottle), + ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), + FluidUtils.getFluidStack("hydrofluoricacid", 125), + null); + // Add an empty recipe, but only if we didn't for the standard GT HF. Prevents Fluid transformation exploits. + if (!addedGtExtraction) { + CORE.RA.addFluidCannerRecipe( + ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), + ItemUtils.getSimpleStack(Items.glass_bottle), + null, + FluidUtils.getFluidStack("hydrofluoricacid", 125)); + } + + // Gelid Cryotheum + CORE.RA.addFluidExtractionRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("dustCryotheum", 1), + FluidUtils.getFluidStack("cryotheum", 250), + 200, + 240); + + // Ender Fluid + CORE.RA.addFluidExtractionRecipe( + ItemUtils.getSimpleStack(Items.ender_pearl), FluidUtils.getFluidStack("ender", 250), 100, 30); + + // Blazing Pyrotheum + CORE.RA.addFluidExtractionRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("dustPyrotheum", 1), + FluidUtils.getFluidStack("pyrotheum", 250), + 200, + 240); + } + + private static void cokeOvenRecipes() { + Logger.INFO("Loading Recipes for Industrial Coking Oven."); + // Wood to Charcoal + // Try use all woods found + ArrayList aLogData = OreDictionary.getOres("logWood"); + if (aLogData.isEmpty()) { + AddGregtechRecipe.addCokeAndPyrolyseRecipes( + GT_OreDictUnificator.get(OrePrefixes.log, Materials.Wood, 20L), + 20, + GT_ModHandler.getSteam(1000), + GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Charcoal, 24L), + FluidUtils.getFluidStack("fluid.coalgas", 1440), + 60, + 30); + } else { + for (ItemStack stack : aLogData) { + AddGregtechRecipe.addCokeAndPyrolyseRecipes( + ItemUtils.getSimpleStack(stack, 20), + 20, + GT_ModHandler.getSteam(1000), + GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Charcoal, 24L), + FluidUtils.getFluidStack("fluid.coalgas", 1440), + 60, + 30); + } + } + + // Coal to Coke + AddGregtechRecipe.addCokeAndPyrolyseRecipes( + GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Coal, 16L), + 22, + GT_ModHandler.getSteam(1000), + ItemUtils.getItemStackOfAmountFromOreDict("fuelCoke", 10), + FluidUtils.getFluidStack("fluid.coalgas", 2880), + 30, + 120); + + // Coke & Coal + CORE.RA.addCokeOvenRecipe( + GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Coal, 12L), + ItemUtils.getItemStackOfAmountFromOreDict("fuelCoke", 6), + GT_ModHandler.getSteam(2000), + FluidUtils.getFluidStack("fluid.coalgas", 5040), + ItemUtils.getItemStackOfAmountFromOreDict("fuelCoke", 14), + 60 * 20, + 240); + } + + private static void matterFabRecipes() { + Logger.INFO("Loading Recipes for Matter Fabricator."); + + try { + + CORE.RA.addMatterFabricatorRecipe( + Materials.UUAmplifier.getFluid(1L), // Fluid + // Input + Materials.UUMatter.getFluid(1L), // Fluid Output + 800, // Time in ticks + 32); // EU + } catch (final NullPointerException e) { + Logger.INFO("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE"); + } + try { + + CORE.RA.addMatterFabricatorRecipe( + null, // Fluid Input + Materials.UUMatter.getFluid(1L), // Fluid Output + 3200, // Time in ticks + 32); // EU + } catch (final NullPointerException e) { + Logger.INFO("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE"); + } + } + + private static void dehydratorRecipes() { + Logger.INFO("Loading Recipes for Chemical Dehydrator."); + + ItemStack cropGrape = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cropGrape", 1); + ItemStack foodRaisins = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("foodRaisins", 1); + + if (cropGrape != null && foodRaisins != null) + CORE.RA.addDehydratorRecipe( + new ItemStack[] {CI.getNumberedBioCircuit(20), cropGrape}, // Item + null, // Fluid input (slot 1) + null, // Fluid output (slot 2) + new ItemStack[] {foodRaisins}, // Output + new int[] {10000}, + 10, // Time in ticks + 2); // EU + + // Process Waste Water + CORE.RA.addDehydratorRecipe( + new ItemStack[] {CI.getNumberedBioCircuit(21)}, + FluidUtils.getFluidStack("fluid.sludge", 1000), + FluidUtils.getFluidStack("nitricacid", 10), + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyIron", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyCopper", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyTin", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyNickel", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyCobalt", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyAluminium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinySilver", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyGold", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyIridium", 1) + }, + new int[] {10, 5, 5, 4, 4, 3, 2, 2, 1}, + 2 * 20, + 500); // EU + + // C8H10 = C8H8 + 2H + CORE.RA.addDehydratorRecipe( + new ItemStack[] {CI.getNumberedAdvancedCircuit(18), CI.emptyCells(3)}, + FluidUtils.getFluidStack("fluid.ethylbenzene", 1000), + null, + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("cellStyrene", 1), + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 2) + }, + new int[] {10000, 10000}, + 3 * 20, + 30); + + /* + * Try Add custom Recipe for drying leather + */ + if (LoadedMods.PamsHarvestcraft && Loader.isModLoaded("Backpack")) { + ItemStack aLeather1, aLeather2; + aLeather1 = ItemUtils.getCorrectStacktype("harvestcraft:hardenedleatherItem", 1); + aLeather2 = ItemUtils.getCorrectStacktype("Backpack:tannedLeather", 1); + CORE.RA.addDehydratorRecipe( + new ItemStack[] {CI.getNumberedAdvancedCircuit(18), aLeather1}, + FluidUtils.getFluidStack("fluid.ethylbenzene", 1000), + null, + new ItemStack[] {aLeather2}, + new int[] {10000}, + 5 * 20, + 180); + } + // Alternative ACETIC ANHYDRIDE recipe for Kevlar Line + // 2C2H4O2 = C4H6O3 + H2O + CORE.RA.addDehydratorRecipe( + new ItemStack[] {CI.getNumberedAdvancedCircuit(18), CI.emptyCells(1)}, + FluidUtils.getFluidStack("aceticacid", 2000), + MISC_MATERIALS.ACETIC_ANHYDRIDE.getFluidStack(1000), + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("cellWater", 1), + }, + new int[] {10000}, + 30 * 20, + 480); + } + + private static void largeChemReactorRecipes() { + // Styrene + // C8H10 = C8H8 + 2H + CORE.RA.addMultiblockChemicalRecipe( + new ItemStack[] {CI.getNumberedCircuit(24)}, + new FluidStack[] {FluidUtils.getFluidStack("fluid.ethylbenzene", 1000)}, + new FluidStack[] {MaterialUtils.getMaterial("Styrene").getFluid(1000), Materials.Hydrogen.getGas(2000)}, + null, + 30, + 30); + // Short-cut Styrene + // C6H6 + C2H4 = C8H8 + 2H + CORE.RA.addMultiblockChemicalRecipe( + new ItemStack[] {CI.getNumberedCircuit(24)}, + new FluidStack[] { + MaterialUtils.getMaterial("Ethylene").getGas(500), + MaterialUtils.getMaterial("Benzene").getFluid(500) + }, + new FluidStack[] {MaterialUtils.getMaterial("Styrene").getFluid(500), Materials.Hydrogen.getGas(1000)}, + null, + 240, + 120); + } + + private static void fissionFuelRecipes() { + try { + + } catch (final NullPointerException e) { + Logger.INFO("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE"); + } + } + + private static void assemblerRecipes() { + // ItemUtils.getSimpleStack(GregtechItemList.Casing_Vanadium_Redox.get(1) + addAR( + ItemUtils.getItemStackOfAmountFromOreDict("plateVanadium", 32), + ItemUtils.getItemStackOfAmountFromOreDict("frameGtVanadiumSteel", 8), + FluidUtils.getFluidStack("oxygen", 8000), + ItemUtils.simpleMetaStack(ModItems.itemHalfCompleteCasings, 0, 4), + 16, + 60); + addAR( + ItemUtils.simpleMetaStack(ModItems.itemHalfCompleteCasings, 0, 2), + ItemUtils.getItemStackOfAmountFromOreDict("plateVanadiumGallium", 8), + FluidUtils.getFluidStack("molten.tantalum", 144 * 4), + ItemUtils.simpleMetaStack(ModItems.itemHalfCompleteCasings, 1, 8), + 32, + 120); + + /* + addAR(ItemUtils.simpleMetaStack(ModItems.itemHalfCompleteCasings, 1, 1), + ItemUtils.getItemStackOfAmountFromOreDict("plateDenseLead", 4), FluidUtils.getFluidStack("oxygen", 16000), + ItemUtils.getSimpleStack(GregtechItemList.Casing_Vanadium_Redox.get(1), 1), 64, 240); + */ + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + ItemUtils.simpleMetaStack(ModItems.itemHalfCompleteCasings, 1, 1), + ItemUtils.getItemStackOfAmountFromOreDict("plateDenseLead", 4), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(3), 4), + ItemUtils.getItemStackOfAmountFromOreDict("wireGt01SuperconductorHV", 2) + }, + FluidUtils.getFluidStack("oxygen", 16000), + ItemUtils.getSimpleStack(GregtechItemList.Casing_Vanadium_Redox.get(1), 1), + 64, + 240); + + // Tier 2-6 + ItemStack T1 = GregtechItemList.Casing_Vanadium_Redox.get(1); + ItemStack T2 = GregtechItemList.Casing_Vanadium_Redox_IV.get(1); + ItemStack T3 = GregtechItemList.Casing_Vanadium_Redox_LuV.get(1); + ItemStack T4 = GregtechItemList.Casing_Vanadium_Redox_ZPM.get(1); + ItemStack T5 = GregtechItemList.Casing_Vanadium_Redox_UV.get(1); + ItemStack T6 = GregtechItemList.Casing_Vanadium_Redox_MAX.get(1); + + /* + addAR(T1, + ItemUtils.getItemStackOfAmountFromOreDict("plateDenseTitanium", 4), + FluidUtils.getFluidStack("nitrogen", 16000), + T2, 120, 2000); + */ + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + T1, + ItemUtils.getItemStackOfAmountFromOreDict("plateDenseTitanium", 4), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(4), 4), + ItemUtils.getItemStackOfAmountFromOreDict("wireGt01SuperconductorEV", 2) + }, + FluidUtils.getFluidStack("nitrogen", 16000), + T2, + 120, + 2000); + + /* + addAR(T2, + ItemUtils.getItemStackOfAmountFromOreDict("plateDenseTungstenSteel", 4), + FluidUtils.getFluidStack("helium", 8000), + T3, 250, 8000); + */ + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + T2, + ItemUtils.getItemStackOfAmountFromOreDict("plateDenseTungstenSteel", 4), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(5), 4), + ItemUtils.getItemStackOfAmountFromOreDict("wireGt01SuperconductorIV", 2) + }, + FluidUtils.getFluidStack("helium", 8000), + T3, + 250, + 8000); + /* + addAR(T3, + ItemUtils.getItemStackOfAmountFromOreDict("plateAlloyIridium", 16), + FluidUtils.getFluidStack("argon", 4000), + T4, 500, 32000); + */ + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + T3, + ItemUtils.getItemStackOfAmountFromOreDict("plateAlloyIridium", 16), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(6), 4), + ItemUtils.getItemStackOfAmountFromOreDict("wireGt01SuperconductorLuV", 2) + }, + FluidUtils.getFluidStack("argon", 4000), + T4, + 500, + 32000); + /* + addAR(T4, + ItemUtils.getItemStackOfAmountFromOreDict("plateDenseNaquadah", 4), + FluidUtils.getFluidStack("radon", 4000), + T5, 1000, 128000); + */ + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + T4, + ItemUtils.getItemStackOfAmountFromOreDict("plateDenseNaquadah", 4), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(7), 4), + ItemUtils.getItemStackOfAmountFromOreDict("wireGt01SuperconductorZPM", 2) + }, + FluidUtils.getFluidStack("radon", 4000), + T5, + 1000, + 128000); + /* + addAR(T5, + ItemUtils.getItemStackOfAmountFromOreDict("plateDenseAmericium", 4), + FluidUtils.getFluidStack("krypton", 500), + T6, 2000, 512000); + */ + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + T5, + ItemUtils.getItemStackOfAmountFromOreDict("plateDenseAmericium", 4), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(8), 4), + ItemUtils.getItemStackOfAmountFromOreDict("wireGt01SuperconductorUV", 2) + }, + FluidUtils.getFluidStack("krypton", 500), + T6, + 2000, + 512000); + + addAR( + ItemUtils.getItemStackOfAmountFromOreDict("dustClay", 32), + GregtechItemList.Bomb_Cast_Mold.get(0), + FluidUtils.getWater(4000), + GregtechItemList.Bomb_Cast.get(4), + 30, + 120); + addAR( + ItemUtils.getSimpleStack(Items.redstone, 32), + ItemUtils.getSimpleStack(ModItems.itemRope, 16), + Materials.Glue.getFluid(500), + ItemUtils.getSimpleStack(ModItems.itemDetCable, 24), + 30, + 120); + + /*addAR(ItemUtils.getItemStackOfAmountFromOreDict("plateIncoloy020", 16), + ItemUtils.getItemStackOfAmountFromOreDict("frameGtIncoloyMA956", 4), null, + GregtechItemList.Casing_Power_SubStation.get(4), 80, 120);*/ + + /*CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { + GregtechItemList.Casing_Multi_Use.get(1), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(6), 1), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(4), 8), + CI.sensor_HV, + CI.emitter_HV, + CI.fieldGenerator_HV, + }, + null, + ItemUtils.getSimpleStack(Dimension_Everglades.blockPortalFrame), + 20*20, + 2048); + + */ + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] {ItemUtils.getSimpleStack(ModItems.itemRope, 6)}, + null, + ItemUtils.getSimpleStack(ModBlocks.blockNet, 2), + 1 * 20, + 8); + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + ItemUtils.getSimpleStack(CI.explosiveITNT, 2), + ItemUtils.getSimpleStack(CI.explosiveTNT, 4), + ELEMENT.getInstance().SULFUR.getDust(2), + ELEMENT.getInstance().IRON.getFrameBox(1) + }, + null, + ItemUtils.getSimpleStack(ModBlocks.blockMiningExplosive, 3), + 5 * 20, + 60); + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + ItemUtils.getSimpleStack(Items.nether_star), + ItemUtils.getItemStackOfAmountFromOreDict("plateTungstenSteel", 8), + ItemUtils.getItemStackOfAmountFromOreDict("stickBlackSteel", 8) + }, + null, + ItemUtils.getSimpleStack(ModBlocks.blockWitherGuard, 64), + 30 * 20, + 500); + + ItemStack aFluidReg1 = ItemUtils.getValueOfItemList("FluidRegulator_LV", ItemList.Pump_LV) + .get(1); + ItemStack aFluidReg2 = ItemUtils.getValueOfItemList("FluidRegulator_MV", ItemList.Pump_MV) + .get(1); + ItemStack aFluidReg3 = ItemUtils.getValueOfItemList("FluidRegulator_HV", ItemList.Pump_HV) + .get(1); + ItemStack aFluidReg4 = ItemUtils.getValueOfItemList("FluidRegulator_EV", ItemList.Pump_EV) + .get(1); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + aFluidReg1, + CI.electricMotor_LV, + CI.getTieredComponent(OrePrefixes.bolt, 1, GTNH ? 8 : 4), + ItemUtils.getItemStackOfAmountFromOreDict("ringBrass", 1), + ItemUtils.getItemStackOfAmountFromOreDict("stickBrass", 1), + ItemUtils.getItemStackOfAmountFromOreDict("plateSteel", 2) + }, + null, + ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 1, 1), + 10 * 20, + 30); + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + aFluidReg2, + CI.electricMotor_MV, + CI.getTieredComponent(OrePrefixes.bolt, 2, GTNH ? 8 : 4), + ItemUtils.getItemStackOfAmountFromOreDict("ringInvar", 1), + ItemUtils.getItemStackOfAmountFromOreDict("stickInvar", 1), + ItemUtils.getItemStackOfAmountFromOreDict("plateAluminium", 2) + }, + null, + ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 2, 1), + 10 * 20 * 2, + 120); + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + aFluidReg3, + CI.electricMotor_HV, + CI.getTieredComponent(OrePrefixes.bolt, 3, GTNH ? 8 : 4), + ItemUtils.getItemStackOfAmountFromOreDict("ringChrome", 1), + ItemUtils.getItemStackOfAmountFromOreDict("stickChrome", 1), + ItemUtils.getItemStackOfAmountFromOreDict("plateStainlessSteel", 2) + }, + null, + ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 3, 1), + 10 * 20 * 3, + 480); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + aFluidReg4, + CI.electricMotor_EV, + CI.getTieredComponent(OrePrefixes.bolt, 4, GTNH ? 8 : 4), + ItemUtils.getItemStackOfAmountFromOreDict("ringTitanium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("stickTitanium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("plateTungstenSteel", 2) + }, + null, + ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 4, 1), + 10 * 20 * 4, + 1960); + + GT_Values.RA.addAssemblerRecipe( + ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 1, 1), + CI.getNumberedCircuit(20), + ItemUtils.simpleMetaStack(ModItems.toolGregtechPump, 1000, 1), + 30, + 30); + GT_Values.RA.addAssemblerRecipe( + ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 2, 1), + CI.getNumberedCircuit(20), + ItemUtils.simpleMetaStack(ModItems.toolGregtechPump, 1001, 1), + 120, + 120); + GT_Values.RA.addAssemblerRecipe( + ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 3, 1), + CI.getNumberedCircuit(20), + ItemUtils.simpleMetaStack(ModItems.toolGregtechPump, 1002, 1), + 480, + 480); + GT_Values.RA.addAssemblerRecipe( + ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 4, 1), + CI.getNumberedCircuit(20), + ItemUtils.simpleMetaStack(ModItems.toolGregtechPump, 1003, 1), + 1820, + 1820); + + // Low tier Charge Packs + + final ItemStack[] aPackBatteries = new ItemStack[] { + ItemList.Battery_RE_LV_Lithium.get(4), + ItemList.Battery_RE_MV_Lithium.get(4), + ItemList.Battery_RE_HV_Lithium.get(4), + GregtechItemList.Battery_RE_EV_Lithium.get(4), + ItemList.Energy_LapotronicOrb.get(4), + }; + final ItemStack[] aPackPlates = new ItemStack[] { + CI.getPlate(1, 8), CI.getPlate(2, 8), CI.getPlate(3, 8), CI.getPlate(4, 8), CI.getPlate(5, 8), + }; + final ItemStack[] aPackWire = new ItemStack[] { + CI.getTieredComponent(OrePrefixes.wireGt02, 1, 6), + CI.getTieredComponent(OrePrefixes.wireGt04, 2, 6), + CI.getTieredComponent(OrePrefixes.wireGt08, 3, 6), + CI.getTieredComponent(OrePrefixes.wireGt12, 4, 6), + CI.getTieredComponent(OrePrefixes.wireGt16, 5, 6), + }; + final ItemStack[] aPackCircuit = new ItemStack[] { + CI.getTieredComponent(OrePrefixes.circuit, 1, 4), + CI.getTieredComponent(OrePrefixes.circuit, 2, 4), + CI.getTieredComponent(OrePrefixes.circuit, 3, 4), + CI.getTieredComponent(OrePrefixes.circuit, 4, 4), + CI.getTieredComponent(OrePrefixes.circuit, 5, 4), + }; + final ItemStack[] aPackRing = new ItemStack[] { + CI.getTieredComponent(OrePrefixes.ring, 1, 12), + CI.getTieredComponent(OrePrefixes.ring, 2, 12), + CI.getTieredComponent(OrePrefixes.ring, 3, 12), + CI.getTieredComponent(OrePrefixes.ring, 4, 12), + CI.getTieredComponent(OrePrefixes.ring, 5, 12), + }; + final ItemStack[] aPackOutput = new ItemStack[] { + ItemUtils.getSimpleStack(ModItems.itemChargePack_Low_1), + ItemUtils.getSimpleStack(ModItems.itemChargePack_Low_2), + ItemUtils.getSimpleStack(ModItems.itemChargePack_Low_3), + ItemUtils.getSimpleStack(ModItems.itemChargePack_Low_4), + ItemUtils.getSimpleStack(ModItems.itemChargePack_Low_5) + }; + + for (int i = 1; i < 6; i++) { + + int aAS = i - 1; + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + aPackPlates[aAS], + aPackRing[aAS], + aPackWire[aAS], + aPackCircuit[aAS], + aPackBatteries[aAS], + CI.getSensor(i, GTNH ? 4 : 2), + }, + CI.getTieredFluid(i, (144 * (GTNH ? 4 : 2))), + aPackOutput[aAS], + 30 * 20 * i, + (int) GT_Values.V[i]); + } + + if (!GTNH) { + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + GT_Values.RA.addAssemblerRecipe( + GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.WroughtIron, 1L), + GT_OreDictUnificator.get(OrePrefixes.ring, Materials.WroughtIron, 2L), + GregtechItemList.Fluid_Cell_1L.get(1L, new Object[0]), + 50, + 32); + GT_Values.RA.addAssemblerRecipe( + GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Bronze, 1L), + GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Bronze, 2L), + GregtechItemList.Fluid_Cell_16L.get(1L, new Object[0]), + 50, + 32); + GT_Values.RA.addAssemblerRecipe( + GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Brass, 1L), + GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Brass, 2L), + GregtechItemList.Fluid_Cell_36L.get(1L, new Object[0]), + 75, + 32); + GT_Values.RA.addAssemblerRecipe( + GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Invar, 1L), + GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Invar, 2L), + GregtechItemList.Fluid_Cell_144L.get(1L, new Object[0]), + 75, + 32); + + } else { + GT_Values.RA.addAssemblerRecipe( + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.WroughtIron, 8L), + GT_OreDictUnificator.get(OrePrefixes.ring, Materials.WroughtIron, 4L), + GregtechItemList.Fluid_Cell_1L.get(1L, new Object[0]), + 50, + 32); + GT_Values.RA.addAssemblerRecipe( + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Bronze, 8L), + GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Bronze, 4L), + GregtechItemList.Fluid_Cell_16L.get(1L, new Object[0]), + 50, + 32); + GT_Values.RA.addAssemblerRecipe( + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Brass, 8L), + GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Brass, 4L), + GregtechItemList.Fluid_Cell_36L.get(1L, new Object[0]), + 75, + 32); + GT_Values.RA.addAssemblerRecipe( + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Invar, 8L), + GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Invar, 4L), + GregtechItemList.Fluid_Cell_144L.get(1L, new Object[0]), + 75, + 32); + } + } + + if (LoadedMods.Baubles) { + + // Turbine Housing Research Page + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + ItemUtils.getGregtechCircuit(17), + ItemUtils.getItemStackOfAmountFromOreDict("plateTrinium", GTNH ? 64 : 32), + CI.getSensor(6, GTNH ? 6 : 3), + CI.getBolt(7, GTNH ? 64 : 32), + ItemUtils.getItemStackOfAmountFromOreDict("wireFinePlatinum", GTNH ? 64 : 32), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(7), GTNH ? 12 : 6) + }, + CI.getAlternativeTieredFluid(7, 144 * 32), + ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_8_TURBINE_AUTOMATION, 1), + 20 * 60 * 5, + (int) GT_Values.V[6]); + + // Cloaking Device Research Page + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + ItemUtils.getGregtechCircuit(17), + ItemUtils.getSimpleStack(ModItems.itemCircuitLFTR, 4), + CI.getFieldGenerator(6, GTNH ? 16 : 8), + ItemUtils.getItemStackOfAmountFromOreDict("wireFinePalladium", GTNH ? 32 : 16), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(6), GTNH ? 12 : 6) + }, + CI.getAlternativeTieredFluid(7, 144 * 32), + ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_9_CLOAKING, 1), + 20 * 60 * 10, + (int) GT_Values.V[7]); + + // Supreme Pizza Gloves + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + ItemUtils.getGregtechCircuit(19), + ItemUtils.getSimpleStack(ModItems.itemRope, GTNH ? 32 : 16), + ItemUtils.getItemStackOfAmountFromOreDict("gearGtSmallWroughtIron", GTNH ? 8 : 4), + ItemUtils.getItemStackOfAmountFromOreDict("wireFineCopper", GTNH ? 32 : 16), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(1), GTNH ? 2 : 1) + }, + FluidUtils.getFluidStack("molten.rubber", 2000), + ItemUtils.getSimpleStack(ModItems.itemPersonalFireProofDevice), + 20 * 60 * 5, + 30); + } + } + + private static boolean addAR( + final ItemStack inputA, + final ItemStack inputB, + final FluidStack inputFluidA, + final ItemStack outputA, + final int seconds, + final int voltage) { + // return GT_Values.RA.addAssemblerRecipe(inputA, inputB, outputA, + // seconds*20, voltage); + return GT_Values.RA.addAssemblerRecipe(inputA, inputB, inputFluidA, outputA, seconds * 20, voltage); + } + + private static void distilleryRecipes() { + Logger.INFO("Registering Distillery/Distillation Tower Recipes."); + GT_Values.RA.addDistilleryRecipe( + ItemList.Circuit_Integrated.getWithDamage(0L, 4L, new Object[0]), + FluidUtils.getFluidStack("air", 1000), + FluidUtils.getFluidStack("helium", 1), + 400, + 30, + false); + GT_Values.RA.addDistillationTowerRecipe( + FluidUtils.getFluidStack("air", 20000), + FluidUtils.getFluidStackArray("helium", 25), + ItemUtils.getSimpleStack(ModItems.itemHydrogenBlob, 1), + 200, + 60); + + // Apatite Distillation + /* + * so if you dissolve aparite in sulphuric acid you'll get a mixture of + * SO2, H2O, HF and HCl + */ + final FluidStack[] apatiteOutput = { + FluidUtils.getFluidStack("sulfurousacid", 3800), + FluidUtils.getFluidStack("hydrogenchloride", 1000), + FluidUtils.getFluidStack("hydrofluoricacid", 400) + }; + GT_Values.RA.addDistillationTowerRecipe( + FluidUtils.getFluidStack("sulfuricapatite", 5200), apatiteOutput, null, 45 * 20, 120); + + final FluidStack[] sulfurousacidOutput = { + FluidUtils.getFluidStack("sulfurdioxide", 500), FluidUtils.getFluidStack("water", 500) + }; + GT_Values.RA.addDistillationTowerRecipe( + FluidUtils.getFluidStack("sulfurousacid", 1000), sulfurousacidOutput, null, 10 * 20, 60); + + if (!GTNH) { + final FluidStack[] sulfurdioxideOutput = {FluidUtils.getFluidStack("oxygen", 2000)}; + GT_Values.RA.addDistillationTowerRecipe( + FluidUtils.getFluidStack("sulfurdioxide", 144 * 3), + sulfurdioxideOutput, + ItemUtils.getItemStackOfAmountFromOreDict("dustSulfur", 1), + 5 * 20, + 30); + } + } + + private static void addFuels() { + Logger.INFO("Registering New Fuels."); + + if (!GTNH) { + GT_Values.RA.addFuel(ItemUtils.simpleMetaStack("EnderIO:bucketFire_water", 0, 1), null, 120, 0); + GT_Values.RA.addFuel(ItemUtils.simpleMetaStack("EnderIO:bucketRocket_fuel", 0, 1), null, 112, 0); + GT_Values.RA.addFuel(ItemUtils.simpleMetaStack("EnderIO:bucketHootch", 0, 1), null, 36, 0); + } + + HotFuel.addNewHotFuel( + FluidUtils.getLava(83), + FluidUtils.getPahoehoeLava(83), + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("nuggetCopper", 1), + ItemUtils.getItemStackOfAmountFromOreDict("nuggetTin", 1), + ItemUtils.getItemStackOfAmountFromOreDict("nuggetGold", 1), + ItemUtils.getItemStackOfAmountFromOreDict("nuggetSilver", 1), + ItemUtils.getItemStackOfAmountFromOreDict("nuggetTantalum", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallTungstate", 1), + ItemUtils.getSimpleStack(Blocks.obsidian) + }, + new int[] {2000, 1000, 250, 250, 250, 250, 500}, + 0); + + HotFuel.addNewHotFuel( + FluidUtils.getPahoehoeLava(83), + GT_Values.NF, + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDict("nuggetBronze", 1), + ItemUtils.getItemStackOfAmountFromOreDict("nuggetElectrum", 1), + ItemUtils.getItemStackOfAmountFromOreDict("nuggetTantalum", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallTungstate", 1), + ItemUtils.getSimpleStack(Blocks.obsidian) + }, + new int[] {750, 250, 250, 250, 1850}, + 0); + + HotFuel.addNewHotFuel( + MISC_MATERIALS.SOLAR_SALT_HOT.getFluidStack(1000), + MISC_MATERIALS.SOLAR_SALT_COLD.getFluidStack(1000), + FluidUtils.getSuperHeatedSteam(10000), + 0); + + /* + * HotFuel.addNewHotFuel( FluidUtils.getFluidStack("ic2hotcoolant", + * 100), GT_Values.NF, new ItemStack[]{}, new int[]{}, 0); + */ + + ThermalFuel.addSteamTurbineFuel(FluidUtils.getFluidStack("steam", 1024)); + + // CORE.RA.addFuel(UtilsItems.simpleMetaStack("EnderIO:bucketRocket_fuel", + // 0, 1), null, 112, 0); + GT_Values.RA.addFuel(ItemUtils.getSimpleStack(Items.lava_bucket), null, 32, 2); + GT_Values.RA.addFuel(ItemUtils.getIC2Cell(2), null, 32, 2); + GT_Values.RA.addFuel(ItemUtils.getIC2Cell(11), null, 24, 2); + // System.exit(1); + } + + private static void extractorRecipes() { + Logger.INFO("Registering Extractor Recipes."); + GT_ModHandler.addExtractionRecipe( + GregtechItemList.Battery_RE_EV_Sodium.get(1L, new Object[0]), + ItemList.Battery_Hull_HV.get(4L, new Object[0])); + GT_ModHandler.addExtractionRecipe( + GregtechItemList.Battery_RE_EV_Cadmium.get(1L, new Object[0]), + ItemList.Battery_Hull_HV.get(4L, new Object[0])); + GT_ModHandler.addExtractionRecipe( + GregtechItemList.Battery_RE_EV_Lithium.get(1L, new Object[0]), + ItemList.Battery_Hull_HV.get(4L, new Object[0])); + } + + private static void fluidExtractorRecipes() {} + + private static void chemicalBathRecipes() {} + + private static void centrifugeRecipes() { + + GT_Values.RA.addCentrifugeRecipe( + CI.getNumberedAdvancedCircuit(2), + MISC_MATERIALS.SOLAR_SALT_COLD.getCell(5), + null, + null, + MISC_MATERIALS.SODIUM_NITRATE.getDust(15), + MISC_MATERIALS.POTASSIUM_NITRATE.getDust(10), + CI.emptyCells(5), + null, + null, + null, + null, + 20 * 30, + 120); + } + + private static void mixerRecipes() { + + // S + 2O = SO2 + GT_Values.RA.addMixerRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("dustSulfur", 1), + null, + null, + null, + FluidUtils.getFluidStack("oxygen", 2000), + FluidUtils.getFluidStack("sulfurdioxide", 1000), + null, + 600, + 60); + + GT_Values.RA.addMixerRecipe( + CI.getNumberedAdvancedCircuit(2), + CI.emptyCells(5), + MISC_MATERIALS.SODIUM_NITRATE.getDust(15), + MISC_MATERIALS.POTASSIUM_NITRATE.getDust(10), + null, + null, + MISC_MATERIALS.SOLAR_SALT_COLD.getCell(5), + 20 * 10, + 120); + } + + private static void chemicalReactorRecipes() { + + // Bombs + GT_Values.RA.addChemicalRecipe( + ItemUtils.getSimpleStack(ModItems.itemBombCasing, 4), + ItemUtils.getSimpleStack(RocketFuels.Ammonium_Nitrate_Dust, 8), + Materials.Fuel.getFluid(1000), + null, + ItemUtils.getSimpleStack(ModItems.itemBombUnf, 4), + 300 * 20); + + GT_Values.RA.addChemicalRecipe( + ItemUtils.getSimpleStack(ModItems.itemBombUnf, 4), + ItemUtils.getSimpleStack(ModItems.itemDetCable, 4), + FluidUtils.getFluidStack(RocketFuels.Kerosene, 100), + null, + ItemUtils.getSimpleStack(ModItems.itemBomb, 4), + 10 * 20); + + GT_Values.RA.addChemicalRecipe( + CI.getNumberedAdvancedCircuit(21), + ItemUtils.getItemStackOfAmountFromOreDict("dustApatite", 32), + FluidUtils.getFluidStack("sulfuricacid", 4000), + FluidUtils.getFluidStack("sulfuricapatite", 8000), + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallSulfur", 8), + 20 * 20); + + // KOH + HNO3 = KNO3 + H2O + GT_Values.RA.addChemicalRecipe( + ItemUtils.getSimpleStack(GenericChem.mPotassiumHydroxide, 3), + CI.getNumberedAdvancedCircuit(1), + Materials.NitricAcid.getFluid(1000), + Materials.Water.getFluid(1000), + MISC_MATERIALS.POTASSIUM_NITRATE.getDust(5), + 100, + 30); + + // Na2CO3 + 2HNO3 = 2NaNO3 + CO2 + H2O + GT_Values.RA.addChemicalRecipe( + ItemUtils.getSimpleStack(AgriculturalChem.mSodiumCarbonate, 6), + CI.getNumberedAdvancedCircuit(1), + Materials.NitricAcid.getFluid(2000), + Materials.CarbonDioxide.getGas(1000), + MISC_MATERIALS.SODIUM_NITRATE.getDust(10), + 100, + 30); + } + + private static void blastFurnaceRecipes() { + + // public boolean addBlastRecipe( + // ItemStack aInput1, ItemStack aInput2, + // FluidStack aFluidInput, FluidStack aFluidOutput, + // ItemStack aOutput1, ItemStack aOutput2, + // int aDuration, int aEUt, int aLevel) + + // Synthetic Graphite + GT_Values.RA.addBlastRecipe( + CI.getNumberedCircuit(22), + ALLOY.SILICON_CARBIDE.getDust(16), + ELEMENT.getInstance().NITROGEN.getFluidStack(4000), + GT_Values.NF, + ItemUtils.getItemStackOfAmountFromOreDict("dustGraphite", 8), + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallSilicon", 8), + 60 * 20, + MaterialUtils.getVoltageForTier(GTNH ? 5 : 4), + 4500); + + // Bomb Casings + GT_Values.RA.addBlastRecipe( + GregtechItemList.Bomb_Cast.get(4), + ALLOY.STEEL.getDust(16), + ELEMENT.getInstance().OXYGEN.getFluidStack(2000), + GT_Values.NF, + GregtechItemList.Bomb_Cast_Molten.get(4), + null, + 4 * 60 * 20, + MaterialUtils.getVoltageForTier(GTNH ? 3 : 2), + 2800); + + // Krypton Processing + if (ModItems.itemHotTitaniumIngot != null) { + GT_Values.RA.addBlastRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("ingotTitanium", 1), + CI.getNumberedCircuit(16), + GT_Values.NF, + GT_Values.NF, + ItemUtils.getItemStackOfAmountFromOreDict("ingotHotTitanium", 1), + null, + 10 * 20, + 500, + Materials.Titanium.mBlastFurnaceTemp); + } + } + + private static void autoclaveRecipes() {} + + private static void benderRecipes() { + if (CORE.ConfigSwitches.enableMultiblock_PowerSubstation) { + GT_Values.RA.addBenderRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("ingotVanadium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("plateVanadium", 1), + 8, + 16); + } + } + + private static void compressorRecipes() { + GT_ModHandler.addCompressionRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("dustClay", 1), + ItemUtils.getItemStackOfAmountFromOreDict("plateClay", 1)); + GT_ModHandler.addCompressionRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("dustMeatRaw", 1), + ItemUtils.getItemStackOfAmountFromOreDict("plateMeatRaw", 1)); + GT_ModHandler.addCompressionRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("dustMeatRaw", 9), + ItemUtils.getItemStackOfAmountFromOreDict("blockMeatRaw", 1)); + CORE.RA.addCompressorRecipe( + ItemList.FusionComputer_UV.get(9), + GregtechItemList.Compressed_Fusion_Reactor.get(1), + (int) GT_Values.V[7], + (int) GT_Values.V[8]); + } + + private static void macerationRecipes() { + + GT_ModHandler.addPulverisationRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("blockMeatRaw", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustMeatRaw", 9)); + + GT_ModHandler.addPulverisationRecipe( + GregtechItemList.Bomb_Cast_Broken.get(1), ItemUtils.getItemStackOfAmountFromOreDict("dustClay", 3)); + + if (ItemUtils.simpleMetaStack("chisel:limestone", 0, 1) != null) { + GT_ModHandler.addPulverisationRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("limestone", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustCalcite", 4)); + } + } + + private static void cyclotronRecipes() { + + // Polonium + CORE.RA.addCyclotronRecipe( + CI.getNumberedCircuit(1), + FluidUtils.getFluidStack("molten.bismuth", 1), + new ItemStack[] {GregtechItemList.Pellet_RTG_PO210.get(1)}, + null, + new int[] {100}, + 20 * 300 * 100, + 2040 * 4, + 500 * 20); + + // Americium + CORE.RA.addCyclotronRecipe( + CI.getNumberedCircuit(1), + FluidUtils.getFluidStack("molten.americium", 1), + new ItemStack[] {GregtechItemList.Pellet_RTG_AM241.get(4)}, + null, + new int[] {2500}, + 20 * 300 * 100, + 1020 * 4, + 500 * 20); // PO Special Value + + // Strontium u235 + CORE.RA.addCyclotronRecipe( + CI.getNumberedCircuit(1), + FluidUtils.getFluidStack("molten.uranium235", 10), + new ItemStack[] {GregtechItemList.Pellet_RTG_SR90.get(1)}, + null, + new int[] {570}, + 20 * 300 * 100, + 1020 * 4, + 500 * 20); // PO Special Value + + // Strontium u233 + CORE.RA.addCyclotronRecipe( + CI.getNumberedCircuit(1), + FluidUtils.getFluidStack("molten.uranium233", 10), + new ItemStack[] {GregtechItemList.Pellet_RTG_SR90.get(1)}, + null, + new int[] {660}, + 20 * 300 * 100, + 1020 * 4, + 500 * 20); // PO Special Value + + // Strontium pu239 + CORE.RA.addCyclotronRecipe( + CI.getNumberedCircuit(1), + FluidUtils.getFluidStack("molten.plutonium239", 10), + new ItemStack[] {GregtechItemList.Pellet_RTG_SR90.get(1)}, + null, + new int[] {220}, + 20 * 300 * 100, + 1020 * 4, + 500 * 20); // PO Special Value + + // Plutonium + CORE.RA.addCyclotronRecipe( + CI.getNumberedCircuit(1), + FluidUtils.getFluidStack("molten.plutonium238", 1), + new ItemStack[] {GregtechItemList.Pellet_RTG_PU238.get(2)}, + null, + new int[] {780}, + 20 * 300 * 100, + 1020 * 4, + 500 * 20); // PO Special Value + + // Neptunium + CORE.RA.addCyclotronRecipe( + new ItemStack[] {ELEMENT.getInstance().URANIUM238.getDust(1)}, + FluidUtils.getFluidStack("deuterium", 400), + new ItemStack[] {ItemUtils.getSimpleStack(ModItems.dustNeptunium238)}, + null, + new int[] {500}, + 20 * 5, + 500 * 4, + 500 * 20); // PO Special Value + + /** + * Particle Science + */ + + // Quark Smash + CORE.RA.addCyclotronRecipe( + CI.getNumberedCircuit(3), + FluidUtils.getFluidStack("plasma.hydrogen", 100), + new ItemStack[] { + Particle.getBaseParticle(Particle.UP), + Particle.getBaseParticle(Particle.DOWN), + Particle.getBaseParticle(Particle.CHARM), + Particle.getBaseParticle(Particle.STRANGE), + Particle.getBaseParticle(Particle.TOP), + Particle.getBaseParticle(Particle.BOTTOM), + }, + null, + new int[] {50, 50, 50, 50, 50, 50}, + 20 * 300 * 9, + (int) MaterialUtils.getVoltageForTier(7), + 750 * 20); + + // Lepton Smash + CORE.RA.addCyclotronRecipe( + CI.getNumberedCircuit(6), + FluidUtils.getFluidStack("plasma.helium", 1500), + new ItemStack[] { + Particle.getBaseParticle(Particle.ELECTRON), + Particle.getBaseParticle(Particle.MUON), + Particle.getBaseParticle(Particle.TAU), + Particle.getBaseParticle(Particle.ELECTRON_NEUTRINO), + Particle.getBaseParticle(Particle.MUON_NEUTRINO), + Particle.getBaseParticle(Particle.TAU_NEUTRINO), + }, + null, + new int[] {600, 40, 20, 15, 10, 5}, + 20 * 300 * 8, + (int) MaterialUtils.getVoltageForTier(7), + 750 * 20); + + // Boson Smash + CORE.RA.addCyclotronRecipe( + CI.getNumberedCircuit(9), + FluidUtils.getFluidStack("plasma.helium", 1500), + new ItemStack[] { + Particle.getBaseParticle(Particle.GLUON), + Particle.getBaseParticle(Particle.PHOTON), + Particle.getBaseParticle(Particle.Z_BOSON), + Particle.getBaseParticle(Particle.W_BOSON), + Particle.getBaseParticle(Particle.HIGGS_BOSON), + }, + null, + new int[] {160, 260, 150, 150, 1}, + 20 * 300 * 6, + (int) MaterialUtils.getVoltageForTier(7), + 750 * 20); + + // Mixed Smash 1 + CORE.RA.addCyclotronRecipe( + CI.getNumberedCircuit(12), + FluidUtils.getFluidStack("plasma.beryllium", 2500), + new ItemStack[] { + Particle.getBaseParticle(Particle.GRAVITON), + Particle.getBaseParticle(Particle.ETA_MESON), + Particle.getBaseParticle(Particle.PION), + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.NEUTRON), + Particle.getBaseParticle(Particle.LAMBDA), + Particle.getBaseParticle(Particle.OMEGA), + Particle.getBaseParticle(Particle.HIGGS_BOSON), + }, + null, + new int[] {10, 20, 20, 10, 10, 5, 5, 2}, + 17 * 247 * 32, + (int) MaterialUtils.getVoltageForTier(8), + 750 * 20); + + // Graviton Smash + CORE.RA.addCyclotronRecipe( + CI.getNumberedCircuit(15), + FluidUtils.getFluidStack("plasma.hydrogen", GTNH ? 50 : 10), + new ItemStack[] {Particle.getBaseParticle(Particle.GRAVITON), Particle.getBaseParticle(Particle.UNKNOWN) + }, + null, + new int[] {15, 100}, + 20 * (GTNH ? 90 : 30), + (int) MaterialUtils.getVoltageForTier(6), + 1000 * 20); + + FluidStack aPlasma = Materials.Duranium.getMolten(GTNH ? 40 : 10); + FluidStack aPlasma_NULL = Materials._NULL.getPlasma(1); + + if (aPlasma == null || aPlasma.isFluidEqual(aPlasma_NULL)) { + aPlasma = Materials.Americium.getMolten(GTNH ? 20 : 5); + } + + // Quantum Anomaly + CORE.RA.addCyclotronRecipe( + new ItemStack[] { + CI.getNumberedCircuit(24), Particle.getBaseParticle(Particle.UNKNOWN), + }, + aPlasma, + new ItemStack[] {GregtechItemList.Laser_Lens_Special.get(1)}, + null, + new int[] {100}, + 20 * (GTNH ? 25 : 60), + (int) MaterialUtils.getVoltageForTier(8), + 500 * 20); + + /* + * Ions + */ + + int IonCount = 2; + int tenCountA = (GTNH ? 2 : 1); + int tenCountB = 0; + for (String y : IonParticles.MetaToNameMap.values()) { + if (y.toLowerCase().contains("hydrogen")) { + continue; + } + FluidStack aPlasma2 = FluidUtils.getFluidStack("plasma." + y.toLowerCase(), 2); + Materials aTestMat = MaterialUtils.getMaterial(y); + FluidStack aPlasma3 = aTestMat != null ? aTestMat.getPlasma(2) : aPlasma2; + + // Ionize Plasma + if ((aPlasma2 != null && !aPlasma2.isFluidEqual(aPlasma_NULL)) + || (aPlasma3 != null && !aPlasma3.isFluidEqual(aPlasma_NULL))) { + CORE.RA.addCyclotronRecipe( + CI.getNumberedCircuit(1 + (tenCountA - 1)), + aPlasma2 != null ? aPlasma2 : aPlasma3, + new ItemStack[] { + Particle.getIon(y, 1), + Particle.getIon(y, 2), + Particle.getIon(y, 3), + Particle.getIon(y, -1), + Particle.getIon(y, -2), + Particle.getIon(y, -3), + Particle.getIon(y, 1), + Particle.getIon(y, 2), + Particle.getIon(y, -1), + }, + null, + new int[] {275, 250, 225, 275, 250, 225, 275, 250, 275}, + 20 * 20 * (IonCount++) * tenCountA, + (int) MaterialUtils.getVoltageForTier(7), + 1500 * 20 * tenCountA); + } else { + Logger.INFO("Plasma for " + y + " does not exist, please report this to Alkalus."); + } + + if (tenCountB == 12) { + tenCountB = 0; + tenCountA++; + } else { + tenCountB++; + } + } + + // Generate Hydrogen Ion Recipe + CORE.RA.addCyclotronRecipe( + CI.getNumberedCircuit(24), + FluidUtils.getWildcardFluidStack("hydrogen", 1000), + new ItemStack[] { + Particle.getIon("Hydrogen", 1), + Particle.getIon("Hydrogen", 2), + Particle.getIon("Hydrogen", 3), + Particle.getIon("Hydrogen", 1), + Particle.getIon("Hydrogen", 2), + Particle.getIon("Hydrogen", 3), + Particle.getIon("Hydrogen", -1), + Particle.getIon("Hydrogen", -2), + Particle.getIon("Hydrogen", -3) + }, + null, + new int[] {500, 500, 500, 500, 500, 500, 500, 500, 500}, + 20 * 20, + (int) MaterialUtils.getVoltageForTier(6), + 2500); + + // Generate Hydrogen Plasma Recipe + CORE.RA.addCyclotronRecipe( + new ItemStack[] { + Particle.getIon("Hydrogen", 0), ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 1) + }, + null, + new ItemStack[] { + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.NEUTRON), + Particle.getBaseParticle(Particle.ELECTRON), + Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), + CI.emptyCells(1) + }, + FluidUtils.getFluidStack("plasma.hydrogen", 100), + new int[] {1250, 1250, 1250, 750, 750, 750, 10000}, + 20 * 60 * 2, + (int) MaterialUtils.getVoltageForTier(6), + 750 * 20); + + CORE.RA.addCyclotronRecipe( + new ItemStack[] { + CI.getNumberedCircuit(21), Particle.getIon("Hydrogen", 0), + }, + FluidUtils.getFluidStack("hydrogen", 1000), + new ItemStack[] { + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.NEUTRON), + Particle.getBaseParticle(Particle.ELECTRON), + Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), + }, + FluidUtils.getFluidStack("plasma.hydrogen", 100), + new int[] {1250, 1250, 1250, 750, 750, 750}, + 20 * 60 * 2, + (int) MaterialUtils.getVoltageForTier(6), + 750 * 20); + + // Generate Protons Easily + CORE.RA.addCyclotronRecipe( + new ItemStack[] {CI.getNumberedCircuit(20), Particle.getIon("Hydrogen", 0)}, + FluidUtils.getWildcardFluidStack("hydrogen", 100), + new ItemStack[] { + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + }, + null, + new int[] {750, 750, 750, 750, 750, 750, 750, 750, 750}, + 20 * 20, + (int) MaterialUtils.getVoltageForTier(6), + 1500); + + CORE.RA.addCyclotronRecipe( + new ItemStack[] { + CI.getNumberedCircuit(22), Particle.getBaseParticle(Particle.UNKNOWN), + }, + FluidUtils.getWildcardFluidStack("hydrogen", 100), + new ItemStack[] { + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + }, + null, + new int[] {375, 375, 375, 375, 375, 375, 375, 375, 375}, + 20 * 20, + (int) MaterialUtils.getVoltageForTier(6), + 1500); + + // Create Strange Dust + CORE.RA.addCyclotronRecipe( + new ItemStack[] { + ELEMENT.getInstance().PLUTONIUM238.getDust(1), + Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), + }, + FluidUtils.getFluidStack(FluidUtils.getWildcardFluidStack("ender", 1000), 1000), + new ItemStack[] {ORES.DEEP_EARTH_REACTOR_FUEL_DEPOSIT.getDust(1)}, + null, + new int[] {2500}, + 20 * 60 * 15, + (int) MaterialUtils.getVoltageForTier(7), + 250); + } + + private static void sifterRecipes() {} + + private static void electroMagneticSeperatorRecipes() { + + if (!GTNH) { + // Trinium + GT_Values.RA.addElectromagneticSeparatorRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedNaquadah", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustNaquadah", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallNaquadahEnriched", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallTrinium", 1), + new int[] {10000, 2500, 5000}, + 20 * 20, + 24); + + // Trinium + GT_Values.RA.addElectromagneticSeparatorRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedIridium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustIridium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallOsmium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallTrinium", 1), + new int[] {10000, 2500, 5000}, + 20 * 20, + 24); + + // Trinium + GT_Values.RA.addElectromagneticSeparatorRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedWulfenite", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustWulfenite", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallTrinium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallTrinium", 1), + new int[] {10000, 3000, 3000}, + 20 * 20, + 24); + } + } + + private static void advancedMixerRecipes() { + // HgBa2Ca2Cu3O8 + /*CORE.RA.addMixerRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("cellMercury", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustBarium", 2), + ItemUtils.getItemStackOfAmountFromOreDict("dustCalcium", 2), + ItemUtils.getItemStackOfAmountFromOreDict("dustCopper", 3), + FluidUtils.getFluidStack("oxygen", 8000), + null, CI.emptyCells(1), ALLOY.HG1223.getDust(16), null, null, + 30 * 20, 500); */ + + } } diff --git a/src/main/java/gtPlusPlus/core/recipe/RECIPES_General.java b/src/main/java/gtPlusPlus/core/recipe/RECIPES_General.java index 5aa6afdbd1..42c2b0eeef 100644 --- a/src/main/java/gtPlusPlus/core/recipe/RECIPES_General.java +++ b/src/main/java/gtPlusPlus/core/recipe/RECIPES_General.java @@ -17,7 +17,6 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.ALLOY; import gtPlusPlus.core.material.ELEMENT; -import gtPlusPlus.core.material.MISC_MATERIALS; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.minecraft.*; import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; @@ -29,535 +28,705 @@ import gtPlusPlus.xmod.gregtech.common.helpers.VolumetricFlaskHelper; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; public class RECIPES_General { - static final ItemStack NULL = null; - static ItemStack RECIPE_Paper; - static ItemStack RECIPE_Dirt; - static ItemStack RECIPE_Snow; - static ItemStack RECIPE_Obsidian; - static String RECIPE_LapisDust = "dustLazurite"; - static ItemStack OUTPUT_Blueprint; - static ItemStack RECIPE_CraftingTable; - static String RECIPE_BronzePlate = "plateBronze"; - static String RECIPE_StainlessPlate = "plateStainlessSteel"; - static ItemStack RECIPE_BasicCasingIC2; - static ItemStack OUTPUT_Workbench_Bronze; - static ItemStack OUTPUT_Workbench_Advanced; - static ItemStack RECIPE_HydrogenDust; - - public static void loadRecipes(){ - if (LoadedMods.Gregtech){ - RECIPE_Paper = ItemUtils.getSimpleStack(Items.paper); - RECIPE_Dirt = ItemUtils.getSimpleStack(Blocks.dirt); - RECIPE_Snow = ItemUtils.getSimpleStack(Blocks.snow); - RECIPE_Obsidian = ItemUtils.getSimpleStack(Blocks.obsidian); - RECIPE_CraftingTable = ItemUtils.getSimpleStack(Blocks.crafting_table); - RECIPE_HydrogenDust = ItemUtils.getSimpleStack(ModItems.itemHydrogenBlob); - RECIPE_BasicCasingIC2 = ItemUtils.getItemStackFromFQRN("IC2:blockMachine", 1); - OUTPUT_Workbench_Bronze = GregtechItemList.GT4_Workbench_Bronze.get(1); - OUTPUT_Workbench_Advanced = GregtechItemList.GT4_Workbench_Advanced.get(1); - OUTPUT_Blueprint = ItemUtils.getSimpleStack(ModItems.itemBlueprintBase, 2); - run(); - addCompressedObsidian(); - migratedRecipes(); - } - } - - private static void run() { - //Workbench Blueprint - RecipeUtils.addShapedRecipe( - RECIPE_Paper, RECIPE_LapisDust, NULL, - RECIPE_Paper, RECIPE_LapisDust, NULL, - RECIPE_LapisDust, RECIPE_LapisDust, NULL, - OUTPUT_Blueprint); - - //Bronze Workbench - RecipeUtils.addShapedRecipe( - RECIPE_BronzePlate, RECIPE_CraftingTable, RECIPE_BronzePlate, - RECIPE_BronzePlate, RECIPE_BasicCasingIC2, RECIPE_BronzePlate, - RECIPE_BronzePlate, CI.getTieredCircuitOreDictName(0), RECIPE_BronzePlate, - OUTPUT_Workbench_Bronze); - - RecipeUtils.addShapedRecipe( - RECIPE_StainlessPlate, CI.getTieredCircuitOreDictName(3), RECIPE_StainlessPlate, - RECIPE_StainlessPlate, OUTPUT_Workbench_Bronze, RECIPE_StainlessPlate, - RECIPE_StainlessPlate, CI.getTieredCircuitOreDictName(3), RECIPE_StainlessPlate, - OUTPUT_Workbench_Advanced); - - //Generates recipes for the Dull shard when TC is not installed. - if (!LoadedMods.Thaumcraft) { - //Dull Shard to Aer - RecipeUtils.addShapedRecipe( - RECIPE_HydrogenDust, RECIPE_HydrogenDust, RECIPE_HydrogenDust, - RECIPE_HydrogenDust, ItemUtils.getSimpleStack(ModItems.shardDull), RECIPE_HydrogenDust, - RECIPE_HydrogenDust, RECIPE_HydrogenDust, RECIPE_HydrogenDust, - ItemUtils.getSimpleStack(ModItems.shardAer)); - //Dull Shard to Ignis - RecipeUtils.addShapedRecipe( - RECIPE_Obsidian, RECIPE_Obsidian, RECIPE_Obsidian, - RECIPE_Obsidian, ItemUtils.getSimpleStack(ModItems.shardDull), RECIPE_Obsidian, - RECIPE_Obsidian, RECIPE_Obsidian, RECIPE_Obsidian, - ItemUtils.getSimpleStack(ModItems.shardIgnis)); - //Dull Shard to Terra - RecipeUtils.addShapedRecipe( - RECIPE_Dirt, RECIPE_Dirt, RECIPE_Dirt, - RECIPE_Dirt, ItemUtils.getSimpleStack(ModItems.shardDull), RECIPE_Dirt, - RECIPE_Dirt, RECIPE_Dirt, RECIPE_Dirt, - ItemUtils.getSimpleStack(ModItems.shardTerra)); - //Dull Shard to Aqua - RecipeUtils.addShapedRecipe( - RECIPE_LapisDust, RECIPE_LapisDust, RECIPE_LapisDust, - RECIPE_LapisDust, ItemUtils.getSimpleStack(ModItems.shardDull), RECIPE_LapisDust, - RECIPE_LapisDust, RECIPE_LapisDust, RECIPE_LapisDust, - ItemUtils.getSimpleStack(ModItems.shardAqua)); - - GT_ModHandler.addPulverisationRecipe(ItemUtils.getSimpleStack(ModItems.shardAer), ItemUtils.getSimpleStack(ModItems.dustAer, 2)); - GT_ModHandler.addPulverisationRecipe(ItemUtils.getSimpleStack(ModItems.shardIgnis), ItemUtils.getSimpleStack(ModItems.dustIgnis, 2)); - GT_ModHandler.addPulverisationRecipe(ItemUtils.getSimpleStack(ModItems.shardTerra), ItemUtils.getSimpleStack(ModItems.dustTerra, 2)); - GT_ModHandler.addPulverisationRecipe(ItemUtils.getSimpleStack(ModItems.shardAqua), ItemUtils.getSimpleStack(ModItems.dustAqua, 2)); - - } - - //Rainforest oak Sapling - if (RecipeUtils.addShapedRecipe( - "stickWood", "stickWood", "stickWood", - "stickWood", "treeSapling", "stickWood", - "stickWood", "dustBone", "stickWood", - ItemUtils.getSimpleStack(BOP_Block_Registrator.sapling_Rainforest))){ - Logger.INFO("Added a recipe for Rainforest oak Saplings."); - } - - //Iron bars - final ItemStack ironBars; - if (CORE.GTNH) { - ironBars = ItemUtils.getItemStackFromFQRN("dreamcraft:item.SteelBars", 1); - } else { - ironBars = ItemUtils.getItemStackFromFQRN("minecraft:iron_bars", 1); - } - - //Fish Trap - if (RecipeUtils.addShapedRecipe( - ironBars, ironBars, ironBars, - ironBars, "frameGtWroughtIron", ironBars, - ironBars, ironBars, ironBars, - ItemUtils.getSimpleStack(ModBlocks.blockFishTrap))){ - Logger.INFO("Added a recipe for the Fish Trap."); - } - - //Small Gear Extruder Shape - if (!CORE.GTNH) { - GT_ModHandler.addCraftingRecipe(GregtechItemList.Shape_Extruder_SmallGear.get(1L, new Object[0]), GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"hXS", "XPX", "fXd", Character.valueOf('P'), ItemList.Shape_Extruder_Gear, Character.valueOf('X'), OrePrefixes.plate.get(Materials.Steel), Character.valueOf('S'), OrePrefixes.screw.get(Materials.Steel)}); - - - String[] ironTypes = {"", "Wrought", "Pig", "Any"}; - for (int y=0;y= 2800) ? 64 : 16; - generatePipeRecipes(e.mDefaultLocalName, e.getMass(), tVoltageMultiplier); - } - - Materials[] h = new Materials[] { - Materials.Europium, - Materials.Tungsten, - Materials.DarkSteel, - Materials.Clay, - Materials.Lead, - - }; - - for (Materials e : h) { - if (e == Materials.DarkSteel) { - if (!LoadedMods.EnderIO) { - continue; - } - } - int tVoltageMultiplier = (e.mBlastFurnaceTemp >= 2800) ? 64 : 16; - generatePipeRecipes(e.mDefaultLocalName, e.getMass(), tVoltageMultiplier); - } - - RecipeUtils.addShapedGregtechRecipe(CI.component_Plate[6], ALLOY.MARAGING250.getGear(1), CI.component_Plate[6], - CI.getTieredCircuitOreDictName(4), GregtechItemList.Casing_AdvancedVacuum.get(1), - CI.getTieredCircuitOreDictName(4), CI.component_Plate[5], ItemList.Hatch_Input_IV.get(1), - CI.component_Plate[5], GregtechItemList.Hatch_Input_Cryotheum.get(1L, new Object[0])); - - RecipeUtils.addShapedGregtechRecipe(CI.component_Plate[5], ALLOY.MARAGING300.getGear(1), CI.component_Plate[5], - CI.getTieredCircuitOreDictName(4), GregtechItemList.Casing_Adv_BlastFurnace.get(1), - CI.getTieredCircuitOreDictName(4), CI.component_Plate[6], ItemList.Hatch_Input_IV.get(1), - CI.component_Plate[6], GregtechItemList.Hatch_Input_Pyrotheum.get(1L, new Object[0])); - - RecipeUtils.addShapedGregtechRecipe(CI.component_Plate[8], ALLOY.PIKYONIUM.getGear(1), CI.component_Plate[9], - CI.getTieredCircuitOreDictName(7), GregtechItemList.Casing_Naq_Reactor_A.get(1), - CI.getTieredCircuitOreDictName(7), CI.component_Plate[9], ItemList.Hatch_Input_ZPM.get(1), - CI.component_Plate[8], GregtechItemList.Hatch_Input_Naquadah.get(1L, new Object[0])); - - - if (PollutionUtils.isPollutionEnabled()) { - GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_LV.get(1L, new Object[0]), bitsd, - new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_LV.get(1), Character.valueOf('P'), - GregtechItemList.Pollution_Cleaner_LV.get(1) }); - GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_MV.get(1L, new Object[0]), bitsd, - new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_MV.get(1), Character.valueOf('P'), - GregtechItemList.Pollution_Cleaner_MV.get(1) }); - GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_HV.get(1L, new Object[0]), bitsd, - new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_HV.get(1), Character.valueOf('P'), - GregtechItemList.Pollution_Cleaner_HV.get(1) }); - GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_EV.get(1L, new Object[0]), bitsd, - new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_EV.get(1), Character.valueOf('P'), - GregtechItemList.Pollution_Cleaner_EV.get(1) }); - GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_IV.get(1L, new Object[0]), bitsd, - new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_IV.get(1), Character.valueOf('P'), - GregtechItemList.Pollution_Cleaner_IV.get(1) }); - GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_LuV.get(1L, new Object[0]), bitsd, - new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_LuV.get(1), Character.valueOf('P'), - GregtechItemList.Pollution_Cleaner_LuV.get(1) }); - GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_ZPM.get(1L, new Object[0]), bitsd, - new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_ZPM.get(1), Character.valueOf('P'), - GregtechItemList.Pollution_Cleaner_ZPM.get(1) }); - GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_UV.get(1L, new Object[0]), bitsd, - new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_UV.get(1), Character.valueOf('P'), - GregtechItemList.Pollution_Cleaner_UV.get(1) }); - GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_MAX.get(1L, new Object[0]), bitsd, - new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_MAX.get(1), Character.valueOf('P'), - GregtechItemList.Pollution_Cleaner_MAX.get(1) }); - } - - - - - - - - - - - } - - - - - - - - - + static final ItemStack NULL = null; + static ItemStack RECIPE_Paper; + static ItemStack RECIPE_Dirt; + static ItemStack RECIPE_Snow; + static ItemStack RECIPE_Obsidian; + static String RECIPE_LapisDust = "dustLazurite"; + static ItemStack OUTPUT_Blueprint; + static ItemStack RECIPE_CraftingTable; + static String RECIPE_BronzePlate = "plateBronze"; + static String RECIPE_StainlessPlate = "plateStainlessSteel"; + static ItemStack RECIPE_BasicCasingIC2; + static ItemStack OUTPUT_Workbench_Bronze; + static ItemStack OUTPUT_Workbench_Advanced; + static ItemStack RECIPE_HydrogenDust; + + public static void loadRecipes() { + if (LoadedMods.Gregtech) { + RECIPE_Paper = ItemUtils.getSimpleStack(Items.paper); + RECIPE_Dirt = ItemUtils.getSimpleStack(Blocks.dirt); + RECIPE_Snow = ItemUtils.getSimpleStack(Blocks.snow); + RECIPE_Obsidian = ItemUtils.getSimpleStack(Blocks.obsidian); + RECIPE_CraftingTable = ItemUtils.getSimpleStack(Blocks.crafting_table); + RECIPE_HydrogenDust = ItemUtils.getSimpleStack(ModItems.itemHydrogenBlob); + RECIPE_BasicCasingIC2 = ItemUtils.getItemStackFromFQRN("IC2:blockMachine", 1); + OUTPUT_Workbench_Bronze = GregtechItemList.GT4_Workbench_Bronze.get(1); + OUTPUT_Workbench_Advanced = GregtechItemList.GT4_Workbench_Advanced.get(1); + OUTPUT_Blueprint = ItemUtils.getSimpleStack(ModItems.itemBlueprintBase, 2); + run(); + addCompressedObsidian(); + migratedRecipes(); + } + } + + private static void run() { + // Workbench Blueprint + RecipeUtils.addShapedRecipe( + RECIPE_Paper, + RECIPE_LapisDust, + NULL, + RECIPE_Paper, + RECIPE_LapisDust, + NULL, + RECIPE_LapisDust, + RECIPE_LapisDust, + NULL, + OUTPUT_Blueprint); + + // Bronze Workbench + RecipeUtils.addShapedRecipe( + RECIPE_BronzePlate, + RECIPE_CraftingTable, + RECIPE_BronzePlate, + RECIPE_BronzePlate, + RECIPE_BasicCasingIC2, + RECIPE_BronzePlate, + RECIPE_BronzePlate, + CI.getTieredCircuitOreDictName(0), + RECIPE_BronzePlate, + OUTPUT_Workbench_Bronze); + + RecipeUtils.addShapedRecipe( + RECIPE_StainlessPlate, + CI.getTieredCircuitOreDictName(3), + RECIPE_StainlessPlate, + RECIPE_StainlessPlate, + OUTPUT_Workbench_Bronze, + RECIPE_StainlessPlate, + RECIPE_StainlessPlate, + CI.getTieredCircuitOreDictName(3), + RECIPE_StainlessPlate, + OUTPUT_Workbench_Advanced); + + // Generates recipes for the Dull shard when TC is not installed. + if (!LoadedMods.Thaumcraft) { + // Dull Shard to Aer + RecipeUtils.addShapedRecipe( + RECIPE_HydrogenDust, + RECIPE_HydrogenDust, + RECIPE_HydrogenDust, + RECIPE_HydrogenDust, + ItemUtils.getSimpleStack(ModItems.shardDull), + RECIPE_HydrogenDust, + RECIPE_HydrogenDust, + RECIPE_HydrogenDust, + RECIPE_HydrogenDust, + ItemUtils.getSimpleStack(ModItems.shardAer)); + // Dull Shard to Ignis + RecipeUtils.addShapedRecipe( + RECIPE_Obsidian, + RECIPE_Obsidian, + RECIPE_Obsidian, + RECIPE_Obsidian, + ItemUtils.getSimpleStack(ModItems.shardDull), + RECIPE_Obsidian, + RECIPE_Obsidian, + RECIPE_Obsidian, + RECIPE_Obsidian, + ItemUtils.getSimpleStack(ModItems.shardIgnis)); + // Dull Shard to Terra + RecipeUtils.addShapedRecipe( + RECIPE_Dirt, + RECIPE_Dirt, + RECIPE_Dirt, + RECIPE_Dirt, + ItemUtils.getSimpleStack(ModItems.shardDull), + RECIPE_Dirt, + RECIPE_Dirt, + RECIPE_Dirt, + RECIPE_Dirt, + ItemUtils.getSimpleStack(ModItems.shardTerra)); + // Dull Shard to Aqua + RecipeUtils.addShapedRecipe( + RECIPE_LapisDust, + RECIPE_LapisDust, + RECIPE_LapisDust, + RECIPE_LapisDust, + ItemUtils.getSimpleStack(ModItems.shardDull), + RECIPE_LapisDust, + RECIPE_LapisDust, + RECIPE_LapisDust, + RECIPE_LapisDust, + ItemUtils.getSimpleStack(ModItems.shardAqua)); + + GT_ModHandler.addPulverisationRecipe( + ItemUtils.getSimpleStack(ModItems.shardAer), ItemUtils.getSimpleStack(ModItems.dustAer, 2)); + GT_ModHandler.addPulverisationRecipe( + ItemUtils.getSimpleStack(ModItems.shardIgnis), ItemUtils.getSimpleStack(ModItems.dustIgnis, 2)); + GT_ModHandler.addPulverisationRecipe( + ItemUtils.getSimpleStack(ModItems.shardTerra), ItemUtils.getSimpleStack(ModItems.dustTerra, 2)); + GT_ModHandler.addPulverisationRecipe( + ItemUtils.getSimpleStack(ModItems.shardAqua), ItemUtils.getSimpleStack(ModItems.dustAqua, 2)); + } + + // Rainforest oak Sapling + if (RecipeUtils.addShapedRecipe( + "stickWood", + "stickWood", + "stickWood", + "stickWood", + "treeSapling", + "stickWood", + "stickWood", + "dustBone", + "stickWood", + ItemUtils.getSimpleStack(BOP_Block_Registrator.sapling_Rainforest))) { + Logger.INFO("Added a recipe for Rainforest oak Saplings."); + } + + // Iron bars + final ItemStack ironBars; + if (CORE.GTNH) { + ironBars = ItemUtils.getItemStackFromFQRN("dreamcraft:item.SteelBars", 1); + } else { + ironBars = ItemUtils.getItemStackFromFQRN("minecraft:iron_bars", 1); + } + + // Fish Trap + if (RecipeUtils.addShapedRecipe( + ironBars, + ironBars, + ironBars, + ironBars, + "frameGtWroughtIron", + ironBars, + ironBars, + ironBars, + ironBars, + ItemUtils.getSimpleStack(ModBlocks.blockFishTrap))) { + Logger.INFO("Added a recipe for the Fish Trap."); + } + + // Small Gear Extruder Shape + if (!CORE.GTNH) { + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Shape_Extruder_SmallGear.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.BUFFERED + | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE, + new Object[] { + "hXS", + "XPX", + "fXd", + Character.valueOf('P'), + ItemList.Shape_Extruder_Gear, + Character.valueOf('X'), + OrePrefixes.plate.get(Materials.Steel), + Character.valueOf('S'), + OrePrefixes.screw.get(Materials.Steel) + }); + + String[] ironTypes = {"", "Wrought", "Pig", "Any"}; + for (int y = 0; y < ironTypes.length; y++) { + // Iron bars + String ironRecipe = "stick" + ironTypes[y] + "Iron"; + if (RecipeUtils.addShapedRecipe( + null, + CI.craftingToolWrench, + null, + ironRecipe, + ironRecipe, + ironRecipe, + ironRecipe, + ironRecipe, + ironRecipe, + ItemUtils.getItemStackFromFQRN("minecraft:iron_bars", 8))) { + Logger.INFO("Re-added old GT recipe for Iron Bars."); + } + } + } + + // Shaped Crafting for ULV Material Dusts + + // Potin + if (RecipeUtils.addShapelessGregtechRecipe( + new Object[] {"dustLead", "dustBronze", "dustTin", "dustLead", "dustBronze"}, ALLOY.POTIN.getDust(5))) { + Logger.INFO("Added shapeless recipe for Potin Dust."); + } + + // Tumbaga + if (RecipeUtils.addShapelessGregtechRecipe( + new Object[] {"dustGold", "dustGold", "dustCopper"}, + ItemUtils.getSimpleStack(ModItems.dustTumbagaMix))) { + Logger.INFO("Added shapeless recipe for Tumbaga Mix."); + } + if (RecipeUtils.addShapelessGregtechRecipe( + new Object[] { + ItemUtils.getSimpleStack(ModItems.dustTumbagaMix), + ItemUtils.getSimpleStack(ModItems.dustTumbagaMix), + ItemUtils.getSimpleStack(ModItems.dustTumbagaMix), + "dustGold" + }, + ALLOY.TUMBAGA.getDust(10))) { + Logger.INFO("Added shapeless recipe for Tumbaga Dust."); + } + + if (CORE.ConfigSwitches.enableMachine_Pollution) { + RecipeUtils.addShapedRecipe( + CI.craftingToolFile, + "plateIron", + "stickIron", + "plateIron", + "ringIron", + "plateIron", + "stickIron", + "plateIron", + CI.craftingToolHammer_Hard, + ItemUtils.simpleMetaStack(ModItems.itemBasicTurbine, 0, 1)); + RecipeUtils.addShapedRecipe( + CI.craftingToolFile, + "plateBronze", + "stickBronze", + "plateBronze", + "ringBronze", + "plateBronze", + "stickBronze", + "plateBronze", + CI.craftingToolHammer_Hard, + ItemUtils.simpleMetaStack(ModItems.itemBasicTurbine, 1, 1)); + RecipeUtils.addShapedRecipe( + CI.craftingToolFile, + "plateSteel", + "stickSteel", + "plateSteel", + "ringSteel", + "plateSteel", + "stickSteel", + "plateSteel", + CI.craftingToolHammer_Hard, + ItemUtils.simpleMetaStack(ModItems.itemBasicTurbine, 2, 1)); + } + + if (Meta_GT_Proxy.sDoesVolumetricFlaskExist) { + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(4), + ItemUtils.getSimpleStack(Blocks.glass, 16), + ItemUtils.getSimpleStack(Blocks.glowstone, 16), + ItemList.Large_Fluid_Cell_Steel.get(1) + }, + FluidUtils.getFluidStack("molten.borosilicateglass", 2000), + VolumetricFlaskHelper.getLargeVolumetricFlask(2), + 20 * 15, + MaterialUtils.getVoltageForTier(3)); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(5), + ItemUtils.getSimpleStack(Blocks.glass, 64), + ItemUtils.getSimpleStack(Blocks.glowstone, 64), + ItemList.Large_Fluid_Cell_TungstenSteel.get(1) + }, + FluidUtils.getFluidStack("molten.borosilicateglass", 8000), + VolumetricFlaskHelper.getGiganticVolumetricFlask(2), + 20 * 15, + MaterialUtils.getVoltageForTier(5)); + } + + // Mining Explosive + Logger.RECIPE("[Inspection] Explosives"); + if (RecipeUtils.addShapedRecipe( + CI.explosiveITNT, + CI.explosiveTNT, + CI.explosiveITNT, + CI.explosiveTNT, + "frameGtIron", + CI.explosiveTNT, + "dustSulfur", + CI.explosiveTNT, + "dustSulfur", + ItemUtils.getSimpleStack(ModBlocks.blockMiningExplosive, 3))) { + Logger.INFO("Added a recipe for Mining Explosives."); + } + + // Alkalus Coin + if (RecipeUtils.addShapedRecipe( + "gemExquisiteRuby", + "gemFlawlessDiamond", + "gemExquisiteDiamond", + "gemFlawlessRuby", + ItemList.Credit_Greg_Osmium.get(1), + "gemFlawlessSapphire", + "gemExquisiteEmerald", + "gemFlawlessEmerald", + "gemExquisiteSapphire", + ItemUtils.getSimpleStack(ModItems.itemAlkalusDisk))) { + Logger.INFO("Added a recipe for The Alkalus Disk."); + } + + /*final String fancyGems[] = new String[]{"gemExquisiteDiamond", "gemExquisiteEmerald", "gemExquisiteRuby", "gemExquisiteSapphire"}; + final ItemStack gemShards[] = new ItemStack[]{ItemUtils.simpleMetaStack(ModItems.itemGemShards, 0, 1), + ItemUtils.simpleMetaStack(ModItems.itemGemShards, 1, 1), + ItemUtils.simpleMetaStack(ModItems.itemGemShards, 2, 1), + ItemUtils.simpleMetaStack(ModItems.itemGemShards, 3, 1)}; + + int l=0; + for (final String gem : fancyGems){ + GameRegistry.addShapelessRecipe( + gemShards[l], + ItemUtils.getItemStackOfAmountFromOreDict(gem, 1), + new ItemStack(ModItems.itemAlkalusDisk, 1, OreDictionary.WILDCARD_VALUE)); + l++; + }*/ + + Logger.RECIPE("[Inspection] Wither Cage"); + if (RecipeUtils.addShapedRecipe( + "stickBlackSteel", + "plateTungstenSteel", + "stickBlackSteel", + "plateTungstenSteel", + getSimpleStack(Items.nether_star), + "plateTungstenSteel", + "stickBlackSteel", + "plateTungstenSteel", + "stickBlackSteel", + ItemUtils.getSimpleStack(ModBlocks.blockWitherGuard, 32))) { + Logger.INFO("Added a recipe for Wither Cages."); + } + + /*Logger.RECIPE("[Inspection] Xp Converter"); + if (RecipeUtils.addShapedRecipe( + getSimpleStack(Items.experience_bottle), ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 2, 1), getSimpleStack(Items.experience_bottle), + ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 5, 1), getSimpleStack(Items.nether_star), ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 5, 1), + getSimpleStack(Items.experience_bottle), ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 2, 1), getSimpleStack(Items.experience_bottle), + ItemUtils.getSimpleStack(ModBlocks.blockXpConverter, 1))){ + Logger.INFO("Added a recipe for XP Converter."); + }*/ + + // Rope/Fiber/Net + if (RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDictNoBroken(CI.craftingToolKnife, 1), + ItemUtils.getSimpleStack(Items.reeds) + }, + ItemUtils.getSimpleStack(ModItems.itemFiber, 16))) { + Logger.INFO("Added a recipe for Fiber."); + } + + if (RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[] { + ItemUtils.getItemStackOfAmountFromOreDictNoBroken(CI.craftingToolKnife, 1), + ItemUtils.getSimpleStack(Blocks.sapling) + }, + ItemUtils.getSimpleStack(ModItems.itemFiber, 32))) { + Logger.INFO("Added a recipe for Fiber."); + } + + if (RecipeUtils.addShapedRecipe( + null, + ItemUtils.getSimpleStack(ModItems.itemFiber, 1), + null, + ItemUtils.getSimpleStack(ModItems.itemFiber, 1), + CI.craftingToolKnife, + ItemUtils.getSimpleStack(ModItems.itemFiber, 1), + null, + ItemUtils.getSimpleStack(ModItems.itemFiber, 1), + null, + ItemUtils.getSimpleStack(ModItems.itemRope, 3))) { + Logger.INFO("Added a recipe for Rope."); + } + + Logger.RECIPE("[Inspection] Net"); + if (RecipeUtils.addShapedRecipe( + ItemUtils.getSimpleStack(ModItems.itemRope, 1), + ItemUtils.getSimpleStack(ModItems.itemRope, 1), + ItemUtils.getSimpleStack(ModItems.itemRope, 1), + ItemUtils.getSimpleStack(ModItems.itemRope, 1), + ItemUtils.getSimpleStack(ModItems.itemRope, 1), + ItemUtils.getSimpleStack(ModItems.itemRope, 1), + null, + null, + null, + ItemUtils.getSimpleStack(ModBlocks.blockNet, 2))) { + Logger.INFO("Added a recipe for Nets."); + } + + // Slow Builders Ring + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + ItemUtils.getSimpleStack(Blocks.ice, 8), + ItemUtils.getSimpleStack(ModBlocks.blockNet, 8), + ItemUtils.getSimpleStack(Blocks.vine, 8), + ALLOY.TUMBAGA.getRing(1), + }, + FluidUtils.getWater(1000), // Fluid + ItemUtils.getItemStackFromFQRN("miscutils:SlowBuildingRing", 1), // Output + 20 * 30, // Dur + 16); // Eu + + // Magic Feather + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + ItemUtils.getSimpleStack(Items.feather, 64), + ItemUtils.getSimpleStack(Blocks.emerald_block, 32), + ItemUtils.getSimpleStack(Blocks.diamond_block, 32), + Materials.Ruby.getBlocks(32), + Materials.Sapphire.getBlocks(32), + ItemUtils.getSimpleStack(Blocks.gold_block, 32), + }, + Materials.Silver.getMolten(32 * 144), // Fluid + ItemUtils.getSimpleStack(ModItems.itemMagicFeather, 1), // Output + 20 * 120, // Dur + MaterialUtils.getVoltageForTier(4)); // Eu + + // Pest Killer + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedCircuit(16), + CI.getTieredMachineCasing(1), + CI.getElectricPump(2, 1), + CI.getPlate(2, GTNH ? 4 : 2), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(0), GTNH ? 2 : 1), + }, + FluidUtils.getHotWater(500), // Fluid + ItemUtils.getSimpleStack(ModBlocks.blockPestKiller), // Output + 20 * 60, // Dur + 16); // Eu + } + + private static boolean addCompressedObsidian() { + // Invert Obsidian + ItemStack aInvertedObsidian = ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 5, 1); + if (RecipeUtils.addShapedRecipe( + getSimpleStack(Items.redstone), + getSimpleStack(Items.glowstone_dust), + getSimpleStack(Items.redstone), + getSimpleStack(Items.glowstone_dust), + ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 1, 1), + getSimpleStack(Items.glowstone_dust), + getSimpleStack(Items.redstone), + getSimpleStack(Items.glowstone_dust), + getSimpleStack(Items.redstone), + aInvertedObsidian)) { + Logger.INFO("Added a recipe for Inverted Obsidian."); + } + + final ItemStack[] mItems = new ItemStack[6]; + mItems[0] = ItemUtils.getSimpleStack(Blocks.obsidian); + for (int r = 0; r < 5; r++) { + mItems[r + 1] = ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, r, 1); + } + + final ItemStack[] mItems2 = new ItemStack[6]; + mItems2[0] = ItemUtils.getSimpleStack(Blocks.glowstone); + for (int r = 0; r < 5; r++) { + mItems2[r + 1] = ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 6 + r, 1); + } + + // Compressed Obsidian 1-5 + for (int r = 0; r < 5; r++) { + + final ItemStack input = mItems[r]; + final ItemStack output = mItems[r + 1]; + + if (RecipeUtils.addShapedRecipe(input, input, input, input, input, input, input, input, input, output)) { + Logger.INFO("Added a recipe for Compressed Obsidian [" + r + "]"); + } + + if (RecipeUtils.addShapelessGregtechRecipe(new ItemStack[] {output}, ItemUtils.getSimpleStack(input, 9))) { + Logger.INFO("Added a shapeless recipe for Compressed Obsidian [" + r + "]"); + } + } + + // Compressed Glowstone 1-5 + for (int r = 0; r < 5; r++) { + + final ItemStack input = mItems2[r]; + final ItemStack output = mItems2[r + 1]; + + if (RecipeUtils.addShapedRecipe( + input, + input, + input, + input, + r == 2 ? aInvertedObsidian : input, + input, + input, + input, + input, + output)) { + Logger.INFO("Added a recipe for Compressed Glowstone [" + r + "]"); + } + + if (RecipeUtils.addShapelessGregtechRecipe(new ItemStack[] {output}, ItemUtils.getSimpleStack(input, 9))) { + Logger.INFO("Added a shapeless recipe for Compressed Glowstone [" + r + "]"); + } + } + return true; + } + + private static void migratedRecipes() { + + RecipeUtils.generateMortarRecipe( + ItemUtils.getSimpleStack(ModItems.itemPlateRawMeat), + ItemUtils.getItemStackOfAmountFromOreDict("dustMeatRaw", 1)); + + generateWireRecipes(ELEMENT.getInstance().ZIRCONIUM); + generateWireRecipes(ALLOY.HG1223); + generateWireRecipes(ALLOY.LEAGRISIUM); + generateWireRecipes(ALLOY.TRINIUM_TITANIUM); + generateWireRecipes(ELEMENT.STANDALONE.HYPOGEN); + + GT_Materials[] g = new GT_Materials[] { + GT_Materials.Staballoy, + GT_Materials.Tantalloy60, + GT_Materials.Tantalloy61, + GT_Materials.Void, + GT_Materials.Potin, + GT_Materials.MaragingSteel300, + GT_Materials.MaragingSteel350, + GT_Materials.Inconel690, + GT_Materials.Inconel792, + GT_Materials.HastelloyX, + GT_Materials.TriniumNaquadahCarbonite, + }; + for (GT_Materials e : g) { + if (e == GT_Materials.Void) { + if (!LoadedMods.Thaumcraft) { + continue; + } + } + int tVoltageMultiplier = (e.mBlastFurnaceTemp >= 2800) ? 64 : 16; + generatePipeRecipes(e.mDefaultLocalName, e.getMass(), tVoltageMultiplier); + } + + Materials[] h = new Materials[] { + Materials.Europium, Materials.Tungsten, Materials.DarkSteel, Materials.Clay, Materials.Lead, + }; + + for (Materials e : h) { + if (e == Materials.DarkSteel) { + if (!LoadedMods.EnderIO) { + continue; + } + } + int tVoltageMultiplier = (e.mBlastFurnaceTemp >= 2800) ? 64 : 16; + generatePipeRecipes(e.mDefaultLocalName, e.getMass(), tVoltageMultiplier); + } + + RecipeUtils.addShapedGregtechRecipe( + CI.component_Plate[6], + ALLOY.MARAGING250.getGear(1), + CI.component_Plate[6], + CI.getTieredCircuitOreDictName(4), + GregtechItemList.Casing_AdvancedVacuum.get(1), + CI.getTieredCircuitOreDictName(4), + CI.component_Plate[5], + ItemList.Hatch_Input_IV.get(1), + CI.component_Plate[5], + GregtechItemList.Hatch_Input_Cryotheum.get(1L, new Object[0])); + + RecipeUtils.addShapedGregtechRecipe( + CI.component_Plate[5], + ALLOY.MARAGING300.getGear(1), + CI.component_Plate[5], + CI.getTieredCircuitOreDictName(4), + GregtechItemList.Casing_Adv_BlastFurnace.get(1), + CI.getTieredCircuitOreDictName(4), + CI.component_Plate[6], + ItemList.Hatch_Input_IV.get(1), + CI.component_Plate[6], + GregtechItemList.Hatch_Input_Pyrotheum.get(1L, new Object[0])); + + RecipeUtils.addShapedGregtechRecipe( + CI.component_Plate[8], + ALLOY.PIKYONIUM.getGear(1), + CI.component_Plate[9], + CI.getTieredCircuitOreDictName(7), + GregtechItemList.Casing_Naq_Reactor_A.get(1), + CI.getTieredCircuitOreDictName(7), + CI.component_Plate[9], + ItemList.Hatch_Input_ZPM.get(1), + CI.component_Plate[8], + GregtechItemList.Hatch_Input_Naquadah.get(1L, new Object[0])); + + if (PollutionUtils.isPollutionEnabled()) { + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Hatch_Muffler_Adv_LV.get(1L, new Object[0]), bitsd, new Object[] { + "M", + "P", + Character.valueOf('M'), + ItemList.Hatch_Muffler_LV.get(1), + Character.valueOf('P'), + GregtechItemList.Pollution_Cleaner_LV.get(1) + }); + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Hatch_Muffler_Adv_MV.get(1L, new Object[0]), bitsd, new Object[] { + "M", + "P", + Character.valueOf('M'), + ItemList.Hatch_Muffler_MV.get(1), + Character.valueOf('P'), + GregtechItemList.Pollution_Cleaner_MV.get(1) + }); + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Hatch_Muffler_Adv_HV.get(1L, new Object[0]), bitsd, new Object[] { + "M", + "P", + Character.valueOf('M'), + ItemList.Hatch_Muffler_HV.get(1), + Character.valueOf('P'), + GregtechItemList.Pollution_Cleaner_HV.get(1) + }); + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Hatch_Muffler_Adv_EV.get(1L, new Object[0]), bitsd, new Object[] { + "M", + "P", + Character.valueOf('M'), + ItemList.Hatch_Muffler_EV.get(1), + Character.valueOf('P'), + GregtechItemList.Pollution_Cleaner_EV.get(1) + }); + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Hatch_Muffler_Adv_IV.get(1L, new Object[0]), bitsd, new Object[] { + "M", + "P", + Character.valueOf('M'), + ItemList.Hatch_Muffler_IV.get(1), + Character.valueOf('P'), + GregtechItemList.Pollution_Cleaner_IV.get(1) + }); + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Hatch_Muffler_Adv_LuV.get(1L, new Object[0]), bitsd, new Object[] { + "M", + "P", + Character.valueOf('M'), + ItemList.Hatch_Muffler_LuV.get(1), + Character.valueOf('P'), + GregtechItemList.Pollution_Cleaner_LuV.get(1) + }); + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Hatch_Muffler_Adv_ZPM.get(1L, new Object[0]), bitsd, new Object[] { + "M", + "P", + Character.valueOf('M'), + ItemList.Hatch_Muffler_ZPM.get(1), + Character.valueOf('P'), + GregtechItemList.Pollution_Cleaner_ZPM.get(1) + }); + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Hatch_Muffler_Adv_UV.get(1L, new Object[0]), bitsd, new Object[] { + "M", + "P", + Character.valueOf('M'), + ItemList.Hatch_Muffler_UV.get(1), + Character.valueOf('P'), + GregtechItemList.Pollution_Cleaner_UV.get(1) + }); + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Hatch_Muffler_Adv_MAX.get(1L, new Object[0]), bitsd, new Object[] { + "M", + "P", + Character.valueOf('M'), + ItemList.Hatch_Muffler_MAX.get(1), + Character.valueOf('P'), + GregtechItemList.Pollution_Cleaner_MAX.get(1) + }); + } + } } - - diff --git a/src/main/java/gtPlusPlus/core/recipe/RECIPES_LaserEngraver.java b/src/main/java/gtPlusPlus/core/recipe/RECIPES_LaserEngraver.java index 76182e61d9..aab90619cb 100644 --- a/src/main/java/gtPlusPlus/core/recipe/RECIPES_LaserEngraver.java +++ b/src/main/java/gtPlusPlus/core/recipe/RECIPES_LaserEngraver.java @@ -1,135 +1,188 @@ package gtPlusPlus.core.recipe; -import net.minecraft.item.ItemStack; - import gregtech.api.enums.*; import gregtech.api.interfaces.IOreRecipeRegistrator; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.everglades.dimension.Dimension_Everglades; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import net.minecraft.item.ItemStack; public class RECIPES_LaserEngraver implements IOreRecipeRegistrator { - public RECIPES_LaserEngraver() { - OrePrefixes.crafting.add(this); - } - - @Override - public void registerOre(final OrePrefixes aPrefix, final Materials aMaterial, final String aOreDictName, final String aModName, final ItemStack aStack) { - if (aOreDictName.equals(OreDictNames.craftingLensBlue.toString())) { - - if (CORE.ConfigSwitches.enableCustomCircuits && !CORE.GTNH){ - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("foilYttriumBariumCuprate", 1) != null){ - GT_Values.RA.addLaserEngraverRecipe(GT_OreDictUnificator.get(OrePrefixes.foil, Materials.YttriumBariumCuprate, 2L), GT_Utility.copyAmount(0L, new Object[]{aStack}), GregtechItemList.Circuit_Parts_Wiring_IV.get(1L, new Object[0]), 64, 480); - } - else { - Logger.INFO("foilYttriumBariumCuprate does not exist within Gregtech, please report this issue to Blood-asp on github."); - Logger.INFO("This material item can be re-enabled within the gregtech configuration files, If you wish to fix this yourself."); - } - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("foilVanadiumGallium", 1) != null){ - GT_Values.RA.addLaserEngraverRecipe(GT_OreDictUnificator.get(OrePrefixes.foil, Materials.VanadiumGallium, 2L), GT_Utility.copyAmount(0L, new Object[]{aStack}), GregtechItemList.Circuit_Parts_Wiring_IV.get(1L, new Object[0]), 64, 480); - } - else { - Logger.INFO("foilVanadiumGallium does not exist within Gregtech, please report this issue to Blood-asp on github."); - Logger.INFO("This material item can be re-enabled within the gregtech configuration files, If you wish to fix this yourself."); - } - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("foilNiobiumTitanium", 1) != null){ - GT_Values.RA.addLaserEngraverRecipe(GT_OreDictUnificator.get(OrePrefixes.foil, Materials.NiobiumTitanium, 2L), GT_Utility.copyAmount(0L, new Object[]{aStack}), GregtechItemList.Circuit_Parts_Wiring_IV.get(1L, new Object[0]), 64, 480); - } - else { - Logger.INFO("foilNiobiumTitanium does not exist within Gregtech, please report this issue to Blood-asp on github."); - Logger.INFO("This material item can be re-enabled within the gregtech configuration files, If you wish to fix this yourself."); - } - } - - - } else if (aOreDictName.equals(OreDictNames.craftingLensYellow.toString())) { - if (CORE.ConfigSwitches.enableCustomCircuits && !CORE.GTNH){ - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("foilOsmium", 1) != null){ - GT_Values.RA.addLaserEngraverRecipe(GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Osmium, 2L), GT_Utility.copyAmount(0L, new Object[]{aStack}), GregtechItemList.Circuit_Parts_Wiring_LuV.get(1L, new Object[0]), 64, 1024); - } - else { - Logger.INFO("foilOsmium does not exist within Gregtech, please report this issue to Blood-asp on github."); - Logger.INFO("This material item can be re-enabled within the gregtech configuration files, If you wish to fix this yourself."); - } - } - - } else if (aOreDictName.equals(OreDictNames.craftingLensCyan.toString())) { - } else if (aOreDictName.equals(OreDictNames.craftingLensRed.toString())) { - } else if (aOreDictName.equals(OreDictNames.craftingLensGreen.toString())) { - if (CORE.ConfigSwitches.enableCustomCircuits && !CORE.GTNH){ - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("foilNaquadah", 1) != null){ - GT_Values.RA.addLaserEngraverRecipe(GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Naquadah, 2L), GT_Utility.copyAmount(0L, new Object[]{aStack}), GregtechItemList.Circuit_Parts_Wiring_ZPM.get(1L, new Object[0]), 64, 2000); - } - else { - Logger.INFO("foilNaquadah does not exist within Gregtech, please report this issue to Blood-asp on github."); - Logger.INFO("This material item can be re-enabled within the gregtech configuration files, If you wish to fix this yourself."); - } - } - } else if (aOreDictName.equals(OreDictNames.craftingLensWhite.toString())) { - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateLithium", 1) != null){ - GT_Values.RA.addLaserEngraverRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Lithium, 2L), GT_Utility.copyAmount(0L, new Object[]{aStack}), ItemUtils.getItemStackOfAmountFromOreDict("plateDoubleLithium7", 1), 4*60*20, 2000); - } - else { - Logger.INFO("plateLithium does not exist within Gregtech, please report this issue to Blood-asp on github."); - Logger.INFO("This material item can be re-enabled within the gregtech configuration files, If you wish to fix this yourself."); - } - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustLithium", 1) != null){ - GT_Values.RA.addLaserEngraverRecipe(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Lithium, 3L), GT_Utility.copyAmount(0L, new Object[]{aStack}), ItemUtils.getItemStackOfAmountFromOreDict("dustLithium7", 1), 2*60*20, 2000); - } - else { - Logger.INFO("dustLithium does not exist within Gregtech, please report this issue to Blood-asp on github."); - Logger.INFO("This material item can be re-enabled within the gregtech configuration files, If you wish to fix this yourself."); - } - - } - - else if (aOreDictName.equals(OreDictNames.craftingLensLime.toString())) { - //Coil Wires - ItemStack coilWire1 = ItemUtils.getItemStackWithMeta(true, "miscutils:itemDehydratorCoilWire", "coilWire1", 0, 1); - ItemStack coilWire2 = ItemUtils.getItemStackWithMeta(true, "miscutils:itemDehydratorCoilWire:1", "coilWire2", 1, 1); - ItemStack coilWire3 = ItemUtils.getItemStackWithMeta(true, "miscutils:itemDehydratorCoilWire:2", "coilWire3", 2, 1); - ItemStack coilWire4 = ItemUtils.getItemStackWithMeta(true, "miscutils:itemDehydratorCoilWire:3", "coilWire4", 3, 1); - - //Simple Life - String wire = "wireGt02"; - - //Wires to Laser - ItemStack wireT1a = ItemUtils.getItemStackOfAmountFromOreDict(wire+"Aluminium", 1); - ItemStack wireT1b = ItemUtils.getItemStackOfAmountFromOreDict(wire+"Nichrome", 1); - ItemStack wireT2a = ItemUtils.getItemStackOfAmountFromOreDict(wire+"Osmium", 1); - ItemStack wireT2b = ItemUtils.getItemStackOfAmountFromOreDict(wire+"Platinum", 1); - ItemStack wireT3a = ItemUtils.getItemStackOfAmountFromOreDict(wire+"VanadiumGallium", 1); - ItemStack wireT3b = ItemUtils.getItemStackOfAmountFromOreDict(wire+"YttriumBariumCuprate", 1); - ItemStack wireT3c = ItemUtils.getItemStackOfAmountFromOreDict(wire+"NiobiumTitanium", 1); - ItemStack wireT4a = ItemUtils.getItemStackOfAmountFromOreDict(wire+"Naquadah", 1); - - //T1 - GT_Values.RA.addLaserEngraverRecipe(wireT1a, GT_Utility.copyAmount(0L, new Object[]{aStack}), coilWire1, 10*20, 500); - GT_Values.RA.addLaserEngraverRecipe(wireT1b, GT_Utility.copyAmount(0L, new Object[]{aStack}), coilWire1, 10*20, 500); - //T2 - GT_Values.RA.addLaserEngraverRecipe(wireT2a, GT_Utility.copyAmount(0L, new Object[]{aStack}), coilWire2, 20*20, 2000); - GT_Values.RA.addLaserEngraverRecipe(wireT2b, GT_Utility.copyAmount(0L, new Object[]{aStack}), coilWire2, 20*20, 2000); - //T3 - GT_Values.RA.addLaserEngraverRecipe(wireT3a, GT_Utility.copyAmount(0L, new Object[]{aStack}), coilWire3, 30*20, 8000); - GT_Values.RA.addLaserEngraverRecipe(wireT3b, GT_Utility.copyAmount(0L, new Object[]{aStack}), coilWire3, 30*20, 8000); - GT_Values.RA.addLaserEngraverRecipe(wireT3c, GT_Utility.copyAmount(0L, new Object[]{aStack}), coilWire3, 30*20, 8000); - //T4 - GT_Values.RA.addLaserEngraverRecipe(wireT4a, GT_Utility.copyAmount(0L, new Object[]{aStack}), coilWire4, 40*20, 32000); - - - } - - else if (aOreDictName.equals(OreDictNames.craftingLensOrange.toString())) { - GT_Values.RA.addLaserEngraverRecipe(ItemUtils.getSimpleStack(ModItems.itemAlkalusDisk), GT_Utility.copyAmount(0L, new Object[]{aStack}), ItemUtils.getSimpleStack(Dimension_Everglades.portalItem), 360*60*20, 4096); - } - - - - } + public RECIPES_LaserEngraver() { + OrePrefixes.crafting.add(this); + } + + @Override + public void registerOre( + final OrePrefixes aPrefix, + final Materials aMaterial, + final String aOreDictName, + final String aModName, + final ItemStack aStack) { + if (aOreDictName.equals(OreDictNames.craftingLensBlue.toString())) { + + if (CORE.ConfigSwitches.enableCustomCircuits && !CORE.GTNH) { + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("foilYttriumBariumCuprate", 1) != null) { + GT_Values.RA.addLaserEngraverRecipe( + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.YttriumBariumCuprate, 2L), + GT_Utility.copyAmount(0L, new Object[] {aStack}), + GregtechItemList.Circuit_Parts_Wiring_IV.get(1L, new Object[0]), + 64, + 480); + } else { + Logger.INFO( + "foilYttriumBariumCuprate does not exist within Gregtech, please report this issue to Blood-asp on github."); + Logger.INFO( + "This material item can be re-enabled within the gregtech configuration files, If you wish to fix this yourself."); + } + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("foilVanadiumGallium", 1) != null) { + GT_Values.RA.addLaserEngraverRecipe( + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.VanadiumGallium, 2L), + GT_Utility.copyAmount(0L, new Object[] {aStack}), + GregtechItemList.Circuit_Parts_Wiring_IV.get(1L, new Object[0]), + 64, + 480); + } else { + Logger.INFO( + "foilVanadiumGallium does not exist within Gregtech, please report this issue to Blood-asp on github."); + Logger.INFO( + "This material item can be re-enabled within the gregtech configuration files, If you wish to fix this yourself."); + } + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("foilNiobiumTitanium", 1) != null) { + GT_Values.RA.addLaserEngraverRecipe( + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.NiobiumTitanium, 2L), + GT_Utility.copyAmount(0L, new Object[] {aStack}), + GregtechItemList.Circuit_Parts_Wiring_IV.get(1L, new Object[0]), + 64, + 480); + } else { + Logger.INFO( + "foilNiobiumTitanium does not exist within Gregtech, please report this issue to Blood-asp on github."); + Logger.INFO( + "This material item can be re-enabled within the gregtech configuration files, If you wish to fix this yourself."); + } + } + + } else if (aOreDictName.equals(OreDictNames.craftingLensYellow.toString())) { + if (CORE.ConfigSwitches.enableCustomCircuits && !CORE.GTNH) { + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("foilOsmium", 1) != null) { + GT_Values.RA.addLaserEngraverRecipe( + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Osmium, 2L), + GT_Utility.copyAmount(0L, new Object[] {aStack}), + GregtechItemList.Circuit_Parts_Wiring_LuV.get(1L, new Object[0]), + 64, + 1024); + } else { + Logger.INFO( + "foilOsmium does not exist within Gregtech, please report this issue to Blood-asp on github."); + Logger.INFO( + "This material item can be re-enabled within the gregtech configuration files, If you wish to fix this yourself."); + } + } + + } else if (aOreDictName.equals(OreDictNames.craftingLensCyan.toString())) { + } else if (aOreDictName.equals(OreDictNames.craftingLensRed.toString())) { + } else if (aOreDictName.equals(OreDictNames.craftingLensGreen.toString())) { + if (CORE.ConfigSwitches.enableCustomCircuits && !CORE.GTNH) { + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("foilNaquadah", 1) != null) { + GT_Values.RA.addLaserEngraverRecipe( + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Naquadah, 2L), + GT_Utility.copyAmount(0L, new Object[] {aStack}), + GregtechItemList.Circuit_Parts_Wiring_ZPM.get(1L, new Object[0]), + 64, + 2000); + } else { + Logger.INFO( + "foilNaquadah does not exist within Gregtech, please report this issue to Blood-asp on github."); + Logger.INFO( + "This material item can be re-enabled within the gregtech configuration files, If you wish to fix this yourself."); + } + } + } else if (aOreDictName.equals(OreDictNames.craftingLensWhite.toString())) { + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateLithium", 1) != null) { + GT_Values.RA.addLaserEngraverRecipe( + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Lithium, 2L), + GT_Utility.copyAmount(0L, new Object[] {aStack}), + ItemUtils.getItemStackOfAmountFromOreDict("plateDoubleLithium7", 1), + 4 * 60 * 20, + 2000); + } else { + Logger.INFO( + "plateLithium does not exist within Gregtech, please report this issue to Blood-asp on github."); + Logger.INFO( + "This material item can be re-enabled within the gregtech configuration files, If you wish to fix this yourself."); + } + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustLithium", 1) != null) { + GT_Values.RA.addLaserEngraverRecipe( + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Lithium, 3L), + GT_Utility.copyAmount(0L, new Object[] {aStack}), + ItemUtils.getItemStackOfAmountFromOreDict("dustLithium7", 1), + 2 * 60 * 20, + 2000); + } else { + Logger.INFO( + "dustLithium does not exist within Gregtech, please report this issue to Blood-asp on github."); + Logger.INFO( + "This material item can be re-enabled within the gregtech configuration files, If you wish to fix this yourself."); + } + + } else if (aOreDictName.equals(OreDictNames.craftingLensLime.toString())) { + // Coil Wires + ItemStack coilWire1 = + ItemUtils.getItemStackWithMeta(true, "miscutils:itemDehydratorCoilWire", "coilWire1", 0, 1); + ItemStack coilWire2 = + ItemUtils.getItemStackWithMeta(true, "miscutils:itemDehydratorCoilWire:1", "coilWire2", 1, 1); + ItemStack coilWire3 = + ItemUtils.getItemStackWithMeta(true, "miscutils:itemDehydratorCoilWire:2", "coilWire3", 2, 1); + ItemStack coilWire4 = + ItemUtils.getItemStackWithMeta(true, "miscutils:itemDehydratorCoilWire:3", "coilWire4", 3, 1); + + // Simple Life + String wire = "wireGt02"; + + // Wires to Laser + ItemStack wireT1a = ItemUtils.getItemStackOfAmountFromOreDict(wire + "Aluminium", 1); + ItemStack wireT1b = ItemUtils.getItemStackOfAmountFromOreDict(wire + "Nichrome", 1); + ItemStack wireT2a = ItemUtils.getItemStackOfAmountFromOreDict(wire + "Osmium", 1); + ItemStack wireT2b = ItemUtils.getItemStackOfAmountFromOreDict(wire + "Platinum", 1); + ItemStack wireT3a = ItemUtils.getItemStackOfAmountFromOreDict(wire + "VanadiumGallium", 1); + ItemStack wireT3b = ItemUtils.getItemStackOfAmountFromOreDict(wire + "YttriumBariumCuprate", 1); + ItemStack wireT3c = ItemUtils.getItemStackOfAmountFromOreDict(wire + "NiobiumTitanium", 1); + ItemStack wireT4a = ItemUtils.getItemStackOfAmountFromOreDict(wire + "Naquadah", 1); + + // T1 + GT_Values.RA.addLaserEngraverRecipe( + wireT1a, GT_Utility.copyAmount(0L, new Object[] {aStack}), coilWire1, 10 * 20, 500); + GT_Values.RA.addLaserEngraverRecipe( + wireT1b, GT_Utility.copyAmount(0L, new Object[] {aStack}), coilWire1, 10 * 20, 500); + // T2 + GT_Values.RA.addLaserEngraverRecipe( + wireT2a, GT_Utility.copyAmount(0L, new Object[] {aStack}), coilWire2, 20 * 20, 2000); + GT_Values.RA.addLaserEngraverRecipe( + wireT2b, GT_Utility.copyAmount(0L, new Object[] {aStack}), coilWire2, 20 * 20, 2000); + // T3 + GT_Values.RA.addLaserEngraverRecipe( + wireT3a, GT_Utility.copyAmount(0L, new Object[] {aStack}), coilWire3, 30 * 20, 8000); + GT_Values.RA.addLaserEngraverRecipe( + wireT3b, GT_Utility.copyAmount(0L, new Object[] {aStack}), coilWire3, 30 * 20, 8000); + GT_Values.RA.addLaserEngraverRecipe( + wireT3c, GT_Utility.copyAmount(0L, new Object[] {aStack}), coilWire3, 30 * 20, 8000); + // T4 + GT_Values.RA.addLaserEngraverRecipe( + wireT4a, GT_Utility.copyAmount(0L, new Object[] {aStack}), coilWire4, 40 * 20, 32000); + + } else if (aOreDictName.equals(OreDictNames.craftingLensOrange.toString())) { + GT_Values.RA.addLaserEngraverRecipe( + ItemUtils.getSimpleStack(ModItems.itemAlkalusDisk), + GT_Utility.copyAmount(0L, new Object[] {aStack}), + ItemUtils.getSimpleStack(Dimension_Everglades.portalItem), + 360 * 60 * 20, + 4096); + } + } } diff --git a/src/main/java/gtPlusPlus/core/recipe/RECIPES_MTWRAPPER.java b/src/main/java/gtPlusPlus/core/recipe/RECIPES_MTWRAPPER.java index 0d377f74de..cac350b98e 100644 --- a/src/main/java/gtPlusPlus/core/recipe/RECIPES_MTWRAPPER.java +++ b/src/main/java/gtPlusPlus/core/recipe/RECIPES_MTWRAPPER.java @@ -2,26 +2,22 @@ package gtPlusPlus.core.recipe; public class RECIPES_MTWRAPPER { - public static int MT_RECIPES_LOADED = 0; - public static int MT_RECIPES_FAILED = 0; - - public static void run(){ - - } - - public static void addShaped(final Object item_Output, - final Object item_1, final Object item_2, final Object item_3, - final Object item_4, final Object item_5, final Object item_6, - final Object item_7, final Object item_8, final Object item_9){ - - - } - - public static void addShapeless(){ - - } - - - + public static int MT_RECIPES_LOADED = 0; + public static int MT_RECIPES_FAILED = 0; + + public static void run() {} + + public static void addShaped( + final Object item_Output, + final Object item_1, + final Object item_2, + final Object item_3, + final Object item_4, + final Object item_5, + final Object item_6, + final Object item_7, + final Object item_8, + final Object item_9) {} + + public static void addShapeless() {} } - diff --git a/src/main/java/gtPlusPlus/core/recipe/RECIPES_MachineComponents.java b/src/main/java/gtPlusPlus/core/recipe/RECIPES_MachineComponents.java index 71b4c4ef48..13abb8cfa5 100644 --- a/src/main/java/gtPlusPlus/core/recipe/RECIPES_MachineComponents.java +++ b/src/main/java/gtPlusPlus/core/recipe/RECIPES_MachineComponents.java @@ -2,7 +2,6 @@ package gtPlusPlus.core.recipe; import gregtech.api.enums.*; import gregtech.api.util.GT_OreDictUnificator; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; @@ -11,400 +10,747 @@ import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; public class RECIPES_MachineComponents { - //Wire - public static String wireTier0 = "wireGt01Lead"; - public static String wireTier1 = "wireGt01RedAlloy"; - public static String wireTier6 = "wireGt08NiobiumTitanium"; - public static String wireTier7 = "wireGt08Osmium"; - public static String wireTier8 = "wireGt08Naquadah"; - public static String wireTier9 = "wireGt08Superconductor"; - public static String wireTier10 = "wireGt16Superconductor"; - - //Cable - public static String cableTier0 = "cableGt01Lead"; - public static String cableTier1 = "cableGt01RedAlloy"; - public static String cableTier6 = "cableGt04Tungsten"; - public static String cableTier7 = "cableGt04NiobiumTitanium"; - public static String cableTier8 = "cableGt04Osmium"; - public static String cableTier9 = "cableGt04Naquadah"; - public static String cableTier10 = "wireGt08Superconductor"; - - //Plates - public static String plateTier0 = "plateWroughtIron"; - public static String plateTier7 = "plateChrome"; - public static String plateTier8 = "plateIridium"; - public static String plateTier9 = "plateOsmium"; - public static String plateTier10 = "plateNeutronium"; - - //rods - public static String rodTier0 = "stickWroughtIron"; - public static String rodTier1 = "stickPotin"; - public static String rodTier2 = "stickIronMagnetic"; - public static String rodTier7a = "stickChrome"; - public static String rodTier8a = "stickIridium"; - public static String rodTier9a = "stickOsmium"; - public static String rodTier10a = "stickNeutronium"; - public static String rodTier7b = "stickPlatinum"; - public static String rodTier8b = "stickChrome"; - public static String rodTier9b = "stickIridium"; - public static String rodTier10b = "stickOsmium"; - public static String rodTier7c = "stickTitanium"; - public static String rodTier8c = "stickTungstenSteel"; - public static String rodTier9c = "stickNaquadah"; - public static String rodTier10c = "stickOsmium"; - - //Screws - public static String screwTier0 = "screwPotin"; - public static String screwTier7 = "screwChrome"; - public static String screwTier8 = "screwIridium"; - public static String screwTier9 = "screwOsmium"; - public static String screwTier10 = "screwNeutronium"; - - //Rotors - public static String rotorTier0 = "rotorPotin"; - public static String rotorTier7 = "rotorChrome"; - public static String rotorTier8 = "rotorIridium"; - public static String rotorTier9 = "rotorOsmium"; - public static String rotorTier10 = "rotorNeutronium"; - - //Fluid Pipe - public static String pipeTier0 = "pipeSmallLead"; - public static String pipeTier7 = "pipeHugeSteel"; - public static String pipeTier8 = "pipeHugeStainlessSteel"; - public static String pipeTier9 = "pipeHugeTitanium"; - public static String pipeTier10 = "pipeHugeTungstenSteel"; - - //Rubber Ring/Plate - public static String itemRubberRing = "ringRubber"; - public static String plateRubber = "plateRubber"; - - //Circuits - public static String circuitTier0 = "circuitPrimitive"; - public static String circuitTier1 = "circuitBasic"; - public static String circuitTier6 = "circuitMaster"; - public static String circuitTier7 = "circuitUltimate"; - public static String circuitTier8 = "circuitSuperconductor"; - public static String circuitTier9 = "circuitInfinite"; - public static String circuitTier10 = "circuitQuantum"; - - //small gears - public static String smallGearTier0 = "gearGtSmallWroughtIron"; - public static String smallGearTier7 = "gearGtSmallChrome"; - public static String smallGearTier8 = "gearGtSmallIridium"; - public static String smallGearTier9 = "gearGtSmallOsmium"; - public static String smallGearTier10 = "gearGtSmallNeutronium"; - - public static final void loadRecipes(){ - Logger.INFO("Loading Recipes for the Various Circuits and Machine components."); - if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ - run(); - } - else { - onlyULVComponents(); - if (!CORE.GTNH) { - onlyMaxComponents(); - } - } - gregtechMachinePhase(); - } - - private static void run(){ - //Electric Motors - RecipeUtils.addShapedGregtechRecipe( - cableTier7, wireTier7, rodTier7a, - wireTier7, rodTier7b, wireTier7, - rodTier7a, wireTier7, cableTier7, - CI.electricMotor_LuV); - RecipeUtils.addShapedGregtechRecipe( - cableTier8, wireTier8, rodTier8a, - wireTier8, rodTier8b, wireTier8, - rodTier8a, wireTier8, cableTier8, - CI.electricMotor_ZPM); - RecipeUtils.addShapedGregtechRecipe( - cableTier9, wireTier9, rodTier9a, - wireTier9, rodTier9b, wireTier9, - rodTier9a, wireTier9, cableTier9, - CI.electricMotor_UV); - RecipeUtils.addShapedGregtechRecipe( - cableTier10, wireTier10, rodTier10a, - wireTier10, rodTier10b, wireTier10, - rodTier10a, wireTier10, cableTier10, - CI.electricMotor_MAX); - - //Electric Pump - RecipeUtils.addShapedGregtechRecipe( - cableTier7, rotorTier7, itemRubberRing, - CI.craftingToolScrewdriver, pipeTier7, CI.craftingToolWrench, - itemRubberRing, CI.electricMotor_LuV, cableTier7, - CI.electricPump_LuV); - RecipeUtils.addShapedGregtechRecipe( - cableTier8, rotorTier8, itemRubberRing, - CI.craftingToolScrewdriver, pipeTier8, CI.craftingToolWrench, - itemRubberRing, CI.electricMotor_ZPM, cableTier8, - CI.electricPump_ZPM); - RecipeUtils.addShapedGregtechRecipe( - cableTier9, rotorTier9, itemRubberRing, - CI.craftingToolScrewdriver, pipeTier9, CI.craftingToolWrench, - itemRubberRing, CI.electricMotor_UV, cableTier9, - CI.electricPump_UV); - RecipeUtils.addShapedGregtechRecipe( - cableTier10, rotorTier10, itemRubberRing, - CI.craftingToolScrewdriver, pipeTier10, CI.craftingToolWrench, - itemRubberRing, CI.electricMotor_MAX, cableTier10, - CI.electricPump_MAX); - - //Electric Pump - RecipeUtils.addShapedGregtechRecipe( - plateTier7, plateTier7, plateTier7, - cableTier7, rodTier7a, rodTier7a, - cableTier7, CI.electricMotor_LuV, smallGearTier7, - CI.electricPiston_LuV); - RecipeUtils.addShapedGregtechRecipe( - plateTier8, plateTier8, plateTier8, - cableTier8, rodTier8a, rodTier8a, - cableTier8, CI.electricMotor_ZPM, smallGearTier8, - CI.electricPiston_ZPM); - RecipeUtils.addShapedGregtechRecipe( - plateTier9, plateTier9, plateTier9, - cableTier9, rodTier9a, rodTier9a, - cableTier9, CI.electricMotor_UV, smallGearTier9, - CI.electricPiston_UV); - RecipeUtils.addShapedGregtechRecipe( - plateTier10, plateTier10, plateTier10, - cableTier10, rodTier10a, rodTier10a, - cableTier10, CI.electricMotor_MAX, smallGearTier10, - CI.electricPiston_MAX); - - //Robot Arms - RecipeUtils.addShapedGregtechRecipe( - cableTier7, cableTier7, cableTier7, - CI.electricMotor_LuV, rodTier7a, CI.electricMotor_LuV, - CI.electricPiston_LuV, circuitTier7, rodTier7a, - CI.robotArm_LuV); - RecipeUtils.addShapedGregtechRecipe( - cableTier8, cableTier8, cableTier8, - CI.electricMotor_ZPM, rodTier8a, CI.electricMotor_ZPM, - CI.electricPiston_ZPM, circuitTier8, rodTier8a, - CI.robotArm_ZPM); - RecipeUtils.addShapedGregtechRecipe( - cableTier9, cableTier9, cableTier9, - CI.electricMotor_UV, rodTier9a, CI.electricMotor_UV, - CI.electricPiston_UV, circuitTier9, rodTier9a, - CI.robotArm_UV); - RecipeUtils.addShapedGregtechRecipe( - cableTier10, cableTier10, cableTier10, - CI.electricMotor_MAX, rodTier10a, CI.electricMotor_MAX, - CI.electricPiston_MAX, circuitTier10, rodTier10a, - CI.robotArm_MAX); - - //Conveyor Modules - RecipeUtils.addShapedGregtechRecipe( - plateRubber, plateRubber, plateRubber, - CI.electricMotor_LuV, cableTier7, CI.electricMotor_LuV, - plateRubber, plateRubber, plateRubber, - CI.conveyorModule_LuV); - RecipeUtils.addShapedGregtechRecipe( - plateRubber, plateRubber, plateRubber, - CI.electricMotor_ZPM, cableTier8, CI.electricMotor_ZPM, - plateRubber, plateRubber, plateRubber, - CI.conveyorModule_ZPM); - RecipeUtils.addShapedGregtechRecipe( - plateRubber, plateRubber, plateRubber, - CI.electricMotor_UV, cableTier9, CI.electricMotor_UV, - plateRubber, plateRubber, plateRubber, - CI.conveyorModule_UV); - RecipeUtils.addShapedGregtechRecipe( - plateRubber, plateRubber, plateRubber, - CI.electricMotor_MAX, cableTier10, CI.electricMotor_MAX, - plateRubber, plateRubber, plateRubber, - CI.conveyorModule_MAX); - - //Emitter Modules - RecipeUtils.addShapedGregtechRecipe( - rodTier7c, rodTier7c, circuitTier7, - cableTier7, circuitTier6, rodTier7c, - circuitTier7, cableTier7, rodTier7c, - CI.emitter_LuV); - RecipeUtils.addShapedGregtechRecipe( - rodTier8c, rodTier8c, circuitTier8, - cableTier8, circuitTier7, rodTier8c, - circuitTier8, cableTier8, rodTier8c, - CI.emitter_ZPM); - RecipeUtils.addShapedGregtechRecipe( - rodTier9c, rodTier9c, circuitTier9, - cableTier9, circuitTier8, rodTier9c, - circuitTier9, cableTier9, rodTier9c, - CI.emitter_UV); - RecipeUtils.addShapedGregtechRecipe( - rodTier10c, rodTier10c, circuitTier10, - cableTier10, circuitTier9, rodTier10c, - circuitTier10, cableTier10, rodTier10c, - CI.emitter_MAX); - - //Field Generator Modules - RecipeUtils.addShapedGregtechRecipe( - wireTier7, circuitTier7, wireTier7, - circuitTier7, circuitTier6, circuitTier7, - wireTier7, circuitTier7, wireTier7, - CI.fieldGenerator_LuV); - RecipeUtils.addShapedGregtechRecipe( - wireTier8, circuitTier8, wireTier8, - circuitTier8, circuitTier7, circuitTier8, - wireTier8, circuitTier8, wireTier8, - CI.fieldGenerator_ZPM); - RecipeUtils.addShapedGregtechRecipe( - wireTier9, circuitTier9, wireTier9, - circuitTier9, circuitTier8, circuitTier9, - wireTier9, circuitTier9, wireTier9, - CI.fieldGenerator_UV); - RecipeUtils.addShapedGregtechRecipe( - wireTier10, circuitTier10, wireTier10, - circuitTier10, circuitTier9, circuitTier10, - wireTier10, circuitTier10, wireTier10, - CI.fieldGenerator_MAX); - - //Sensor Modules - RecipeUtils.addShapedRecipe( - plateTier7, null, circuitTier6, - plateTier7, rodTier7c, null, - circuitTier7, plateTier7, plateTier7, - CI.sensor_LuV); - RecipeUtils.addShapedRecipe( - plateTier8, null, circuitTier7, - plateTier8, rodTier8c, null, - circuitTier8, plateTier8, plateTier8, - CI.sensor_ZPM); - RecipeUtils.addShapedRecipe( - plateTier9, null, circuitTier8, - plateTier9, rodTier9c, null, - circuitTier9, plateTier9, plateTier9, - CI.sensor_UV); - RecipeUtils.addShapedRecipe( - plateTier10, null, circuitTier9, - plateTier10, rodTier10c, null, - circuitTier10, plateTier10, plateTier10, - CI.sensor_MAX); - - onlyULVComponents(); - - Logger.INFO("Done loading recipes for the Various machine components."); - - } - - private static void onlyULVComponents(){ - RecipeUtils.addShapedGregtechRecipe( - cableTier1, wireTier0, rodTier0, - wireTier0, rodTier2, wireTier0, - rodTier0, wireTier0, cableTier1, - CI.electricMotor_ULV); - - RecipeUtils.addShapedGregtechRecipe( - cableTier0, rotorTier0, itemRubberRing, - CI.craftingToolScrewdriver, pipeTier0, CI.craftingToolWrench, - itemRubberRing, CI.electricMotor_ULV, cableTier0, - CI.electricPump_ULV); - - RecipeUtils.addShapedGregtechRecipe( - plateTier0, plateTier0, plateTier0, - cableTier0, rodTier1, rodTier1, - cableTier0, CI.electricMotor_ULV, smallGearTier0, - CI.electricPiston_ULV); - - RecipeUtils.addShapedGregtechRecipe( - cableTier0, cableTier0, cableTier0, - CI.electricMotor_ULV, rodTier1, CI.electricMotor_ULV, - CI.electricPiston_ULV, circuitTier0, rodTier1, - CI.robotArm_ULV); - - RecipeUtils.addShapedGregtechRecipe( - plateRubber, plateRubber, plateRubber, - CI.electricMotor_ULV, cableTier0, CI.electricMotor_ULV, - plateRubber, plateRubber, plateRubber, - CI.conveyorModule_ULV); - - RecipeUtils.addShapedGregtechRecipe( - rodTier2, rodTier2, circuitTier0, - cableTier0, circuitTier1, rodTier2, - circuitTier0, cableTier0, rodTier2, - CI.emitter_ULV); - - RecipeUtils.addShapedGregtechRecipe( - wireTier0, circuitTier0, wireTier0, - circuitTier0, circuitTier1, circuitTier0, - wireTier0, circuitTier0, wireTier0, - CI.fieldGenerator_ULV); - - RecipeUtils.addShapedRecipe( - plateTier0, null, circuitTier1, - plateTier0, rodTier2, null, - circuitTier0, plateTier0, plateTier0, - CI.sensor_ULV); - } - - private static void onlyMaxComponents(){ - RecipeUtils.addShapedGregtechRecipe( - cableTier10, wireTier10, rodTier10a, - wireTier10, rodTier10b, wireTier10, - rodTier10a, wireTier10, cableTier10, - CI.electricMotor_MAX); - RecipeUtils.addShapedGregtechRecipe( - cableTier10, rotorTier10, itemRubberRing, - CI.craftingToolScrewdriver, pipeTier10, CI.craftingToolWrench, - itemRubberRing, CI.electricMotor_MAX, cableTier10, - CI.electricPump_MAX); - RecipeUtils.addShapedGregtechRecipe( - plateTier10, plateTier10, plateTier10, - cableTier10, rodTier10a, rodTier10a, - cableTier10, CI.electricMotor_MAX, smallGearTier10, - CI.electricPiston_MAX); - RecipeUtils.addShapedGregtechRecipe( - cableTier10, cableTier10, cableTier10, - CI.electricMotor_MAX, rodTier10a, CI.electricMotor_MAX, - CI.electricPiston_MAX, circuitTier10, rodTier10a, - CI.robotArm_MAX); - RecipeUtils.addShapedGregtechRecipe( - plateRubber, plateRubber, plateRubber, - CI.electricMotor_MAX, cableTier10, CI.electricMotor_MAX, - plateRubber, plateRubber, plateRubber, - CI.conveyorModule_MAX); - RecipeUtils.addShapedGregtechRecipe( - rodTier10c, rodTier10c, circuitTier10, - cableTier10, circuitTier9, rodTier10c, - circuitTier10, cableTier10, rodTier10c, - CI.emitter_MAX); - RecipeUtils.addShapedGregtechRecipe( - wireTier10, circuitTier10, wireTier10, - circuitTier10, circuitTier9, circuitTier10, - wireTier10, circuitTier10, wireTier10, - CI.fieldGenerator_MAX); - RecipeUtils.addShapedRecipe( - plateTier10, null, circuitTier9, - plateTier10, rodTier10c, null, - circuitTier10, plateTier10, plateTier10, - CI.sensor_MAX); - } - - private static void gregtechMachinePhase(){ - if (CORE.ConfigSwitches.enableCustomCircuits && !CORE.GTNH){ - Logger.INFO("Adding Gregtech machine recipes for the circuits."); - GT_Values.RA.addFormingPressRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Silicon, 1L), GregtechItemList.Circuit_Parts_Wiring_IV.get(4L, new Object[0]), GregtechItemList.Circuit_Board_IV.get(1L, new Object[0]), 30, 240); - GT_Values.RA.addFormingPressRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Silicon, 1L), GregtechItemList.Circuit_Parts_Wiring_LuV.get(4L, new Object[0]), GregtechItemList.Circuit_Board_LuV.get(1L, new Object[0]), 60, 480); - GT_Values.RA.addFormingPressRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Silicon, 2L), GregtechItemList.Circuit_Parts_Wiring_ZPM.get(4L, new Object[0]), GregtechItemList.Circuit_Board_ZPM.get(1L, new Object[0]), 90, 1000); - GT_Values.RA.addFormingPressRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Lazurite, 1L), GregtechItemList.Circuit_Parts_Crystal_Chip_IV.get(3L, new Object[0]), GregtechItemList.Circuit_Parts_IV.get(1L, new Object[0]), 30, 480); - GT_Values.RA.addFormingPressRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Lazurite, 1L), GregtechItemList.Circuit_Parts_Crystal_Chip_LuV.get(3L, new Object[0]), GregtechItemList.Circuit_Parts_LuV.get(1L, new Object[0]), 60, 1000); - GT_Values.RA.addFormingPressRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Lazurite, 1L), GregtechItemList.Circuit_Parts_Crystal_Chip_ZPM.get(3L, new Object[0]), GregtechItemList.Circuit_Parts_ZPM.get(1L, new Object[0]), 90, 2000); - GT_Values.RA.addForgeHammerRecipe(ItemList.Circuit_Master.get(1L, new Object[0]), GregtechItemList.Circuit_Parts_Crystal_Chip_IV.get(5L, new Object[0]), 30, 256); - GT_Values.RA.addForgeHammerRecipe(GregtechItemList.Circuit_IV.get(1L, new Object[0]), GregtechItemList.Circuit_Parts_Crystal_Chip_LuV.get(5L, new Object[0]), 60, 512); - GT_Values.RA.addForgeHammerRecipe(GregtechItemList.Circuit_LuV.get(1L, new Object[0]), GregtechItemList.Circuit_Parts_Crystal_Chip_ZPM.get(5L, new Object[0]), 120, 1024); - for (final Materials tMat : Materials.values()) { - if ((tMat.mStandardMoltenFluid != null) && (tMat.contains(SubTag.SOLDERING_MATERIAL))) { - final int tMultiplier = tMat.contains(SubTag.SOLDERING_MATERIAL_GOOD) ? 1 : tMat.contains(SubTag.SOLDERING_MATERIAL_BAD) ? 4 : 2; - GT_Values.RA.addAssemblerRecipe(GregtechItemList.Circuit_Board_IV.get(1L, new Object[0]), GregtechItemList.Circuit_Parts_IV.get(1L, new Object[0]), tMat.getMolten((144L * tMultiplier) / 4L), GregtechItemList.Circuit_IV.get(1L, new Object[0]), 30, 480); - GT_Values.RA.addAssemblerRecipe(GregtechItemList.Circuit_Board_LuV.get(1L, new Object[0]), GregtechItemList.Circuit_Parts_LuV.get(1L, new Object[0]), tMat.getMolten((144L * tMultiplier) / 4L), GregtechItemList.Circuit_LuV.get(1L, new Object[0]), 60, 1000); - GT_Values.RA.addAssemblerRecipe(GregtechItemList.Circuit_Board_ZPM.get(1L, new Object[0]), GregtechItemList.Circuit_Parts_ZPM.get(1L, new Object[0]), tMat.getMolten((144L * tMultiplier) / 4L), GregtechItemList.Circuit_ZPM.get(1L, new Object[0]), 90, 2000); - - } - } - } - } + // Wire + public static String wireTier0 = "wireGt01Lead"; + public static String wireTier1 = "wireGt01RedAlloy"; + public static String wireTier6 = "wireGt08NiobiumTitanium"; + public static String wireTier7 = "wireGt08Osmium"; + public static String wireTier8 = "wireGt08Naquadah"; + public static String wireTier9 = "wireGt08Superconductor"; + public static String wireTier10 = "wireGt16Superconductor"; + + // Cable + public static String cableTier0 = "cableGt01Lead"; + public static String cableTier1 = "cableGt01RedAlloy"; + public static String cableTier6 = "cableGt04Tungsten"; + public static String cableTier7 = "cableGt04NiobiumTitanium"; + public static String cableTier8 = "cableGt04Osmium"; + public static String cableTier9 = "cableGt04Naquadah"; + public static String cableTier10 = "wireGt08Superconductor"; + + // Plates + public static String plateTier0 = "plateWroughtIron"; + public static String plateTier7 = "plateChrome"; + public static String plateTier8 = "plateIridium"; + public static String plateTier9 = "plateOsmium"; + public static String plateTier10 = "plateNeutronium"; + + // rods + public static String rodTier0 = "stickWroughtIron"; + public static String rodTier1 = "stickPotin"; + public static String rodTier2 = "stickIronMagnetic"; + public static String rodTier7a = "stickChrome"; + public static String rodTier8a = "stickIridium"; + public static String rodTier9a = "stickOsmium"; + public static String rodTier10a = "stickNeutronium"; + public static String rodTier7b = "stickPlatinum"; + public static String rodTier8b = "stickChrome"; + public static String rodTier9b = "stickIridium"; + public static String rodTier10b = "stickOsmium"; + public static String rodTier7c = "stickTitanium"; + public static String rodTier8c = "stickTungstenSteel"; + public static String rodTier9c = "stickNaquadah"; + public static String rodTier10c = "stickOsmium"; + + // Screws + public static String screwTier0 = "screwPotin"; + public static String screwTier7 = "screwChrome"; + public static String screwTier8 = "screwIridium"; + public static String screwTier9 = "screwOsmium"; + public static String screwTier10 = "screwNeutronium"; + + // Rotors + public static String rotorTier0 = "rotorPotin"; + public static String rotorTier7 = "rotorChrome"; + public static String rotorTier8 = "rotorIridium"; + public static String rotorTier9 = "rotorOsmium"; + public static String rotorTier10 = "rotorNeutronium"; + + // Fluid Pipe + public static String pipeTier0 = "pipeSmallLead"; + public static String pipeTier7 = "pipeHugeSteel"; + public static String pipeTier8 = "pipeHugeStainlessSteel"; + public static String pipeTier9 = "pipeHugeTitanium"; + public static String pipeTier10 = "pipeHugeTungstenSteel"; + + // Rubber Ring/Plate + public static String itemRubberRing = "ringRubber"; + public static String plateRubber = "plateRubber"; + + // Circuits + public static String circuitTier0 = "circuitPrimitive"; + public static String circuitTier1 = "circuitBasic"; + public static String circuitTier6 = "circuitMaster"; + public static String circuitTier7 = "circuitUltimate"; + public static String circuitTier8 = "circuitSuperconductor"; + public static String circuitTier9 = "circuitInfinite"; + public static String circuitTier10 = "circuitQuantum"; + + // small gears + public static String smallGearTier0 = "gearGtSmallWroughtIron"; + public static String smallGearTier7 = "gearGtSmallChrome"; + public static String smallGearTier8 = "gearGtSmallIridium"; + public static String smallGearTier9 = "gearGtSmallOsmium"; + public static String smallGearTier10 = "gearGtSmallNeutronium"; + + public static final void loadRecipes() { + Logger.INFO("Loading Recipes for the Various Circuits and Machine components."); + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + run(); + } else { + onlyULVComponents(); + if (!CORE.GTNH) { + onlyMaxComponents(); + } + } + gregtechMachinePhase(); + } + + private static void run() { + // Electric Motors + RecipeUtils.addShapedGregtechRecipe( + cableTier7, + wireTier7, + rodTier7a, + wireTier7, + rodTier7b, + wireTier7, + rodTier7a, + wireTier7, + cableTier7, + CI.electricMotor_LuV); + RecipeUtils.addShapedGregtechRecipe( + cableTier8, + wireTier8, + rodTier8a, + wireTier8, + rodTier8b, + wireTier8, + rodTier8a, + wireTier8, + cableTier8, + CI.electricMotor_ZPM); + RecipeUtils.addShapedGregtechRecipe( + cableTier9, + wireTier9, + rodTier9a, + wireTier9, + rodTier9b, + wireTier9, + rodTier9a, + wireTier9, + cableTier9, + CI.electricMotor_UV); + RecipeUtils.addShapedGregtechRecipe( + cableTier10, + wireTier10, + rodTier10a, + wireTier10, + rodTier10b, + wireTier10, + rodTier10a, + wireTier10, + cableTier10, + CI.electricMotor_MAX); + + // Electric Pump + RecipeUtils.addShapedGregtechRecipe( + cableTier7, + rotorTier7, + itemRubberRing, + CI.craftingToolScrewdriver, + pipeTier7, + CI.craftingToolWrench, + itemRubberRing, + CI.electricMotor_LuV, + cableTier7, + CI.electricPump_LuV); + RecipeUtils.addShapedGregtechRecipe( + cableTier8, + rotorTier8, + itemRubberRing, + CI.craftingToolScrewdriver, + pipeTier8, + CI.craftingToolWrench, + itemRubberRing, + CI.electricMotor_ZPM, + cableTier8, + CI.electricPump_ZPM); + RecipeUtils.addShapedGregtechRecipe( + cableTier9, + rotorTier9, + itemRubberRing, + CI.craftingToolScrewdriver, + pipeTier9, + CI.craftingToolWrench, + itemRubberRing, + CI.electricMotor_UV, + cableTier9, + CI.electricPump_UV); + RecipeUtils.addShapedGregtechRecipe( + cableTier10, + rotorTier10, + itemRubberRing, + CI.craftingToolScrewdriver, + pipeTier10, + CI.craftingToolWrench, + itemRubberRing, + CI.electricMotor_MAX, + cableTier10, + CI.electricPump_MAX); + + // Electric Pump + RecipeUtils.addShapedGregtechRecipe( + plateTier7, + plateTier7, + plateTier7, + cableTier7, + rodTier7a, + rodTier7a, + cableTier7, + CI.electricMotor_LuV, + smallGearTier7, + CI.electricPiston_LuV); + RecipeUtils.addShapedGregtechRecipe( + plateTier8, + plateTier8, + plateTier8, + cableTier8, + rodTier8a, + rodTier8a, + cableTier8, + CI.electricMotor_ZPM, + smallGearTier8, + CI.electricPiston_ZPM); + RecipeUtils.addShapedGregtechRecipe( + plateTier9, + plateTier9, + plateTier9, + cableTier9, + rodTier9a, + rodTier9a, + cableTier9, + CI.electricMotor_UV, + smallGearTier9, + CI.electricPiston_UV); + RecipeUtils.addShapedGregtechRecipe( + plateTier10, + plateTier10, + plateTier10, + cableTier10, + rodTier10a, + rodTier10a, + cableTier10, + CI.electricMotor_MAX, + smallGearTier10, + CI.electricPiston_MAX); + + // Robot Arms + RecipeUtils.addShapedGregtechRecipe( + cableTier7, + cableTier7, + cableTier7, + CI.electricMotor_LuV, + rodTier7a, + CI.electricMotor_LuV, + CI.electricPiston_LuV, + circuitTier7, + rodTier7a, + CI.robotArm_LuV); + RecipeUtils.addShapedGregtechRecipe( + cableTier8, + cableTier8, + cableTier8, + CI.electricMotor_ZPM, + rodTier8a, + CI.electricMotor_ZPM, + CI.electricPiston_ZPM, + circuitTier8, + rodTier8a, + CI.robotArm_ZPM); + RecipeUtils.addShapedGregtechRecipe( + cableTier9, + cableTier9, + cableTier9, + CI.electricMotor_UV, + rodTier9a, + CI.electricMotor_UV, + CI.electricPiston_UV, + circuitTier9, + rodTier9a, + CI.robotArm_UV); + RecipeUtils.addShapedGregtechRecipe( + cableTier10, + cableTier10, + cableTier10, + CI.electricMotor_MAX, + rodTier10a, + CI.electricMotor_MAX, + CI.electricPiston_MAX, + circuitTier10, + rodTier10a, + CI.robotArm_MAX); + + // Conveyor Modules + RecipeUtils.addShapedGregtechRecipe( + plateRubber, + plateRubber, + plateRubber, + CI.electricMotor_LuV, + cableTier7, + CI.electricMotor_LuV, + plateRubber, + plateRubber, + plateRubber, + CI.conveyorModule_LuV); + RecipeUtils.addShapedGregtechRecipe( + plateRubber, + plateRubber, + plateRubber, + CI.electricMotor_ZPM, + cableTier8, + CI.electricMotor_ZPM, + plateRubber, + plateRubber, + plateRubber, + CI.conveyorModule_ZPM); + RecipeUtils.addShapedGregtechRecipe( + plateRubber, + plateRubber, + plateRubber, + CI.electricMotor_UV, + cableTier9, + CI.electricMotor_UV, + plateRubber, + plateRubber, + plateRubber, + CI.conveyorModule_UV); + RecipeUtils.addShapedGregtechRecipe( + plateRubber, + plateRubber, + plateRubber, + CI.electricMotor_MAX, + cableTier10, + CI.electricMotor_MAX, + plateRubber, + plateRubber, + plateRubber, + CI.conveyorModule_MAX); + + // Emitter Modules + RecipeUtils.addShapedGregtechRecipe( + rodTier7c, + rodTier7c, + circuitTier7, + cableTier7, + circuitTier6, + rodTier7c, + circuitTier7, + cableTier7, + rodTier7c, + CI.emitter_LuV); + RecipeUtils.addShapedGregtechRecipe( + rodTier8c, + rodTier8c, + circuitTier8, + cableTier8, + circuitTier7, + rodTier8c, + circuitTier8, + cableTier8, + rodTier8c, + CI.emitter_ZPM); + RecipeUtils.addShapedGregtechRecipe( + rodTier9c, + rodTier9c, + circuitTier9, + cableTier9, + circuitTier8, + rodTier9c, + circuitTier9, + cableTier9, + rodTier9c, + CI.emitter_UV); + RecipeUtils.addShapedGregtechRecipe( + rodTier10c, + rodTier10c, + circuitTier10, + cableTier10, + circuitTier9, + rodTier10c, + circuitTier10, + cableTier10, + rodTier10c, + CI.emitter_MAX); + + // Field Generator Modules + RecipeUtils.addShapedGregtechRecipe( + wireTier7, + circuitTier7, + wireTier7, + circuitTier7, + circuitTier6, + circuitTier7, + wireTier7, + circuitTier7, + wireTier7, + CI.fieldGenerator_LuV); + RecipeUtils.addShapedGregtechRecipe( + wireTier8, + circuitTier8, + wireTier8, + circuitTier8, + circuitTier7, + circuitTier8, + wireTier8, + circuitTier8, + wireTier8, + CI.fieldGenerator_ZPM); + RecipeUtils.addShapedGregtechRecipe( + wireTier9, + circuitTier9, + wireTier9, + circuitTier9, + circuitTier8, + circuitTier9, + wireTier9, + circuitTier9, + wireTier9, + CI.fieldGenerator_UV); + RecipeUtils.addShapedGregtechRecipe( + wireTier10, + circuitTier10, + wireTier10, + circuitTier10, + circuitTier9, + circuitTier10, + wireTier10, + circuitTier10, + wireTier10, + CI.fieldGenerator_MAX); + + // Sensor Modules + RecipeUtils.addShapedRecipe( + plateTier7, + null, + circuitTier6, + plateTier7, + rodTier7c, + null, + circuitTier7, + plateTier7, + plateTier7, + CI.sensor_LuV); + RecipeUtils.addShapedRecipe( + plateTier8, + null, + circuitTier7, + plateTier8, + rodTier8c, + null, + circuitTier8, + plateTier8, + plateTier8, + CI.sensor_ZPM); + RecipeUtils.addShapedRecipe( + plateTier9, + null, + circuitTier8, + plateTier9, + rodTier9c, + null, + circuitTier9, + plateTier9, + plateTier9, + CI.sensor_UV); + RecipeUtils.addShapedRecipe( + plateTier10, + null, + circuitTier9, + plateTier10, + rodTier10c, + null, + circuitTier10, + plateTier10, + plateTier10, + CI.sensor_MAX); + + onlyULVComponents(); + + Logger.INFO("Done loading recipes for the Various machine components."); + } + + private static void onlyULVComponents() { + RecipeUtils.addShapedGregtechRecipe( + cableTier1, + wireTier0, + rodTier0, + wireTier0, + rodTier2, + wireTier0, + rodTier0, + wireTier0, + cableTier1, + CI.electricMotor_ULV); + + RecipeUtils.addShapedGregtechRecipe( + cableTier0, + rotorTier0, + itemRubberRing, + CI.craftingToolScrewdriver, + pipeTier0, + CI.craftingToolWrench, + itemRubberRing, + CI.electricMotor_ULV, + cableTier0, + CI.electricPump_ULV); + + RecipeUtils.addShapedGregtechRecipe( + plateTier0, + plateTier0, + plateTier0, + cableTier0, + rodTier1, + rodTier1, + cableTier0, + CI.electricMotor_ULV, + smallGearTier0, + CI.electricPiston_ULV); + + RecipeUtils.addShapedGregtechRecipe( + cableTier0, + cableTier0, + cableTier0, + CI.electricMotor_ULV, + rodTier1, + CI.electricMotor_ULV, + CI.electricPiston_ULV, + circuitTier0, + rodTier1, + CI.robotArm_ULV); + + RecipeUtils.addShapedGregtechRecipe( + plateRubber, + plateRubber, + plateRubber, + CI.electricMotor_ULV, + cableTier0, + CI.electricMotor_ULV, + plateRubber, + plateRubber, + plateRubber, + CI.conveyorModule_ULV); + + RecipeUtils.addShapedGregtechRecipe( + rodTier2, + rodTier2, + circuitTier0, + cableTier0, + circuitTier1, + rodTier2, + circuitTier0, + cableTier0, + rodTier2, + CI.emitter_ULV); + + RecipeUtils.addShapedGregtechRecipe( + wireTier0, + circuitTier0, + wireTier0, + circuitTier0, + circuitTier1, + circuitTier0, + wireTier0, + circuitTier0, + wireTier0, + CI.fieldGenerator_ULV); + + RecipeUtils.addShapedRecipe( + plateTier0, + null, + circuitTier1, + plateTier0, + rodTier2, + null, + circuitTier0, + plateTier0, + plateTier0, + CI.sensor_ULV); + } + + private static void onlyMaxComponents() { + RecipeUtils.addShapedGregtechRecipe( + cableTier10, + wireTier10, + rodTier10a, + wireTier10, + rodTier10b, + wireTier10, + rodTier10a, + wireTier10, + cableTier10, + CI.electricMotor_MAX); + RecipeUtils.addShapedGregtechRecipe( + cableTier10, + rotorTier10, + itemRubberRing, + CI.craftingToolScrewdriver, + pipeTier10, + CI.craftingToolWrench, + itemRubberRing, + CI.electricMotor_MAX, + cableTier10, + CI.electricPump_MAX); + RecipeUtils.addShapedGregtechRecipe( + plateTier10, + plateTier10, + plateTier10, + cableTier10, + rodTier10a, + rodTier10a, + cableTier10, + CI.electricMotor_MAX, + smallGearTier10, + CI.electricPiston_MAX); + RecipeUtils.addShapedGregtechRecipe( + cableTier10, + cableTier10, + cableTier10, + CI.electricMotor_MAX, + rodTier10a, + CI.electricMotor_MAX, + CI.electricPiston_MAX, + circuitTier10, + rodTier10a, + CI.robotArm_MAX); + RecipeUtils.addShapedGregtechRecipe( + plateRubber, + plateRubber, + plateRubber, + CI.electricMotor_MAX, + cableTier10, + CI.electricMotor_MAX, + plateRubber, + plateRubber, + plateRubber, + CI.conveyorModule_MAX); + RecipeUtils.addShapedGregtechRecipe( + rodTier10c, + rodTier10c, + circuitTier10, + cableTier10, + circuitTier9, + rodTier10c, + circuitTier10, + cableTier10, + rodTier10c, + CI.emitter_MAX); + RecipeUtils.addShapedGregtechRecipe( + wireTier10, + circuitTier10, + wireTier10, + circuitTier10, + circuitTier9, + circuitTier10, + wireTier10, + circuitTier10, + wireTier10, + CI.fieldGenerator_MAX); + RecipeUtils.addShapedRecipe( + plateTier10, + null, + circuitTier9, + plateTier10, + rodTier10c, + null, + circuitTier10, + plateTier10, + plateTier10, + CI.sensor_MAX); + } + + private static void gregtechMachinePhase() { + if (CORE.ConfigSwitches.enableCustomCircuits && !CORE.GTNH) { + Logger.INFO("Adding Gregtech machine recipes for the circuits."); + GT_Values.RA.addFormingPressRecipe( + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Silicon, 1L), + GregtechItemList.Circuit_Parts_Wiring_IV.get(4L, new Object[0]), + GregtechItemList.Circuit_Board_IV.get(1L, new Object[0]), + 30, + 240); + GT_Values.RA.addFormingPressRecipe( + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Silicon, 1L), + GregtechItemList.Circuit_Parts_Wiring_LuV.get(4L, new Object[0]), + GregtechItemList.Circuit_Board_LuV.get(1L, new Object[0]), + 60, + 480); + GT_Values.RA.addFormingPressRecipe( + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Silicon, 2L), + GregtechItemList.Circuit_Parts_Wiring_ZPM.get(4L, new Object[0]), + GregtechItemList.Circuit_Board_ZPM.get(1L, new Object[0]), + 90, + 1000); + GT_Values.RA.addFormingPressRecipe( + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Lazurite, 1L), + GregtechItemList.Circuit_Parts_Crystal_Chip_IV.get(3L, new Object[0]), + GregtechItemList.Circuit_Parts_IV.get(1L, new Object[0]), + 30, + 480); + GT_Values.RA.addFormingPressRecipe( + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Lazurite, 1L), + GregtechItemList.Circuit_Parts_Crystal_Chip_LuV.get(3L, new Object[0]), + GregtechItemList.Circuit_Parts_LuV.get(1L, new Object[0]), + 60, + 1000); + GT_Values.RA.addFormingPressRecipe( + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Lazurite, 1L), + GregtechItemList.Circuit_Parts_Crystal_Chip_ZPM.get(3L, new Object[0]), + GregtechItemList.Circuit_Parts_ZPM.get(1L, new Object[0]), + 90, + 2000); + GT_Values.RA.addForgeHammerRecipe( + ItemList.Circuit_Master.get(1L, new Object[0]), + GregtechItemList.Circuit_Parts_Crystal_Chip_IV.get(5L, new Object[0]), + 30, + 256); + GT_Values.RA.addForgeHammerRecipe( + GregtechItemList.Circuit_IV.get(1L, new Object[0]), + GregtechItemList.Circuit_Parts_Crystal_Chip_LuV.get(5L, new Object[0]), + 60, + 512); + GT_Values.RA.addForgeHammerRecipe( + GregtechItemList.Circuit_LuV.get(1L, new Object[0]), + GregtechItemList.Circuit_Parts_Crystal_Chip_ZPM.get(5L, new Object[0]), + 120, + 1024); + for (final Materials tMat : Materials.values()) { + if ((tMat.mStandardMoltenFluid != null) && (tMat.contains(SubTag.SOLDERING_MATERIAL))) { + final int tMultiplier = tMat.contains(SubTag.SOLDERING_MATERIAL_GOOD) + ? 1 + : tMat.contains(SubTag.SOLDERING_MATERIAL_BAD) ? 4 : 2; + GT_Values.RA.addAssemblerRecipe( + GregtechItemList.Circuit_Board_IV.get(1L, new Object[0]), + GregtechItemList.Circuit_Parts_IV.get(1L, new Object[0]), + tMat.getMolten((144L * tMultiplier) / 4L), + GregtechItemList.Circuit_IV.get(1L, new Object[0]), + 30, + 480); + GT_Values.RA.addAssemblerRecipe( + GregtechItemList.Circuit_Board_LuV.get(1L, new Object[0]), + GregtechItemList.Circuit_Parts_LuV.get(1L, new Object[0]), + tMat.getMolten((144L * tMultiplier) / 4L), + GregtechItemList.Circuit_LuV.get(1L, new Object[0]), + 60, + 1000); + GT_Values.RA.addAssemblerRecipe( + GregtechItemList.Circuit_Board_ZPM.get(1L, new Object[0]), + GregtechItemList.Circuit_Parts_ZPM.get(1L, new Object[0]), + tMat.getMolten((144L * tMultiplier) / 4L), + GregtechItemList.Circuit_ZPM.get(1L, new Object[0]), + 90, + 2000); + } + } + } + } } diff --git a/src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java index 64dda6c684..9a1c1ed029 100644 --- a/src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -39,3593 +39,4296 @@ import net.minecraftforge.fluids.FluidStack; public class RECIPES_Machines { - //Outputs - //static ItemStack RECIPE_BufferCore_ULV = new ItemStack(GregtechEnergyBuffer.itemBufferCore); - public static ItemStack RECIPE_SteamCondenser; - public static ItemStack RECIPE_IronBlastFurnace; - public static ItemStack RECIPE_IronPlatedBricks; - public static ItemStack RECIPE_Buffer_ULV = GregtechItemList.Energy_Buffer_1by1_ULV.get(1); - public static ItemStack RECIPE_Buffer_LV = GregtechItemList.Energy_Buffer_1by1_LV.get(1); - public static ItemStack RECIPE_Buffer_MV = GregtechItemList.Energy_Buffer_1by1_MV.get(1); - public static ItemStack RECIPE_Buffer_HV = GregtechItemList.Energy_Buffer_1by1_HV.get(1); - public static ItemStack RECIPE_Buffer_EV = GregtechItemList.Energy_Buffer_1by1_EV.get(1); - public static ItemStack RECIPE_Buffer_IV = GregtechItemList.Energy_Buffer_1by1_IV.get(1); - public static ItemStack RECIPE_Buffer_LuV = GregtechItemList.Energy_Buffer_1by1_LuV.get(1); - public static ItemStack RECIPE_Buffer_ZPM = GregtechItemList.Energy_Buffer_1by1_ZPM.get(1); - public static ItemStack RECIPE_Buffer_UV = GregtechItemList.Energy_Buffer_1by1_UV.get(1); - public static ItemStack RECIPE_Buffer_MAX = GregtechItemList.Energy_Buffer_1by1_MAX.get(1); - //Industrial Centrifuge - public static ItemStack RECIPE_IndustrialCentrifugeController; - public static ItemStack RECIPE_IndustrialCentrifugeCasing; - //Industrial Coke Oven - public static ItemStack RECIPE_IndustrialCokeOvenController; - public static ItemStack RECIPE_IndustrialCokeOvenFrame; - public static ItemStack RECIPE_IndustrialCokeOvenCasingA; - public static ItemStack RECIPE_IndustrialCokeOvenCasingB; - //Industrial Electrolyzer - public static ItemStack RECIPE_IndustrialElectrolyzerController; - public static ItemStack RECIPE_IndustrialElectrolyzerFrame; - //Industrial Material Press - public static ItemStack RECIPE_IndustrialMaterialPressController; - public static ItemStack RECIPE_IndustrialMaterialPressFrame; - //Industrial Maceration Stack - public static ItemStack RECIPE_IndustrialMacerationStackController; - public static ItemStack RECIPE_IndustrialMacerationStackFrame; - //Industrial Wire Factory - public static ItemStack RECIPE_IndustrialWireFactoryController; - public static ItemStack RECIPE_IndustrialWireFactoryFrame; - //Industrial Multi Tank - public static ItemStack RECIPE_IndustrialMultiTankController; - public static ItemStack RECIPE_IndustrialMultiTankFrame; - //Industrial Matter Fabricator - public static ItemStack RECIPE_IndustrialMatterFabController; - public static ItemStack RECIPE_IndustrialMatterFabFrame; - public static ItemStack RECIPE_IndustrialMatterFabCoil; - //Industrial Blast Smelter - public static ItemStack RECIPE_IndustrialBlastSmelterController; - public static ItemStack RECIPE_IndustrialBlastSmelterFrame; - public static ItemStack RECIPE_IndustrialBlastSmelterCoil; - //Industrial Sieve - public static ItemStack RECIPE_IndustrialSieveController; - public static ItemStack RECIPE_IndustrialSieveFrame; - public static ItemStack RECIPE_IndustrialSieveGrate; - //Industrial Tree Farmer - public static ItemStack RECIPE_TreeFarmController; - public static ItemStack RECIPE_TreeFarmFrame; - //Tesseracts - public static ItemStack RECIPE_TesseractGenerator; - public static ItemStack RECIPE_TesseractTerminal; - //Thermal Boiler - public static ItemStack RECIPE_ThermalBoilerController; - public static ItemStack RECIPE_ThermalBoilerCasing; - - //Thorium Reactor - public static ItemStack RECIPE_LFTRController; - public static ItemStack RECIPE_LFTROuterCasing; - public static ItemStack RECIPE_LFTRInnerCasing; - - //Milling - public static ItemStack RECIPE_ISAMill_Controller; - public static ItemStack RECIPE_ISAMill_Gearbox; - public static ItemStack RECIPE_ISAMill_Casing; - public static ItemStack RECIPE_ISAMill_Hatch; - public static ItemStack RECIPE_Flotation_Controller; - public static ItemStack RECIPE_Flotation_Casing; - - //Cyclotron - public static ItemStack RECIPE_CyclotronController; - public static ItemStack RECIPE_CyclotronOuterCasing; - public static ItemStack RECIPE_CyclotronInnerCoil; - - - //Buffer Cores - public static ItemStack RECIPE_BufferCore_ULV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore1", 1); - public static ItemStack RECIPE_BufferCore_LV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore2", 1); - public static ItemStack RECIPE_BufferCore_MV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore3", 1); - public static ItemStack RECIPE_BufferCore_HV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore4", 1); - public static ItemStack RECIPE_BufferCore_EV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore5", 1); - public static ItemStack RECIPE_BufferCore_IV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore6", 1); - public static ItemStack RECIPE_BufferCore_LuV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore7", 1); - public static ItemStack RECIPE_BufferCore_ZPM = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore8", 1); - public static ItemStack RECIPE_BufferCore_UV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore9", 1); - public static ItemStack RECIPE_BufferCore_MAX = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore10", 1); - - - //Wire - public static String wireTier1 = "wireGt08Lead"; - public static String wireTier2 = "wireGt08Tin"; - public static String wireTier3 = "wireGt08Copper"; - public static String wireTier4 = "wireGt08Gold"; - public static String wireTier5 = "wireGt08Aluminium"; - public static String wireTier6 = "wireGt08Tungsten"; - public static String wireTier7 = "wireGt08Naquadah"; - public static String wireTier8 = "wireGt08Osmium"; - public static String wireTier9 = "wireGt08Superconductor"; - public static String wireTier10 = "wireGt16Superconductor"; - - //Wire - public static String cableTier1 = "cableGt04Lead"; - public static String cableTier2 = "cableGt04Tin"; - public static String cableTier3 = "cableGt04Copper"; - public static String cableTier4 = "cableGt04Gold"; - public static String cableTier5 = "cableGt04Aluminium"; - public static String cableTier6 = "cableGt04Tungsten"; - public static String cableTier7 = "cableGt04Naquadah"; - public static String cableTier8 = "cableGt04Osmium"; - public static String cableTier9 = "cableGt04NiobiumTitanium"; - public static String cableTier10 = "cableGt08NiobiumTitanium"; - - public static String pipeTier1 = "pipeHuge"+"Clay"; - public static String pipeTier2 = "pipeHuge"+"Potin"; - public static String pipeTier3 = "pipeHuge"+"Steel"; - public static String pipeTier4 = "pipeHuge"+"StainlessSteel"; - public static String pipeTier5 = "pipeHuge"+"TungstenSteel"; - public static String pipeTier6 = "pipeHuge"+"MaragingSteel300"; - public static String pipeTier7 = "pipeHuge"+"Tantalloy60"; - public static String pipeTier8 = "pipeHuge"+"Tantalloy61"; - public static String pipeTier9 = "pipeHuge"+"Inconel792"; - public static String pipeTier10 = "pipeHuge"+"HastelloyX"; - public static String pipeTier11 = "pipeHuge"+"Europium"; - - // EV/IV MACHINES - public static ItemStack EV_MACHINE_Electrolyzer; - public static ItemStack EV_MACHINE_Centrifuge; - public static ItemStack EV_MACHINE_BendingMachine; - public static ItemStack EV_MACHINE_Wiremill; - public static ItemStack HV_MACHINE_Macerator; - public static ItemStack EV_MACHINE_Macerator; - public static ItemStack EV_MACHINE_Cutter; - public static ItemStack EV_MACHINE_MassFabricator; - public static ItemStack EV_MACHINE_Extruder; - public static ItemStack EV_MACHINE_Sifter; - public static ItemStack EV_MACHINE_ThermalCentrifuge; - public static ItemStack EV_MACHINE_OreWasher; - public static ItemStack EV_MACHINE_AlloySmelter; - public static ItemStack EV_MACHINE_Mixer; - - - //Cables - public static String cableGt02Electrum = "cableGt02Electrum"; - - - //Plates - public static String plateElectricalSteel= "plateElectricalSteel"; - public static String plateEnergeticAlloy= "plateEnergeticAlloy"; - public static String plateCobalt = "plateCobalt"; - public static String plateBronze = "plateBronze"; - public static String plateSteel = "plateSteel"; - - //Pipes - public static String pipeLargeCopper="pipeLargeCopper"; - public static String pipeHugeSteel="pipeHugeSteel"; - public static String pipeHugeStainlessSteel="pipeHugeStainlessSteel"; - public static String pipeHugeTitanium="pipeHugeTitanium"; - - //Lava Boiler - public static ItemStack boiler_Coal; - public static ItemStack blockBricks = ItemUtils.getItemStackFromFQRN("minecraft:brick_block", 1); - - //Batteries - public static String batteryBasic = "batteryBasic"; - public static String batteryAdvanced = "batteryAdvanced"; - public static String batteryElite = "batteryElite"; - public static String batteryMaster = "batteryMaster"; - public static String batteryUltimate = "batteryUltimate"; - public static ItemStack IC2MFE; - public static ItemStack IC2MFSU; - - //Misc - public static ItemStack INPUT_RCCokeOvenBlock; - public static ItemStack INPUT_IECokeOvenBlock; - - //Output Determiner - public static int Casing_Amount; - - - - public static final void loadRecipes(){ - run(); - Logger.INFO("Loading Recipes for the Various machine blocks."); - } - - private static void run(){ - - //Determines Casing Recipe Output - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && !GTNH){ - Casing_Amount=2; - } - else { - Casing_Amount=1; - } - - initModItems(); - tieredMachineHulls(); - controlCores(); - energyCores(); - wirelessChargers(); - largeArcFurnace(); - industrialVacuumFurnace(); - fakeMachineCasingCovers(); - ztonesCoverRecipes(); - overflowValveCovers(); - superBuses(); - roundRobinators(); - chunkloaders(); - distillus(); - algaeFarm(); - chemPlant(); - zyngen(); - milling(); - sparging(); - chisels(); - rockBreaker(); - thermicFluidHeater(); - advHeatExchanger(); - - gt4FarmManager(); - gt4Redstone(); - gt4Inventory(); - - //multiGeneratorArray(); - multiForgeHammer(); - multiMolecularTransformer(); - multiXlTurbines(); - multiSolarTower(); - multiElementalDuplicator(); - - computerCube(); - - resonanceChambers(); - modulators(); - - - } - - - private static void thermicFluidHeater() { - - RecipeUtils.addShapedGregtechRecipe( - CI.getPlate(5, 1), CI.circuitTier5, CI.getPlate(5, 1), - pipeTier7, ItemList.Machine_IV_FluidHeater.get(1), pipeTier7, - CI.getPlate(5, 1), CI.circuitTier4, CI.getPlate(5, 1), - GregtechItemList.Controller_IndustrialFluidHeater.get(1)); - } - - private static void advHeatExchanger() { - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(18), - ItemList.Machine_Multi_HeatExchanger.get(1), - CI.getDoublePlate(6, 8), - CI.getScrew(6, 16), - CI.getCircuit(5, 8) - }, - CI.tieredMaterials[5].getMolten(144 * 8), - GregtechItemList.XL_HeatExchanger.get(1), - 20 * 60, - MaterialUtils.getVoltageForTier(6)); - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(18), - ItemList.Casing_StableTitanium.get(1), - CI.getPlate(5, 4), - CI.getScrew(5, 8), - }, - CI.tieredMaterials[5].getMolten(144 * 2), - GregtechItemList.Casing_XL_HeatExchanger.get(1), - 20 * 5, - MaterialUtils.getVoltageForTier(6)); - } - - private static void computerCube() { - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(20), - CI.getTieredGTPPMachineCasing(4, 1), - CI.getCircuit(4, 8), - CI.getFieldGenerator(2, 4), - CI.getDoublePlate(4, 8), - CI.getRobotArm(4, 8) - }, - Materials.Redstone.getMolten(144 * 32), - GregtechItemList.Gregtech_Computer_Cube_Machine.get(1), - 20 * 60 * 10, - MaterialUtils.getVoltageForTier(4)); - - } - - - private static void gt4FarmManager() { - - - - ItemList[] aInputHatches = new ItemList[] { - ItemList.Hatch_Input_LV, ItemList.Hatch_Input_MV, ItemList.Hatch_Input_HV, - ItemList.Hatch_Input_EV, ItemList.Hatch_Input_IV, ItemList.Hatch_Input_LuV, - ItemList.Hatch_Input_ZPM, ItemList.Hatch_Input_UV - }; - GregtechItemList[] aOutputMachines = new GregtechItemList[] { - GregtechItemList.GT4_Crop_Harvester_LV, GregtechItemList.GT4_Crop_Harvester_MV, GregtechItemList.GT4_Crop_Harvester_HV, - GregtechItemList.GT4_Crop_Harvester_EV, GregtechItemList.GT4_Crop_Harvester_IV, GregtechItemList.GT4_Crop_Harvester_LuV, - GregtechItemList.GT4_Crop_Harvester_ZPM, GregtechItemList.GT4_Crop_Harvester_UV - }; - - int aTier = 1; - for (int i=0;i<8;i++) { - RecipeUtils.addShapedRecipe( - CI.getRobotArm(aTier, 1), CI.getSensor(aTier, 1), CI.getRobotArm(aTier, 1), - ItemUtils.getOrePrefixStack(OrePrefixes.toolHeadSense, CI.tieredMaterials[aTier], 1), CI.getTieredMachineHull(aTier, 1), ItemUtils.getOrePrefixStack(OrePrefixes.toolHeadSense, CI.tieredMaterials[aTier], 1), - CI.getTieredCircuitOreDictName(aTier), aInputHatches[i].get(1), CI.getTieredCircuitOreDictName(aTier), - aOutputMachines[i].get(1)); - aTier++; - } - - } - - private static void gt4Redstone() { - - RecipeUtils.addShapedRecipe( - "plateIron", "plateGlass", "plateIron", - "plateGlass", ItemUtils.getSimpleStack(Blocks.redstone_lamp), "plateGlass", - "plateIron", "plateGlass", "plateIron", - GregtechItemList.GT4_Redstone_Lamp.get(2)); - RecipeUtils.addShapedRecipe( - "plateAluminium", "plateGlass", "plateAluminium", - "plateGlass", ItemUtils.getSimpleStack(Blocks.redstone_lamp), "plateGlass", - "plateAluminium", "plateGlass", "plateAluminium", - GregtechItemList.GT4_Redstone_Lamp.get(8)); - - RecipeUtils.addShapedRecipe( - "plateIron", "plateIron", "plateIron", - ItemUtils.getSimpleStack(Items.comparator), ItemList.Cover_Screen.get(1), ItemUtils.getSimpleStack(Items.comparator), - "plateIron", "plateIron", "plateIron", - GregtechItemList.GT4_Redstone_Display.get(2)); - RecipeUtils.addShapedRecipe( - "plateAluminium", "plateAluminium", "plateAluminium", - ItemUtils.getSimpleStack(Items.comparator), ItemList.Cover_Screen.get(1), ItemUtils.getSimpleStack(Items.comparator), - "plateAluminium", "plateAluminium", "plateAluminium", - GregtechItemList.GT4_Redstone_Display.get(8)); - - RecipeUtils.addShapedRecipe( - "plateIron", "plateIron", "plateIron", - ItemUtils.getSimpleStack(Items.comparator), ItemList.Cover_EnergyDetector.get(1), ItemUtils.getSimpleStack(Items.comparator), - "plateIron", "plateIron", "plateIron", - GregtechItemList.GT4_Redstone_Scale.get(2)); - RecipeUtils.addShapedRecipe( - "plateAluminium", "plateAluminium", "plateAluminium", - ItemUtils.getSimpleStack(Items.comparator), ItemList.Cover_EnergyDetector.get(1), ItemUtils.getSimpleStack(Items.comparator), - "plateAluminium", "plateAluminium", "plateAluminium", - GregtechItemList.GT4_Redstone_Scale.get(8)); - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getTieredMachineHull(1), - ItemUtils.getSimpleStack(Blocks.stone_button, 16) - }, - null, - GregtechItemList.GT4_Redstone_Button_Panel.get(1), - 800, - 4); - - RecipeUtils.addShapedRecipe( - "plateIron", ItemUtils.getSimpleStack(Items.repeater), "plateIron", - ItemUtils.getSimpleStack(Items.comparator), CI.getTieredCircuitOreDictName(1), ItemUtils.getSimpleStack(Items.comparator), - "plateIron", ItemUtils.getSimpleStack(Items.repeater), "plateIron", - GregtechItemList.GT4_Redstone_Circuit.get(1)); - RecipeUtils.addShapedRecipe( - "plateAluminium", ItemUtils.getSimpleStack(Items.repeater), "plateAluminium", - ItemUtils.getSimpleStack(Items.comparator), CI.getTieredCircuitOreDictName(1), ItemUtils.getSimpleStack(Items.comparator), - "plateAluminium", ItemUtils.getSimpleStack(Items.repeater), "plateAluminium", - GregtechItemList.GT4_Redstone_Circuit.get(2)); - - } - - private static void gt4Inventory() { - - ItemList[] aEnergyHatches = new ItemList[] { - ItemList.Hatch_Energy_LV, ItemList.Hatch_Energy_MV, ItemList.Hatch_Energy_HV, - ItemList.Hatch_Energy_EV, ItemList.Hatch_Energy_IV, ItemList.Hatch_Energy_LuV, - ItemList.Hatch_Energy_ZPM, ItemList.Hatch_Energy_UV - }; - - ItemList[] aRegulators = new ItemList[] { - ItemList.Automation_Regulator_LV, ItemList.Automation_Regulator_MV, ItemList.Automation_Regulator_HV, - ItemList.Automation_Regulator_EV, ItemList.Automation_Regulator_IV, ItemList.Automation_Regulator_LuV, - ItemList.Automation_Regulator_ZPM, ItemList.Automation_Regulator_UV - }; - - GregtechItemList[] aOutputInventoryManager = new GregtechItemList[] { - GregtechItemList.GT4_Electric_Inventory_Manager_LV, GregtechItemList.GT4_Electric_Inventory_Manager_MV, GregtechItemList.GT4_Electric_Inventory_Manager_HV, - GregtechItemList.GT4_Electric_Inventory_Manager_EV, GregtechItemList.GT4_Electric_Inventory_Manager_IV, GregtechItemList.GT4_Electric_Inventory_Manager_LuV, - GregtechItemList.GT4_Electric_Inventory_Manager_ZPM, GregtechItemList.GT4_Electric_Inventory_Manager_UV - }; - - int aTier = 1; - for (int i=0;i<8;i++) { - RecipeUtils.addShapedRecipe( - CI.getTieredCircuitOreDictName(aTier), aRegulators[i].get(1), CI.getTieredCircuitOreDictName(aTier), - CI.getRobotArm(aTier, 1), CI.getTieredMachineHull(aTier), CI.getRobotArm(aTier, 1), - CI.getTieredCircuitOreDictName(aTier), aEnergyHatches[i].get(1), CI.getTieredCircuitOreDictName(aTier), - aOutputInventoryManager[i].get(1)); - aTier++; - } - - GregtechItemList[] aOutputElectricCraftingTable = new GregtechItemList[] { - GregtechItemList.GT4_Electric_Auto_Workbench_LV, GregtechItemList.GT4_Electric_Auto_Workbench_MV, GregtechItemList.GT4_Electric_Auto_Workbench_HV, - GregtechItemList.GT4_Electric_Auto_Workbench_EV, GregtechItemList.GT4_Electric_Auto_Workbench_IV, GregtechItemList.GT4_Electric_Auto_Workbench_LuV, - GregtechItemList.GT4_Electric_Auto_Workbench_ZPM, GregtechItemList.GT4_Electric_Auto_Workbench_UV - }; - - aTier = 1; - for (int i=0;i<8;i++) { - RecipeUtils.addShapedRecipe( - ItemUtils.getOrePrefixStack(OrePrefixes.plate, CI.tieredMaterials[aTier], 1), ItemUtils.getSimpleStack(Blocks.crafting_table), ItemUtils.getOrePrefixStack(OrePrefixes.plate, CI.tieredMaterials[aTier], 1), - CI.getTieredCircuitOreDictName(aTier), CI.getTieredMachineHull(aTier), CI.getTieredCircuitOreDictName(aTier), - ItemUtils.getOrePrefixStack(OrePrefixes.plate, CI.tieredMaterials[aTier], 1), CI.getRobotArm(aTier, 1), ItemUtils.getOrePrefixStack(OrePrefixes.plate, CI.tieredMaterials[aTier], 1), - aOutputElectricCraftingTable[i].get(1)); - aTier++; - } - - } - - private static void multiGeneratorArray() { - - GT_ModHandler.addCraftingRecipe( - GregtechItemList.Generator_Array_Controller.get(1L), - CI.bitsd, - new Object[]{"CTC", "FMF", "CBC", - 'M', CI.getTieredGTPPMachineCasing(4, 1), - 'B', OrePrefixes.pipeHuge.get(Materials.StainlessSteel), - 'C', OrePrefixes.circuit.get(Materials.Data), - 'F', ItemList.Electric_Pump_EV, - 'T', CI.getSensor(4, 1)}); - } - - private static void multiForgeHammer() { - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - ItemUtils.getSimpleStack(CI.machineHull_IV, 2), - ItemList.Machine_IV_Hammer.get(1), - CI.getPlate(4, 8), - CI.getBolt(5, 32), - ELEMENT.getInstance().ZIRCONIUM.getFineWire(32), - ItemUtils.getItemStackOfAmountFromOreDict("circuitElite", 4) - }, - CI.getTieredFluid(4, 144 * 12), - GregtechItemList.Controller_IndustrialForgeHammer.get(1), - 20 * 30, - MaterialUtils.getVoltageForTier(5)); - - GT_ModHandler.addCraftingRecipe(GregtechItemList.Casing_IndustrialForgeHammer.get(1), - CI.bitsd, - new Object[]{"IBI", "HCH", "IHI", - 'I', CI.getPlate(4, 1), - 'B', ALLOY.BABBIT_ALLOY.getPlate(1), - 'C', ItemList.Casing_HeatProof.get(1), - 'H', ALLOY.HASTELLOY_X.getRod(1)}); - - } - - private static void multiMolecularTransformer() { - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getTieredGTPPMachineCasing(6, 1), - CI.getPlate(5, 16), - CI.getBolt(5, 32), - ALLOY.HG1223.getFineWire(64), - CI.getEmitter(4, 8), - ItemUtils.getItemStackOfAmountFromOreDict("circuitMaster", 10) - }, - CI.getTieredFluid(5, 144 * 16), - ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_11_MOLECULAR_TRANSFORMER, 1), - 20 * 60, - MaterialUtils.getVoltageForTier(5)); - - CORE.RA.addAssemblylineRecipe( - ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_11_MOLECULAR_TRANSFORMER, 1), - 20 * 60 * 30, - new Object[] { - ALLOY.HG1223.getFineWire(64), - ALLOY.HG1223.getFineWire(64), - ItemList.Electric_Motor_IV.get(GTNH ? 32 : 16), - ItemList.Energy_LapotronicOrb.get(GTNH ? 32 : 16), - CI.getTieredComponent(OrePrefixes.cableGt12, 6, GTNH ? 32 : 16), - CI.getTieredComponent(OrePrefixes.wireGt16, 5, GTNH ? 64 : 32), - ALLOY.ZERON_100.getFrameBox(4), - ALLOY.ZIRCONIUM_CARBIDE.getPlateDouble(32), - ALLOY.BABBIT_ALLOY.getPlate(64), - ALLOY.LEAGRISIUM.getGear(GTNH ? 16 : 8), - new Object[] {CI.getTieredCircuitOreDictName(4), 64}, - new Object[] {CI.getTieredCircuitOreDictName(5), 32}, - new Object[] {CI.getTieredCircuitOreDictName(6), 16}, - GregtechItemList.Laser_Lens_WoodsGlass.get(1), - }, - new FluidStack[] { - ALLOY.NITINOL_60.getFluidStack(144 * 9 * (GTNH ? 4 : 2)), - ALLOY.INCOLOY_MA956.getFluidStack(144 * 9 * (GTNH ? 32 : 8)), - ALLOY.KANTHAL.getFluidStack(144 * 1 * (GTNH ? 16 : 4)), - }, - GregtechItemList.Controller_MolecularTransformer.get(1), - 20 * 60 * 10 * (GTNH ? 2 : 1), - (int) MaterialUtils.getVoltageForTier(6)); - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(16), - CI.getPlate(6, 4), - CI.getScrew(6, 8), - ELEMENT.getInstance().PALLADIUM.getFineWire(16), - CI.getSensor(5, 2), - ItemUtils.getItemStackOfAmountFromOreDict("circuitElite", 4) - }, - CI.getTieredFluid(5, 144 * 4), - GregtechItemList.Casing_Molecular_Transformer_1.get(1), - 20 * 20, - MaterialUtils.getVoltageForTier(5)); - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(16), - CI.getPlate(5, 4), - CI.getScrew(5, 8), - ItemList.Casing_Coil_Nichrome.get(2), - CI.getFieldGenerator(3, 2), - ItemUtils.getItemStackOfAmountFromOreDict("circuitData", 8) - }, - CI.getTieredFluid(5, 144 * 4), - GregtechItemList.Casing_Molecular_Transformer_2.get(1), - 20 * 20, - MaterialUtils.getVoltageForTier(5)); - - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(16), - ItemUtils.getSimpleStack(Blocks.glowstone, 16), - CI.getGear(5, 8), - ELEMENT.getInstance().TITANIUM.getWire04(4), - CI.getFieldGenerator(4, 2), - ItemUtils.getItemStackOfAmountFromOreDict("circuitData", 8) - }, - CI.getTieredFluid(5, 144 * 4), - GregtechItemList.Casing_Molecular_Transformer_3.get(1), - 20 * 60, - MaterialUtils.getVoltageForTier(5)); - - } - - private static void multiXlTurbines() { - - RecipeUtils.addShapedRecipe( - CI.getDoublePlate(4, 1), CI.getElectricMotor(3, 1), CI.getDoublePlate(4, 1), - ItemUtils.getItemStackOfAmountFromOreDict("cellLubricant", 1), ItemList.Casing_Gearbox_Titanium.get(1), ItemUtils.getItemStackOfAmountFromOreDict("cellLubricant", 1), - CI.getDoublePlate(4, 1), CI.getElectricMotor(3, 1), CI.getDoublePlate(4, 1), - GregtechItemList.Casing_Turbine_Shaft.get(1)); - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(18), - ItemList.Casing_Turbine.get(1), - CI.getPlate(4, 4), - CI.getScrew(4, 8), - CI.getCircuit(4, 4), - CI.getGear(3, 8) - }, - CI.tieredMaterials[3].getMolten(144 * 8), - GregtechItemList.Hatch_Turbine_Rotor.get(1), - 20 * 60, - MaterialUtils.getVoltageForTier(4)); - - // Steam - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(18), - ItemList.Casing_Turbine.get(1), - CI.getPlate(3, 4), - CI.getScrew(3, 8), - }, - CI.tieredMaterials[2].getMolten(144 * 2), - GregtechItemList.Casing_Turbine_LP.get(1), - 20 * 5, - MaterialUtils.getVoltageForTier(3)); - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(18), - ItemList.LargeSteamTurbine.get(1), - CI.getPlate(4, 8), - CI.getScrew(4, 16), - CI.getGear(4, 4), - CI.getCircuit(4, 8) - }, - CI.tieredMaterials[4].getMolten(144 * 8), - GregtechItemList.Large_Steam_Turbine.get(1), - 20 * 60, - MaterialUtils.getVoltageForTier(4)); - - // Gas - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(18), - ItemList.Casing_Turbine1.get(1), - CI.getPlate(4, 4), - CI.getScrew(4, 8), - }, - CI.tieredMaterials[3].getMolten(144 * 2), - GregtechItemList.Casing_Turbine_Gas.get(1), - 20 * 5, - MaterialUtils.getVoltageForTier(4)); - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(18), - ItemList.LargeGasTurbine.get(1), - CI.getPlate(5, 8), - CI.getScrew(5, 16), - CI.getGear(5, 4), - CI.getCircuit(5, 8) - }, - CI.tieredMaterials[5].getMolten(144 * 8), - GregtechItemList.Large_Gas_Turbine.get(1), - 20 * 60, - MaterialUtils.getVoltageForTier(5)); - - // HP Steam - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(18), - ItemList.Casing_Turbine2.get(1), - CI.getPlate(5, 4), - CI.getScrew(5, 8), - }, - CI.tieredMaterials[4].getMolten(144 * 2), - GregtechItemList.Casing_Turbine_HP.get(1), - 20 * 5, - MaterialUtils.getVoltageForTier(5)); - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(18), - ItemList.LargeHPSteamTurbine.get(1), - CI.getPlate(6, 8), - CI.getScrew(6, 16), - CI.getGear(6, 4), - CI.getCircuit(6, 8) - }, - CI.tieredMaterials[6].getMolten(144 * 8), - GregtechItemList.Large_HPSteam_Turbine.get(1), - 20 * 60, - MaterialUtils.getVoltageForTier(6)); - - // Plasma - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(18), - ItemList.Casing_Turbine3.get(1), - CI.getPlate(6, 4), - CI.getScrew(6, 8), - }, - CI.tieredMaterials[5].getMolten(144 * 2), - GregtechItemList.Casing_Turbine_Plasma.get(1), - 20 * 5, - MaterialUtils.getVoltageForTier(6)); - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(18), - ItemList.LargePlasmaTurbine.get(1), - CI.getPlate(7, 8), - CI.getScrew(7, 16), - CI.getGear(7, 4), - CI.getCircuit(7, 8) - }, - CI.tieredMaterials[7].getMolten(144 * 8), - GregtechItemList.Large_Plasma_Turbine.get(1), - 20 * 60, - MaterialUtils.getVoltageForTier(7)); - - - } - - private static void multiSolarTower() { - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(17), - CI.getTieredGTPPMachineCasing(3, 4), - ALLOY.MARAGING250.getPlate(8), - ALLOY.MARAGING250.getBolt(8), - ALLOY.MARAGING250.getScrew(8), - CI.getCircuit(5, 8) - }, - CI.getTieredFluid(3, 144 * 16), - GregtechItemList.Industrial_Solar_Tower.get(1), - 20 * 30, - MaterialUtils.getVoltageForTier(4)); - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(17), - ALLOY.MARAGING350.getFrameBox(1), - ALLOY.STAINLESS_STEEL.getPlate(4), - ALLOY.MARAGING350.getScrew(8) - }, - CI.getTieredFluid(3, 144 * 4), - GregtechItemList.Casing_SolarTower_Structural.get(1), - 20 * 30, - MaterialUtils.getVoltageForTier(3)); - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(17), - ALLOY.MARAGING250.getFrameBox(1), - ALLOY.STAINLESS_STEEL.getPlate(4), - ALLOY.MARAGING250.getBolt(16), - ELEMENT.getInstance().ALUMINIUM.getScrew(8) - }, - CI.getTieredFluid(3, 144 * 4), - GregtechItemList.Casing_SolarTower_SaltContainment.get(1), - 20 * 30, - MaterialUtils.getVoltageForTier(3)); - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(17), - ALLOY.MARAGING250.getFrameBox(1), - ALLOY.STEEL_BLACK.getPlate(4), - ALLOY.MARAGING250.getScrew(8) - }, - CI.getAlternativeTieredFluid(3, 144 * 4), - GregtechItemList.Casing_SolarTower_HeatContainment.get(1), - 20 * 30, - MaterialUtils.getVoltageForTier(3)); - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(17), - CI.getTieredGTPPMachineCasing(2, 1), - CI.getPlate(3, 2), - CI.getGear(3, 4), - CI.getElectricMotor(3, 2), - CI.getCircuit(3, 4) - - }, - CI.getTertiaryTieredFluid(3, 144 * 4), - GregtechItemList.Solar_Tower_Reflector.get(1), - 20 * 60, - MaterialUtils.getVoltageForTier(3)); - - } - - private static void multiElementalDuplicator() { - - CORE.RA.addAssemblylineRecipe( - ItemList.Machine_IV_Replicator.get(1), - 20 * 60 * 60 * 12, - new Object[] { - CI.getTieredMachineHull(7, 4), - CI.getFieldGenerator(5, GTNH ? 32 : 16), - CI.getElectricMotor(7, GTNH ? 32 : 16), - CI.getElectricPiston(7, GTNH ? 16 : 4), - CI.getEnergyCore(6, GTNH ? 8 : 2), - CI.getPlate(7, GTNH ? 32 : 16), - CI.getScrew(7, GTNH ? 64 : 32), - CI.getBolt(6, GTNH ? 64 : 32), - CI.getTieredComponent(OrePrefixes.rod, 6, GTNH ? 20 : 10), - new Object[] {CI.getTieredCircuitOreDictName(7), 20}, - ItemList.Tool_DataOrb.get(32), - GregtechItemList.Laser_Lens_Special.get(1) - }, - new FluidStack[] { - CI.getTieredFluid(7, 144 * 32), - CI.getAlternativeTieredFluid(6, 144 * 16), - CI.getTertiaryTieredFluid(6, 144 * 16), - ALLOY.BABBIT_ALLOY.getFluidStack(128 * 144), - - }, - GregtechItemList.Controller_ElementalDuplicator.get(1), - 20 * 60 * 60 * (GTNH ? 2 : 1), - (int) MaterialUtils.getVoltageForTier(7)); - - CORE.RA.addAssemblylineRecipe( - GregtechItemList.Modulator_III.get(1), - 20 * 60 * 60 * 4, - new Object[] { - CI.getTieredGTPPMachineCasing(7, 2), - CI.getFieldGenerator(4, GTNH ? 8 : 4), - CI.getEnergyCore(4, GTNH ? 8 : 2), - CI.getPlate(7, GTNH ? 16 : 8), - CI.getScrew(6, GTNH ? 32 : 16), - CI.getBolt(6, GTNH ? 32 : 16), - CI.getTieredComponent(OrePrefixes.rod, 5, GTNH ? 32 : 16), - new Object[] {CI.getTieredCircuitOreDictName(6), 32}, - ItemList.Tool_DataOrb.get(32), - }, - new FluidStack[] { - CI.getTieredFluid(6, 144 * 16), - CI.getAlternativeTieredFluid(5, 144 * 8), - CI.getTertiaryTieredFluid(5, 144 * 8), - ALLOY.BABBIT_ALLOY.getFluidStack(64 * 144), - - }, - GregtechItemList.Hatch_Input_Elemental_Duplicator.get(1), - 20 * 60 * 60 * (GTNH ? 4 : 2), - (int) MaterialUtils.getVoltageForTier(6)); - - CORE.RA.addAssemblylineRecipe( - GregtechItemList.ResonanceChamber_III.get(1), - 20 * 60 * 60 * 2, - new Object[] { - CI.getTieredMachineHull(6, 5), - CI.getFieldGenerator(3, GTNH ? 32 : 16), - CI.getEnergyCore(2, GTNH ? 8 : 2), - CI.getPlate(7, GTNH ? 8 : 4), - CI.getScrew(7, GTNH ? 8 : 4), - CI.getBolt(6, GTNH ? 16 : 8), - CI.getTieredComponent(OrePrefixes.rod, 5, GTNH ? 8 : 4), - new Object[] {CI.getTieredCircuitOreDictName(5), 4}, - ItemList.Tool_DataStick.get(4), - }, - new FluidStack[] { - CI.getTieredFluid(5, 144 * 16), - CI.getAlternativeTieredFluid(4, 144 * 8), - CI.getTertiaryTieredFluid(4, 144 * 8), - ALLOY.BABBIT_ALLOY.getFluidStack(16 * 144), - - }, - GregtechItemList.Casing_ElementalDuplicator.get(1), - 20 * 60 * (GTNH ? 20 : 10), - (int) MaterialUtils.getVoltageForTier(6)); - - } - - private static void resonanceChambers() { - int aFieldTier = 1; - int aCasingTier = 4; - for (int i = 0; i < 4; i++) { - RecipeUtils.addShapedRecipe( - CI.getDoublePlate(aCasingTier, 1), CI.getFieldGenerator(aFieldTier, 1), CI.getDoublePlate(aCasingTier, 1), - CI.getFieldGenerator(aFieldTier, 1), CI.getTieredMachineCasing(aCasingTier), CI.getFieldGenerator(aFieldTier, 1), - CI.getDoublePlate(aCasingTier, 1), CI.getFieldGenerator(aFieldTier, 1), CI.getDoublePlate(aCasingTier, 1), - ItemUtils.simpleMetaStack(ModBlocks.blockSpecialMultiCasings2, i, 1)); - aCasingTier++; - aFieldTier++; - } - } - - private static void modulators() { - int aCasingTier = 4; - for (int i = 4; i < 8; i++) { - RecipeUtils.addShapedRecipe( - CI.getTieredCircuitOreDictName(aCasingTier), CI.getPlate(aCasingTier, 1), CI.getTieredCircuitOreDictName(aCasingTier), - CI.getPlate(aCasingTier, 1), CI.getTieredMachineCasing(aCasingTier), CI.getPlate(aCasingTier, 1), - CI.getTieredCircuitOreDictName(aCasingTier), CI.getPlate(aCasingTier, 1), CI.getTieredCircuitOreDictName(aCasingTier), - ItemUtils.simpleMetaStack(ModBlocks.blockSpecialMultiCasings2, i, 1)); - aCasingTier++; - } - } - - private static void zyngen() { - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(6), - CI.getTieredMachineHull(4), - ItemList.Machine_IV_AlloySmelter.get(1), - CI.getGear(3, 16), - CI.getBolt(3, 64), - CI.getPlate(4, 16) - }, - CI.getAlternativeTieredFluid(4, 144 * 8), - GregtechItemList.Industrial_AlloySmelter.get(1), - 20 * 30, - MaterialUtils.getVoltageForTier(4)); - - } - - private static void chemPlant() { - + // Outputs + // static ItemStack RECIPE_BufferCore_ULV = new ItemStack(GregtechEnergyBuffer.itemBufferCore); + public static ItemStack RECIPE_SteamCondenser; + public static ItemStack RECIPE_IronBlastFurnace; + public static ItemStack RECIPE_IronPlatedBricks; + public static ItemStack RECIPE_Buffer_ULV = GregtechItemList.Energy_Buffer_1by1_ULV.get(1); + public static ItemStack RECIPE_Buffer_LV = GregtechItemList.Energy_Buffer_1by1_LV.get(1); + public static ItemStack RECIPE_Buffer_MV = GregtechItemList.Energy_Buffer_1by1_MV.get(1); + public static ItemStack RECIPE_Buffer_HV = GregtechItemList.Energy_Buffer_1by1_HV.get(1); + public static ItemStack RECIPE_Buffer_EV = GregtechItemList.Energy_Buffer_1by1_EV.get(1); + public static ItemStack RECIPE_Buffer_IV = GregtechItemList.Energy_Buffer_1by1_IV.get(1); + public static ItemStack RECIPE_Buffer_LuV = GregtechItemList.Energy_Buffer_1by1_LuV.get(1); + public static ItemStack RECIPE_Buffer_ZPM = GregtechItemList.Energy_Buffer_1by1_ZPM.get(1); + public static ItemStack RECIPE_Buffer_UV = GregtechItemList.Energy_Buffer_1by1_UV.get(1); + public static ItemStack RECIPE_Buffer_MAX = GregtechItemList.Energy_Buffer_1by1_MAX.get(1); + // Industrial Centrifuge + public static ItemStack RECIPE_IndustrialCentrifugeController; + public static ItemStack RECIPE_IndustrialCentrifugeCasing; + // Industrial Coke Oven + public static ItemStack RECIPE_IndustrialCokeOvenController; + public static ItemStack RECIPE_IndustrialCokeOvenFrame; + public static ItemStack RECIPE_IndustrialCokeOvenCasingA; + public static ItemStack RECIPE_IndustrialCokeOvenCasingB; + // Industrial Electrolyzer + public static ItemStack RECIPE_IndustrialElectrolyzerController; + public static ItemStack RECIPE_IndustrialElectrolyzerFrame; + // Industrial Material Press + public static ItemStack RECIPE_IndustrialMaterialPressController; + public static ItemStack RECIPE_IndustrialMaterialPressFrame; + // Industrial Maceration Stack + public static ItemStack RECIPE_IndustrialMacerationStackController; + public static ItemStack RECIPE_IndustrialMacerationStackFrame; + // Industrial Wire Factory + public static ItemStack RECIPE_IndustrialWireFactoryController; + public static ItemStack RECIPE_IndustrialWireFactoryFrame; + // Industrial Multi Tank + public static ItemStack RECIPE_IndustrialMultiTankController; + public static ItemStack RECIPE_IndustrialMultiTankFrame; + // Industrial Matter Fabricator + public static ItemStack RECIPE_IndustrialMatterFabController; + public static ItemStack RECIPE_IndustrialMatterFabFrame; + public static ItemStack RECIPE_IndustrialMatterFabCoil; + // Industrial Blast Smelter + public static ItemStack RECIPE_IndustrialBlastSmelterController; + public static ItemStack RECIPE_IndustrialBlastSmelterFrame; + public static ItemStack RECIPE_IndustrialBlastSmelterCoil; + // Industrial Sieve + public static ItemStack RECIPE_IndustrialSieveController; + public static ItemStack RECIPE_IndustrialSieveFrame; + public static ItemStack RECIPE_IndustrialSieveGrate; + // Industrial Tree Farmer + public static ItemStack RECIPE_TreeFarmController; + public static ItemStack RECIPE_TreeFarmFrame; + // Tesseracts + public static ItemStack RECIPE_TesseractGenerator; + public static ItemStack RECIPE_TesseractTerminal; + // Thermal Boiler + public static ItemStack RECIPE_ThermalBoilerController; + public static ItemStack RECIPE_ThermalBoilerCasing; + + // Thorium Reactor + public static ItemStack RECIPE_LFTRController; + public static ItemStack RECIPE_LFTROuterCasing; + public static ItemStack RECIPE_LFTRInnerCasing; + + // Milling + public static ItemStack RECIPE_ISAMill_Controller; + public static ItemStack RECIPE_ISAMill_Gearbox; + public static ItemStack RECIPE_ISAMill_Casing; + public static ItemStack RECIPE_ISAMill_Hatch; + public static ItemStack RECIPE_Flotation_Controller; + public static ItemStack RECIPE_Flotation_Casing; + + // Cyclotron + public static ItemStack RECIPE_CyclotronController; + public static ItemStack RECIPE_CyclotronOuterCasing; + public static ItemStack RECIPE_CyclotronInnerCoil; + + // Buffer Cores + public static ItemStack RECIPE_BufferCore_ULV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore1", 1); + public static ItemStack RECIPE_BufferCore_LV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore2", 1); + public static ItemStack RECIPE_BufferCore_MV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore3", 1); + public static ItemStack RECIPE_BufferCore_HV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore4", 1); + public static ItemStack RECIPE_BufferCore_EV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore5", 1); + public static ItemStack RECIPE_BufferCore_IV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore6", 1); + public static ItemStack RECIPE_BufferCore_LuV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore7", 1); + public static ItemStack RECIPE_BufferCore_ZPM = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore8", 1); + public static ItemStack RECIPE_BufferCore_UV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore9", 1); + public static ItemStack RECIPE_BufferCore_MAX = + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore10", 1); + + // Wire + public static String wireTier1 = "wireGt08Lead"; + public static String wireTier2 = "wireGt08Tin"; + public static String wireTier3 = "wireGt08Copper"; + public static String wireTier4 = "wireGt08Gold"; + public static String wireTier5 = "wireGt08Aluminium"; + public static String wireTier6 = "wireGt08Tungsten"; + public static String wireTier7 = "wireGt08Naquadah"; + public static String wireTier8 = "wireGt08Osmium"; + public static String wireTier9 = "wireGt08Superconductor"; + public static String wireTier10 = "wireGt16Superconductor"; + + // Wire + public static String cableTier1 = "cableGt04Lead"; + public static String cableTier2 = "cableGt04Tin"; + public static String cableTier3 = "cableGt04Copper"; + public static String cableTier4 = "cableGt04Gold"; + public static String cableTier5 = "cableGt04Aluminium"; + public static String cableTier6 = "cableGt04Tungsten"; + public static String cableTier7 = "cableGt04Naquadah"; + public static String cableTier8 = "cableGt04Osmium"; + public static String cableTier9 = "cableGt04NiobiumTitanium"; + public static String cableTier10 = "cableGt08NiobiumTitanium"; + + public static String pipeTier1 = "pipeHuge" + "Clay"; + public static String pipeTier2 = "pipeHuge" + "Potin"; + public static String pipeTier3 = "pipeHuge" + "Steel"; + public static String pipeTier4 = "pipeHuge" + "StainlessSteel"; + public static String pipeTier5 = "pipeHuge" + "TungstenSteel"; + public static String pipeTier6 = "pipeHuge" + "MaragingSteel300"; + public static String pipeTier7 = "pipeHuge" + "Tantalloy60"; + public static String pipeTier8 = "pipeHuge" + "Tantalloy61"; + public static String pipeTier9 = "pipeHuge" + "Inconel792"; + public static String pipeTier10 = "pipeHuge" + "HastelloyX"; + public static String pipeTier11 = "pipeHuge" + "Europium"; + + // EV/IV MACHINES + public static ItemStack EV_MACHINE_Electrolyzer; + public static ItemStack EV_MACHINE_Centrifuge; + public static ItemStack EV_MACHINE_BendingMachine; + public static ItemStack EV_MACHINE_Wiremill; + public static ItemStack HV_MACHINE_Macerator; + public static ItemStack EV_MACHINE_Macerator; + public static ItemStack EV_MACHINE_Cutter; + public static ItemStack EV_MACHINE_MassFabricator; + public static ItemStack EV_MACHINE_Extruder; + public static ItemStack EV_MACHINE_Sifter; + public static ItemStack EV_MACHINE_ThermalCentrifuge; + public static ItemStack EV_MACHINE_OreWasher; + public static ItemStack EV_MACHINE_AlloySmelter; + public static ItemStack EV_MACHINE_Mixer; + + // Cables + public static String cableGt02Electrum = "cableGt02Electrum"; + + // Plates + public static String plateElectricalSteel = "plateElectricalSteel"; + public static String plateEnergeticAlloy = "plateEnergeticAlloy"; + public static String plateCobalt = "plateCobalt"; + public static String plateBronze = "plateBronze"; + public static String plateSteel = "plateSteel"; + + // Pipes + public static String pipeLargeCopper = "pipeLargeCopper"; + public static String pipeHugeSteel = "pipeHugeSteel"; + public static String pipeHugeStainlessSteel = "pipeHugeStainlessSteel"; + public static String pipeHugeTitanium = "pipeHugeTitanium"; + + // Lava Boiler + public static ItemStack boiler_Coal; + public static ItemStack blockBricks = ItemUtils.getItemStackFromFQRN("minecraft:brick_block", 1); + + // Batteries + public static String batteryBasic = "batteryBasic"; + public static String batteryAdvanced = "batteryAdvanced"; + public static String batteryElite = "batteryElite"; + public static String batteryMaster = "batteryMaster"; + public static String batteryUltimate = "batteryUltimate"; + public static ItemStack IC2MFE; + public static ItemStack IC2MFSU; + + // Misc + public static ItemStack INPUT_RCCokeOvenBlock; + public static ItemStack INPUT_IECokeOvenBlock; + + // Output Determiner + public static int Casing_Amount; + + public static final void loadRecipes() { + run(); + Logger.INFO("Loading Recipes for the Various machine blocks."); + } + + private static void run() { + + // Determines Casing Recipe Output + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && !GTNH) { + Casing_Amount = 2; + } else { + Casing_Amount = 1; + } + + initModItems(); + tieredMachineHulls(); + controlCores(); + energyCores(); + wirelessChargers(); + largeArcFurnace(); + industrialVacuumFurnace(); + fakeMachineCasingCovers(); + ztonesCoverRecipes(); + overflowValveCovers(); + superBuses(); + roundRobinators(); + chunkloaders(); + distillus(); + algaeFarm(); + chemPlant(); + zyngen(); + milling(); + sparging(); + chisels(); + rockBreaker(); + thermicFluidHeater(); + advHeatExchanger(); + + gt4FarmManager(); + gt4Redstone(); + gt4Inventory(); + + // multiGeneratorArray(); + multiForgeHammer(); + multiMolecularTransformer(); + multiXlTurbines(); + multiSolarTower(); + multiElementalDuplicator(); + + computerCube(); + + resonanceChambers(); + modulators(); + } + + private static void thermicFluidHeater() { + + RecipeUtils.addShapedGregtechRecipe( + CI.getPlate(5, 1), + CI.circuitTier5, + CI.getPlate(5, 1), + pipeTier7, + ItemList.Machine_IV_FluidHeater.get(1), + pipeTier7, + CI.getPlate(5, 1), + CI.circuitTier4, + CI.getPlate(5, 1), + GregtechItemList.Controller_IndustrialFluidHeater.get(1)); + } + + private static void advHeatExchanger() { + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(18), + ItemList.Machine_Multi_HeatExchanger.get(1), + CI.getDoublePlate(6, 8), + CI.getScrew(6, 16), + CI.getCircuit(5, 8) + }, + CI.tieredMaterials[5].getMolten(144 * 8), + GregtechItemList.XL_HeatExchanger.get(1), + 20 * 60, + MaterialUtils.getVoltageForTier(6)); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(18), + ItemList.Casing_StableTitanium.get(1), + CI.getPlate(5, 4), + CI.getScrew(5, 8), + }, + CI.tieredMaterials[5].getMolten(144 * 2), + GregtechItemList.Casing_XL_HeatExchanger.get(1), + 20 * 5, + MaterialUtils.getVoltageForTier(6)); + } + + private static void computerCube() { + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(20), + CI.getTieredGTPPMachineCasing(4, 1), + CI.getCircuit(4, 8), + CI.getFieldGenerator(2, 4), + CI.getDoublePlate(4, 8), + CI.getRobotArm(4, 8) + }, + Materials.Redstone.getMolten(144 * 32), + GregtechItemList.Gregtech_Computer_Cube_Machine.get(1), + 20 * 60 * 10, + MaterialUtils.getVoltageForTier(4)); + } + + private static void gt4FarmManager() { + + ItemList[] aInputHatches = new ItemList[] { + ItemList.Hatch_Input_LV, ItemList.Hatch_Input_MV, ItemList.Hatch_Input_HV, + ItemList.Hatch_Input_EV, ItemList.Hatch_Input_IV, ItemList.Hatch_Input_LuV, + ItemList.Hatch_Input_ZPM, ItemList.Hatch_Input_UV + }; + GregtechItemList[] aOutputMachines = new GregtechItemList[] { + GregtechItemList.GT4_Crop_Harvester_LV, GregtechItemList.GT4_Crop_Harvester_MV, + GregtechItemList.GT4_Crop_Harvester_HV, + GregtechItemList.GT4_Crop_Harvester_EV, GregtechItemList.GT4_Crop_Harvester_IV, + GregtechItemList.GT4_Crop_Harvester_LuV, + GregtechItemList.GT4_Crop_Harvester_ZPM, GregtechItemList.GT4_Crop_Harvester_UV + }; + + int aTier = 1; + for (int i = 0; i < 8; i++) { + RecipeUtils.addShapedRecipe( + CI.getRobotArm(aTier, 1), + CI.getSensor(aTier, 1), + CI.getRobotArm(aTier, 1), + ItemUtils.getOrePrefixStack(OrePrefixes.toolHeadSense, CI.tieredMaterials[aTier], 1), + CI.getTieredMachineHull(aTier, 1), + ItemUtils.getOrePrefixStack(OrePrefixes.toolHeadSense, CI.tieredMaterials[aTier], 1), + CI.getTieredCircuitOreDictName(aTier), + aInputHatches[i].get(1), + CI.getTieredCircuitOreDictName(aTier), + aOutputMachines[i].get(1)); + aTier++; + } + } + + private static void gt4Redstone() { + + RecipeUtils.addShapedRecipe( + "plateIron", + "plateGlass", + "plateIron", + "plateGlass", + ItemUtils.getSimpleStack(Blocks.redstone_lamp), + "plateGlass", + "plateIron", + "plateGlass", + "plateIron", + GregtechItemList.GT4_Redstone_Lamp.get(2)); + RecipeUtils.addShapedRecipe( + "plateAluminium", + "plateGlass", + "plateAluminium", + "plateGlass", + ItemUtils.getSimpleStack(Blocks.redstone_lamp), + "plateGlass", + "plateAluminium", + "plateGlass", + "plateAluminium", + GregtechItemList.GT4_Redstone_Lamp.get(8)); + + RecipeUtils.addShapedRecipe( + "plateIron", + "plateIron", + "plateIron", + ItemUtils.getSimpleStack(Items.comparator), + ItemList.Cover_Screen.get(1), + ItemUtils.getSimpleStack(Items.comparator), + "plateIron", + "plateIron", + "plateIron", + GregtechItemList.GT4_Redstone_Display.get(2)); + RecipeUtils.addShapedRecipe( + "plateAluminium", + "plateAluminium", + "plateAluminium", + ItemUtils.getSimpleStack(Items.comparator), + ItemList.Cover_Screen.get(1), + ItemUtils.getSimpleStack(Items.comparator), + "plateAluminium", + "plateAluminium", + "plateAluminium", + GregtechItemList.GT4_Redstone_Display.get(8)); + + RecipeUtils.addShapedRecipe( + "plateIron", + "plateIron", + "plateIron", + ItemUtils.getSimpleStack(Items.comparator), + ItemList.Cover_EnergyDetector.get(1), + ItemUtils.getSimpleStack(Items.comparator), + "plateIron", + "plateIron", + "plateIron", + GregtechItemList.GT4_Redstone_Scale.get(2)); + RecipeUtils.addShapedRecipe( + "plateAluminium", + "plateAluminium", + "plateAluminium", + ItemUtils.getSimpleStack(Items.comparator), + ItemList.Cover_EnergyDetector.get(1), + ItemUtils.getSimpleStack(Items.comparator), + "plateAluminium", + "plateAluminium", + "plateAluminium", + GregtechItemList.GT4_Redstone_Scale.get(8)); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] {CI.getTieredMachineHull(1), ItemUtils.getSimpleStack(Blocks.stone_button, 16)}, + null, + GregtechItemList.GT4_Redstone_Button_Panel.get(1), + 800, + 4); + + RecipeUtils.addShapedRecipe( + "plateIron", + ItemUtils.getSimpleStack(Items.repeater), + "plateIron", + ItemUtils.getSimpleStack(Items.comparator), + CI.getTieredCircuitOreDictName(1), + ItemUtils.getSimpleStack(Items.comparator), + "plateIron", + ItemUtils.getSimpleStack(Items.repeater), + "plateIron", + GregtechItemList.GT4_Redstone_Circuit.get(1)); + RecipeUtils.addShapedRecipe( + "plateAluminium", + ItemUtils.getSimpleStack(Items.repeater), + "plateAluminium", + ItemUtils.getSimpleStack(Items.comparator), + CI.getTieredCircuitOreDictName(1), + ItemUtils.getSimpleStack(Items.comparator), + "plateAluminium", + ItemUtils.getSimpleStack(Items.repeater), + "plateAluminium", + GregtechItemList.GT4_Redstone_Circuit.get(2)); + } + + private static void gt4Inventory() { + + ItemList[] aEnergyHatches = new ItemList[] { + ItemList.Hatch_Energy_LV, ItemList.Hatch_Energy_MV, ItemList.Hatch_Energy_HV, + ItemList.Hatch_Energy_EV, ItemList.Hatch_Energy_IV, ItemList.Hatch_Energy_LuV, + ItemList.Hatch_Energy_ZPM, ItemList.Hatch_Energy_UV + }; + + ItemList[] aRegulators = new ItemList[] { + ItemList.Automation_Regulator_LV, ItemList.Automation_Regulator_MV, ItemList.Automation_Regulator_HV, + ItemList.Automation_Regulator_EV, ItemList.Automation_Regulator_IV, ItemList.Automation_Regulator_LuV, + ItemList.Automation_Regulator_ZPM, ItemList.Automation_Regulator_UV + }; + + GregtechItemList[] aOutputInventoryManager = new GregtechItemList[] { + GregtechItemList.GT4_Electric_Inventory_Manager_LV, GregtechItemList.GT4_Electric_Inventory_Manager_MV, + GregtechItemList.GT4_Electric_Inventory_Manager_HV, + GregtechItemList.GT4_Electric_Inventory_Manager_EV, GregtechItemList.GT4_Electric_Inventory_Manager_IV, + GregtechItemList.GT4_Electric_Inventory_Manager_LuV, + GregtechItemList.GT4_Electric_Inventory_Manager_ZPM, GregtechItemList.GT4_Electric_Inventory_Manager_UV + }; + + int aTier = 1; + for (int i = 0; i < 8; i++) { + RecipeUtils.addShapedRecipe( + CI.getTieredCircuitOreDictName(aTier), + aRegulators[i].get(1), + CI.getTieredCircuitOreDictName(aTier), + CI.getRobotArm(aTier, 1), + CI.getTieredMachineHull(aTier), + CI.getRobotArm(aTier, 1), + CI.getTieredCircuitOreDictName(aTier), + aEnergyHatches[i].get(1), + CI.getTieredCircuitOreDictName(aTier), + aOutputInventoryManager[i].get(1)); + aTier++; + } + + GregtechItemList[] aOutputElectricCraftingTable = new GregtechItemList[] { + GregtechItemList.GT4_Electric_Auto_Workbench_LV, GregtechItemList.GT4_Electric_Auto_Workbench_MV, + GregtechItemList.GT4_Electric_Auto_Workbench_HV, + GregtechItemList.GT4_Electric_Auto_Workbench_EV, GregtechItemList.GT4_Electric_Auto_Workbench_IV, + GregtechItemList.GT4_Electric_Auto_Workbench_LuV, + GregtechItemList.GT4_Electric_Auto_Workbench_ZPM, GregtechItemList.GT4_Electric_Auto_Workbench_UV + }; + + aTier = 1; + for (int i = 0; i < 8; i++) { + RecipeUtils.addShapedRecipe( + ItemUtils.getOrePrefixStack(OrePrefixes.plate, CI.tieredMaterials[aTier], 1), + ItemUtils.getSimpleStack(Blocks.crafting_table), + ItemUtils.getOrePrefixStack(OrePrefixes.plate, CI.tieredMaterials[aTier], 1), + CI.getTieredCircuitOreDictName(aTier), + CI.getTieredMachineHull(aTier), + CI.getTieredCircuitOreDictName(aTier), + ItemUtils.getOrePrefixStack(OrePrefixes.plate, CI.tieredMaterials[aTier], 1), + CI.getRobotArm(aTier, 1), + ItemUtils.getOrePrefixStack(OrePrefixes.plate, CI.tieredMaterials[aTier], 1), + aOutputElectricCraftingTable[i].get(1)); + aTier++; + } + } + + private static void multiGeneratorArray() { + + GT_ModHandler.addCraftingRecipe(GregtechItemList.Generator_Array_Controller.get(1L), CI.bitsd, new Object[] { + "CTC", + "FMF", + "CBC", + 'M', + CI.getTieredGTPPMachineCasing(4, 1), + 'B', + OrePrefixes.pipeHuge.get(Materials.StainlessSteel), + 'C', + OrePrefixes.circuit.get(Materials.Data), + 'F', + ItemList.Electric_Pump_EV, + 'T', + CI.getSensor(4, 1) + }); + } + + private static void multiForgeHammer() { + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + ItemUtils.getSimpleStack(CI.machineHull_IV, 2), + ItemList.Machine_IV_Hammer.get(1), + CI.getPlate(4, 8), + CI.getBolt(5, 32), + ELEMENT.getInstance().ZIRCONIUM.getFineWire(32), + ItemUtils.getItemStackOfAmountFromOreDict("circuitElite", 4) + }, + CI.getTieredFluid(4, 144 * 12), + GregtechItemList.Controller_IndustrialForgeHammer.get(1), + 20 * 30, + MaterialUtils.getVoltageForTier(5)); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.Casing_IndustrialForgeHammer.get(1), CI.bitsd, new Object[] { + "IBI", + "HCH", + "IHI", + 'I', + CI.getPlate(4, 1), + 'B', + ALLOY.BABBIT_ALLOY.getPlate(1), + 'C', + ItemList.Casing_HeatProof.get(1), + 'H', + ALLOY.HASTELLOY_X.getRod(1) + }); + } + + private static void multiMolecularTransformer() { + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getTieredGTPPMachineCasing(6, 1), + CI.getPlate(5, 16), + CI.getBolt(5, 32), + ALLOY.HG1223.getFineWire(64), + CI.getEmitter(4, 8), + ItemUtils.getItemStackOfAmountFromOreDict("circuitMaster", 10) + }, + CI.getTieredFluid(5, 144 * 16), + ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_11_MOLECULAR_TRANSFORMER, 1), + 20 * 60, + MaterialUtils.getVoltageForTier(5)); + + CORE.RA.addAssemblylineRecipe( + ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_11_MOLECULAR_TRANSFORMER, 1), + 20 * 60 * 30, + new Object[] { + ALLOY.HG1223.getFineWire(64), + ALLOY.HG1223.getFineWire(64), + ItemList.Electric_Motor_IV.get(GTNH ? 32 : 16), + ItemList.Energy_LapotronicOrb.get(GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.cableGt12, 6, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.wireGt16, 5, GTNH ? 64 : 32), + ALLOY.ZERON_100.getFrameBox(4), + ALLOY.ZIRCONIUM_CARBIDE.getPlateDouble(32), + ALLOY.BABBIT_ALLOY.getPlate(64), + ALLOY.LEAGRISIUM.getGear(GTNH ? 16 : 8), + new Object[] {CI.getTieredCircuitOreDictName(4), 64}, + new Object[] {CI.getTieredCircuitOreDictName(5), 32}, + new Object[] {CI.getTieredCircuitOreDictName(6), 16}, + GregtechItemList.Laser_Lens_WoodsGlass.get(1), + }, + new FluidStack[] { + ALLOY.NITINOL_60.getFluidStack(144 * 9 * (GTNH ? 4 : 2)), + ALLOY.INCOLOY_MA956.getFluidStack(144 * 9 * (GTNH ? 32 : 8)), + ALLOY.KANTHAL.getFluidStack(144 * 1 * (GTNH ? 16 : 4)), + }, + GregtechItemList.Controller_MolecularTransformer.get(1), + 20 * 60 * 10 * (GTNH ? 2 : 1), + (int) MaterialUtils.getVoltageForTier(6)); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(16), + CI.getPlate(6, 4), + CI.getScrew(6, 8), + ELEMENT.getInstance().PALLADIUM.getFineWire(16), + CI.getSensor(5, 2), + ItemUtils.getItemStackOfAmountFromOreDict("circuitElite", 4) + }, + CI.getTieredFluid(5, 144 * 4), + GregtechItemList.Casing_Molecular_Transformer_1.get(1), + 20 * 20, + MaterialUtils.getVoltageForTier(5)); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(16), + CI.getPlate(5, 4), + CI.getScrew(5, 8), + ItemList.Casing_Coil_Nichrome.get(2), + CI.getFieldGenerator(3, 2), + ItemUtils.getItemStackOfAmountFromOreDict("circuitData", 8) + }, + CI.getTieredFluid(5, 144 * 4), + GregtechItemList.Casing_Molecular_Transformer_2.get(1), + 20 * 20, + MaterialUtils.getVoltageForTier(5)); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(16), + ItemUtils.getSimpleStack(Blocks.glowstone, 16), + CI.getGear(5, 8), + ELEMENT.getInstance().TITANIUM.getWire04(4), + CI.getFieldGenerator(4, 2), + ItemUtils.getItemStackOfAmountFromOreDict("circuitData", 8) + }, + CI.getTieredFluid(5, 144 * 4), + GregtechItemList.Casing_Molecular_Transformer_3.get(1), + 20 * 60, + MaterialUtils.getVoltageForTier(5)); + } + + private static void multiXlTurbines() { + + RecipeUtils.addShapedRecipe( + CI.getDoublePlate(4, 1), + CI.getElectricMotor(3, 1), + CI.getDoublePlate(4, 1), + ItemUtils.getItemStackOfAmountFromOreDict("cellLubricant", 1), + ItemList.Casing_Gearbox_Titanium.get(1), + ItemUtils.getItemStackOfAmountFromOreDict("cellLubricant", 1), + CI.getDoublePlate(4, 1), + CI.getElectricMotor(3, 1), + CI.getDoublePlate(4, 1), + GregtechItemList.Casing_Turbine_Shaft.get(1)); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(18), + ItemList.Casing_Turbine.get(1), + CI.getPlate(4, 4), + CI.getScrew(4, 8), + CI.getCircuit(4, 4), + CI.getGear(3, 8) + }, + CI.tieredMaterials[3].getMolten(144 * 8), + GregtechItemList.Hatch_Turbine_Rotor.get(1), + 20 * 60, + MaterialUtils.getVoltageForTier(4)); + + // Steam + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(18), + ItemList.Casing_Turbine.get(1), + CI.getPlate(3, 4), + CI.getScrew(3, 8), + }, + CI.tieredMaterials[2].getMolten(144 * 2), + GregtechItemList.Casing_Turbine_LP.get(1), + 20 * 5, + MaterialUtils.getVoltageForTier(3)); + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(18), + ItemList.LargeSteamTurbine.get(1), + CI.getPlate(4, 8), + CI.getScrew(4, 16), + CI.getGear(4, 4), + CI.getCircuit(4, 8) + }, + CI.tieredMaterials[4].getMolten(144 * 8), + GregtechItemList.Large_Steam_Turbine.get(1), + 20 * 60, + MaterialUtils.getVoltageForTier(4)); + + // Gas + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(18), + ItemList.Casing_Turbine1.get(1), + CI.getPlate(4, 4), + CI.getScrew(4, 8), + }, + CI.tieredMaterials[3].getMolten(144 * 2), + GregtechItemList.Casing_Turbine_Gas.get(1), + 20 * 5, + MaterialUtils.getVoltageForTier(4)); + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(18), + ItemList.LargeGasTurbine.get(1), + CI.getPlate(5, 8), + CI.getScrew(5, 16), + CI.getGear(5, 4), + CI.getCircuit(5, 8) + }, + CI.tieredMaterials[5].getMolten(144 * 8), + GregtechItemList.Large_Gas_Turbine.get(1), + 20 * 60, + MaterialUtils.getVoltageForTier(5)); + + // HP Steam + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(18), + ItemList.Casing_Turbine2.get(1), + CI.getPlate(5, 4), + CI.getScrew(5, 8), + }, + CI.tieredMaterials[4].getMolten(144 * 2), + GregtechItemList.Casing_Turbine_HP.get(1), + 20 * 5, + MaterialUtils.getVoltageForTier(5)); + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(18), + ItemList.LargeHPSteamTurbine.get(1), + CI.getPlate(6, 8), + CI.getScrew(6, 16), + CI.getGear(6, 4), + CI.getCircuit(6, 8) + }, + CI.tieredMaterials[6].getMolten(144 * 8), + GregtechItemList.Large_HPSteam_Turbine.get(1), + 20 * 60, + MaterialUtils.getVoltageForTier(6)); + + // Plasma + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(18), + ItemList.Casing_Turbine3.get(1), + CI.getPlate(6, 4), + CI.getScrew(6, 8), + }, + CI.tieredMaterials[5].getMolten(144 * 2), + GregtechItemList.Casing_Turbine_Plasma.get(1), + 20 * 5, + MaterialUtils.getVoltageForTier(6)); + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(18), + ItemList.LargePlasmaTurbine.get(1), + CI.getPlate(7, 8), + CI.getScrew(7, 16), + CI.getGear(7, 4), + CI.getCircuit(7, 8) + }, + CI.tieredMaterials[7].getMolten(144 * 8), + GregtechItemList.Large_Plasma_Turbine.get(1), + 20 * 60, + MaterialUtils.getVoltageForTier(7)); + } + + private static void multiSolarTower() { + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(17), + CI.getTieredGTPPMachineCasing(3, 4), + ALLOY.MARAGING250.getPlate(8), + ALLOY.MARAGING250.getBolt(8), + ALLOY.MARAGING250.getScrew(8), + CI.getCircuit(5, 8) + }, + CI.getTieredFluid(3, 144 * 16), + GregtechItemList.Industrial_Solar_Tower.get(1), + 20 * 30, + MaterialUtils.getVoltageForTier(4)); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(17), + ALLOY.MARAGING350.getFrameBox(1), + ALLOY.STAINLESS_STEEL.getPlate(4), + ALLOY.MARAGING350.getScrew(8) + }, + CI.getTieredFluid(3, 144 * 4), + GregtechItemList.Casing_SolarTower_Structural.get(1), + 20 * 30, + MaterialUtils.getVoltageForTier(3)); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(17), + ALLOY.MARAGING250.getFrameBox(1), + ALLOY.STAINLESS_STEEL.getPlate(4), + ALLOY.MARAGING250.getBolt(16), + ELEMENT.getInstance().ALUMINIUM.getScrew(8) + }, + CI.getTieredFluid(3, 144 * 4), + GregtechItemList.Casing_SolarTower_SaltContainment.get(1), + 20 * 30, + MaterialUtils.getVoltageForTier(3)); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(17), + ALLOY.MARAGING250.getFrameBox(1), + ALLOY.STEEL_BLACK.getPlate(4), + ALLOY.MARAGING250.getScrew(8) + }, + CI.getAlternativeTieredFluid(3, 144 * 4), + GregtechItemList.Casing_SolarTower_HeatContainment.get(1), + 20 * 30, + MaterialUtils.getVoltageForTier(3)); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(17), + CI.getTieredGTPPMachineCasing(2, 1), + CI.getPlate(3, 2), + CI.getGear(3, 4), + CI.getElectricMotor(3, 2), + CI.getCircuit(3, 4) + }, + CI.getTertiaryTieredFluid(3, 144 * 4), + GregtechItemList.Solar_Tower_Reflector.get(1), + 20 * 60, + MaterialUtils.getVoltageForTier(3)); + } + + private static void multiElementalDuplicator() { + + CORE.RA.addAssemblylineRecipe( + ItemList.Machine_IV_Replicator.get(1), + 20 * 60 * 60 * 12, + new Object[] { + CI.getTieredMachineHull(7, 4), + CI.getFieldGenerator(5, GTNH ? 32 : 16), + CI.getElectricMotor(7, GTNH ? 32 : 16), + CI.getElectricPiston(7, GTNH ? 16 : 4), + CI.getEnergyCore(6, GTNH ? 8 : 2), + CI.getPlate(7, GTNH ? 32 : 16), + CI.getScrew(7, GTNH ? 64 : 32), + CI.getBolt(6, GTNH ? 64 : 32), + CI.getTieredComponent(OrePrefixes.rod, 6, GTNH ? 20 : 10), + new Object[] {CI.getTieredCircuitOreDictName(7), 20}, + ItemList.Tool_DataOrb.get(32), + GregtechItemList.Laser_Lens_Special.get(1) + }, + new FluidStack[] { + CI.getTieredFluid(7, 144 * 32), + CI.getAlternativeTieredFluid(6, 144 * 16), + CI.getTertiaryTieredFluid(6, 144 * 16), + ALLOY.BABBIT_ALLOY.getFluidStack(128 * 144), + }, + GregtechItemList.Controller_ElementalDuplicator.get(1), + 20 * 60 * 60 * (GTNH ? 2 : 1), + (int) MaterialUtils.getVoltageForTier(7)); + + CORE.RA.addAssemblylineRecipe( + GregtechItemList.Modulator_III.get(1), + 20 * 60 * 60 * 4, + new Object[] { + CI.getTieredGTPPMachineCasing(7, 2), + CI.getFieldGenerator(4, GTNH ? 8 : 4), + CI.getEnergyCore(4, GTNH ? 8 : 2), + CI.getPlate(7, GTNH ? 16 : 8), + CI.getScrew(6, GTNH ? 32 : 16), + CI.getBolt(6, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.rod, 5, GTNH ? 32 : 16), + new Object[] {CI.getTieredCircuitOreDictName(6), 32}, + ItemList.Tool_DataOrb.get(32), + }, + new FluidStack[] { + CI.getTieredFluid(6, 144 * 16), + CI.getAlternativeTieredFluid(5, 144 * 8), + CI.getTertiaryTieredFluid(5, 144 * 8), + ALLOY.BABBIT_ALLOY.getFluidStack(64 * 144), + }, + GregtechItemList.Hatch_Input_Elemental_Duplicator.get(1), + 20 * 60 * 60 * (GTNH ? 4 : 2), + (int) MaterialUtils.getVoltageForTier(6)); + + CORE.RA.addAssemblylineRecipe( + GregtechItemList.ResonanceChamber_III.get(1), + 20 * 60 * 60 * 2, + new Object[] { + CI.getTieredMachineHull(6, 5), + CI.getFieldGenerator(3, GTNH ? 32 : 16), + CI.getEnergyCore(2, GTNH ? 8 : 2), + CI.getPlate(7, GTNH ? 8 : 4), + CI.getScrew(7, GTNH ? 8 : 4), + CI.getBolt(6, GTNH ? 16 : 8), + CI.getTieredComponent(OrePrefixes.rod, 5, GTNH ? 8 : 4), + new Object[] {CI.getTieredCircuitOreDictName(5), 4}, + ItemList.Tool_DataStick.get(4), + }, + new FluidStack[] { + CI.getTieredFluid(5, 144 * 16), + CI.getAlternativeTieredFluid(4, 144 * 8), + CI.getTertiaryTieredFluid(4, 144 * 8), + ALLOY.BABBIT_ALLOY.getFluidStack(16 * 144), + }, + GregtechItemList.Casing_ElementalDuplicator.get(1), + 20 * 60 * (GTNH ? 20 : 10), + (int) MaterialUtils.getVoltageForTier(6)); + } + + private static void resonanceChambers() { + int aFieldTier = 1; + int aCasingTier = 4; + for (int i = 0; i < 4; i++) { + RecipeUtils.addShapedRecipe( + CI.getDoublePlate(aCasingTier, 1), + CI.getFieldGenerator(aFieldTier, 1), + CI.getDoublePlate(aCasingTier, 1), + CI.getFieldGenerator(aFieldTier, 1), + CI.getTieredMachineCasing(aCasingTier), + CI.getFieldGenerator(aFieldTier, 1), + CI.getDoublePlate(aCasingTier, 1), + CI.getFieldGenerator(aFieldTier, 1), + CI.getDoublePlate(aCasingTier, 1), + ItemUtils.simpleMetaStack(ModBlocks.blockSpecialMultiCasings2, i, 1)); + aCasingTier++; + aFieldTier++; + } + } + + private static void modulators() { + int aCasingTier = 4; + for (int i = 4; i < 8; i++) { + RecipeUtils.addShapedRecipe( + CI.getTieredCircuitOreDictName(aCasingTier), + CI.getPlate(aCasingTier, 1), + CI.getTieredCircuitOreDictName(aCasingTier), + CI.getPlate(aCasingTier, 1), + CI.getTieredMachineCasing(aCasingTier), + CI.getPlate(aCasingTier, 1), + CI.getTieredCircuitOreDictName(aCasingTier), + CI.getPlate(aCasingTier, 1), + CI.getTieredCircuitOreDictName(aCasingTier), + ItemUtils.simpleMetaStack(ModBlocks.blockSpecialMultiCasings2, i, 1)); + aCasingTier++; + } + } + + private static void zyngen() { + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(6), + CI.getTieredMachineHull(4), + ItemList.Machine_IV_AlloySmelter.get(1), + CI.getGear(3, 16), + CI.getBolt(3, 64), + CI.getPlate(4, 16) + }, + CI.getAlternativeTieredFluid(4, 144 * 8), + GregtechItemList.Industrial_AlloySmelter.get(1), + 20 * 30, + MaterialUtils.getVoltageForTier(4)); + } + + private static void chemPlant() { GT_ModHandler.addCraftingRecipe( - GregtechItemList.Casing_Machine_Custom_1.get(2L, new Object[0]), - CI.bits, - new Object[]{ - "PhP", - "PFP", - "PwP", - 'P', - OrePrefixes.plate.get(Materials.Bronze), - 'F', - OrePrefixes.frameGt.get(Materials.Bronze) - } - ); - - GT_ModHandler.addCraftingRecipe( - GregtechItemList.Casing_Machine_Custom_2.get(2L, new Object[0]), - CI.bits, - new Object[]{ - "PPP", - "hFw", - "PPP", - 'P', - OrePrefixes.plate.get(Materials.Aluminium), - 'F', - OrePrefixes.frameGt.get(Materials.Aluminium) - } - ); - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedBioCircuit(19), - CI.getTieredGTPPMachineCasing(1, 6), - CI.getTieredComponentOfMaterial(Materials.Steel, OrePrefixes.gearGt, 6), - CI.getTieredComponentOfMaterial(Materials.Aluminium, OrePrefixes.plate, 32), - CI.getTieredComponentOfMaterial(Materials.CobaltBrass, OrePrefixes.dust, 16), - CI.getTieredComponent(OrePrefixes.frameGt, 2, 4), - }, - ALLOY.STEEL.getFluidStack(2 * (144 * 4)), - GregtechItemList.ChemicalPlant_Controller.get(1), - 120 * 20, - MaterialUtils.getVoltageForTier(2)); - - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedBioCircuit(15), - CI.getTieredGTPPMachineCasing(1, 2), - ItemList.Hatch_Input_Bus_MV.get(1), - CI.getTieredComponentOfMaterial(Materials.Bronze, OrePrefixes.gearGt, 8), - CI.getTieredComponentOfMaterial(Materials.Lead, OrePrefixes.plate, 48), - CI.getTieredComponentOfMaterial(Materials.SolderingAlloy, OrePrefixes.wireFine, 16), - }, - ALLOY.BRONZE.getFluidStack(2 * (144 * 4)), - GregtechItemList.Bus_Catalysts.get(1), - 60 * 20, - MaterialUtils.getVoltageForTier(2)); - - } - - private static void algaeFarm() { - - // Give the shitty algae a use :) - CORE.RA.addDistilleryRecipe( - ItemUtils.getSimpleStack(AgriculturalChem.mAlgaeBiosmass, 32), - null, - null, - ItemUtils.getSimpleStack(AgriculturalChem.mGreenAlgaeBiosmass, 4), - 20 * 15, - 16, - false); - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedBioCircuit(21), - CI.getTieredGTPPMachineCasing(0, 4), - CI.getTieredComponentOfMaterial(Materials.Iron, OrePrefixes.rod, 12), - CI.getTieredComponentOfMaterial(Materials.Wood, OrePrefixes.plate, 32), - CI.getTieredComponentOfMaterial(Materials.Bronze, OrePrefixes.bolt, 16), - CI.getTieredComponentOfMaterial(Materials.Redstone, OrePrefixes.dust, 32), - }, - ALLOY.POTIN.getFluidStack(2 * (144 * 4)), - GregtechItemList.AlgaeFarm_Controller.get(1), - 60 * 20, - MaterialUtils.getVoltageForTier(1)); - - - } - - private static void distillus() { - - CORE.RA.addChemicalPlantRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(19), - ItemList.Distillation_Tower.get(2), - GregtechItemList.GTPP_Casing_IV.get(16), - CI.getTieredComponent(OrePrefixes.circuit, 6, 8) - }, - new FluidStack[] { - ALLOY.AQUATIC_STEEL.getFluidStack(144 * 32), - ALLOY.BABBIT_ALLOY.getFluidStack(144 * 16), - ALLOY.BRONZE.getFluidStack(144 * 64), - ALLOY.KANTHAL.getFluidStack(144 * 16), - }, - new ItemStack[] { - GregtechItemList.Machine_Adv_DistillationTower.get(1) - }, - new FluidStack[] { - - }, - 20 * 600, - MaterialUtils.getVoltageForTier(6), - 5); - - } - - private static void chunkloaders() { - - ItemStack aOutputs[] = new ItemStack[] { - GregtechItemList.GT_Chunkloader_HV.get(1L), - GregtechItemList.GT_Chunkloader_IV.get(1L), - GregtechItemList.GT_Chunkloader_ZPM.get(1L), - }; - - int aIndex = 0; - - for (int i=3;i<8;i++) { - if (i == 4 || i == 6) { - continue; - } - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(21), - CI.getElectricPiston(i, 10), - CI.getFieldGenerator(i + 1, 6), - CI.getPlate(i, 16), - CI.getTransmissionComponent(i - 1, 8), - CI.getTieredComponent(OrePrefixes.cableGt08, i, 16) - }, - ALLOY.EGLIN_STEEL.getFluidStack(i * (144 * 4)), - aOutputs[aIndex++].copy(), - 300 * 20, - MaterialUtils.getVoltageForTier(i)); - } - - - } - - private static void overflowValveCovers() { - ItemStack aOutputs[] = new ItemStack[] { - GregtechItemList.Cover_Overflow_ULV.get(1L), - GregtechItemList.Cover_Overflow_LV.get(1L), - GregtechItemList.Cover_Overflow_MV.get(1L), - GregtechItemList.Cover_Overflow_HV.get(1L), - GregtechItemList.Cover_Overflow_EV.get(1L), - GregtechItemList.Cover_Overflow_IV.get(1L), - }; - - for (int i=0;i<6;i++) { - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedBioCircuit(19), - CI.getElectricPump(i, 2), - CI.getElectricMotor(i, 2), - CI.getPlate(i, 4) - }, - FluidUtils.getWater((i+1) * 750), - aOutputs[i].copy(), - 20 * 20, - MaterialUtils.getVoltageForTier(i)); - } - - } - - private static void tieredMachineHulls() { - - GregtechItemList[] aHulls = new GregtechItemList[] { - GregtechItemList.GTPP_Casing_ULV, - GregtechItemList.GTPP_Casing_LV, - GregtechItemList.GTPP_Casing_MV, - GregtechItemList.GTPP_Casing_HV, - GregtechItemList.GTPP_Casing_EV, - GregtechItemList.GTPP_Casing_IV, - GregtechItemList.GTPP_Casing_LuV, - GregtechItemList.GTPP_Casing_ZPM, - GregtechItemList.GTPP_Casing_UV, - GregtechItemList.GTPP_Casing_MAX - }; - - for (int i=0;i<10;i++) { - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedBioCircuit(20), - CI.getTieredMachineCasing(i), - CI.getPlate(i, 8), - CI.getGear(i, 2), - CI.getTieredComponent(OrePrefixes.cableGt02, i, 4), - CI.getTieredComponent(OrePrefixes.circuit, i, 2) - }, - CI.getAlternativeTieredFluid(i, 144 * (i+1) * 2), - aHulls[i].get(1), - 20 * 20, - MaterialUtils.getVoltageForTier(i)); - } - - } - - private static void initModItems(){ - if (LoadedMods.IndustrialCraft2){ - IC2MFE = ItemUtils.getItemStackWithMeta(LoadedMods.IndustrialCraft2, "IC2:blockElectric", "IC2_MFE", 1, 1); - IC2MFSU = ItemUtils.getItemStackWithMeta(LoadedMods.IndustrialCraft2, "IC2:blockElectric", "IC2_MFSU", 2, 1); - } - if (LoadedMods.Gregtech){ - - //Lava Boiler - boiler_Coal = ItemList.Machine_Bronze_Boiler.get(1); - - //IV MACHINES - if (!GTNH){ - EV_MACHINE_Electrolyzer = ItemList.Machine_EV_Electrolyzer.get(1); - EV_MACHINE_BendingMachine= ItemList.Machine_EV_Bender.get(1); - EV_MACHINE_Wiremill= ItemList.Machine_EV_Wiremill.get(1); - HV_MACHINE_Macerator= ItemList.Machine_HV_Macerator.get(1); - EV_MACHINE_Macerator= ItemList.Machine_EV_Macerator.get(1); - EV_MACHINE_MassFabricator= ItemList.Machine_EV_Massfab.get(1); - EV_MACHINE_Centrifuge= ItemList.Machine_EV_Centrifuge.get(1); - EV_MACHINE_Cutter = ItemList.Machine_EV_Cutter.get(1); - EV_MACHINE_Extruder = ItemList.Machine_EV_Extruder.get(1); - EV_MACHINE_Sifter = ItemList.Machine_HV_Sifter.get(1); - EV_MACHINE_ThermalCentrifuge = ItemList.Machine_EV_ThermalCentrifuge.get(1); - EV_MACHINE_OreWasher = ItemList.Machine_EV_OreWasher.get(1); - EV_MACHINE_AlloySmelter = ItemList.Machine_EV_AlloySmelter.get(1); - EV_MACHINE_Mixer = ItemList.Machine_EV_Mixer.get(1); - } - //Balanced opposites - else { - EV_MACHINE_Electrolyzer = ItemList.Machine_IV_Electrolyzer.get(1); - EV_MACHINE_BendingMachine= ItemList.Machine_IV_Bender.get(1); - EV_MACHINE_Wiremill= ItemList.Machine_IV_Wiremill.get(1); - HV_MACHINE_Macerator= ItemList.Machine_EV_Macerator.get(1); - EV_MACHINE_Macerator= ItemList.Machine_IV_Macerator.get(1); - EV_MACHINE_MassFabricator= CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK ? ItemUtils.getValueOfItemList("Machine_LuV_Massfab", ItemList.Machine_IV_Massfab).get(1) : ItemList.Machine_IV_Massfab.get(1); - EV_MACHINE_Centrifuge= ItemList.Machine_IV_Centrifuge.get(1); - EV_MACHINE_Cutter = ItemList.Machine_IV_Cutter.get(1); - EV_MACHINE_Extruder = ItemList.Machine_IV_Extruder.get(1); - EV_MACHINE_Sifter = ItemList.Machine_HV_Sifter.get(1); - EV_MACHINE_ThermalCentrifuge = ItemList.Machine_IV_ThermalCentrifuge.get(1); - EV_MACHINE_OreWasher = ItemList.Machine_IV_OreWasher.get(1); - EV_MACHINE_AlloySmelter = ItemList.Machine_IV_AlloySmelter.get(1); - EV_MACHINE_Mixer = ItemList.Machine_IV_Mixer.get(1); - } - - - - } - if (CORE.ConfigSwitches.enableMultiblock_IndustrialCokeOven){ - if(LoadedMods.Railcraft){ - //Misc - INPUT_RCCokeOvenBlock = ItemUtils.getItemStackWithMeta(LoadedMods.Railcraft, "Railcraft:machine.alpha", "Coke_Oven_RC", 7, 1); - } - if(LoadedMods.ImmersiveEngineering){ - //Misc - INPUT_IECokeOvenBlock = ItemUtils.getItemStackWithMeta(LoadedMods.ImmersiveEngineering, "ImmersiveEngineering:stoneDecoration", "Coke_Oven_IE", 1, 1); - } - } - runModRecipes(); - } - - private static void runModRecipes(){ - if (LoadedMods.Gregtech){ - - //Computer Cube - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - ItemUtils.getSimpleStack(CI.getDataOrb(), 4 * (GTNH ? 2 : 1)), - ItemList.Cover_Screen.get(4), - CI.machineHull_IV, - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(7), 2) - }, - ELEMENT.getInstance().TANTALUM.getFluidStack(144 * 16), - GregtechItemList.Gregtech_Computer_Cube.get(1), - 60 * 20 * 3, - 8000); - - //Circuit programmer - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - ItemUtils.getSimpleStack(CI.robotArm_LV, 4 * (GTNH ? 2 : 1)), - ItemList.Cover_Controller.get(1, CI.electricMotor_MV), - CI.machineHull_MV, - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(1), 2), - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(2), 2) - }, - ELEMENT.getInstance().IRON.getFluidStack(144 * 4), - ItemUtils.getSimpleStack(ModBlocks.blockCircuitProgrammer), - 60 * 10 * 1, - 30); - - //Lead Lined Chest - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.machineHull_LV, - ItemUtils.getItemStackOfAmountFromOreDict("plateRubber", 32), - ItemUtils.getItemStackOfAmountFromOreDict("plateDenseLead", 9), - ItemUtils.getSimpleStack(Blocks.chest) - }, - ELEMENT.getInstance().LEAD.getFluidStack(144 * 16), - ItemUtils.getSimpleStack(ModBlocks.blockDecayablesChest), - 60 * 10 * 3, - 60); - - //RTG - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - ItemUtils.getItemStackWithMeta(true, "IC2:blockGenerator:6", "IC2-RTG", 6, 1), - ALLOY.NITINOL_60.getPlate(GTNH ? 32 : 8), - ALLOY.MARAGING350.getGear(GTNH ? 16 : 4), - ItemUtils.getSimpleStack(GTNH ? CI.fieldGenerator_IV : CI.fieldGenerator_EV, 8 ), - ItemUtils.getItemStackOfAmountFromOreDict("wireFinePlatinum", GTNH ? 64 : 32), - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(GTNH ? 7 : 6), GTNH ? 5 : 4) - }, - ALLOY.NIOBIUM_CARBIDE.getFluidStack(144 * 16), - GregtechItemList.RTG.get(1), - 60 * 20 * 10, - 8000); - - // Super Jukebox - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.machineHull_LV, - ItemUtils.getItemStackOfAmountFromOreDict("circuitBasic", 4), - ItemUtils.getItemStackOfAmountFromOreDict("plateTumbaga", 8), - ItemUtils.getSimpleStack(Blocks.jukebox) - }, - ELEMENT.getInstance().COPPER.getFluidStack(144 * 2), - ItemUtils.getSimpleStack(ModBlocks.blockCustomJukebox), - 20 * 30, - 30); - - ItemStack aFluidRegulator1 = ItemUtils.getValueOfItemList("FluidRegulator_MV",GTNH ? 4 : 2, ItemList.Electric_Pump_HV); - ItemStack aFluidRegulator2 = ItemUtils.getValueOfItemList("FluidRegulator_IV", GTNH ? 4 : 2, ItemUtils.getValueOfItemList("Electric_Pump_LuV", GTNH ? 8 : 4, ItemList.Electric_Pump_IV)); - - //Poo Collector - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.machineHull_MV, - aFluidRegulator1, - CI.getTieredComponent(OrePrefixes.pipeMedium, 2, GTNH ? 4 : 2), - ALLOY.EGLIN_STEEL.getPlate(GTNH ? 8 : 4), - ALLOY.POTIN.getScrew(GTNH ? 12 : 6) - }, - ALLOY.TUMBAGA.getFluidStack(144 * 4), - ItemUtils.getSimpleStack(ModBlocks.blockPooCollector), - 20 * 60, - 30); - - //Adv. Poo Collector - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getTieredMachineHull(-1), - ItemUtils.getSimpleStack(ModBlocks.blockPooCollector), - aFluidRegulator2, - CI.getTieredComponent(OrePrefixes.pipeHuge, 6, GTNH ? 8 : 4), - CI.getTieredComponent(OrePrefixes.screw, 6, GTNH ? 32 : 16) - }, - CI.getAlternativeTieredFluid(5, 144 * 9), - ItemUtils.getSimpleStack(ModBlocks.blockPooCollector, 8, 1), - 20 * 60 * 5, - 500); - - - //Basic Steam Turbine - RecipeUtils.addShapedGregtechRecipe( - CI.getTieredComponent(OrePrefixes.pipeSmall, 0, 1), "circuitPrimitive", CI.getTieredComponent(OrePrefixes.pipeSmall, 0, 1), - ALLOY.TUMBAGA.getRotor(1), CI.machineCasing_ULV, ALLOY.TUMBAGA.getRotor(1), - CI.getElectricMotor(0, 1), "cableGt01RedAlloy", CI.getElectricMotor(0, 1), - GregtechItemList.Generator_Steam_Turbine_ULV.get(1)); - - //Basic Gas Turbine - RecipeUtils.addShapedGregtechRecipe( - "circuitPrimitive", ALLOY.TUMBAGA.getRotor(1), "circuitPrimitive", - ALLOY.TUMBAGA.getRotor(1), CI.machineCasing_ULV, ALLOY.TUMBAGA.getRotor(1), - CI.getElectricMotor(0, 1), "cableGt01RedAlloy", CI.getElectricMotor(0, 1), - GregtechItemList.Generator_Gas_Turbine_ULV.get(1)); - - //Basic Combustion Turbine - RecipeUtils.addShapedGregtechRecipe( - CI.getElectricPiston(0, 1), "circuitPrimitive", CI.getElectricPiston(0, 1), - CI.getElectricMotor(0, 1), CI.machineCasing_ULV, CI.getElectricMotor(0, 1), - ALLOY.TUMBAGA.getGear(1), "cableGt01RedAlloy", ALLOY.TUMBAGA.getGear(1), - GregtechItemList.Generator_Diesel_ULV.get(1)); - - - - //Steam Condenser - if (CORE.ConfigSwitches.enableMachine_SteamConverter ){ - RECIPE_SteamCondenser = GregtechItemList.Condensor_MAX.get(1); - RecipeUtils.addShapedGregtechRecipe( - pipeLargeCopper, pipeHugeSteel, pipeLargeCopper, - plateEnergeticAlloy, CI.electricPump_HV, plateEnergeticAlloy, - plateEnergeticAlloy, pipeLargeCopper, plateEnergeticAlloy, - RECIPE_SteamCondenser); - } - - ItemStack aBronzeBricks = ItemUtils.simpleMetaStack(GregTech_API.sBlockCasings1, 10, 1); - // Steam Macerator Multi - RecipeUtils.addShapedGregtechRecipe( - aBronzeBricks, "gemDiamond", aBronzeBricks, - "craftingPiston", ALLOY.TUMBAGA.getFrameBox(1), "craftingPiston", - aBronzeBricks, "gemDiamond", aBronzeBricks, - GregtechItemList.Controller_SteamMaceratorMulti.get(1)); - // Steam Compressor Multi - RecipeUtils.addShapedGregtechRecipe( - aBronzeBricks, "craftingPiston", aBronzeBricks, - ALLOY.TUMBAGA.getGear(1), ALLOY.TUMBAGA.getFrameBox(1), ALLOY.TUMBAGA.getGear(1), - aBronzeBricks, "craftingPiston", aBronzeBricks, - GregtechItemList.Controller_SteamCompressorMulti.get(1)); - - // Steam Hatch - RecipeUtils.addShapedGregtechRecipe( - "plateBronze", "pipeMediumBronze", "plateBronze", - "plateBronze", GregtechItemList.GT_FluidTank_ULV.get(1), "plateBronze", - "plateBronze", "pipeMediumBronze", "plateBronze", - GregtechItemList.Hatch_Input_Steam.get(1)); - - // Steam Input Bus - RecipeUtils.addShapedGregtechRecipe( - "plateBronze", ALLOY.TUMBAGA.getPlate(1), "plateBronze", - "plateTin", ItemUtils.getSimpleStack(Blocks.hopper), "plateTin", - "plateBronze", ALLOY.TUMBAGA.getPlate(1), "plateBronze", - GregtechItemList.Hatch_Input_Bus_Steam.get(1)); - - // Steam Output Bus - RecipeUtils.addShapedGregtechRecipe( - "plateBronze", "plateTin", "plateBronze", - ALLOY.TUMBAGA.getPlate(1), ItemUtils.getSimpleStack(Blocks.hopper), ALLOY.TUMBAGA.getPlate(1), - "plateBronze", "plateTin", "plateBronze", - GregtechItemList.Hatch_Output_Bus_Steam.get(1)); - - - //RF Convertor - if (LoadedMods.CoFHCore && CORE.ConfigSwitches.enableMachine_RF_Convetor){ - RecipeUtils.addShapedGregtechRecipe( - CI.getPlate(4, 1), CI.getTieredCircuitOreDictName(5), CI.getPlate(4, 1), - CI.getTransmissionComponent(3, 1), CI.getTieredGTPPMachineCasing(4, 1), CI.getTransmissionComponent(3, 1), - CI.getPlate(4, 1), plateEnergeticAlloy, CI.getPlate(4, 1), - GregtechItemList.Energy_Buffer_RF_Convertor.get(1)); - } - - // Egg Box - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(8), - CI.getTieredMachineHull(3), - ItemUtils.getSimpleStack(Items.egg, 64), - ItemUtils.getSimpleStack(ModItems.itemRope, 32), - CI.getPlate(4, GTNH ? 16 : 8) - }, - FluidUtils.getFluidStack("mobessence", 4096), - ItemUtils.getSimpleStack(ModBlocks.blockEggBox, 1), - 20 * 60, - 480); - - //Flask Configurator - if (Meta_GT_Proxy.sDoesVolumetricFlaskExist) { - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(8), - CI.getTieredMachineHull(2), - ItemUtils.getSimpleStack(ModBlocks.blockCircuitProgrammer), - VolumetricFlaskHelper.getVolumetricFlask(8), - CI.getTieredComponent(OrePrefixes.pipeSmall, 2, GTNH ? 4 : 2), - CI.getPlate(2, GTNH ? 8 : 4) - }, - CI.getAlternativeTieredFluid(1, 144 * 8), - ItemUtils.getSimpleStack(ModBlocks.blockVolumetricFlaskSetter, 1), - 20 * 60, - 120); - } - - - if (CORE.ConfigSwitches.enableMultiblock_IronBlastFurnace){ - - RECIPE_IronBlastFurnace = GregtechItemList.Machine_Iron_BlastFurnace.get(1); - RECIPE_IronPlatedBricks = GregtechItemList.Casing_IronPlatedBricks.get(Casing_Amount); - - //Iron BF - RecipeUtils.addShapedGregtechRecipe( - "plateDoubleAnyIron", "craftingFurnace", "plateDoubleAnyIron", - boiler_Coal, CI.machineCasing_ULV, boiler_Coal, - "plateDoubleAnyIron", "bucketLava", "plateDoubleAnyIron", - RECIPE_IronBlastFurnace); - //Iron plated Bricks - RecipeUtils.addShapedGregtechRecipe( - "plateAnyIron", RECIPES_Tools.craftingToolHardHammer, "plateAnyIron", - "plateAnyIron", blockBricks, "plateAnyIron", - "plateAnyIron", RECIPES_Tools.craftingToolWrench, "plateAnyIron", - RECIPE_IronPlatedBricks); - - //Add recycle recipes for the Iron Plated Bricks - //GT_ModHandler.addPulverisationRecipe(RECIPE_IronPlatedBricks, ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustIron", 6), ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustClay", 2), true); - CORE.RA.addPulverisationRecipe( - RECIPE_IronPlatedBricks, - ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustIron", 6), - ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustClay", 2), - null); - GT_Values.RA.addArcFurnaceRecipe(RECIPE_IronPlatedBricks, new ItemStack[]{ItemUtils.getItemStackOfAmountFromOreDictNoBroken("ingotWroughtIron", 6), ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustAsh", 2)}, new int[]{0}, 32*20, 32); - } - - if (CORE.ConfigSwitches.enableMultiblock_IndustrialCentrifuge){ - //Industrial Centrifuge - RECIPE_IndustrialCentrifugeController = GregtechItemList.Industrial_Centrifuge.get(1); - RECIPE_IndustrialCentrifugeCasing = GregtechItemList.Casing_Centrifuge1.get(Casing_Amount); - - //Industrial Centrifuge - RecipeUtils.addShapedGregtechRecipe( - CI.circuitTier5, pipeHugeStainlessSteel, CI.circuitTier5, - CI.component_Plate[6], EV_MACHINE_Centrifuge, CI.component_Plate[6], - CI.component_Plate[8], CI.machineCasing_IV, CI.component_Plate[8], - RECIPE_IndustrialCentrifugeController); - //Centrifuge Casing - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[6], "stickTumbaga", CI.component_Plate[6], - CI.component_Plate[8], "stickTumbaga", CI.component_Plate[8], - CI.component_Plate[6], "stickTumbaga", CI.component_Plate[6], - RECIPE_IndustrialCentrifugeCasing); - } - - if (CORE.ConfigSwitches.enableMultiblock_IndustrialCokeOven){ - //Industrial Coke Oven - RECIPE_IndustrialCokeOvenController = GregtechItemList.Industrial_CokeOven.get(1); - RECIPE_IndustrialCokeOvenFrame = GregtechItemList.Casing_CokeOven.get(Casing_Amount); - RECIPE_IndustrialCokeOvenCasingA = GregtechItemList.Casing_CokeOven_Coil1.get(Casing_Amount); - RECIPE_IndustrialCokeOvenCasingB = GregtechItemList.Casing_CokeOven_Coil2.get(Casing_Amount); - - if (LoadedMods.Railcraft){ - //Industrial Coke Oven - RecipeUtils.addShapedGregtechRecipe( - plateCobalt, CI.circuitTier4, plateCobalt, - CI.machineCasing_HV, INPUT_RCCokeOvenBlock, CI.machineCasing_HV, - plateCobalt, CI.circuitTier5, plateCobalt, - RECIPE_IndustrialCokeOvenController); - } - if (LoadedMods.ImmersiveEngineering){ - //Industrial Coke Oven - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[8], CI.circuitTier4, CI.component_Plate[8], - CI.machineCasing_HV, INPUT_IECokeOvenBlock, CI.machineCasing_HV, - CI.component_Plate[8], CI.circuitTier3, CI.component_Plate[8], - RECIPE_IndustrialCokeOvenController); - } - //Coke Oven Frame Casing - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[7], CI.component_Rod[7], CI.component_Plate[7], - CI.component_Rod[7], "frameGtTantalloy61", CI.component_Rod[7], - CI.component_Plate[7], CI.component_Rod[7], CI.component_Plate[7], - RECIPE_IndustrialCokeOvenFrame); - //Coke Oven Coil 1 - RecipeUtils.addShapedGregtechRecipe( - plateBronze, plateBronze, plateBronze, - "frameGtBronze", CI.gearboxCasing_Tier_1, "frameGtBronze", - plateBronze, plateBronze, plateBronze, - RECIPE_IndustrialCokeOvenCasingA); - //Coke Oven Coil 2 - RecipeUtils.addShapedGregtechRecipe( - plateSteel, plateSteel, plateSteel, - "frameGtSteel", CI.gearboxCasing_Tier_2, "frameGtSteel", - plateSteel, plateSteel, plateSteel, - RECIPE_IndustrialCokeOvenCasingB); - } - - if (CORE.ConfigSwitches.enableMultiblock_IndustrialElectrolyzer){ - //Industrial Electrolyzer - RECIPE_IndustrialElectrolyzerController = GregtechItemList.Industrial_Electrolyzer.get(1); - RECIPE_IndustrialElectrolyzerFrame = GregtechItemList.Casing_Electrolyzer.get(Casing_Amount); - - //Electrolyzer Frame Casing - RecipeUtils.addShapedGregtechRecipe( - "platePotin", "stickLongChrome", "platePotin", - "stickLongPotin", "frameGtPotin", "stickLongPotin", - "platePotin", "stickLongPotin", "platePotin", - RECIPE_IndustrialElectrolyzerFrame); - //Industrial Electrolyzer - RecipeUtils.addShapedGregtechRecipe( - "plateStellite", CI.circuitTier5, "plateStellite", - CI.machineCasing_EV, EV_MACHINE_Electrolyzer, CI.machineCasing_EV, - "plateStellite", "rotorStellite", "plateStellite", - RECIPE_IndustrialElectrolyzerController); - } - - if (CORE.ConfigSwitches.enableMultiblock_IndustrialPlatePress){ - //Industrial Material Press - RECIPE_IndustrialMaterialPressController = GregtechItemList.Industrial_PlatePress.get(1); - RECIPE_IndustrialMaterialPressFrame = GregtechItemList.Casing_MaterialPress.get(Casing_Amount); - - //Material Press Frame Casing - RecipeUtils.addShapedGregtechRecipe( - "plateTitanium", "stickLongTumbaga", "plateTitanium", - "stickTantalloy60", "frameGtTumbaga", "stickTantalloy60", - "plateTitanium", "stickLongTumbaga", "plateTitanium", - RECIPE_IndustrialMaterialPressFrame); - //Industrial Material Press - RecipeUtils.addShapedGregtechRecipe( - "plateTitanium", CI.circuitTier5, "plateTitanium", - CI.machineCasing_EV, EV_MACHINE_BendingMachine, CI.machineCasing_EV, - "plateTitanium", CI.circuitTier5, "plateTitanium", - RECIPE_IndustrialMaterialPressController); - } - - if (CORE.ConfigSwitches.enableMultiblock_IndustrialMacerationStack){ - //Industrial Maceration Stack - RECIPE_IndustrialMacerationStackController = GregtechItemList.Industrial_MacerationStack.get(1); - RECIPE_IndustrialMacerationStackFrame = GregtechItemList.Casing_MacerationStack.get(Casing_Amount); - - //Maceration Frame Casing - RecipeUtils.addShapedGregtechRecipe( - "platePalladium", "platePalladium", "platePalladium", - "stickPlatinum", "frameGtInconel625", "stickPlatinum", - "platePalladium", "stickLongPalladium", "platePalladium", - RECIPE_IndustrialMacerationStackFrame); - //Industrial Maceration stack - RecipeUtils.addShapedGregtechRecipe( - "plateTungstenCarbide", EV_MACHINE_Macerator, "plateTungstenCarbide", - HV_MACHINE_Macerator, CI.circuitTier7, HV_MACHINE_Macerator, - "plateTungstenCarbide", CI.machineCasing_IV, "plateTungstenCarbide", - RECIPE_IndustrialMacerationStackController); - } - - if (CORE.ConfigSwitches.enableMultiblock_IndustrialWireMill){ - //Industrial Wire Factory - RECIPE_IndustrialWireFactoryController = GregtechItemList.Industrial_WireFactory.get(1); - RECIPE_IndustrialWireFactoryFrame = GregtechItemList.Casing_WireFactory.get(Casing_Amount); - - //Wire Factory Frame Casing - RecipeUtils.addShapedGregtechRecipe( - "plateBlueSteel", "stickBlueSteel", "plateBlueSteel", - "stickBlueSteel", "frameGtBlueSteel", "stickBlueSteel", - "plateBlueSteel", "stickBlueSteel", "plateBlueSteel", - RECIPE_IndustrialWireFactoryFrame); - //Industrial Wire Factory - RecipeUtils.addShapedGregtechRecipe( - "plateZeron100", CI.machineCasing_IV, "plateZeron100", - CI.circuitTier5, EV_MACHINE_Wiremill, CI.circuitTier5, - "plateZeron100", CI.machineCasing_IV, "plateZeron100", - RECIPE_IndustrialWireFactoryController); - } - - - - //Tiered Tanks - if (CORE.ConfigSwitches.enableMachine_FluidTanks){ - Logger.WARNING("Is New Horizons Loaded? "+GTNH); - if (!GTNH){ - - // Allows clearing stored fluids. - GregtechItemList[] aTanks = new GregtechItemList[] { - GregtechItemList.GT_FluidTank_ULV, GregtechItemList.GT_FluidTank_LV, GregtechItemList.GT_FluidTank_MV, - GregtechItemList.GT_FluidTank_HV, GregtechItemList.GT_FluidTank_EV, GregtechItemList.GT_FluidTank_IV, - GregtechItemList.GT_FluidTank_LuV, GregtechItemList.GT_FluidTank_ZPM, GregtechItemList.GT_FluidTank_UV, - GregtechItemList.GT_FluidTank_MAX}; - for (GregtechItemList aTank : aTanks) { - RecipeUtils.addShapedGregtechRecipe( - aTank.get(1), null, null, - null, null, null, - null, null, null, - aTank.get(1)); - } - - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[1], CI.component_Plate[1], CI.component_Plate[1], - CI.component_Plate[1], pipeTier1, CI.component_Plate[1], - CI.component_Plate[1], GregtechItemList.Fluid_Cell_144L.get(1), CI.component_Plate[1], - GregtechItemList.GT_FluidTank_ULV.get(1)); - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[2], CI.component_Plate[2], CI.component_Plate[2], - CI.component_Plate[2], pipeTier2, CI.component_Plate[2], - CI.component_Plate[2], CI.electricPump_LV, CI.component_Plate[2], - GregtechItemList.GT_FluidTank_LV.get(1)); - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[3], CI.component_Plate[3], CI.component_Plate[3], - CI.component_Plate[3], pipeTier3, CI.component_Plate[3], - CI.component_Plate[3], CI.electricPump_MV, CI.component_Plate[3], - GregtechItemList.GT_FluidTank_MV.get(1)); - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[4], CI.component_Plate[4], CI.component_Plate[4], - CI.component_Plate[4], pipeTier4, CI.component_Plate[4], - CI.component_Plate[4], CI.electricPump_HV, CI.component_Plate[4], - GregtechItemList.GT_FluidTank_HV.get(1)); - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[5], CI.component_Plate[5], CI.component_Plate[5], - CI.component_Plate[5], pipeTier5, CI.component_Plate[5], - CI.component_Plate[5], CI.electricPump_EV, CI.component_Plate[5], - GregtechItemList.GT_FluidTank_EV.get(1)); - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[6], CI.component_Plate[6], CI.component_Plate[6], - CI.component_Plate[6], pipeTier6, CI.component_Plate[6], - CI.component_Plate[6], CI.electricPump_IV, CI.component_Plate[6], - GregtechItemList.GT_FluidTank_IV.get(1)); - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[7], CI.component_Plate[7], CI.component_Plate[7], - CI.component_Plate[7], pipeTier7, CI.component_Plate[7], - CI.component_Plate[7], CI.electricPump_LuV, CI.component_Plate[7], - GregtechItemList.GT_FluidTank_LuV.get(1)); - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[8], CI.component_Plate[8], CI.component_Plate[8], - CI.component_Plate[8], pipeTier8, CI.component_Plate[8], - CI.component_Plate[8], CI.electricPump_ZPM, CI.component_Plate[8], - GregtechItemList.GT_FluidTank_ZPM.get(1)); - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[9], CI.component_Plate[9], CI.component_Plate[9], - CI.component_Plate[9], pipeTier9, CI.component_Plate[9], - CI.component_Plate[9], CI.electricPump_UV, CI.component_Plate[9], - GregtechItemList.GT_FluidTank_UV.get(1)); - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[10], CI.component_Plate[10], CI.component_Plate[10], - CI.component_Plate[10], pipeTier10, CI.component_Plate[10], - CI.component_Plate[10], CI.electricPump_MAX, CI.component_Plate[10], - GregtechItemList.GT_FluidTank_MAX.get(1)); - } - else { - - CI.component_Plate[1] = "plateTin"; - pipeTier1 = "pipeLargeClay"; - CI.circuitTier1 = ItemList.Circuit_Primitive.get(1); - CI.component_Plate[2] = "plateCopper"; - pipeTier2 = "pipeHugeClay"; - CI.component_Plate[3] = "plateBronze"; - pipeTier3 = "pipeMediumBronze"; - CI.component_Plate[4] = "plateIron"; - pipeTier4 = "pipeMediumSteel"; - CI.component_Plate[5] = "plateSteel"; - CI.component_Plate[6] = "plateRedstone"; - CI.component_Plate[7] = "plateAluminium"; - CI.component_Plate[8] = "plateDarkSteel"; - ItemStack waterBucket = ItemUtils.getSimpleStack(Items.water_bucket); - - // Allows clearing stored fluids. - GregtechItemList[] aTanks = new GregtechItemList[] {GregtechItemList.GT_FluidTank_ULV, GregtechItemList.GT_FluidTank_LV, GregtechItemList.GT_FluidTank_MV, GregtechItemList.GT_FluidTank_HV}; - for (GregtechItemList aTank : aTanks) { - RecipeUtils.addShapedGregtechRecipe( - aTank.get(1), null, null, - null, null, null, - null, null, null, - aTank.get(1)); - } - - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[1], CI.component_Plate[5], CI.component_Plate[1], - CI.component_Plate[4], pipeTier1, CI.component_Plate[4], - CI.component_Plate[4], waterBucket, CI.component_Plate[4], - GregtechItemList.GT_FluidTank_ULV.get(1)); - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[5], CI.component_Plate[4], CI.component_Plate[5], - CI.component_Plate[3], pipeTier2, CI.component_Plate[3], - CI.component_Plate[3], CI.electricPump_LV, CI.component_Plate[3], - GregtechItemList.GT_FluidTank_LV.get(1)); - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[8], CI.component_Plate[3], CI.component_Plate[8], - CI.component_Plate[5], pipeTier3, CI.component_Plate[5], - CI.component_Plate[5], CI.electricPump_LV, CI.component_Plate[5], - GregtechItemList.GT_FluidTank_MV.get(1)); - RecipeUtils.addShapedGregtechRecipe( - CI.circuitTier1, CI.component_Plate[7], CI.circuitTier1, - CI.component_Plate[8], pipeTier4, CI.component_Plate[8], - CI.circuitTier1, CI.electricPump_MV, CI.circuitTier1, - GregtechItemList.GT_FluidTank_HV.get(1)); - } - } - - if (CORE.ConfigSwitches.enableMultiblock_MultiTank){ - //Industrial Multi Tank - //RECIPE_IndustrialMultiTankController = GregtechItemList.Industrial_MultiTank.get(1); - RECIPE_IndustrialMultiTankFrame = GregtechItemList.Casing_MultitankExterior.get(Casing_Amount); - - //Industrial Multi Tank Casing - RecipeUtils.addShapedGregtechRecipe( - "stickGrisium", "plateGrisium", "stickGrisium", - "plateGrisium", "frameGtGrisium", "plateGrisium", - "plateGrisium", "plateGrisium", "plateGrisium", - RECIPE_IndustrialMultiTankFrame); - //Industrial Multi Tank - RecipeUtils.addShapedGregtechRecipe( - "pipeHugeTantalloy60", "gearGrisium", "pipeHugeTantalloy60", - CI.circuitTier4, RECIPE_IndustrialMultiTankFrame, CI.circuitTier4, - "plateDoubleGrisium", "rotorGrisium", "plateDoubleGrisium", - RECIPE_IndustrialMultiTankController); - } - //TODO - - //Semi-Fluid Generators - ItemStack[][] aSemiFluidInputs = new ItemStack[3][6]; - aSemiFluidInputs[0] = new ItemStack[]{ - CI.getNumberedBioCircuit(14), - CI.getTieredMachineHull(1, 1), - CI.getElectricPiston(1, GTNH ? 4 : 2), - CI.getTieredComponent(OrePrefixes.circuit, 1, GTNH ? 4 : 2), - CI.getPlate(1, GTNH ? 8 : 4), - CI.getGear(1, GTNH ? 4 : 2) - }; - aSemiFluidInputs[1] = new ItemStack[]{ - CI.getNumberedCircuit(14), - CI.getTieredMachineHull(2, 1), - CI.getElectricPiston(2, GTNH ? 4 : 2), - CI.getTieredComponent(OrePrefixes.circuit, 2, GTNH ? 4 : 2), - CI.getPlate(2, GTNH ? 8 : 4), - CI.getGear(2, GTNH ? 4 : 2) - }; - aSemiFluidInputs[2] = new ItemStack[]{ - CI.getNumberedAdvancedCircuit(14), - CI.getTieredMachineHull(3, 1), - CI.getElectricPiston(3, GTNH ? 4 : 2), - CI.getTieredComponent(OrePrefixes.circuit, 3, GTNH ? 4 : 2), - CI.getPlate(3, GTNH ? 8 : 4), - CI.getGear(3, GTNH ? 4 : 2) - }; - FluidStack[] aSemiFluidFluidInputs = new FluidStack[] { - ALLOY.BRONZE.getFluidStack(144 * 8), - ALLOY.STEEL.getFluidStack(144 * 8), - ELEMENT.getInstance().ALUMINIUM.getFluidStack(144 * 8), - }; - - //ItemUtils.simpleMetaStack("IC2:blockGenerator:7", 7, 1); - ItemStack[] aSemifluids = new ItemStack[] {GregtechItemList.Generator_SemiFluid_LV.get(1), GregtechItemList.Generator_SemiFluid_MV.get(1), GregtechItemList.Generator_SemiFluid_HV.get(1)}; - for (int o=0;o<3;o++) { - CORE.RA.addSixSlotAssemblingRecipe( - aSemiFluidInputs[o], - aSemiFluidFluidInputs[o], - aSemifluids[o], - 20 * 30, - MaterialUtils.getVoltageForTier(o+1)); - } - - if (CORE.ConfigSwitches.enableMultiblock_AlloyBlastSmelter){ - //Industrial Blast Smelter - RECIPE_IndustrialBlastSmelterController = GregtechItemList.Industrial_AlloyBlastSmelter.get(1); - RECIPE_IndustrialBlastSmelterFrame = GregtechItemList.Casing_BlastSmelter.get(Casing_Amount); - RECIPE_IndustrialBlastSmelterCoil = GregtechItemList.Casing_Coil_BlastSmelter.get(Casing_Amount); - - //Blast Smelter - RecipeUtils.addShapedGregtechRecipe( - "plateZirconiumCarbide", CI.circuitTier4, "plateZirconiumCarbide", - cableTier4, EV_MACHINE_AlloySmelter, cableTier4, - "plateZirconiumCarbide", CI.circuitTier3, "plateZirconiumCarbide", - RECIPE_IndustrialBlastSmelterController); - //Blast Smelter Frame Casing - RecipeUtils.addShapedGregtechRecipe( - "plateZirconiumCarbide", CI.component_Rod[5], "plateZirconiumCarbide", - CI.component_Rod[5], "frameGtTumbaga", CI.component_Rod[5], - "plateZirconiumCarbide", CI.component_Rod[5], "plateZirconiumCarbide", - RECIPE_IndustrialBlastSmelterFrame); - //Blast Smelter Coil - RecipeUtils.addShapedGregtechRecipe( - "plateStaballoy", "plateStaballoy", "plateStaballoy", - "frameGtStaballoy", CI.gearboxCasing_Tier_3, "frameGtStaballoy", - "plateStaballoy", "plateStaballoy", "plateStaballoy", - RECIPE_IndustrialBlastSmelterCoil); - } - - if (CORE.ConfigSwitches.enableMultiblock_MatterFabricator){ - //Industrial Matter Fabricator - RECIPE_IndustrialMatterFabController = GregtechItemList.Industrial_MassFab.get(1); - RECIPE_IndustrialMatterFabFrame = GregtechItemList.Casing_MatterFab.get(Casing_Amount); - RECIPE_IndustrialMatterFabCoil = GregtechItemList.Casing_MatterGen.get(Casing_Amount); - - //Matter Fabricator CPU - RecipeUtils.addShapedGregtechRecipe( - CI.getDoublePlate(8, 1), CI.circuitTier5, CI.getPlate(8, 1), - cableTier8, CI.machineCasing_LuV, cableTier8, - CI.getPlate(8, 1), CI.circuitTier5, CI.getPlate(8, 1), - RECIPE_IndustrialMatterFabController); - //Matter Fabricator Frame Casing - RecipeUtils.addShapedGregtechRecipe( - "plateNiobiumCarbide", CI.component_Rod[8], "plateNiobiumCarbide", - CI.component_Rod[8], "frameGtInconel690", CI.component_Rod[8], - "plateNiobiumCarbide", CI.component_Rod[8], "plateNiobiumCarbide", - RECIPE_IndustrialMatterFabFrame); - //Matter Fabricator Coil - RecipeUtils.addShapedGregtechRecipe( - CI.getPlate(6, 1), CI.getPlate(7, 1), CI.getPlate(6, 1), - "frameGtStellite", CI.machineCasing_UV, "frameGtStellite", - CI.getPlate(6, 1), CI.getPlate(7, 1), CI.getPlate(6, 1), - RECIPE_IndustrialMatterFabCoil); - } - - if (CORE.ConfigSwitches.enableMultiblock_IndustrialSifter){ - //Industrial Sieve - RECIPE_IndustrialSieveController = GregtechItemList.Industrial_Sifter.get(1); - RECIPE_IndustrialSieveFrame = GregtechItemList.Casing_Sifter.get(Casing_Amount); - RECIPE_IndustrialSieveGrate = GregtechItemList.Casing_SifterGrate.get(Casing_Amount); - - //Industrial Sieve - RecipeUtils.addShapedGregtechRecipe( - "plateEglinSteel", CI.circuitTier3, "plateEglinSteel", - cableTier4, EV_MACHINE_Sifter, cableTier4, - "plateEglinSteel", CI.circuitTier3, "plateEglinSteel", - RECIPE_IndustrialSieveController); - //Industrial Sieve Casing - RecipeUtils.addShapedGregtechRecipe( - "plateEglinSteel", "plateEglinSteel", "plateEglinSteel", - "plateEglinSteel", "frameGtTumbaga", "plateEglinSteel", - "plateEglinSteel", "plateEglinSteel", "plateEglinSteel", - RECIPE_IndustrialSieveFrame); - //Industrial Sieve Grate - RecipeUtils.addShapedGregtechRecipe( - "frameGtEglinSteel", "wireFineSteel", "frameGtEglinSteel", - "wireFineSteel", "wireFineSteel", "wireFineSteel", - "frameGtEglinSteel", "wireFineSteel", "frameGtEglinSteel", - RECIPE_IndustrialSieveGrate); - } - - if (CORE.ConfigSwitches.enableMultiblock_TreeFarmer){ - //Industrial Tree Farmer - RECIPE_TreeFarmController = GregtechItemList.Industrial_TreeFarm.get(1); - RECIPE_TreeFarmFrame = GregtechItemList.Casing_PLACEHOLDER_TreeFarmer.get(Casing_Amount); - //Industrial Tree Farm Controller - if (!GTNH) { - RecipeUtils.addShapedGregtechRecipe( - "plateEglinSteel", "rotorEglinSteel", "plateEglinSteel", - "cableGt02Steel", "pipeMediumSteel", "cableGt02Steel", - "plateEglinSteel", CI.machineCasing_MV, "plateEglinSteel", - RECIPE_TreeFarmController); - } - else { - RecipeUtils.addShapedGregtechRecipe( - ItemList.Field_Generator_IV.get(1), ALLOY.INCOLOY_MA956.getRotor(1), ItemList.Field_Generator_IV.get(1), - ALLOY.NITINOL_60.getPlate(1), GregtechItemList.GTPP_Casing_IV.get(1), ALLOY.NITINOL_60.getPlate(1), - ItemList.Field_Generator_IV.get(1), ALLOY.INCONEL_792.getComponentByPrefix(OrePrefixes.pipeMedium, 1), ItemList.Field_Generator_IV.get(1), - RECIPE_TreeFarmController); - } - //Industrial Tree Farm Frame - GT_Values.RA.addAssemblerRecipe( - new ItemStack[] { - GT_Utility.getIntegratedCircuit(2), - ALLOY.INCONEL_625.getFrameBox(1), - ALLOY.HASTELLOY_X.getComponentByPrefix(OrePrefixes.pipeTiny, 1), - ItemList.Electric_Pump_EV.get(2), - ItemList.HV_Coil.get(4), - ItemList.IC2_Plantball.get(8), - GT_OreDictUnificator.get(OrePrefixes.plank, Materials.Wood, 6), - }, - GT_ModHandler.getDistilledWater(8000), - RECIPE_TreeFarmFrame, - 60, - 1960 - ); - } - - if (CORE.ConfigSwitches.enableMachine_Tesseracts){ - //Tesseracts - RECIPE_TesseractGenerator = GregtechItemList.GT4_Tesseract_Generator.get(1); - RECIPE_TesseractTerminal = GregtechItemList.GT4_Tesseract_Terminal.get(1); - //Tesseract Generator - RecipeUtils.addShapedGregtechRecipe( - "plateTitanium","circuitMaster","plateTitanium", - "circuitMaster",ItemUtils.getSimpleStack(Blocks.ender_chest),"circuitMaster", - "plateTitanium",GregtechItemList.Gregtech_Computer_Cube.get(1),"plateTitanium", - RECIPE_TesseractGenerator); - //Tesseract Terminal - RecipeUtils.addShapedGregtechRecipe( - "plateTitanium","circuitElite","plateTitanium", - "circuitElite",ItemUtils.getSimpleStack(Blocks.ender_chest),"circuitElite", - "plateTitanium",CI.machineHull_EV,"plateTitanium", - RECIPE_TesseractTerminal); - } - - if (CORE.ConfigSwitches.enableMachine_SimpleWasher){ - ItemStack plateWrought = ItemUtils.getItemStackOfAmountFromOreDict("plateWroughtIron", 1); - ItemStack washerPipe; - - - if (CORE.ConfigSwitches.enableCustom_Pipes){ - washerPipe = ItemUtils.getItemStackOfAmountFromOreDict("pipeLargeClay", 1); - RecipeUtils.addShapedGregtechRecipe( - plateWrought, CI.electricPump_LV, plateWrought, - plateWrought, washerPipe, plateWrought, - plateWrought, CI.machineCasing_ULV, plateWrought, - GregtechItemList.SimpleDustWasher_ULV.get(1)); - } - //Add Recipe - washerPipe = ItemUtils.getItemStackOfAmountFromOreDict("pipeLargeCopper", 1); - RecipeUtils.addShapedGregtechRecipe( - plateWrought, CI.electricPump_LV, plateWrought, - plateWrought, washerPipe, plateWrought, - plateWrought, CI.machineCasing_ULV, plateWrought, - GregtechItemList.SimpleDustWasher_ULV.get(1)); - - int aSimpleWasherTier = 2; - int aSlot = 0; - ItemStack[][] aInputsForSimpleWashers = new ItemStack[4][6]; - - aInputsForSimpleWashers[0] = new ItemStack[] { - CI.getTieredMachineHull(2), - CI.getTieredComponent(OrePrefixes.screw, 2, GTNH ? 16 : 8), - CI.getTieredComponent(OrePrefixes.plate, 1, GTNH ? 8 : 4), - CI.getTieredComponent(OrePrefixes.rod, 2, GTNH ? 4 : 2), - CI.getTieredComponent(OrePrefixes.circuit, 2, GTNH ? 3 : 1), - - }; - aInputsForSimpleWashers[1] = new ItemStack[] { - CI.getTieredMachineHull(4), - CI.getTieredComponent(OrePrefixes.screw, 4, GTNH ? 24 : 12), - CI.getTieredComponent(OrePrefixes.plate, 3, GTNH ? 12 : 6), - CI.getTieredComponent(OrePrefixes.rod, 4, GTNH ? 6 : 3), - CI.getTieredComponent(OrePrefixes.circuit, 4, GTNH ? 4 : 2), - - }; - aInputsForSimpleWashers[2] = new ItemStack[] { - CI.getTieredMachineHull(6), - CI.getTieredComponent(OrePrefixes.screw, 6, GTNH ? 48 : 24), - CI.getTieredComponent(OrePrefixes.plate, 5, GTNH ? 16 : 8), - CI.getTieredComponent(OrePrefixes.rod, 6, GTNH ? 8 : 4), - CI.getTieredComponent(OrePrefixes.circuit, 6, GTNH ? 6 : 3), - - }; - aInputsForSimpleWashers[3] = new ItemStack[] { - CI.getTieredMachineHull(8), - CI.getTieredComponent(OrePrefixes.screw, 8, GTNH ? 64 : 32), - CI.getTieredComponent(OrePrefixes.plate, 7, GTNH ? 32 : 16), - CI.getTieredComponent(OrePrefixes.rod, 8, GTNH ? 10 : 5), - CI.getTieredComponent(OrePrefixes.circuit, 8, GTNH ? 8 : 4), - - }; - - - - - - - ItemStack[] aSimpleWashers = new ItemStack[] {GregtechItemList.SimpleDustWasher_MV.get(1), GregtechItemList.SimpleDustWasher_EV.get(1), GregtechItemList.SimpleDustWasher_LuV.get(1), GregtechItemList.SimpleDustWasher_UV.get(1)}; - for (int i=0;i<4;i++) { - - CORE.RA.addSixSlotAssemblingRecipe( - aInputsForSimpleWashers[aSlot], - CI.getTieredFluid(aSimpleWasherTier, 144 * aSimpleWasherTier), - aSimpleWashers[aSlot], - 20 * 15 * aSimpleWasherTier, - (int) GT_Values.V[aSimpleWasherTier]); - - aSimpleWasherTier += 2; - aSlot++; - } - } - - if (CORE.ConfigSwitches.enableMachine_Pollution && PollutionUtils.isPollutionEnabled()){ - - RecipeUtils.addShapedGregtechRecipe( - "plateCarbon", "plateCarbon", "plateCarbon", - "dustCarbon", "dustCarbon", "dustCarbon", - "plateCarbon", "plateCarbon", "plateCarbon", - ItemUtils.simpleMetaStack(ModItems.itemAirFilter, 0, 1)); - - RecipeUtils.addShapedGregtechRecipe( - "plateCarbon", "plateCarbon", "plateCarbon", - "cellLithiumPeroxide", "dustCarbon", "cellLithiumPeroxide", - "plateCarbon", "plateCarbon", "plateCarbon", - ItemUtils.simpleMetaStack(ModItems.itemAirFilter, 1, 1)); - - //Pollution Detector - RecipeUtils.addShapedGregtechRecipe( - "plateSteel", CI.sensor_LV, "plateSteel", - "plateSteel", CI.electricMotor_LV, "plateSteel", - CI.getTieredCircuit(1), CI.machineHull_LV, CI.getTieredCircuit(1), - GregtechItemList.Pollution_Detector.get(1)); - - //ULV - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[0], ItemUtils.simpleMetaStack(ModItems.itemAirFilter, 0, 1), CI.component_Plate[0], - CI.component_Plate[0], CI.electricMotor_ULV, CI.component_Plate[0], - CI.getTieredCircuit(0), CI.machineHull_ULV, CI.getTieredCircuit(0), - GregtechItemList.Pollution_Cleaner_ULV.get(1)); - //LV - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[1], ItemUtils.simpleMetaStack(ModItems.itemAirFilter, 0, 1), CI.component_Plate[1], - CI.component_Plate[1], CI.electricMotor_LV, CI.component_Plate[1], - CI.getTieredCircuit(1), CI.machineHull_LV, CI.getTieredCircuit(1), - GregtechItemList.Pollution_Cleaner_LV.get(1)); - //MV - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[2], ItemUtils.simpleMetaStack(ModItems.itemAirFilter, 0, 1), CI.component_Plate[2], - CI.component_Plate[2], CI.electricMotor_MV, CI.component_Plate[2], - CI.getTieredCircuit(2), CI.machineHull_MV, CI.getTieredCircuit(2), - GregtechItemList.Pollution_Cleaner_MV.get(1)); - //HV - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[3], ItemUtils.simpleMetaStack(ModItems.itemAirFilter, 0, 1), CI.component_Plate[3], - CI.component_Plate[3], CI.electricMotor_HV, CI.component_Plate[3], - CI.getTieredCircuit(3), CI.machineHull_HV, CI.getTieredCircuit(3), - GregtechItemList.Pollution_Cleaner_HV.get(1)); - //EV - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[4], ItemUtils.simpleMetaStack(ModItems.itemAirFilter, 0, 1), CI.component_Plate[4], - CI.component_Plate[4], CI.electricMotor_EV, CI.component_Plate[4], - CI.getTieredCircuit(4), CI.machineHull_EV, CI.getTieredCircuit(4), - GregtechItemList.Pollution_Cleaner_EV.get(1)); - //IV - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[5], ItemUtils.simpleMetaStack(ModItems.itemAirFilter, 1, 1), CI.component_Plate[5], - CI.component_Plate[5], CI.electricMotor_IV, CI.component_Plate[5], - CI.getTieredCircuit(5), CI.machineHull_IV, CI.getTieredCircuit(5), - GregtechItemList.Pollution_Cleaner_IV.get(1)); - //LuV - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[6], ItemUtils.simpleMetaStack(ModItems.itemAirFilter, 1, 1), CI.component_Plate[6], - CI.component_Plate[6], CI.electricMotor_LuV, CI.component_Plate[6], - CI.getTieredCircuit(6), CI.machineHull_LuV, CI.getTieredCircuit(6), - GregtechItemList.Pollution_Cleaner_LuV.get(1)); - //ZPM - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[7], ItemUtils.simpleMetaStack(ModItems.itemAirFilter, 1, 1), CI.component_Plate[7], - CI.component_Plate[7], CI.electricMotor_ZPM, CI.component_Plate[7], - CI.getTieredCircuit(7), CI.machineHull_ZPM, CI.getTieredCircuit(7), - GregtechItemList.Pollution_Cleaner_ZPM.get(1)); - //UV - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[8], ItemUtils.simpleMetaStack(ModItems.itemAirFilter, 1, 1), CI.component_Plate[8], - CI.component_Plate[8], CI.electricMotor_UV, CI.component_Plate[8], - CI.getTieredCircuit(8), CI.machineHull_UV, CI.getTieredCircuit(8), - GregtechItemList.Pollution_Cleaner_UV.get(1)); - //MAX - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[9], ItemUtils.simpleMetaStack(ModItems.itemAirFilter, 1, 1), CI.component_Plate[9], - CI.component_Plate[9], CI.electricMotor_MAX, CI.component_Plate[9], - CI.getTieredCircuit(9), CI.machineHull_MAX, CI.getTieredCircuit(9), - GregtechItemList.Pollution_Cleaner_MAX.get(1)); - - - } - - if (CORE.ConfigSwitches.enableMultiblock_ThermalBoiler){ - RECIPE_ThermalBoilerController = GregtechItemList.GT4_Thermal_Boiler.get(1); - RECIPE_ThermalBoilerCasing = GregtechItemList.Casing_ThermalContainment.get(GTNH ? 1 : 2); - ItemStack centrifugeHV = GTNH ? ItemList.Machine_IV_Centrifuge.get(1) : ItemList.Machine_EV_Centrifuge.get(1); - - RecipeUtils.addShapedGregtechRecipe( - "craftingGeothermalGenerator", centrifugeHV, "craftingGeothermalGenerator", - "gearGtTitanium", CI.getTieredCircuitOreDictName(6), "gearGtTitanium", - "craftingGeothermalGenerator", centrifugeHV, "craftingGeothermalGenerator", - RECIPE_ThermalBoilerController); - - RecipeUtils.addShapedGregtechRecipe( - "craftingGeothermalGenerator", centrifugeHV, "craftingGeothermalGenerator", - "gearGtTungstenSteel", CI.getTieredCircuitOreDictName(5), "gearGtTungstenSteel", - "craftingGeothermalGenerator", centrifugeHV, "craftingGeothermalGenerator", - RECIPE_ThermalBoilerController); - - RecipeUtils.addShapedGregtechRecipe( - ALLOY.MARAGING350.getPlate(1), "plateStainlessSteel", ALLOY.MARAGING350.getPlate(1), - "circuitAdvanced", CI.machineCasing_HV, "circuitAdvanced", - ALLOY.MARAGING350.getPlate(1), ALLOY.MARAGING350.getPlate(1), ALLOY.MARAGING350.getPlate(1), - RECIPE_ThermalBoilerCasing); - - //Lava Filter Recipe - CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - CI.getNumberedCircuit(18), - ItemUtils.getItemStackOfAmountFromOreDict("dustCarbon", GTNH ? 64 : 32), - ItemUtils.getItemStackOfAmountFromOreDict("wireFineSteel", GTNH ? 64 : 32), - ItemUtils.getItemStackOfAmountFromOreDict("ringTumbaga", GTNH ? 32 : 16), - ItemUtils.getItemStackOfAmountFromOreDict("foilCopper", GTNH ? 8 : 4), - ItemUtils.getItemStackWithMeta(LoadedMods.IndustrialCraft2, "IC2:itemPartCarbonMesh", "RawCarbonMesh", 0, 64), - - }, - CI.getTieredFluid(3, 144), - ItemUtils.getSimpleStack(ModItems.itemLavaFilter, GTNH ? 8 : 16), - 1600, - 240 - ); - } - - //Air Intake Hatch - ItemList FluidRegulator_IV = ItemUtils.getValueOfItemList("FluidRegulator_IV", ItemList.Pump_IV); - ItemStack aTieredFluidRegulator = CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK ? FluidRegulator_IV.get(1) : ItemList.Pump_IV.get(1); - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[6], ItemList.Casing_Grate.get(1), CI.component_Plate[6], - CI.component_Plate[6], CI.getFluidRegulator(5, 1), CI.component_Plate[6], - CI.getTieredCircuit(5), ItemList.Hatch_Input_IV.get(1), CI.getTieredCircuit(5), - GregtechItemList.Hatch_Air_Intake.get(1)); - - - RecipeUtils.addShapedGregtechRecipe( - CI.getPlate(6, 1), ItemList.Casing_Gearbox_Titanium.get(1), CI.getPlate(6, 1), - CI.getPlate(6, 1), CI.getFluidRegulator(5, 1), CI.getPlate(6, 1), - CI.getTieredCircuit(6), ItemList.Hatch_Input_IV.get(1), CI.getTieredCircuit(6), - GregtechItemList.Hatch_Reservoir.get(1)); - - RecipeUtils.addShapedGregtechRecipe( - CI.getPlate(7, 1), GregtechItemList.Hatch_Air_Intake.get(1), CI.getPlate(7, 1), - CI.getPlate(7, 1), CI.getFluidRegulator(7, 1), CI.getPlate(7, 1), - CI.getTieredCircuit(7), ItemList.Hatch_Input_ZPM.get(1), CI.getTieredCircuit(7), - GregtechItemList.Hatch_Air_Intake_Extreme.get(1)); - - if (CORE.ConfigSwitches.enableMultiblock_LiquidFluorideThoriumReactor){ - - //Thorium Reactor - RECIPE_LFTRController = GregtechItemList.ThoriumReactor.get(1); - RECIPE_LFTRInnerCasing = GregtechItemList.Casing_Reactor_II.get(1); //Zeron - RECIPE_LFTROuterCasing = GregtechItemList.Casing_Reactor_I.get(1); //Hastelloy - - ItemStack controlCircuit = ItemUtils.getSimpleStack(ModItems.itemCircuitLFTR); - if(!GTNH) { - RecipeUtils.addShapedGregtechRecipe( - controlCircuit, "cableGt12NaquadahAlloy", controlCircuit, - "plateDoubleHastelloyN", GregtechItemList.Gregtech_Computer_Cube.get(1), "plateDoubleHastelloyN", - "plateThorium232", CI.machineHull_EV, "plateThorium232", - RECIPE_LFTRController); - } else { - RecipeUtils.addShapedGregtechRecipe( - controlCircuit, "cableGt12Naquadah", controlCircuit, - "plateDoubleHastelloyN", GregtechItemList.Gregtech_Computer_Cube.get(1), "plateDoubleHastelloyN", - "plateThorium232", CI.machineHull_IV, "plateThorium232", - RECIPE_LFTRController); - } - RecipeUtils.addShapedGregtechRecipe( - "plateDoubleHastelloyC276", CI.craftingToolScrewdriver, "plateDoubleHastelloyC276", - "gearGtTalonite", CI.fieldGenerator_MV, "gearGtTalonite", - "plateDoubleHastelloyC276", CI.craftingToolHammer_Hard, "plateDoubleHastelloyC276", - RECIPE_LFTRInnerCasing); - - ItemStack IC2HeatPlate = ItemUtils.getItemStackFromFQRN("IC2:reactorPlatingHeat", 1); - RecipeUtils.addShapedGregtechRecipe( - "plateDoubleHastelloyN", IC2HeatPlate, "plateDoubleHastelloyN", - IC2HeatPlate, "frameGtHastelloyC276", IC2HeatPlate, - "plateDoubleHastelloyN", IC2HeatPlate, "plateDoubleHastelloyN", - RECIPE_LFTROuterCasing); - - //LFTR Control Circuit - CORE.RA.addSixSlotAssemblingRecipe(new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(6), 1), - CI.fieldGenerator_HV - }, - null, controlCircuit, 240*20, 500); - - - //Fission Fuel Plant - RecipeUtils.addShapedGregtechRecipe( - CI.getTieredCircuitOreDictName(5), CI.craftingToolSolderingIron, CI.getTieredCircuitOreDictName(5), - "plateDenseTungstenSteel", GregtechItemList.Gregtech_Computer_Cube.get(1), "plateDenseTungstenSteel", - "gearGtStellite", CI.machineHull_IV, "gearGtStellite", - GregtechItemList.Industrial_FuelRefinery.get(1)); - - ItemStack mInnerTank; - - if (GTNH || !CORE.ConfigSwitches.enableMachine_FluidTanks){ - mInnerTank = ItemList.Quantum_Tank_LV.get(1); - } - else { - mInnerTank = GregtechItemList.GT_FluidTank_EV.get(1); - } - - //Incoloy Casing - RecipeUtils.addShapedGregtechRecipe( - "plateIncoloyDS", "pipeHugeStaballoy", "plateIncoloyDS", - "gearGtIncoloyDS", mInnerTank, "gearGtIncoloyDS", - "plateIncoloyDS", "pipeHugeStaballoy", "plateIncoloyDS", - GregtechItemList.Casing_Refinery_Internal.get(Casing_Amount)); - - //Hastelloy-N Sealant Casing - RecipeUtils.addShapedGregtechRecipe( - "plateIncoloyMA956", "plateHastelloyN", "plateIncoloyMA956", - "plateHastelloyN", "frameGtHastelloyC276", "plateHastelloyN", - "plateIncoloyMA956", "plateHastelloyN", "plateIncoloyMA956", - GregtechItemList.Casing_Refinery_External.get(Casing_Amount)); - - //Hastelloy-X Structural Casing - RecipeUtils.addShapedGregtechRecipe( - "ringInconel792", "gearGtHastelloyX", CI.component_Plate[5], - CI.craftingToolHammer_Hard, "frameGtHastelloyC276", CI.craftingToolWrench, - CI.component_Plate[5], CI.getTieredMachineCasing(4), "ringInconel792", - GregtechItemList.Casing_Refinery_Structural.get(Casing_Amount)); - - RecipeUtils.addShapedGregtechRecipe( - CI.getPlate(5, 1), ALLOY.HASTELLOY_X.getPlateDouble(1), CI.getPlate(5, 1), - CI.getPlate(5, 1), CI.getTieredMachineCasing(5), CI.getPlate(5, 1), - CI.getRobotArm(5, 1), ItemList.Casing_FrostProof.get(1), CI.getRobotArm(5, 1), - GregtechItemList.ColdTrap_IV.get(1)); - RecipeUtils.addShapedGregtechRecipe( - CI.getPlate(7, 1), ALLOY.HS188A.getPlateDouble(1), CI.getPlate(7, 1), - CI.getPlate(7, 1), GregtechItemList.ColdTrap_IV.get(1), CI.getPlate(7, 1), - CI.getRobotArm(7, 1), ItemList.Casing_FrostProof.get(1), CI.getRobotArm(7, 1), - GregtechItemList.ColdTrap_ZPM.get(1)); - - RecipeUtils.addShapedGregtechRecipe( - CI.getFieldGenerator(3, 1), CI.getRobotArm(5, 1), CI.getPlate(5, 1), - ALLOY.HASTELLOY_N.getPlateDouble(1), ItemList.Machine_IV_ChemicalReactor.get(1), ALLOY.HASTELLOY_N.getPlateDouble(1), - CI.getPlate(5, 1), ALLOY.HASTELLOY_N.getPlateDouble(1), CI.getFieldGenerator(3, 1), - GregtechItemList.ReactorProcessingUnit_IV.get(1)); - RecipeUtils.addShapedGregtechRecipe( - CI.getFieldGenerator(5, 1), CI.getRobotArm(7, 1), CI.getPlate(7, 1), - ALLOY.HS188A.getPlateDouble(1), GregtechItemList.ReactorProcessingUnit_IV.get(1), ALLOY.HS188A.getPlateDouble(1), - CI.getPlate(7, 1), ALLOY.HS188A.getPlateDouble(1), CI.getFieldGenerator(5, 1), - GregtechItemList.ReactorProcessingUnit_ZPM.get(1)); - - } - - //Shelves - RecipeUtils.addShapedGregtechRecipe( - "screwWood", "plateWood", "screwWood", - CI.craftingToolHammer_Hard, "frameGtWood", CI.craftingToolHammer_Soft, - "plateWood", "plateWood", "plateWood", - GregtechItemList.GT4_Shelf.get(2)); - - RecipeUtils.addShapelessGregtechRecipe(new ItemStack[] {GregtechItemList.GT4_Shelf.get(1)}, GregtechItemList.GT4_Shelf_Compartment.get(1)); - RecipeUtils.addShapelessGregtechRecipe(new ItemStack[] {GregtechItemList.GT4_Shelf_Compartment.get(1)}, GregtechItemList.GT4_Shelf_Desk.get(1)); - RecipeUtils.addShapelessGregtechRecipe(new ItemStack[] {GregtechItemList.GT4_Shelf_Desk.get(1)}, GregtechItemList.GT4_Shelf_Iron.get(1)); - RecipeUtils.addShapelessGregtechRecipe(new ItemStack[] {GregtechItemList.GT4_Shelf_Iron.get(1)}, GregtechItemList.GT4_Shelf_FileCabinet.get(1)); - RecipeUtils.addShapelessGregtechRecipe(new ItemStack[] {GregtechItemList.GT4_Shelf_FileCabinet.get(1)}, GregtechItemList.GT4_Shelf.get(1)); - - - //Cyclotron - if (CORE.ConfigSwitches.enableMultiblock_Cyclotron){ - RECIPE_CyclotronController = GregtechItemList.COMET_Cyclotron.get(1); - RECIPE_CyclotronOuterCasing = GregtechItemList.Casing_Cyclotron_External.get(Casing_Amount); - RECIPE_CyclotronInnerCoil = GregtechItemList.Casing_Cyclotron_Coil.get(1); - - //Outer Casing - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - ItemList.Casing_FrostProof.get(1), - ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 0, GTNH ? 8 : 4), - ALLOY.INCOLOY_DS.getPlate(GTNH ? 16 : 8), - ALLOY.INCONEL_690.getScrew(GTNH ? 32 : 16), - ALLOY.EGLIN_STEEL.getLongRod(GTNH ? 16 : 4), - CI.getElectricPiston(3, GTNH ? 4 : 2) - }, - ALLOY.ZIRCONIUM_CARBIDE.getFluidStack(144 * 8), //Input Fluid - RECIPE_CyclotronOuterCasing, - 30 * 20 * 2, - MaterialUtils.getVoltageForTier(4)); - - - //Inner Coil - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - ItemList.Casing_Coil_Nichrome.get(1), - ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 1, GTNH ? 32 : 8), - ALLOY.INCOLOY_MA956.getPlate(GTNH ? 16 : 8), - ALLOY.TANTALLOY_61.getBolt(GTNH ? 32 : 16), - ALLOY.INCOLOY_020.getScrew(GTNH ? 64 : 32), - CI.getFieldGenerator(4, GTNH ? 2 : 1) - }, - ALLOY.HG1223.getFluidStack(144 * 5), //Input Fluid - RECIPE_CyclotronInnerCoil, - 60 * 20 * 2, - MaterialUtils.getVoltageForTier(5)); - - - //Controller - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.machineHull_IV, - ItemUtils.getSimpleStack(RECIPE_CyclotronInnerCoil, GTNH ? 4 : 2), - ALLOY.INCOLOY_020.getPlate(GTNH ? 16 : 8), - ALLOY.TANTALLOY_61.getGear(GTNH ? 4 : 2), - ALLOY.INCOLOY_MA956.getScrew(GTNH ? 64 : 16), - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(GTNH ? 6 : 5), GTNH ? 8 : 16) - }, - ALLOY.INCOLOY_020.getFluidStack(144 * 9), //Input Fluid - RECIPE_CyclotronController, - 60 * 20 * 5, - MaterialUtils.getVoltageForTier(5)); - } - - // Mazut - GT_ModHandler.addCraftingRecipe( - GregtechItemList.Controller_LargeSemifluidGenerator.get(1L), - CI.bitsd, - new Object[]{ - "PCP", - "EME", - "GWG", - 'M', ItemList.Hull_EV, - 'P', ItemList.Electric_Piston_EV, - 'E', ItemList.Electric_Pump_EV, - 'C', OrePrefixes.circuit.get(Materials.Data), - 'W', OrePrefixes.cableGt08.get(Materials.Electrum), - 'G', ALLOY.INCONEL_792.getGear(1) - }); - - - if (CORE.ConfigSwitches.enableMultiblock_PowerSubstation){ - RecipeUtils.addShapedRecipe( - "screwTitanium", "plateIncoloy020", "screwTitanium", - "plateIncoloy020", "frameGtIncoloyMA956", "plateIncoloy020", - "screwTitanium", "plateIncoloy020", "screwTitanium", - GregtechItemList.Casing_Power_SubStation.get(Casing_Amount)); - - ItemStack mBattery = ItemUtils.getSimpleStack(ModItems.itemCircuitLFTR); - - RecipeUtils.addShapedRecipe( - "plateIncoloyMA956", mBattery, "plateIncoloyMA956", - GregtechItemList.Casing_Power_SubStation.get(1), GregtechItemList.Casing_Vanadium_Redox.get(1), GregtechItemList.Casing_Power_SubStation.get(1), - "plateIncoloy020", "plateIncoloyMA956", "plateIncoloy020", - GregtechItemList.PowerSubStation.get(1)); - } - - if (CORE.ConfigSwitches.enableMultiblock_IndustrialThermalCentrifuge){ - RecipeUtils.addShapedRecipe( - "plateRedSteel", CI.craftingToolHammer_Hard, "plateRedSteel", - "plateRedSteel", "frameGtBlackSteel", "plateRedSteel", - "plateRedSteel", CI.craftingToolWrench, "plateRedSteel", - GregtechItemList.Casing_ThermalCentrifuge.get(Casing_Amount)); - - RecipeUtils.addShapedRecipe( - "plateRedSteel","circuitData","plateRedSteel", - "stickTalonite",EV_MACHINE_ThermalCentrifuge,"stickTalonite", - "plateRedSteel","gearGtTalonite","plateRedSteel", - GregtechItemList.Industrial_ThermalCentrifuge.get(1)); - } - - if (CORE.ConfigSwitches.enableMultiblock_IndustrialWashPlant){ - RecipeUtils.addShapedRecipe( - "plateGrisium", CI.craftingToolHammer_Hard, "plateGrisium", - "plateTalonite", "frameGtGrisium", "plateTalonite", - "plateGrisium", CI.craftingToolWrench, "plateGrisium", - GregtechItemList.Casing_WashPlant.get(Casing_Amount)); - - RecipeUtils.addShapedRecipe( - "plateGrisium",CI.electricPump_MV,"plateGrisium", - "plateTalonite",EV_MACHINE_OreWasher,"plateTalonite", - "plateGrisium","circuitData","plateGrisium", - GregtechItemList.Industrial_WashPlant.get(1)); - } - - if (CORE.ConfigSwitches.enableMultiblock_LargeAutoCrafter) { - - ItemStack aCoreBlock = CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK - ? ItemUtils.getValueOfItemList("Block_IridiumTungstensteel", 1, ItemUtils.getItemStackOfAmountFromOreDict("blockOsmiridium", 1)) - : ItemUtils.getItemStackOfAmountFromOreDict("blockOsmiridium", 1); - - aCoreBlock.stackSize = GTNH ? 2 : 1; - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - ItemUtils.getSimpleStack(GregtechItemList.Casing_Multi_Use.get(1), GTNH ? 2 : 1), - aCoreBlock, - CI.getTieredComponent(OrePrefixes.circuit, GTNH ? 3 : 2, 16), - CI.getTieredComponent(OrePrefixes.screw, GTNH ? 6 : 5, 32), - CI.getTieredComponent(OrePrefixes.bolt, GTNH ? 6 : 5, 12), - CI.getTieredComponent(OrePrefixes.plate, GTNH ? 7 : 6, 8), }, - CI.getTertiaryTieredFluid(6, 144 * (GTNH ? 12 : 4)), - GregtechItemList.Casing_Autocrafter.get(Casing_Amount), 20 * 60 * 2, - MaterialUtils.getVoltageForTier(GTNH ? 6 : 5)); - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - GregtechItemList.Casing_Refinery_Structural.get(4), - ItemUtils.getSimpleStack(ModItems.itemCircuitLFTR, GTNH ? 2 : 1), - CI.getTieredComponent(OrePrefixes.cableGt08, GTNH ? 7 : 6, GTNH ? 32 : 16), - CI.getTransmissionComponent(GTNH ? 6 : 5, 2), - GregtechItemList.Gregtech_Computer_Cube.get(1), - }, - CI.getTieredFluid(7, 144 * (GTNH ? 32 : 8)), GregtechItemList.GT4_Multi_Crafter.get(1), - 20 * 60 * 5, MaterialUtils.getVoltageForTier(GTNH ? 6 : 5)); - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - ItemUtils.getSimpleStack(GregtechItemList.Casing_Multi_Use.get(1), Casing_Amount), - CI.getEmitter(GTNH ? 5 : 4, GTNH ? 4 : 2), CI.getRobotArm(GTNH ? 5 : 4, GTNH ? 4 : 2), - CI.getTieredComponent(OrePrefixes.circuit, GTNH ? 3 : 2, 8), - CI.getTieredComponent(OrePrefixes.screw, GTNH ? 4 : 3, 8), - CI.getTieredComponent(OrePrefixes.plate, 5, GTNH ? 16 : 4), }, - CI.getAlternativeTieredFluid(5, 144 * 4), ItemUtils.getSimpleStack(ModBlocks.blockProjectTable), - 20 * 30 * 3, MaterialUtils.getVoltageForTier(GTNH ? 5 : 4)); - - } - - if (CORE.ConfigSwitches.enableMultiblock_IndustrialCuttingMachine){ - ItemStack plate = ALLOY.MARAGING300.getPlate(1); - RecipeUtils.addShapedRecipe( - plate, CI.craftingToolHammer_Hard, plate, - "plateStellite", "frameGtTalonite", "plateStellite", - plate, CI.craftingToolWrench, plate, - GregtechItemList.Casing_CuttingFactoryFrame.get(Casing_Amount)); - - RecipeUtils.addShapedRecipe( - plate,CI.getTieredCircuit(3),plate, - "wireFinePlatinum", EV_MACHINE_Cutter, "wireFinePlatinum", - plate,CI.getTieredCircuit(4),plate, - GregtechItemList.Industrial_CuttingFactoryController.get(1)); - } - - //EV_MACHINE_Extruder - if (CORE.ConfigSwitches.enableMultiblock_IndustrialExtrudingMachine){ - ItemStack plate = ALLOY.INCONEL_690.getPlate(1); - RecipeUtils.addShapedRecipe( - plate, CI.craftingToolHammer_Hard, plate, - "plateTalonite", "frameGtStaballoy", "plateTalonite", - plate, CI.craftingToolWrench, plate, - GregtechItemList.Casing_Extruder.get(Casing_Amount)); - - RecipeUtils.addShapedRecipe( - plate,CI.getTieredCircuit(4),plate, - CI.electricPiston_EV, EV_MACHINE_Extruder, CI.electricPiston_EV, - plate,CI.getTieredCircuit(4),plate, - GregtechItemList.Industrial_Extruder.get(1)); - } - - if (CORE.ConfigSwitches.enableMultiblock_IndustrialFishingPort){ - ItemStack plate = ALLOY.AQUATIC_STEEL.getPlate(1); - RecipeUtils.addShapedRecipe( - plate, CI.craftingToolHammer_Hard, plate, - "plateEglinSteel", "frameGtEglinSteel", "plateEglinSteel", - plate, CI.craftingToolWrench, plate, - GregtechItemList.Casing_FishPond.get(Casing_Amount)); - - RecipeUtils.addShapedRecipe( - plate,CI.getTieredCircuit(3),plate, - "wireFineElectrum", ItemUtils.getSimpleStack(ModBlocks.blockFishTrap), "wireFineElectrum", - plate,CI.getTieredCircuit(2),plate, - GregtechItemList.Industrial_FishingPond.get(1)); - } - - if (true) { - //Advanced Vacuum Freezer - ItemStack plate = ALLOY.HG1223.getPlateDouble(1); - ItemStack gear = ALLOY.INCOLOY_MA956.getGear(1); - ItemStack frame = ALLOY.LAFIUM.getFrameBox(1); - ItemStack cell1 = ItemList.Reactor_Coolant_He_6.get(1); - ItemStack cell2 = ItemList.Reactor_Coolant_NaK_6.get(1); - - RecipeUtils.addShapedRecipe( - plate, gear, plate, - cell1, frame, cell2, - plate, gear, plate, - GregtechItemList.Casing_AdvancedVacuum.get(Casing_Amount)); - RecipeUtils.addShapedRecipe( - gear,CI.getTieredCircuit(6),gear, - CI.electricPiston_IV, GregtechItemList.Casing_AdvancedVacuum.get(1), CI.electricPiston_IV, - plate, GregtechItemList.Gregtech_Computer_Cube.get(1), plate, - GregtechItemList.Industrial_Cryogenic_Freezer.get(1)); - - //Advanced Blast Furnace - plate = ALLOY.HASTELLOY_N.getPlateDouble(1); - gear = ALLOY.HASTELLOY_W.getGear(1); - frame = ALLOY.HASTELLOY_X.getFrameBox(1); - cell1 = ItemUtils.simpleMetaStack("IC2:reactorHeatSwitchDiamond:1", 1, 1); - cell2 = ItemUtils.simpleMetaStack("IC2:reactorVentGold:1", 1, 1); - ItemStack cell3 = ItemUtils.simpleMetaStack("IC2:reactorVentDiamond:1:1", 1, 1); - - RecipeUtils.addShapedRecipe( - plate, cell1, plate, - cell3, frame, cell2, - plate, gear, plate, - GregtechItemList.Casing_Adv_BlastFurnace.get(Casing_Amount)); - RecipeUtils.addShapedRecipe( - gear,CI.getTieredCircuit(6),gear, - CI.robotArm_IV, GregtechItemList.Casing_Adv_BlastFurnace.get(1), CI.robotArm_IV, - plate, GregtechItemList.Gregtech_Computer_Cube.get(1), plate, - GregtechItemList.Machine_Adv_BlastFurnace.get(1)); - - //Advanced Implosion Compressor - plate = ItemUtils.getItemStackOfAmountFromOreDict("plateAlloyIridium", 1); - gear = ALLOY.LEAGRISIUM.getGear(1); - frame = ALLOY.CINOBITE.getFrameBox(1); - cell1 = ItemUtils.simpleMetaStack("IC2:reactorHeatSwitchDiamond:1", 1, 1); - cell2 = ItemUtils.simpleMetaStack("IC2:reactorVentGold:1", 1, 1); - - RecipeUtils.addShapedRecipe( - gear,CI.getTieredCircuit(6),gear, - CI.fieldGenerator_IV, CI.machineHull_ZPM, CI.robotArm_IV, - plate, GregtechItemList.Gregtech_Computer_Cube.get(1), plate, - GregtechItemList.Machine_Adv_ImplosionCompressor.get(1)); - - - - //Supply Depot - plate = ALLOY.TUNGSTEN_CARBIDE.getPlateDouble(1); - gear = ALLOY.TRINIUM_TITANIUM.getRing(1); - frame = ALLOY.TUNGSTEN_CARBIDE.getFrameBox(1); - cell1 = CI.conveyorModule_EV; - cell2 = CI.electricMotor_IV; - ItemStack casingAmazon = GregtechItemList.Casing_AmazonWarehouse.get(1); - ItemStack aTieredUnboxinator = CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK ? ItemUtils.getValueOfItemList("Machine_LuV_Unboxinator", 1, ItemList.Machine_IV_Unboxinator.get(1)) : ItemList.Machine_IV_Unboxinator.get(1); - - - RecipeUtils.addShapedRecipe( - plate, ItemUtils.getItemStackOfAmountFromOreDict("cableGt12VanadiumGallium", 1), plate, - cell1, frame, cell2, - plate, gear, plate, - GregtechItemList.Casing_AmazonWarehouse.get(Casing_Amount)); - RecipeUtils.addShapedRecipe( - casingAmazon, CI.getTieredCircuit(7), casingAmazon, - CI.robotArm_LuV, aTieredUnboxinator, CI.robotArm_LuV, - CI.conveyorModule_LuV, GregtechItemList.Gregtech_Computer_Cube.get(1), CI.conveyorModule_LuV, - GregtechItemList.Amazon_Warehouse_Controller.get(1)); - - - //Industrial Mixing Machine - RecipeUtils.addShapedRecipe( - "plateStaballoy",CI.getTieredCircuit(5),"plateStaballoy", - "plateZirconiumCarbide", EV_MACHINE_Mixer, "plateZirconiumCarbide", - "plateStaballoy",CI.getTieredCircuit(5),"plateStaballoy", - GregtechItemList.Industrial_Mixer.get(1)); - - } - - if (CORE.ConfigSwitches.enableMultiblock_IndustrialMultiMachine){ - ItemStack plate = ALLOY.STABALLOY.getPlate(1); - - - ItemStack o_Compressor; - ItemStack o_Lathe; - ItemStack o_Electromagnet; - ItemStack o_Fermenter; - ItemStack o_Distillery; - ItemStack o_Extractor; - if (GTNH) { - o_Compressor = ItemList.Machine_IV_Compressor.get(1); - o_Lathe = ItemList.Machine_IV_Lathe.get(1); - o_Electromagnet = ItemList.Machine_IV_Polarizer.get(1); - o_Fermenter = ItemList.Machine_IV_Fermenter.get(1); - o_Distillery = ItemList.Machine_IV_FluidExtractor.get(1); - o_Extractor = ItemList.Machine_IV_Extractor.get(1); - } - else { - o_Compressor = ItemList.Machine_EV_Compressor.get(1); - o_Lathe = ItemList.Machine_EV_Lathe.get(1); - o_Electromagnet = ItemList.Machine_EV_Polarizer.get(1); - o_Fermenter = ItemList.Machine_EV_Fermenter.get(1); - o_Distillery = ItemList.Machine_EV_FluidExtractor.get(1); - o_Extractor = ItemList.Machine_EV_Extractor.get(1); - } - RecipeUtils.addShapedRecipe( - plate, CI.craftingToolHammer_Hard, plate, - "plateStainlessSteel", "frameGtZirconiumCarbide", "plateStainlessSteel", - plate, CI.craftingToolWrench, plate, - GregtechItemList.Casing_Multi_Use.get(Casing_Amount)); - - RecipeUtils.addShapedRecipe( - o_Compressor, o_Lathe, o_Electromagnet, - plate, ItemUtils.getSimpleStack(ModBlocks.blockProjectTable), plate, - o_Fermenter, o_Distillery, o_Extractor, - GregtechItemList.Industrial_MultiMachine.get(1)); - } - - - - - /* - * 6/1/19 - Content additions - */ - - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - - ItemStack aDrillController = ItemUtils.getValueOfItemList("OreDrill4", ItemList.Hull_UV).get(1); - - //Drilling Platform - /*CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - aDrillController, - ItemUtils.getItemStackOfAmountFromOreDict("frameGtTriniumNaquadahCarbonite", 3), - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(9), 2 * (GTNH ? 4 : 1)), - ItemUtils.getSimpleStack((GTNH ? CI.conveyorModule_UV : CI.conveyorModule_ZPM), 2 * (GTNH ? 2 : 1)), - ItemUtils.getSimpleStack((GTNH ? CI.electricPump_UV : CI.electricPump_ZPM), 4 * (GTNH ? 2 : 1)), - }, - ALLOY.LAFIUM.getFluid(144 * 8 * (GTNH ? 2 : 1)), - GregtechItemList.BedrockMiner_MKI.get(1), - (int) GT_Values.V[5], - (int) GT_Values.V[7]);*/ - - //Drilling Platform Casings - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - ItemUtils.getItemStackOfAmountFromOreDict("frameGtTriniumNaquadahCarbonite", 4), - ItemUtils.getItemStackOfAmountFromOreDict("plateDoubleTriniumTitaniumAlloy", 1 * (GTNH ? 2 : 1)), - ItemUtils.getItemStackOfAmountFromOreDict("gearGtPikyonium64B", 2 * (GTNH ? 2 : 1)), - ALLOY.TRINIUM_REINFORCED_STEEL.getPlateDouble(4 * (GTNH ? 2 : 1)), - ItemUtils.getSimpleStack((GTNH ? CI.machineHull_UV : CI.machineHull_LuV), 1 * (GTNH ? 2 : 1)), - }, - ALLOY.MARAGING350.getFluidStack(144 * 16 * (GTNH ? 2 : 1)), - GregtechItemList.Casing_BedrockMiner.get(1), - (int) GT_Values.V[4], - (int) GT_Values.V[6]); - - - - - - - - - - } - - - - - - - - - - - } - - int aCostMultiplier = GTNH ? 2 : 1; - - //Mystic Frame - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - GregtechItemList.Casing_Multi_Use.get(1), - ItemList.Field_Generator_MV.get(1, CI.circuitTier7), - ItemList.Field_Generator_HV.get(1, CI.circuitTier7), - ItemList.Emitter_HV.get(1, CI.circuitTier7), - ItemList.Sensor_HV.get(1, CI.circuitTier7), - CI.getTieredComponent(OrePrefixes.plate, 7, 8 * aCostMultiplier), - CI.getTieredComponent(OrePrefixes.wireGt08, 8, 4 * aCostMultiplier), - }, - CI.getTieredFluid(6, (144 * 8)), //Input Fluid - ItemUtils.getSimpleStack(Dimension_Everglades.blockPortalFrame, 2), - 45 * 20 * 1 * (6), - MaterialUtils.getVoltageForTier(6)); - GT_MetaTileEntity_Disassembler.addBlacklist(ItemUtils.getSimpleStack(Dimension_Everglades.blockPortalFrame, 1)); - - - //Player Doors - ItemStack[] aDoorInputs = new ItemStack[] { - ItemUtils.getSimpleStack(Blocks.log2), - ItemUtils.getSimpleStack(Blocks.iron_block), - ItemUtils.getSimpleStack(Blocks.glass), - ItemUtils.getSimpleStack(Blocks.packed_ice), - ItemUtils.getSimpleStack(Blocks.cactus), - }; - ItemStack[] aDoorOutputs = new ItemStack[] { - ItemUtils.getSimpleStack(ModBlocks.blockPlayerDoorWooden), - ItemUtils.getSimpleStack(ModBlocks.blockPlayerDoorIron), - ItemUtils.getSimpleStack(ModBlocks.blockPlayerDoorCustom_Glass), - ItemUtils.getSimpleStack(ModBlocks.blockPlayerDoorCustom_Ice), - ItemUtils.getSimpleStack(ModBlocks.blockPlayerDoorCustom_Cactus), - }; - - for (int y = 0; y < aDoorInputs.length; y++) { - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - ItemUtils.getSimpleStack(Items.iron_door), - aDoorInputs[y], - ItemList.Sensor_LV.get(1, CI.circuitTier7), - CI.getTieredComponent(OrePrefixes.plate, 1, 2 * aCostMultiplier), - CI.getTieredComponent(OrePrefixes.wireGt02, 1, 2 * aCostMultiplier), - ItemUtils.getSimpleStack(Items.redstone, 16) - }, - CI.getTieredFluid(1, (144 * 2)), //Input Fluid - aDoorOutputs[y], - 100, - MaterialUtils.getVoltageForTier(1)); - } - - - - - - - Logger.INFO("Done loading recipes for the Various machine blocks."); - } - - - private static void controlCores() { - - Material[] aMat_A = new Material[] { - ALLOY.POTIN, - ALLOY.ZIRCONIUM_CARBIDE, - ALLOY.TANTALLOY_61, - ALLOY.INCONEL_792, - ALLOY.STABALLOY, - ALLOY.TALONITE, - ALLOY.HASTELLOY_N, - ALLOY.HG1223, - ALLOY.LAFIUM, - ALLOY.PIKYONIUM - }; - Material[] aMat_B = new Material[] { - ALLOY.TUMBAGA, - ALLOY.SILICON_CARBIDE, - ALLOY.EGLIN_STEEL, - ALLOY.NICHROME, - ALLOY.TUNGSTEN_CARBIDE, - ALLOY.STELLITE, - ALLOY.HASTELLOY_C276, - ALLOY.NITINOL_60, - ALLOY.ZERON_100, - ALLOY.CINOBITE - }; - - Item aBaseCore = ModItems.itemControlCore; - ItemStack[] aInputPrevTier = new ItemStack[] { - GTNH ? ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore3", 1) : ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore2", 1), - ItemUtils.simpleMetaStack(aBaseCore, 0, 1), - ItemUtils.simpleMetaStack(aBaseCore, 1, 1), - ItemUtils.simpleMetaStack(aBaseCore, 2, 1), - ItemUtils.simpleMetaStack(aBaseCore, 3, 1), - ItemUtils.simpleMetaStack(aBaseCore, 4, 1), - ItemUtils.simpleMetaStack(aBaseCore, 5, 1), - ItemUtils.simpleMetaStack(aBaseCore, 6, 1), - ItemUtils.simpleMetaStack(aBaseCore, 7, 1), - ItemUtils.simpleMetaStack(aBaseCore, 8, 1), - }; - ItemStack[] aOutput = new ItemStack[] { - ItemUtils.simpleMetaStack(aBaseCore, 0, 1), - ItemUtils.simpleMetaStack(aBaseCore, 1, 1), - ItemUtils.simpleMetaStack(aBaseCore, 2, 1), - ItemUtils.simpleMetaStack(aBaseCore, 3, 1), - ItemUtils.simpleMetaStack(aBaseCore, 4, 1), - ItemUtils.simpleMetaStack(aBaseCore, 5, 1), - ItemUtils.simpleMetaStack(aBaseCore, 6, 1), - ItemUtils.simpleMetaStack(aBaseCore, 7, 1), - ItemUtils.simpleMetaStack(aBaseCore, 8, 1), - ItemUtils.simpleMetaStack(aBaseCore, 9, 1), - - }; - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.machineHull_HV, - aOutput[1], - aMat_A[1].getGear(GTNH ? 4 : 2), - aMat_B[2].getPlateDouble(GTNH ? 16 : 8), - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+(GTNH ? "2" : "1"), GTNH ? 4 : 2), - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(GTNH ? 3 : 2), GTNH ? 10 : 5) - }, - aMat_B[3].getFluidStack(144 * 8), //Input Fluid - GregtechItemList.Hatch_Control_Core.get(1), - 60 * 20 * 5, - MaterialUtils.getVoltageForTier(3)); - - - for (int i = 0; i < 10; i++) { - boolean aDub = false; - ItemStack aPlateStack = aMat_A[i].getPlateDouble((GTNH ? 16 : 8) * (aDub ? 2 : 1)); - ItemStack aGearStack = aMat_B[i].getGear(GTNH ? 4 : 2 * (aDub ? 2 : 1)); - ItemStack aRodStack = aMat_A[i].getLongRod(GTNH ? 16 : 8 * (aDub ? 2 : 1)); - ItemStack aScrewStack = aMat_B[i].getScrew(32 * (aDub ? 2 : 1)); - - if (!ItemUtils.checkForInvalidItems(aPlateStack)) { - aPlateStack = aMat_A[i].getPlate((GTNH ? 16 : 8) * (aDub ? 2 : 1) * 2); - if (!ItemUtils.checkForInvalidItems(aPlateStack)) { - aPlateStack = aMat_B[i].getPlateDouble((GTNH ? 16 : 8) * (aDub ? 2 : 1)); - if (!ItemUtils.checkForInvalidItems(aPlateStack)) { - aPlateStack = aMat_B[i].getPlate((GTNH ? 16 : 8) * (aDub ? 2 : 1) * 2); - } - } - } - if (!ItemUtils.checkForInvalidItems(aGearStack)) { - aGearStack = aMat_A[i].getGear(GTNH ? 8 : 4 * (aDub ? 2 : 1)); - } - if (!ItemUtils.checkForInvalidItems(aRodStack)) { - aRodStack = aMat_B[i].getLongRod(GTNH ? 32 : 16 * (aDub ? 2 : 1)); - } - if (!ItemUtils.checkForInvalidItems(aScrewStack)) { - aScrewStack = aMat_A[i].getScrew(32 * (aDub ? 2 : 1)); - } - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getEnergyCore(i, 4), - aPlateStack, - aGearStack, - aRodStack, - aScrewStack, - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName((int) (4+Math.ceil((double) i / (double) 2))), GTNH ? (i * 2 * 2) : (i * 2)) - }, - CI.getTieredFluid(i, 144 * 4 * (i+1)), //Input Fluid - aOutput[i], - 60 * 20 * 1 * (i+1), - MaterialUtils.getVoltageForTier(i)); - } - } - - private static void energyCores() { - - //Simpler Recipes for normal Players, Force assembly crafting in GTNH - if (!GTNH) { - //Buffer Core - /*RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[1], cableTier1, CI.component_Plate[1], - "circuitPrimitive", "plateStaballoy", "circuitPrimitive", - CI.component_Plate[1], cableTier1, CI.component_Plate[1], - RECIPE_BufferCore_ULV); - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[2], cableTier2, CI.component_Plate[2], - RECIPE_BufferCore_ULV, CI.machineHull_HV, RECIPE_BufferCore_ULV, - CI.component_Plate[2], cableTier2, CI.component_Plate[2], - RECIPE_BufferCore_LV); - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[3], cableTier3, CI.component_Plate[3], - RECIPE_BufferCore_LV, CI.circuitTier2, RECIPE_BufferCore_LV, - CI.component_Plate[3], cableTier3, CI.component_Plate[3], - RECIPE_BufferCore_MV); - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[4], cableTier4, CI.component_Plate[4], - RECIPE_BufferCore_MV, CI.circuitTier3, RECIPE_BufferCore_MV, - CI.component_Plate[4], cableTier4, CI.component_Plate[4], - RECIPE_BufferCore_HV); - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[5], cableTier5, CI.component_Plate[5], - RECIPE_BufferCore_HV, CI.circuitTier4, RECIPE_BufferCore_HV, - CI.component_Plate[5], cableTier5, CI.component_Plate[5], - RECIPE_BufferCore_EV); - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[6], cableTier6, CI.component_Plate[6], - RECIPE_BufferCore_EV, CI.circuitTier5, RECIPE_BufferCore_EV, - CI.component_Plate[6], cableTier6, CI.component_Plate[6], - RECIPE_BufferCore_IV); - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[7], cableTier7, CI.component_Plate[7], - RECIPE_BufferCore_IV, CI.circuitTier6, RECIPE_BufferCore_IV, - CI.component_Plate[7], cableTier7, CI.component_Plate[7], - RECIPE_BufferCore_LuV); - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[8], cableTier8, CI.component_Plate[8], - RECIPE_BufferCore_LuV, CI.circuitTier7, RECIPE_BufferCore_LuV, - CI.component_Plate[8], cableTier8, CI.component_Plate[8], - RECIPE_BufferCore_ZPM); - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[9], cableTier9, CI.component_Plate[9], - RECIPE_BufferCore_ZPM, CI.circuitTier8, RECIPE_BufferCore_ZPM, - CI.component_Plate[9], cableTier9, CI.component_Plate[9], - RECIPE_BufferCore_UV); - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[10], cableTier10, CI.component_Plate[10], - RECIPE_BufferCore_UV, CI.circuitTier9, RECIPE_BufferCore_UV, - CI.component_Plate[10], cableTier10, CI.component_Plate[10], - RECIPE_BufferCore_MAX);*/ - - - /*RecipeUtils.addShapedGregtechRecipe( - wireTier1, RECIPE_BufferCore_ULV, wireTier1, - wireTier1, CI.machineCasing_ULV, wireTier1, - CI.circuitPrimitive, CI.circuitTier1, CI.circuitPrimitive, - RECIPE_Buffer_ULV); - RecipeUtils.addShapedGregtechRecipe( - wireTier2, RECIPE_BufferCore_LV, wireTier2, - wireTier2, CI.machineCasing_LV, wireTier2, - CI.circuitTier1, RECIPE_BufferCore_LV, CI.circuitTier1, - RECIPE_Buffer_LV); - RecipeUtils.addShapedGregtechRecipe( - wireTier3, RECIPE_BufferCore_MV, wireTier3, - wireTier3, CI.machineCasing_MV, wireTier3, - CI.circuitTier2, RECIPE_BufferCore_MV, CI.circuitTier2, - RECIPE_Buffer_MV); - RecipeUtils.addShapedGregtechRecipe( - wireTier4, RECIPE_BufferCore_HV, wireTier4, - wireTier4, CI.machineCasing_HV, wireTier4, - CI.circuitTier3, RECIPE_BufferCore_HV, CI.circuitTier3, - RECIPE_Buffer_HV); - RecipeUtils.addShapedGregtechRecipe( - wireTier5, RECIPE_BufferCore_EV, wireTier5, - wireTier5, CI.machineCasing_EV, wireTier5, - CI.circuitTier4, RECIPE_BufferCore_EV, CI.circuitTier4, - RECIPE_Buffer_EV); - RecipeUtils.addShapedGregtechRecipe( - wireTier6, RECIPE_BufferCore_IV, wireTier6, - wireTier6, CI.machineCasing_IV, wireTier6, - CI.circuitTier5, RECIPE_BufferCore_IV, CI.circuitTier5, - RECIPE_Buffer_IV); - RecipeUtils.addShapedGregtechRecipe( - wireTier7, RECIPE_BufferCore_LuV, wireTier7, - wireTier7, CI.machineCasing_LuV, wireTier7, - CI.circuitTier6, RECIPE_BufferCore_LuV, CI.circuitTier6, - RECIPE_Buffer_LuV); - RecipeUtils.addShapedGregtechRecipe( - wireTier8, RECIPE_BufferCore_ZPM, wireTier8, - wireTier8, CI.machineCasing_ZPM, wireTier8, - CI.circuitTier7, RECIPE_BufferCore_ZPM, CI.circuitTier7, - RECIPE_Buffer_ZPM); - RecipeUtils.addShapedGregtechRecipe( - wireTier9, RECIPE_BufferCore_UV, wireTier9, - wireTier9, CI.machineCasing_UV, wireTier9, - CI.circuitTier8, RECIPE_BufferCore_UV, CI.circuitTier8, - RECIPE_Buffer_UV); - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[11], RECIPE_BufferCore_MAX, CI.component_Plate[11], - wireTier10, CI.machineCasing_MAX, wireTier10, - CI.circuitTier9, RECIPE_BufferCore_MAX, CI.circuitTier9, - RECIPE_Buffer_MAX);*/ - } - - - ItemStack[] aBufferOutput = new ItemStack[] { - RECIPE_Buffer_ULV, RECIPE_Buffer_LV, RECIPE_Buffer_MV, - RECIPE_Buffer_HV, RECIPE_Buffer_EV, RECIPE_Buffer_IV, - RECIPE_Buffer_LuV, RECIPE_Buffer_ZPM, RECIPE_Buffer_UV, RECIPE_Buffer_MAX }; - - - - ItemStack[] aOutput = new ItemStack[] { - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"1", 1), - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"2", 1), - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"3", 1), - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"4", 1), - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"5", 1), - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"6", 1), - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"7", 1), - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"8", 1), - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"9", 1), - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"10", 1) - }; - - int aCostMultiplier = GTNH ? 4 : 1; - - for (int i = 0; i < 10; i++) { - - ItemStack aPrevTier = (i == 0 ? CI.getTieredMachineHull(GTNH ? 2 : 1) : aOutput[i-1]); - aPrevTier.stackSize = GTNH ? 2 : 1; - int aTier = (i + 1); - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - aPrevTier, - CI.getTieredComponent(OrePrefixes.plate, aTier, 4 * aCostMultiplier), - CI.getTieredComponent(OrePrefixes.cableGt04, i, 2 * aCostMultiplier), - CI.getTieredComponent(OrePrefixes.circuit, aTier, 2 * aCostMultiplier), - CI.getTieredComponent(OrePrefixes.screw, aTier, 6 * aCostMultiplier), - CI.getTieredComponent(OrePrefixes.bolt, i, 12 * (GTNH ? 2 : 1)), - }, - CI.getTieredFluid(i, (144 * 4 * aTier)), //Input Fluid - aOutput[i], - 45 * 10 * 1 * (aTier), - MaterialUtils.getVoltageForTier(i)); - - //Energy Buffer - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - ItemUtils.getSimpleStack(aOutput[i], 4), - CI.getTieredComponent(OrePrefixes.plate, aTier, 8 * aCostMultiplier), - CI.getTieredComponent(OrePrefixes.wireGt08, i, 4 * aCostMultiplier), - CI.getTieredComponent(OrePrefixes.circuit, i, 4 * aCostMultiplier), - CI.getTieredComponent(OrePrefixes.stickLong, aTier, 4 * aCostMultiplier), - CI.getTieredComponent(OrePrefixes.gearGt, i, 5 * (GTNH ? 2 : 1)), - }, - CI.getTieredFluid(aTier, (144 * 16 * aTier)), //Input Fluid - aBufferOutput[i], - 45 * 20 * 1 * (aTier), - MaterialUtils.getVoltageForTier(i)); - - } - - - - - } - - private static void wirelessChargers() { - - ItemStack[] aChargers = new ItemStack[] { - null, - GregtechItemList.Charger_LV.get(1), - GregtechItemList.Charger_MV.get(1), - GregtechItemList.Charger_HV.get(1), - GregtechItemList.Charger_EV.get(1), - GregtechItemList.Charger_IV.get(1), - GregtechItemList.Charger_LuV.get(1), - GregtechItemList.Charger_ZPM.get(1), - GregtechItemList.Charger_UV.get(1), - GregtechItemList.Charger_MAX.get(1) - }; - - int aCostMultiplier = GTNH ? 2 : 1; - - for (int i = 0; i < 10; i++) { - if (i == 0) { - continue; - } - int aTier = (i + 1); - ItemStack[] aInputs = new ItemStack[] { - CI.getTieredMachineHull(i, 1 * aCostMultiplier), - CI.getTransmissionComponent(i, 2 * aCostMultiplier), - CI.getFieldGenerator(i, 1 * aCostMultiplier), - CI.getTieredComponent(OrePrefixes.plate, aTier, 4 * aCostMultiplier), - CI.getTieredComponent(OrePrefixes.circuit, aTier, 2 * aCostMultiplier), - }; - CORE.RA.addSixSlotAssemblingRecipe( - aInputs, - CI.getAlternativeTieredFluid(i, (144 * 2 * aTier)), //Input Fluid - aChargers[i], - 45 * 10 * 1 * (aTier), - MaterialUtils.getVoltageForTier(i)); - - } - } - - private static void largeArcFurnace() { - int aCostMultiplier = GTNH ? 2 : 1; - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getTieredMachineHull(-1, 1 * aCostMultiplier), - CI.getTransmissionComponent(2, 2 * aCostMultiplier), - CI.getElectricPiston(4, 2 * aCostMultiplier), - CI.getTieredComponent(OrePrefixes.plate, 5, 4 * aCostMultiplier), - CI.getTieredComponent(OrePrefixes.pipeSmall, 4, 1 * aCostMultiplier), - }, - CI.getAlternativeTieredFluid(5, (144 * 2 * 4)), //Input Fluid - GregtechItemList.Casing_Industrial_Arc_Furnace.get(Casing_Amount), - 20 * 10 * 1 * (6), - MaterialUtils.getVoltageForTier(5)); - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - GregtechItemList.Casing_Industrial_Arc_Furnace.get(Casing_Amount), - CI.getFieldGenerator(4, 2 * aCostMultiplier), - CI.getRobotArm(5, 4 * aCostMultiplier), - CI.getEnergyCore(4, 2 * aCostMultiplier), - CI.getTieredComponent(OrePrefixes.plate, 6, 8 * aCostMultiplier), - CI.getTieredComponent(OrePrefixes.circuit, 5, 8 * aCostMultiplier), - }, - CI.getAlternativeTieredFluid(6, (144 * 4 * 5)), //Input Fluid - GregtechItemList.Industrial_Arc_Furnace.get(1), - 60 * 20 * 8, - MaterialUtils.getVoltageForTier(6)); - } - - private static void industrialVacuumFurnace() { - int aCostMultiplier = GTNH ? 2 : 1; - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getTieredMachineHull(-1, 1 * aCostMultiplier), - CI.getHeatCoil(2), - CI.getElectricPiston(3, 2 * aCostMultiplier), - CI.getTieredComponent(OrePrefixes.plate, 6, 4 * aCostMultiplier), - CI.getTieredComponent(OrePrefixes.gearGt, 6, 2 * aCostMultiplier), - }, - CI.getTertiaryTieredFluid(5, (144 * 2 * 4 * aCostMultiplier)), //Input Fluid - GregtechItemList.Casing_Vacuum_Furnace.get(Casing_Amount), - 20 * 10 * 6, - MaterialUtils.getVoltageForTier(6)); - - ; - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - GregtechItemList.Casing_Vacuum_Furnace.get(aCostMultiplier), - CI.getTieredComponent(OrePrefixes.wireGt16, 7, 4 * aCostMultiplier), - CI.getEnergyCore(6, 1 * aCostMultiplier), - CI.getRobotArm(4, 4 * aCostMultiplier), - CI.getTieredComponent(OrePrefixes.plate, 7, 8 * aCostMultiplier), - CI.getTieredComponent(OrePrefixes.circuit, 6, 8 * aCostMultiplier), - }, - CI.getTieredFluid(7, (144 * 4 * 5 * aCostMultiplier)), //Input Fluid - GregtechItemList.Controller_Vacuum_Furnace.get(1), - 60 * 20 * 12, - MaterialUtils.getVoltageForTier(7)); - } - - private static void milling() { - - - /*public static ItemStack RECIPE_ISAMill_Controller; - public static ItemStack RECIPE_ISAMill_Gearbox; - public static ItemStack RECIPE_ISAMill_Casing; - public static ItemStack RECIPE_ISAMill_Hatch; - public static ItemStack RECIPE_Flotation_Controller; - public static ItemStack RECIPE_Flotation_Casing;*/ - - // Isa Mill Controller - CORE.RA.addAssemblylineRecipe( - ItemList.Machine_IV_Macerator.get(1), - 20 * 60 * 20, - new Object[] { - GregtechItemList.Casing_IsaMill_Gearbox.get(4), - CI.getTieredGTPPMachineCasing(6, 4), - ItemList.Component_Grinder_Tungsten.get(16), - new Object[] {CI.getTieredCircuitOreDictName(6), 8}, - ALLOY.INCONEL_625.getGear(8), - ALLOY.INCONEL_625.getPlate(32), - ALLOY.ZERON_100.getPlateDouble(8), - ALLOY.ZERON_100.getPlateDouble(8), - ALLOY.ZERON_100.getScrew(64), - CI.getTieredComponentOfMaterial(Materials.NiobiumTitanium, OrePrefixes.wireFine, 32), - CI.getTieredComponentOfMaterial(Materials.NiobiumTitanium, OrePrefixes.wireFine, 32), - CI.getTieredComponentOfMaterial(Materials.Titanium, OrePrefixes.foil, 16), - CI.getTieredComponentOfMaterial(Materials.Titanium, OrePrefixes.foil, 16), - - }, - new FluidStack[] { - CI.getTieredFluid(6, 16 * 144), - CI.getAlternativeTieredFluid(6, 32 * 144), - CI.getTertiaryTieredFluid(6, 32 * 144) - }, - GregtechItemList.Controller_IsaMill.get(1), - 20 * 60 * 10, - MaterialUtils.getVoltageForTier(6)); - - // Isa Mill Gearbox - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(7), - ItemList.Casing_Gearbox_Titanium.get(2), - ALLOY.INCONEL_625.getGear(4), - CI.getTieredComponentOfMaterial(Materials.HSSE, OrePrefixes.gearGtSmall, 8), - ALLOY.INCONEL_625.getPlate(16), - ALLOY.ZERON_100.getBolt(16), - }, - ALLOY.TUNGSTENSTEEL.getFluidStack(8 * 144), - GregtechItemList.Casing_IsaMill_Gearbox.get(1), - 60 * 20 * 2, - MaterialUtils.getVoltageForTier(6)); - - // Isa Mill Casing - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(7), - CI.getTieredGTPPMachineCasing(5, 1), - ALLOY.INCONEL_625.getPlate(8), - ALLOY.ZERON_100.getRod(4), - CI.getTieredComponentOfMaterial(Materials.HSSG, OrePrefixes.gearGtSmall, 4), - ALLOY.ZERON_100.getScrew(8), - }, - ELEMENT.getInstance().TITANIUM.getFluidStack(4 * 144), - GregtechItemList.Casing_IsaMill_Casing.get(1), - 60 * 20 * 2, - MaterialUtils.getVoltageForTier(6)); - - // Isa Mill Pipe - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(7), - CI.getTieredGTPPMachineCasing(4, 2), - ALLOY.INCONEL_625.getPlateDouble(4), - ALLOY.INCOLOY_MA956.getRing(8), - CI.getTieredComponentOfMaterial(Materials.HSSE, OrePrefixes.plate, 8), - ALLOY.INCOLOY_MA956.getBolt(16), - }, - ELEMENT.getInstance().ALUMINIUM.getFluidStack(8 * 144), - GregtechItemList.Casing_IsaMill_Pipe.get(1), - 60 * 20 * 8, - MaterialUtils.getVoltageForTier(4)); - - // Flotation Cell Controller - CORE.RA.addAssemblylineRecipe( - ItemList.Distillation_Tower.get(1), - 20 * 60 * 20, - new Object[] { - GregtechItemList.Casing_Flotation_Cell.get(4), - CI.getTieredGTPPMachineCasing(5, 4), - ItemList.Machine_IV_Distillery.get(1), - new Object[] {CI.getTieredCircuitOreDictName(6), 8}, - ALLOY.STELLITE.getGear(8), - ALLOY.STELLITE.getPlate(32), - ALLOY.HASTELLOY_N.getPlateDouble(8), - ALLOY.HASTELLOY_N.getPlateDouble(8), - ALLOY.HASTELLOY_N.getScrew(64), - CI.getTieredComponentOfMaterial(Materials.YttriumBariumCuprate, OrePrefixes.wireFine, 64), - CI.getTieredComponentOfMaterial(Materials.YttriumBariumCuprate, OrePrefixes.wireFine, 64), - CI.getTieredComponentOfMaterial(Materials.Platinum, OrePrefixes.foil, 32), - CI.getTieredComponentOfMaterial(Materials.Platinum, OrePrefixes.foil, 32), - - }, - new FluidStack[] { - CI.getTieredFluid(5, 16 * 144), - CI.getAlternativeTieredFluid(4, 32 * 144), - CI.getTertiaryTieredFluid(4, 32 * 144) - }, - GregtechItemList.Controller_Flotation_Cell.get(1), - 20 * 60 * 10, - MaterialUtils.getVoltageForTier(6)); - - // Flotation Cell Casing - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(7), - CI.getTieredGTPPMachineCasing(4, 1), - ALLOY.AQUATIC_STEEL.getPlate(8), - ALLOY.STELLITE.getRing(8), - CI.getTieredComponentOfMaterial(Materials.HSSG, OrePrefixes.plateDouble, 4), - ALLOY.HASTELLOY_N.getScrew(8), - }, - ALLOY.STAINLESS_STEEL.getFluidStack(8 * 144), - GregtechItemList.Casing_Flotation_Cell.get(1), - 60 * 20 * 2, - MaterialUtils.getVoltageForTier(6)); - - // Milling Bus - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(7), - CI.getTieredGTPPMachineCasing(5, 1), - ItemList.Hatch_Input_Bus_EV.get(1), - CI.getTieredComponentOfMaterial(Materials.Titanium, OrePrefixes.gearGt, 8), - CI.getTieredComponentOfMaterial(Materials.TungstenSteel, OrePrefixes.plate, 32), - CI.getTieredComponentOfMaterial(Materials.SolderingAlloy, OrePrefixes.wireFine, 16), - }, - ELEMENT.getInstance().TUNGSTEN.getFluidStack(8 * 144), - GregtechItemList.Bus_Milling_Balls.get(1), - 60 * 20 * 4, - MaterialUtils.getVoltageForTier(5)); - - } - - private static void sparging() { - - // Sparge Tower Research - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(8), - ELEMENT.getInstance().HELIUM.getCell(8), - ELEMENT.getInstance().FLUORINE.getCell(8), - ALLOY.HS188A.getIngot(8), - ItemList.Distillation_Tower.get(1) - }, - null, - ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_10_SPARGING, 1), - 60 * 20 * 5, - MaterialUtils.getVoltageForTier(5)); - - // Sparge Tower Controller - CORE.RA.addAssemblylineRecipe( - ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_10_SPARGING, 1), - 20 * 60 * 20, - new Object[] { - GregtechItemList.Casing_Sparge_Tower_Exterior.get(4), - CI.getTieredGTPPMachineCasing(4, 4), - ItemList.Machine_IV_Distillery.get(1), - new Object[] {CI.getTieredCircuitOreDictName(5), 8}, - ALLOY.HS188A.getGear(8), - ALLOY.HS188A.getPlate(32), - ALLOY.HASTELLOY_N.getPlateDouble(8), - ALLOY.HASTELLOY_N.getPlateDouble(8), - ALLOY.HASTELLOY_N.getScrew(64), - CI.getTieredComponentOfMaterial(Materials.YttriumBariumCuprate, OrePrefixes.wireFine, 64), - CI.getTieredComponentOfMaterial(Materials.YttriumBariumCuprate, OrePrefixes.wireFine, 64), - CI.getTieredComponentOfMaterial(Materials.Platinum, OrePrefixes.foil, 32), - CI.getTieredComponentOfMaterial(Materials.Platinum, OrePrefixes.foil, 32), - - }, - new FluidStack[] { - CI.getTieredFluid(4, 16 * 144), - CI.getAlternativeTieredFluid(3, 32 * 144), - CI.getTertiaryTieredFluid(3, 32 * 144) - }, - GregtechItemList.Controller_Sparge_Tower.get(1), - 20 * 60 * 10, - MaterialUtils.getVoltageForTier(6)); - - // Sparge Tower Casing - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(8), - CI.getTieredGTPPMachineCasing(3, 1), - ALLOY.HS188A.getPlate(8), - ALLOY.HASTELLOY_N.getRing(4), - CI.getTieredComponentOfMaterial(Materials.TungstenSteel, OrePrefixes.plateDouble, 4), - ALLOY.HASTELLOY_N.getScrew(4), - }, - ALLOY.STAINLESS_STEEL.getFluidStack(8 * 144), - GregtechItemList.Casing_Sparge_Tower_Exterior.get(1), - 60 * 20 * 2, - MaterialUtils.getVoltageForTier(5)); - } - - private static void chisels() { - ItemStack[] aChisels = new ItemStack[] { - GregtechItemList.GT_Chisel_LV.get(1), - GregtechItemList.GT_Chisel_MV.get(1), - GregtechItemList.GT_Chisel_HV.get(1), - }; - for (int i=1;i<4;i++) { - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedBioCircuit(10+i), - CI.getTieredMachineCasing(i), - CI.getPlate(i, 4), - CI.getElectricMotor(i, 2), - CI.getConveyor(i, 2), - CI.getRobotArm(i, 1) - }, - CI.getTieredFluid(i, 144 * 4), - aChisels[i-1], - 20 * 20, - MaterialUtils.getVoltageForTier(i)); - } - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedBioCircuit(14), - aChisels[2], - CI.getPlate(4, 8), - CI.getElectricMotor(4, 8), - CI.getConveyor(4, 8), - CI.getRobotArm(4, 4) - }, - CI.getTieredFluid(4, 144 * 8), - GregtechItemList.Controller_IndustrialAutoChisel.get(1), - 20 * 20, - MaterialUtils.getVoltageForTier(4)); - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedBioCircuit(14), - ItemList.Casing_SolidSteel.get(2), - CI.getPlate(4, 2), - CI.getTieredComponent(OrePrefixes.plate, 3, 4), - CI.getTieredComponent(OrePrefixes.ring, 3, 8), - CI.getTieredComponent(OrePrefixes.rod, 2, 4), - }, - CI.getTieredFluid(2, 144 * 2), - GregtechItemList.Casing_IndustrialAutoChisel.get(1), - 20 * 20, - MaterialUtils.getVoltageForTier(3)); - - - - } - - private static void rockBreaker() { - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - CI.getNumberedAdvancedCircuit(12), - ItemList.Machine_EV_RockBreaker.get(1), - ALLOY.STAINLESS_STEEL.getPlate(8), - ALLOY.STAINLESS_STEEL.getRing(4), - CI.getTieredComponentOfMaterial(Materials.Aluminium, OrePrefixes.plateDouble, 8), - ALLOY.EGLIN_STEEL.getScrew(8), - }, - ELEMENT.getInstance().ALUMINIUM.getFluidStack(144 * 8), - GregtechItemList.Controller_IndustrialRockBreaker.get(1), - 60 * 20 * 2, - MaterialUtils.getVoltageForTier(4)); - - } - - private static void fakeMachineCasingCovers() { - GregtechItemList[] mMachineCasingCovers = new GregtechItemList[] { - GregtechItemList.FakeMachineCasingPlate_ULV, - GregtechItemList.FakeMachineCasingPlate_LV, - GregtechItemList.FakeMachineCasingPlate_MV, - GregtechItemList.FakeMachineCasingPlate_HV, - GregtechItemList.FakeMachineCasingPlate_EV, - GregtechItemList.FakeMachineCasingPlate_IV, - GregtechItemList.FakeMachineCasingPlate_LuV, - GregtechItemList.FakeMachineCasingPlate_ZPM, - GregtechItemList.FakeMachineCasingPlate_UV, - GregtechItemList.FakeMachineCasingPlate_MAX, - }; - int aMaxTier = GT_Values.VOLTAGE_NAMES.length; - if (!GTNH) { - aMaxTier = 10; - } - ItemStack aTier[] = new ItemStack[aMaxTier]; - for (int i=0;i= 30; - - setItemList(ItemList.Circuit_Primitive, GregtechItemList.Old_Circuit_Primitive); - setItemList(ItemList.Circuit_Basic, GregtechItemList.Old_Circuit_Basic); - setItemList(ItemList.Circuit_Good, GregtechItemList.Old_Circuit_Good); - setItemList(ItemList.Circuit_Advanced, GregtechItemList.Old_Circuit_Advanced); - //ItemList.Circuit_Data, GregtechItemList.Old_Circuit_Data); - setItemList(ItemList.Circuit_Elite, GregtechItemList.Old_Circuit_Elite); - setItemList(ItemList.Circuit_Master, GregtechItemList.Old_Circuit_Master); - setItemList(ItemList.Circuit_Ultimate, GregtechItemList.Old_Circuit_Ultimate); - - /** - * Try Set New circuits to have old replacements - */ - - //Basic - if (newVersion) { - setItemList(ItemList.valueOf("Circuit_Microprocessor"), GregtechItemList.Old_Circuit_Basic); //NEW - } - //Good - if (newVersion) { - setItemList(ItemList.valueOf("Circuit_Integrated_Good"), GregtechItemList.Old_Circuit_Good); //New - } - //Advanced - if (newVersion) { - setItemList(ItemList.valueOf("Circuit_Nanoprocessor"), GregtechItemList.Old_Circuit_Advanced); - } - //Data - if (newVersion) { - setItemList(ItemList.valueOf("Circuit_Quantumprocessor"), GregtechItemList.Old_Circuit_Data); - } - if (newVersion) { - setItemList(ItemList.valueOf("Circuit_Nanocomputer"), GregtechItemList.Old_Circuit_Data); - } - //Elite - if (newVersion) { - setItemList(ItemList.valueOf("Circuit_Crystalprocessor"), GregtechItemList.Old_Circuit_Elite); - } - if (newVersion) { - setItemList(ItemList.valueOf("Circuit_Quantumcomputer"), GregtechItemList.Old_Circuit_Elite); - } - if (newVersion) { - setItemList(ItemList.valueOf("Circuit_Elitenanocomputer"), GregtechItemList.Old_Circuit_Elite); - } - //Master - if (newVersion) { - setItemList(ItemList.valueOf("Circuit_Neuroprocessor"), GregtechItemList.Old_Circuit_Master); - } - if (newVersion) { - setItemList(ItemList.valueOf("Circuit_Masterquantumcomputer"), GregtechItemList.Old_Circuit_Master); - } - //Ultimate - if (newVersion) { - setItemList(ItemList.valueOf("Circuit_Wetwarecomputer"), GregtechItemList.Old_Circuit_Ultimate); - } - if (newVersion) { - setItemList(ItemList.valueOf("Circuit_Ultimatecrystalcomputer"), GregtechItemList.Old_Circuit_Ultimate); - } - if (newVersion) { - setItemList(ItemList.valueOf("Circuit_Quantummainframe"), GregtechItemList.Old_Circuit_Ultimate); - } - //Superconductor - if (newVersion) { - setItemList(ItemList.valueOf("Circuit_Wetwaresupercomputer"), GregtechItemList.Circuit_IV); - } - if (newVersion) { - setItemList(ItemList.valueOf("Circuit_Crystalmainframe"), GregtechItemList.Circuit_IV); - } - //Infinite - if (newVersion) { - setItemList(ItemList.valueOf("Circuit_Wetwaremainframe"), GregtechItemList.Circuit_LuV); - } - - //set data orbs and sticks to their new replacements - setItemList(ItemList.Tool_DataStick, GregtechItemList.Old_Tool_DataStick); - setItemList(ItemList.Tool_DataOrb, GregtechItemList.Old_Tool_DataOrb); - - setItemList(ItemList.Circuit_Board_Basic, GregtechItemList.Old_Circuit_Board_Basic); - setItemList(ItemList.Circuit_Board_Advanced, GregtechItemList.Old_Circuit_Board_Advanced); - setItemList(ItemList.Circuit_Board_Elite, GregtechItemList.Old_Circuit_Board_Elite); - setItemList(ItemList.Circuit_Parts_Advanced, GregtechItemList.Old_Circuit_Parts_Advanced); - setItemList(ItemList.Circuit_Parts_Wiring_Basic, GregtechItemList.Old_Circuit_Parts_Wiring_Basic); - setItemList(ItemList.Circuit_Parts_Wiring_Advanced, GregtechItemList.Old_Circuit_Parts_Wiring_Advanced); - setItemList(ItemList.Circuit_Parts_Wiring_Elite, GregtechItemList.Old_Circuit_Parts_Wiring_Elite); - setItemList(ItemList.Circuit_Parts_Crystal_Chip_Elite, GregtechItemList.Old_Circuit_Parts_Crystal_Chip_Elite); - setItemList(ItemList.Circuit_Parts_Crystal_Chip_Master, GregtechItemList.Old_Circuit_Parts_Crystal_Chip_Master); - - return true; - } - - private static boolean generateTradeRecipes(){ - - //Data stick and Data orbs. - //GT Type to GT++ Type - RecipeUtils.recipeBuilder( - CI.craftingToolScrewdriver, null, null, - ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32708", 32708, 1), null, null, - null, null, null, - GregtechItemList.Old_Tool_DataStick.get(1)); - RecipeUtils.recipeBuilder( - CI.craftingToolScrewdriver, null, null, - ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32707", 32707, 1), null, null, - null, null, null, - GregtechItemList.Old_Tool_DataOrb.get(1)); - - //GT++ Type to GT Type - RecipeUtils.recipeBuilder( - CI.craftingToolScrewdriver, null, null, - GregtechItemList.Old_Tool_DataStick.get(1), null, null, - null, null, null, - ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32708", 32708, 1)); - RecipeUtils.recipeBuilder( - CI.craftingToolScrewdriver, null, null, - GregtechItemList.Old_Tool_DataOrb.get(1), null, null, - null, null, null, - ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32707", 32707, 1)); - - - - //Primitive - RecipeUtils.addShapelessGregtechRecipe( - new ItemStack[]{ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32700", 32700, 1)}, - ItemUtils.getItemStackOfAmountFromOreDict("circuitPrimitive", 1)); - - //Basic - RecipeUtils.addShapelessGregtechRecipe( - new ItemStack[]{ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32701", 32701, 1)}, - ItemUtils.getItemStackOfAmountFromOreDict("circuitBasic", 1)); - RecipeUtils.addShapelessGregtechRecipe( - new ItemStack[]{ItemUtils.simpleMetaStack("gregtech:gt.metaitem.03:32078", 32078, 1)}, - ItemUtils.getItemStackOfAmountFromOreDict("circuitBasic", 1)); - - //Good - RecipeUtils.addShapelessGregtechRecipe( - new ItemStack[]{ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32702", 32702, 1)}, - ItemUtils.getItemStackOfAmountFromOreDict("circuitGood", 1)); - RecipeUtils.addShapelessGregtechRecipe( - new ItemStack[]{ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32702", 32702, 1)}, - ItemUtils.getItemStackOfAmountFromOreDict("circuitGood", 1)); - - //Advanced - RecipeUtils.addShapelessGregtechRecipe( - new ItemStack[]{ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32703", 32703, 1)}, - ItemUtils.getItemStackOfAmountFromOreDict("circuitAdvanced", 1)); - RecipeUtils.addShapelessGregtechRecipe( - new ItemStack[]{ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32703", 32703, 1)}, - ItemUtils.getItemStackOfAmountFromOreDict("circuitAdvanced", 1)); - - //Data - RecipeUtils.addShapelessGregtechRecipe( - new ItemStack[]{ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32704", 32704, 1)}, - ItemUtils.getItemStackOfAmountFromOreDict("circuitData", 1)); - - //Elite - RecipeUtils.addShapelessGregtechRecipe( - new ItemStack[]{ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32705", 32705, 1)}, - ItemUtils.getItemStackOfAmountFromOreDict("circuitElite", 1)); - - //Master - RecipeUtils.addShapelessGregtechRecipe( - new ItemStack[]{ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32706", 32706, 1)}, - ItemUtils.getItemStackOfAmountFromOreDict("circuitMaster", 1)); - - - - //Components - //Green Chip - RecipeUtils.addShapelessGregtechRecipe( - new ItemStack[]{ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32713", 32713, 1)}, - GregtechItemList.Old_Circuit_Parts_Crystal_Chip_Elite.get(1)); - //Blue Chip - RecipeUtils.addShapelessGregtechRecipe( - new ItemStack[]{ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32714", 32714, 1)}, - GregtechItemList.Old_Circuit_Parts_Crystal_Chip_Master.get(1)); - - //Basic Board - RecipeUtils.addShapelessGregtechRecipe( - new ItemStack[]{ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32710", 32710, 1)}, - GregtechItemList.Old_Circuit_Board_Basic.get(1)); - //Advanced Board - RecipeUtils.addShapelessGregtechRecipe( - new ItemStack[]{ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32711", 32711, 1)}, - GregtechItemList.Old_Circuit_Board_Advanced.get(1)); - //Elite Board - RecipeUtils.addShapelessGregtechRecipe( - new ItemStack[]{ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32712", 32712, 1)}, - GregtechItemList.Old_Circuit_Board_Elite.get(1)); - - - //remove a few recipes - /*GT_ModHandler.removeRecipeByOutput(ItemUtils.simpleMetaStack("gregtech:gt.metaitem.03:32070", 32070, 1)); - GT_ModHandler.removeRecipeByOutput(ItemUtils.simpleMetaStack("gregtech:gt.metaitem.03:32069", 32069, 1)); - if (LoadedMods.Extra_Utils){ - ItemStack EQU = ItemUtils.simpleMetaStack("ExtraUtilities:enderQuarryUpgrade", 0, 1); - if (EQU != null){ - GT_ModHandler.removeRecipeByOutput(EQU); - GT_Values.RA.addAssemblerRecipe( - ItemUtils.simpleMetaStack("ExtraUtilities:decorativeBlock1:12", 12, 1), - GregtechItemList.Old_Circuit_Master.get(1), - EQU, - 80*20, - 2); - } - } - if (LoadedMods.GalacticraftCore){ - ItemStack ACW = ItemUtils.simpleMetaStack("GalacticraftCore:item.basicItem:14", 14, 1); - if (ACW != null){ - GT_ModHandler.removeRecipeByOutput(ACW); - GT_Values.RA.addAssemblerRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("gemDiamond", 1), - GregtechItemList.Old_Circuit_Board_Advanced.get(1), - ACW, - 160*20, - 4); - } - ItemStack ACW2 = ItemUtils.simpleMetaStack("GalacticraftCore:item.basicItem:13", 13, 1); - if (ACW2 != null){ - GT_ModHandler.removeRecipeByOutput(ACW2); - GT_Values.RA.addAssemblerRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("gemDiamond", 1), - GregtechItemList.Old_Circuit_Board_Basic.get(1), - ACW2, - 80*20, - 2); - } - }*/ - - return true; - } - - private static boolean hideCircuitsNEI(){ - Boolean isNEILoaded = Loader.isModLoaded("NotEnoughItems"); - if (isNEILoaded && !CORE.ConfigSwitches.showHiddenNEIItems){ - Logger.INFO("[Old Feature - Circuits] Hiding .28+ circuits in NEI."); - String[] CircuitToHide = { - "Circuit_Board_Basic", - "Circuit_Board_Advanced", - "Circuit_Board_Elite", - "Circuit_Parts_Advanced", - "Circuit_Parts_Wiring_Basic", - "Circuit_Parts_Wiring_Advanced", - "Circuit_Parts_Wiring_Elite", - "Circuit_Parts_Crystal_Chip_Elite", - "Circuit_Parts_Crystal_Chip_Master", - "Circuit_Primitive", - "Circuit_Basic", - "Circuit_Integrated_Good", - "Circuit_Good", - "Circuit_Advanced", - "Circuit_Data", - "Circuit_Elite", - "Circuit_Master", - "Circuit_Ultimate", - "Circuit_Board_Coated", - "Circuit_Board_Phenolic", - "Circuit_Board_Epoxy", - "Circuit_Board_Fiberglass", - "Circuit_Board_Multifiberglass", - "Circuit_Board_Wetware", - "Circuit_Parts_Resistor", - "Circuit_Parts_ResistorSMD", - "Circuit_Parts_Glass_Tube", - "Circuit_Parts_Vacuum_Tube", - "Circuit_Parts_Coil", - "Circuit_Parts_Diode", - "Circuit_Parts_DiodeSMD", - "Circuit_Parts_Transistor", - "Circuit_Parts_TransistorSMD", - "Circuit_Parts_Capacitor", - "Circuit_Parts_CapacitorSMD", - "Circuit_Silicon_Ingot", - "Circuit_Silicon_Ingot2", - "Circuit_Silicon_Ingot3", - "Circuit_Silicon_Wafer", - "Circuit_Silicon_Wafer2", - "Circuit_Silicon_Wafer3", - "Circuit_Wafer_ILC", - "Circuit_Chip_ILC", - "Circuit_Wafer_Ram", - "Circuit_Chip_Ram", - "Circuit_Wafer_NAND", - "Circuit_Chip_NAND", - "Circuit_Wafer_NOR", - "Circuit_Chip_NOR", - "Circuit_Wafer_CPU", - "Circuit_Chip_CPU", - "Circuit_Wafer_SoC", - "Circuit_Chip_SoC", - "Circuit_Wafer_SoC2", - "Circuit_Chip_SoC2", - "Circuit_Wafer_PIC", - "Circuit_Chip_PIC", - "Circuit_Wafer_HPIC", - "Circuit_Chip_HPIC", - "Circuit_Wafer_NanoCPU", - "Circuit_Chip_NanoCPU", - "Circuit_Wafer_QuantumCPU", - "Circuit_Chip_QuantumCPU", - "Circuit_Chip_CrystalCPU", - "Circuit_Chip_CrystalSoC", - "Circuit_Chip_NeuroCPU", - "Circuit_Chip_Stemcell", - "Circuit_Processor", - "Circuit_Computer", - "Circuit_Nanoprocessor", - "Circuit_Nanocomputer", - "Circuit_Elitenanocomputer", - "Circuit_Quantumprocessor", - "Circuit_Quantumcomputer", - "Circuit_Masterquantumcomputer", - "Circuit_Quantummainframe", - "Circuit_Crystalprocessor", - "Circuit_Crystalcomputer", - "Circuit_Ultimatecrystalcomputer", - "Circuit_Crystalmainframe", - "Circuit_Neuroprocessor", - "Circuit_Wetwarecomputer", - "Circuit_Wetwaresupercomputer", - "Circuit_Wetwaremainframe", - "Circuit_Parts_RawCrystalChip", - //Circuits Additions in .30/.31 - "Circuit_Board_Plastic", - "Circuit_Parts_GlassFiber", - "Circuit_Parts_PetriDish", - "Circuit_Microprocessor" - }; - - for (String component : CircuitToHide){ - try { - ItemUtils.hideItemFromNEI(ItemUtils.getValueOfItemList(component, null).get(1L, new Object[0])); - } catch (IllegalArgumentException I){ - Logger.INFO("Could not find "+component+" in the Gregtech item list."); - Logger.INFO("This is NOT an error, simply a notification."); - } - } - } - return true; - } - +public class RECIPES_Old_Circuits implements IOreRecipeRegistrator { + public RECIPES_Old_Circuits() { + OrePrefixes.crafting.add(this); + } + + @Override + public void registerOre( + final OrePrefixes aPrefix, + final Materials aMaterial, + final String aOreDictName, + final String aModName, + final ItemStack aStack) { + if (aOreDictName.equals(OreDictNames.craftingLensRed.toString())) { + Logger.INFO("[Old Feature - Circuits] Adding recipes for old circuits. (Part 2)"); + GT_Values.RA.addLaserEngraverRecipe( + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Copper, 1L), + GT_Utility.copyAmount(0L, new Object[] {aStack}), + GregtechItemList.Old_Circuit_Parts_Wiring_Basic.get(1L, new Object[0]), + 64, + 30); + GT_Values.RA.addLaserEngraverRecipe( + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.AnnealedCopper, 1L), + GT_Utility.copyAmount(0L, new Object[] {aStack}), + GregtechItemList.Old_Circuit_Parts_Wiring_Basic.get(1L, new Object[0]), + 64, + 30); + GT_Values.RA.addLaserEngraverRecipe( + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Gold, 1L), + GT_Utility.copyAmount(0L, new Object[] {aStack}), + GregtechItemList.Old_Circuit_Parts_Wiring_Advanced.get(1L, new Object[0]), + 64, + 120); + GT_Values.RA.addLaserEngraverRecipe( + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Electrum, 1L), + GT_Utility.copyAmount(0L, new Object[] {aStack}), + GregtechItemList.Old_Circuit_Parts_Wiring_Advanced.get(1L, new Object[0]), + 64, + 120); + GT_Values.RA.addLaserEngraverRecipe( + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Platinum, 1L), + GT_Utility.copyAmount(0L, new Object[] {aStack}), + GregtechItemList.Old_Circuit_Parts_Wiring_Elite.get(1L, new Object[0]), + 64, + 480); + } else if (aOreDictName.equals(OreDictNames.craftingLensGreen.toString())) { + Logger.INFO("[Old Feature - Circuits] Adding recipes for old circuits. (Part 3)"); + GT_Values.RA.addLaserEngraverRecipe( + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Olivine, 1L), + GT_Utility.copyAmount(0L, new Object[] {aStack}), + GregtechItemList.Old_Circuit_Parts_Crystal_Chip_Elite.get(1L, new Object[0]), + 256, + 480); + GT_Values.RA.addLaserEngraverRecipe( + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Emerald, 1L), + GT_Utility.copyAmount(0L, new Object[] {aStack}), + GregtechItemList.Old_Circuit_Parts_Crystal_Chip_Elite.get(1L, new Object[0]), + 256, + 480); + } else if (aOreDictName.equals(OreDictNames.craftingLensBlue.toString()) + || aOreDictName.equals(OreDictNames.craftingLensCyan.toString()) + || aOreDictName.equals(OreDictNames.craftingLensLightBlue.toString())) { + Logger.INFO("[Old Feature - Circuits] Adding recipes for old circuits. (Part 4)"); + GT_Values.RA.addLaserEngraverRecipe( + ItemList.IC2_LapotronCrystal.getWildcard(1L, new Object[0]), + GT_Utility.copyAmount(0L, new Object[] {aStack}), + GregtechItemList.Old_Circuit_Parts_Crystal_Chip_Master.get(3L, new Object[0]), + 256, + 480); + } + } + + private static boolean addCircuitRecipes() { + Logger.INFO("[Old Feature - Circuits] Adding recipes for old circuits. (Part 1)"); + GT_ModHandler.addShapelessCraftingRecipe( + GregtechItemList.Old_Circuit_Primitive.get(1L, new Object[0]), new Object[] { + GT_ModHandler.getIC2Item("casingadviron", 1L), + OrePrefixes.wireGt01.get(Materials.RedAlloy), + OrePrefixes.wireGt01.get(Materials.RedAlloy), + OrePrefixes.wireGt01.get(Materials.Tin) + }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Old_Circuit_Basic.get(1L, new Object[0]), new Object[] { + "WWW", + "CPC", + "WWW", + 'C', + OrePrefixes.circuit.get(Materials.Primitive), + 'W', + OreDictNames.craftingWireCopper, + 'P', + OrePrefixes.plate.get(Materials.Steel) + }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Old_Circuit_Basic.get(1L, new Object[0]), new Object[] { + "WCW", + "WPW", + "WCW", + 'C', + OrePrefixes.circuit.get(Materials.Primitive), + 'W', + OreDictNames.craftingWireCopper, + 'P', + OrePrefixes.plate.get(Materials.Steel) + }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Old_Circuit_Basic.get(1L, new Object[0]), new Object[] { + "WWW", + "CPC", + "WWW", + 'C', + OrePrefixes.circuit.get(Materials.Primitive), + 'W', + OrePrefixes.cableGt01.get(Materials.RedAlloy), + 'P', + OrePrefixes.plate.get(Materials.Steel) + }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Old_Circuit_Basic.get(1L, new Object[0]), new Object[] { + "WCW", + "WPW", + "WCW", + 'C', + OrePrefixes.circuit.get(Materials.Primitive), + 'W', + OrePrefixes.cableGt01.get(Materials.RedAlloy), + 'P', + OrePrefixes.plate.get(Materials.Steel) + }); + + GT_Values.RA.addFormingPressRecipe( + GregtechItemList.Old_Empty_Board_Basic.get(1L, new Object[0]), + GregtechItemList.Old_Circuit_Parts_Wiring_Basic.get(4L, new Object[0]), + GregtechItemList.Old_Circuit_Board_Basic.get(1L, new Object[0]), + 32, + 16); + GT_Values.RA.addFormingPressRecipe( + GregtechItemList.Old_Empty_Board_Basic.get(1L, new Object[0]), + GregtechItemList.Old_Circuit_Parts_Wiring_Advanced.get(4L, new Object[0]), + GregtechItemList.Old_Circuit_Board_Advanced.get(1L, new Object[0]), + 32, + 64); + GT_Values.RA.addFormingPressRecipe( + GregtechItemList.Old_Empty_Board_Elite.get(1L, new Object[0]), + GregtechItemList.Old_Circuit_Parts_Wiring_Elite.get(4L, new Object[0]), + GregtechItemList.Old_Circuit_Board_Elite.get(1L, new Object[0]), + 32, + 256); + + GT_Values.RA.addFormingPressRecipe( + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Lapis, 1L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Glowstone, 1L), + GregtechItemList.Old_Circuit_Parts_Advanced.get(2L, new Object[0]), + 32, + 64); + GT_Values.RA.addFormingPressRecipe( + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Lazurite, 1L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Glowstone, 1L), + GregtechItemList.Old_Circuit_Parts_Advanced.get(2L, new Object[0]), + 32, + 64); + + int tMultiplier; + for (Materials tMat : Materials.values()) { + if ((tMat.mStandardMoltenFluid != null) && (tMat.contains(SubTag.SOLDERING_MATERIAL))) { + tMultiplier = tMat.contains(SubTag.SOLDERING_MATERIAL_BAD) + ? 4 + : tMat.contains(SubTag.SOLDERING_MATERIAL_GOOD) ? 1 : 2; + + GT_Values.RA.addAssemblerRecipe( + ItemList.IC2_Item_Casing_Steel.get(1L, new Object[0]), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.RedAlloy, 2L), + tMat.getMolten(144L * tMultiplier / 8L), + GregtechItemList.Old_Circuit_Primitive.get(1L, new Object[0]), + 16, + 8); + GT_Values.RA.addAssemblerRecipe( + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Plastic, 1L), + GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.RedAlloy, 1L), + tMat.getMolten(144L * tMultiplier / 8L), + GregtechItemList.Old_Circuit_Primitive.get(1L, new Object[0]), + 16, + 8); + GT_Values.RA.addAssemblerRecipe( + GregtechItemList.Old_Circuit_Board_Basic.get(1L, new Object[0]), + GregtechItemList.Old_Circuit_Primitive.get(2L, new Object[0]), + tMat.getMolten(144L * tMultiplier / 4L), + GregtechItemList.Old_Circuit_Basic.get(1L, new Object[0]), + 32, + 16); + GT_Values.RA.addAssemblerRecipe( + GregtechItemList.Old_Circuit_Basic.get(1L, new Object[0]), + GregtechItemList.Old_Circuit_Primitive.get(2L, new Object[0]), + tMat.getMolten(144L * tMultiplier / 4L), + GregtechItemList.Old_Circuit_Good.get(1L, new Object[0]), + 32, + 16); + GT_Values.RA.addAssemblerRecipe( + GregtechItemList.Old_Circuit_Board_Advanced.get(1L, new Object[0]), + GregtechItemList.Old_Circuit_Parts_Advanced.get(2L, new Object[0]), + tMat.getMolten(144L * tMultiplier / 2L), + GregtechItemList.Old_Circuit_Advanced.get(1L, new Object[0]), + 32, + 64); + GT_Values.RA.addAssemblerRecipe( + GregtechItemList.Old_Circuit_Board_Advanced.get(1L, new Object[0]), + GregtechItemList.Old_Circuit_Parts_Crystal_Chip_Elite.get(1L, new Object[0]), + tMat.getMolten(144L * tMultiplier / 2L), + GregtechItemList.Old_Circuit_Data.get(1L, new Object[0]), + 32, + 64); + GT_Values.RA.addAssemblerRecipe( + GregtechItemList.Old_Circuit_Board_Elite.get(1L, new Object[0]), + GregtechItemList.Old_Circuit_Data.get(3L, new Object[0]), + tMat.getMolten(144L * tMultiplier / 1L), + GregtechItemList.Old_Circuit_Elite.get(1L, new Object[0]), + 32, + 256); + GT_Values.RA.addAssemblerRecipe( + GregtechItemList.Old_Circuit_Board_Elite.get(1L, new Object[0]), + ItemList.Circuit_Parts_Crystal_Chip_Master.get(3L, new Object[0]), + tMat.getMolten(144L * tMultiplier / 1L), + GregtechItemList.Old_Circuit_Master.get(1L, new Object[0]), + 32, + 256); + GT_Values.RA.addAssemblerRecipe( + GregtechItemList.Old_Circuit_Board_Elite.get(1L, new Object[0]), + GregtechItemList.Old_Circuit_Parts_Crystal_Chip_Master.get(3L, new Object[0]), + tMat.getMolten(144L * tMultiplier / 1L), + GregtechItemList.Old_Circuit_Master.get(1L, new Object[0]), + 32, + 256); + GT_Values.RA.addAssemblerRecipe( + GregtechItemList.Old_Circuit_Data.get(1L, new Object[0]), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Plastic, 2L), + tMat.getMolten(144L * tMultiplier / 2L), + GregtechItemList.Old_Tool_DataStick.get(1L, new Object[0]), + 128, + 64); + } + } + + GT_Values.RA.addAssemblerRecipe( + GregtechItemList.Old_Circuit_Elite.get(2L, new Object[0]), + GregtechItemList.Old_Circuit_Parts_Crystal_Chip_Elite.get(18L, new Object[0]), + GT_Values.NF, + GregtechItemList.Old_Tool_DataOrb.get(1L, new Object[0]), + 512, + 256); + GT_Values.RA.addAssemblerRecipe( + GregtechItemList.Old_Circuit_Master.get(2L, new Object[0]), + ItemList.Circuit_Parts_Crystal_Chip_Master.get(18L, new Object[0]), + GT_Values.NF, + ItemList.Energy_LapotronicOrb.get(1L, new Object[0]), + 512, + 1024); + GT_Values.RA.addAssemblerRecipe( + GregtechItemList.Old_Circuit_Master.get(2L, new Object[0]), + GregtechItemList.Old_Circuit_Parts_Crystal_Chip_Master.get(18L, new Object[0]), + GT_Values.NF, + ItemList.Energy_LapotronicOrb.get(1L, new Object[0]), + 512, + 1024); + GT_Values.RA.addAssemblerRecipe( + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Silicon, 1L), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Plastic, 1L), + GregtechItemList.Old_Empty_Board_Basic.get(1L, new Object[0]), + 32, + 16); + + Materials plasticType = Materials.get("Polytetrafluoroethylene") != null + ? Materials.get("Polytetrafluoroethylene") + : Materials.Plastic; + GT_Values.RA.addAssemblerRecipe( + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Silicon, 2L), + GT_OreDictUnificator.get(OrePrefixes.plate, plasticType, 1L), + GregtechItemList.Old_Empty_Board_Elite.get(1L, new Object[0]), + 32, + 256); + + return true; + } + + public static boolean handleCircuits() { + hideCircuitsNEI(); + addCircuitRecipes(); + removeNewCircuits(); + generateTradeRecipes(); + return true; + } + + private static boolean setItemList(ItemList Set, GregtechItemList Get) { + try { + Set.set(Get.get(1)); + return true; + } catch (Throwable t) { + } + return false; + } + + private static boolean removeNewCircuits() { + Logger.INFO( + "[Old Feature - Circuits] Overriding .28+ circuit values in the GT5u Itemlist with values from GT++."); + + boolean newVersion = CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && Utils.getGregtechSubVersion() >= 30; + + setItemList(ItemList.Circuit_Primitive, GregtechItemList.Old_Circuit_Primitive); + setItemList(ItemList.Circuit_Basic, GregtechItemList.Old_Circuit_Basic); + setItemList(ItemList.Circuit_Good, GregtechItemList.Old_Circuit_Good); + setItemList(ItemList.Circuit_Advanced, GregtechItemList.Old_Circuit_Advanced); + // ItemList.Circuit_Data, GregtechItemList.Old_Circuit_Data); + setItemList(ItemList.Circuit_Elite, GregtechItemList.Old_Circuit_Elite); + setItemList(ItemList.Circuit_Master, GregtechItemList.Old_Circuit_Master); + setItemList(ItemList.Circuit_Ultimate, GregtechItemList.Old_Circuit_Ultimate); + + /** + * Try Set New circuits to have old replacements + */ + + // Basic + if (newVersion) { + setItemList(ItemList.valueOf("Circuit_Microprocessor"), GregtechItemList.Old_Circuit_Basic); // NEW + } + // Good + if (newVersion) { + setItemList(ItemList.valueOf("Circuit_Integrated_Good"), GregtechItemList.Old_Circuit_Good); // New + } + // Advanced + if (newVersion) { + setItemList(ItemList.valueOf("Circuit_Nanoprocessor"), GregtechItemList.Old_Circuit_Advanced); + } + // Data + if (newVersion) { + setItemList(ItemList.valueOf("Circuit_Quantumprocessor"), GregtechItemList.Old_Circuit_Data); + } + if (newVersion) { + setItemList(ItemList.valueOf("Circuit_Nanocomputer"), GregtechItemList.Old_Circuit_Data); + } + // Elite + if (newVersion) { + setItemList(ItemList.valueOf("Circuit_Crystalprocessor"), GregtechItemList.Old_Circuit_Elite); + } + if (newVersion) { + setItemList(ItemList.valueOf("Circuit_Quantumcomputer"), GregtechItemList.Old_Circuit_Elite); + } + if (newVersion) { + setItemList(ItemList.valueOf("Circuit_Elitenanocomputer"), GregtechItemList.Old_Circuit_Elite); + } + // Master + if (newVersion) { + setItemList(ItemList.valueOf("Circuit_Neuroprocessor"), GregtechItemList.Old_Circuit_Master); + } + if (newVersion) { + setItemList(ItemList.valueOf("Circuit_Masterquantumcomputer"), GregtechItemList.Old_Circuit_Master); + } + // Ultimate + if (newVersion) { + setItemList(ItemList.valueOf("Circuit_Wetwarecomputer"), GregtechItemList.Old_Circuit_Ultimate); + } + if (newVersion) { + setItemList(ItemList.valueOf("Circuit_Ultimatecrystalcomputer"), GregtechItemList.Old_Circuit_Ultimate); + } + if (newVersion) { + setItemList(ItemList.valueOf("Circuit_Quantummainframe"), GregtechItemList.Old_Circuit_Ultimate); + } + // Superconductor + if (newVersion) { + setItemList(ItemList.valueOf("Circuit_Wetwaresupercomputer"), GregtechItemList.Circuit_IV); + } + if (newVersion) { + setItemList(ItemList.valueOf("Circuit_Crystalmainframe"), GregtechItemList.Circuit_IV); + } + // Infinite + if (newVersion) { + setItemList(ItemList.valueOf("Circuit_Wetwaremainframe"), GregtechItemList.Circuit_LuV); + } + + // set data orbs and sticks to their new replacements + setItemList(ItemList.Tool_DataStick, GregtechItemList.Old_Tool_DataStick); + setItemList(ItemList.Tool_DataOrb, GregtechItemList.Old_Tool_DataOrb); + + setItemList(ItemList.Circuit_Board_Basic, GregtechItemList.Old_Circuit_Board_Basic); + setItemList(ItemList.Circuit_Board_Advanced, GregtechItemList.Old_Circuit_Board_Advanced); + setItemList(ItemList.Circuit_Board_Elite, GregtechItemList.Old_Circuit_Board_Elite); + setItemList(ItemList.Circuit_Parts_Advanced, GregtechItemList.Old_Circuit_Parts_Advanced); + setItemList(ItemList.Circuit_Parts_Wiring_Basic, GregtechItemList.Old_Circuit_Parts_Wiring_Basic); + setItemList(ItemList.Circuit_Parts_Wiring_Advanced, GregtechItemList.Old_Circuit_Parts_Wiring_Advanced); + setItemList(ItemList.Circuit_Parts_Wiring_Elite, GregtechItemList.Old_Circuit_Parts_Wiring_Elite); + setItemList(ItemList.Circuit_Parts_Crystal_Chip_Elite, GregtechItemList.Old_Circuit_Parts_Crystal_Chip_Elite); + setItemList(ItemList.Circuit_Parts_Crystal_Chip_Master, GregtechItemList.Old_Circuit_Parts_Crystal_Chip_Master); + + return true; + } + + private static boolean generateTradeRecipes() { + + // Data stick and Data orbs. + // GT Type to GT++ Type + RecipeUtils.recipeBuilder( + CI.craftingToolScrewdriver, + null, + null, + ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32708", 32708, 1), + null, + null, + null, + null, + null, + GregtechItemList.Old_Tool_DataStick.get(1)); + RecipeUtils.recipeBuilder( + CI.craftingToolScrewdriver, + null, + null, + ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32707", 32707, 1), + null, + null, + null, + null, + null, + GregtechItemList.Old_Tool_DataOrb.get(1)); + + // GT++ Type to GT Type + RecipeUtils.recipeBuilder( + CI.craftingToolScrewdriver, + null, + null, + GregtechItemList.Old_Tool_DataStick.get(1), + null, + null, + null, + null, + null, + ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32708", 32708, 1)); + RecipeUtils.recipeBuilder( + CI.craftingToolScrewdriver, + null, + null, + GregtechItemList.Old_Tool_DataOrb.get(1), + null, + null, + null, + null, + null, + ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32707", 32707, 1)); + + // Primitive + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[] {ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32700", 32700, 1)}, + ItemUtils.getItemStackOfAmountFromOreDict("circuitPrimitive", 1)); + + // Basic + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[] {ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32701", 32701, 1)}, + ItemUtils.getItemStackOfAmountFromOreDict("circuitBasic", 1)); + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[] {ItemUtils.simpleMetaStack("gregtech:gt.metaitem.03:32078", 32078, 1)}, + ItemUtils.getItemStackOfAmountFromOreDict("circuitBasic", 1)); + + // Good + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[] {ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32702", 32702, 1)}, + ItemUtils.getItemStackOfAmountFromOreDict("circuitGood", 1)); + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[] {ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32702", 32702, 1)}, + ItemUtils.getItemStackOfAmountFromOreDict("circuitGood", 1)); + + // Advanced + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[] {ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32703", 32703, 1)}, + ItemUtils.getItemStackOfAmountFromOreDict("circuitAdvanced", 1)); + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[] {ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32703", 32703, 1)}, + ItemUtils.getItemStackOfAmountFromOreDict("circuitAdvanced", 1)); + + // Data + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[] {ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32704", 32704, 1)}, + ItemUtils.getItemStackOfAmountFromOreDict("circuitData", 1)); + + // Elite + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[] {ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32705", 32705, 1)}, + ItemUtils.getItemStackOfAmountFromOreDict("circuitElite", 1)); + + // Master + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[] {ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32706", 32706, 1)}, + ItemUtils.getItemStackOfAmountFromOreDict("circuitMaster", 1)); + + // Components + // Green Chip + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[] {ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32713", 32713, 1)}, + GregtechItemList.Old_Circuit_Parts_Crystal_Chip_Elite.get(1)); + // Blue Chip + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[] {ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32714", 32714, 1)}, + GregtechItemList.Old_Circuit_Parts_Crystal_Chip_Master.get(1)); + + // Basic Board + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[] {ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32710", 32710, 1)}, + GregtechItemList.Old_Circuit_Board_Basic.get(1)); + // Advanced Board + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[] {ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32711", 32711, 1)}, + GregtechItemList.Old_Circuit_Board_Advanced.get(1)); + // Elite Board + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[] {ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32712", 32712, 1)}, + GregtechItemList.Old_Circuit_Board_Elite.get(1)); + + // remove a few recipes + /*GT_ModHandler.removeRecipeByOutput(ItemUtils.simpleMetaStack("gregtech:gt.metaitem.03:32070", 32070, 1)); + GT_ModHandler.removeRecipeByOutput(ItemUtils.simpleMetaStack("gregtech:gt.metaitem.03:32069", 32069, 1)); + if (LoadedMods.Extra_Utils){ + ItemStack EQU = ItemUtils.simpleMetaStack("ExtraUtilities:enderQuarryUpgrade", 0, 1); + if (EQU != null){ + GT_ModHandler.removeRecipeByOutput(EQU); + GT_Values.RA.addAssemblerRecipe( + ItemUtils.simpleMetaStack("ExtraUtilities:decorativeBlock1:12", 12, 1), + GregtechItemList.Old_Circuit_Master.get(1), + EQU, + 80*20, + 2); + } + } + if (LoadedMods.GalacticraftCore){ + ItemStack ACW = ItemUtils.simpleMetaStack("GalacticraftCore:item.basicItem:14", 14, 1); + if (ACW != null){ + GT_ModHandler.removeRecipeByOutput(ACW); + GT_Values.RA.addAssemblerRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("gemDiamond", 1), + GregtechItemList.Old_Circuit_Board_Advanced.get(1), + ACW, + 160*20, + 4); + } + ItemStack ACW2 = ItemUtils.simpleMetaStack("GalacticraftCore:item.basicItem:13", 13, 1); + if (ACW2 != null){ + GT_ModHandler.removeRecipeByOutput(ACW2); + GT_Values.RA.addAssemblerRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("gemDiamond", 1), + GregtechItemList.Old_Circuit_Board_Basic.get(1), + ACW2, + 80*20, + 2); + } + }*/ + + return true; + } + + private static boolean hideCircuitsNEI() { + Boolean isNEILoaded = Loader.isModLoaded("NotEnoughItems"); + if (isNEILoaded && !CORE.ConfigSwitches.showHiddenNEIItems) { + Logger.INFO("[Old Feature - Circuits] Hiding .28+ circuits in NEI."); + String[] CircuitToHide = { + "Circuit_Board_Basic", + "Circuit_Board_Advanced", + "Circuit_Board_Elite", + "Circuit_Parts_Advanced", + "Circuit_Parts_Wiring_Basic", + "Circuit_Parts_Wiring_Advanced", + "Circuit_Parts_Wiring_Elite", + "Circuit_Parts_Crystal_Chip_Elite", + "Circuit_Parts_Crystal_Chip_Master", + "Circuit_Primitive", + "Circuit_Basic", + "Circuit_Integrated_Good", + "Circuit_Good", + "Circuit_Advanced", + "Circuit_Data", + "Circuit_Elite", + "Circuit_Master", + "Circuit_Ultimate", + "Circuit_Board_Coated", + "Circuit_Board_Phenolic", + "Circuit_Board_Epoxy", + "Circuit_Board_Fiberglass", + "Circuit_Board_Multifiberglass", + "Circuit_Board_Wetware", + "Circuit_Parts_Resistor", + "Circuit_Parts_ResistorSMD", + "Circuit_Parts_Glass_Tube", + "Circuit_Parts_Vacuum_Tube", + "Circuit_Parts_Coil", + "Circuit_Parts_Diode", + "Circuit_Parts_DiodeSMD", + "Circuit_Parts_Transistor", + "Circuit_Parts_TransistorSMD", + "Circuit_Parts_Capacitor", + "Circuit_Parts_CapacitorSMD", + "Circuit_Silicon_Ingot", + "Circuit_Silicon_Ingot2", + "Circuit_Silicon_Ingot3", + "Circuit_Silicon_Wafer", + "Circuit_Silicon_Wafer2", + "Circuit_Silicon_Wafer3", + "Circuit_Wafer_ILC", + "Circuit_Chip_ILC", + "Circuit_Wafer_Ram", + "Circuit_Chip_Ram", + "Circuit_Wafer_NAND", + "Circuit_Chip_NAND", + "Circuit_Wafer_NOR", + "Circuit_Chip_NOR", + "Circuit_Wafer_CPU", + "Circuit_Chip_CPU", + "Circuit_Wafer_SoC", + "Circuit_Chip_SoC", + "Circuit_Wafer_SoC2", + "Circuit_Chip_SoC2", + "Circuit_Wafer_PIC", + "Circuit_Chip_PIC", + "Circuit_Wafer_HPIC", + "Circuit_Chip_HPIC", + "Circuit_Wafer_NanoCPU", + "Circuit_Chip_NanoCPU", + "Circuit_Wafer_QuantumCPU", + "Circuit_Chip_QuantumCPU", + "Circuit_Chip_CrystalCPU", + "Circuit_Chip_CrystalSoC", + "Circuit_Chip_NeuroCPU", + "Circuit_Chip_Stemcell", + "Circuit_Processor", + "Circuit_Computer", + "Circuit_Nanoprocessor", + "Circuit_Nanocomputer", + "Circuit_Elitenanocomputer", + "Circuit_Quantumprocessor", + "Circuit_Quantumcomputer", + "Circuit_Masterquantumcomputer", + "Circuit_Quantummainframe", + "Circuit_Crystalprocessor", + "Circuit_Crystalcomputer", + "Circuit_Ultimatecrystalcomputer", + "Circuit_Crystalmainframe", + "Circuit_Neuroprocessor", + "Circuit_Wetwarecomputer", + "Circuit_Wetwaresupercomputer", + "Circuit_Wetwaremainframe", + "Circuit_Parts_RawCrystalChip", + // Circuits Additions in .30/.31 + "Circuit_Board_Plastic", + "Circuit_Parts_GlassFiber", + "Circuit_Parts_PetriDish", + "Circuit_Microprocessor" + }; + + for (String component : CircuitToHide) { + try { + ItemUtils.hideItemFromNEI( + ItemUtils.getValueOfItemList(component, null).get(1L, new Object[0])); + } catch (IllegalArgumentException I) { + Logger.INFO("Could not find " + component + " in the Gregtech item list."); + Logger.INFO("This is NOT an error, simply a notification."); + } + } + } + return true; + } } diff --git a/src/main/java/gtPlusPlus/core/recipe/RECIPES_RareEarthProcessing.java b/src/main/java/gtPlusPlus/core/recipe/RECIPES_RareEarthProcessing.java index 860a87deae..b55bb260dd 100644 --- a/src/main/java/gtPlusPlus/core/recipe/RECIPES_RareEarthProcessing.java +++ b/src/main/java/gtPlusPlus/core/recipe/RECIPES_RareEarthProcessing.java @@ -15,7 +15,6 @@ import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_OreDictUnificator; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.material.MISC_MATERIALS; import gtPlusPlus.core.material.MaterialGenerator; import gtPlusPlus.core.material.ORES; @@ -29,225 +28,211 @@ import net.minecraftforge.fluids.FluidStack; public class RECIPES_RareEarthProcessing { - private static ItemStack mDustSodiumHydroxide; - private static ItemStack mDustSalt; - private static FluidStack mSaltWater; - private static FluidStack mBrine; - private static FluidStack mHydrogenChloride; - - public static void init() { - - // Salt Check and Assignment - mDustSalt = ItemUtils.getItemStackOfAmountFromOreDict("dustSalt", 1); - if (mDustSalt == null) { - MaterialUtils.generateSpecialDustAndAssignToAMaterial(SODIUM_CHLORIDE, false); - mDustSalt = SODIUM_CHLORIDE.getDust(1); - } - else { - SODIUM_CHLORIDE.registerComponentForMaterial(OrePrefixes.dust, mDustSalt); - } - - // Salt water Check and Assignment - mSaltWater = FluidUtils.getFluidStack("saltwater", 1000); - if (mSaltWater == null) { - Fluid f = SALT_WATER.generateFluid(); - SALT_WATER.registerComponentForMaterial(FluidUtils.getFluidStack(f, 1000)); - mSaltWater = SALT_WATER.getFluidStack(1000); - } - else { - SALT_WATER.registerComponentForMaterial(FluidUtils.getFluidStack(mSaltWater, 1000)); - } - - // Brine Check and assignment - mBrine = FluidUtils.getFluidStack("brine", 1000); - if (mBrine == null) { - Fluid f = BRINE.generateFluid(); - BRINE.registerComponentForMaterial(FluidUtils.getFluidStack(f, 1000)); - mBrine = BRINE.getFluidStack(1000); - } - else { - BRINE.registerComponentForMaterial(FluidUtils.getFluidStack(mBrine, 1000)); - } - - // Check Sodium Hydroxide Exists, generate if not. - mDustSodiumHydroxide = ItemUtils.getItemStackOfAmountFromOreDict("dustSodiumHydroxide", 1); - if (mDustSodiumHydroxide == null) { - mDustSodiumHydroxide = ItemUtils.getItemStackOfAmountFromOreDict("dustSodiumHydroxide_GT5U", 1); - if (mDustSodiumHydroxide == null) { - MaterialUtils.generateSpecialDustAndAssignToAMaterial(SODIUM_HYDROXIDE, false); - mDustSodiumHydroxide = SODIUM_HYDROXIDE.getDust(1); - } - else { - SODIUM_HYDROXIDE.registerComponentForMaterial(OrePrefixes.dust, mDustSodiumHydroxide); - } - } - else { - SODIUM_HYDROXIDE.registerComponentForMaterial(OrePrefixes.dust, mDustSodiumHydroxide); - } - - // Hydrogen Chloride Check and assignment - mHydrogenChloride = FluidUtils.getFluidStack("hydrogenchloride", 1000); - if (mHydrogenChloride == null) { - HYDROGEN_CHLORIDE.generateFluid(); - mHydrogenChloride = BRINE.getFluidStack(1000); - } - else { - HYDROGEN_CHLORIDE.registerComponentForMaterial(FluidUtils.getFluidStack(mHydrogenChloride, 1000)); - } - - - // Add Process for creating Brine - CORE.RA.addBrewingRecipe( - ItemUtils.getSimpleStack(mDustSalt, 16), - MISC_MATERIALS.SALT_WATER.getFluidStack(2000), - FluidUtils.getFluidStack(mBrine, 4000), - 20 * 20, - 120, - false); - - // Chloralkali process - GT_Values.RA.addElectrolyzerRecipe( - CI.getNumberedCircuit(16), - CI.emptyCells(4), - FluidUtils.getFluidStack(mBrine, 4000), - null, // Out - ItemUtils.getItemStackOfAmountFromOreDict("cellChlorine", 2), - ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 2), - ItemUtils.getSimpleStack(mDustSodiumHydroxide, 2), - null, - null, - null, - new int[] {10000, 10000, 10000}, - 20 * 30, - 120); - - // Generate Special Laser Recipe - CORE.RA.addMixerRecipe( - CI.getNumberedBioCircuit(2), - ItemUtils.getItemStackOfAmountFromOreDict("cellChlorine", 1), - ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 1), - null, - null, - null, - ItemUtils.getSimpleStack(ModItems.cellHydrogenChlorideMix, 2), - null, - null, - null, - 20 * 10, - 480); - - CORE.RA.addUvLaserRecipe( - ItemUtils.getSimpleStack(ModItems.cellHydrogenChlorideMix, 4), - ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogenChloride", 4), - 20 * 30, - 480); - - - // Set Material Tiers correctly - ORES.GREENOCKITE.vTier = 1; - RARE_EARTH_LOW.vTier = 1; - RARE_EARTH_MID.vTier = 3; - RARE_EARTH_HIGH.vTier = 5; - - // Set Material Voltages correctly - ORES.GREENOCKITE.vVoltageMultiplier = 30; - RARE_EARTH_LOW.vVoltageMultiplier = 30; - RARE_EARTH_MID.vVoltageMultiplier = 480; - RARE_EARTH_HIGH.vVoltageMultiplier = 7680; - - // Set Material Tooltips to be shorter - RARE_EARTH_LOW.vChemicalFormula = "??????"; - RARE_EARTH_MID.vChemicalFormula = "??????"; - RARE_EARTH_HIGH.vChemicalFormula = "??????"; - - // Set Material Tooltips to be shorter - RARE_EARTH_LOW.vChemicalSymbol = "??"; - RARE_EARTH_MID.vChemicalSymbol = "??"; - RARE_EARTH_HIGH.vChemicalSymbol = "??"; - - // Generate Ore Materials - MaterialGenerator.generateOreMaterial(RARE_EARTH_LOW); - MaterialGenerator.generateOreMaterial(RARE_EARTH_MID); - MaterialGenerator.generateOreMaterial(RARE_EARTH_HIGH); - - ItemStack aRareEarth = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.RareEarth, 1L); - - Fluid aSulfuric = FluidUtils.getFluidStack("sulfuricacid", 1).getFluid(); - Fluid aHydrocholric = FluidUtils.getFluidStack("hydrogenchloride", 1).getFluid(); - Fluid aNitric = FluidUtils.getFluidStack("hydrofluoricacid", 1).getFluid(); - - - - // LV Rare Earth - GT_Values.RA.addChemicalBathRecipe( - ItemUtils.getSimpleStack(aRareEarth, 3), - FluidUtils.getFluidStack(aSulfuric, 1000), - RARE_EARTH_LOW.getCrushed(2), - RARE_EARTH_LOW.getCrushed(2), - RARE_EARTH_LOW.getCrushed(2), - new int[] {10000, 10000, 10000}, - 20 * 30, - MaterialUtils.getVoltageForTier(1)); - - // HV Rare Earth - GT_Values.RA.addChemicalBathRecipe( - ItemUtils.getSimpleStack(aRareEarth, 6), - FluidUtils.getFluidStack(aHydrocholric, 2000), - RARE_EARTH_MID.getCrushed(4), - RARE_EARTH_MID.getCrushed(4), - RARE_EARTH_MID.getCrushed(4), - new int[] {10000, 9000, 8000}, - 20 * 30, - MaterialUtils.getVoltageForTier(3)); - - // IV Rare Earth - GT_Values.RA.addChemicalBathRecipe( - ItemUtils.getSimpleStack(aRareEarth, 9), - FluidUtils.getHydrofluoricAcid(3000), - RARE_EARTH_HIGH.getCrushed(6), - RARE_EARTH_HIGH.getCrushed(6), - RARE_EARTH_HIGH.getCrushed(6), - new int[] {10000, 9000, 8000}, - 20 * 30, - MaterialUtils.getVoltageForTier(5)); - - if (FluidUtils.doesHydrofluoricAcidGtExist()) { - // IV Rare Earth - GT_Values.RA.addChemicalBathRecipe( - ItemUtils.getSimpleStack(aRareEarth, 9), - FluidUtils.getHydrofluoricAcidGT(6000), - RARE_EARTH_HIGH.getCrushed(6), - RARE_EARTH_HIGH.getCrushed(6), - RARE_EARTH_HIGH.getCrushed(6), - new int[] {9000, 8000, 7000}, - 20 * 30, - MaterialUtils.getVoltageForTier(5)); - } - - - } - - - public static void processCopperRecipes() { - - // Rare Earth Processing - /*GT_Values.RA.addSifterRecipe(ItemUtils.getItemStackOfAmountFromOreDict("dustRareEarth", 1), - new ItemStack[] { - ELEMENT.getInstance().YTTRIUM.getSmallDust(1), - ELEMENT.getInstance().NEODYMIUM.getSmallDust(1), - ELEMENT.getInstance().LANTHANUM.getSmallDust(1), - ELEMENT.getInstance().CERIUM.getSmallDust(1), - ELEMENT.getInstance().CADMIUM.getSmallDust(1), - ELEMENT.getInstance().CAESIUM.getSmallDust(1), - ORES.SAMARSKITE_YB.getSmallDust(1), - ORES.FLORENCITE.getSmallDust(1), - ORES.FLUORCAPHITE.getSmallDust(1), - //ELEMENT.getInstance().YTTERBIUM.getTinyDust(1), - //ELEMENT.getInstance().SAMARIUM.getTinyDust(1), - //ELEMENT.getInstance().GADOLINIUM.getTinyDust(1) - }, - new int[] { 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000 }, 20 * 30, 500);*/ - - } - + private static ItemStack mDustSodiumHydroxide; + private static ItemStack mDustSalt; + private static FluidStack mSaltWater; + private static FluidStack mBrine; + private static FluidStack mHydrogenChloride; + + public static void init() { + + // Salt Check and Assignment + mDustSalt = ItemUtils.getItemStackOfAmountFromOreDict("dustSalt", 1); + if (mDustSalt == null) { + MaterialUtils.generateSpecialDustAndAssignToAMaterial(SODIUM_CHLORIDE, false); + mDustSalt = SODIUM_CHLORIDE.getDust(1); + } else { + SODIUM_CHLORIDE.registerComponentForMaterial(OrePrefixes.dust, mDustSalt); + } + + // Salt water Check and Assignment + mSaltWater = FluidUtils.getFluidStack("saltwater", 1000); + if (mSaltWater == null) { + Fluid f = SALT_WATER.generateFluid(); + SALT_WATER.registerComponentForMaterial(FluidUtils.getFluidStack(f, 1000)); + mSaltWater = SALT_WATER.getFluidStack(1000); + } else { + SALT_WATER.registerComponentForMaterial(FluidUtils.getFluidStack(mSaltWater, 1000)); + } + + // Brine Check and assignment + mBrine = FluidUtils.getFluidStack("brine", 1000); + if (mBrine == null) { + Fluid f = BRINE.generateFluid(); + BRINE.registerComponentForMaterial(FluidUtils.getFluidStack(f, 1000)); + mBrine = BRINE.getFluidStack(1000); + } else { + BRINE.registerComponentForMaterial(FluidUtils.getFluidStack(mBrine, 1000)); + } + + // Check Sodium Hydroxide Exists, generate if not. + mDustSodiumHydroxide = ItemUtils.getItemStackOfAmountFromOreDict("dustSodiumHydroxide", 1); + if (mDustSodiumHydroxide == null) { + mDustSodiumHydroxide = ItemUtils.getItemStackOfAmountFromOreDict("dustSodiumHydroxide_GT5U", 1); + if (mDustSodiumHydroxide == null) { + MaterialUtils.generateSpecialDustAndAssignToAMaterial(SODIUM_HYDROXIDE, false); + mDustSodiumHydroxide = SODIUM_HYDROXIDE.getDust(1); + } else { + SODIUM_HYDROXIDE.registerComponentForMaterial(OrePrefixes.dust, mDustSodiumHydroxide); + } + } else { + SODIUM_HYDROXIDE.registerComponentForMaterial(OrePrefixes.dust, mDustSodiumHydroxide); + } + + // Hydrogen Chloride Check and assignment + mHydrogenChloride = FluidUtils.getFluidStack("hydrogenchloride", 1000); + if (mHydrogenChloride == null) { + HYDROGEN_CHLORIDE.generateFluid(); + mHydrogenChloride = BRINE.getFluidStack(1000); + } else { + HYDROGEN_CHLORIDE.registerComponentForMaterial(FluidUtils.getFluidStack(mHydrogenChloride, 1000)); + } + + // Add Process for creating Brine + CORE.RA.addBrewingRecipe( + ItemUtils.getSimpleStack(mDustSalt, 16), + MISC_MATERIALS.SALT_WATER.getFluidStack(2000), + FluidUtils.getFluidStack(mBrine, 4000), + 20 * 20, + 120, + false); + + // Chloralkali process + GT_Values.RA.addElectrolyzerRecipe( + CI.getNumberedCircuit(16), + CI.emptyCells(4), + FluidUtils.getFluidStack(mBrine, 4000), + null, // Out + ItemUtils.getItemStackOfAmountFromOreDict("cellChlorine", 2), + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 2), + ItemUtils.getSimpleStack(mDustSodiumHydroxide, 2), + null, + null, + null, + new int[] {10000, 10000, 10000}, + 20 * 30, + 120); + + // Generate Special Laser Recipe + CORE.RA.addMixerRecipe( + CI.getNumberedBioCircuit(2), + ItemUtils.getItemStackOfAmountFromOreDict("cellChlorine", 1), + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 1), + null, + null, + null, + ItemUtils.getSimpleStack(ModItems.cellHydrogenChlorideMix, 2), + null, + null, + null, + 20 * 10, + 480); + + CORE.RA.addUvLaserRecipe( + ItemUtils.getSimpleStack(ModItems.cellHydrogenChlorideMix, 4), + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogenChloride", 4), + 20 * 30, + 480); + + // Set Material Tiers correctly + ORES.GREENOCKITE.vTier = 1; + RARE_EARTH_LOW.vTier = 1; + RARE_EARTH_MID.vTier = 3; + RARE_EARTH_HIGH.vTier = 5; + + // Set Material Voltages correctly + ORES.GREENOCKITE.vVoltageMultiplier = 30; + RARE_EARTH_LOW.vVoltageMultiplier = 30; + RARE_EARTH_MID.vVoltageMultiplier = 480; + RARE_EARTH_HIGH.vVoltageMultiplier = 7680; + + // Set Material Tooltips to be shorter + RARE_EARTH_LOW.vChemicalFormula = "??????"; + RARE_EARTH_MID.vChemicalFormula = "??????"; + RARE_EARTH_HIGH.vChemicalFormula = "??????"; + + // Set Material Tooltips to be shorter + RARE_EARTH_LOW.vChemicalSymbol = "??"; + RARE_EARTH_MID.vChemicalSymbol = "??"; + RARE_EARTH_HIGH.vChemicalSymbol = "??"; + + // Generate Ore Materials + MaterialGenerator.generateOreMaterial(RARE_EARTH_LOW); + MaterialGenerator.generateOreMaterial(RARE_EARTH_MID); + MaterialGenerator.generateOreMaterial(RARE_EARTH_HIGH); + + ItemStack aRareEarth = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.RareEarth, 1L); + + Fluid aSulfuric = FluidUtils.getFluidStack("sulfuricacid", 1).getFluid(); + Fluid aHydrocholric = FluidUtils.getFluidStack("hydrogenchloride", 1).getFluid(); + Fluid aNitric = FluidUtils.getFluidStack("hydrofluoricacid", 1).getFluid(); + + // LV Rare Earth + GT_Values.RA.addChemicalBathRecipe( + ItemUtils.getSimpleStack(aRareEarth, 3), + FluidUtils.getFluidStack(aSulfuric, 1000), + RARE_EARTH_LOW.getCrushed(2), + RARE_EARTH_LOW.getCrushed(2), + RARE_EARTH_LOW.getCrushed(2), + new int[] {10000, 10000, 10000}, + 20 * 30, + MaterialUtils.getVoltageForTier(1)); + + // HV Rare Earth + GT_Values.RA.addChemicalBathRecipe( + ItemUtils.getSimpleStack(aRareEarth, 6), + FluidUtils.getFluidStack(aHydrocholric, 2000), + RARE_EARTH_MID.getCrushed(4), + RARE_EARTH_MID.getCrushed(4), + RARE_EARTH_MID.getCrushed(4), + new int[] {10000, 9000, 8000}, + 20 * 30, + MaterialUtils.getVoltageForTier(3)); + + // IV Rare Earth + GT_Values.RA.addChemicalBathRecipe( + ItemUtils.getSimpleStack(aRareEarth, 9), + FluidUtils.getHydrofluoricAcid(3000), + RARE_EARTH_HIGH.getCrushed(6), + RARE_EARTH_HIGH.getCrushed(6), + RARE_EARTH_HIGH.getCrushed(6), + new int[] {10000, 9000, 8000}, + 20 * 30, + MaterialUtils.getVoltageForTier(5)); + + if (FluidUtils.doesHydrofluoricAcidGtExist()) { + // IV Rare Earth + GT_Values.RA.addChemicalBathRecipe( + ItemUtils.getSimpleStack(aRareEarth, 9), + FluidUtils.getHydrofluoricAcidGT(6000), + RARE_EARTH_HIGH.getCrushed(6), + RARE_EARTH_HIGH.getCrushed(6), + RARE_EARTH_HIGH.getCrushed(6), + new int[] {9000, 8000, 7000}, + 20 * 30, + MaterialUtils.getVoltageForTier(5)); + } + } + + public static void processCopperRecipes() { + + // Rare Earth Processing + /*GT_Values.RA.addSifterRecipe(ItemUtils.getItemStackOfAmountFromOreDict("dustRareEarth", 1), + new ItemStack[] { + ELEMENT.getInstance().YTTRIUM.getSmallDust(1), + ELEMENT.getInstance().NEODYMIUM.getSmallDust(1), + ELEMENT.getInstance().LANTHANUM.getSmallDust(1), + ELEMENT.getInstance().CERIUM.getSmallDust(1), + ELEMENT.getInstance().CADMIUM.getSmallDust(1), + ELEMENT.getInstance().CAESIUM.getSmallDust(1), + ORES.SAMARSKITE_YB.getSmallDust(1), + ORES.FLORENCITE.getSmallDust(1), + ORES.FLUORCAPHITE.getSmallDust(1), + //ELEMENT.getInstance().YTTERBIUM.getTinyDust(1), + //ELEMENT.getInstance().SAMARIUM.getTinyDust(1), + //ELEMENT.getInstance().GADOLINIUM.getTinyDust(1) + }, + new int[] { 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000 }, 20 * 30, 500);*/ + + } } diff --git a/src/main/java/gtPlusPlus/core/recipe/RECIPES_SeleniumProcessing.java b/src/main/java/gtPlusPlus/core/recipe/RECIPES_SeleniumProcessing.java index 9a2ea8bad0..674ba9e7bb 100644 --- a/src/main/java/gtPlusPlus/core/recipe/RECIPES_SeleniumProcessing.java +++ b/src/main/java/gtPlusPlus/core/recipe/RECIPES_SeleniumProcessing.java @@ -14,42 +14,55 @@ import net.minecraft.item.ItemStack; public class RECIPES_SeleniumProcessing { - public static void init() { - - //We need this - MaterialUtils.generateSpecialDustAndAssignToAMaterial(MISC_MATERIALS.SELENIUM_DIOXIDE, false); - - // Makes Selenium Dioxide - processCopperRecipes(); - - //Liquify the Dried Dioxide - AddGregtechRecipe.addCokeAndPyrolyseRecipes(MISC_MATERIALS.SELENIUM_DIOXIDE.getDust(1), 13, FluidUtils.getSteam(500), null, MISC_MATERIALS.SELENIUM_DIOXIDE.getFluidStack(1000), 20, 1024); - - // Produce Selenious Acid - AddGregtechRecipe.addCokeAndPyrolyseRecipes(MISC_MATERIALS.SELENIUM_DIOXIDE.getCell(1), 14, FluidUtils.getHotWater(4000), CI.emptyCells(1), MISC_MATERIALS.SELENIOUS_ACID.getFluidStack(1000), 20, 2048); - - // Make Selenium - CORE.RA.addBlastSmelterRecipe( - new ItemStack[] { - ItemUtils.getGregtechCircuit(14), - ItemUtils.getItemStackOfAmountFromOreDict("cellSulfuricAcid", 8), - ELEMENT.getInstance().CARBON.getDust(16), - }, - MISC_MATERIALS.SELENIOUS_ACID.getFluidStack(750), - ELEMENT.getInstance().SELENIUM.getFluidStack(144 * 1), - new ItemStack[] { - CI.emptyCells(8), - ELEMENT.getInstance().SELENIUM.getIngot(1), - ELEMENT.getInstance().SELENIUM.getIngot(1), - }, - new int[] {10000, 2000, 2000}, - 20 * 300, - 7200); - + public static void init() { + + // We need this + MaterialUtils.generateSpecialDustAndAssignToAMaterial(MISC_MATERIALS.SELENIUM_DIOXIDE, false); + + // Makes Selenium Dioxide + processCopperRecipes(); + + // Liquify the Dried Dioxide + AddGregtechRecipe.addCokeAndPyrolyseRecipes( + MISC_MATERIALS.SELENIUM_DIOXIDE.getDust(1), + 13, + FluidUtils.getSteam(500), + null, + MISC_MATERIALS.SELENIUM_DIOXIDE.getFluidStack(1000), + 20, + 1024); + + // Produce Selenious Acid + AddGregtechRecipe.addCokeAndPyrolyseRecipes( + MISC_MATERIALS.SELENIUM_DIOXIDE.getCell(1), + 14, + FluidUtils.getHotWater(4000), + CI.emptyCells(1), + MISC_MATERIALS.SELENIOUS_ACID.getFluidStack(1000), + 20, + 2048); + + // Make Selenium + CORE.RA.addBlastSmelterRecipe( + new ItemStack[] { + ItemUtils.getGregtechCircuit(14), + ItemUtils.getItemStackOfAmountFromOreDict("cellSulfuricAcid", 8), + ELEMENT.getInstance().CARBON.getDust(16), + }, + MISC_MATERIALS.SELENIOUS_ACID.getFluidStack(750), + ELEMENT.getInstance().SELENIUM.getFluidStack(144 * 1), + new ItemStack[] { + CI.emptyCells(8), + ELEMENT.getInstance().SELENIUM.getIngot(1), + ELEMENT.getInstance().SELENIUM.getIngot(1), + }, + new int[] {10000, 2000, 2000}, + 20 * 300, + 7200); - /*// Old recipes for Selenium Roasting + /*// Old recipes for Selenium Roasting CORE.RA.addBlastSmelterRecipe( - new ItemStack[] { + new ItemStack[] { ItemUtils.getGregtechCircuit(16), ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedPyrite", 8), ELEMENT.getInstance().CARBON.getDust(32), @@ -58,9 +71,9 @@ public class RECIPES_SeleniumProcessing { ELEMENT.getInstance().SELENIUM.getFluid(144), 0, 20 * 300, - 2000); + 2000); CORE.RA.addBlastSmelterRecipe( - new ItemStack[] { + new ItemStack[] { ItemUtils.getGregtechCircuit(17), ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedChalcopyrite", 8), ELEMENT.getInstance().CARBON.getDust(32), @@ -71,7 +84,7 @@ public class RECIPES_SeleniumProcessing { 20 * 300, 2000); CORE.RA.addBlastSmelterRecipe( - new ItemStack[] { + new ItemStack[] { ItemUtils.getGregtechCircuit(18), ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedGalena", 8), ELEMENT.getInstance().CARBON.getDust(32), @@ -80,143 +93,101 @@ public class RECIPES_SeleniumProcessing { ELEMENT.getInstance().SELENIUM.getFluid(144), 0, 20 * 300, - 2000);*/ - } - - - public static void processCopperRecipes() { - - //Copper - CORE.RA.addDehydratorRecipe( - new ItemStack[]{ - CI.getNumberedAdvancedCircuit(23), - ItemUtils.getOrePrefixStack(OrePrefixes.crushedPurified, Materials.Copper, 1), // Item Input - }, - FluidUtils.getHotWater(1000), // Fluid - MISC_MATERIALS.SELENIUM_DIOXIDE.getFluidStack(20), // Fluid - new ItemStack[] { - ItemUtils.getOrePrefixStack(OrePrefixes.crushedCentrifuged, Materials.Copper, 1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getDust(1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getDust(1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), - }, // Output - new int[] { - 10000, - 100, - 100, - 500, - 500, - 500, - 1000, - 1000, - 1000 - }, - 40 * 20, // Time in ticks - 1024); // EU - - //Tetra - CORE.RA.addDehydratorRecipe( - new ItemStack[]{ - CI.getNumberedAdvancedCircuit(23), - ItemUtils.getOrePrefixStack(OrePrefixes.crushedPurified, Materials.Tetrahedrite, 1), // Item Input - }, - FluidUtils.getHotWater(1000), // Fluid - MISC_MATERIALS.SELENIUM_DIOXIDE.getFluidStack(10), // Fluid - new ItemStack[] { - ItemUtils.getOrePrefixStack(OrePrefixes.crushedCentrifuged, Materials.Tetrahedrite, 1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getDust(1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getDust(1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), - }, // Output - new int[] { - 10000, - 100, - 100, - 300, - 300, - 300, - 800, - 800, - 800 - }, - 40 * 20, // Time in ticks - 1024); // EU + 2000);*/ + } - //Chalco - CORE.RA.addDehydratorRecipe( - new ItemStack[]{ - CI.getNumberedAdvancedCircuit(23), - ItemUtils.getOrePrefixStack(OrePrefixes.crushedPurified, Materials.Chalcopyrite, 1), // Item Input - }, - FluidUtils.getHotWater(1000), // Fluid - MISC_MATERIALS.SELENIUM_DIOXIDE.getFluidStack(10), // Fluid - new ItemStack[] { - ItemUtils.getOrePrefixStack(OrePrefixes.crushedCentrifuged, Materials.Chalcopyrite, 1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getDust(1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getDust(1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), - }, // Output - new int[] { - 10000, - 100, - 100, - 300, - 300, - 300, - 800, - 800, - 800 - }, - 40 * 20, // Time in ticks - 1024); // EU - - //Malachite - CORE.RA.addDehydratorRecipe( - new ItemStack[]{ - CI.getNumberedAdvancedCircuit(23), - ItemUtils.getOrePrefixStack(OrePrefixes.crushedPurified, Materials.Malachite, 1), // Item Input - }, - FluidUtils.getHotWater(1000), // Fluid - MISC_MATERIALS.SELENIUM_DIOXIDE.getFluidStack(10), // Fluid - new ItemStack[] { - ItemUtils.getOrePrefixStack(OrePrefixes.crushedCentrifuged, Materials.Malachite, 1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getDust(1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getDust(1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), - MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), - }, // Output - new int[] { - 10000, - 100, - 100, - 300, - 300, - 300, - 800, - 800, - 800 - }, - 40 * 20, // Time in ticks - 1024); // EU - } + public static void processCopperRecipes() { + // Copper + CORE.RA.addDehydratorRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(23), + ItemUtils.getOrePrefixStack(OrePrefixes.crushedPurified, Materials.Copper, 1), // Item Input + }, + FluidUtils.getHotWater(1000), // Fluid + MISC_MATERIALS.SELENIUM_DIOXIDE.getFluidStack(20), // Fluid + new ItemStack[] { + ItemUtils.getOrePrefixStack(OrePrefixes.crushedCentrifuged, Materials.Copper, 1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), + }, // Output + new int[] {10000, 100, 100, 500, 500, 500, 1000, 1000, 1000}, + 40 * 20, // Time in ticks + 1024); // EU + + // Tetra + CORE.RA.addDehydratorRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(23), + ItemUtils.getOrePrefixStack(OrePrefixes.crushedPurified, Materials.Tetrahedrite, 1), // Item Input + }, + FluidUtils.getHotWater(1000), // Fluid + MISC_MATERIALS.SELENIUM_DIOXIDE.getFluidStack(10), // Fluid + new ItemStack[] { + ItemUtils.getOrePrefixStack(OrePrefixes.crushedCentrifuged, Materials.Tetrahedrite, 1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), + }, // Output + new int[] {10000, 100, 100, 300, 300, 300, 800, 800, 800}, + 40 * 20, // Time in ticks + 1024); // EU + + // Chalco + CORE.RA.addDehydratorRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(23), + ItemUtils.getOrePrefixStack(OrePrefixes.crushedPurified, Materials.Chalcopyrite, 1), // Item Input + }, + FluidUtils.getHotWater(1000), // Fluid + MISC_MATERIALS.SELENIUM_DIOXIDE.getFluidStack(10), // Fluid + new ItemStack[] { + ItemUtils.getOrePrefixStack(OrePrefixes.crushedCentrifuged, Materials.Chalcopyrite, 1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), + }, // Output + new int[] {10000, 100, 100, 300, 300, 300, 800, 800, 800}, + 40 * 20, // Time in ticks + 1024); // EU + + // Malachite + CORE.RA.addDehydratorRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(23), + ItemUtils.getOrePrefixStack(OrePrefixes.crushedPurified, Materials.Malachite, 1), // Item Input + }, + FluidUtils.getHotWater(1000), // Fluid + MISC_MATERIALS.SELENIUM_DIOXIDE.getFluidStack(10), // Fluid + new ItemStack[] { + ItemUtils.getOrePrefixStack(OrePrefixes.crushedCentrifuged, Materials.Malachite, 1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getSmallDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), + MISC_MATERIALS.SELENIUM_DIOXIDE.getTinyDust(1), + }, // Output + new int[] {10000, 100, 100, 300, 300, 300, 800, 800, 800}, + 40 * 20, // Time in ticks + 1024); // EU + } } diff --git a/src/main/java/gtPlusPlus/core/recipe/RECIPES_Shapeless.java b/src/main/java/gtPlusPlus/core/recipe/RECIPES_Shapeless.java index 7ffdcf295b..b561de2e43 100644 --- a/src/main/java/gtPlusPlus/core/recipe/RECIPES_Shapeless.java +++ b/src/main/java/gtPlusPlus/core/recipe/RECIPES_Shapeless.java @@ -1,35 +1,31 @@ package gtPlusPlus.core.recipe; -import net.minecraft.item.ItemStack; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.LoadedMods; +import net.minecraft.item.ItemStack; public class RECIPES_Shapeless { - static ItemStack dustStaballoy; - - //Circuits - static String circuitPrimitive = "circuitPrimitive"; - static String circuitBasic = "circuitBasic"; - static String circuitGood = "circuitGood"; - static String circuitAdvanced = "circuitAdvanced"; - static String circuitData = "circuitData"; - static String circuitElite = "circuitElite"; - static String circuitMaster = "circuitMaster"; - static String circuitUltimate = "circuitUltimate"; - static ItemStack gearboxCasing_Tier_1; - - public static final void loadRecipes(){ - //run(); - Logger.INFO("Loading Shapeless Recipes."); - } - - private static void run(){ - //Gregtech items - if (LoadedMods.Gregtech){ - - } - } - + static ItemStack dustStaballoy; + + // Circuits + static String circuitPrimitive = "circuitPrimitive"; + static String circuitBasic = "circuitBasic"; + static String circuitGood = "circuitGood"; + static String circuitAdvanced = "circuitAdvanced"; + static String circuitData = "circuitData"; + static String circuitElite = "circuitElite"; + static String circuitMaster = "circuitMaster"; + static String circuitUltimate = "circuitUltimate"; + static ItemStack gearboxCasing_Tier_1; + + public static final void loadRecipes() { + // run(); + Logger.INFO("Loading Shapeless Recipes."); + } + + private static void run() { + // Gregtech items + if (LoadedMods.Gregtech) {} + } } diff --git a/src/main/java/gtPlusPlus/core/recipe/RECIPES_Tools.java b/src/main/java/gtPlusPlus/core/recipe/RECIPES_Tools.java index 42448e6b74..38832b07fe 100644 --- a/src/main/java/gtPlusPlus/core/recipe/RECIPES_Tools.java +++ b/src/main/java/gtPlusPlus/core/recipe/RECIPES_Tools.java @@ -1,181 +1,201 @@ package gtPlusPlus.core.recipe; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.RecipeUtils; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; - -import gtPlusPlus.core.item.ModItems; -import gtPlusPlus.core.lib.LoadedMods; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.minecraft.RecipeUtils; import net.minecraftforge.oredict.OreDictionary; public class RECIPES_Tools { - //Outputs - public static ItemStack RECIPE_StaballoyPickaxe = new ItemStack(ModItems.itemStaballoyPickaxe); - public static ItemStack RECIPE_StaballoyAxe = new ItemStack(ModItems.itemStaballoyAxe); - public static ItemStack RECIPE_SandstoneHammer = new ItemStack(ModItems.itemSandstoneHammer); - //public static ItemStack RECIPE_StaballoyIngot = new ItemStack(ModItems.itemIngotStaballoy); - public static ItemStack RECIPE_SandStone = new ItemStack(Blocks.sandstone, 2); - public static ItemStack RECIPE_Sand = new ItemStack(Blocks.sand, 4); - public static ItemStack RECIPE_FireStarter = ItemUtils.getSimpleStack(ModItems.itemBasicFireMaker); - - public static ItemStack RECIPE_DivisionSigil; - - //MC Items - public static Item Apple = Items.apple; - - //MC Blocks - public static Block CobbleStone = Blocks.cobblestone; - public static Block Dirt = Blocks.dirt; - public static Block Sand = Blocks.sand; - public static Block Gravel = Blocks.gravel; - public static Block Sandstone = Blocks.sandstone; - - //null - public static String empty = " "; - - //Batteries - public static String batteryBasic = "batteryBasic"; - public static String batteryAdvanced = "batteryAdvanced"; - public static String batteryElite = "batteryElite"; - public static String batteryMaster = "batteryMaster"; - public static String batteryUltimate = "batteryUltimate"; - - //Circuits - public static String circuitPrimitive = "circuitPrimitive"; - public static String circuitBasic = "circuitBasic"; - public static String circuitGood = "circuitGood"; - public static String circuitAdvanced = "circuitAdvanced"; - public static String circuitElite = "circuitElite"; - public static String circuitMaster = "circuitMaster"; - public static String circuitUltimate = "circuitUltimate"; - - //Cables - public static String cableGt01Electrum = "cableGt01Electrum"; - public static String cableGt02Electrum = "cableGt02Electrum"; - public static String cableGt01RedstoneAlloy = "cableGt01RedstoneAlloy"; - public static String cableGt02RedstoneAlloy = "cableGt02RedstoneAlloy"; - public static String cableGt01Copper = "cableGt01Copper"; - public static String cableGt02Copper = "cableGt02Copper"; - public static String cableGt01AnnealedCopper = "cableGt01AnnealedCopper"; - public static String cableGt02AnnealedCopper = "cableGt02AnnealedCopper"; - - //Rods - public static String stickWood = "stickWood"; - public static String stickStaballoy= "stickStaballoy"; - public static String stickTitanium= "stickTitanium"; - public static String stickIron= "stickIron"; - public static String stickGold= "stickGold"; - public static String stickSilver= "stickSilver"; - public static String stickSteel= "stickSteel"; - public static String stickBronze= "stickBronze"; - public static String stickTungsten= "stickTungsten"; - public static String stickRedAlloy= "stickRedAlloy"; - public static String stickInvar= "stickInvar"; - public static String stickElectrum= "stickElectrum"; - public static String stickElectricalSteel= "stickElectricalSteel"; - - //Plates - public static String plateStaballoy= "plateStaballoy"; - public static String plateTitanium= "plateTitanium"; - public static String plateIron= "plateIron"; - public static String plateGold= "plateGold"; - public static String plateSilver= "plateSilver"; - public static String plateSteel= "plateSteel"; - public static String plateBronze= "plateBronze"; - public static String plateTungsten= "plateTungsten"; - public static String plateRedAlloy= "plateRedAlloy"; - public static String plateInvar= "plateInvar"; - public static String plateElectrum= "plateElectrum"; - public static String plateElectricalSteel= "plateElectricalSteel"; - - //Ingots - public static String ingotStaballoy= "ingotStaballoy"; - public static String ingotTitanium= "ingotTitanium"; - public static String ingotIron= "ingotIron"; - public static String ingotGold= "ingotGold"; - public static String ingotSilver= "ingotSilver"; - public static String ingotSteel= "ingotSteel"; - public static String ingotBronze= "ingotBronze"; - public static String ingotTungsten= "ingotTungsten"; - public static String ingotRedAlloy= "ingotRedAlloy"; - public static String ingotInvar= "ingotInvar"; - public static String ingotElectrum= "ingotElectrum"; - public static String ingotUranium= "ingotUranium"; - public static String ingotElectricalSteel= "ingotElectricalSteel"; - - //Crafting Tools - public static String craftingToolHardHammer = "craftingToolHardHammer"; - public static String craftingToolSoftHammer = "craftingToolSoftHammer"; - public static String craftingToolFile = "craftingToolFile"; - public static String craftingToolSaw = "craftingToolSaw"; - public static String craftingToolPickaxe = "craftingToolPickaxe"; - public static String craftingToolWrench = "craftingToolWrench"; - public static String craftingToolCrowbar = "craftingToolCrowbar"; - public static String craftingToolKnife = "craftingToolKnife"; - public static String craftingToolScrewdriver = "craftingToolScrewdriver"; - - public static ItemStack sandHammer = new ItemStack (ModItems.itemSandstoneHammer, 1, OreDictionary.WILDCARD_VALUE); - public static String craftingToolSandHammer = "craftingToolSandHammer"; - - public static ItemStack personalCloakingDevice = ItemUtils.getSimpleStack(ModItems.itemPersonalCloakingDevice); - public static String plateDoubleNiChrome = "plateDoubleNichrome"; - public static String plateIridiumAlloy = "plateAlloyIridium"; - - public static final void loadRecipes(){ - - - run(); - - } - - private static void run(){ - //Staballoy Pickaxe - RecipeUtils.addShapedRecipe( - plateStaballoy, plateStaballoy, ingotStaballoy, - craftingToolFile, stickTungsten, craftingToolHardHammer, - craftingToolWrench, stickTungsten, craftingToolHardHammer, - RECIPE_StaballoyPickaxe); - - //Staballoy Axe - RecipeUtils.addShapedRecipe( - plateStaballoy, ingotStaballoy, craftingToolHardHammer, - plateStaballoy, stickTungsten, craftingToolHardHammer, - craftingToolFile, stickTungsten, craftingToolWrench, - RECIPE_StaballoyAxe); - - //Cobble to Sand - RecipeUtils.addShapedRecipe( - CobbleStone, CobbleStone, CobbleStone, - CobbleStone, sandHammer, CobbleStone, - CobbleStone, CobbleStone, CobbleStone, - RECIPE_Sand); - - //Sand to Sandstone - RecipeUtils.addShapedRecipe( - Sand, Sand, Sand, - Sand, sandHammer, Sand, - Sand, Sand, Sand, - RECIPE_SandStone); - - //Sandstone Hammer - RecipeUtils.addShapedRecipe( - plateElectrum, ingotElectrum, plateElectrum, - craftingToolScrewdriver, stickBronze, craftingToolHardHammer, - null, stickSteel, null, - RECIPE_SandstoneHammer); - - //Basic Firemaker - RecipeUtils.addShapedRecipe( - "cropWheat", "cropWheat", "cropWheat", - ItemUtils.getSimpleStack(Items.string), stickWood, ItemUtils.getSimpleStack(Items.string), - "cropWheat", "cropWheat", "cropWheat", - RECIPE_FireStarter); - - } - + // Outputs + public static ItemStack RECIPE_StaballoyPickaxe = new ItemStack(ModItems.itemStaballoyPickaxe); + public static ItemStack RECIPE_StaballoyAxe = new ItemStack(ModItems.itemStaballoyAxe); + public static ItemStack RECIPE_SandstoneHammer = new ItemStack(ModItems.itemSandstoneHammer); + // public static ItemStack RECIPE_StaballoyIngot = new ItemStack(ModItems.itemIngotStaballoy); + public static ItemStack RECIPE_SandStone = new ItemStack(Blocks.sandstone, 2); + public static ItemStack RECIPE_Sand = new ItemStack(Blocks.sand, 4); + public static ItemStack RECIPE_FireStarter = ItemUtils.getSimpleStack(ModItems.itemBasicFireMaker); + + public static ItemStack RECIPE_DivisionSigil; + + // MC Items + public static Item Apple = Items.apple; + + // MC Blocks + public static Block CobbleStone = Blocks.cobblestone; + public static Block Dirt = Blocks.dirt; + public static Block Sand = Blocks.sand; + public static Block Gravel = Blocks.gravel; + public static Block Sandstone = Blocks.sandstone; + + // null + public static String empty = " "; + + // Batteries + public static String batteryBasic = "batteryBasic"; + public static String batteryAdvanced = "batteryAdvanced"; + public static String batteryElite = "batteryElite"; + public static String batteryMaster = "batteryMaster"; + public static String batteryUltimate = "batteryUltimate"; + + // Circuits + public static String circuitPrimitive = "circuitPrimitive"; + public static String circuitBasic = "circuitBasic"; + public static String circuitGood = "circuitGood"; + public static String circuitAdvanced = "circuitAdvanced"; + public static String circuitElite = "circuitElite"; + public static String circuitMaster = "circuitMaster"; + public static String circuitUltimate = "circuitUltimate"; + + // Cables + public static String cableGt01Electrum = "cableGt01Electrum"; + public static String cableGt02Electrum = "cableGt02Electrum"; + public static String cableGt01RedstoneAlloy = "cableGt01RedstoneAlloy"; + public static String cableGt02RedstoneAlloy = "cableGt02RedstoneAlloy"; + public static String cableGt01Copper = "cableGt01Copper"; + public static String cableGt02Copper = "cableGt02Copper"; + public static String cableGt01AnnealedCopper = "cableGt01AnnealedCopper"; + public static String cableGt02AnnealedCopper = "cableGt02AnnealedCopper"; + + // Rods + public static String stickWood = "stickWood"; + public static String stickStaballoy = "stickStaballoy"; + public static String stickTitanium = "stickTitanium"; + public static String stickIron = "stickIron"; + public static String stickGold = "stickGold"; + public static String stickSilver = "stickSilver"; + public static String stickSteel = "stickSteel"; + public static String stickBronze = "stickBronze"; + public static String stickTungsten = "stickTungsten"; + public static String stickRedAlloy = "stickRedAlloy"; + public static String stickInvar = "stickInvar"; + public static String stickElectrum = "stickElectrum"; + public static String stickElectricalSteel = "stickElectricalSteel"; + + // Plates + public static String plateStaballoy = "plateStaballoy"; + public static String plateTitanium = "plateTitanium"; + public static String plateIron = "plateIron"; + public static String plateGold = "plateGold"; + public static String plateSilver = "plateSilver"; + public static String plateSteel = "plateSteel"; + public static String plateBronze = "plateBronze"; + public static String plateTungsten = "plateTungsten"; + public static String plateRedAlloy = "plateRedAlloy"; + public static String plateInvar = "plateInvar"; + public static String plateElectrum = "plateElectrum"; + public static String plateElectricalSteel = "plateElectricalSteel"; + + // Ingots + public static String ingotStaballoy = "ingotStaballoy"; + public static String ingotTitanium = "ingotTitanium"; + public static String ingotIron = "ingotIron"; + public static String ingotGold = "ingotGold"; + public static String ingotSilver = "ingotSilver"; + public static String ingotSteel = "ingotSteel"; + public static String ingotBronze = "ingotBronze"; + public static String ingotTungsten = "ingotTungsten"; + public static String ingotRedAlloy = "ingotRedAlloy"; + public static String ingotInvar = "ingotInvar"; + public static String ingotElectrum = "ingotElectrum"; + public static String ingotUranium = "ingotUranium"; + public static String ingotElectricalSteel = "ingotElectricalSteel"; + + // Crafting Tools + public static String craftingToolHardHammer = "craftingToolHardHammer"; + public static String craftingToolSoftHammer = "craftingToolSoftHammer"; + public static String craftingToolFile = "craftingToolFile"; + public static String craftingToolSaw = "craftingToolSaw"; + public static String craftingToolPickaxe = "craftingToolPickaxe"; + public static String craftingToolWrench = "craftingToolWrench"; + public static String craftingToolCrowbar = "craftingToolCrowbar"; + public static String craftingToolKnife = "craftingToolKnife"; + public static String craftingToolScrewdriver = "craftingToolScrewdriver"; + + public static ItemStack sandHammer = new ItemStack(ModItems.itemSandstoneHammer, 1, OreDictionary.WILDCARD_VALUE); + public static String craftingToolSandHammer = "craftingToolSandHammer"; + + public static ItemStack personalCloakingDevice = ItemUtils.getSimpleStack(ModItems.itemPersonalCloakingDevice); + public static String plateDoubleNiChrome = "plateDoubleNichrome"; + public static String plateIridiumAlloy = "plateAlloyIridium"; + + public static final void loadRecipes() { + + run(); + } + + private static void run() { + // Staballoy Pickaxe + RecipeUtils.addShapedRecipe( + plateStaballoy, + plateStaballoy, + ingotStaballoy, + craftingToolFile, + stickTungsten, + craftingToolHardHammer, + craftingToolWrench, + stickTungsten, + craftingToolHardHammer, + RECIPE_StaballoyPickaxe); + + // Staballoy Axe + RecipeUtils.addShapedRecipe( + plateStaballoy, + ingotStaballoy, + craftingToolHardHammer, + plateStaballoy, + stickTungsten, + craftingToolHardHammer, + craftingToolFile, + stickTungsten, + craftingToolWrench, + RECIPE_StaballoyAxe); + + // Cobble to Sand + RecipeUtils.addShapedRecipe( + CobbleStone, + CobbleStone, + CobbleStone, + CobbleStone, + sandHammer, + CobbleStone, + CobbleStone, + CobbleStone, + CobbleStone, + RECIPE_Sand); + + // Sand to Sandstone + RecipeUtils.addShapedRecipe(Sand, Sand, Sand, Sand, sandHammer, Sand, Sand, Sand, Sand, RECIPE_SandStone); + + // Sandstone Hammer + RecipeUtils.addShapedRecipe( + plateElectrum, + ingotElectrum, + plateElectrum, + craftingToolScrewdriver, + stickBronze, + craftingToolHardHammer, + null, + stickSteel, + null, + RECIPE_SandstoneHammer); + + // Basic Firemaker + RecipeUtils.addShapedRecipe( + "cropWheat", + "cropWheat", + "cropWheat", + ItemUtils.getSimpleStack(Items.string), + stickWood, + ItemUtils.getSimpleStack(Items.string), + "cropWheat", + "cropWheat", + "cropWheat", + RECIPE_FireStarter); + } } diff --git a/src/main/java/gtPlusPlus/core/recipe/RECIPE_Batteries.java b/src/main/java/gtPlusPlus/core/recipe/RECIPE_Batteries.java index 5476ef0e8d..62cd9f3800 100644 --- a/src/main/java/gtPlusPlus/core/recipe/RECIPE_Batteries.java +++ b/src/main/java/gtPlusPlus/core/recipe/RECIPE_Batteries.java @@ -1,52 +1,65 @@ package gtPlusPlus.core.recipe; -import net.minecraft.item.ItemStack; - import gregtech.api.enums.ItemList; - import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.RecipeUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import net.minecraft.item.ItemStack; public class RECIPE_Batteries { - static ItemStack RECIPE_Battery_Sodium = GregtechItemList.Battery_RE_EV_Sodium.get(1); - static ItemStack RECIPE_Battery_Cadmium = GregtechItemList.Battery_RE_EV_Cadmium.get(1); - static ItemStack RECIPE_Battery_Lithium = GregtechItemList.Battery_RE_EV_Lithium.get(1); - static ItemStack GT_Battery_Sodium = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32539, 1); - static ItemStack GT_Battery_Cadmium = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32537, 1); - static ItemStack GT_Battery_Lithium = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32538, 1); - static ItemStack machineTransformer_EV; - - public static void loadRecipes(){ - - if (LoadedMods.Gregtech){ - machineTransformer_EV = ItemList.Transformer_EV_HV.get(1); - run(); - } - } - - private static void run(){ + static ItemStack RECIPE_Battery_Sodium = GregtechItemList.Battery_RE_EV_Sodium.get(1); + static ItemStack RECIPE_Battery_Cadmium = GregtechItemList.Battery_RE_EV_Cadmium.get(1); + static ItemStack RECIPE_Battery_Lithium = GregtechItemList.Battery_RE_EV_Lithium.get(1); + static ItemStack GT_Battery_Sodium = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32539, 1); + static ItemStack GT_Battery_Cadmium = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32537, 1); + static ItemStack GT_Battery_Lithium = ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01", 32538, 1); + static ItemStack machineTransformer_EV; + public static void loadRecipes() { - RecipeUtils.addShapedGregtechRecipe( - GT_Battery_Sodium, RECIPES_Machines.cableTier4, GT_Battery_Sodium, - CI.circuitTier3, machineTransformer_EV, CI.circuitTier3, - GT_Battery_Sodium, RECIPES_Machines.cableTier4, GT_Battery_Sodium, - RECIPE_Battery_Sodium); - RecipeUtils.addShapedGregtechRecipe( - GT_Battery_Cadmium, RECIPES_Machines.cableTier4, GT_Battery_Cadmium, - CI.circuitTier3, machineTransformer_EV, CI.circuitTier3, - GT_Battery_Cadmium, RECIPES_Machines.cableTier4, GT_Battery_Cadmium, - RECIPE_Battery_Cadmium); - RecipeUtils.addShapedGregtechRecipe( - GT_Battery_Lithium, RECIPES_Machines.cableTier4, GT_Battery_Lithium, - CI.circuitTier3, machineTransformer_EV, CI.circuitTier3, - GT_Battery_Lithium, RECIPES_Machines.cableTier4, GT_Battery_Lithium, - RECIPE_Battery_Lithium); + if (LoadedMods.Gregtech) { + machineTransformer_EV = ItemList.Transformer_EV_HV.get(1); + run(); + } + } - } + private static void run() { + RecipeUtils.addShapedGregtechRecipe( + GT_Battery_Sodium, + RECIPES_Machines.cableTier4, + GT_Battery_Sodium, + CI.circuitTier3, + machineTransformer_EV, + CI.circuitTier3, + GT_Battery_Sodium, + RECIPES_Machines.cableTier4, + GT_Battery_Sodium, + RECIPE_Battery_Sodium); + RecipeUtils.addShapedGregtechRecipe( + GT_Battery_Cadmium, + RECIPES_Machines.cableTier4, + GT_Battery_Cadmium, + CI.circuitTier3, + machineTransformer_EV, + CI.circuitTier3, + GT_Battery_Cadmium, + RECIPES_Machines.cableTier4, + GT_Battery_Cadmium, + RECIPE_Battery_Cadmium); + RecipeUtils.addShapedGregtechRecipe( + GT_Battery_Lithium, + RECIPES_Machines.cableTier4, + GT_Battery_Lithium, + CI.circuitTier3, + machineTransformer_EV, + CI.circuitTier3, + GT_Battery_Lithium, + RECIPES_Machines.cableTier4, + GT_Battery_Lithium, + RECIPE_Battery_Lithium); + } } diff --git a/src/main/java/gtPlusPlus/core/recipe/ShapedRecipeObject.java b/src/main/java/gtPlusPlus/core/recipe/ShapedRecipeObject.java index 0d25d2bec9..67cf787b13 100644 --- a/src/main/java/gtPlusPlus/core/recipe/ShapedRecipeObject.java +++ b/src/main/java/gtPlusPlus/core/recipe/ShapedRecipeObject.java @@ -1,43 +1,57 @@ package gtPlusPlus.core.recipe; -import net.minecraft.item.ItemStack; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.minecraft.RecipeUtils; +import net.minecraft.item.ItemStack; public class ShapedRecipeObject { - public Object object_A; - public Object object_B; - public Object object_C; - public Object object_D; - public Object object_E; - public Object object_F; - public Object object_G; - public Object object_H; - public Object object_I; - public ItemStack object_OUTPUT; - - public ShapedRecipeObject( - final Object input_A,final Object input_B,final Object input_C, - final Object input_D,final Object input_E,final Object input_F, - final Object input_G,final Object input_H,final Object input_I, - final ItemStack input_Output){ - this.object_A = input_A; - this.object_B = input_B; - this.object_C = input_C; - this.object_D = input_D; - this.object_E = input_E; - this.object_F = input_F; - this.object_G = input_G; - this.object_H = input_H; - this.object_I = input_I; - this.object_OUTPUT = input_Output; - Logger.SPECIFIC_WARNING("ShapedRecipeObject", "New object created.", 36); - } + public Object object_A; + public Object object_B; + public Object object_C; + public Object object_D; + public Object object_E; + public Object object_F; + public Object object_G; + public Object object_H; + public Object object_I; + public ItemStack object_OUTPUT; - public void buildRecipe(){ - RecipeUtils.recipeBuilder(this.object_A, this.object_B, this.object_C, this.object_D, this.object_E, this.object_F, this.object_G, this.object_H, this.object_I, this.object_OUTPUT); - } + public ShapedRecipeObject( + final Object input_A, + final Object input_B, + final Object input_C, + final Object input_D, + final Object input_E, + final Object input_F, + final Object input_G, + final Object input_H, + final Object input_I, + final ItemStack input_Output) { + this.object_A = input_A; + this.object_B = input_B; + this.object_C = input_C; + this.object_D = input_D; + this.object_E = input_E; + this.object_F = input_F; + this.object_G = input_G; + this.object_H = input_H; + this.object_I = input_I; + this.object_OUTPUT = input_Output; + Logger.SPECIFIC_WARNING("ShapedRecipeObject", "New object created.", 36); + } + public void buildRecipe() { + RecipeUtils.recipeBuilder( + this.object_A, + this.object_B, + this.object_C, + this.object_D, + this.object_E, + this.object_F, + this.object_G, + this.object_H, + this.object_I, + this.object_OUTPUT); + } } diff --git a/src/main/java/gtPlusPlus/core/recipe/common/CI.java b/src/main/java/gtPlusPlus/core/recipe/common/CI.java index f656cfe9f0..f3689897e5 100644 --- a/src/main/java/gtPlusPlus/core/recipe/common/CI.java +++ b/src/main/java/gtPlusPlus/core/recipe/common/CI.java @@ -26,1384 +26,1213 @@ import net.minecraftforge.fluids.FluidStack; public class CI { - //null - public static ItemStack _NULL = ItemUtils.getErrorStack(1); - - //bits - public static long bits = GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE - | GT_ModHandler.RecipeBits.BUFFERED; - public static long bitsd = GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE - | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED; - - //Circuits - public static Object circuitPrimitive; - public static Object circuitTier1; - public static Object circuitTier2; - public static Object circuitTier3; - public static Object circuitTier4; - public static Object circuitTier5; - public static Object circuitTier6; - public static Object circuitTier7; - public static Object circuitTier8; - public static Object circuitTier9; - - //Machine Components - public static ItemStack electricMotor_ULV; - public static ItemStack electricMotor_LV; - public static ItemStack electricMotor_MV; - public static ItemStack electricMotor_HV; - public static ItemStack electricMotor_EV; - public static ItemStack electricMotor_IV; - public static ItemStack electricMotor_LuV; - public static ItemStack electricMotor_ZPM; - public static ItemStack electricMotor_UV; - public static ItemStack electricMotor_MAX; - public static ItemStack electricPump_ULV; - public static ItemStack electricPump_LV; - public static ItemStack electricPump_MV; - public static ItemStack electricPump_HV; - public static ItemStack electricPump_EV; - public static ItemStack electricPump_IV; - public static ItemStack electricPump_LuV; - public static ItemStack electricPump_ZPM; - public static ItemStack electricPump_UV; - public static ItemStack electricPump_MAX; - public static ItemStack electricPiston_ULV; - public static ItemStack electricPiston_LV; - public static ItemStack electricPiston_MV; - public static ItemStack electricPiston_HV; - public static ItemStack electricPiston_EV; - public static ItemStack electricPiston_IV; - public static ItemStack electricPiston_LuV; - public static ItemStack electricPiston_ZPM; - public static ItemStack electricPiston_UV ; - public static ItemStack electricPiston_MAX; - public static ItemStack robotArm_ULV; - public static ItemStack robotArm_LV; - public static ItemStack robotArm_MV; - public static ItemStack robotArm_HV; - public static ItemStack robotArm_EV; - public static ItemStack robotArm_IV; - public static ItemStack robotArm_LuV; - public static ItemStack robotArm_ZPM; - public static ItemStack robotArm_UV; - public static ItemStack robotArm_MAX; - public static ItemStack conveyorModule_ULV; - public static ItemStack conveyorModule_LV; - public static ItemStack conveyorModule_MV; - public static ItemStack conveyorModule_HV; - public static ItemStack conveyorModule_EV; - public static ItemStack conveyorModule_IV; - public static ItemStack conveyorModule_LuV; - public static ItemStack conveyorModule_ZPM; - public static ItemStack conveyorModule_UV; - public static ItemStack conveyorModule_MAX; - public static ItemStack emitter_ULV; - public static ItemStack emitter_LV; - public static ItemStack emitter_MV; - public static ItemStack emitter_HV; - public static ItemStack emitter_EV; - public static ItemStack emitter_IV; - public static ItemStack emitter_LuV; - public static ItemStack emitter_ZPM; - public static ItemStack emitter_UV; - public static ItemStack emitter_MAX; - public static ItemStack fieldGenerator_ULV; - public static ItemStack fieldGenerator_LV; - public static ItemStack fieldGenerator_MV; - public static ItemStack fieldGenerator_HV; - public static ItemStack fieldGenerator_EV; - public static ItemStack fieldGenerator_IV; - public static ItemStack fieldGenerator_LuV; - public static ItemStack fieldGenerator_ZPM; - public static ItemStack fieldGenerator_UV; - public static ItemStack fieldGenerator_MAX; - public static ItemStack sensor_ULV; - public static ItemStack sensor_LV; - public static ItemStack sensor_MV; - public static ItemStack sensor_HV; - public static ItemStack sensor_EV; - public static ItemStack sensor_IV; - public static ItemStack sensor_LuV; - public static ItemStack sensor_ZPM; - public static ItemStack sensor_UV; - public static ItemStack sensor_MAX; - - public static ItemStack fluidRegulator_LV; - public static ItemStack fluidRegulator_MV; - public static ItemStack fluidRegulator_HV; - public static ItemStack fluidRegulator_EV; - public static ItemStack fluidRegulator_IV; - public static ItemStack fluidRegulator_LuV; - public static ItemStack fluidRegulator_ZPM; - public static ItemStack fluidRegulator_UV; - - //Machine Casings - public static ItemStack machineCasing_ULV; - public static ItemStack machineCasing_LV; - public static ItemStack machineCasing_MV; - public static ItemStack machineCasing_HV; - public static ItemStack machineCasing_EV; - public static ItemStack machineCasing_IV; - public static ItemStack machineCasing_LuV; - public static ItemStack machineCasing_ZPM; - public static ItemStack machineCasing_UV; - public static ItemStack machineCasing_MAX; - - //Machine Hulls - public static ItemStack machineHull_ULV; - public static ItemStack machineHull_LV; - public static ItemStack machineHull_MV; - public static ItemStack machineHull_HV; - public static ItemStack machineHull_EV; - public static ItemStack machineHull_IV; - public static ItemStack machineHull_LuV; - public static ItemStack machineHull_ZPM; - public static ItemStack machineHull_UV; - public static ItemStack machineHull_MAX; - - //Gearbox Casings - public static ItemStack gearboxCasing_Tier_1; - public static ItemStack gearboxCasing_Tier_2; - public static ItemStack gearboxCasing_Tier_3; - public static ItemStack gearboxCasing_Tier_4; - - public static String[] component_Plate; - public static String[] component_Rod; - public static String[] component_Ingot; - - //Crafting Tools - public static String craftingToolWrench = "craftingToolWrench"; - public static String craftingToolHammer_Hard = "craftingToolHardHammer"; - public static String craftingToolHammer_Soft = "craftingToolSoftHammer"; - public static String craftingToolScrewdriver = "craftingToolScrewdriver"; - public static String craftingToolFile = "craftingToolFile"; - public static String craftingToolMortar = "craftingToolMortar"; - public static String craftingToolKnife = "craftingToolKnife"; - public static String craftingToolCrowbar = "craftingToolCrowbar"; - public static String craftingToolSaw = "craftingToolSaw"; - public static String craftingToolWireCutter = "craftingToolWirecutter"; - public static String craftingToolSolderingIron = "craftingToolSolderingIron"; - - //Explosives - public static ItemStack explosivePowderKeg; - public static ItemStack explosiveTNT; - public static ItemStack explosiveITNT; - - public static Materials[] tieredMaterials = new Materials[] { - Materials.Iron, Materials.Steel, Materials.Aluminium, - Materials.StainlessSteel, Materials.Titanium, Materials.TungstenSteel, - Materials.Chrome, Materials.Iridium, Materials.Osmium, - Materials.Neutronium - };; - - public static void preInit(){ - - //Tiered Components - component_Plate = new String[]{ - getTieredComponent(OrePrefixes.plate, 0), - getTieredComponent(OrePrefixes.plate, 1), - getTieredComponent(OrePrefixes.plate, 2), - getTieredComponent(OrePrefixes.plate, 3), - getTieredComponent(OrePrefixes.plate, 4), - getTieredComponent(OrePrefixes.plate, 5), - getTieredComponent(OrePrefixes.plate, 6), - getTieredComponent(OrePrefixes.plate, 7), - getTieredComponent(OrePrefixes.plate, 8), - getTieredComponent(OrePrefixes.plate, 9), - getTieredComponent(OrePrefixes.plate, 10), - getTieredComponent(OrePrefixes.plate, 11) - }; - component_Rod = new String[]{ - getTieredComponent(OrePrefixes.stick, 0), - getTieredComponent(OrePrefixes.stick, 1), - getTieredComponent(OrePrefixes.stick, 2), - getTieredComponent(OrePrefixes.stick, 3), - getTieredComponent(OrePrefixes.stick, 4), - getTieredComponent(OrePrefixes.stick, 5), - getTieredComponent(OrePrefixes.stick, 6), - getTieredComponent(OrePrefixes.stick, 7), - getTieredComponent(OrePrefixes.stick, 8), - getTieredComponent(OrePrefixes.stick, 9), - getTieredComponent(OrePrefixes.stick, 10), - getTieredComponent(OrePrefixes.stick, 11) - }; - component_Ingot = new String[]{ - getTieredComponent(OrePrefixes.ingot, 0), - getTieredComponent(OrePrefixes.ingot, 1), - getTieredComponent(OrePrefixes.ingot, 2), - getTieredComponent(OrePrefixes.ingot, 3), - getTieredComponent(OrePrefixes.ingot, 4), - getTieredComponent(OrePrefixes.ingot, 5), - getTieredComponent(OrePrefixes.ingot, 6), - getTieredComponent(OrePrefixes.ingot, 7), - getTieredComponent(OrePrefixes.ingot, 8), - getTieredComponent(OrePrefixes.ingot, 9), - getTieredComponent(OrePrefixes.ingot, 10), - getTieredComponent(OrePrefixes.ingot, 11) - }; - - //Circuits - circuitPrimitive = getTieredCircuit(0); - circuitTier1 = getTieredCircuit(1); - circuitTier2 = getTieredCircuit(2); - circuitTier3 = getTieredCircuit(3); - circuitTier4 = getTieredCircuit(4); - circuitTier5 = getTieredCircuit(5); - circuitTier6 = getTieredCircuit(6); - circuitTier7 = getTieredCircuit(7); - circuitTier8 = getTieredCircuit(8); - circuitTier9 = getTieredCircuit(9); - - } - - public static Object getTieredCircuit(int tier){ - if (CORE.ConfigSwitches.enableOldGTcircuits && CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && !CORE.GTNH){ - if (tier == 0){ - return GregtechItemList.Old_Circuit_Primitive.get(1); - } - else if (tier == 1){ - return GregtechItemList.Old_Circuit_Basic.get(1); - } - else if (tier == 2){ - return GregtechItemList.Old_Circuit_Good.get(1); - } - else if (tier == 3){ - return GregtechItemList.Old_Circuit_Advanced.get(1); - } - else if (tier == 4){ - return GregtechItemList.Old_Circuit_Data.get(1); - } - else if (tier == 5){ - return GregtechItemList.Old_Circuit_Elite.get(1); - } - else if (tier == 6){ - return GregtechItemList.Old_Circuit_Master.get(1); - } - else if (tier == 7){ - return GregtechItemList.Old_Circuit_Ultimate.get(1); - } - else if (tier == 8){ - return GregtechItemList.Circuit_IV.get(1); - } - else if (tier == 9){ - return GregtechItemList.Circuit_LuV.get(1); - } - else if (tier == 10){ - return GregtechItemList.Circuit_ZPM.get(1); - } - } - else { - return getTieredCircuitOreDictName(tier); - } - return _NULL; - } - - public static ItemStack[] getAllCircuitsOfTier(int tier){ - return ItemUtils.getStackOfAllOreDictGroup(getTieredCircuitOreDictName(tier)); - } - - public static String getTieredCircuitOreDictName(int tier){ - if (tier == 0){ - return "circuitPrimitive"; - } - else if (tier == 1){ - return "circuitBasic"; - } - else if (tier == 2){ - return "circuitGood"; - } - else if (tier == 3){ - return "circuitAdvanced"; - } - else if (tier == 4){ - return "circuitData"; - } - else if (tier == 5){ - return "circuitElite"; - } - else if (tier == 6){ - return "circuitMaster"; - } - else if (tier == 7){ - return "circuitUltimate"; - } - else if (tier == 8){ - return "circuitSuperconductor"; - } - else if (tier == 9){ - return "circuitInfinite"; - } - else if (tier == 10){ - return "circuitQuantum"; - } - else { - return "circuitPrimitive"; - } - } - - public static ItemStack getNumberedCircuit(int Meta){ - return ItemUtils.getGregtechCircuit(Meta); - } - - private static Object getMaterialFromTier(int tier){ - if (tier == 0){ - return Materials.Wood; - } - else if (tier == 1){ - return Materials.Lead; - } - else if (tier == 2){ - return Materials.Bronze; - } - else if (tier == 3){ - return Materials.Steel; - } - else if (tier == 4){ - return ALLOY.EGLIN_STEEL; - } - else if (tier == 5){ - return Materials.Aluminium; - } - else if (tier == 6){ - return ALLOY.MARAGING250; - } - else if (tier == 7){ - return ALLOY.TANTALLOY_61; - } - else if (tier == 8){ - return ALLOY.INCONEL_792; - } - else if (tier == 9){ - return ALLOY.ZERON_100; - } - else if (tier == 10){ - return Materials.NaquadahEnriched; - } - else if (tier == 11){ - return Materials.Neutronium; - } - return Materials._NULL; - } - - @Deprecated - public static String getTieredComponent(OrePrefixes type, int tier){ - Object material = getMaterialFromTier(tier); - if (material != null){ - if (material instanceof Materials){ - //return (ItemStack) type.get(material); - String materialName = ((Materials) material).mDefaultLocalName; - Logger.INFO("Searching for a component named "+type.name()+materialName); - //return ItemUtils.getItemStackOfAmountFromOreDict(type.name()+materialName, 1); - return (type.name()+materialName); - } - else { - String materialName = (Utils.sanitizeString(((Material) material).getLocalizedName())); - Logger.INFO("Searching for a component named "+type.name()+materialName); - //return ItemUtils.getItemStackOfAmountFromOreDict(type.name()+materialName, 1); - return (type.name()+materialName); - } - } - Logger.INFO("[Components] Failed getting a tiered component. "+type.name()+" | "+tier); - return null; - } - - public static ItemStack getDataOrb(){ - if (CORE.ConfigSwitches.enableOldGTcircuits && CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && !CORE.GTNH){ - return GregtechItemList.Old_Tool_DataOrb.get(1); - } - else { - return ItemList.Tool_DataOrb.get(1); - } - } - - public static ItemStack getDataStick(){ - if (CORE.ConfigSwitches.enableOldGTcircuits && CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && !CORE.GTNH){ - return GregtechItemList.Old_Tool_DataStick.get(1); - } - else { - return ItemList.Tool_DataStick.get(1); - } - } - - public static final ItemStack getTieredMachineHull(int tier){ - if (tier == 0){ - return machineHull_ULV; - } - else if (tier == 1){ - return machineHull_LV; - } - else if (tier == 2){ - return machineHull_MV; - } - else if (tier == 3){ - return machineHull_HV; - } - else if (tier == 4){ - return machineHull_EV; - } - else if (tier == 5){ - return machineHull_IV; - } - else if (tier == 6){ - return machineHull_LuV; - } - else if (tier == 7){ - return machineHull_ZPM; - } - else if (tier == 8){ - return machineHull_UV; - } - else if (tier == 9){ - return machineHull_MAX; - } - else { - return GregtechItemList.Casing_Multi_Use.get(1); - } - } - - public static final ItemStack getTieredMachineCasing(int tier){ - if (tier == 0){ - if (machineCasing_ULV == null) { - machineCasing_ULV = ItemList.Casing_ULV.get(1); - } - return machineCasing_ULV; - } - else if (tier == 1){ - return machineCasing_LV; - } - else if (tier == 2){ - return machineCasing_MV; - } - else if (tier == 3){ - return machineCasing_HV; - } - else if (tier == 4){ - return machineCasing_EV; - } - else if (tier == 5){ - return machineCasing_IV; - } - else if (tier == 6){ - return machineCasing_LuV; - } - else if (tier == 7){ - return machineCasing_ZPM; - } - else if (tier == 8){ - return machineCasing_UV; - } - else if (tier == 9){ - return machineCasing_MAX; - } - else { - return GregtechItemList.Casing_Multi_Use.get(1); - } - } - - public static void init() { - //Set Explosives - explosivePowderKeg = ItemUtils.getValueOfItemList("Block_Powderbarrel", 1, ItemUtils.getSimpleStack(Items.gunpowder, 16)); - explosiveTNT = ItemUtils.getSimpleStack(Blocks.tnt).copy(); - explosiveITNT = Ic2Items.industrialTnt.copy(); - - //Machine Casings - machineCasing_ULV = ItemList.Casing_ULV.get(1); - machineCasing_LV = ItemList.Casing_LV.get(1); - machineCasing_MV = ItemList.Casing_MV.get(1); - machineCasing_HV = ItemList.Casing_HV.get(1); - machineCasing_EV = ItemList.Casing_EV.get(1); - machineCasing_IV = ItemList.Casing_IV.get(1); - machineCasing_LuV = ItemList.Casing_LuV.get(1); - machineCasing_ZPM = ItemList.Casing_ZPM.get(1); - machineCasing_UV = ItemList.Casing_UV.get(1); - machineCasing_MAX = ItemList.Casing_MAX.get(1); - - //Machine Hulls - machineHull_ULV = ItemList.Hull_ULV.get(1); - machineHull_LV = ItemList.Hull_LV.get(1); - machineHull_MV = ItemList.Hull_MV.get(1); - machineHull_HV = ItemList.Hull_HV.get(1); - machineHull_EV = ItemList.Hull_EV.get(1); - machineHull_IV = ItemList.Hull_IV.get(1); - machineHull_LuV = ItemList.Hull_LuV.get(1); - machineHull_ZPM = ItemList.Hull_ZPM.get(1); - machineHull_UV = ItemList.Hull_UV.get(1); - machineHull_MAX = ItemList.Hull_MAX.get(1); - - //Gear box Casings - gearboxCasing_Tier_1 = ItemList.Casing_Gearbox_Bronze.get(1); - gearboxCasing_Tier_2 = ItemList.Casing_Gearbox_Steel.get(1); - gearboxCasing_Tier_3 = ItemList.Casing_Gearbox_Titanium.get(1); - gearboxCasing_Tier_4 = ItemList.Casing_Gearbox_TungstenSteel.get(1); - - //Machine Components - LOADER_Machine_Components.initialise(); - } - - public static ItemStack emptyCells(int i) { - return ItemUtils.getEmptyCell(i); - } - - private static final Material[] aMaterial_Main = new Material[] { - ALLOY.POTIN, - ALLOY.TUMBAGA, - ALLOY.EGLIN_STEEL, - ALLOY.INCONEL_792, - ALLOY.INCOLOY_MA956, - ALLOY.NITINOL_60, - ALLOY.ZERON_100, - ALLOY.PIKYONIUM, - ELEMENT.STANDALONE.ADVANCED_NITINOL, - ALLOY.ABYSSAL, - ALLOY.QUANTUM, - ELEMENT.STANDALONE.HYPOGEN - }; - - private static final Material[] aMaterial_Secondary = new Material[] { - ALLOY.STEEL, - ALLOY.SILICON_CARBIDE, - ALLOY.BABBIT_ALLOY, - ALLOY.INCONEL_690, - ALLOY.STELLITE, - ALLOY.ARCANITE, - ALLOY.LAFIUM, - ALLOY.CINOBITE, - ALLOY.TITANSTEEL, - ALLOY.OCTIRON, - ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN, - ELEMENT.STANDALONE.HYPOGEN - }; - - private static final Material[] aMaterial_Tertiary = new Material[] { - ELEMENT.getInstance().LEAD, - ELEMENT.getInstance().ALUMINIUM, - ELEMENT.STANDALONE.BLACK_METAL, - ELEMENT.getInstance().TITANIUM, - ALLOY.HASTELLOY_N, - ALLOY.ENERGYCRYSTAL, - ALLOY.TRINIUM_NAQUADAH_CARBON, - ALLOY.TRINIUM_REINFORCED_STEEL, //Arceus - ALLOY.TITANSTEEL, - ELEMENT.STANDALONE.ASTRAL_TITANIUM, - ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN, - ELEMENT.STANDALONE.HYPOGEN - }; - - private static final Materials[] aMaterial_Cables = new Materials[] { - !CORE.GTNH ? Materials.Lead : Materials.Tin, - Materials.Cobalt, - Materials.AnnealedCopper, - Materials.Gold, - Materials.Titanium, - Materials.Nichrome, - Materials.Platinum, - Materials.YttriumBariumCuprate, - Materials.Naquadah, - Materials.Duranium, - Materials.Superconductor, - }; - - private static final Materials[] aMaterial_Circuits = new Materials[] { - Materials.Primitive, - Materials.Basic, - Materials.Good, - Materials.Advanced, - Materials.Data, - Materials.Data, - Materials.Elite, - Materials.Master, - Materials.Ultimate, - Materials.Superconductor, - Materials.Infinite, - }; - - private static final Material[][] aMaster = new Material[][] {aMaterial_Main, aMaterial_Secondary, aMaterial_Tertiary}; - - - public static FluidStack getTieredFluid(int aTier, int aAmount) { - return getTieredFluid(aTier, aAmount, 0); - } - - public static FluidStack getAlternativeTieredFluid(int aTier, int aAmount) { - return getTieredFluid(aTier, aAmount, 1); - } - - public static FluidStack getTertiaryTieredFluid(int aTier, int aAmount) { - return getTieredFluid(aTier, aAmount, 2); - } - - public static FluidStack getTieredFluid(int aTier, int aAmount, int aType) { - // Weird Legacy handling - /*ItemStack aCell = getTieredComponent(OrePrefixes.liquid, aTier, 1); - FluidStack a = GT_Utility.getFluidForFilledItem(aCell, true); - if (a == null) { - a = aMaster[aType][aTier].getFluid(aAmount); - }*/ - - // Modern Handling - FluidStack a = aMaster[aType][aTier].getFluidStack(aAmount); - if (a == null) { - ItemStack aCell = getTieredComponent(OrePrefixes.liquid, aTier, 1); - if (aCell != null) { - a = GT_Utility.getFluidForFilledItem(aCell, true); - a.amount = aAmount; - } - } - return a; - } - - public static ItemStack getEnergyCore(int aTier, int aAmount) { - ItemStack[] aOutput = new ItemStack[] { - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"1", 1), - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"2", 1), - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"3", 1), - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"4", 1), - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"5", 1), - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"6", 1), - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"7", 1), - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"8", 1), - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"9", 1), - ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"10", 1) - }; - return ItemUtils.getSimpleStack(aOutput[MathUtils.balance(aTier, 0, 9)], aAmount); - } - - public static ItemStack getPlate(int aTier, int aAmount) { - return getTieredComponent(OrePrefixes.plate, aTier, aAmount); - } - - public static ItemStack getDoublePlate(int aTier, int aAmount) { - return getTieredComponent(OrePrefixes.plateDouble, aTier, aAmount); - } - - public static ItemStack getGear(int aTier, int aAmount) { - return getTieredComponent(OrePrefixes.gearGt, aTier, aAmount); - } - - public static ItemStack getIngot(int aTier, int aAmount) { - return getTieredComponent(OrePrefixes.ingot, aTier, aAmount); - } - - public static ItemStack getBolt(int aTier, int aAmount) { - return getTieredComponent(OrePrefixes.bolt, aTier, aAmount); - } - - public static ItemStack getScrew(int aTier, int aAmount) { - return getTieredComponent(OrePrefixes.screw, aTier, aAmount); - } - - public static ItemStack getCircuit(int aTier, int aAmount) { - return getTieredComponent(OrePrefixes.circuit, aTier, aAmount); - } - - public static ItemStack getTieredComponent(OrePrefixes aPrefix, int aTier, int aAmount) { - aTier = Math.max(0, aTier); - - Material m = null; - - if (aPrefix == OrePrefixes.liquid) { - int aMatID = (aTier == 0 || aTier == 2 || aTier == 5 || aTier == 8 ? 0 : (aTier == 1 || aTier == 3 || aTier == 6 || aTier == 9 ? 1 : 2)); - ItemStack aCell = aMaster[aMatID][aTier].getCell(aAmount); - return aCell; - } - - if (aPrefix == OrePrefixes.circuit) { - /*if (aTier == 4) { - return ItemUtils.getSimpleStack(CI.getDataStick(), aAmount); - } - else if (aTier == 5) { - return ItemUtils.getSimpleStack(CI.getDataOrb(), aAmount); - }*/ - return ItemUtils.getOrePrefixStack(OrePrefixes.circuit, aMaterial_Circuits[aTier], aAmount); - } - - //Check for Cables first, catch SuperConductor case and swap to wire. - if (aPrefix == OrePrefixes.cableGt01 || aPrefix == OrePrefixes.cableGt02 || aPrefix == OrePrefixes.cableGt04 || aPrefix == OrePrefixes.cableGt08 || aPrefix == OrePrefixes.cableGt12) { - //Special Handler - if (aTier == 10) { - if (aPrefix == OrePrefixes.cableGt01) { - aPrefix = OrePrefixes.wireGt02; - } - else if (aPrefix == OrePrefixes.cableGt02) { - aPrefix = OrePrefixes.wireGt04; - } - else if (aPrefix == OrePrefixes.cableGt04) { - aPrefix = OrePrefixes.wireGt08; - } - else if (aPrefix == OrePrefixes.cableGt08) { - aPrefix = OrePrefixes.wireGt12; - } - else if (aPrefix == OrePrefixes.cableGt12) { - aPrefix = OrePrefixes.wireGt16; - } - } - else { - return ItemUtils.getOrePrefixStack(aPrefix, aMaterial_Cables[aTier], aAmount); - } - - - } - if (aPrefix == OrePrefixes.wireGt01 || aPrefix == OrePrefixes.wireGt02 || aPrefix == OrePrefixes.wireGt04 || aPrefix == OrePrefixes.wireGt08 || aPrefix == OrePrefixes.wireGt12 || aPrefix == OrePrefixes.wireGt16) { - return ItemUtils.getOrePrefixStack(aPrefix, aMaterial_Cables[aTier], aAmount); - } - - if (aPrefix == OrePrefixes.pipeTiny || aPrefix == OrePrefixes.pipeSmall || aPrefix == OrePrefixes.pipe || aPrefix == OrePrefixes.pipeMedium || aPrefix == OrePrefixes.pipeLarge || aPrefix == OrePrefixes.pipeHuge) { - - if (aPrefix == OrePrefixes.pipe) { - aPrefix = OrePrefixes.pipeMedium; - } - - if (aTier == 0) { - return ItemUtils.getOrePrefixStack(aPrefix, Materials.Lead, aAmount); - } - else if (aTier == 1) { - return ItemUtils.getOrePrefixStack(aPrefix, Materials.Steel, aAmount); - } - else if (aTier == 2) { - return ItemUtils.getOrePrefixStack(aPrefix, Materials.StainlessSteel, aAmount); - } - else if (aTier == 3) { - return ItemUtils.getOrePrefixStack(aPrefix, Materials.Tungsten, aAmount); - } - else if (aTier == 4) { - return ItemUtils.getOrePrefixStack(aPrefix, Materials.TungstenSteel, aAmount); - } - else if (aTier == 5) { - return ItemUtils.getOrePrefixStack(aPrefix, ALLOY.MARAGING350, aAmount); - } - else if (aTier == 6) { - return ItemUtils.getOrePrefixStack(aPrefix, ALLOY.STABALLOY, aAmount); - } - else if (aTier == 7) { - return ItemUtils.getOrePrefixStack(aPrefix, ALLOY.HASTELLOY_X, aAmount); - } - else if (aTier == 8) { - return ItemUtils.getOrePrefixStack(aPrefix, Materials.Ultimate, aAmount); - } - else if (aTier == 9) { - return ItemUtils.getOrePrefixStack(OrePrefixes.pipeMedium, Materials.Superconductor, aAmount); - } - else if (aTier == 10) { - return ItemUtils.getOrePrefixStack(aPrefix, Materials.Europium, aAmount); - } - else { - return ItemUtils.getOrePrefixStack(aPrefix, Materials.Titanium, aAmount); - } - } - - if (aPrefix == OrePrefixes.rod) { - aPrefix = OrePrefixes.stick; - } - - if (aPrefix == OrePrefixes.gear || aPrefix == OrePrefixes.gearGt) { - m = aMaster[0][aTier]; - } - else if (aPrefix == OrePrefixes.rod || aPrefix == OrePrefixes.stick) { - m = aMaster[0][aTier]; - } - else if (aPrefix == OrePrefixes.stickLong) { - m = aMaster[1][aTier]; - } - else if (aPrefix == OrePrefixes.bolt) { - m = aMaster[2][aTier]; - } - else if (aPrefix == OrePrefixes.screw) { - m = aMaster[0][aTier]; - } - else if (aPrefix == OrePrefixes.rotor) { - m = aMaster[1][aTier]; - } - else if (aPrefix == OrePrefixes.frame || aPrefix == OrePrefixes.frameGt) { - m = aMaster[2][aTier]; - } - else if (aPrefix == OrePrefixes.ingot) { - m = aMaster[1][aTier]; - } - else if (aPrefix == OrePrefixes.plate) { - m = aMaster[0][aTier]; - } - else if (aPrefix == OrePrefixes.plateDouble) { - m = aMaster[0][aTier]; - } - else if (aPrefix == OrePrefixes.ring) { - m = aMaster[2][aTier]; - } - else if (aPrefix == OrePrefixes.cell) { - m = aMaster[1][aTier]; - } - else { - m = aMaterial_Main[aTier]; - } - - ItemStack aReturn = ItemUtils.getOrePrefixStack(aPrefix, m, aAmount); - - //If Invalid, Try First Material - if (!ItemUtils.checkForInvalidItems(aReturn)) { - m = aMaster[0][aTier]; - aReturn = ItemUtils.getOrePrefixStack(aPrefix, m, aAmount); - - //If Invalid, Try Second Material - if (!ItemUtils.checkForInvalidItems(aReturn)) { - m = aMaster[1][aTier]; - aReturn = ItemUtils.getOrePrefixStack(aPrefix, m, aAmount); - - //If Invalid, Try Third Material - if (!ItemUtils.checkForInvalidItems(aReturn)) { - m = aMaster[2][aTier]; - aReturn = ItemUtils.getOrePrefixStack(aPrefix, m, aAmount); - - //All Invalid? Ok, shit. - //Let's add a special error ingot. - if (!ItemUtils.checkForInvalidItems(aReturn)) { - aReturn = ItemUtils.getErrorStack(1, (aPrefix.toString()+m.getLocalizedName()+" x"+aAmount)); - } - } - } - } - - return aReturn; - - - } - - public static ItemStack getElectricMotor(int aTier, int aSize) { - ItemStack aType; - int aLazyTier = 0; - if (aTier == aLazyTier++) { - aType = CI.electricMotor_ULV; - } - else if (aTier == aLazyTier++) { - aType = CI.electricMotor_LV; - } - else if (aTier == aLazyTier++) { - aType = CI.electricMotor_MV; - } - else if (aTier == aLazyTier++) { - aType = CI.electricMotor_HV; - } - else if (aTier == aLazyTier++) { - aType = CI.electricMotor_EV; - } - else if (aTier == aLazyTier++) { - aType = CI.electricMotor_IV; - } - else if (aTier == aLazyTier++) { - aType = CI.electricMotor_LuV; - } - else if (aTier == aLazyTier++) { - aType = CI.electricMotor_ZPM; - } - else if (aTier == aLazyTier++) { - aType = CI.electricMotor_UV; - } - else if (aTier == aLazyTier++) { - aType = CI.electricMotor_MAX; - } - else { - aType = CI.electricMotor_LV; - } - return ItemUtils.getSimpleStack(aType, aSize); - } - - public static ItemStack getFluidRegulator(int aTier, int aSize) { - if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - return CI.getElectricPump(aTier, aSize); - } - ItemStack aType; - int aLazyTier = 0; - if (aTier == aLazyTier++) { - aType = CI.fluidRegulator_LV; - } - else if (aTier == aLazyTier++) { - aType = CI.fluidRegulator_LV; - } - else if (aTier == aLazyTier++) { - aType = CI.fluidRegulator_MV; - } - else if (aTier == aLazyTier++) { - aType = CI.fluidRegulator_HV; - } - else if (aTier == aLazyTier++) { - aType = CI.fluidRegulator_EV; - } - else if (aTier == aLazyTier++) { - aType = CI.fluidRegulator_IV; - } - else if (aTier == aLazyTier++) { - aType = CI.fluidRegulator_LuV; - } - else if (aTier == aLazyTier++) { - aType = CI.fluidRegulator_ZPM; - } - else if (aTier == aLazyTier++) { - aType = CI.fluidRegulator_UV; - } - else if (aTier == aLazyTier++) { - aType = CI.fluidRegulator_UV; - } - else { - aType = CI.fluidRegulator_LV; - } - return ItemUtils.getSimpleStack(aType, aSize); - } - - public static ItemStack getElectricPiston(int aTier, int aSize) { - ItemStack aType; - int aLazyTier = 0; - if (aTier == aLazyTier++) { - aType = CI.electricPiston_ULV; - } - else if (aTier == aLazyTier++) { - aType = CI.electricPiston_LV; - } - else if (aTier == aLazyTier++) { - aType = CI.electricPiston_MV; - } - else if (aTier == aLazyTier++) { - aType = CI.electricPiston_HV; - } - else if (aTier == aLazyTier++) { - aType = CI.electricPiston_EV; - } - else if (aTier == aLazyTier++) { - aType = CI.electricPiston_IV; - } - else if (aTier == aLazyTier++) { - aType = CI.electricPiston_LuV; - } - else if (aTier == aLazyTier++) { - aType = CI.electricPiston_ZPM; - } - else if (aTier == aLazyTier++) { - aType = CI.electricPiston_UV; - } - else if (aTier == aLazyTier++) { - aType = CI.electricPiston_MAX; - } - else { - aType = CI.electricPiston_LV; - } - return ItemUtils.getSimpleStack(aType, aSize); - } - - public static ItemStack getElectricPump(int aTier, int aSize) { - ItemStack aType; - int aLazyTier = 0; - if (aTier == aLazyTier++) { - aType = CI.electricPump_ULV; - } - else if (aTier == aLazyTier++) { - aType = CI.electricPump_LV; - } - else if (aTier == aLazyTier++) { - aType = CI.electricPump_MV; - } - else if (aTier == aLazyTier++) { - aType = CI.electricPump_HV; - } - else if (aTier == aLazyTier++) { - aType = CI.electricPump_EV; - } - else if (aTier == aLazyTier++) { - aType = CI.electricPump_IV; - } - else if (aTier == aLazyTier++) { - aType = CI.electricPump_LuV; - } - else if (aTier == aLazyTier++) { - aType = CI.electricPump_ZPM; - } - else if (aTier == aLazyTier++) { - aType = CI.electricPump_UV; - } - else if (aTier == aLazyTier++) { - aType = CI.electricPump_MAX; - } - else { - aType = CI.electricPump_LV; - } - return ItemUtils.getSimpleStack(aType, aSize); - } - - public static ItemStack getRobotArm(int aTier, int aSize) { - ItemStack aType; - int aLazyTier = 0; - if (aTier == aLazyTier++) { - aType = CI.robotArm_ULV; - } - else if (aTier == aLazyTier++) { - aType = CI.robotArm_LV; - } - else if (aTier == aLazyTier++) { - aType = CI.robotArm_MV; - } - else if (aTier == aLazyTier++) { - aType = CI.robotArm_HV; - } - else if (aTier == aLazyTier++) { - aType = CI.robotArm_EV; - } - else if (aTier == aLazyTier++) { - aType = CI.robotArm_IV; - } - else if (aTier == aLazyTier++) { - aType = CI.robotArm_LuV; - } - else if (aTier == aLazyTier++) { - aType = CI.robotArm_ZPM; - } - else if (aTier == aLazyTier++) { - aType = CI.robotArm_UV; - } - else if (aTier == aLazyTier++) { - aType = CI.robotArm_MAX; - } - else { - aType = CI.robotArm_LV; - } - return ItemUtils.getSimpleStack(aType, aSize); - } - - public static ItemStack getConveyor(int aTier, int aSize) { - ItemStack aType; - int aLazyTier = 0; - if (aTier == aLazyTier++) { - aType = CI.conveyorModule_ULV; - } - else if (aTier == aLazyTier++) { - aType = CI.conveyorModule_LV; - } - else if (aTier == aLazyTier++) { - aType = CI.conveyorModule_MV; - } - else if (aTier == aLazyTier++) { - aType = CI.conveyorModule_HV; - } - else if (aTier == aLazyTier++) { - aType = CI.conveyorModule_EV; - } - else if (aTier == aLazyTier++) { - aType = CI.conveyorModule_IV; - } - else if (aTier == aLazyTier++) { - aType = CI.conveyorModule_LuV; - } - else if (aTier == aLazyTier++) { - aType = CI.conveyorModule_ZPM; - } - else if (aTier == aLazyTier++) { - aType = CI.conveyorModule_UV; - } - else if (aTier == aLazyTier++) { - aType = CI.conveyorModule_MAX; - } - else { - aType = CI.conveyorModule_LV; - } - return ItemUtils.getSimpleStack(aType, aSize); - } - - public static ItemStack getEmitter(int aTier, int aSize) { - ItemStack aType; - int aLazyTier = 0; - if (aTier == aLazyTier++) { - aType = CI.emitter_ULV; - } - else if (aTier == aLazyTier++) { - aType = CI.emitter_LV; - } - else if (aTier == aLazyTier++) { - aType = CI.emitter_MV; - } - else if (aTier == aLazyTier++) { - aType = CI.emitter_HV; - } - else if (aTier == aLazyTier++) { - aType = CI.emitter_EV; - } - else if (aTier == aLazyTier++) { - aType = CI.emitter_IV; - } - else if (aTier == aLazyTier++) { - aType = CI.emitter_LuV; - } - else if (aTier == aLazyTier++) { - aType = CI.emitter_ZPM; - } - else if (aTier == aLazyTier++) { - aType = CI.emitter_UV; - } - else if (aTier == aLazyTier++) { - aType = CI.emitter_MAX; - } - else { - aType = CI.emitter_LV; - } - return ItemUtils.getSimpleStack(aType, aSize); - } - - public static ItemStack getSensor(int aTier, int aSize) { - ItemStack aType; - int aLazyTier = 0; - if (aTier == aLazyTier++) { - aType = CI.sensor_ULV; - } - else if (aTier == aLazyTier++) { - aType = CI.sensor_LV; - } - else if (aTier == aLazyTier++) { - aType = CI.sensor_MV; - } - else if (aTier == aLazyTier++) { - aType = CI.sensor_HV; - } - else if (aTier == aLazyTier++) { - aType = CI.sensor_EV; - } - else if (aTier == aLazyTier++) { - aType = CI.sensor_IV; - } - else if (aTier == aLazyTier++) { - aType = CI.sensor_LuV; - } - else if (aTier == aLazyTier++) { - aType = CI.sensor_ZPM; - } - else if (aTier == aLazyTier++) { - aType = CI.sensor_UV; - } - else if (aTier == aLazyTier++) { - aType = CI.sensor_MAX; - } - else { - aType = CI.sensor_LV; - } - return ItemUtils.getSimpleStack(aType, aSize); - } - - public static ItemStack getFieldGenerator(int aTier, int aSize) { - ItemStack aType; - int aLazyTier = 0; - if (aTier == aLazyTier++) { - aType = CI.fieldGenerator_ULV; - } - else if (aTier == aLazyTier++) { - aType = CI.fieldGenerator_LV; - } - else if (aTier == aLazyTier++) { - aType = CI.fieldGenerator_MV; - } - else if (aTier == aLazyTier++) { - aType = CI.fieldGenerator_HV; - } - else if (aTier == aLazyTier++) { - aType = CI.fieldGenerator_EV; - } - else if (aTier == aLazyTier++) { - aType = CI.fieldGenerator_IV; - } - else if (aTier == aLazyTier++) { - aType = CI.fieldGenerator_LuV; - } - else if (aTier == aLazyTier++) { - aType = CI.fieldGenerator_ZPM; - } - else if (aTier == aLazyTier++) { - aType = CI.fieldGenerator_UV; - } - else if (aTier == aLazyTier++) { - aType = CI.fieldGenerator_MAX; - } - else { - aType = CI.fieldGenerator_LV; - } - return ItemUtils.getSimpleStack(aType, aSize); - } - - - - public static ItemStack getTieredMachineHull(int aTier, int aSize) { - ItemStack aType; - int aLazyTier = 0; - if (aTier == aLazyTier++) { - aType = CI.machineHull_ULV; - } - else if (aTier == aLazyTier++) { - aType = CI.machineHull_LV; - } - else if (aTier == aLazyTier++) { - aType = CI.machineHull_MV; - } - else if (aTier == aLazyTier++) { - aType = CI.machineHull_HV; - } - else if (aTier == aLazyTier++) { - aType = CI.machineHull_EV; - } - else if (aTier == aLazyTier++) { - aType = CI.machineHull_IV; - } - else if (aTier == aLazyTier++) { - aType = CI.machineHull_LuV; - } - else if (aTier == aLazyTier++) { - aType = CI.machineHull_ZPM; - } - else if (aTier == aLazyTier++) { - aType = CI.machineHull_UV; - } - else if (aTier == aLazyTier++) { - aType = CI.machineHull_MAX; - } - else { - aType = GregtechItemList.Casing_Multi_Use.get(1, CI.machineHull_MV); - } - return ItemUtils.getSimpleStack(aType, aSize); - } - - public static ItemStack getHeatCoil(int i) { - if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - if (i == 1) { - return ItemList.Casing_Coil_Kanthal.get(1); - } else if (i == 2) { - return ItemList.Casing_Coil_Nichrome.get(1); - } else { - return ItemList.Casing_Coil_Cupronickel.get(1); - } - } else { - if (!CORE.GTNH) { - if (i > 6) { - i = 6; - } - } else { - if (i > 8) { - i = 8; - } - } - return ItemUtils.simpleMetaStack(StaticFields59.getBlockCasings5(), i, 1); - } - - } - - public static ItemStack getNumberedBioCircuit(int i) { - return ItemUtils.simpleMetaStack(AgriculturalChem.mBioCircuit, i, 0); - } - - public static ItemStack getNumberedAdvancedCircuit(int i) { - return ItemUtils.simpleMetaStack(GenericChem.mAdvancedCircuit, i, 0); - } - - public static ItemStack getTieredGTPPMachineCasing(int aTier, int aAmount) { - GregtechItemList[] aHulls = new GregtechItemList[] { - GregtechItemList.GTPP_Casing_ULV, - GregtechItemList.GTPP_Casing_LV, - GregtechItemList.GTPP_Casing_MV, - GregtechItemList.GTPP_Casing_HV, - GregtechItemList.GTPP_Casing_EV, - GregtechItemList.GTPP_Casing_IV, - GregtechItemList.GTPP_Casing_LuV, - GregtechItemList.GTPP_Casing_ZPM, - GregtechItemList.GTPP_Casing_UV, - GregtechItemList.GTPP_Casing_MAX - }; - return aHulls[aTier].get(aAmount); - } - - public static ItemStack getTieredComponentOfMaterial(Materials aMaterial, OrePrefixes aPrefix, int aAmount) { - return ItemUtils.getOrePrefixStack(aPrefix, aMaterial, aAmount); - } - - public static ItemStack getTransmissionComponent(int aTier, int aAmount) { - GregtechItemList[] aTransParts = new GregtechItemList[] { - GregtechItemList.TransmissionComponent_ULV, - GregtechItemList.TransmissionComponent_LV, - GregtechItemList.TransmissionComponent_MV, - GregtechItemList.TransmissionComponent_HV, - GregtechItemList.TransmissionComponent_EV, - GregtechItemList.TransmissionComponent_IV, - GregtechItemList.TransmissionComponent_LuV, - GregtechItemList.TransmissionComponent_ZPM, - GregtechItemList.TransmissionComponent_UV, - GregtechItemList.TransmissionComponent_MAX, - }; - return aTransParts[aTier].get(aAmount); - } - - public static ItemStack getEmptyCatalyst(int aAmount) { - return ItemUtils.simpleMetaStack(AgriculturalChem.mAgrichemItem1, 13, aAmount); - } - - /** - * Aluminium + Silver Catalyst - * @param aAmount - Stacksize - * @return - A Catalyst stack of given size - */ - public static ItemStack getGreenCatalyst(int aAmount) { - return ItemUtils.simpleMetaStack(AgriculturalChem.mAgrichemItem1, 14, aAmount); - } - - /** - * Iron + Copper Catalyst - * @param aAmount - Stacksize - * @return - A Catalyst stack of given size - */ - public static ItemStack getRedCatalyst(int aAmount) { - return ItemUtils.simpleMetaStack(GenericChem.mGenericChemItem1, 0, aAmount); - } - - /** - * Tungsten + Nickel Catalyst - * @param aAmount - Stacksize - * @return - A Catalyst stack of given size - */ - public static ItemStack getYellowCatalyst(int aAmount) { - return ItemUtils.simpleMetaStack(GenericChem.mGenericChemItem1, 1, aAmount); - } - - /** - * Cobalt + Titanium Catalyst - * @param aAmount - Stacksize - * @return - A Catalyst stack of given size - */ - public static ItemStack getBlueCatalyst(int aAmount) { - return ItemUtils.simpleMetaStack(GenericChem.mGenericChemItem1, 2, aAmount); - } - - /** - * Vanadium + Palladium Catalyst - * @param aAmount - Stacksize - * @return - A Catalyst stack of given size - */ - public static ItemStack getOrangeCatalyst(int aAmount) { - return ItemUtils.simpleMetaStack(GenericChem.mGenericChemItem1, 3, aAmount); - } - - /** - * Iridium + Ruthenium Catalyst - * @param aAmount - Stacksize - * @return - A Catalyst stack of given size - */ - public static ItemStack getPurpleCatalyst(int aAmount) { - return ItemUtils.simpleMetaStack(GenericChem.mGenericChemItem1, 4, aAmount); - } - - /** - * Aluminium + Nickel Catalyst - * @param aAmount - Stacksize - * @return - A Catalyst stack of given size - */ - public static ItemStack getBrownCatalyst(int aAmount) { - return ItemUtils.simpleMetaStack(GenericChem.mGenericChemItem1, 5, aAmount); - } - - /** - * Platinum + Rhodium Catalyst - * @param aAmount - Stacksize - * @return - A Catalyst stack of given size - */ - public static ItemStack getPinkCatalyst(int aAmount) { - return ItemUtils.simpleMetaStack(GenericChem.mGenericChemItem1, 6, aAmount); - } - + // null + public static ItemStack _NULL = ItemUtils.getErrorStack(1); + + // bits + public static long bits = GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE + | GT_ModHandler.RecipeBits.BUFFERED; + public static long bitsd = GT_ModHandler.RecipeBits.DISMANTLEABLE + | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE + | GT_ModHandler.RecipeBits.BUFFERED; + + // Circuits + public static Object circuitPrimitive; + public static Object circuitTier1; + public static Object circuitTier2; + public static Object circuitTier3; + public static Object circuitTier4; + public static Object circuitTier5; + public static Object circuitTier6; + public static Object circuitTier7; + public static Object circuitTier8; + public static Object circuitTier9; + + // Machine Components + public static ItemStack electricMotor_ULV; + public static ItemStack electricMotor_LV; + public static ItemStack electricMotor_MV; + public static ItemStack electricMotor_HV; + public static ItemStack electricMotor_EV; + public static ItemStack electricMotor_IV; + public static ItemStack electricMotor_LuV; + public static ItemStack electricMotor_ZPM; + public static ItemStack electricMotor_UV; + public static ItemStack electricMotor_MAX; + public static ItemStack electricPump_ULV; + public static ItemStack electricPump_LV; + public static ItemStack electricPump_MV; + public static ItemStack electricPump_HV; + public static ItemStack electricPump_EV; + public static ItemStack electricPump_IV; + public static ItemStack electricPump_LuV; + public static ItemStack electricPump_ZPM; + public static ItemStack electricPump_UV; + public static ItemStack electricPump_MAX; + public static ItemStack electricPiston_ULV; + public static ItemStack electricPiston_LV; + public static ItemStack electricPiston_MV; + public static ItemStack electricPiston_HV; + public static ItemStack electricPiston_EV; + public static ItemStack electricPiston_IV; + public static ItemStack electricPiston_LuV; + public static ItemStack electricPiston_ZPM; + public static ItemStack electricPiston_UV; + public static ItemStack electricPiston_MAX; + public static ItemStack robotArm_ULV; + public static ItemStack robotArm_LV; + public static ItemStack robotArm_MV; + public static ItemStack robotArm_HV; + public static ItemStack robotArm_EV; + public static ItemStack robotArm_IV; + public static ItemStack robotArm_LuV; + public static ItemStack robotArm_ZPM; + public static ItemStack robotArm_UV; + public static ItemStack robotArm_MAX; + public static ItemStack conveyorModule_ULV; + public static ItemStack conveyorModule_LV; + public static ItemStack conveyorModule_MV; + public static ItemStack conveyorModule_HV; + public static ItemStack conveyorModule_EV; + public static ItemStack conveyorModule_IV; + public static ItemStack conveyorModule_LuV; + public static ItemStack conveyorModule_ZPM; + public static ItemStack conveyorModule_UV; + public static ItemStack conveyorModule_MAX; + public static ItemStack emitter_ULV; + public static ItemStack emitter_LV; + public static ItemStack emitter_MV; + public static ItemStack emitter_HV; + public static ItemStack emitter_EV; + public static ItemStack emitter_IV; + public static ItemStack emitter_LuV; + public static ItemStack emitter_ZPM; + public static ItemStack emitter_UV; + public static ItemStack emitter_MAX; + public static ItemStack fieldGenerator_ULV; + public static ItemStack fieldGenerator_LV; + public static ItemStack fieldGenerator_MV; + public static ItemStack fieldGenerator_HV; + public static ItemStack fieldGenerator_EV; + public static ItemStack fieldGenerator_IV; + public static ItemStack fieldGenerator_LuV; + public static ItemStack fieldGenerator_ZPM; + public static ItemStack fieldGenerator_UV; + public static ItemStack fieldGenerator_MAX; + public static ItemStack sensor_ULV; + public static ItemStack sensor_LV; + public static ItemStack sensor_MV; + public static ItemStack sensor_HV; + public static ItemStack sensor_EV; + public static ItemStack sensor_IV; + public static ItemStack sensor_LuV; + public static ItemStack sensor_ZPM; + public static ItemStack sensor_UV; + public static ItemStack sensor_MAX; + + public static ItemStack fluidRegulator_LV; + public static ItemStack fluidRegulator_MV; + public static ItemStack fluidRegulator_HV; + public static ItemStack fluidRegulator_EV; + public static ItemStack fluidRegulator_IV; + public static ItemStack fluidRegulator_LuV; + public static ItemStack fluidRegulator_ZPM; + public static ItemStack fluidRegulator_UV; + + // Machine Casings + public static ItemStack machineCasing_ULV; + public static ItemStack machineCasing_LV; + public static ItemStack machineCasing_MV; + public static ItemStack machineCasing_HV; + public static ItemStack machineCasing_EV; + public static ItemStack machineCasing_IV; + public static ItemStack machineCasing_LuV; + public static ItemStack machineCasing_ZPM; + public static ItemStack machineCasing_UV; + public static ItemStack machineCasing_MAX; + + // Machine Hulls + public static ItemStack machineHull_ULV; + public static ItemStack machineHull_LV; + public static ItemStack machineHull_MV; + public static ItemStack machineHull_HV; + public static ItemStack machineHull_EV; + public static ItemStack machineHull_IV; + public static ItemStack machineHull_LuV; + public static ItemStack machineHull_ZPM; + public static ItemStack machineHull_UV; + public static ItemStack machineHull_MAX; + + // Gearbox Casings + public static ItemStack gearboxCasing_Tier_1; + public static ItemStack gearboxCasing_Tier_2; + public static ItemStack gearboxCasing_Tier_3; + public static ItemStack gearboxCasing_Tier_4; + + public static String[] component_Plate; + public static String[] component_Rod; + public static String[] component_Ingot; + + // Crafting Tools + public static String craftingToolWrench = "craftingToolWrench"; + public static String craftingToolHammer_Hard = "craftingToolHardHammer"; + public static String craftingToolHammer_Soft = "craftingToolSoftHammer"; + public static String craftingToolScrewdriver = "craftingToolScrewdriver"; + public static String craftingToolFile = "craftingToolFile"; + public static String craftingToolMortar = "craftingToolMortar"; + public static String craftingToolKnife = "craftingToolKnife"; + public static String craftingToolCrowbar = "craftingToolCrowbar"; + public static String craftingToolSaw = "craftingToolSaw"; + public static String craftingToolWireCutter = "craftingToolWirecutter"; + public static String craftingToolSolderingIron = "craftingToolSolderingIron"; + + // Explosives + public static ItemStack explosivePowderKeg; + public static ItemStack explosiveTNT; + public static ItemStack explosiveITNT; + + public static Materials[] tieredMaterials = new Materials[] { + Materials.Iron, Materials.Steel, Materials.Aluminium, + Materials.StainlessSteel, Materials.Titanium, Materials.TungstenSteel, + Materials.Chrome, Materials.Iridium, Materials.Osmium, + Materials.Neutronium + }; + ; + + public static void preInit() { + + // Tiered Components + component_Plate = new String[] { + getTieredComponent(OrePrefixes.plate, 0), + getTieredComponent(OrePrefixes.plate, 1), + getTieredComponent(OrePrefixes.plate, 2), + getTieredComponent(OrePrefixes.plate, 3), + getTieredComponent(OrePrefixes.plate, 4), + getTieredComponent(OrePrefixes.plate, 5), + getTieredComponent(OrePrefixes.plate, 6), + getTieredComponent(OrePrefixes.plate, 7), + getTieredComponent(OrePrefixes.plate, 8), + getTieredComponent(OrePrefixes.plate, 9), + getTieredComponent(OrePrefixes.plate, 10), + getTieredComponent(OrePrefixes.plate, 11) + }; + component_Rod = new String[] { + getTieredComponent(OrePrefixes.stick, 0), + getTieredComponent(OrePrefixes.stick, 1), + getTieredComponent(OrePrefixes.stick, 2), + getTieredComponent(OrePrefixes.stick, 3), + getTieredComponent(OrePrefixes.stick, 4), + getTieredComponent(OrePrefixes.stick, 5), + getTieredComponent(OrePrefixes.stick, 6), + getTieredComponent(OrePrefixes.stick, 7), + getTieredComponent(OrePrefixes.stick, 8), + getTieredComponent(OrePrefixes.stick, 9), + getTieredComponent(OrePrefixes.stick, 10), + getTieredComponent(OrePrefixes.stick, 11) + }; + component_Ingot = new String[] { + getTieredComponent(OrePrefixes.ingot, 0), + getTieredComponent(OrePrefixes.ingot, 1), + getTieredComponent(OrePrefixes.ingot, 2), + getTieredComponent(OrePrefixes.ingot, 3), + getTieredComponent(OrePrefixes.ingot, 4), + getTieredComponent(OrePrefixes.ingot, 5), + getTieredComponent(OrePrefixes.ingot, 6), + getTieredComponent(OrePrefixes.ingot, 7), + getTieredComponent(OrePrefixes.ingot, 8), + getTieredComponent(OrePrefixes.ingot, 9), + getTieredComponent(OrePrefixes.ingot, 10), + getTieredComponent(OrePrefixes.ingot, 11) + }; + + // Circuits + circuitPrimitive = getTieredCircuit(0); + circuitTier1 = getTieredCircuit(1); + circuitTier2 = getTieredCircuit(2); + circuitTier3 = getTieredCircuit(3); + circuitTier4 = getTieredCircuit(4); + circuitTier5 = getTieredCircuit(5); + circuitTier6 = getTieredCircuit(6); + circuitTier7 = getTieredCircuit(7); + circuitTier8 = getTieredCircuit(8); + circuitTier9 = getTieredCircuit(9); + } + + public static Object getTieredCircuit(int tier) { + if (CORE.ConfigSwitches.enableOldGTcircuits && CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && !CORE.GTNH) { + if (tier == 0) { + return GregtechItemList.Old_Circuit_Primitive.get(1); + } else if (tier == 1) { + return GregtechItemList.Old_Circuit_Basic.get(1); + } else if (tier == 2) { + return GregtechItemList.Old_Circuit_Good.get(1); + } else if (tier == 3) { + return GregtechItemList.Old_Circuit_Advanced.get(1); + } else if (tier == 4) { + return GregtechItemList.Old_Circuit_Data.get(1); + } else if (tier == 5) { + return GregtechItemList.Old_Circuit_Elite.get(1); + } else if (tier == 6) { + return GregtechItemList.Old_Circuit_Master.get(1); + } else if (tier == 7) { + return GregtechItemList.Old_Circuit_Ultimate.get(1); + } else if (tier == 8) { + return GregtechItemList.Circuit_IV.get(1); + } else if (tier == 9) { + return GregtechItemList.Circuit_LuV.get(1); + } else if (tier == 10) { + return GregtechItemList.Circuit_ZPM.get(1); + } + } else { + return getTieredCircuitOreDictName(tier); + } + return _NULL; + } + + public static ItemStack[] getAllCircuitsOfTier(int tier) { + return ItemUtils.getStackOfAllOreDictGroup(getTieredCircuitOreDictName(tier)); + } + + public static String getTieredCircuitOreDictName(int tier) { + if (tier == 0) { + return "circuitPrimitive"; + } else if (tier == 1) { + return "circuitBasic"; + } else if (tier == 2) { + return "circuitGood"; + } else if (tier == 3) { + return "circuitAdvanced"; + } else if (tier == 4) { + return "circuitData"; + } else if (tier == 5) { + return "circuitElite"; + } else if (tier == 6) { + return "circuitMaster"; + } else if (tier == 7) { + return "circuitUltimate"; + } else if (tier == 8) { + return "circuitSuperconductor"; + } else if (tier == 9) { + return "circuitInfinite"; + } else if (tier == 10) { + return "circuitQuantum"; + } else { + return "circuitPrimitive"; + } + } + + public static ItemStack getNumberedCircuit(int Meta) { + return ItemUtils.getGregtechCircuit(Meta); + } + + private static Object getMaterialFromTier(int tier) { + if (tier == 0) { + return Materials.Wood; + } else if (tier == 1) { + return Materials.Lead; + } else if (tier == 2) { + return Materials.Bronze; + } else if (tier == 3) { + return Materials.Steel; + } else if (tier == 4) { + return ALLOY.EGLIN_STEEL; + } else if (tier == 5) { + return Materials.Aluminium; + } else if (tier == 6) { + return ALLOY.MARAGING250; + } else if (tier == 7) { + return ALLOY.TANTALLOY_61; + } else if (tier == 8) { + return ALLOY.INCONEL_792; + } else if (tier == 9) { + return ALLOY.ZERON_100; + } else if (tier == 10) { + return Materials.NaquadahEnriched; + } else if (tier == 11) { + return Materials.Neutronium; + } + return Materials._NULL; + } + + @Deprecated + public static String getTieredComponent(OrePrefixes type, int tier) { + Object material = getMaterialFromTier(tier); + if (material != null) { + if (material instanceof Materials) { + // return (ItemStack) type.get(material); + String materialName = ((Materials) material).mDefaultLocalName; + Logger.INFO("Searching for a component named " + type.name() + materialName); + // return ItemUtils.getItemStackOfAmountFromOreDict(type.name()+materialName, 1); + return (type.name() + materialName); + } else { + String materialName = (Utils.sanitizeString(((Material) material).getLocalizedName())); + Logger.INFO("Searching for a component named " + type.name() + materialName); + // return ItemUtils.getItemStackOfAmountFromOreDict(type.name()+materialName, 1); + return (type.name() + materialName); + } + } + Logger.INFO("[Components] Failed getting a tiered component. " + type.name() + " | " + tier); + return null; + } + + public static ItemStack getDataOrb() { + if (CORE.ConfigSwitches.enableOldGTcircuits && CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && !CORE.GTNH) { + return GregtechItemList.Old_Tool_DataOrb.get(1); + } else { + return ItemList.Tool_DataOrb.get(1); + } + } + + public static ItemStack getDataStick() { + if (CORE.ConfigSwitches.enableOldGTcircuits && CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && !CORE.GTNH) { + return GregtechItemList.Old_Tool_DataStick.get(1); + } else { + return ItemList.Tool_DataStick.get(1); + } + } + + public static final ItemStack getTieredMachineHull(int tier) { + if (tier == 0) { + return machineHull_ULV; + } else if (tier == 1) { + return machineHull_LV; + } else if (tier == 2) { + return machineHull_MV; + } else if (tier == 3) { + return machineHull_HV; + } else if (tier == 4) { + return machineHull_EV; + } else if (tier == 5) { + return machineHull_IV; + } else if (tier == 6) { + return machineHull_LuV; + } else if (tier == 7) { + return machineHull_ZPM; + } else if (tier == 8) { + return machineHull_UV; + } else if (tier == 9) { + return machineHull_MAX; + } else { + return GregtechItemList.Casing_Multi_Use.get(1); + } + } + + public static final ItemStack getTieredMachineCasing(int tier) { + if (tier == 0) { + if (machineCasing_ULV == null) { + machineCasing_ULV = ItemList.Casing_ULV.get(1); + } + return machineCasing_ULV; + } else if (tier == 1) { + return machineCasing_LV; + } else if (tier == 2) { + return machineCasing_MV; + } else if (tier == 3) { + return machineCasing_HV; + } else if (tier == 4) { + return machineCasing_EV; + } else if (tier == 5) { + return machineCasing_IV; + } else if (tier == 6) { + return machineCasing_LuV; + } else if (tier == 7) { + return machineCasing_ZPM; + } else if (tier == 8) { + return machineCasing_UV; + } else if (tier == 9) { + return machineCasing_MAX; + } else { + return GregtechItemList.Casing_Multi_Use.get(1); + } + } + + public static void init() { + // Set Explosives + explosivePowderKeg = + ItemUtils.getValueOfItemList("Block_Powderbarrel", 1, ItemUtils.getSimpleStack(Items.gunpowder, 16)); + explosiveTNT = ItemUtils.getSimpleStack(Blocks.tnt).copy(); + explosiveITNT = Ic2Items.industrialTnt.copy(); + + // Machine Casings + machineCasing_ULV = ItemList.Casing_ULV.get(1); + machineCasing_LV = ItemList.Casing_LV.get(1); + machineCasing_MV = ItemList.Casing_MV.get(1); + machineCasing_HV = ItemList.Casing_HV.get(1); + machineCasing_EV = ItemList.Casing_EV.get(1); + machineCasing_IV = ItemList.Casing_IV.get(1); + machineCasing_LuV = ItemList.Casing_LuV.get(1); + machineCasing_ZPM = ItemList.Casing_ZPM.get(1); + machineCasing_UV = ItemList.Casing_UV.get(1); + machineCasing_MAX = ItemList.Casing_MAX.get(1); + + // Machine Hulls + machineHull_ULV = ItemList.Hull_ULV.get(1); + machineHull_LV = ItemList.Hull_LV.get(1); + machineHull_MV = ItemList.Hull_MV.get(1); + machineHull_HV = ItemList.Hull_HV.get(1); + machineHull_EV = ItemList.Hull_EV.get(1); + machineHull_IV = ItemList.Hull_IV.get(1); + machineHull_LuV = ItemList.Hull_LuV.get(1); + machineHull_ZPM = ItemList.Hull_ZPM.get(1); + machineHull_UV = ItemList.Hull_UV.get(1); + machineHull_MAX = ItemList.Hull_MAX.get(1); + + // Gear box Casings + gearboxCasing_Tier_1 = ItemList.Casing_Gearbox_Bronze.get(1); + gearboxCasing_Tier_2 = ItemList.Casing_Gearbox_Steel.get(1); + gearboxCasing_Tier_3 = ItemList.Casing_Gearbox_Titanium.get(1); + gearboxCasing_Tier_4 = ItemList.Casing_Gearbox_TungstenSteel.get(1); + + // Machine Components + LOADER_Machine_Components.initialise(); + } + + public static ItemStack emptyCells(int i) { + return ItemUtils.getEmptyCell(i); + } + + private static final Material[] aMaterial_Main = new Material[] { + ALLOY.POTIN, + ALLOY.TUMBAGA, + ALLOY.EGLIN_STEEL, + ALLOY.INCONEL_792, + ALLOY.INCOLOY_MA956, + ALLOY.NITINOL_60, + ALLOY.ZERON_100, + ALLOY.PIKYONIUM, + ELEMENT.STANDALONE.ADVANCED_NITINOL, + ALLOY.ABYSSAL, + ALLOY.QUANTUM, + ELEMENT.STANDALONE.HYPOGEN + }; + + private static final Material[] aMaterial_Secondary = new Material[] { + ALLOY.STEEL, + ALLOY.SILICON_CARBIDE, + ALLOY.BABBIT_ALLOY, + ALLOY.INCONEL_690, + ALLOY.STELLITE, + ALLOY.ARCANITE, + ALLOY.LAFIUM, + ALLOY.CINOBITE, + ALLOY.TITANSTEEL, + ALLOY.OCTIRON, + ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN, + ELEMENT.STANDALONE.HYPOGEN + }; + + private static final Material[] aMaterial_Tertiary = new Material[] { + ELEMENT.getInstance().LEAD, + ELEMENT.getInstance().ALUMINIUM, + ELEMENT.STANDALONE.BLACK_METAL, + ELEMENT.getInstance().TITANIUM, + ALLOY.HASTELLOY_N, + ALLOY.ENERGYCRYSTAL, + ALLOY.TRINIUM_NAQUADAH_CARBON, + ALLOY.TRINIUM_REINFORCED_STEEL, // Arceus + ALLOY.TITANSTEEL, + ELEMENT.STANDALONE.ASTRAL_TITANIUM, + ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN, + ELEMENT.STANDALONE.HYPOGEN + }; + + private static final Materials[] aMaterial_Cables = new Materials[] { + !CORE.GTNH ? Materials.Lead : Materials.Tin, + Materials.Cobalt, + Materials.AnnealedCopper, + Materials.Gold, + Materials.Titanium, + Materials.Nichrome, + Materials.Platinum, + Materials.YttriumBariumCuprate, + Materials.Naquadah, + Materials.Duranium, + Materials.Superconductor, + }; + + private static final Materials[] aMaterial_Circuits = new Materials[] { + Materials.Primitive, + Materials.Basic, + Materials.Good, + Materials.Advanced, + Materials.Data, + Materials.Data, + Materials.Elite, + Materials.Master, + Materials.Ultimate, + Materials.Superconductor, + Materials.Infinite, + }; + + private static final Material[][] aMaster = + new Material[][] {aMaterial_Main, aMaterial_Secondary, aMaterial_Tertiary}; + + public static FluidStack getTieredFluid(int aTier, int aAmount) { + return getTieredFluid(aTier, aAmount, 0); + } + + public static FluidStack getAlternativeTieredFluid(int aTier, int aAmount) { + return getTieredFluid(aTier, aAmount, 1); + } + + public static FluidStack getTertiaryTieredFluid(int aTier, int aAmount) { + return getTieredFluid(aTier, aAmount, 2); + } + + public static FluidStack getTieredFluid(int aTier, int aAmount, int aType) { + // Weird Legacy handling + /*ItemStack aCell = getTieredComponent(OrePrefixes.liquid, aTier, 1); + FluidStack a = GT_Utility.getFluidForFilledItem(aCell, true); + if (a == null) { + a = aMaster[aType][aTier].getFluid(aAmount); + }*/ + + // Modern Handling + FluidStack a = aMaster[aType][aTier].getFluidStack(aAmount); + if (a == null) { + ItemStack aCell = getTieredComponent(OrePrefixes.liquid, aTier, 1); + if (aCell != null) { + a = GT_Utility.getFluidForFilledItem(aCell, true); + a.amount = aAmount; + } + } + return a; + } + + public static ItemStack getEnergyCore(int aTier, int aAmount) { + ItemStack[] aOutput = new ItemStack[] { + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "1", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "2", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "3", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "4", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "5", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "6", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "7", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "8", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "9", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore" + "10", 1) + }; + return ItemUtils.getSimpleStack(aOutput[MathUtils.balance(aTier, 0, 9)], aAmount); + } + + public static ItemStack getPlate(int aTier, int aAmount) { + return getTieredComponent(OrePrefixes.plate, aTier, aAmount); + } + + public static ItemStack getDoublePlate(int aTier, int aAmount) { + return getTieredComponent(OrePrefixes.plateDouble, aTier, aAmount); + } + + public static ItemStack getGear(int aTier, int aAmount) { + return getTieredComponent(OrePrefixes.gearGt, aTier, aAmount); + } + + public static ItemStack getIngot(int aTier, int aAmount) { + return getTieredComponent(OrePrefixes.ingot, aTier, aAmount); + } + + public static ItemStack getBolt(int aTier, int aAmount) { + return getTieredComponent(OrePrefixes.bolt, aTier, aAmount); + } + + public static ItemStack getScrew(int aTier, int aAmount) { + return getTieredComponent(OrePrefixes.screw, aTier, aAmount); + } + + public static ItemStack getCircuit(int aTier, int aAmount) { + return getTieredComponent(OrePrefixes.circuit, aTier, aAmount); + } + + public static ItemStack getTieredComponent(OrePrefixes aPrefix, int aTier, int aAmount) { + aTier = Math.max(0, aTier); + + Material m = null; + + if (aPrefix == OrePrefixes.liquid) { + int aMatID = (aTier == 0 || aTier == 2 || aTier == 5 || aTier == 8 + ? 0 + : (aTier == 1 || aTier == 3 || aTier == 6 || aTier == 9 ? 1 : 2)); + ItemStack aCell = aMaster[aMatID][aTier].getCell(aAmount); + return aCell; + } + + if (aPrefix == OrePrefixes.circuit) { + /*if (aTier == 4) { + return ItemUtils.getSimpleStack(CI.getDataStick(), aAmount); + } + else if (aTier == 5) { + return ItemUtils.getSimpleStack(CI.getDataOrb(), aAmount); + }*/ + return ItemUtils.getOrePrefixStack(OrePrefixes.circuit, aMaterial_Circuits[aTier], aAmount); + } + + // Check for Cables first, catch SuperConductor case and swap to wire. + if (aPrefix == OrePrefixes.cableGt01 + || aPrefix == OrePrefixes.cableGt02 + || aPrefix == OrePrefixes.cableGt04 + || aPrefix == OrePrefixes.cableGt08 + || aPrefix == OrePrefixes.cableGt12) { + // Special Handler + if (aTier == 10) { + if (aPrefix == OrePrefixes.cableGt01) { + aPrefix = OrePrefixes.wireGt02; + } else if (aPrefix == OrePrefixes.cableGt02) { + aPrefix = OrePrefixes.wireGt04; + } else if (aPrefix == OrePrefixes.cableGt04) { + aPrefix = OrePrefixes.wireGt08; + } else if (aPrefix == OrePrefixes.cableGt08) { + aPrefix = OrePrefixes.wireGt12; + } else if (aPrefix == OrePrefixes.cableGt12) { + aPrefix = OrePrefixes.wireGt16; + } + } else { + return ItemUtils.getOrePrefixStack(aPrefix, aMaterial_Cables[aTier], aAmount); + } + } + if (aPrefix == OrePrefixes.wireGt01 + || aPrefix == OrePrefixes.wireGt02 + || aPrefix == OrePrefixes.wireGt04 + || aPrefix == OrePrefixes.wireGt08 + || aPrefix == OrePrefixes.wireGt12 + || aPrefix == OrePrefixes.wireGt16) { + return ItemUtils.getOrePrefixStack(aPrefix, aMaterial_Cables[aTier], aAmount); + } + + if (aPrefix == OrePrefixes.pipeTiny + || aPrefix == OrePrefixes.pipeSmall + || aPrefix == OrePrefixes.pipe + || aPrefix == OrePrefixes.pipeMedium + || aPrefix == OrePrefixes.pipeLarge + || aPrefix == OrePrefixes.pipeHuge) { + + if (aPrefix == OrePrefixes.pipe) { + aPrefix = OrePrefixes.pipeMedium; + } + + if (aTier == 0) { + return ItemUtils.getOrePrefixStack(aPrefix, Materials.Lead, aAmount); + } else if (aTier == 1) { + return ItemUtils.getOrePrefixStack(aPrefix, Materials.Steel, aAmount); + } else if (aTier == 2) { + return ItemUtils.getOrePrefixStack(aPrefix, Materials.StainlessSteel, aAmount); + } else if (aTier == 3) { + return ItemUtils.getOrePrefixStack(aPrefix, Materials.Tungsten, aAmount); + } else if (aTier == 4) { + return ItemUtils.getOrePrefixStack(aPrefix, Materials.TungstenSteel, aAmount); + } else if (aTier == 5) { + return ItemUtils.getOrePrefixStack(aPrefix, ALLOY.MARAGING350, aAmount); + } else if (aTier == 6) { + return ItemUtils.getOrePrefixStack(aPrefix, ALLOY.STABALLOY, aAmount); + } else if (aTier == 7) { + return ItemUtils.getOrePrefixStack(aPrefix, ALLOY.HASTELLOY_X, aAmount); + } else if (aTier == 8) { + return ItemUtils.getOrePrefixStack(aPrefix, Materials.Ultimate, aAmount); + } else if (aTier == 9) { + return ItemUtils.getOrePrefixStack(OrePrefixes.pipeMedium, Materials.Superconductor, aAmount); + } else if (aTier == 10) { + return ItemUtils.getOrePrefixStack(aPrefix, Materials.Europium, aAmount); + } else { + return ItemUtils.getOrePrefixStack(aPrefix, Materials.Titanium, aAmount); + } + } + + if (aPrefix == OrePrefixes.rod) { + aPrefix = OrePrefixes.stick; + } + + if (aPrefix == OrePrefixes.gear || aPrefix == OrePrefixes.gearGt) { + m = aMaster[0][aTier]; + } else if (aPrefix == OrePrefixes.rod || aPrefix == OrePrefixes.stick) { + m = aMaster[0][aTier]; + } else if (aPrefix == OrePrefixes.stickLong) { + m = aMaster[1][aTier]; + } else if (aPrefix == OrePrefixes.bolt) { + m = aMaster[2][aTier]; + } else if (aPrefix == OrePrefixes.screw) { + m = aMaster[0][aTier]; + } else if (aPrefix == OrePrefixes.rotor) { + m = aMaster[1][aTier]; + } else if (aPrefix == OrePrefixes.frame || aPrefix == OrePrefixes.frameGt) { + m = aMaster[2][aTier]; + } else if (aPrefix == OrePrefixes.ingot) { + m = aMaster[1][aTier]; + } else if (aPrefix == OrePrefixes.plate) { + m = aMaster[0][aTier]; + } else if (aPrefix == OrePrefixes.plateDouble) { + m = aMaster[0][aTier]; + } else if (aPrefix == OrePrefixes.ring) { + m = aMaster[2][aTier]; + } else if (aPrefix == OrePrefixes.cell) { + m = aMaster[1][aTier]; + } else { + m = aMaterial_Main[aTier]; + } + + ItemStack aReturn = ItemUtils.getOrePrefixStack(aPrefix, m, aAmount); + + // If Invalid, Try First Material + if (!ItemUtils.checkForInvalidItems(aReturn)) { + m = aMaster[0][aTier]; + aReturn = ItemUtils.getOrePrefixStack(aPrefix, m, aAmount); + + // If Invalid, Try Second Material + if (!ItemUtils.checkForInvalidItems(aReturn)) { + m = aMaster[1][aTier]; + aReturn = ItemUtils.getOrePrefixStack(aPrefix, m, aAmount); + + // If Invalid, Try Third Material + if (!ItemUtils.checkForInvalidItems(aReturn)) { + m = aMaster[2][aTier]; + aReturn = ItemUtils.getOrePrefixStack(aPrefix, m, aAmount); + + // All Invalid? Ok, shit. + // Let's add a special error ingot. + if (!ItemUtils.checkForInvalidItems(aReturn)) { + aReturn = ItemUtils.getErrorStack( + 1, (aPrefix.toString() + m.getLocalizedName() + " x" + aAmount)); + } + } + } + } + + return aReturn; + } + + public static ItemStack getElectricMotor(int aTier, int aSize) { + ItemStack aType; + int aLazyTier = 0; + if (aTier == aLazyTier++) { + aType = CI.electricMotor_ULV; + } else if (aTier == aLazyTier++) { + aType = CI.electricMotor_LV; + } else if (aTier == aLazyTier++) { + aType = CI.electricMotor_MV; + } else if (aTier == aLazyTier++) { + aType = CI.electricMotor_HV; + } else if (aTier == aLazyTier++) { + aType = CI.electricMotor_EV; + } else if (aTier == aLazyTier++) { + aType = CI.electricMotor_IV; + } else if (aTier == aLazyTier++) { + aType = CI.electricMotor_LuV; + } else if (aTier == aLazyTier++) { + aType = CI.electricMotor_ZPM; + } else if (aTier == aLazyTier++) { + aType = CI.electricMotor_UV; + } else if (aTier == aLazyTier++) { + aType = CI.electricMotor_MAX; + } else { + aType = CI.electricMotor_LV; + } + return ItemUtils.getSimpleStack(aType, aSize); + } + + public static ItemStack getFluidRegulator(int aTier, int aSize) { + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + return CI.getElectricPump(aTier, aSize); + } + ItemStack aType; + int aLazyTier = 0; + if (aTier == aLazyTier++) { + aType = CI.fluidRegulator_LV; + } else if (aTier == aLazyTier++) { + aType = CI.fluidRegulator_LV; + } else if (aTier == aLazyTier++) { + aType = CI.fluidRegulator_MV; + } else if (aTier == aLazyTier++) { + aType = CI.fluidRegulator_HV; + } else if (aTier == aLazyTier++) { + aType = CI.fluidRegulator_EV; + } else if (aTier == aLazyTier++) { + aType = CI.fluidRegulator_IV; + } else if (aTier == aLazyTier++) { + aType = CI.fluidRegulator_LuV; + } else if (aTier == aLazyTier++) { + aType = CI.fluidRegulator_ZPM; + } else if (aTier == aLazyTier++) { + aType = CI.fluidRegulator_UV; + } else if (aTier == aLazyTier++) { + aType = CI.fluidRegulator_UV; + } else { + aType = CI.fluidRegulator_LV; + } + return ItemUtils.getSimpleStack(aType, aSize); + } + + public static ItemStack getElectricPiston(int aTier, int aSize) { + ItemStack aType; + int aLazyTier = 0; + if (aTier == aLazyTier++) { + aType = CI.electricPiston_ULV; + } else if (aTier == aLazyTier++) { + aType = CI.electricPiston_LV; + } else if (aTier == aLazyTier++) { + aType = CI.electricPiston_MV; + } else if (aTier == aLazyTier++) { + aType = CI.electricPiston_HV; + } else if (aTier == aLazyTier++) { + aType = CI.electricPiston_EV; + } else if (aTier == aLazyTier++) { + aType = CI.electricPiston_IV; + } else if (aTier == aLazyTier++) { + aType = CI.electricPiston_LuV; + } else if (aTier == aLazyTier++) { + aType = CI.electricPiston_ZPM; + } else if (aTier == aLazyTier++) { + aType = CI.electricPiston_UV; + } else if (aTier == aLazyTier++) { + aType = CI.electricPiston_MAX; + } else { + aType = CI.electricPiston_LV; + } + return ItemUtils.getSimpleStack(aType, aSize); + } + + public static ItemStack getElectricPump(int aTier, int aSize) { + ItemStack aType; + int aLazyTier = 0; + if (aTier == aLazyTier++) { + aType = CI.electricPump_ULV; + } else if (aTier == aLazyTier++) { + aType = CI.electricPump_LV; + } else if (aTier == aLazyTier++) { + aType = CI.electricPump_MV; + } else if (aTier == aLazyTier++) { + aType = CI.electricPump_HV; + } else if (aTier == aLazyTier++) { + aType = CI.electricPump_EV; + } else if (aTier == aLazyTier++) { + aType = CI.electricPump_IV; + } else if (aTier == aLazyTier++) { + aType = CI.electricPump_LuV; + } else if (aTier == aLazyTier++) { + aType = CI.electricPump_ZPM; + } else if (aTier == aLazyTier++) { + aType = CI.electricPump_UV; + } else if (aTier == aLazyTier++) { + aType = CI.electricPump_MAX; + } else { + aType = CI.electricPump_LV; + } + return ItemUtils.getSimpleStack(aType, aSize); + } + + public static ItemStack getRobotArm(int aTier, int aSize) { + ItemStack aType; + int aLazyTier = 0; + if (aTier == aLazyTier++) { + aType = CI.robotArm_ULV; + } else if (aTier == aLazyTier++) { + aType = CI.robotArm_LV; + } else if (aTier == aLazyTier++) { + aType = CI.robotArm_MV; + } else if (aTier == aLazyTier++) { + aType = CI.robotArm_HV; + } else if (aTier == aLazyTier++) { + aType = CI.robotArm_EV; + } else if (aTier == aLazyTier++) { + aType = CI.robotArm_IV; + } else if (aTier == aLazyTier++) { + aType = CI.robotArm_LuV; + } else if (aTier == aLazyTier++) { + aType = CI.robotArm_ZPM; + } else if (aTier == aLazyTier++) { + aType = CI.robotArm_UV; + } else if (aTier == aLazyTier++) { + aType = CI.robotArm_MAX; + } else { + aType = CI.robotArm_LV; + } + return ItemUtils.getSimpleStack(aType, aSize); + } + + public static ItemStack getConveyor(int aTier, int aSize) { + ItemStack aType; + int aLazyTier = 0; + if (aTier == aLazyTier++) { + aType = CI.conveyorModule_ULV; + } else if (aTier == aLazyTier++) { + aType = CI.conveyorModule_LV; + } else if (aTier == aLazyTier++) { + aType = CI.conveyorModule_MV; + } else if (aTier == aLazyTier++) { + aType = CI.conveyorModule_HV; + } else if (aTier == aLazyTier++) { + aType = CI.conveyorModule_EV; + } else if (aTier == aLazyTier++) { + aType = CI.conveyorModule_IV; + } else if (aTier == aLazyTier++) { + aType = CI.conveyorModule_LuV; + } else if (aTier == aLazyTier++) { + aType = CI.conveyorModule_ZPM; + } else if (aTier == aLazyTier++) { + aType = CI.conveyorModule_UV; + } else if (aTier == aLazyTier++) { + aType = CI.conveyorModule_MAX; + } else { + aType = CI.conveyorModule_LV; + } + return ItemUtils.getSimpleStack(aType, aSize); + } + + public static ItemStack getEmitter(int aTier, int aSize) { + ItemStack aType; + int aLazyTier = 0; + if (aTier == aLazyTier++) { + aType = CI.emitter_ULV; + } else if (aTier == aLazyTier++) { + aType = CI.emitter_LV; + } else if (aTier == aLazyTier++) { + aType = CI.emitter_MV; + } else if (aTier == aLazyTier++) { + aType = CI.emitter_HV; + } else if (aTier == aLazyTier++) { + aType = CI.emitter_EV; + } else if (aTier == aLazyTier++) { + aType = CI.emitter_IV; + } else if (aTier == aLazyTier++) { + aType = CI.emitter_LuV; + } else if (aTier == aLazyTier++) { + aType = CI.emitter_ZPM; + } else if (aTier == aLazyTier++) { + aType = CI.emitter_UV; + } else if (aTier == aLazyTier++) { + aType = CI.emitter_MAX; + } else { + aType = CI.emitter_LV; + } + return ItemUtils.getSimpleStack(aType, aSize); + } + + public static ItemStack getSensor(int aTier, int aSize) { + ItemStack aType; + int aLazyTier = 0; + if (aTier == aLazyTier++) { + aType = CI.sensor_ULV; + } else if (aTier == aLazyTier++) { + aType = CI.sensor_LV; + } else if (aTier == aLazyTier++) { + aType = CI.sensor_MV; + } else if (aTier == aLazyTier++) { + aType = CI.sensor_HV; + } else if (aTier == aLazyTier++) { + aType = CI.sensor_EV; + } else if (aTier == aLazyTier++) { + aType = CI.sensor_IV; + } else if (aTier == aLazyTier++) { + aType = CI.sensor_LuV; + } else if (aTier == aLazyTier++) { + aType = CI.sensor_ZPM; + } else if (aTier == aLazyTier++) { + aType = CI.sensor_UV; + } else if (aTier == aLazyTier++) { + aType = CI.sensor_MAX; + } else { + aType = CI.sensor_LV; + } + return ItemUtils.getSimpleStack(aType, aSize); + } + + public static ItemStack getFieldGenerator(int aTier, int aSize) { + ItemStack aType; + int aLazyTier = 0; + if (aTier == aLazyTier++) { + aType = CI.fieldGenerator_ULV; + } else if (aTier == aLazyTier++) { + aType = CI.fieldGenerator_LV; + } else if (aTier == aLazyTier++) { + aType = CI.fieldGenerator_MV; + } else if (aTier == aLazyTier++) { + aType = CI.fieldGenerator_HV; + } else if (aTier == aLazyTier++) { + aType = CI.fieldGenerator_EV; + } else if (aTier == aLazyTier++) { + aType = CI.fieldGenerator_IV; + } else if (aTier == aLazyTier++) { + aType = CI.fieldGenerator_LuV; + } else if (aTier == aLazyTier++) { + aType = CI.fieldGenerator_ZPM; + } else if (aTier == aLazyTier++) { + aType = CI.fieldGenerator_UV; + } else if (aTier == aLazyTier++) { + aType = CI.fieldGenerator_MAX; + } else { + aType = CI.fieldGenerator_LV; + } + return ItemUtils.getSimpleStack(aType, aSize); + } + + public static ItemStack getTieredMachineHull(int aTier, int aSize) { + ItemStack aType; + int aLazyTier = 0; + if (aTier == aLazyTier++) { + aType = CI.machineHull_ULV; + } else if (aTier == aLazyTier++) { + aType = CI.machineHull_LV; + } else if (aTier == aLazyTier++) { + aType = CI.machineHull_MV; + } else if (aTier == aLazyTier++) { + aType = CI.machineHull_HV; + } else if (aTier == aLazyTier++) { + aType = CI.machineHull_EV; + } else if (aTier == aLazyTier++) { + aType = CI.machineHull_IV; + } else if (aTier == aLazyTier++) { + aType = CI.machineHull_LuV; + } else if (aTier == aLazyTier++) { + aType = CI.machineHull_ZPM; + } else if (aTier == aLazyTier++) { + aType = CI.machineHull_UV; + } else if (aTier == aLazyTier++) { + aType = CI.machineHull_MAX; + } else { + aType = GregtechItemList.Casing_Multi_Use.get(1, CI.machineHull_MV); + } + return ItemUtils.getSimpleStack(aType, aSize); + } + + public static ItemStack getHeatCoil(int i) { + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + if (i == 1) { + return ItemList.Casing_Coil_Kanthal.get(1); + } else if (i == 2) { + return ItemList.Casing_Coil_Nichrome.get(1); + } else { + return ItemList.Casing_Coil_Cupronickel.get(1); + } + } else { + if (!CORE.GTNH) { + if (i > 6) { + i = 6; + } + } else { + if (i > 8) { + i = 8; + } + } + return ItemUtils.simpleMetaStack(StaticFields59.getBlockCasings5(), i, 1); + } + } + + public static ItemStack getNumberedBioCircuit(int i) { + return ItemUtils.simpleMetaStack(AgriculturalChem.mBioCircuit, i, 0); + } + + public static ItemStack getNumberedAdvancedCircuit(int i) { + return ItemUtils.simpleMetaStack(GenericChem.mAdvancedCircuit, i, 0); + } + + public static ItemStack getTieredGTPPMachineCasing(int aTier, int aAmount) { + GregtechItemList[] aHulls = new GregtechItemList[] { + GregtechItemList.GTPP_Casing_ULV, + GregtechItemList.GTPP_Casing_LV, + GregtechItemList.GTPP_Casing_MV, + GregtechItemList.GTPP_Casing_HV, + GregtechItemList.GTPP_Casing_EV, + GregtechItemList.GTPP_Casing_IV, + GregtechItemList.GTPP_Casing_LuV, + GregtechItemList.GTPP_Casing_ZPM, + GregtechItemList.GTPP_Casing_UV, + GregtechItemList.GTPP_Casing_MAX + }; + return aHulls[aTier].get(aAmount); + } + + public static ItemStack getTieredComponentOfMaterial(Materials aMaterial, OrePrefixes aPrefix, int aAmount) { + return ItemUtils.getOrePrefixStack(aPrefix, aMaterial, aAmount); + } + + public static ItemStack getTransmissionComponent(int aTier, int aAmount) { + GregtechItemList[] aTransParts = new GregtechItemList[] { + GregtechItemList.TransmissionComponent_ULV, + GregtechItemList.TransmissionComponent_LV, + GregtechItemList.TransmissionComponent_MV, + GregtechItemList.TransmissionComponent_HV, + GregtechItemList.TransmissionComponent_EV, + GregtechItemList.TransmissionComponent_IV, + GregtechItemList.TransmissionComponent_LuV, + GregtechItemList.TransmissionComponent_ZPM, + GregtechItemList.TransmissionComponent_UV, + GregtechItemList.TransmissionComponent_MAX, + }; + return aTransParts[aTier].get(aAmount); + } + + public static ItemStack getEmptyCatalyst(int aAmount) { + return ItemUtils.simpleMetaStack(AgriculturalChem.mAgrichemItem1, 13, aAmount); + } + + /** + * Aluminium + Silver Catalyst + * @param aAmount - Stacksize + * @return - A Catalyst stack of given size + */ + public static ItemStack getGreenCatalyst(int aAmount) { + return ItemUtils.simpleMetaStack(AgriculturalChem.mAgrichemItem1, 14, aAmount); + } + + /** + * Iron + Copper Catalyst + * @param aAmount - Stacksize + * @return - A Catalyst stack of given size + */ + public static ItemStack getRedCatalyst(int aAmount) { + return ItemUtils.simpleMetaStack(GenericChem.mGenericChemItem1, 0, aAmount); + } + + /** + * Tungsten + Nickel Catalyst + * @param aAmount - Stacksize + * @return - A Catalyst stack of given size + */ + public static ItemStack getYellowCatalyst(int aAmount) { + return ItemUtils.simpleMetaStack(GenericChem.mGenericChemItem1, 1, aAmount); + } + + /** + * Cobalt + Titanium Catalyst + * @param aAmount - Stacksize + * @return - A Catalyst stack of given size + */ + public static ItemStack getBlueCatalyst(int aAmount) { + return ItemUtils.simpleMetaStack(GenericChem.mGenericChemItem1, 2, aAmount); + } + + /** + * Vanadium + Palladium Catalyst + * @param aAmount - Stacksize + * @return - A Catalyst stack of given size + */ + public static ItemStack getOrangeCatalyst(int aAmount) { + return ItemUtils.simpleMetaStack(GenericChem.mGenericChemItem1, 3, aAmount); + } + + /** + * Iridium + Ruthenium Catalyst + * @param aAmount - Stacksize + * @return - A Catalyst stack of given size + */ + public static ItemStack getPurpleCatalyst(int aAmount) { + return ItemUtils.simpleMetaStack(GenericChem.mGenericChemItem1, 4, aAmount); + } + + /** + * Aluminium + Nickel Catalyst + * @param aAmount - Stacksize + * @return - A Catalyst stack of given size + */ + public static ItemStack getBrownCatalyst(int aAmount) { + return ItemUtils.simpleMetaStack(GenericChem.mGenericChemItem1, 5, aAmount); + } + + /** + * Platinum + Rhodium Catalyst + * @param aAmount - Stacksize + * @return - A Catalyst stack of given size + */ + public static ItemStack getPinkCatalyst(int aAmount) { + return ItemUtils.simpleMetaStack(GenericChem.mGenericChemItem1, 6, aAmount); + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotAirFilter.java b/src/main/java/gtPlusPlus/core/slots/SlotAirFilter.java index 92e9bebe21..8ad0b000bc 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotAirFilter.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotAirFilter.java @@ -7,24 +7,23 @@ import net.minecraft.item.ItemStack; public class SlotAirFilter extends Slot { - public SlotAirFilter(final IInventory inventory, final int slot, final int x, final int y) { - super(inventory, slot, x, y); - } + public SlotAirFilter(final IInventory inventory, final int slot, final int x, final int y) { + super(inventory, slot, x, y); + } - @Override - public boolean isItemValid(final ItemStack itemstack) { - if (itemstack == null) { - return false; - } - if (itemstack.getItem() instanceof ItemAirFilter){ - return true; - } - return false; - } - - @Override - public int getSlotStackLimit() { - return 1; - } + @Override + public boolean isItemValid(final ItemStack itemstack) { + if (itemstack == null) { + return false; + } + if (itemstack.getItem() instanceof ItemAirFilter) { + return true; + } + return false; + } + @Override + public int getSlotStackLimit() { + return 1; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotBlueprint.java b/src/main/java/gtPlusPlus/core/slots/SlotBlueprint.java index 532f2f0822..56d39233e7 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotBlueprint.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotBlueprint.java @@ -1,31 +1,29 @@ package gtPlusPlus.core.slots; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.interfaces.IItemBlueprint; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.interfaces.IItemBlueprint; - public class SlotBlueprint extends Slot { - public SlotBlueprint(final IInventory inventory, final int x, final int y, final int z) { - super(inventory, x, y, z); - } - - @Override - public boolean isItemValid(final ItemStack itemstack) { - if (itemstack.getItem() instanceof IItemBlueprint) { - Logger.WARNING(itemstack.getDisplayName() + " is a valid Blueprint."); - return true; - } - Logger.WARNING(itemstack.getDisplayName() + " is not a valid Blueprint."); - return false; - } + public SlotBlueprint(final IInventory inventory, final int x, final int y, final int z) { + super(inventory, x, y, z); + } - @Override - public int getSlotStackLimit() { - return 1; - } + @Override + public boolean isItemValid(final ItemStack itemstack) { + if (itemstack.getItem() instanceof IItemBlueprint) { + Logger.WARNING(itemstack.getDisplayName() + " is a valid Blueprint."); + return true; + } + Logger.WARNING(itemstack.getDisplayName() + " is not a valid Blueprint."); + return false; + } + @Override + public int getSlotStackLimit() { + return 1; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotBuzzSaw.java b/src/main/java/gtPlusPlus/core/slots/SlotBuzzSaw.java index 94b0b9ecc7..0caee5e6d0 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotBuzzSaw.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotBuzzSaw.java @@ -1,77 +1,73 @@ package gtPlusPlus.core.slots; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - import gregtech.api.enums.OrePrefixes; import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.common.items.GT_MetaGenerated_Item_02; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; public class SlotBuzzSaw extends Slot { - public SAWTOOL currentTool = SAWTOOL.NONE; - - public SlotBuzzSaw(final IInventory inventory, final int slot, final int x, final int y) { - super(inventory, slot, x, y); - - } + public SAWTOOL currentTool = SAWTOOL.NONE; - @Override - public boolean isItemValid(final ItemStack itemstack) { - boolean isValid = false; + public SlotBuzzSaw(final IInventory inventory, final int slot, final int x, final int y) { + super(inventory, slot, x, y); + } - if (itemstack != null) { - if ((itemstack.getItem() instanceof GT_MetaGenerated_Item_02) - || (itemstack.getItem() instanceof GT_MetaGenerated_Tool)) { - // Buzzsaw Blade //TODO - /* - * if (OrePrefixes.toolHeadBuzzSaw.contains(itemstack)){ isValid - * = false; } - */ - if (OrePrefixes.craftingTool.contains(itemstack)) { - if (itemstack.getDisplayName().toLowerCase().contains("saw") - || itemstack.getDisplayName().toLowerCase().contains("gt.metatool.01.10") - || itemstack.getDisplayName().toLowerCase().contains("gt.metatool.01.110") - || itemstack.getDisplayName().toLowerCase().contains("gt.metatool.01.112") - || itemstack.getDisplayName().toLowerCase().contains("gt.metatool.01.114") - || itemstack.getDisplayName().toLowerCase().contains("gt.metatool.01.140")) { - if (itemstack.getItemDamage() == 10) { - isValid = true; - this.currentTool = SAWTOOL.SAW; - } - else if (itemstack.getItemDamage() == 110) { - isValid = true; - this.currentTool = SAWTOOL.CHAINSAW; - } - else if (itemstack.getItemDamage() == 112) { - isValid = true; - this.currentTool = SAWTOOL.CHAINSAW; - } - else if (itemstack.getItemDamage() == 114) { - isValid = true; - this.currentTool = SAWTOOL.CHAINSAW; - } - else if (itemstack.getItemDamage() == 140) { - isValid = true; - this.currentTool = SAWTOOL.BUZZSAW; - } - return isValid; - } - } - } - } - this.currentTool = SAWTOOL.NONE; - return isValid; - } + @Override + public boolean isItemValid(final ItemStack itemstack) { + boolean isValid = false; - @Override - public int getSlotStackLimit() { - return 1; - } + if (itemstack != null) { + if ((itemstack.getItem() instanceof GT_MetaGenerated_Item_02) + || (itemstack.getItem() instanceof GT_MetaGenerated_Tool)) { + // Buzzsaw Blade //TODO + /* + * if (OrePrefixes.toolHeadBuzzSaw.contains(itemstack)){ isValid + * = false; } + */ + if (OrePrefixes.craftingTool.contains(itemstack)) { + if (itemstack.getDisplayName().toLowerCase().contains("saw") + || itemstack.getDisplayName().toLowerCase().contains("gt.metatool.01.10") + || itemstack.getDisplayName().toLowerCase().contains("gt.metatool.01.110") + || itemstack.getDisplayName().toLowerCase().contains("gt.metatool.01.112") + || itemstack.getDisplayName().toLowerCase().contains("gt.metatool.01.114") + || itemstack.getDisplayName().toLowerCase().contains("gt.metatool.01.140")) { + if (itemstack.getItemDamage() == 10) { + isValid = true; + this.currentTool = SAWTOOL.SAW; + } else if (itemstack.getItemDamage() == 110) { + isValid = true; + this.currentTool = SAWTOOL.CHAINSAW; + } else if (itemstack.getItemDamage() == 112) { + isValid = true; + this.currentTool = SAWTOOL.CHAINSAW; + } else if (itemstack.getItemDamage() == 114) { + isValid = true; + this.currentTool = SAWTOOL.CHAINSAW; + } else if (itemstack.getItemDamage() == 140) { + isValid = true; + this.currentTool = SAWTOOL.BUZZSAW; + } + return isValid; + } + } + } + } + this.currentTool = SAWTOOL.NONE; + return isValid; + } - public enum SAWTOOL { - NONE, SAW, BUZZSAW, CHAINSAW - } + @Override + public int getSlotStackLimit() { + return 1; + } + public enum SAWTOOL { + NONE, + SAW, + BUZZSAW, + CHAINSAW + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotChemicalPlantInput.java b/src/main/java/gtPlusPlus/core/slots/SlotChemicalPlantInput.java index 1029d37a78..4bfda45170 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotChemicalPlantInput.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotChemicalPlantInput.java @@ -10,36 +10,35 @@ import net.minecraftforge.fluids.FluidStack; public class SlotChemicalPlantInput extends Slot { - public SlotChemicalPlantInput(final IInventory inventory, final int index, final int x, final int y) { - super(inventory, index, x, y); - } + public SlotChemicalPlantInput(final IInventory inventory, final int index, final int x, final int y) { + super(inventory, index, x, y); + } - @Override - public boolean isItemValid(final ItemStack itemstack) { - return isItemValidForChemicalPlantSlot(itemstack); - } - - public static boolean isItemValidForChemicalPlantSlot(ItemStack aStack) { - boolean validItem = GTPP_Recipe_Map.sChemicalPlantRecipes.containsInput(aStack); - if (!validItem) { - for (GT_Recipe f : GTPP_Recipe_Map.sChemicalPlantRecipes.mRecipeList) { - if (f.mFluidInputs.length > 0) { - for (FluidStack g : f.mFluidInputs) { - if (g != null) { - if (FluidContainerRegistry.containsFluid(aStack, g)) { - return true; - } - } - } - } - } - } - return validItem; - } + @Override + public boolean isItemValid(final ItemStack itemstack) { + return isItemValidForChemicalPlantSlot(itemstack); + } - @Override - public int getSlotStackLimit() { - return 64; - } + public static boolean isItemValidForChemicalPlantSlot(ItemStack aStack) { + boolean validItem = GTPP_Recipe_Map.sChemicalPlantRecipes.containsInput(aStack); + if (!validItem) { + for (GT_Recipe f : GTPP_Recipe_Map.sChemicalPlantRecipes.mRecipeList) { + if (f.mFluidInputs.length > 0) { + for (FluidStack g : f.mFluidInputs) { + if (g != null) { + if (FluidContainerRegistry.containsFluid(aStack, g)) { + return true; + } + } + } + } + } + } + return validItem; + } + @Override + public int getSlotStackLimit() { + return 64; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotCrafting.java b/src/main/java/gtPlusPlus/core/slots/SlotCrafting.java index 42b7b585e2..8d7c0946ec 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotCrafting.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotCrafting.java @@ -1,7 +1,6 @@ package gtPlusPlus.core.slots; import cpw.mods.fml.common.FMLCommonHandler; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -9,143 +8,149 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.*; import net.minecraft.stats.AchievementList; - import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; public class SlotCrafting extends Slot { - /** The craft matrix inventory linked to this result slot. */ - private final IInventory craftMatrix; - /** The player that is using the GUI where this slot resides. */ - private final EntityPlayer thePlayer; - /** - * The number of items that have been crafted so far. Gets passed to - * ItemStack.onCrafting before being reset. - */ - private int amountCrafted; - private static final String __OBFID = "CL_00001761"; - - public SlotCrafting(final EntityPlayer p_i1823_1_, final IInventory p_i1823_2_, final IInventory p_i1823_3_, - final int p_i1823_4_, final int p_i1823_5_, final int p_i1823_6_) { - super(p_i1823_3_, p_i1823_4_, p_i1823_5_, p_i1823_6_); - this.thePlayer = p_i1823_1_; - this.craftMatrix = p_i1823_2_; - } - - /** - * Check if the stack is a valid item for this slot. Always true beside for - * the armor slots. - */ - @Override - public boolean isItemValid(final ItemStack p_75214_1_) { - return false; - } - - /** - * Decrease the size of the stack in slot (first int arg) by the amount of - * the second int arg. Returns the new stack. - */ - @Override - public ItemStack decrStackSize(final int p_75209_1_) { - if (this.getHasStack()) { - this.amountCrafted += Math.min(p_75209_1_, this.getStack().stackSize); - } - - return super.decrStackSize(p_75209_1_); - } - - /** - * the itemStack passed in is the output - ie, iron ingots, and pickaxes, - * not ore and wood. Typically increases an internal count then calls - * onCrafting(item). - */ - @Override - protected void onCrafting(final ItemStack p_75210_1_, final int p_75210_2_) { - this.amountCrafted += p_75210_2_; - this.onCrafting(p_75210_1_); - } - - /** - * the itemStack passed in is the output - ie, iron ingots, and pickaxes, - * not ore and wood. - */ - @Override - protected void onCrafting(final ItemStack p_75208_1_) { - p_75208_1_.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted); - this.amountCrafted = 0; - - if (p_75208_1_.getItem() == Item.getItemFromBlock(Blocks.crafting_table)) { - this.thePlayer.addStat(AchievementList.buildWorkBench, 1); - } - - if (p_75208_1_.getItem() instanceof ItemPickaxe) { - this.thePlayer.addStat(AchievementList.buildPickaxe, 1); - } - - if (p_75208_1_.getItem() == Item.getItemFromBlock(Blocks.furnace)) { - this.thePlayer.addStat(AchievementList.buildFurnace, 1); - } - - if (p_75208_1_.getItem() instanceof ItemHoe) { - this.thePlayer.addStat(AchievementList.buildHoe, 1); - } - - if (p_75208_1_.getItem() == Items.bread) { - this.thePlayer.addStat(AchievementList.makeBread, 1); - } - - if (p_75208_1_.getItem() == Items.cake) { - this.thePlayer.addStat(AchievementList.bakeCake, 1); - } - - if ((p_75208_1_.getItem() instanceof ItemPickaxe) - && (((ItemPickaxe) p_75208_1_.getItem()).func_150913_i() != Item.ToolMaterial.WOOD)) { - this.thePlayer.addStat(AchievementList.buildBetterPickaxe, 1); - } - - if (p_75208_1_.getItem() instanceof ItemSword) { - this.thePlayer.addStat(AchievementList.buildSword, 1); - } - - if (p_75208_1_.getItem() == Item.getItemFromBlock(Blocks.enchanting_table)) { - this.thePlayer.addStat(AchievementList.enchantments, 1); - } - - if (p_75208_1_.getItem() == Item.getItemFromBlock(Blocks.bookshelf)) { - this.thePlayer.addStat(AchievementList.bookcase, 1); - } - } - - @Override - public void onPickupFromSlot(final EntityPlayer p_82870_1_, final ItemStack p_82870_2_) { - FMLCommonHandler.instance().firePlayerCraftingEvent(p_82870_1_, p_82870_2_, this.craftMatrix); - this.onCrafting(p_82870_2_); - - for (int i = 0; i < this.craftMatrix.getSizeInventory(); ++i) { - final ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i); - - if (itemstack1 != null) { - this.craftMatrix.decrStackSize(i, 1); - - if (itemstack1.getItem().hasContainerItem(itemstack1)) { - final ItemStack itemstack2 = itemstack1.getItem().getContainerItem(itemstack1); - - if ((itemstack2 != null) && itemstack2.isItemStackDamageable() - && (itemstack2.getItemDamage() > itemstack2.getMaxDamage())) { - MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(this.thePlayer, itemstack2)); - continue; - } - - if (!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1) - || !this.thePlayer.inventory.addItemStackToInventory(itemstack2)) { - if (this.craftMatrix.getStackInSlot(i) == null) { - this.craftMatrix.setInventorySlotContents(i, itemstack2); - } else { - this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false); - } - } - } - } - } - } -} \ No newline at end of file + /** The craft matrix inventory linked to this result slot. */ + private final IInventory craftMatrix; + /** The player that is using the GUI where this slot resides. */ + private final EntityPlayer thePlayer; + /** + * The number of items that have been crafted so far. Gets passed to + * ItemStack.onCrafting before being reset. + */ + private int amountCrafted; + + private static final String __OBFID = "CL_00001761"; + + public SlotCrafting( + final EntityPlayer p_i1823_1_, + final IInventory p_i1823_2_, + final IInventory p_i1823_3_, + final int p_i1823_4_, + final int p_i1823_5_, + final int p_i1823_6_) { + super(p_i1823_3_, p_i1823_4_, p_i1823_5_, p_i1823_6_); + this.thePlayer = p_i1823_1_; + this.craftMatrix = p_i1823_2_; + } + + /** + * Check if the stack is a valid item for this slot. Always true beside for + * the armor slots. + */ + @Override + public boolean isItemValid(final ItemStack p_75214_1_) { + return false; + } + + /** + * Decrease the size of the stack in slot (first int arg) by the amount of + * the second int arg. Returns the new stack. + */ + @Override + public ItemStack decrStackSize(final int p_75209_1_) { + if (this.getHasStack()) { + this.amountCrafted += Math.min(p_75209_1_, this.getStack().stackSize); + } + + return super.decrStackSize(p_75209_1_); + } + + /** + * the itemStack passed in is the output - ie, iron ingots, and pickaxes, + * not ore and wood. Typically increases an internal count then calls + * onCrafting(item). + */ + @Override + protected void onCrafting(final ItemStack p_75210_1_, final int p_75210_2_) { + this.amountCrafted += p_75210_2_; + this.onCrafting(p_75210_1_); + } + + /** + * the itemStack passed in is the output - ie, iron ingots, and pickaxes, + * not ore and wood. + */ + @Override + protected void onCrafting(final ItemStack p_75208_1_) { + p_75208_1_.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted); + this.amountCrafted = 0; + + if (p_75208_1_.getItem() == Item.getItemFromBlock(Blocks.crafting_table)) { + this.thePlayer.addStat(AchievementList.buildWorkBench, 1); + } + + if (p_75208_1_.getItem() instanceof ItemPickaxe) { + this.thePlayer.addStat(AchievementList.buildPickaxe, 1); + } + + if (p_75208_1_.getItem() == Item.getItemFromBlock(Blocks.furnace)) { + this.thePlayer.addStat(AchievementList.buildFurnace, 1); + } + + if (p_75208_1_.getItem() instanceof ItemHoe) { + this.thePlayer.addStat(AchievementList.buildHoe, 1); + } + + if (p_75208_1_.getItem() == Items.bread) { + this.thePlayer.addStat(AchievementList.makeBread, 1); + } + + if (p_75208_1_.getItem() == Items.cake) { + this.thePlayer.addStat(AchievementList.bakeCake, 1); + } + + if ((p_75208_1_.getItem() instanceof ItemPickaxe) + && (((ItemPickaxe) p_75208_1_.getItem()).func_150913_i() != Item.ToolMaterial.WOOD)) { + this.thePlayer.addStat(AchievementList.buildBetterPickaxe, 1); + } + + if (p_75208_1_.getItem() instanceof ItemSword) { + this.thePlayer.addStat(AchievementList.buildSword, 1); + } + + if (p_75208_1_.getItem() == Item.getItemFromBlock(Blocks.enchanting_table)) { + this.thePlayer.addStat(AchievementList.enchantments, 1); + } + + if (p_75208_1_.getItem() == Item.getItemFromBlock(Blocks.bookshelf)) { + this.thePlayer.addStat(AchievementList.bookcase, 1); + } + } + + @Override + public void onPickupFromSlot(final EntityPlayer p_82870_1_, final ItemStack p_82870_2_) { + FMLCommonHandler.instance().firePlayerCraftingEvent(p_82870_1_, p_82870_2_, this.craftMatrix); + this.onCrafting(p_82870_2_); + + for (int i = 0; i < this.craftMatrix.getSizeInventory(); ++i) { + final ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i); + + if (itemstack1 != null) { + this.craftMatrix.decrStackSize(i, 1); + + if (itemstack1.getItem().hasContainerItem(itemstack1)) { + final ItemStack itemstack2 = itemstack1.getItem().getContainerItem(itemstack1); + + if ((itemstack2 != null) + && itemstack2.isItemStackDamageable() + && (itemstack2.getItemDamage() > itemstack2.getMaxDamage())) { + MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(this.thePlayer, itemstack2)); + continue; + } + + if (!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1) + || !this.thePlayer.inventory.addItemStackToInventory(itemstack2)) { + if (this.craftMatrix.getStackInSlot(i) == null) { + this.craftMatrix.setInventorySlotContents(i, itemstack2); + } else { + this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false); + } + } + } + } + } + } +} diff --git a/src/main/java/gtPlusPlus/core/slots/SlotCraftingNoCollect.java b/src/main/java/gtPlusPlus/core/slots/SlotCraftingNoCollect.java index 3608c3724c..cf96dd69e2 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotCraftingNoCollect.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotCraftingNoCollect.java @@ -1,7 +1,6 @@ package gtPlusPlus.core.slots; import cpw.mods.fml.common.FMLCommonHandler; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -10,138 +9,138 @@ import net.minecraft.item.*; import net.minecraft.stats.AchievementList; public class SlotCraftingNoCollect extends SlotCrafting { - /** The craft matrix inventory linked to this result slot. */ - private final IInventory craftMatrix; - /** The player that is using the GUI where this slot resides. */ - private EntityPlayer thePlayer; - /** - * The number of items that have been crafted so far. Gets passed to - * ItemStack.onCrafting before being reset. - */ - private int amountCrafted; - - public SlotCraftingNoCollect(EntityPlayer player, IInventory inventory, IInventory inventory2, int x, int y, - int z) { - super(player, inventory, inventory2, x, y, z); - this.thePlayer = player; - this.craftMatrix = inventory; - } - - /** - * Check if the stack is a valid item for this slot. Always true beside for - * the armor slots. - */ - @Override - public boolean isItemValid(ItemStack p_75214_1_) { - return false; - } - - /** - * Decrease the size of the stack in slot (first int arg) by the amount of - * the second int arg. Returns the new stack. - */ - @Override - public ItemStack decrStackSize(int amount) { - if (this.getHasStack()) { - this.amountCrafted += Math.min(amount, this.getStack().stackSize); - } - - return super.decrStackSize(amount); - } - - /** - * the itemStack passed in is the output - ie, iron ingots, and pickaxes, - * not ore and wood. Typically increases an internal count then calls - * onCrafting(item). - */ - @Override - protected void onCrafting(ItemStack output, int amount) { - this.amountCrafted += amount; - this.onCrafting(output); - } - - /** - * the itemStack passed in is the output - ie, iron ingots, and pickaxes, - * not ore and wood. - */ - @Override - protected void onCrafting(ItemStack output) { - output.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted); - this.amountCrafted = 0; - - if (output.getItem() == Item.getItemFromBlock(Blocks.crafting_table)) { - this.thePlayer.addStat(AchievementList.buildWorkBench, 1); - } - - if (output.getItem() instanceof ItemPickaxe) { - this.thePlayer.addStat(AchievementList.buildPickaxe, 1); - } - - if (output.getItem() == Item.getItemFromBlock(Blocks.furnace)) { - this.thePlayer.addStat(AchievementList.buildFurnace, 1); - } - - if (output.getItem() instanceof ItemHoe) { - this.thePlayer.addStat(AchievementList.buildHoe, 1); - } - - if (output.getItem() == Items.bread) { - this.thePlayer.addStat(AchievementList.makeBread, 1); - } - - if (output.getItem() == Items.cake) { - this.thePlayer.addStat(AchievementList.bakeCake, 1); - } - - if (output.getItem() instanceof ItemPickaxe - && ((ItemPickaxe) output.getItem()).func_150913_i() != Item.ToolMaterial.WOOD) { - this.thePlayer.addStat(AchievementList.buildBetterPickaxe, 1); - } - - if (output.getItem() instanceof ItemSword) { - this.thePlayer.addStat(AchievementList.buildSword, 1); - } - - if (output.getItem() == Item.getItemFromBlock(Blocks.enchanting_table)) { - this.thePlayer.addStat(AchievementList.enchantments, 1); - } - - if (output.getItem() == Item.getItemFromBlock(Blocks.bookshelf)) { - this.thePlayer.addStat(AchievementList.bookcase, 1); - } - } - - @Override - public void onPickupFromSlot(EntityPlayer player, ItemStack output) { - FMLCommonHandler.instance().firePlayerCraftingEvent(player, output, craftMatrix); - this.onCrafting(output); - - /* - * for (int i = 0; i < this.craftMatrix.getSizeInventory(); ++i) { - * ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i); - * - * if (itemstack1 != null) { this.craftMatrix.decrStackSize(i, 1); - * - * if (itemstack1.getItem().hasContainerItem(itemstack1)) { ItemStack - * itemstack2 = itemstack1.getItem().getContainerItem(itemstack1); - * - * if (itemstack2 != null && itemstack2.isItemStackDamageable() && - * itemstack2.getItemDamage() > itemstack2.getMaxDamage()) { - * MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thePlayer, - * itemstack2)); continue; } - * - * if - * (!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1) - * || !this.thePlayer.inventory.addItemStackToInventory(itemstack2)) { - * if (this.craftMatrix.getStackInSlot(i) == null) { - * this.craftMatrix.setInventorySlotContents(i, itemstack2); } else { - * this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false); } } - * } } } - */ - } - - @Override - public boolean canTakeStack(EntityPlayer player) { - return false; - } -} \ No newline at end of file + /** The craft matrix inventory linked to this result slot. */ + private final IInventory craftMatrix; + /** The player that is using the GUI where this slot resides. */ + private EntityPlayer thePlayer; + /** + * The number of items that have been crafted so far. Gets passed to + * ItemStack.onCrafting before being reset. + */ + private int amountCrafted; + + public SlotCraftingNoCollect( + EntityPlayer player, IInventory inventory, IInventory inventory2, int x, int y, int z) { + super(player, inventory, inventory2, x, y, z); + this.thePlayer = player; + this.craftMatrix = inventory; + } + + /** + * Check if the stack is a valid item for this slot. Always true beside for + * the armor slots. + */ + @Override + public boolean isItemValid(ItemStack p_75214_1_) { + return false; + } + + /** + * Decrease the size of the stack in slot (first int arg) by the amount of + * the second int arg. Returns the new stack. + */ + @Override + public ItemStack decrStackSize(int amount) { + if (this.getHasStack()) { + this.amountCrafted += Math.min(amount, this.getStack().stackSize); + } + + return super.decrStackSize(amount); + } + + /** + * the itemStack passed in is the output - ie, iron ingots, and pickaxes, + * not ore and wood. Typically increases an internal count then calls + * onCrafting(item). + */ + @Override + protected void onCrafting(ItemStack output, int amount) { + this.amountCrafted += amount; + this.onCrafting(output); + } + + /** + * the itemStack passed in is the output - ie, iron ingots, and pickaxes, + * not ore and wood. + */ + @Override + protected void onCrafting(ItemStack output) { + output.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted); + this.amountCrafted = 0; + + if (output.getItem() == Item.getItemFromBlock(Blocks.crafting_table)) { + this.thePlayer.addStat(AchievementList.buildWorkBench, 1); + } + + if (output.getItem() instanceof ItemPickaxe) { + this.thePlayer.addStat(AchievementList.buildPickaxe, 1); + } + + if (output.getItem() == Item.getItemFromBlock(Blocks.furnace)) { + this.thePlayer.addStat(AchievementList.buildFurnace, 1); + } + + if (output.getItem() instanceof ItemHoe) { + this.thePlayer.addStat(AchievementList.buildHoe, 1); + } + + if (output.getItem() == Items.bread) { + this.thePlayer.addStat(AchievementList.makeBread, 1); + } + + if (output.getItem() == Items.cake) { + this.thePlayer.addStat(AchievementList.bakeCake, 1); + } + + if (output.getItem() instanceof ItemPickaxe + && ((ItemPickaxe) output.getItem()).func_150913_i() != Item.ToolMaterial.WOOD) { + this.thePlayer.addStat(AchievementList.buildBetterPickaxe, 1); + } + + if (output.getItem() instanceof ItemSword) { + this.thePlayer.addStat(AchievementList.buildSword, 1); + } + + if (output.getItem() == Item.getItemFromBlock(Blocks.enchanting_table)) { + this.thePlayer.addStat(AchievementList.enchantments, 1); + } + + if (output.getItem() == Item.getItemFromBlock(Blocks.bookshelf)) { + this.thePlayer.addStat(AchievementList.bookcase, 1); + } + } + + @Override + public void onPickupFromSlot(EntityPlayer player, ItemStack output) { + FMLCommonHandler.instance().firePlayerCraftingEvent(player, output, craftMatrix); + this.onCrafting(output); + + /* + * for (int i = 0; i < this.craftMatrix.getSizeInventory(); ++i) { + * ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i); + * + * if (itemstack1 != null) { this.craftMatrix.decrStackSize(i, 1); + * + * if (itemstack1.getItem().hasContainerItem(itemstack1)) { ItemStack + * itemstack2 = itemstack1.getItem().getContainerItem(itemstack1); + * + * if (itemstack2 != null && itemstack2.isItemStackDamageable() && + * itemstack2.getItemDamage() > itemstack2.getMaxDamage()) { + * MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thePlayer, + * itemstack2)); continue; } + * + * if + * (!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1) + * || !this.thePlayer.inventory.addItemStackToInventory(itemstack2)) { + * if (this.craftMatrix.getStackInSlot(i) == null) { + * this.craftMatrix.setInventorySlotContents(i, itemstack2); } else { + * this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false); } } + * } } } + */ + } + + @Override + public boolean canTakeStack(EntityPlayer player) { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/core/slots/SlotDataStick.java b/src/main/java/gtPlusPlus/core/slots/SlotDataStick.java index ce97a2fdbf..69feaa3384 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotDataStick.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotDataStick.java @@ -1,42 +1,41 @@ package gtPlusPlus.core.slots; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.recipe.common.CI; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.recipe.common.CI; - public class SlotDataStick extends Slot { - public SlotDataStick(final IInventory inventory, final int slot, final int x, final int y) { - super(inventory, slot, x, y); + public SlotDataStick(final IInventory inventory, final int slot, final int x, final int y) { + super(inventory, slot, x, y); + } - } + public static ItemStack[] mDataItems = new ItemStack[2]; - public static ItemStack[] mDataItems = new ItemStack[2]; - - @Override - public synchronized boolean isItemValid(final ItemStack itemstack) { - boolean isValid = false; - if (itemstack != null) { - if (mDataItems[0] == null) { - mDataItems[0] = CI.getDataStick(); - } - if (mDataItems[1] == null) { - mDataItems[1] = CI.getDataOrb(); - } - if (mDataItems[0] != null && mDataItems[1] != null) { - if (GT_Utility.areStacksEqual(itemstack, mDataItems[0], true) || GT_Utility.areStacksEqual(itemstack, mDataItems[1], true) ) { - isValid = true; - } - } - } - return isValid; - } + @Override + public synchronized boolean isItemValid(final ItemStack itemstack) { + boolean isValid = false; + if (itemstack != null) { + if (mDataItems[0] == null) { + mDataItems[0] = CI.getDataStick(); + } + if (mDataItems[1] == null) { + mDataItems[1] = CI.getDataOrb(); + } + if (mDataItems[0] != null && mDataItems[1] != null) { + if (GT_Utility.areStacksEqual(itemstack, mDataItems[0], true) + || GT_Utility.areStacksEqual(itemstack, mDataItems[1], true)) { + isValid = true; + } + } + } + return isValid; + } - @Override - public int getSlotStackLimit() { - return 1; - } + @Override + public int getSlotStackLimit() { + return 1; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotElectric.java b/src/main/java/gtPlusPlus/core/slots/SlotElectric.java index a747432a74..9c14afc6cc 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotElectric.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotElectric.java @@ -1,45 +1,48 @@ package gtPlusPlus.core.slots; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaGenerated_Tool; - import ic2.api.info.Info; import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; public class SlotElectric extends Slot { - - public SlotElectric(final IInventory inventory, final int x, final int y, final int z) { - super(inventory, x, y, z); - } - - public SlotElectric(IGregTechTileEntity mTileEntity, int i, int j, int k) { - this(mTileEntity.getIInventory(mTileEntity.getXCoord(), mTileEntity.getYCoord(), mTileEntity.getZCoord()), i, j, k); - } - - @Override - public boolean isItemValid(final ItemStack itemstack) { - if ((accepts(itemstack)) || (itemstack.getItem() instanceof GT_MetaGenerated_Tool) || (itemstack.getItem() instanceof IElectricItem)) { - return true; - } - return false; - } - - public boolean accepts(final ItemStack stack) { - if (stack == null) { - return false; - } - return (Info.itemEnergy.getEnergyValue(stack) > 0.0D) - || (ElectricItem.manager.discharge(stack, (1.0D / 0.0D), 4, true, true, true) > 0.0D); - } - - @Override - public int getSlotStackLimit() { - return 1; - } + public SlotElectric(final IInventory inventory, final int x, final int y, final int z) { + super(inventory, x, y, z); + } + + public SlotElectric(IGregTechTileEntity mTileEntity, int i, int j, int k) { + this( + mTileEntity.getIInventory(mTileEntity.getXCoord(), mTileEntity.getYCoord(), mTileEntity.getZCoord()), + i, + j, + k); + } + + @Override + public boolean isItemValid(final ItemStack itemstack) { + if ((accepts(itemstack)) + || (itemstack.getItem() instanceof GT_MetaGenerated_Tool) + || (itemstack.getItem() instanceof IElectricItem)) { + return true; + } + return false; + } + + public boolean accepts(final ItemStack stack) { + if (stack == null) { + return false; + } + return (Info.itemEnergy.getEnergyValue(stack) > 0.0D) + || (ElectricItem.manager.discharge(stack, (1.0D / 0.0D), 4, true, true, true) > 0.0D); + } + + @Override + public int getSlotStackLimit() { + return 1; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotFrame.java b/src/main/java/gtPlusPlus/core/slots/SlotFrame.java index 4168ded5bc..593ec747e8 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotFrame.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotFrame.java @@ -1,26 +1,23 @@ package gtPlusPlus.core.slots; +import forestry.api.apiculture.IHiveFrame; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import forestry.api.apiculture.IHiveFrame; - public class SlotFrame extends Slot { - public SlotFrame(final IInventory inventory, final int x, final int y, final int z) { - super(inventory, x, y, z); - - } - - @Override - public boolean isItemValid(final ItemStack itemstack) { - return itemstack.getItem() instanceof IHiveFrame; - } + public SlotFrame(final IInventory inventory, final int x, final int y, final int z) { + super(inventory, x, y, z); + } - @Override - public int getSlotStackLimit() { - return 1; - } + @Override + public boolean isItemValid(final ItemStack itemstack) { + return itemstack.getItem() instanceof IHiveFrame; + } + @Override + public int getSlotStackLimit() { + return 1; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotFuelRod.java b/src/main/java/gtPlusPlus/core/slots/SlotFuelRod.java index b50b679665..18c5878e35 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotFuelRod.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotFuelRod.java @@ -1,55 +1,51 @@ package gtPlusPlus.core.slots; +import gregtech.api.enums.ItemList; +import ic2.core.Ic2Items; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import gregtech.api.enums.ItemList; - -import ic2.core.Ic2Items; - public class SlotFuelRod extends Slot { - public SlotFuelRod(final IInventory inventory, final int index, final int x, final int y) { - super(inventory, index, x, y); - - } - - @Override - public boolean isItemValid(final ItemStack itemstack) { - boolean returnValue = false; - // Uranium Rods - if (itemstack.getItem() == Ic2Items.reactorUraniumSimple.getItem()) { - returnValue = true; - } else if (itemstack.getItem() == Ic2Items.reactorUraniumDual.getItem()) { - returnValue = true; - } else if (itemstack.getItem() == Ic2Items.reactorUraniumQuad.getItem()) { - returnValue = true; - } - - // Mox Rods - if (itemstack.getItem() == Ic2Items.reactorMOXSimple.getItem()) { - returnValue = true; - } else if (itemstack.getItem() == Ic2Items.reactorMOXDual.getItem()) { - returnValue = true; - } else if (itemstack.getItem() == Ic2Items.reactorMOXQuad.getItem()) { - returnValue = true; - } - - // Thorium Rods - if (itemstack.getItem() == ItemList.ThoriumCell_1.getItem()) { - returnValue = true; - } else if (itemstack.getItem() == ItemList.ThoriumCell_2.getItem()) { - returnValue = true; - } else if (itemstack.getItem() == ItemList.ThoriumCell_4.getItem()) { - returnValue = true; - } - return returnValue; - } - - @Override - public int getSlotStackLimit() { - return 1; - } - + public SlotFuelRod(final IInventory inventory, final int index, final int x, final int y) { + super(inventory, index, x, y); + } + + @Override + public boolean isItemValid(final ItemStack itemstack) { + boolean returnValue = false; + // Uranium Rods + if (itemstack.getItem() == Ic2Items.reactorUraniumSimple.getItem()) { + returnValue = true; + } else if (itemstack.getItem() == Ic2Items.reactorUraniumDual.getItem()) { + returnValue = true; + } else if (itemstack.getItem() == Ic2Items.reactorUraniumQuad.getItem()) { + returnValue = true; + } + + // Mox Rods + if (itemstack.getItem() == Ic2Items.reactorMOXSimple.getItem()) { + returnValue = true; + } else if (itemstack.getItem() == Ic2Items.reactorMOXDual.getItem()) { + returnValue = true; + } else if (itemstack.getItem() == Ic2Items.reactorMOXQuad.getItem()) { + returnValue = true; + } + + // Thorium Rods + if (itemstack.getItem() == ItemList.ThoriumCell_1.getItem()) { + returnValue = true; + } else if (itemstack.getItem() == ItemList.ThoriumCell_2.getItem()) { + returnValue = true; + } else if (itemstack.getItem() == ItemList.ThoriumCell_4.getItem()) { + returnValue = true; + } + return returnValue; + } + + @Override + public int getSlotStackLimit() { + return 1; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotGeneric.java b/src/main/java/gtPlusPlus/core/slots/SlotGeneric.java index 533539d914..bfb384efe8 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotGeneric.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotGeneric.java @@ -6,18 +6,17 @@ import net.minecraft.item.ItemStack; public class SlotGeneric extends Slot { - public SlotGeneric(final IInventory inventory, final int aSlotID, final int x, final int y) { - super(inventory, aSlotID, x, y); - } + public SlotGeneric(final IInventory inventory, final int aSlotID, final int x, final int y) { + super(inventory, aSlotID, x, y); + } - @Override - public boolean isItemValid(final ItemStack itemstack) { - return true; - } - - @Override - public int getSlotStackLimit() { - return 64; - } + @Override + public boolean isItemValid(final ItemStack itemstack) { + return true; + } + @Override + public int getSlotStackLimit() { + return 64; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotGtTool.java b/src/main/java/gtPlusPlus/core/slots/SlotGtTool.java index 54e25362db..ea2d8f3a93 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotGtTool.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotGtTool.java @@ -1,33 +1,29 @@ package gtPlusPlus.core.slots; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gtPlusPlus.api.objects.Logger; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import gregtech.api.items.GT_MetaGenerated_Tool; - -import gtPlusPlus.api.objects.Logger; - public class SlotGtTool extends Slot { - public SlotGtTool(final IInventory inventory, final int x, final int y, final int z) { - super(inventory, x, y, z); - - } - - @Override - public boolean isItemValid(final ItemStack itemstack) { - if (itemstack.getItem() instanceof GT_MetaGenerated_Tool) { - Logger.WARNING(itemstack.getDisplayName() + " is a valid Tool."); - return true; - } - Logger.WARNING(itemstack.getDisplayName() + " is not a valid Tool."); - return false; - } - - @Override - public int getSlotStackLimit() { - return 1; - } - + public SlotGtTool(final IInventory inventory, final int x, final int y, final int z) { + super(inventory, x, y, z); + } + + @Override + public boolean isItemValid(final ItemStack itemstack) { + if (itemstack.getItem() instanceof GT_MetaGenerated_Tool) { + Logger.WARNING(itemstack.getDisplayName() + " is a valid Tool."); + return true; + } + Logger.WARNING(itemstack.getDisplayName() + " is not a valid Tool."); + return false; + } + + @Override + public int getSlotStackLimit() { + return 1; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotGtToolElectric.java b/src/main/java/gtPlusPlus/core/slots/SlotGtToolElectric.java index c0e3340769..c7013660dc 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotGtToolElectric.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotGtToolElectric.java @@ -1,94 +1,95 @@ package gtPlusPlus.core.slots; -import net.minecraft.init.Items; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; - import gregtech.api.items.GT_MetaGenerated_Tool; - import gtPlusPlus.api.objects.Logger; import ic2.api.info.Info; import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; +import net.minecraft.init.Items; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; public class SlotGtToolElectric extends SlotGtTool { - public int tier; - private ItemStack content; - - public SlotGtToolElectric(final IInventory base, final int x, final int y, final int z, final int tier, - final boolean allowRedstoneDust) { - super(base, x, y, z); - this.tier = tier; - this.allowRedstoneDust = allowRedstoneDust; - } - - public boolean accepts(final ItemStack stack) { - if (stack == null) { - return false; - } - if ((stack.getItem() == Items.redstone) && (!this.allowRedstoneDust)) { - return false; - } - return (Info.itemEnergy.getEnergyValue(stack) > 0.0D) - || (ElectricItem.manager.discharge(stack, (1.0D / 0.0D), this.tier, true, true, true) > 0.0D); - } - - public double discharge(final double amount, final boolean ignoreLimit) { - if (amount <= 0.0D) { - throw new IllegalArgumentException("Amount must be > 0."); - } - final ItemStack stack = this.get(0); - if (stack == null) { - return 0.0D; - } - double realAmount = ElectricItem.manager.discharge(stack, amount, this.tier, ignoreLimit, true, false); - if (realAmount <= 0.0D) { - realAmount = Info.itemEnergy.getEnergyValue(stack); - if (realAmount <= 0.0D) { - return 0.0D; - } - stack.stackSize -= 1; - if (stack.stackSize <= 0) { - this.put(0, null); - } - } - return realAmount; - } - - public void setTier(final int tier1) { - this.tier = tier1; - } - - public boolean allowRedstoneDust = true; - - public ItemStack get() { - return this.get(0); - } - - public ItemStack get(final int index) { - return this.content; - } - - public void put(final ItemStack content) { - this.put(0, content); - } - - public void put(final int index, final ItemStack content) { - this.content = content; - this.onChanged(); - } - - public void onChanged() { - } - - @Override - public boolean isItemValid(final ItemStack itemstack) { - if ((itemstack.getItem() instanceof GT_MetaGenerated_Tool) || (itemstack.getItem() instanceof IElectricItem)) { - Logger.WARNING(itemstack.getDisplayName() + " is a valid Tool."); - return true; - } - Logger.WARNING(itemstack.getDisplayName() + " is not a valid Tool."); - return false; - } - + public int tier; + private ItemStack content; + + public SlotGtToolElectric( + final IInventory base, + final int x, + final int y, + final int z, + final int tier, + final boolean allowRedstoneDust) { + super(base, x, y, z); + this.tier = tier; + this.allowRedstoneDust = allowRedstoneDust; + } + + public boolean accepts(final ItemStack stack) { + if (stack == null) { + return false; + } + if ((stack.getItem() == Items.redstone) && (!this.allowRedstoneDust)) { + return false; + } + return (Info.itemEnergy.getEnergyValue(stack) > 0.0D) + || (ElectricItem.manager.discharge(stack, (1.0D / 0.0D), this.tier, true, true, true) > 0.0D); + } + + public double discharge(final double amount, final boolean ignoreLimit) { + if (amount <= 0.0D) { + throw new IllegalArgumentException("Amount must be > 0."); + } + final ItemStack stack = this.get(0); + if (stack == null) { + return 0.0D; + } + double realAmount = ElectricItem.manager.discharge(stack, amount, this.tier, ignoreLimit, true, false); + if (realAmount <= 0.0D) { + realAmount = Info.itemEnergy.getEnergyValue(stack); + if (realAmount <= 0.0D) { + return 0.0D; + } + stack.stackSize -= 1; + if (stack.stackSize <= 0) { + this.put(0, null); + } + } + return realAmount; + } + + public void setTier(final int tier1) { + this.tier = tier1; + } + + public boolean allowRedstoneDust = true; + + public ItemStack get() { + return this.get(0); + } + + public ItemStack get(final int index) { + return this.content; + } + + public void put(final ItemStack content) { + this.put(0, content); + } + + public void put(final int index, final ItemStack content) { + this.content = content; + this.onChanged(); + } + + public void onChanged() {} + + @Override + public boolean isItemValid(final ItemStack itemstack) { + if ((itemstack.getItem() instanceof GT_MetaGenerated_Tool) || (itemstack.getItem() instanceof IElectricItem)) { + Logger.WARNING(itemstack.getDisplayName() + " is a valid Tool."); + return true; + } + Logger.WARNING(itemstack.getDisplayName() + " is not a valid Tool."); + return false; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotIntegratedCircuit.java b/src/main/java/gtPlusPlus/core/slots/SlotIntegratedCircuit.java index 8c8a118abb..702f678804 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotIntegratedCircuit.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotIntegratedCircuit.java @@ -1,105 +1,104 @@ package gtPlusPlus.core.slots; +import gtPlusPlus.core.recipe.common.CI; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import gtPlusPlus.core.recipe.common.CI; - public class SlotIntegratedCircuit extends Slot { - public static Item mCircuitItem; - public static Item mCircuitItem2; - public static Item mCircuitItem3; - private final short mCircuitLock; + public static Item mCircuitItem; + public static Item mCircuitItem2; + public static Item mCircuitItem3; + private final short mCircuitLock; - public SlotIntegratedCircuit(final IInventory inventory, final int slot, final int x, final int y) { - this(Short.MAX_VALUE+1, inventory, slot, x, y); - } + public SlotIntegratedCircuit(final IInventory inventory, final int slot, final int x, final int y) { + this(Short.MAX_VALUE + 1, inventory, slot, x, y); + } - public SlotIntegratedCircuit(int mTypeLock, final IInventory inventory, final int slot, final int x, final int y) { - super(inventory, slot, x, y); - if (mTypeLock > Short.MAX_VALUE || mTypeLock < Short.MIN_VALUE) { - mCircuitLock = -1; - } - else { - mCircuitLock = (short) mTypeLock; - } - } + public SlotIntegratedCircuit(int mTypeLock, final IInventory inventory, final int slot, final int x, final int y) { + super(inventory, slot, x, y); + if (mTypeLock > Short.MAX_VALUE || mTypeLock < Short.MIN_VALUE) { + mCircuitLock = -1; + } else { + mCircuitLock = (short) mTypeLock; + } + } - @Override - public synchronized boolean isItemValid(final ItemStack itemstack) { - return isItemValidForSlot(mCircuitLock, itemstack); - } + @Override + public synchronized boolean isItemValid(final ItemStack itemstack) { + return isItemValidForSlot(mCircuitLock, itemstack); + } - public static synchronized boolean isItemValidForSlot(final ItemStack itemstack) { - return isItemValidForSlot(-1, itemstack); - } + public static synchronized boolean isItemValidForSlot(final ItemStack itemstack) { + return isItemValidForSlot(-1, itemstack); + } - public static synchronized boolean isItemValidForSlot(int aLockedCircuitNumber, final ItemStack itemstack) { - boolean isValid = false; - if (mCircuitItem == null) { - mCircuitItem = CI.getNumberedCircuit(0).getItem(); - } - if (mCircuitItem2 == null) { - mCircuitItem2 = CI.getNumberedBioCircuit(0).getItem(); - } - if (mCircuitItem3 == null) { - mCircuitItem3 = CI.getNumberedAdvancedCircuit(0).getItem(); - } - if (mCircuitItem != null && mCircuitItem2 != null && mCircuitItem3 != null) { - if (itemstack != null) { - if (itemstack.getItem() == mCircuitItem || itemstack.getItem() == mCircuitItem2 || itemstack.getItem() == mCircuitItem3) { - if (aLockedCircuitNumber == -1) { - isValid = true; - } - else { - if (itemstack.getItemDamage() == aLockedCircuitNumber) { - isValid = true; - } - } - } - } - } - return isValid; - } + public static synchronized boolean isItemValidForSlot(int aLockedCircuitNumber, final ItemStack itemstack) { + boolean isValid = false; + if (mCircuitItem == null) { + mCircuitItem = CI.getNumberedCircuit(0).getItem(); + } + if (mCircuitItem2 == null) { + mCircuitItem2 = CI.getNumberedBioCircuit(0).getItem(); + } + if (mCircuitItem3 == null) { + mCircuitItem3 = CI.getNumberedAdvancedCircuit(0).getItem(); + } + if (mCircuitItem != null && mCircuitItem2 != null && mCircuitItem3 != null) { + if (itemstack != null) { + if (itemstack.getItem() == mCircuitItem + || itemstack.getItem() == mCircuitItem2 + || itemstack.getItem() == mCircuitItem3) { + if (aLockedCircuitNumber == -1) { + isValid = true; + } else { + if (itemstack.getItemDamage() == aLockedCircuitNumber) { + isValid = true; + } + } + } + } + } + return isValid; + } - /** - * Returns the circuit type. -1 is invalid, 0 is standard, 1 is GT++ bio. - * @param itemstack - the Circuit Stack. - * @return - */ - public static synchronized int isRegularProgrammableCircuit(final ItemStack itemstack) { - if (mCircuitItem == null) { - mCircuitItem = CI.getNumberedCircuit(0).getItem(); - } - if (mCircuitItem2 == null) { - mCircuitItem2 = CI.getNumberedBioCircuit(0).getItem(); - } - if (mCircuitItem3 == null) { - mCircuitItem3 = CI.getNumberedAdvancedCircuit(0).getItem(); - } - if (mCircuitItem != null && mCircuitItem2 != null && mCircuitItem3 != null) { - if (itemstack != null) { - if (itemstack.getItem() == mCircuitItem || itemstack.getItem() == mCircuitItem2 || itemstack.getItem() == mCircuitItem3) { - if (itemstack.getItem() == mCircuitItem) { - return 0; - } - else if (itemstack.getItem() == mCircuitItem2) { - return 1; - } - else if (itemstack.getItem() == mCircuitItem3) { - return 2; - } - } - } - } - return -1; - } + /** + * Returns the circuit type. -1 is invalid, 0 is standard, 1 is GT++ bio. + * @param itemstack - the Circuit Stack. + * @return + */ + public static synchronized int isRegularProgrammableCircuit(final ItemStack itemstack) { + if (mCircuitItem == null) { + mCircuitItem = CI.getNumberedCircuit(0).getItem(); + } + if (mCircuitItem2 == null) { + mCircuitItem2 = CI.getNumberedBioCircuit(0).getItem(); + } + if (mCircuitItem3 == null) { + mCircuitItem3 = CI.getNumberedAdvancedCircuit(0).getItem(); + } + if (mCircuitItem != null && mCircuitItem2 != null && mCircuitItem3 != null) { + if (itemstack != null) { + if (itemstack.getItem() == mCircuitItem + || itemstack.getItem() == mCircuitItem2 + || itemstack.getItem() == mCircuitItem3) { + if (itemstack.getItem() == mCircuitItem) { + return 0; + } else if (itemstack.getItem() == mCircuitItem2) { + return 1; + } else if (itemstack.getItem() == mCircuitItem3) { + return 2; + } + } + } + } + return -1; + } - @Override - public int getSlotStackLimit() { - return 64; - } + @Override + public int getSlotStackLimit() { + return 64; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotItemBackpackInv.java b/src/main/java/gtPlusPlus/core/slots/SlotItemBackpackInv.java index 3aa551f966..7711858dae 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotItemBackpackInv.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotItemBackpackInv.java @@ -1,26 +1,25 @@ package gtPlusPlus.core.slots; +import gtPlusPlus.core.item.base.BaseItemBackpack; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import gtPlusPlus.core.item.base.BaseItemBackpack; - public class SlotItemBackpackInv extends Slot { - public SlotItemBackpackInv(final IInventory inv, final int index, final int xPos, final int yPos) { - super(inv, index, xPos, yPos); - } + public SlotItemBackpackInv(final IInventory inv, final int index, final int xPos, final int yPos) { + super(inv, index, xPos, yPos); + } - // This is the only method we need to override so that - // we can't place our inventory-storing Item within - // its own inventory (thus making it permanently inaccessible) - // as well as preventing abuse of storing backpacks within backpacks - /** - * Check if the stack is a valid item for this slot. - */ - @Override - public boolean isItemValid(final ItemStack itemstack) { - // Everything returns true except an instance of our Item - return !(itemstack.getItem() instanceof BaseItemBackpack); - } -} \ No newline at end of file + // This is the only method we need to override so that + // we can't place our inventory-storing Item within + // its own inventory (thus making it permanently inaccessible) + // as well as preventing abuse of storing backpacks within backpacks + /** + * Check if the stack is a valid item for this slot. + */ + @Override + public boolean isItemValid(final ItemStack itemstack) { + // Everything returns true except an instance of our Item + return !(itemstack.getItem() instanceof BaseItemBackpack); + } +} diff --git a/src/main/java/gtPlusPlus/core/slots/SlotJukebox.java b/src/main/java/gtPlusPlus/core/slots/SlotJukebox.java index 0f8af988a1..1351e5c188 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotJukebox.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotJukebox.java @@ -7,31 +7,29 @@ import net.minecraft.item.ItemStack; public class SlotJukebox extends SlotGeneric { - private final boolean isDisplay; - - - public SlotJukebox(IInventory inventory, int x, int y, int z) { - this(inventory, x, y, z, false); - } - - public SlotJukebox(IInventory inventory, int x, int y, int z, boolean display) { - super(inventory, x, y, z); - isDisplay = display; - } - - @Override - public boolean isItemValid(ItemStack itemstack) { - return (itemstack != null && itemstack.getItem() instanceof ItemRecord); - } - - @Override - public int getSlotStackLimit() { - return 1; - } - - @Override - public boolean canTakeStack(EntityPlayer p_82869_1_) { - return !isDisplay; - } - + private final boolean isDisplay; + + public SlotJukebox(IInventory inventory, int x, int y, int z) { + this(inventory, x, y, z, false); + } + + public SlotJukebox(IInventory inventory, int x, int y, int z, boolean display) { + super(inventory, x, y, z); + isDisplay = display; + } + + @Override + public boolean isItemValid(ItemStack itemstack) { + return (itemstack != null && itemstack.getItem() instanceof ItemRecord); + } + + @Override + public int getSlotStackLimit() { + return 1; + } + + @Override + public boolean canTakeStack(EntityPlayer p_82869_1_) { + return !isDisplay; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotLockedInput.java b/src/main/java/gtPlusPlus/core/slots/SlotLockedInput.java index c67f8acfeb..41a3236275 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotLockedInput.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotLockedInput.java @@ -1,57 +1,53 @@ package gtPlusPlus.core.slots; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - import gtPlusPlus.core.util.reflect.ReflectionUtils; -import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_TieredChest; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; public class SlotLockedInput extends Slot { - private ItemStack mLockStack; - private final IGregTechTileEntity mEntity; - private boolean mChecked = false; - - public SlotLockedInput(final IGregTechTileEntity inventory, final int index, final int x, final int y, ItemStack lockStack) { - super(inventory, index, x, y); - mLockStack = lockStack; - mEntity = inventory; - } - - @Override - public boolean isItemValid(final ItemStack itemstack) { - if (mEntity == null) { - return false; - } - else { - if (!mChecked) { - try { - mLockStack = (ItemStack) ReflectionUtils.getField(this.mEntity.getMetaTileEntity().getClass(), "mItemStack").get(this.mEntity.getMetaTileEntity()); - } - catch (Throwable t) { - t.printStackTrace(); - mLockStack = null; - } - mChecked = true; - } - } - - if (mLockStack == null) { - return true; - } - else { - if (ItemStack.areItemStacksEqual(itemstack, mLockStack)) { - return true; - } - } - return false; - } - - @Override - public int getSlotStackLimit() { - return mLockStack == null ? 64 : mLockStack.getMaxStackSize(); - } - + private ItemStack mLockStack; + private final IGregTechTileEntity mEntity; + private boolean mChecked = false; + + public SlotLockedInput( + final IGregTechTileEntity inventory, final int index, final int x, final int y, ItemStack lockStack) { + super(inventory, index, x, y); + mLockStack = lockStack; + mEntity = inventory; + } + + @Override + public boolean isItemValid(final ItemStack itemstack) { + if (mEntity == null) { + return false; + } else { + if (!mChecked) { + try { + mLockStack = (ItemStack) ReflectionUtils.getField( + this.mEntity.getMetaTileEntity().getClass(), "mItemStack") + .get(this.mEntity.getMetaTileEntity()); + } catch (Throwable t) { + t.printStackTrace(); + mLockStack = null; + } + mChecked = true; + } + } + + if (mLockStack == null) { + return true; + } else { + if (ItemStack.areItemStacksEqual(itemstack, mLockStack)) { + return true; + } + } + return false; + } + + @Override + public int getSlotStackLimit() { + return mLockStack == null ? 64 : mLockStack.getMaxStackSize(); + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotLunchBox.java b/src/main/java/gtPlusPlus/core/slots/SlotLunchBox.java index bb82a28936..341921814f 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotLunchBox.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotLunchBox.java @@ -1,30 +1,28 @@ package gtPlusPlus.core.slots; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.minecraft.FoodUtils; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.util.minecraft.FoodUtils; - public class SlotLunchBox extends SlotGtTool { - - public SlotLunchBox(final IInventory base, final int x, final int y, final int z) { - super(base, x, y, z); - } - - @Override - public boolean isItemValid(final ItemStack itemstack) { - return isItemValid_STATIC(itemstack); - } - - public static boolean isItemValid_STATIC(final ItemStack itemstack) { - if ((itemstack.getItem() instanceof ItemFood) || (FoodUtils.isFood(itemstack))) { - Logger.WARNING(itemstack.getDisplayName() + " is a valid food."); - return true; - } - Logger.WARNING(itemstack.getDisplayName() + " is not a valid food."); - return false; - } + public SlotLunchBox(final IInventory base, final int x, final int y, final int z) { + super(base, x, y, z); + } + + @Override + public boolean isItemValid(final ItemStack itemstack) { + return isItemValid_STATIC(itemstack); + } + + public static boolean isItemValid_STATIC(final ItemStack itemstack) { + if ((itemstack.getItem() instanceof ItemFood) || (FoodUtils.isFood(itemstack))) { + Logger.WARNING(itemstack.getDisplayName() + " is a valid food."); + return true; + } + Logger.WARNING(itemstack.getDisplayName() + " is not a valid food."); + return false; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotMagicToolBag.java b/src/main/java/gtPlusPlus/core/slots/SlotMagicToolBag.java index d555f10a44..6427dccc69 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotMagicToolBag.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotMagicToolBag.java @@ -1,29 +1,28 @@ package gtPlusPlus.core.slots; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.minecraft.FoodUtils; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.util.minecraft.FoodUtils; public class SlotMagicToolBag extends SlotGtTool { - - public SlotMagicToolBag(final IInventory base, final int x, final int y, final int z) { - super(base, x, y, z); - } - @Override - public boolean isItemValid(final ItemStack itemstack) { - return isItemValid_STATIC(itemstack); - } - - public static boolean isItemValid_STATIC(final ItemStack itemstack) { - if ((itemstack.getItem() instanceof ItemFood) || (FoodUtils.isFood(itemstack))) { - Logger.WARNING(itemstack.getDisplayName() + " is a valid food."); - return true; - } - Logger.WARNING(itemstack.getDisplayName() + " is not a valid food."); - return false; - } - + public SlotMagicToolBag(final IInventory base, final int x, final int y, final int z) { + super(base, x, y, z); + } + + @Override + public boolean isItemValid(final ItemStack itemstack) { + return isItemValid_STATIC(itemstack); + } + + public static boolean isItemValid_STATIC(final ItemStack itemstack) { + if ((itemstack.getItem() instanceof ItemFood) || (FoodUtils.isFood(itemstack))) { + Logger.WARNING(itemstack.getDisplayName() + " is a valid food."); + return true; + } + Logger.WARNING(itemstack.getDisplayName() + " is not a valid food."); + return false; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotModularBauble.java b/src/main/java/gtPlusPlus/core/slots/SlotModularBauble.java index 4aef5bc877..47a3beb393 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotModularBauble.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotModularBauble.java @@ -1,32 +1,30 @@ package gtPlusPlus.core.slots; +import gtPlusPlus.core.item.bauble.ModularBauble; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import gtPlusPlus.core.item.bauble.ModularBauble; - public class SlotModularBauble extends Slot { - public SlotModularBauble(final IInventory inventory, final int slot, final int x, final int y) { - super(inventory, slot, x, y); - - } - - @Override - public boolean isItemValid(final ItemStack itemstack) { - boolean isValid = false; - - if (itemstack != null) { - if (itemstack.getItem() instanceof ModularBauble) { - isValid = true; - } - } - return isValid; - } - - @Override - public int getSlotStackLimit() { - return 1; - } + public SlotModularBauble(final IInventory inventory, final int slot, final int x, final int y) { + super(inventory, slot, x, y); + } + + @Override + public boolean isItemValid(final ItemStack itemstack) { + boolean isValid = false; + + if (itemstack != null) { + if (itemstack.getItem() instanceof ModularBauble) { + isValid = true; + } + } + return isValid; + } + + @Override + public int getSlotStackLimit() { + return 1; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotModularBaubleUpgrades.java b/src/main/java/gtPlusPlus/core/slots/SlotModularBaubleUpgrades.java index dae62f0415..f73f27b788 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotModularBaubleUpgrades.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotModularBaubleUpgrades.java @@ -2,55 +2,54 @@ package gtPlusPlus.core.slots; import static gtPlusPlus.core.tileentities.machines.TileEntityModularityTable.*; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.core.util.minecraft.ModularArmourUtils.BT; +import gtPlusPlus.core.util.minecraft.ModularArmourUtils.Modifiers; import java.util.Iterator; import java.util.Map.Entry; - import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.data.Pair; -import gtPlusPlus.core.util.minecraft.ModularArmourUtils.BT; -import gtPlusPlus.core.util.minecraft.ModularArmourUtils.Modifiers; - public class SlotModularBaubleUpgrades extends Slot { - public SlotModularBaubleUpgrades(final IInventory inventory, final int slot, final int x, final int y) { - super(inventory, slot, x, y); - - } - - @Override - public boolean isItemValid(final ItemStack itemstack) { - boolean isValid = false; - if (itemstack != null) { - Logger.INFO("trying to insert " + itemstack.getDisplayName()); - Logger.INFO("Valid Upgrade count: " + mValidUpgradeList.size()); - - Iterator> it = mValidUpgradeListFormChange.entrySet().iterator(); - while (it.hasNext()) { - Entry pair = it.next(); - if (pair.getKey().getItem() == itemstack.getItem() - && pair.getKey().getItemDamage() == itemstack.getItemDamage()) { - isValid = true; - } - } - - Iterator>> it2 = mValidUpgradeList.entrySet().iterator(); - while (it2.hasNext()) { - Entry> pair = it2.next(); - if (pair.getKey().getItem() == itemstack.getItem() - && pair.getKey().getItemDamage() == itemstack.getItemDamage()) { - isValid = true; - } - } - } - return isValid; - } - - @Override - public int getSlotStackLimit() { - return 64; - } + public SlotModularBaubleUpgrades(final IInventory inventory, final int slot, final int x, final int y) { + super(inventory, slot, x, y); + } + + @Override + public boolean isItemValid(final ItemStack itemstack) { + boolean isValid = false; + if (itemstack != null) { + Logger.INFO("trying to insert " + itemstack.getDisplayName()); + Logger.INFO("Valid Upgrade count: " + mValidUpgradeList.size()); + + Iterator> it = + mValidUpgradeListFormChange.entrySet().iterator(); + while (it.hasNext()) { + Entry pair = it.next(); + if (pair.getKey().getItem() == itemstack.getItem() + && pair.getKey().getItemDamage() == itemstack.getItemDamage()) { + isValid = true; + } + } + + Iterator>> it2 = + mValidUpgradeList.entrySet().iterator(); + while (it2.hasNext()) { + Entry> pair = it2.next(); + if (pair.getKey().getItem() == itemstack.getItem() + && pair.getKey().getItemDamage() == itemstack.getItemDamage()) { + isValid = true; + } + } + } + return isValid; + } + + @Override + public int getSlotStackLimit() { + return 64; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotNoInput.java b/src/main/java/gtPlusPlus/core/slots/SlotNoInput.java index 1a1cf62e2b..d4e8696075 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotNoInput.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotNoInput.java @@ -6,18 +6,17 @@ import net.minecraft.item.ItemStack; public class SlotNoInput extends Slot { - public SlotNoInput(final IInventory inventory, final int index, final int x, final int y) { - super(inventory, index, x, y); - } + public SlotNoInput(final IInventory inventory, final int index, final int x, final int y) { + super(inventory, index, x, y); + } - @Override - public boolean isItemValid(final ItemStack itemstack) { - return false; - } - - @Override - public int getSlotStackLimit() { - return 0; - } + @Override + public boolean isItemValid(final ItemStack itemstack) { + return false; + } + @Override + public int getSlotStackLimit() { + return 0; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotNoInputLogging.java b/src/main/java/gtPlusPlus/core/slots/SlotNoInputLogging.java index 762714ac94..230a299d41 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotNoInputLogging.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotNoInputLogging.java @@ -8,29 +8,27 @@ import net.minecraft.item.ItemStack; public class SlotNoInputLogging extends SlotNoInput { - private final int aSlotIndex; - - public SlotNoInputLogging(final IInventory inventory, final int index, final int x, final int y) { - super(inventory, index, x, y); - aSlotIndex = index; - Logger.INFO("Slot "+index+" is doing logging"); - } + private final int aSlotIndex; - @Override - public boolean isItemValid(final ItemStack itemstack) { - if (ItemUtils.checkForInvalidItems(itemstack)) { - Logger.INFO("Tried Inserting "+ItemUtils.getItemName(itemstack)+" into slot "+aSlotIndex); - Block b = Block.getBlockFromItem(itemstack.getItem()); - Logger.INFO(""+itemstack.getUnlocalizedName()); - if (b != null) { - Logger.INFO(""+b.getLocalizedName()); - Logger.INFO(""+b.getUnlocalizedName()); - } - } - else { - Logger.INFO("Bad Itemstack"); - } - return false; - } + public SlotNoInputLogging(final IInventory inventory, final int index, final int x, final int y) { + super(inventory, index, x, y); + aSlotIndex = index; + Logger.INFO("Slot " + index + " is doing logging"); + } + @Override + public boolean isItemValid(final ItemStack itemstack) { + if (ItemUtils.checkForInvalidItems(itemstack)) { + Logger.INFO("Tried Inserting " + ItemUtils.getItemName(itemstack) + " into slot " + aSlotIndex); + Block b = Block.getBlockFromItem(itemstack.getItem()); + Logger.INFO("" + itemstack.getUnlocalizedName()); + if (b != null) { + Logger.INFO("" + b.getLocalizedName()); + Logger.INFO("" + b.getUnlocalizedName()); + } + } else { + Logger.INFO("Bad Itemstack"); + } + return false; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotOutput.java b/src/main/java/gtPlusPlus/core/slots/SlotOutput.java index f22e0645f5..dc469b32a4 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotOutput.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotOutput.java @@ -1,96 +1,99 @@ package gtPlusPlus.core.slots; import cpw.mods.fml.common.FMLCommonHandler; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; - import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; public class SlotOutput extends SlotCrafting { - private final IInventory craftMatrix; - private final EntityPlayer thePlayer; - private int amountCrafted; + private final IInventory craftMatrix; + private final EntityPlayer thePlayer; + private int amountCrafted; - public SlotOutput(final EntityPlayer player, final InventoryCrafting craftingInventory, - final IInventory p_i45790_3_, final int slotIndex, final int xPosition, final int yPosition) { - super(player, craftingInventory, p_i45790_3_, slotIndex, xPosition, yPosition); - this.thePlayer = player; - this.craftMatrix = craftingInventory; - } + public SlotOutput( + final EntityPlayer player, + final InventoryCrafting craftingInventory, + final IInventory p_i45790_3_, + final int slotIndex, + final int xPosition, + final int yPosition) { + super(player, craftingInventory, p_i45790_3_, slotIndex, xPosition, yPosition); + this.thePlayer = player; + this.craftMatrix = craftingInventory; + } - /** - * Check if the stack is a valid item for this slot. Always true beside for - * the armor slots. - */ - @Override - public boolean isItemValid(final ItemStack par1ItemStack) { - return false; - } + /** + * Check if the stack is a valid item for this slot. Always true beside for + * the armor slots. + */ + @Override + public boolean isItemValid(final ItemStack par1ItemStack) { + return false; + } - /** - * Decrease the size of the stack in slot (first int arg) by the amount of - * the second int arg. Returns the new stack. - */ - @Override - public ItemStack decrStackSize(final int par1) { - if (this.getHasStack()) { - this.amountCrafted += Math.min(par1, this.getStack().stackSize); - } - return super.decrStackSize(par1); - } + /** + * Decrease the size of the stack in slot (first int arg) by the amount of + * the second int arg. Returns the new stack. + */ + @Override + public ItemStack decrStackSize(final int par1) { + if (this.getHasStack()) { + this.amountCrafted += Math.min(par1, this.getStack().stackSize); + } + return super.decrStackSize(par1); + } - /** - * the itemStack passed in is the output - ie, iron ingots, and pickaxes, - * not ore and wood. Typically increases an internal count then calls - * onCrafting(item). - */ - @Override - protected void onCrafting(final ItemStack par1ItemStack, final int par2) { - this.amountCrafted += par2; - this.onCrafting(par1ItemStack); - } + /** + * the itemStack passed in is the output - ie, iron ingots, and pickaxes, + * not ore and wood. Typically increases an internal count then calls + * onCrafting(item). + */ + @Override + protected void onCrafting(final ItemStack par1ItemStack, final int par2) { + this.amountCrafted += par2; + this.onCrafting(par1ItemStack); + } - /** - * the itemStack passed in is the output - ie, iron ingots, and pickaxes, - * not ore and wood. - */ - @Override - protected void onCrafting(final ItemStack stack) { - stack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted); - this.amountCrafted = 0; - } + /** + * the itemStack passed in is the output - ie, iron ingots, and pickaxes, + * not ore and wood. + */ + @Override + protected void onCrafting(final ItemStack stack) { + stack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted); + this.amountCrafted = 0; + } - @Override - public void onPickupFromSlot(final EntityPlayer playerIn, final ItemStack stack) { - { - FMLCommonHandler.instance().firePlayerCraftingEvent(playerIn, stack, this.craftMatrix); - this.onCrafting(stack); - for (int i = 0; i < this.craftMatrix.getSizeInventory(); ++i) { - final ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i); - if (itemstack1 != null) { - this.craftMatrix.decrStackSize(i, 1); - if (itemstack1.getItem().hasContainerItem(itemstack1)) { - ItemStack itemstack2 = itemstack1.getItem().getContainerItem(itemstack1); - if (itemstack2.isItemStackDamageable() - && (itemstack2.getItemDamage() > itemstack2.getMaxDamage())) { - MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(this.thePlayer, itemstack2)); - itemstack2 = null; - } - if (!this.thePlayer.inventory.addItemStackToInventory(itemstack2)) { - if (this.craftMatrix.getStackInSlot(i) == null) { - this.craftMatrix.setInventorySlotContents(i, itemstack2); - } else { - this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false); - } - } - } - } - } - } - } -} \ No newline at end of file + @Override + public void onPickupFromSlot(final EntityPlayer playerIn, final ItemStack stack) { + { + FMLCommonHandler.instance().firePlayerCraftingEvent(playerIn, stack, this.craftMatrix); + this.onCrafting(stack); + for (int i = 0; i < this.craftMatrix.getSizeInventory(); ++i) { + final ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i); + if (itemstack1 != null) { + this.craftMatrix.decrStackSize(i, 1); + if (itemstack1.getItem().hasContainerItem(itemstack1)) { + ItemStack itemstack2 = itemstack1.getItem().getContainerItem(itemstack1); + if (itemstack2.isItemStackDamageable() + && (itemstack2.getItemDamage() > itemstack2.getMaxDamage())) { + MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(this.thePlayer, itemstack2)); + itemstack2 = null; + } + if (!this.thePlayer.inventory.addItemStackToInventory(itemstack2)) { + if (this.craftMatrix.getStackInSlot(i) == null) { + this.craftMatrix.setInventorySlotContents(i, itemstack2); + } else { + this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false); + } + } + } + } + } + } + } +} diff --git a/src/main/java/gtPlusPlus/core/slots/SlotPollutionScrubber.java b/src/main/java/gtPlusPlus/core/slots/SlotPollutionScrubber.java index 6dd3745d09..7025943908 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotPollutionScrubber.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotPollutionScrubber.java @@ -1,66 +1,67 @@ package gtPlusPlus.core.slots; -import java.util.HashMap; - import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.item.general.ItemAirFilter; import gtPlusPlus.core.item.general.ItemBasicScrubberTurbine; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; +import java.util.HashMap; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; public class SlotPollutionScrubber extends Slot { - private final int mType; - private final int mTier; - - private static HashMap mConveyorMap = new HashMap(); - - static { - for (int i=0; i<(CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK ? 9 : 5); i++) { - mConveyorMap.put(i, CI.getConveyor(i, 1)); - } - } + private final int mType; + private final int mTier; + + private static HashMap mConveyorMap = new HashMap(); + + static { + for (int i = 0; i < (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK ? 9 : 5); i++) { + mConveyorMap.put(i, CI.getConveyor(i, 1)); + } + } - public SlotPollutionScrubber(final int aType, final int aTier, final IInventory inventory, final int slot, final int x, final int y) { - super(inventory, slot, x, y); - mType = aType; - mTier = aTier; - } + public SlotPollutionScrubber( + final int aType, final int aTier, final IInventory inventory, final int slot, final int x, final int y) { + super(inventory, slot, x, y); + mType = aType; + mTier = aTier; + } - @Override - public synchronized boolean isItemValid(final ItemStack itemstack) { - return isItemValidForSlot(this, itemstack); - } + @Override + public synchronized boolean isItemValid(final ItemStack itemstack) { + return isItemValidForSlot(this, itemstack); + } - public static synchronized boolean isItemValidForSlot(final SlotPollutionScrubber aSlot, final ItemStack itemstack) { - if (aSlot.mType == 0) { - if (itemstack.getItem() instanceof ItemBasicScrubberTurbine) { - return true; - } - if (itemstack.getItem() instanceof GT_MetaGenerated_Tool && itemstack.getItemDamage() >= 170 && itemstack.getItemDamage() <= 179){ - return true; - } - } - else if (aSlot.mType == 1) { - if (itemstack.getItem() instanceof ItemAirFilter) { - return true; - } - } - else if (aSlot.mType == 2) { - ItemStack aConveyorStack = mConveyorMap.get(aSlot.mTier); - if (GT_Utility.areStacksEqual(itemstack, aConveyorStack, true)) { - return true; - } - } - return false; - } + public static synchronized boolean isItemValidForSlot( + final SlotPollutionScrubber aSlot, final ItemStack itemstack) { + if (aSlot.mType == 0) { + if (itemstack.getItem() instanceof ItemBasicScrubberTurbine) { + return true; + } + if (itemstack.getItem() instanceof GT_MetaGenerated_Tool + && itemstack.getItemDamage() >= 170 + && itemstack.getItemDamage() <= 179) { + return true; + } + } else if (aSlot.mType == 1) { + if (itemstack.getItem() instanceof ItemAirFilter) { + return true; + } + } else if (aSlot.mType == 2) { + ItemStack aConveyorStack = mConveyorMap.get(aSlot.mTier); + if (GT_Utility.areStacksEqual(itemstack, aConveyorStack, true)) { + return true; + } + } + return false; + } - @Override - public int getSlotStackLimit() { - return 1; - } + @Override + public int getSlotStackLimit() { + return 1; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotRTG.java b/src/main/java/gtPlusPlus/core/slots/SlotRTG.java index 181052cc57..f07fdd2894 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotRTG.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotRTG.java @@ -1,26 +1,23 @@ package gtPlusPlus.core.slots; +import ic2.core.Ic2Items; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import ic2.core.Ic2Items; - public class SlotRTG extends Slot { - public SlotRTG(final IInventory inventory, final int x, final int y, final int z) { - super(inventory, x, y, z); - - } - - @Override - public boolean isItemValid(final ItemStack itemstack) { - return itemstack.getItem().getClass() == Ic2Items.RTGPellets.getItem().getClass(); - } + public SlotRTG(final IInventory inventory, final int x, final int y, final int z) { + super(inventory, x, y, z); + } - @Override - public int getSlotStackLimit() { - return 1; - } + @Override + public boolean isItemValid(final ItemStack itemstack) { + return itemstack.getItem().getClass() == Ic2Items.RTGPellets.getItem().getClass(); + } + @Override + public int getSlotStackLimit() { + return 1; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotToolBox.java b/src/main/java/gtPlusPlus/core/slots/SlotToolBox.java index 87967b75b5..54b8f0bd92 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotToolBox.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotToolBox.java @@ -1,113 +1,119 @@ package gtPlusPlus.core.slots; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemTool; import gregtech.api.items.GT_MetaGenerated_Tool; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemTool; public class SlotToolBox extends SlotGtTool { - - private static final AutoMap mSupportedCustomTools = new AutoMap(); - - static { - //Look for Supported custom tool types - Class temp; - //IHL Pumps - temp = ReflectionUtils.getClass("ihl.handpump.IHLHandPump"); - if (temp != null) { - mSupportedCustomTools.put(temp); - temp = null; - } + private static final AutoMap mSupportedCustomTools = new AutoMap(); + + static { + // Look for Supported custom tool types + Class temp; + + // IHL Pumps + temp = ReflectionUtils.getClass("ihl.handpump.IHLHandPump"); + if (temp != null) { + mSupportedCustomTools.put(temp); + temp = null; + } + + // IC2 Electrics + temp = ReflectionUtils.getClass("ic2.api.item.IElectricItem"); + if (temp != null) { + mSupportedCustomTools.put(temp); + temp = null; + } + + // IC2 Boxables + temp = ReflectionUtils.getClass(" ic2.api.item.IBoxable"); + if (temp != null) { + mSupportedCustomTools.put(temp); + temp = null; + } + + // Tinkers Tools + temp = ReflectionUtils.getClass("tconstruct.library.tools.Weapon"); + if (temp != null) { + mSupportedCustomTools.put(temp); + temp = null; + } + // BattleGear Weapons + temp = ReflectionUtils.getClass("mods.battlegear2.api.weapons.IBattlegearWeapon"); + if (temp != null) { + mSupportedCustomTools.put(temp); + temp = null; + } + + // OpenMods + String[] OpenModsContent = new String[] { + "openblocks.common.item.ItemDevNull", + "openblocks.common.item.ItemHangGlider", + "openblocks.common.item.ItemWrench", + "openblocks.common.item.ItemSleepingBag" + }; + for (String t : OpenModsContent) { + temp = ReflectionUtils.getClass(t); + if (temp != null) { + mSupportedCustomTools.put(temp); + temp = null; + } + } + + // GC Wrench + temp = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.items.ItemUniversalWrench"); + if (temp != null) { + mSupportedCustomTools.put(temp); + temp = null; + } + + // EIO + String[] EioContent = new String[] { + "crazypants.enderio.api.tool.ITool", + "crazypants.enderio.item.ItemMagnet", + "crazypants.enderio.item.ItemConduitProbe" + }; + for (String t : EioContent) { + temp = ReflectionUtils.getClass(t); + if (temp != null) { + mSupportedCustomTools.put(temp); + temp = null; + } + } - //IC2 Electrics - temp = ReflectionUtils.getClass("ic2.api.item.IElectricItem"); - if (temp != null) { - mSupportedCustomTools.put(temp); - temp = null; - } - - //IC2 Boxables - temp = ReflectionUtils.getClass(" ic2.api.item.IBoxable"); - if (temp != null) { - mSupportedCustomTools.put(temp); - temp = null; - } - - //Tinkers Tools - temp = ReflectionUtils.getClass("tconstruct.library.tools.Weapon"); - if (temp != null) { - mSupportedCustomTools.put(temp); - temp = null; - } - //BattleGear Weapons - temp = ReflectionUtils.getClass("mods.battlegear2.api.weapons.IBattlegearWeapon"); - if (temp != null) { - mSupportedCustomTools.put(temp); - temp = null; - } - - - //OpenMods - String[] OpenModsContent = new String[] {"openblocks.common.item.ItemDevNull", "openblocks.common.item.ItemHangGlider", "openblocks.common.item.ItemWrench", "openblocks.common.item.ItemSleepingBag"}; - for (String t : OpenModsContent) { - temp = ReflectionUtils.getClass(t); - if (temp != null) { - mSupportedCustomTools.put(temp); - temp = null; - } - } + // Forestry + temp = ReflectionUtils.getClass("forestry.core.items.ItemForestryTool"); + if (temp != null) { + mSupportedCustomTools.put(temp); + temp = null; + } + } - //GC Wrench - temp = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.items.ItemUniversalWrench"); - if (temp != null) { - mSupportedCustomTools.put(temp); - temp = null; - } - - //EIO - String[] EioContent = new String[] {"crazypants.enderio.api.tool.ITool", "crazypants.enderio.item.ItemMagnet", "crazypants.enderio.item.ItemConduitProbe"}; - for (String t : EioContent) { - temp = ReflectionUtils.getClass(t); - if (temp != null) { - mSupportedCustomTools.put(temp); - temp = null; - } - } - - //Forestry - temp = ReflectionUtils.getClass("forestry.core.items.ItemForestryTool"); - if (temp != null) { - mSupportedCustomTools.put(temp); - temp = null; - } - } - - public SlotToolBox(final IInventory base, final int x, final int y, final int z) { - super(base, x, y, z); - } + public SlotToolBox(final IInventory base, final int x, final int y, final int z) { + super(base, x, y, z); + } - @Override - public boolean isItemValid(final ItemStack itemstack) { - return isItemValid_STATIC(itemstack); - } - - public static boolean isItemValid_STATIC(final ItemStack itemstack) { - if ((itemstack.getItem() instanceof GT_MetaGenerated_Tool) || (itemstack.getItem() instanceof ItemTool)) { - Logger.WARNING(itemstack.getDisplayName() + " is a valid Tool."); - return true; - } - for (Class C : mSupportedCustomTools) { - if (C.isInstance(itemstack.getItem())) { - return true; - } - } - Logger.WARNING(itemstack.getDisplayName() + " is not a valid Tool."); - return false; - } + @Override + public boolean isItemValid(final ItemStack itemstack) { + return isItemValid_STATIC(itemstack); + } + public static boolean isItemValid_STATIC(final ItemStack itemstack) { + if ((itemstack.getItem() instanceof GT_MetaGenerated_Tool) || (itemstack.getItem() instanceof ItemTool)) { + Logger.WARNING(itemstack.getDisplayName() + " is a valid Tool."); + return true; + } + for (Class C : mSupportedCustomTools) { + if (C.isInstance(itemstack.getItem())) { + return true; + } + } + Logger.WARNING(itemstack.getDisplayName() + " is not a valid Tool."); + return false; + } } diff --git a/src/main/java/gtPlusPlus/core/slots/SlotVolumetricFlask.java b/src/main/java/gtPlusPlus/core/slots/SlotVolumetricFlask.java index b8955f6dc8..0decde112d 100644 --- a/src/main/java/gtPlusPlus/core/slots/SlotVolumetricFlask.java +++ b/src/main/java/gtPlusPlus/core/slots/SlotVolumetricFlask.java @@ -8,23 +8,23 @@ import net.minecraft.item.ItemStack; public class SlotVolumetricFlask extends Slot { - public static Item mFlask; + public static Item mFlask; - public SlotVolumetricFlask(final IInventory inventory, final int slot, final int x, final int y) { - super(inventory, slot, x, y); - } + public SlotVolumetricFlask(final IInventory inventory, final int slot, final int x, final int y) { + super(inventory, slot, x, y); + } - @Override - public synchronized boolean isItemValid(final ItemStack itemstack) { - return isItemValidForSlot(itemstack); - } + @Override + public synchronized boolean isItemValid(final ItemStack itemstack) { + return isItemValidForSlot(itemstack); + } - public static synchronized boolean isItemValidForSlot(final ItemStack itemstack) { - return VolumetricFlaskHelper.isVolumetricFlask(itemstack); - } + public static synchronized boolean isItemValidForSlot(final ItemStack itemstack) { + return VolumetricFlaskHelper.isVolumetricFlask(itemstack); + } - @Override - public int getSlotStackLimit() { - return 16; - } + @Override + public int getSlotStackLimit() { + return 16; + } } diff --git a/src/main/java/gtPlusPlus/core/tileentities/ModTileEntities.java b/src/main/java/gtPlusPlus/core/tileentities/ModTileEntities.java index 0fcbb6a576..1ec58b0813 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/ModTileEntities.java +++ b/src/main/java/gtPlusPlus/core/tileentities/ModTileEntities.java @@ -26,42 +26,43 @@ import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; public class ModTileEntities { - public static void init() { - Logger.INFO("Registering Tile Entities."); - GameRegistry.registerTileEntity(TileEntityPooCollector.class, "TileEntityPooCollector"); - GameRegistry.registerTileEntity(TileEntityAdvPooCollector.class, "TileEntityAdvPooCollector"); - GameRegistry.registerTileEntity(TileEntityFishTrap.class, "TileFishTrap"); - GameRegistry.registerTileEntity(TileEntityFirepit.class, "TileFirePit"); - GameRegistry.registerTileEntity(TileEntityInfiniteFluid.class, "TileInfiniteFluid"); - GameRegistry.registerTileEntity(TileEntityProjectTable.class, "TileProjectTable"); - GameRegistry.registerTileEntity(TileEntityTradeTable.class, "TileTradeTable"); - GameRegistry.registerTileEntity(TileEntityModularityTable.class, "TileEntityModularityTable"); - GameRegistry.registerTileEntity(TileEntityXpConverter.class, "TileEntityXpConverter"); - GameRegistry.registerTileEntity(TileEntityGenericSpawner.class, "TileEntityGenericSpawner"); - GameRegistry.registerTileEntity(TileEntityCircuitProgrammer.class, "TileCircuitProgrammer"); - GameRegistry.registerTileEntity(TileEntityPlayerDoorBase.class, "TilePlayerDoorBase"); - GameRegistry.registerTileEntity(TileEntityDecayablesChest.class, "TileDecayablesChest"); - GameRegistry.registerTileEntity(TileEntitySuperJukebox.class, "TileEntitySuperJukebox"); - GameRegistry.registerTileEntity(TileEntitySuperLight.class, "TileEntitySuperLight"); - GameRegistry.registerTileEntity(TileEntityPestKiller.class, "TileEntityPestKiller"); - GameRegistry.registerTileEntity(TileEntityRoundRobinator.class, "TileEntityRoundRobinator"); - GameRegistry.registerTileEntity(TileEntityEggBox.class, "TileEggBox"); - - if (Meta_GT_Proxy.sDoesVolumetricFlaskExist) { - GameRegistry.registerTileEntity(TileEntityVolumetricFlaskSetter.class, "TileEntityVolumetricFlaskSetter"); - } - - //Mod TEs - if (LoadedMods.Thaumcraft){ - - } - blacklistTilesFromAcceleration(); - } - - private static void blacklistTilesFromAcceleration() { - Meta_GT_Proxy.setTileEntityClassAsBlacklistedInWorldAccelerator("gtPlusPlus.core.tileentities.general.TileEntityFishTrap"); - Meta_GT_Proxy.setTileEntityClassAsBlacklistedInWorldAccelerator("gtPlusPlus.core.tileentities.general.TileEntityDecayablesChest"); - Meta_GT_Proxy.setTileEntityClassAsBlacklistedInWorldAccelerator("gtPlusPlus.core.tileentities.general.TileEggBox"); - } + public static void init() { + Logger.INFO("Registering Tile Entities."); + GameRegistry.registerTileEntity(TileEntityPooCollector.class, "TileEntityPooCollector"); + GameRegistry.registerTileEntity(TileEntityAdvPooCollector.class, "TileEntityAdvPooCollector"); + GameRegistry.registerTileEntity(TileEntityFishTrap.class, "TileFishTrap"); + GameRegistry.registerTileEntity(TileEntityFirepit.class, "TileFirePit"); + GameRegistry.registerTileEntity(TileEntityInfiniteFluid.class, "TileInfiniteFluid"); + GameRegistry.registerTileEntity(TileEntityProjectTable.class, "TileProjectTable"); + GameRegistry.registerTileEntity(TileEntityTradeTable.class, "TileTradeTable"); + GameRegistry.registerTileEntity(TileEntityModularityTable.class, "TileEntityModularityTable"); + GameRegistry.registerTileEntity(TileEntityXpConverter.class, "TileEntityXpConverter"); + GameRegistry.registerTileEntity(TileEntityGenericSpawner.class, "TileEntityGenericSpawner"); + GameRegistry.registerTileEntity(TileEntityCircuitProgrammer.class, "TileCircuitProgrammer"); + GameRegistry.registerTileEntity(TileEntityPlayerDoorBase.class, "TilePlayerDoorBase"); + GameRegistry.registerTileEntity(TileEntityDecayablesChest.class, "TileDecayablesChest"); + GameRegistry.registerTileEntity(TileEntitySuperJukebox.class, "TileEntitySuperJukebox"); + GameRegistry.registerTileEntity(TileEntitySuperLight.class, "TileEntitySuperLight"); + GameRegistry.registerTileEntity(TileEntityPestKiller.class, "TileEntityPestKiller"); + GameRegistry.registerTileEntity(TileEntityRoundRobinator.class, "TileEntityRoundRobinator"); + GameRegistry.registerTileEntity(TileEntityEggBox.class, "TileEggBox"); + if (Meta_GT_Proxy.sDoesVolumetricFlaskExist) { + GameRegistry.registerTileEntity(TileEntityVolumetricFlaskSetter.class, "TileEntityVolumetricFlaskSetter"); + } + + // Mod TEs + if (LoadedMods.Thaumcraft) {} + + blacklistTilesFromAcceleration(); + } + + private static void blacklistTilesFromAcceleration() { + Meta_GT_Proxy.setTileEntityClassAsBlacklistedInWorldAccelerator( + "gtPlusPlus.core.tileentities.general.TileEntityFishTrap"); + Meta_GT_Proxy.setTileEntityClassAsBlacklistedInWorldAccelerator( + "gtPlusPlus.core.tileentities.general.TileEntityDecayablesChest"); + Meta_GT_Proxy.setTileEntityClassAsBlacklistedInWorldAccelerator( + "gtPlusPlus.core.tileentities.general.TileEggBox"); + } } diff --git a/src/main/java/gtPlusPlus/core/tileentities/base/TILE_ENTITY_BASE.java b/src/main/java/gtPlusPlus/core/tileentities/base/TILE_ENTITY_BASE.java index 839bcc353a..ff1484a984 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/base/TILE_ENTITY_BASE.java +++ b/src/main/java/gtPlusPlus/core/tileentities/base/TILE_ENTITY_BASE.java @@ -8,32 +8,32 @@ import net.minecraft.tileentity.TileEntity; public class TILE_ENTITY_BASE extends TileEntity { - @Override - public void writeToNBT(final NBTTagCompound tag) { - super.writeToNBT(tag); - this.writeCustomNBT(tag); - } - - @Override - public void readFromNBT(final NBTTagCompound tag) { - super.readFromNBT(tag); - this.readCustomNBT(tag); - } - - public void writeCustomNBT(final NBTTagCompound tag) {} - public void readCustomNBT(final NBTTagCompound tag) {} - - @Override - public Packet getDescriptionPacket() { - final NBTTagCompound tag = new NBTTagCompound(); - this.writeCustomNBT(tag); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, -999, tag); - } - - @Override - public void onDataPacket(final NetworkManager net, final S35PacketUpdateTileEntity packet) { - super.onDataPacket(net, packet); - this.readCustomNBT(packet.func_148857_g()); - } - + @Override + public void writeToNBT(final NBTTagCompound tag) { + super.writeToNBT(tag); + this.writeCustomNBT(tag); + } + + @Override + public void readFromNBT(final NBTTagCompound tag) { + super.readFromNBT(tag); + this.readCustomNBT(tag); + } + + public void writeCustomNBT(final NBTTagCompound tag) {} + + public void readCustomNBT(final NBTTagCompound tag) {} + + @Override + public Packet getDescriptionPacket() { + final NBTTagCompound tag = new NBTTagCompound(); + this.writeCustomNBT(tag); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, -999, tag); + } + + @Override + public void onDataPacket(final NetworkManager net, final S35PacketUpdateTileEntity packet) { + super.onDataPacket(net, packet); + this.readCustomNBT(packet.func_148857_g()); + } } diff --git a/src/main/java/gtPlusPlus/core/tileentities/base/TileBasicTank.java b/src/main/java/gtPlusPlus/core/tileentities/base/TileBasicTank.java index 671a49fca5..32a39a7096 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/base/TileBasicTank.java +++ b/src/main/java/gtPlusPlus/core/tileentities/base/TileBasicTank.java @@ -10,141 +10,197 @@ import net.minecraftforge.fluids.IFluidTank; public class TileBasicTank extends TileEntityBase implements IFluidHandler, IFluidTank { - public final BTF_FluidTank mTank; - - public TileBasicTank(int aMaxSlots, int aFluidCapacity) { - super(aMaxSlots); - mTank = new BTF_FluidTank(aFluidCapacity); - } - - @Override - public boolean onPreTick(long aTick) { - - if (this.isServerSide()) { - if (mTank.isFluidChangingAllowed() && mTank.getFillableStack() != null - && mTank.getFillableStack().amount <= 0) { - mTank.setFillableStack((FluidStack) null); - } - } - - return super.onPreTick(aTick); - - } - - - private final boolean canFillEx(ForgeDirection aSide, Fluid aFluid) { - return this.fill(aSide, new FluidStack(aFluid, 1), false) == 1; - } - - - private final boolean canDrainEx(ForgeDirection aSide, Fluid aFluid) { - return this.drain(aSide, new FluidStack(aFluid, 1), false) != null; - } - - - private final FluidTankInfo[] getTankInfoEx(ForgeDirection aSide) { - return mTank.getCapacity() <= 0 ? new FluidTankInfo[0] - : new FluidTankInfo[]{mTank.getInfo()}; - } - - private final int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { - return mTank.fill(aFluid, doFill); - } - - - private final int fillEx(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { - return this.fill_default(aSide, aFluid, doFill); - } - - - private final FluidStack drainEx(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) { - return mTank.getFluid() != null && aFluid != null && mTank.getFluid().isFluidEqual(aFluid) - ? mTank.drain(aFluid.amount, doDrain) - : null; - } - - - private final FluidStack drainEx(ForgeDirection aSide, int maxDrain, boolean doDrain) { - return mTank.drain(maxDrain, doDrain); - } - - - public boolean isLiquidInput(byte aSide) { - return true; - } - - public boolean isLiquidOutput(byte aSide) { - return true; - } - - @Override + public final BTF_FluidTank mTank; + + public TileBasicTank(int aMaxSlots, int aFluidCapacity) { + super(aMaxSlots); + mTank = new BTF_FluidTank(aFluidCapacity); + } + + @Override + public boolean onPreTick(long aTick) { + + if (this.isServerSide()) { + if (mTank.isFluidChangingAllowed() + && mTank.getFillableStack() != null + && mTank.getFillableStack().amount <= 0) { + mTank.setFillableStack((FluidStack) null); + } + } + + return super.onPreTick(aTick); + } + + private final boolean canFillEx(ForgeDirection aSide, Fluid aFluid) { + return this.fill(aSide, new FluidStack(aFluid, 1), false) == 1; + } + + private final boolean canDrainEx(ForgeDirection aSide, Fluid aFluid) { + return this.drain(aSide, new FluidStack(aFluid, 1), false) != null; + } + + private final FluidTankInfo[] getTankInfoEx(ForgeDirection aSide) { + return mTank.getCapacity() <= 0 ? new FluidTankInfo[0] : new FluidTankInfo[] {mTank.getInfo()}; + } + + private final int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + return mTank.fill(aFluid, doFill); + } + + private final int fillEx(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + return this.fill_default(aSide, aFluid, doFill); + } + + private final FluidStack drainEx(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) { + return mTank.getFluid() != null && aFluid != null && mTank.getFluid().isFluidEqual(aFluid) + ? mTank.drain(aFluid.amount, doDrain) + : null; + } + + private final FluidStack drainEx(ForgeDirection aSide, int maxDrain, boolean doDrain) { + return mTank.drain(maxDrain, doDrain); + } + + public boolean isLiquidInput(byte aSide) { + return true; + } + + public boolean isLiquidOutput(byte aSide) { + return true; + } + + @Override public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { - if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mInputDisabled) && (aSide == ForgeDirection.UNKNOWN || (this.isLiquidInput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid == null ? null : aFluid.getFluid(), this)))) - return this.fillEx(aSide, aFluid, doFill); + if (mTickTimer > 5 + && canAccessData() + && (mRunningThroughTick || !mInputDisabled) + && (aSide == ForgeDirection.UNKNOWN + || (this.isLiquidInput((byte) aSide.ordinal()) + && getCoverBehaviorAtSide((byte) aSide.ordinal()) + .letsFluidIn( + (byte) aSide.ordinal(), + getCoverIDAtSide((byte) aSide.ordinal()), + getCoverDataAtSide((byte) aSide.ordinal()), + aFluid == null ? null : aFluid.getFluid(), + this)))) return this.fillEx(aSide, aFluid, doFill); return 0; } @Override public FluidStack drain(ForgeDirection aSide, int maxDrain, boolean doDrain) { - if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mOutputDisabled) && (aSide == ForgeDirection.UNKNOWN || (this.isLiquidOutput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), this.getFluid() == null ? null : this.getFluid().getFluid(), this)))) - return this.drainEx(aSide, maxDrain, doDrain); + if (mTickTimer > 5 + && canAccessData() + && (mRunningThroughTick || !mOutputDisabled) + && (aSide == ForgeDirection.UNKNOWN + || (this.isLiquidOutput((byte) aSide.ordinal()) + && getCoverBehaviorAtSide((byte) aSide.ordinal()) + .letsFluidOut( + (byte) aSide.ordinal(), + getCoverIDAtSide((byte) aSide.ordinal()), + getCoverDataAtSide((byte) aSide.ordinal()), + this.getFluid() == null + ? null + : this.getFluid().getFluid(), + this)))) return this.drainEx(aSide, maxDrain, doDrain); return null; } @Override public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) { - if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mOutputDisabled) && (aSide == ForgeDirection.UNKNOWN || (this.isLiquidOutput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid == null ? null : aFluid.getFluid(), this)))) - return this.drainEx(aSide, aFluid, doDrain); + if (mTickTimer > 5 + && canAccessData() + && (mRunningThroughTick || !mOutputDisabled) + && (aSide == ForgeDirection.UNKNOWN + || (this.isLiquidOutput((byte) aSide.ordinal()) + && getCoverBehaviorAtSide((byte) aSide.ordinal()) + .letsFluidOut( + (byte) aSide.ordinal(), + getCoverIDAtSide((byte) aSide.ordinal()), + getCoverDataAtSide((byte) aSide.ordinal()), + aFluid == null ? null : aFluid.getFluid(), + this)))) return this.drainEx(aSide, aFluid, doDrain); return null; } @Override public boolean canFill(ForgeDirection aSide, Fluid aFluid) { - if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mInputDisabled) && (aSide == ForgeDirection.UNKNOWN || (this.isLiquidInput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid, this)))) - return this.canFillEx(aSide, aFluid); + if (mTickTimer > 5 + && canAccessData() + && (mRunningThroughTick || !mInputDisabled) + && (aSide == ForgeDirection.UNKNOWN + || (this.isLiquidInput((byte) aSide.ordinal()) + && getCoverBehaviorAtSide((byte) aSide.ordinal()) + .letsFluidIn( + (byte) aSide.ordinal(), + getCoverIDAtSide((byte) aSide.ordinal()), + getCoverDataAtSide((byte) aSide.ordinal()), + aFluid, + this)))) return this.canFillEx(aSide, aFluid); return false; } @Override public boolean canDrain(ForgeDirection aSide, Fluid aFluid) { - if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mOutputDisabled) && (aSide == ForgeDirection.UNKNOWN || (this.isLiquidOutput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid, this)))) - return this.canDrainEx(aSide, aFluid); + if (mTickTimer > 5 + && canAccessData() + && (mRunningThroughTick || !mOutputDisabled) + && (aSide == ForgeDirection.UNKNOWN + || (this.isLiquidOutput((byte) aSide.ordinal()) + && getCoverBehaviorAtSide((byte) aSide.ordinal()) + .letsFluidOut( + (byte) aSide.ordinal(), + getCoverIDAtSide((byte) aSide.ordinal()), + getCoverDataAtSide((byte) aSide.ordinal()), + aFluid, + this)))) return this.canDrainEx(aSide, aFluid); return false; } @Override public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { - if (canAccessData() && (aSide == ForgeDirection.UNKNOWN || (this.isLiquidInput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), null, this)) || (this.isLiquidOutput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), null, this)))) - return this.getTankInfoEx(aSide); - return new FluidTankInfo[]{}; - } - - @Override - public FluidStack getFluid() { - return mTank.getFluid(); - } - - @Override - public int getFluidAmount() { - return mTank.getFluidAmount(); - } - - @Override - public FluidTankInfo getInfo() { - return mTank.getInfo(); - } - - @Override - public int fill(FluidStack resource, boolean doFill) { - return mTank.fill(resource, doFill); - } - - @Override - public FluidStack drain(int maxDrain, boolean doDrain) { - return mTank.drain(maxDrain, doDrain); - } - - - - + if (canAccessData() + && (aSide == ForgeDirection.UNKNOWN + || (this.isLiquidInput((byte) aSide.ordinal()) + && getCoverBehaviorAtSide((byte) aSide.ordinal()) + .letsFluidIn( + (byte) aSide.ordinal(), + getCoverIDAtSide((byte) aSide.ordinal()), + getCoverDataAtSide((byte) aSide.ordinal()), + null, + this)) + || (this.isLiquidOutput((byte) aSide.ordinal()) + && getCoverBehaviorAtSide((byte) aSide.ordinal()) + .letsFluidOut( + (byte) aSide.ordinal(), + getCoverIDAtSide((byte) aSide.ordinal()), + getCoverDataAtSide((byte) aSide.ordinal()), + null, + this)))) return this.getTankInfoEx(aSide); + return new FluidTankInfo[] {}; + } + + @Override + public FluidStack getFluid() { + return mTank.getFluid(); + } + + @Override + public int getFluidAmount() { + return mTank.getFluidAmount(); + } + + @Override + public FluidTankInfo getInfo() { + return mTank.getInfo(); + } + + @Override + public int fill(FluidStack resource, boolean doFill) { + return mTank.fill(resource, doFill); + } + + @Override + public FluidStack drain(int maxDrain, boolean doDrain) { + return mTank.drain(maxDrain, doDrain); + } } diff --git a/src/main/java/gtPlusPlus/core/tileentities/base/TileEntityBase.java b/src/main/java/gtPlusPlus/core/tileentities/base/TileEntityBase.java index 5b67a318be..f52ce86a99 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/base/TileEntityBase.java +++ b/src/main/java/gtPlusPlus/core/tileentities/base/TileEntityBase.java @@ -1,7 +1,5 @@ package gtPlusPlus.core.tileentities.base; -import java.util.UUID; - import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; @@ -14,6 +12,12 @@ import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; import gregtech.api.util.ISerializableObject; +import gtPlusPlus.api.interfaces.ILazyCoverable; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.minecraft.BTF_Inventory; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +import ic2.api.Direction; +import java.util.UUID; import net.minecraft.block.Block; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -26,186 +30,182 @@ import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.IFluidHandler; -import gtPlusPlus.api.interfaces.ILazyCoverable; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.minecraft.BTF_Inventory; -import gtPlusPlus.core.util.data.ArrayUtils; -import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; -import ic2.api.Direction; public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregTechDeviceInformation, IDescribable { - private String customName; - public String mOwnerName = "null"; - public String mOwnerUUID = "null"; - private boolean mIsOwnerOP = false; - - public final BTF_Inventory mInventory; - - public TileEntityBase(int aCapacity) { - mInventory = new BTF_Inventory(aCapacity, this); - } - - public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag){ - if(!nbt.hasKey(tag)) - { - nbt.setTag(tag, new NBTTagCompound()); - } - return nbt.getCompoundTag(tag); - } - - @Override - public void writeToNBT(final NBTTagCompound nbt){ - super.writeToNBT(nbt); - if (this.hasCustomInventoryName()) { - nbt.setString("CustomName", this.getCustomName()); - } - nbt.setBoolean("mIsOwnerOP", this.mIsOwnerOP); - nbt.setString("mOwnerName", this.mOwnerName); - nbt.setString("mOwnerUUID", this.mOwnerUUID); - } - - @Override - public void readFromNBT(final NBTTagCompound nbt){ - - super.readFromNBT(nbt); - - if (nbt.hasKey("CustomName", 8)) { - this.setCustomName(nbt.getString("CustomName")); - } - - this.mIsOwnerOP = nbt.getBoolean("mIsOwnerOP"); - this.mOwnerName = nbt.getString("mOwnerName"); - this.mOwnerUUID = nbt.getString("mOwnerUUID"); - } - - @Override - public void updateEntity() { - long aTick = System.currentTimeMillis(); - this.isDead = false; - if (!firstTicked) { - onFirstTick(); - } - try{ - if (this.isServerSide()){ - onPreTick(aTick); - } - } catch (Throwable t){ - Logger.ERROR("Tile Entity Encountered an error in it's pre-tick stage."); - t.printStackTrace(); - } - try{ - if (this.isServerSide()){ - onTick(aTick); - } - } catch (Throwable t){ - Logger.ERROR("Tile Entity Encountered an error in it's tick stage."); - t.printStackTrace(); - } - try{ - if (this.isServerSide()){ - onPostTick(aTick); - } - } catch (Throwable t){ - Logger.ERROR("Tile Entity Encountered an error in it's post-tick stage."); - t.printStackTrace(); - } - } - - public boolean onPreTick(long aTick) { - return true; - } - - public boolean onTick(long aTick){ - try{ - if (this.isServerSide()){ - processRecipe(); - } - } catch (Throwable t){ - Logger.ERROR("Tile Entity Encountered an error in it's processing of a recipe stage."); - t.printStackTrace(); - } - return true; - } - - public boolean onPostTick(long aTick){ - return true; - } - - public boolean processRecipe(){ - return true; - } - - @Override - public boolean canUpdate() { - return true; - } - - public String getOwner(){ - if (this.mOwnerName == null){ - return "null"; - } - return this.mOwnerName; - } - - public UUID getOwnerUUID(){ - return UUID.fromString(this.mOwnerUUID); - } - - public boolean isOwnerOP() { - return mIsOwnerOP; - } - - public void setOwnerInformation(String mName, String mUUID, boolean mOP){ - if (isServerSide()){ - if (this.mOwnerName == null || this.mOwnerUUID == null || this.mOwnerName.equals("null") || this.mOwnerUUID.equals("null")){ - this.mOwnerName = mName; - this.mOwnerUUID = mUUID; - this.mIsOwnerOP = mOP; - } - } - } - - public boolean isServerSide(){ - if (this.hasWorldObj()){ - if (!this.getWorldObj().isRemote){ - return true; - } - } - return false; - } - - public final boolean isClientSide() { - return this.worldObj.isRemote; - } - - public String getCustomName() { - return this.customName; - } - - public void setCustomName(String customName) { - this.customName = customName; - } - - @Override - public String getInventoryName() { - return this.hasCustomInventoryName() ? this.customName : "container.tileentity.name"; - } - - @Override - public boolean hasCustomInventoryName() { - return this.customName != null && !this.customName.equals(""); - } - - @Override - public int getSizeInventory() { - return this.mInventory.getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(int aIndex) { - return this.mInventory.getStackInSlot(aIndex); - } + private String customName; + public String mOwnerName = "null"; + public String mOwnerUUID = "null"; + private boolean mIsOwnerOP = false; + + public final BTF_Inventory mInventory; + + public TileEntityBase(int aCapacity) { + mInventory = new BTF_Inventory(aCapacity, this); + } + + public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) { + if (!nbt.hasKey(tag)) { + nbt.setTag(tag, new NBTTagCompound()); + } + return nbt.getCompoundTag(tag); + } + + @Override + public void writeToNBT(final NBTTagCompound nbt) { + super.writeToNBT(nbt); + if (this.hasCustomInventoryName()) { + nbt.setString("CustomName", this.getCustomName()); + } + nbt.setBoolean("mIsOwnerOP", this.mIsOwnerOP); + nbt.setString("mOwnerName", this.mOwnerName); + nbt.setString("mOwnerUUID", this.mOwnerUUID); + } + + @Override + public void readFromNBT(final NBTTagCompound nbt) { + + super.readFromNBT(nbt); + + if (nbt.hasKey("CustomName", 8)) { + this.setCustomName(nbt.getString("CustomName")); + } + + this.mIsOwnerOP = nbt.getBoolean("mIsOwnerOP"); + this.mOwnerName = nbt.getString("mOwnerName"); + this.mOwnerUUID = nbt.getString("mOwnerUUID"); + } + + @Override + public void updateEntity() { + long aTick = System.currentTimeMillis(); + this.isDead = false; + if (!firstTicked) { + onFirstTick(); + } + try { + if (this.isServerSide()) { + onPreTick(aTick); + } + } catch (Throwable t) { + Logger.ERROR("Tile Entity Encountered an error in it's pre-tick stage."); + t.printStackTrace(); + } + try { + if (this.isServerSide()) { + onTick(aTick); + } + } catch (Throwable t) { + Logger.ERROR("Tile Entity Encountered an error in it's tick stage."); + t.printStackTrace(); + } + try { + if (this.isServerSide()) { + onPostTick(aTick); + } + } catch (Throwable t) { + Logger.ERROR("Tile Entity Encountered an error in it's post-tick stage."); + t.printStackTrace(); + } + } + + public boolean onPreTick(long aTick) { + return true; + } + + public boolean onTick(long aTick) { + try { + if (this.isServerSide()) { + processRecipe(); + } + } catch (Throwable t) { + Logger.ERROR("Tile Entity Encountered an error in it's processing of a recipe stage."); + t.printStackTrace(); + } + return true; + } + + public boolean onPostTick(long aTick) { + return true; + } + + public boolean processRecipe() { + return true; + } + + @Override + public boolean canUpdate() { + return true; + } + + public String getOwner() { + if (this.mOwnerName == null) { + return "null"; + } + return this.mOwnerName; + } + + public UUID getOwnerUUID() { + return UUID.fromString(this.mOwnerUUID); + } + + public boolean isOwnerOP() { + return mIsOwnerOP; + } + + public void setOwnerInformation(String mName, String mUUID, boolean mOP) { + if (isServerSide()) { + if (this.mOwnerName == null + || this.mOwnerUUID == null + || this.mOwnerName.equals("null") + || this.mOwnerUUID.equals("null")) { + this.mOwnerName = mName; + this.mOwnerUUID = mUUID; + this.mIsOwnerOP = mOP; + } + } + } + + public boolean isServerSide() { + if (this.hasWorldObj()) { + if (!this.getWorldObj().isRemote) { + return true; + } + } + return false; + } + + public final boolean isClientSide() { + return this.worldObj.isRemote; + } + + public String getCustomName() { + return this.customName; + } + + public void setCustomName(String customName) { + this.customName = customName; + } + + @Override + public String getInventoryName() { + return this.hasCustomInventoryName() ? this.customName : "container.tileentity.name"; + } + + @Override + public boolean hasCustomInventoryName() { + return this.customName != null && !this.customName.equals(""); + } + + @Override + public int getSizeInventory() { + return this.mInventory.getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(int aIndex) { + return this.mInventory.getStackInSlot(aIndex); + } @Override public ItemStack decrStackSize(int aIndex, int aAmount) { @@ -216,37 +216,37 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT return null; } - @Override - public ItemStack getStackInSlotOnClosing(int p_70304_1_) { - return this.mInventory.getStackInSlotOnClosing(p_70304_1_); - } + @Override + public ItemStack getStackInSlotOnClosing(int p_70304_1_) { + return this.mInventory.getStackInSlotOnClosing(p_70304_1_); + } - @Override - public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) { - this.mInventory.setInventorySlotContents(p_70299_1_, p_70299_2_); - } + @Override + public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) { + this.mInventory.setInventorySlotContents(p_70299_1_, p_70299_2_); + } - @Override - public int getInventoryStackLimit() { - return this.mInventory.getInventoryStackLimit(); - } + @Override + public int getInventoryStackLimit() { + return this.mInventory.getInventoryStackLimit(); + } - @Override - public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { - return this.mInventory.isUseableByPlayer(p_70300_1_); - } + @Override + public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { + return this.mInventory.isUseableByPlayer(p_70300_1_); + } - @Override - public void openInventory() { - this.mInventory.openInventory(); - } + @Override + public void openInventory() { + this.mInventory.openInventory(); + } - @Override - public void closeInventory() { - this.mInventory.closeInventory(); - } + @Override + public void closeInventory() { + this.mInventory.closeInventory(); + } - /** + /** * Can put aStack into Slot */ @Override @@ -260,8 +260,21 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT */ @Override public int[] getAccessibleSlotsFromSide(int aSide) { - if (canAccessData() && (getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, getCoverIDAtSide((byte) aSide), getCoverDataAtSide((byte) aSide), -1, this) || getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, getCoverIDAtSide((byte) aSide), getCoverDataAtSide((byte) aSide), -1, this))) - return mInventory.getAccessibleSlotsFromSide(aSide); + if (canAccessData() + && (getCoverBehaviorAtSide((byte) aSide) + .letsItemsOut( + (byte) aSide, + getCoverIDAtSide((byte) aSide), + getCoverDataAtSide((byte) aSide), + -1, + this) + || getCoverBehaviorAtSide((byte) aSide) + .letsItemsIn( + (byte) aSide, + getCoverIDAtSide((byte) aSide), + getCoverDataAtSide((byte) aSide), + -1, + this))) return mInventory.getAccessibleSlotsFromSide(aSide); return new int[0]; } @@ -270,7 +283,16 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT */ @Override public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { - return canAccessData() && (mRunningThroughTick || !mInputDisabled) && getCoverBehaviorAtSide((byte) aSide).letsItemsIn((byte) aSide, getCoverIDAtSide((byte) aSide), getCoverDataAtSide((byte) aSide), aIndex, this) && mInventory.canInsertItem(aIndex, aStack, aSide); + return canAccessData() + && (mRunningThroughTick || !mInputDisabled) + && getCoverBehaviorAtSide((byte) aSide) + .letsItemsIn( + (byte) aSide, + getCoverIDAtSide((byte) aSide), + getCoverDataAtSide((byte) aSide), + aIndex, + this) + && mInventory.canInsertItem(aIndex, aStack, aSide); } /** @@ -278,566 +300,612 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT */ @Override public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { - return canAccessData() && (mRunningThroughTick || !mOutputDisabled) && getCoverBehaviorAtSide((byte) aSide).letsItemsOut((byte) aSide, getCoverIDAtSide((byte) aSide), getCoverDataAtSide((byte) aSide), aIndex, this) && mInventory.canExtractItem(aIndex, aStack, aSide); - } - - - @Override - public boolean isValidSlot(int aIndex) { - return this.canAccessData() ? this.mInventory.isValidSlot(aIndex) : false; - } - - - - - private final GT_CoverBehavior[] mCoverBehaviors = new GT_CoverBehavior[] { GregTech_API.sNoBehavior, - GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, - GregTech_API.sNoBehavior }; - protected TileEntityBase mMetaTileEntity; - protected long mStoredEnergy = 0; - protected int mAverageEUInputIndex = 0, mAverageEUOutputIndex = 0; - protected boolean mReleaseEnergy = false; - protected int[] mAverageEUInput = new int[11], mAverageEUOutput = new int[11]; - private boolean[] mActiveEUInputs = new boolean[] { false, false, false, false, false, false }, - mActiveEUOutputs = new boolean[] { false, false, false, false, false, false }; - private byte[] mSidedRedstone = new byte[] { 15, 15, 15, 15, 15, 15 }; - private int[] mCoverSides = new int[] { 0, 0, 0, 0, 0, 0 }, mCoverData = new int[] { 0, 0, 0, 0, 0, 0 }, - mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING]; - private boolean mHasEnoughEnergy = true; - protected boolean mRunningThroughTick = false; - protected boolean mInputDisabled = false; - protected boolean mOutputDisabled = false; - private boolean mMuffler = false; - private boolean mLockUpgrade = false; - private boolean mActive = false; - private boolean mRedstone = false; - private boolean mWorkUpdate = false; - private boolean mSteamConverter = false; - private boolean mInventoryChanged = false; - private boolean mWorks = true; - private boolean mNeedsUpdate = true; - private boolean mNeedsBlockUpdate = true; - private boolean mSendClientData = false; - private boolean oRedstone = false; - private boolean mEnergyStateReady = false; - private byte mColor = 0, oColor = 0, mStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, - oTexturePage = 0, oLightValueClient = -1, oLightValue = -1, mLightValue = 0, mOtherUpgrades = 0, - mFacing = 0, oFacing = 0, mWorkData = 0; - private int mDisplayErrorCode = 0, oX = 0, oY = 0, oZ = 0, mTimeStatisticsIndex = 0, mLagWarningCount = 0; - private short mID = 0; - protected long mTickTimer = 0; - private long oOutput = 0; - private long mAcceptedAmperes = Long.MAX_VALUE; - - - /** - * Cover Support - */ - - public void issueClientUpdate() { - this.mSendClientData = true; - } - + return canAccessData() + && (mRunningThroughTick || !mOutputDisabled) + && getCoverBehaviorAtSide((byte) aSide) + .letsItemsOut( + (byte) aSide, + getCoverIDAtSide((byte) aSide), + getCoverDataAtSide((byte) aSide), + aIndex, + this) + && mInventory.canExtractItem(aIndex, aStack, aSide); + } + + @Override + public boolean isValidSlot(int aIndex) { + return this.canAccessData() ? this.mInventory.isValidSlot(aIndex) : false; + } + + private final GT_CoverBehavior[] mCoverBehaviors = new GT_CoverBehavior[] { + GregTech_API.sNoBehavior, + GregTech_API.sNoBehavior, + GregTech_API.sNoBehavior, + GregTech_API.sNoBehavior, + GregTech_API.sNoBehavior, + GregTech_API.sNoBehavior + }; + protected TileEntityBase mMetaTileEntity; + protected long mStoredEnergy = 0; + protected int mAverageEUInputIndex = 0, mAverageEUOutputIndex = 0; + protected boolean mReleaseEnergy = false; + protected int[] mAverageEUInput = new int[11], mAverageEUOutput = new int[11]; + private boolean[] mActiveEUInputs = new boolean[] {false, false, false, false, false, false}, + mActiveEUOutputs = new boolean[] {false, false, false, false, false, false}; + private byte[] mSidedRedstone = new byte[] {15, 15, 15, 15, 15, 15}; + private int[] mCoverSides = new int[] {0, 0, 0, 0, 0, 0}, + mCoverData = new int[] {0, 0, 0, 0, 0, 0}, + mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING]; + private boolean mHasEnoughEnergy = true; + protected boolean mRunningThroughTick = false; + protected boolean mInputDisabled = false; + protected boolean mOutputDisabled = false; + private boolean mMuffler = false; + private boolean mLockUpgrade = false; + private boolean mActive = false; + private boolean mRedstone = false; + private boolean mWorkUpdate = false; + private boolean mSteamConverter = false; + private boolean mInventoryChanged = false; + private boolean mWorks = true; + private boolean mNeedsUpdate = true; + private boolean mNeedsBlockUpdate = true; + private boolean mSendClientData = false; + private boolean oRedstone = false; + private boolean mEnergyStateReady = false; + private byte mColor = 0, + oColor = 0, + mStrongRedstone = 0, + oRedstoneData = 63, + oTextureData = 0, + oUpdateData = 0, + oTexturePage = 0, + oLightValueClient = -1, + oLightValue = -1, + mLightValue = 0, + mOtherUpgrades = 0, + mFacing = 0, + oFacing = 0, + mWorkData = 0; + private int mDisplayErrorCode = 0, oX = 0, oY = 0, oZ = 0, mTimeStatisticsIndex = 0, mLagWarningCount = 0; + private short mID = 0; + protected long mTickTimer = 0; + private long oOutput = 0; + private long mAcceptedAmperes = Long.MAX_VALUE; + + /** + * Cover Support + */ + public void issueClientUpdate() { + this.mSendClientData = true; + } + protected final boolean canAccessData() { return !isDead() && !this.isInvalid(); } - @Override - public void issueBlockUpdate() { - super.markDirty(); - } - - @Override - public void issueCoverUpdate(byte aSide) { - this.issueClientUpdate(); - } - - @Override - public void receiveCoverData(byte coverSide, int coverID, int coverData) { - if ((coverSide >= 0 && coverSide < 6) && (mCoverSides[coverSide] == coverID)) - setCoverDataAtSide(coverSide, coverData); - } - - @Override - public long getTimer() { - return this.mTickTimer; - } - - - - - - - - public long getOutputAmperage() { - return this.canAccessData() && this.mMetaTileEntity.isElectric() ? this.mMetaTileEntity.maxAmperesOut() : 0L; - } - - public long getOutputVoltage() { - return this.canAccessData() && this.mMetaTileEntity.isElectric() && this.mMetaTileEntity.isEnetOutput() - ? this.mMetaTileEntity.maxEUOutput() - : 0L; - } - - public long getInputAmperage() { - return this.canAccessData() && this.mMetaTileEntity.isElectric() ? this.mMetaTileEntity.maxAmperesIn() : 0L; - } - - public long getInputVoltage() { - return this.canAccessData() && this.mMetaTileEntity.isElectric() - ? this.mMetaTileEntity.maxEUInput() - : 2147483647L; - } - - @Override - public boolean decreaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooLessEnergy) { - return !this.canAccessData() ? false : (this.mHasEnoughEnergy = this.decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy)); - } - - @Override - public boolean increaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooMuchEnergy) { - if (!this.canAccessData()) { - return false; - } else if (this.getStoredEU() >= this.getEUCapacity() && !aIgnoreTooMuchEnergy) { - return false; - } else { - this.setStoredEU(this.mMetaTileEntity.getEUVar() + aEnergy); - return true; - } - } - - @Override - public boolean inputEnergyFrom(byte aSide) { - return aSide == 6 - ? true - : (!this.isServerSide() - ? this.isEnergyInputSide(aSide) - : aSide >= 0 && aSide < 6 && this.mActiveEUInputs[aSide] && !this.mReleaseEnergy); - } - - @Override - public boolean outputsEnergyTo(byte aSide) { - return aSide == 6 - ? true - : (!this.isServerSide() - ? this.isEnergyOutputSide(aSide) - : aSide >= 0 && aSide < 6 && this.mActiveEUOutputs[aSide] || this.mReleaseEnergy); - } - - private boolean isEnergyInputSide(byte aSide) { - if (aSide >= 0 && aSide < 6) { - if (!this.getCoverBehaviorAtSide(aSide).letsEnergyIn(aSide, this.getCoverIDAtSide(aSide), - this.getCoverDataAtSide(aSide), this)) { - return false; - } - - if (this.isInvalid() || this.mReleaseEnergy) { - return false; - } - - if (this.canAccessData() && this.mMetaTileEntity.isElectric() && this.mMetaTileEntity.isEnetInput()) { - return this.mMetaTileEntity.isInputFacing(aSide); - } - } - - return false; - } - - private boolean isEnergyOutputSide(byte aSide) { - if (aSide >= 0 && aSide < 6) { - if (!this.getCoverBehaviorAtSide(aSide).letsEnergyOut(aSide, this.getCoverIDAtSide(aSide), - this.getCoverDataAtSide(aSide), this)) { - return false; - } - - if (this.isInvalid() || this.mReleaseEnergy) { - return this.mReleaseEnergy; - } - - if (this.canAccessData() && this.mMetaTileEntity.isElectric() && this.mMetaTileEntity.isEnetOutput()) { - return this.mMetaTileEntity.isOutputFacing(aSide); - } - } - - return false; - } - - public boolean isOutputFacing(byte aSide) { - return false; - } - - public boolean isInputFacing(byte aSide) { - return false; - } - - private final TileEntity[] mBufferedTileEntities = new TileEntity[6]; - public boolean ignoreUnloadedChunks = true; - public boolean isDead = false; - - private final void clearNullMarkersFromTileEntityBuffer() { - for (int i = 0; i < this.mBufferedTileEntities.length; ++i) { - if (this.mBufferedTileEntities[i] == this) { - this.mBufferedTileEntities[i] = null; - } - } - - } - - protected final void clearTileEntityBuffer() { - for (int i = 0; i < this.mBufferedTileEntities.length; ++i) { - this.mBufferedTileEntities[i] = null; - } - - } - - public final World getWorld() { - return this.worldObj; - } - - public final int getXCoord() { - return this.xCoord; - } - - public final short getYCoord() { - return (short) this.yCoord; - } - - public final int getZCoord() { - return this.zCoord; - } - - public final int getOffsetX(byte aSide, int aMultiplier) { - return this.xCoord + ForgeDirection.getOrientation(aSide).offsetX * aMultiplier; - } - - public final short getOffsetY(byte aSide, int aMultiplier) { - return (short) (this.yCoord + ForgeDirection.getOrientation(aSide).offsetY * aMultiplier); - } - - public final int getOffsetZ(byte aSide, int aMultiplier) { - return this.zCoord + ForgeDirection.getOrientation(aSide).offsetZ * aMultiplier; - } - - public final boolean openGUI(EntityPlayer aPlayer) { - return this.openGUI(aPlayer, 0); - } - - public final boolean openGUI(EntityPlayer aPlayer, int aID) { - if (aPlayer == null) { - return false; - } else { - aPlayer.openGui(GT_Values.GT, aID, this.worldObj, this.xCoord, this.yCoord, this.zCoord); - return true; - } - } - - public final int getRandomNumber(int aRange) { - return this.worldObj.rand.nextInt(aRange); - } - - public final BiomeGenBase getBiome(int aX, int aZ) { - return this.worldObj.getBiomeGenForCoords(aX, aZ); - } - - public final BiomeGenBase getBiome() { - return this.getBiome(this.xCoord, this.zCoord); - } - - public final Block getBlockOffset(int aX, int aY, int aZ) { - return this.getBlock(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); - } - - public final Block getBlockAtSide(byte aSide) { - return this.getBlockAtSideAndDistance(aSide, 1); - } - - public final Block getBlockAtSideAndDistance(byte aSide, int aDistance) { - return this.getBlock(this.getOffsetX(aSide, aDistance), this.getOffsetY(aSide, aDistance), - this.getOffsetZ(aSide, aDistance)); - } - - public final byte getMetaIDOffset(int aX, int aY, int aZ) { - return this.getMetaID(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); - } - - public final byte getMetaIDAtSide(byte aSide) { - return this.getMetaIDAtSideAndDistance(aSide, 1); - } - - public final byte getMetaIDAtSideAndDistance(byte aSide, int aDistance) { - return this.getMetaID(this.getOffsetX(aSide, aDistance), this.getOffsetY(aSide, aDistance), - this.getOffsetZ(aSide, aDistance)); - } - - public final byte getLightLevelOffset(int aX, int aY, int aZ) { - return this.getLightLevel(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); - } - - public final byte getLightLevelAtSide(byte aSide) { - return this.getLightLevelAtSideAndDistance(aSide, 1); - } - - public final byte getLightLevelAtSideAndDistance(byte aSide, int aDistance) { - return this.getLightLevel(this.getOffsetX(aSide, aDistance), this.getOffsetY(aSide, aDistance), - this.getOffsetZ(aSide, aDistance)); - } - - public final boolean getOpacityOffset(int aX, int aY, int aZ) { - return this.getOpacity(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); - } - - public final boolean getOpacityAtSide(byte aSide) { - return this.getOpacityAtSideAndDistance(aSide, 1); - } - - public final boolean getOpacityAtSideAndDistance(byte aSide, int aDistance) { - return this.getOpacity(this.getOffsetX(aSide, aDistance), this.getOffsetY(aSide, aDistance), - this.getOffsetZ(aSide, aDistance)); - } - - public final boolean getSkyOffset(int aX, int aY, int aZ) { - return this.getSky(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); - } - - public final boolean getSkyAtSide(byte aSide) { - return this.getSkyAtSideAndDistance(aSide, 1); - } - - public final boolean getSkyAtSideAndDistance(byte aSide, int aDistance) { - return this.getSky(this.getOffsetX(aSide, aDistance), this.getOffsetY(aSide, aDistance), - this.getOffsetZ(aSide, aDistance)); - } - - public final boolean getAirOffset(int aX, int aY, int aZ) { - return this.getAir(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); - } - - public final boolean getAirAtSide(byte aSide) { - return this.getAirAtSideAndDistance(aSide, 1); - } - - public final boolean getAirAtSideAndDistance(byte aSide, int aDistance) { - return this.getAir(this.getOffsetX(aSide, aDistance), this.getOffsetY(aSide, aDistance), - this.getOffsetZ(aSide, aDistance)); - } - - public final TileEntity getTileEntityOffset(int aX, int aY, int aZ) { - return this.getTileEntity(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); - } - - public final TileEntity getTileEntityAtSideAndDistance(byte aSide, int aDistance) { - return aDistance == 1 - ? this.getTileEntityAtSide(aSide) - : this.getTileEntity(this.getOffsetX(aSide, aDistance), this.getOffsetY(aSide, aDistance), - this.getOffsetZ(aSide, aDistance)); - } - - public final IInventory getIInventory(int aX, int aY, int aZ) { - TileEntity tTileEntity = this.getTileEntity(aX, aY, aZ); - return tTileEntity instanceof IInventory ? (IInventory) tTileEntity : null; - } - - public final IInventory getIInventoryOffset(int aX, int aY, int aZ) { - TileEntity tTileEntity = this.getTileEntityOffset(aX, aY, aZ); - return tTileEntity instanceof IInventory ? (IInventory) tTileEntity : null; - } - - public final IInventory getIInventoryAtSide(byte aSide) { - TileEntity tTileEntity = this.getTileEntityAtSide(aSide); - return tTileEntity instanceof IInventory ? (IInventory) tTileEntity : null; - } - - public final IInventory getIInventoryAtSideAndDistance(byte aSide, int aDistance) { - TileEntity tTileEntity = this.getTileEntityAtSideAndDistance(aSide, aDistance); - return tTileEntity instanceof IInventory ? (IInventory) tTileEntity : null; - } - - public final IFluidHandler getITankContainer(int aX, int aY, int aZ) { - TileEntity tTileEntity = this.getTileEntity(aX, aY, aZ); - return tTileEntity instanceof IFluidHandler ? (IFluidHandler) tTileEntity : null; - } - - public final IFluidHandler getITankContainerOffset(int aX, int aY, int aZ) { - TileEntity tTileEntity = this.getTileEntityOffset(aX, aY, aZ); - return tTileEntity instanceof IFluidHandler ? (IFluidHandler) tTileEntity : null; - } - - public final IFluidHandler getITankContainerAtSide(byte aSide) { - TileEntity tTileEntity = this.getTileEntityAtSide(aSide); - return tTileEntity instanceof IFluidHandler ? (IFluidHandler) tTileEntity : null; - } - - public final IFluidHandler getITankContainerAtSideAndDistance(byte aSide, int aDistance) { - TileEntity tTileEntity = this.getTileEntityAtSideAndDistance(aSide, aDistance); - return tTileEntity instanceof IFluidHandler ? (IFluidHandler) tTileEntity : null; - } - - public final IGregTechTileEntity getIGregTechTileEntity(int aX, int aY, int aZ) { - TileEntity tTileEntity = this.getTileEntity(aX, aY, aZ); - return tTileEntity instanceof IGregTechTileEntity ? (IGregTechTileEntity) tTileEntity : null; - } - - public final IGregTechTileEntity getIGregTechTileEntityOffset(int aX, int aY, int aZ) { - TileEntity tTileEntity = this.getTileEntityOffset(aX, aY, aZ); - return tTileEntity instanceof IGregTechTileEntity ? (IGregTechTileEntity) tTileEntity : null; - } - - public final IGregTechTileEntity getIGregTechTileEntityAtSide(byte aSide) { - TileEntity tTileEntity = this.getTileEntityAtSide(aSide); - return tTileEntity instanceof IGregTechTileEntity ? (IGregTechTileEntity) tTileEntity : null; - } - - public final IGregTechTileEntity getIGregTechTileEntityAtSideAndDistance(byte aSide, int aDistance) { - TileEntity tTileEntity = this.getTileEntityAtSideAndDistance(aSide, aDistance); - return tTileEntity instanceof IGregTechTileEntity ? (IGregTechTileEntity) tTileEntity : null; - } - - public final Block getBlock(int aX, int aY, int aZ) { - return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ) - ? Blocks.air - : this.worldObj.getBlock(aX, aY, aZ); - } - - public final byte getMetaID(int aX, int aY, int aZ) { - return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ) - ? 0 - : (byte) this.worldObj.getBlockMetadata(aX, aY, aZ); - } - - public final byte getLightLevel(int aX, int aY, int aZ) { - return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ) - ? 0 - : (byte) ((int) (this.worldObj.getLightBrightness(aX, aY, aZ) * 15.0F)); - } - - public final boolean getSky(int aX, int aY, int aZ) { - return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ) - ? true - : this.worldObj.canBlockSeeTheSky(aX, aY, aZ); - } - - public final boolean getOpacity(int aX, int aY, int aZ) { - return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ) - ? false - : GT_Utility.isOpaqueBlock(this.worldObj, aX, aY, aZ); - } - - public final boolean getAir(int aX, int aY, int aZ) { - return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ) - ? true - : GT_Utility.isBlockAir(this.worldObj, aX, aY, aZ); - } - - public final TileEntity getTileEntity(int aX, int aY, int aZ) { - return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ) - ? null - : this.worldObj.getTileEntity(aX, aY, aZ); - } - - public final TileEntity getTileEntityAtSide(byte aSide) { - if (aSide >= 0 && aSide < 6 && this.mBufferedTileEntities[aSide] != this) { - int tX = this.getOffsetX(aSide, 1); - short tY = this.getOffsetY(aSide, 1); - int tZ = this.getOffsetZ(aSide, 1); - if (this.crossedChunkBorder(tX, tZ)) { - this.mBufferedTileEntities[aSide] = null; - if (this.ignoreUnloadedChunks && !this.worldObj.blockExists(tX, tY, tZ)) { - return null; - } - } - - if (this.mBufferedTileEntities[aSide] == null) { - this.mBufferedTileEntities[aSide] = this.worldObj.getTileEntity(tX, tY, tZ); - if (this.mBufferedTileEntities[aSide] == null) { - this.mBufferedTileEntities[aSide] = this; - return null; - } else { - return this.mBufferedTileEntities[aSide]; - } - } else if (this.mBufferedTileEntities[aSide].isInvalid()) { - this.mBufferedTileEntities[aSide] = null; - return this.getTileEntityAtSide(aSide); - } else { - return this.mBufferedTileEntities[aSide].xCoord == tX && this.mBufferedTileEntities[aSide].yCoord == tY - && this.mBufferedTileEntities[aSide].zCoord == tZ ? this.mBufferedTileEntities[aSide] : null; - } - } else { - return null; - } - } - - public boolean isDead() { - return this.isDead || this.isInvalidTileEntity(); - } - - public void validate() { - this.clearNullMarkersFromTileEntityBuffer(); - super.validate(); - } - - public void invalidate() { - this.clearNullMarkersFromTileEntityBuffer(); - super.invalidate(); - } - - public void onChunkUnload() { - this.clearNullMarkersFromTileEntityBuffer(); - super.onChunkUnload(); - this.isDead = true; - } - - public final void onAdjacentBlockChange(int aX, int aY, int aZ) { - this.clearNullMarkersFromTileEntityBuffer(); - } - - public final void sendBlockEvent(byte aID, byte aValue) { - GT_Values.NW.sendPacketToAllPlayersInRange(this.worldObj, - new GT_Packet_Block_Event(this.xCoord, (short) this.yCoord, this.zCoord, aID, aValue), this.xCoord, - this.zCoord); - } - - private boolean crossedChunkBorder(int aX, int aZ) { - return aX >> 4 != this.xCoord >> 4 || aZ >> 4 != this.zCoord >> 4; - } - - public final void setOnFire() { - GT_Utility.setCoordsOnFire(this.worldObj, this.xCoord, this.yCoord, this.zCoord, false); - } - - public final void setToFire() { - this.worldObj.setBlock(this.xCoord, this.yCoord, this.zCoord, Blocks.fire); - } - - public String trans(String aKey, String aEnglish) { - return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false); - } + @Override + public void issueBlockUpdate() { + super.markDirty(); + } + + @Override + public void issueCoverUpdate(byte aSide) { + this.issueClientUpdate(); + } + + @Override + public void receiveCoverData(byte coverSide, int coverID, int coverData) { + if ((coverSide >= 0 && coverSide < 6) && (mCoverSides[coverSide] == coverID)) + setCoverDataAtSide(coverSide, coverData); + } + + @Override + public long getTimer() { + return this.mTickTimer; + } + + public long getOutputAmperage() { + return this.canAccessData() && this.mMetaTileEntity.isElectric() ? this.mMetaTileEntity.maxAmperesOut() : 0L; + } + + public long getOutputVoltage() { + return this.canAccessData() && this.mMetaTileEntity.isElectric() && this.mMetaTileEntity.isEnetOutput() + ? this.mMetaTileEntity.maxEUOutput() + : 0L; + } + + public long getInputAmperage() { + return this.canAccessData() && this.mMetaTileEntity.isElectric() ? this.mMetaTileEntity.maxAmperesIn() : 0L; + } + + public long getInputVoltage() { + return this.canAccessData() && this.mMetaTileEntity.isElectric() + ? this.mMetaTileEntity.maxEUInput() + : 2147483647L; + } + + @Override + public boolean decreaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooLessEnergy) { + return !this.canAccessData() + ? false + : (this.mHasEnoughEnergy = this.decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy)); + } + + @Override + public boolean increaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooMuchEnergy) { + if (!this.canAccessData()) { + return false; + } else if (this.getStoredEU() >= this.getEUCapacity() && !aIgnoreTooMuchEnergy) { + return false; + } else { + this.setStoredEU(this.mMetaTileEntity.getEUVar() + aEnergy); + return true; + } + } + + @Override + public boolean inputEnergyFrom(byte aSide) { + return aSide == 6 + ? true + : (!this.isServerSide() + ? this.isEnergyInputSide(aSide) + : aSide >= 0 && aSide < 6 && this.mActiveEUInputs[aSide] && !this.mReleaseEnergy); + } + + @Override + public boolean outputsEnergyTo(byte aSide) { + return aSide == 6 + ? true + : (!this.isServerSide() + ? this.isEnergyOutputSide(aSide) + : aSide >= 0 && aSide < 6 && this.mActiveEUOutputs[aSide] || this.mReleaseEnergy); + } + + private boolean isEnergyInputSide(byte aSide) { + if (aSide >= 0 && aSide < 6) { + if (!this.getCoverBehaviorAtSide(aSide) + .letsEnergyIn(aSide, this.getCoverIDAtSide(aSide), this.getCoverDataAtSide(aSide), this)) { + return false; + } + + if (this.isInvalid() || this.mReleaseEnergy) { + return false; + } + + if (this.canAccessData() && this.mMetaTileEntity.isElectric() && this.mMetaTileEntity.isEnetInput()) { + return this.mMetaTileEntity.isInputFacing(aSide); + } + } + + return false; + } + + private boolean isEnergyOutputSide(byte aSide) { + if (aSide >= 0 && aSide < 6) { + if (!this.getCoverBehaviorAtSide(aSide) + .letsEnergyOut(aSide, this.getCoverIDAtSide(aSide), this.getCoverDataAtSide(aSide), this)) { + return false; + } + + if (this.isInvalid() || this.mReleaseEnergy) { + return this.mReleaseEnergy; + } + + if (this.canAccessData() && this.mMetaTileEntity.isElectric() && this.mMetaTileEntity.isEnetOutput()) { + return this.mMetaTileEntity.isOutputFacing(aSide); + } + } + + return false; + } + + public boolean isOutputFacing(byte aSide) { + return false; + } + + public boolean isInputFacing(byte aSide) { + return false; + } + + private final TileEntity[] mBufferedTileEntities = new TileEntity[6]; + public boolean ignoreUnloadedChunks = true; + public boolean isDead = false; + + private final void clearNullMarkersFromTileEntityBuffer() { + for (int i = 0; i < this.mBufferedTileEntities.length; ++i) { + if (this.mBufferedTileEntities[i] == this) { + this.mBufferedTileEntities[i] = null; + } + } + } + + protected final void clearTileEntityBuffer() { + for (int i = 0; i < this.mBufferedTileEntities.length; ++i) { + this.mBufferedTileEntities[i] = null; + } + } + + public final World getWorld() { + return this.worldObj; + } + + public final int getXCoord() { + return this.xCoord; + } + + public final short getYCoord() { + return (short) this.yCoord; + } + + public final int getZCoord() { + return this.zCoord; + } + + public final int getOffsetX(byte aSide, int aMultiplier) { + return this.xCoord + ForgeDirection.getOrientation(aSide).offsetX * aMultiplier; + } + + public final short getOffsetY(byte aSide, int aMultiplier) { + return (short) (this.yCoord + ForgeDirection.getOrientation(aSide).offsetY * aMultiplier); + } + + public final int getOffsetZ(byte aSide, int aMultiplier) { + return this.zCoord + ForgeDirection.getOrientation(aSide).offsetZ * aMultiplier; + } + + public final boolean openGUI(EntityPlayer aPlayer) { + return this.openGUI(aPlayer, 0); + } + + public final boolean openGUI(EntityPlayer aPlayer, int aID) { + if (aPlayer == null) { + return false; + } else { + aPlayer.openGui(GT_Values.GT, aID, this.worldObj, this.xCoord, this.yCoord, this.zCoord); + return true; + } + } + + public final int getRandomNumber(int aRange) { + return this.worldObj.rand.nextInt(aRange); + } + + public final BiomeGenBase getBiome(int aX, int aZ) { + return this.worldObj.getBiomeGenForCoords(aX, aZ); + } + + public final BiomeGenBase getBiome() { + return this.getBiome(this.xCoord, this.zCoord); + } + + public final Block getBlockOffset(int aX, int aY, int aZ) { + return this.getBlock(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); + } + + public final Block getBlockAtSide(byte aSide) { + return this.getBlockAtSideAndDistance(aSide, 1); + } + + public final Block getBlockAtSideAndDistance(byte aSide, int aDistance) { + return this.getBlock( + this.getOffsetX(aSide, aDistance), + this.getOffsetY(aSide, aDistance), + this.getOffsetZ(aSide, aDistance)); + } + + public final byte getMetaIDOffset(int aX, int aY, int aZ) { + return this.getMetaID(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); + } + + public final byte getMetaIDAtSide(byte aSide) { + return this.getMetaIDAtSideAndDistance(aSide, 1); + } + + public final byte getMetaIDAtSideAndDistance(byte aSide, int aDistance) { + return this.getMetaID( + this.getOffsetX(aSide, aDistance), + this.getOffsetY(aSide, aDistance), + this.getOffsetZ(aSide, aDistance)); + } + + public final byte getLightLevelOffset(int aX, int aY, int aZ) { + return this.getLightLevel(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); + } + + public final byte getLightLevelAtSide(byte aSide) { + return this.getLightLevelAtSideAndDistance(aSide, 1); + } + + public final byte getLightLevelAtSideAndDistance(byte aSide, int aDistance) { + return this.getLightLevel( + this.getOffsetX(aSide, aDistance), + this.getOffsetY(aSide, aDistance), + this.getOffsetZ(aSide, aDistance)); + } + + public final boolean getOpacityOffset(int aX, int aY, int aZ) { + return this.getOpacity(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); + } + + public final boolean getOpacityAtSide(byte aSide) { + return this.getOpacityAtSideAndDistance(aSide, 1); + } + + public final boolean getOpacityAtSideAndDistance(byte aSide, int aDistance) { + return this.getOpacity( + this.getOffsetX(aSide, aDistance), + this.getOffsetY(aSide, aDistance), + this.getOffsetZ(aSide, aDistance)); + } + + public final boolean getSkyOffset(int aX, int aY, int aZ) { + return this.getSky(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); + } + + public final boolean getSkyAtSide(byte aSide) { + return this.getSkyAtSideAndDistance(aSide, 1); + } + + public final boolean getSkyAtSideAndDistance(byte aSide, int aDistance) { + return this.getSky( + this.getOffsetX(aSide, aDistance), + this.getOffsetY(aSide, aDistance), + this.getOffsetZ(aSide, aDistance)); + } + + public final boolean getAirOffset(int aX, int aY, int aZ) { + return this.getAir(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); + } + + public final boolean getAirAtSide(byte aSide) { + return this.getAirAtSideAndDistance(aSide, 1); + } + + public final boolean getAirAtSideAndDistance(byte aSide, int aDistance) { + return this.getAir( + this.getOffsetX(aSide, aDistance), + this.getOffsetY(aSide, aDistance), + this.getOffsetZ(aSide, aDistance)); + } + + public final TileEntity getTileEntityOffset(int aX, int aY, int aZ) { + return this.getTileEntity(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); + } + + public final TileEntity getTileEntityAtSideAndDistance(byte aSide, int aDistance) { + return aDistance == 1 + ? this.getTileEntityAtSide(aSide) + : this.getTileEntity( + this.getOffsetX(aSide, aDistance), + this.getOffsetY(aSide, aDistance), + this.getOffsetZ(aSide, aDistance)); + } + + public final IInventory getIInventory(int aX, int aY, int aZ) { + TileEntity tTileEntity = this.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof IInventory ? (IInventory) tTileEntity : null; + } + + public final IInventory getIInventoryOffset(int aX, int aY, int aZ) { + TileEntity tTileEntity = this.getTileEntityOffset(aX, aY, aZ); + return tTileEntity instanceof IInventory ? (IInventory) tTileEntity : null; + } + + public final IInventory getIInventoryAtSide(byte aSide) { + TileEntity tTileEntity = this.getTileEntityAtSide(aSide); + return tTileEntity instanceof IInventory ? (IInventory) tTileEntity : null; + } + + public final IInventory getIInventoryAtSideAndDistance(byte aSide, int aDistance) { + TileEntity tTileEntity = this.getTileEntityAtSideAndDistance(aSide, aDistance); + return tTileEntity instanceof IInventory ? (IInventory) tTileEntity : null; + } + + public final IFluidHandler getITankContainer(int aX, int aY, int aZ) { + TileEntity tTileEntity = this.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof IFluidHandler ? (IFluidHandler) tTileEntity : null; + } + + public final IFluidHandler getITankContainerOffset(int aX, int aY, int aZ) { + TileEntity tTileEntity = this.getTileEntityOffset(aX, aY, aZ); + return tTileEntity instanceof IFluidHandler ? (IFluidHandler) tTileEntity : null; + } + + public final IFluidHandler getITankContainerAtSide(byte aSide) { + TileEntity tTileEntity = this.getTileEntityAtSide(aSide); + return tTileEntity instanceof IFluidHandler ? (IFluidHandler) tTileEntity : null; + } + + public final IFluidHandler getITankContainerAtSideAndDistance(byte aSide, int aDistance) { + TileEntity tTileEntity = this.getTileEntityAtSideAndDistance(aSide, aDistance); + return tTileEntity instanceof IFluidHandler ? (IFluidHandler) tTileEntity : null; + } + + public final IGregTechTileEntity getIGregTechTileEntity(int aX, int aY, int aZ) { + TileEntity tTileEntity = this.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof IGregTechTileEntity ? (IGregTechTileEntity) tTileEntity : null; + } + + public final IGregTechTileEntity getIGregTechTileEntityOffset(int aX, int aY, int aZ) { + TileEntity tTileEntity = this.getTileEntityOffset(aX, aY, aZ); + return tTileEntity instanceof IGregTechTileEntity ? (IGregTechTileEntity) tTileEntity : null; + } + + public final IGregTechTileEntity getIGregTechTileEntityAtSide(byte aSide) { + TileEntity tTileEntity = this.getTileEntityAtSide(aSide); + return tTileEntity instanceof IGregTechTileEntity ? (IGregTechTileEntity) tTileEntity : null; + } + + public final IGregTechTileEntity getIGregTechTileEntityAtSideAndDistance(byte aSide, int aDistance) { + TileEntity tTileEntity = this.getTileEntityAtSideAndDistance(aSide, aDistance); + return tTileEntity instanceof IGregTechTileEntity ? (IGregTechTileEntity) tTileEntity : null; + } + + public final Block getBlock(int aX, int aY, int aZ) { + return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ) + ? Blocks.air + : this.worldObj.getBlock(aX, aY, aZ); + } + + public final byte getMetaID(int aX, int aY, int aZ) { + return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ) + ? 0 + : (byte) this.worldObj.getBlockMetadata(aX, aY, aZ); + } + + public final byte getLightLevel(int aX, int aY, int aZ) { + return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ) + ? 0 + : (byte) ((int) (this.worldObj.getLightBrightness(aX, aY, aZ) * 15.0F)); + } + + public final boolean getSky(int aX, int aY, int aZ) { + return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ) + ? true + : this.worldObj.canBlockSeeTheSky(aX, aY, aZ); + } + + public final boolean getOpacity(int aX, int aY, int aZ) { + return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ) + ? false + : GT_Utility.isOpaqueBlock(this.worldObj, aX, aY, aZ); + } + + public final boolean getAir(int aX, int aY, int aZ) { + return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ) + ? true + : GT_Utility.isBlockAir(this.worldObj, aX, aY, aZ); + } + + public final TileEntity getTileEntity(int aX, int aY, int aZ) { + return this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ) + ? null + : this.worldObj.getTileEntity(aX, aY, aZ); + } + + public final TileEntity getTileEntityAtSide(byte aSide) { + if (aSide >= 0 && aSide < 6 && this.mBufferedTileEntities[aSide] != this) { + int tX = this.getOffsetX(aSide, 1); + short tY = this.getOffsetY(aSide, 1); + int tZ = this.getOffsetZ(aSide, 1); + if (this.crossedChunkBorder(tX, tZ)) { + this.mBufferedTileEntities[aSide] = null; + if (this.ignoreUnloadedChunks && !this.worldObj.blockExists(tX, tY, tZ)) { + return null; + } + } + + if (this.mBufferedTileEntities[aSide] == null) { + this.mBufferedTileEntities[aSide] = this.worldObj.getTileEntity(tX, tY, tZ); + if (this.mBufferedTileEntities[aSide] == null) { + this.mBufferedTileEntities[aSide] = this; + return null; + } else { + return this.mBufferedTileEntities[aSide]; + } + } else if (this.mBufferedTileEntities[aSide].isInvalid()) { + this.mBufferedTileEntities[aSide] = null; + return this.getTileEntityAtSide(aSide); + } else { + return this.mBufferedTileEntities[aSide].xCoord == tX + && this.mBufferedTileEntities[aSide].yCoord == tY + && this.mBufferedTileEntities[aSide].zCoord == tZ + ? this.mBufferedTileEntities[aSide] + : null; + } + } else { + return null; + } + } + + public boolean isDead() { + return this.isDead || this.isInvalidTileEntity(); + } + + public void validate() { + this.clearNullMarkersFromTileEntityBuffer(); + super.validate(); + } + + public void invalidate() { + this.clearNullMarkersFromTileEntityBuffer(); + super.invalidate(); + } + + public void onChunkUnload() { + this.clearNullMarkersFromTileEntityBuffer(); + super.onChunkUnload(); + this.isDead = true; + } + + public final void onAdjacentBlockChange(int aX, int aY, int aZ) { + this.clearNullMarkersFromTileEntityBuffer(); + } + + public final void sendBlockEvent(byte aID, byte aValue) { + GT_Values.NW.sendPacketToAllPlayersInRange( + this.worldObj, + new GT_Packet_Block_Event(this.xCoord, (short) this.yCoord, this.zCoord, aID, aValue), + this.xCoord, + this.zCoord); + } + + private boolean crossedChunkBorder(int aX, int aZ) { + return aX >> 4 != this.xCoord >> 4 || aZ >> 4 != this.zCoord >> 4; + } + + public final void setOnFire() { + GT_Utility.setCoordsOnFire(this.worldObj, this.xCoord, this.yCoord, this.zCoord, false); + } + + public final void setToFire() { + this.worldObj.setBlock(this.xCoord, this.yCoord, this.zCoord, Blocks.fire); + } + + public String trans(String aKey, String aEnglish) { + return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false); + } @Override public byte getInternalInputRedstoneSignal(byte aSide) { - return (byte) (getCoverBehaviorAtSide(aSide).getRedstoneInput(aSide, getInputRedstoneSignal(aSide), getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this) & 15); + return (byte) (getCoverBehaviorAtSide(aSide) + .getRedstoneInput( + aSide, + getInputRedstoneSignal(aSide), + getCoverIDAtSide(aSide), + getCoverDataAtSide(aSide), + this) + & 15); } @Override public byte getInputRedstoneSignal(byte aSide) { - return (byte) (worldObj.getIndirectPowerLevelTo(getOffsetX(aSide, 1), getOffsetY(aSide, 1), getOffsetZ(aSide, 1), aSide) & 15); + return (byte) (worldObj.getIndirectPowerLevelTo( + getOffsetX(aSide, 1), getOffsetY(aSide, 1), getOffsetZ(aSide, 1), aSide) + & 15); } @Override public byte getOutputRedstoneSignal(byte aSide) { - return getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this) ? mSidedRedstone[aSide] : getGeneralRS(aSide); + return getCoverBehaviorAtSide(aSide) + .manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this) + ? mSidedRedstone[aSide] + : getGeneralRS(aSide); + } + + public boolean allowGeneralRedstoneOutput() { + return false; } - - public boolean allowGeneralRedstoneOutput() { - return false; - } - - public byte getGeneralRS(byte aSide){ - return allowGeneralRedstoneOutput() ? mSidedRedstone[aSide] : 0; + + public byte getGeneralRS(byte aSide) { + return allowGeneralRedstoneOutput() ? mSidedRedstone[aSide] : 0; } @Override public void setInternalOutputRedstoneSignal(byte aSide, byte aStrength) { - if (!getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this)) + if (!getCoverBehaviorAtSide(aSide) + .manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this)) setOutputRedstoneSignal(aSide, aStrength); } @@ -873,24 +941,24 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT } } - @Override - public boolean setCoverIDAtSideNoUpdate(byte aSide, int aID) { - if (aSide >= 0 && aSide < 6) { - mCoverSides[aSide] = aID; - mCoverData[aSide] = 0; - mCoverBehaviors[aSide] = GregTech_API.getCoverBehavior(aID); - return true; - } - return false; - } - - @Override - public void setCoverIdAndDataAtSide(byte aSide, int aId, ISerializableObject aData) { - setCoverIDAtSide(aSide, aId); - setCoverDataAtSide(aSide, aData); - } - - @Override + @Override + public boolean setCoverIDAtSideNoUpdate(byte aSide, int aID) { + if (aSide >= 0 && aSide < 6) { + mCoverSides[aSide] = aID; + mCoverData[aSide] = 0; + mCoverBehaviors[aSide] = GregTech_API.getCoverBehavior(aID); + return true; + } + return false; + } + + @Override + public void setCoverIdAndDataAtSide(byte aSide, int aId, ISerializableObject aData) { + setCoverIDAtSide(aSide, aId); + setCoverDataAtSide(aSide, aData); + } + + @Override public void setCoverItemAtSide(byte aSide, ItemStack aCover) { GregTech_API.getCoverBehavior(aCover).placeCover(aSide, aCover, this); } @@ -940,8 +1008,7 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT public long getAverageElectricInput() { int rEU = 0; for (int i = 0; i < mAverageEUInput.length; i++) { - if (i != mAverageEUInputIndex) - rEU += mAverageEUInput[i]; + if (i != mAverageEUInputIndex) rEU += mAverageEUInput[i]; } return rEU / (mAverageEUInput.length - 1); } @@ -950,23 +1017,30 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT public long getAverageElectricOutput() { int rEU = 0; for (int i = 0; i < mAverageEUOutput.length; i++) { - if (i != mAverageEUOutputIndex) - rEU += mAverageEUOutput[i]; + if (i != mAverageEUOutputIndex) rEU += mAverageEUOutput[i]; } return rEU / (mAverageEUOutput.length - 1); } - public boolean hasSidedRedstoneOutputBehavior() { - return false; - } + public boolean hasSidedRedstoneOutputBehavior() { + return false; + } @Override public boolean dropCover(byte aSide, byte aDroppedSide, boolean aForced) { - if (getCoverBehaviorAtSide(aSide).onCoverRemoval(aSide, getCoverIDAtSide(aSide), mCoverData[aSide], this, aForced) || aForced) { - ItemStack tStack = getCoverBehaviorAtSide(aSide).getDrop(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this); + if (getCoverBehaviorAtSide(aSide) + .onCoverRemoval(aSide, getCoverIDAtSide(aSide), mCoverData[aSide], this, aForced) + || aForced) { + ItemStack tStack = getCoverBehaviorAtSide(aSide) + .getDrop(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this); if (tStack != null) { tStack.setTagCompound(null); - EntityItem tEntity = new EntityItem(worldObj, getOffsetX(aDroppedSide, 1) + 0.5, getOffsetY(aDroppedSide, 1) + 0.5, getOffsetZ(aDroppedSide, 1) + 0.5, tStack); + EntityItem tEntity = new EntityItem( + worldObj, + getOffsetX(aDroppedSide, 1) + 0.5, + getOffsetY(aDroppedSide, 1) + 0.5, + getOffsetZ(aDroppedSide, 1) + 0.5, + tStack); tEntity.motionX = 0; tEntity.motionY = 0; tEntity.motionZ = 0; @@ -1000,7 +1074,9 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT @Override public byte getStrongOutputRedstoneSignal(byte aSide) { - return aSide >= 0 && aSide < 6 && (mStrongRedstone & (1 << aSide)) != 0 ? (byte) (mSidedRedstone[aSide] & 15) : 0; + return aSide >= 0 && aSide < 6 && (mStrongRedstone & (1 << aSide)) != 0 + ? (byte) (mSidedRedstone[aSide] & 15) + : 0; } @Override @@ -1011,13 +1087,25 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT @Override public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) { - if (!canAccessData() || !mMetaTileEntity.isElectric() || !inputEnergyFrom(aSide) || aAmperage <= 0 || aVoltage <= 0 || getStoredEU() >= getEUCapacity() || mMetaTileEntity.maxAmperesIn() <= mAcceptedAmperes) - return 0; + if (!canAccessData() + || !mMetaTileEntity.isElectric() + || !inputEnergyFrom(aSide) + || aAmperage <= 0 + || aVoltage <= 0 + || getStoredEU() >= getEUCapacity() + || mMetaTileEntity.maxAmperesIn() <= mAcceptedAmperes) return 0; if (aVoltage > getInputVoltage()) { doExplosion(aVoltage); return 0; } - if (increaseStoredEnergyUnits(aVoltage * (aAmperage = Math.min(aAmperage, Math.min(mMetaTileEntity.maxAmperesIn() - mAcceptedAmperes, 1 + ((getEUCapacity() - getStoredEU()) / aVoltage)))), true)) { + if (increaseStoredEnergyUnits( + aVoltage + * (aAmperage = Math.min( + aAmperage, + Math.min( + mMetaTileEntity.maxAmperesIn() - mAcceptedAmperes, + 1 + ((getEUCapacity() - getStoredEU()) / aVoltage)))), + true)) { mAverageEUInput[mAverageEUInputIndex] += aVoltage * aAmperage; mAcceptedAmperes += aAmperage; return aAmperage; @@ -1027,8 +1115,10 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT @Override public boolean drainEnergyUnits(byte aSide, long aVoltage, long aAmperage) { - if (!canAccessData() || !mMetaTileEntity.isElectric() || !outputsEnergyTo(aSide) || getStoredEU() - (aVoltage * aAmperage) < mMetaTileEntity.getMinimumStoredEU()) - return false; + if (!canAccessData() + || !mMetaTileEntity.isElectric() + || !outputsEnergyTo(aSide) + || getStoredEU() - (aVoltage * aAmperage) < mMetaTileEntity.getMinimumStoredEU()) return false; if (decreaseStoredEU(aVoltage * aAmperage, false)) { mAverageEUOutput[mAverageEUOutputIndex] += aVoltage * aAmperage; return true; @@ -1036,106 +1126,87 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT return false; } - public double getOutputEnergyUnitsPerTick() { return oOutput; } - public boolean isTeleporterCompatible(ForgeDirection aSide) { return false; } - public double demandedEnergyUnits() { if (mReleaseEnergy || !canAccessData() || !mMetaTileEntity.isEnetInput()) return 0; return getEUCapacity() - getStoredEU(); } - public double injectEnergyUnits(ForgeDirection aDirection, double aAmount) { return injectEnergyUnits((byte) aDirection.ordinal(), (int) aAmount, 1) > 0 ? 0 : aAmount; } - public boolean acceptsEnergyFrom(TileEntity aEmitter, ForgeDirection aDirection) { return inputEnergyFrom((byte) aDirection.ordinal()); } - public boolean emitsEnergyTo(TileEntity aReceiver, ForgeDirection aDirection) { return outputsEnergyTo((byte) aDirection.ordinal()); } - public double getOfferedEnergy() { - return (canAccessData() && getStoredEU() - mMetaTileEntity.getMinimumStoredEU() >= oOutput) ? Math.max(0, oOutput) : 0; + return (canAccessData() && getStoredEU() - mMetaTileEntity.getMinimumStoredEU() >= oOutput) + ? Math.max(0, oOutput) + : 0; } - public void drawEnergy(double amount) { mAverageEUOutput[mAverageEUOutputIndex] += amount; decreaseStoredEU((int) amount, true); } - public int injectEnergy(ForgeDirection aForgeDirection, int aAmount) { return injectEnergyUnits((byte) aForgeDirection.ordinal(), aAmount, 1) > 0 ? 0 : aAmount; } - public int addEnergy(int aEnergy) { if (!canAccessData()) return 0; - if (aEnergy > 0) - increaseStoredEnergyUnits(aEnergy, true); - else - decreaseStoredEU(-aEnergy, true); + if (aEnergy > 0) increaseStoredEnergyUnits(aEnergy, true); + else decreaseStoredEU(-aEnergy, true); return (int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getEUVar()); } - public boolean isAddedToEnergyNet() { return false; } - public int demandsEnergy() { if (mReleaseEnergy || !canAccessData() || !mMetaTileEntity.isEnetInput()) return 0; return getCapacity() - getStored(); } - public int getCapacity() { return (int) Math.min(Integer.MAX_VALUE, getEUCapacity()); } - public int getStored() { return (int) Math.min(Integer.MAX_VALUE, Math.min(getStoredEU(), getCapacity())); } - public void setStored(int aEU) { if (canAccessData()) setStoredEU(aEU); } - public int getMaxSafeInput() { return (int) Math.min(Integer.MAX_VALUE, getInputVoltage()); } - public int getMaxEnergyOutput() { if (mReleaseEnergy) return Integer.MAX_VALUE; return getOutput(); } - public int getOutput() { return (int) Math.min(Integer.MAX_VALUE, oOutput); } - public int injectEnergy(Direction aDirection, int aAmount) { return injectEnergyUnits((byte) aDirection.toSideValue(), aAmount, 1) > 0 ? 0 : aAmount; } @@ -1144,7 +1215,6 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT return inputEnergyFrom((byte) aDirection.toSideValue()); } - public boolean emitsEnergyTo(TileEntity aReceiver, Direction aDirection) { return outputsEnergyTo((byte) aDirection.toSideValue()); } @@ -1164,7 +1234,9 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT return true; } aStack = GT_OreDictUnificator.get(aStack); - if (GT_Utility.areStacksEqual(tStack, aStack) && tStack.stackSize + aStack.stackSize <= Math.min(aStack.getMaxStackSize(), getInventoryStackLimit())) { + if (GT_Utility.areStacksEqual(tStack, aStack) + && tStack.stackSize + aStack.stackSize + <= Math.min(aStack.getMaxStackSize(), getInventoryStackLimit())) { tStack.stackSize += aStack.stackSize; return true; } @@ -1182,181 +1254,170 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT mInventoryChanged = true; } - - /** * To Do */ - - public boolean isElectric() { - return true; - } - - public boolean isEnetOutput() { - return false; - } - - public boolean isEnetInput() { - return false; - } - - public long maxEUStore() { - return 0L; - } - - public long maxEUInput() { - return 0L; - } - - public long maxEUOutput() { - return 0L; - } - - public long maxAmperesOut() { - return 1L; - } - - public long maxAmperesIn() { - return 1L; - } - - public void doEnergyExplosion() { - if (this.getUniversalEnergyCapacity() > 0L - && this.getUniversalEnergyStored() >= this.getUniversalEnergyCapacity() / 5L) { - this.doExplosion(this.oOutput * (long) (this.getUniversalEnergyStored() >= this.getUniversalEnergyCapacity() - ? 4 - : (this.getUniversalEnergyStored() >= this.getUniversalEnergyCapacity() / 2L ? 2 : 1))); - GT_Mod arg9999 = GT_Mod.instance; - GT_Mod.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(this.mOwnerName), - "electricproblems"); - } - - } - - public void doExplosion(long aAmount) { - if (this.canAccessData()) { - if (GregTech_API.sMachineWireFire && this.mMetaTileEntity.isElectric()) { - try { - this.mReleaseEnergy = true; - Util.emitEnergyToNetwork(GT_Values.V[5], Math.max(1L, this.getStoredEU() / GT_Values.V[5]), this); - } catch (Exception arg4) { - } - } - this.mReleaseEnergy = false; - this.onExplosion(); - PollutionUtils.addPollution(this, 100000); - this.mMetaTileEntity.doExplosion(aAmount); - } - - } - - public void onExplosion() { - - } - - @Override - public String[] getDescription() { - return this.canAccessData() ? this.mMetaTileEntity.getDescription() : new String[0]; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public String[] getInfoData() { - return null; - } - - public long getEUVar() { - return this.mStoredEnergy; - } - - public void setEUVar(long aEnergy) { - this.mStoredEnergy = aEnergy; - } - - public long getStoredEU() { - return this.canAccessData() ? Math.min(this.mMetaTileEntity.getEUVar(), this.getEUCapacity()) : 0L; - } - - public long getEUCapacity() { - return this.canAccessData() ? this.mMetaTileEntity.maxEUStore() : 0L; - } - - public long getMinimumStoredEU() { - return 512L; - } - - public boolean setStoredEU(long aEnergy) { - if (!this.canAccessData()) { - return false; - } else { - if (aEnergy < 0L) { - aEnergy = 0L; - } - - this.mMetaTileEntity.setEUVar(aEnergy); - return true; - } - } - - public boolean decreaseStoredEU(long aEnergy, boolean aIgnoreTooLessEnergy) { - if (!this.canAccessData()) { - return false; - } else if (this.mMetaTileEntity.getEUVar() - aEnergy < 0L && !aIgnoreTooLessEnergy) { - return false; - } else { - this.setStoredEU(this.mMetaTileEntity.getEUVar() - aEnergy); - if (this.mMetaTileEntity.getEUVar() < 0L) { - this.setStoredEU(0L); - return false; - } else { - return true; - } - } - } - - //Required as of 5.09.32-pre5 - public boolean energyStateReady() { - return false; - } - - - private boolean firstTicked = false; - - public boolean onFirstTick() { - if (!firstTicked) { - firstTicked = true; - if (this.mInventory != null) { - this.mInventory.purgeNulls(); - return true; - } - } - return false; - } - - - /** - * Adds support for the newer function added by https://github.com/Blood-Asp/GT5-Unofficial/commit/73ee102b63efd92c0f164a7ed7a79ebcd2619617#diff-3051838621d8ae87aa5ccd1345e1f07d - */ - public boolean inputEnergyFrom(byte arg0, boolean arg1) { - // TODO Auto-generated method stub - return false; - } - - - /** - * Adds support for the newer function added by https://github.com/Blood-Asp/GT5-Unofficial/commit/73ee102b63efd92c0f164a7ed7a79ebcd2619617#diff-3051838621d8ae87aa5ccd1345e1f07d - */ - public boolean outputsEnergyTo(byte arg0, boolean arg1) { - // TODO Auto-generated method stub - return false; - } - - + public boolean isElectric() { + return true; + } + public boolean isEnetOutput() { + return false; + } + public boolean isEnetInput() { + return false; + } + + public long maxEUStore() { + return 0L; + } + + public long maxEUInput() { + return 0L; + } + + public long maxEUOutput() { + return 0L; + } + + public long maxAmperesOut() { + return 1L; + } + public long maxAmperesIn() { + return 1L; + } + + public void doEnergyExplosion() { + if (this.getUniversalEnergyCapacity() > 0L + && this.getUniversalEnergyStored() >= this.getUniversalEnergyCapacity() / 5L) { + this.doExplosion(this.oOutput + * (long) + (this.getUniversalEnergyStored() >= this.getUniversalEnergyCapacity() + ? 4 + : (this.getUniversalEnergyStored() >= this.getUniversalEnergyCapacity() / 2L + ? 2 + : 1))); + GT_Mod arg9999 = GT_Mod.instance; + GT_Mod.achievements.issueAchievement( + this.getWorldObj().getPlayerEntityByName(this.mOwnerName), "electricproblems"); + } + } + + public void doExplosion(long aAmount) { + if (this.canAccessData()) { + if (GregTech_API.sMachineWireFire && this.mMetaTileEntity.isElectric()) { + try { + this.mReleaseEnergy = true; + Util.emitEnergyToNetwork(GT_Values.V[5], Math.max(1L, this.getStoredEU() / GT_Values.V[5]), this); + } catch (Exception arg4) { + } + } + this.mReleaseEnergy = false; + this.onExplosion(); + PollutionUtils.addPollution(this, 100000); + this.mMetaTileEntity.doExplosion(aAmount); + } + } + + public void onExplosion() {} + + @Override + public String[] getDescription() { + return this.canAccessData() ? this.mMetaTileEntity.getDescription() : new String[0]; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + return null; + } + + public long getEUVar() { + return this.mStoredEnergy; + } + + public void setEUVar(long aEnergy) { + this.mStoredEnergy = aEnergy; + } + + public long getStoredEU() { + return this.canAccessData() ? Math.min(this.mMetaTileEntity.getEUVar(), this.getEUCapacity()) : 0L; + } + + public long getEUCapacity() { + return this.canAccessData() ? this.mMetaTileEntity.maxEUStore() : 0L; + } + + public long getMinimumStoredEU() { + return 512L; + } + + public boolean setStoredEU(long aEnergy) { + if (!this.canAccessData()) { + return false; + } else { + if (aEnergy < 0L) { + aEnergy = 0L; + } + + this.mMetaTileEntity.setEUVar(aEnergy); + return true; + } + } + + public boolean decreaseStoredEU(long aEnergy, boolean aIgnoreTooLessEnergy) { + if (!this.canAccessData()) { + return false; + } else if (this.mMetaTileEntity.getEUVar() - aEnergy < 0L && !aIgnoreTooLessEnergy) { + return false; + } else { + this.setStoredEU(this.mMetaTileEntity.getEUVar() - aEnergy); + if (this.mMetaTileEntity.getEUVar() < 0L) { + this.setStoredEU(0L); + return false; + } else { + return true; + } + } + } + + // Required as of 5.09.32-pre5 + public boolean energyStateReady() { + return false; + } + + private boolean firstTicked = false; + + public boolean onFirstTick() { + if (!firstTicked) { + firstTicked = true; + if (this.mInventory != null) { + this.mInventory.purgeNulls(); + return true; + } + } + return false; + } + + /** + * Adds support for the newer function added by https://github.com/Blood-Asp/GT5-Unofficial/commit/73ee102b63efd92c0f164a7ed7a79ebcd2619617#diff-3051838621d8ae87aa5ccd1345e1f07d + */ + public boolean inputEnergyFrom(byte arg0, boolean arg1) { + // TODO Auto-generated method stub + return false; + } + + /** + * Adds support for the newer function added by https://github.com/Blood-Asp/GT5-Unofficial/commit/73ee102b63efd92c0f164a7ed7a79ebcd2619617#diff-3051838621d8ae87aa5ccd1345e1f07d + */ + public boolean outputsEnergyTo(byte arg0, boolean arg1) { + // TODO Auto-generated method stub + return false; + } } diff --git a/src/main/java/gtPlusPlus/core/tileentities/base/TilePoweredGT.java b/src/main/java/gtPlusPlus/core/tileentities/base/TilePoweredGT.java index fb599b0bae..257dc740ea 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/base/TilePoweredGT.java +++ b/src/main/java/gtPlusPlus/core/tileentities/base/TilePoweredGT.java @@ -1,37 +1,16 @@ /*package gtPlusPlus.core.tileentities.base; -import net.minecraft.block.Block; -import net.minecraft.entity.Entity; -import net.minecraft.init.Blocks; -import net.minecraft.inventory.IInventory; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.Packet; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -import gregtech.api.GregTech_API; -import gregtech.api.enums.GT_Values; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.net.GT_Packet; -import gregtech.api.net.GT_Packet_Block_Event; -import gregtech.api.util.GT_Utility; - -import gtPlusPlus.api.interfaces.IGregtechPower; -import gtPlusPlus.api.objects.data.AutoMap; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; -import net.minecraftforge.common.util.ForgeDirection; public abstract class TilePoweredGT extends TileEntityBase implements IGregtechPower { - + public static AutoMap mPoweredEntities = new AutoMap(); - + //Base Tile Fields public boolean ignoreUnloadedChunks; public boolean isDead; //Meta Tile Fields private long mAcceptedAmperes; - + private boolean[] mActiveEUInputs; private boolean[] mActiveEUOutputs; protected int[] mAverageEUInput; @@ -57,13 +36,13 @@ public abstract class TilePoweredGT extends TileEntityBase implements IGregtechP this.isDead = false; mPoweredEntities.put(this); } - + @Override public boolean acceptsRotationalEnergy(byte p0) { return false; } - private boolean canAccessData() { + private boolean canAccessData() { return this.isInvalid() ? false : true; } @@ -121,7 +100,7 @@ public abstract class TilePoweredGT extends TileEntityBase implements IGregtechP } return true; } - + public void doExplosion(final long aExplosionPower) { final float tStrength = (aExplosionPower < GT_Values.V[0]) ? 1.0f @@ -287,7 +266,7 @@ public abstract class TilePoweredGT extends TileEntityBase implements IGregtechP } return null; } - + @Override public final IGregTechTileEntity getIGregTechTileEntityAtSideAndDistance(final byte aSide, final int aDistance) { final TileEntity tTileEntity = this.getTileEntityAtSideAndDistance(aSide, aDistance); @@ -617,9 +596,9 @@ public abstract class TilePoweredGT extends TileEntityBase implements IGregtechP return aSide >= 0 && aSide < 6 && this.mActiveEUInputs[aSide] && !this.mReleaseEnergy; } return this.isEnergyInputSide(aSide); - } - - + } + + public final boolean isClientSide() { return this.worldObj.isRemote; } @@ -628,13 +607,13 @@ public abstract class TilePoweredGT extends TileEntityBase implements IGregtechP public boolean isDead() { return this.isDead; } - + private boolean isElectric() { return true; } private boolean isEnergyInputSide(final byte aSide) { - if (aSide >= 0 && aSide < 6) { + if (aSide >= 0 && aSide < 6) { if (this.isInvalid() || this.mReleaseEnergy) { return false; } @@ -644,9 +623,9 @@ public abstract class TilePoweredGT extends TileEntityBase implements IGregtechP } return false; } - + private boolean isEnergyOutputSide(final byte aSide) { - if (aSide >= 0 && aSide < 6) { + if (aSide >= 0 && aSide < 6) { if (this.isInvalid() || this.mReleaseEnergy) { return this.mReleaseEnergy; } @@ -673,8 +652,8 @@ public abstract class TilePoweredGT extends TileEntityBase implements IGregtechP public boolean isInputFacing(final byte aSide) { return false; } - - + + @Override @@ -706,7 +685,7 @@ public abstract class TilePoweredGT extends TileEntityBase implements IGregtechP public long maxAmperesOut() { return 1L; } - + public long maxEUInput() { return 0L; } @@ -714,7 +693,7 @@ public abstract class TilePoweredGT extends TileEntityBase implements IGregtechP public long maxEUOutput() { return 0L; } - + public long maxEUStore() { return 0L; } @@ -722,7 +701,7 @@ public abstract class TilePoweredGT extends TileEntityBase implements IGregtechP public long maxSteamStore() { return 256000L; } - + public final void onAdjacentBlockChange(final int aX, final int aY, final int aZ) { this.clearNullMarkersFromTileEntityBuffer(); } @@ -761,7 +740,7 @@ public abstract class TilePoweredGT extends TileEntityBase implements IGregtechP //this.onMachineBlockUpdate(); } } - + public void setSteamVar(final long aSteam) { mStoredSteam = aSteam; } @@ -776,7 +755,7 @@ public abstract class TilePoweredGT extends TileEntityBase implements IGregtechP this.setEUVar(aEnergy); return true; } - + public boolean setStoredSteam(long aEnergy) { if (!this.canAccessData()) { return false; @@ -800,9 +779,9 @@ public abstract class TilePoweredGT extends TileEntityBase implements IGregtechP super.readFromNBT(nbt); } - - - + + + @Override public boolean onPreTick(long aTick) { return onPreTick(this, this.mTickTimer); @@ -850,12 +829,12 @@ public abstract class TilePoweredGT extends TileEntityBase implements IGregtechP super.onChunkUnload(); this.isDead = true; } - - + + public void updateEntity() { super.updateEntity(); this.isDead = false; - + this.mRunningThroughTick = true; long tTime = System.currentTimeMillis(); int tCode = 0; @@ -873,7 +852,7 @@ public abstract class TilePoweredGT extends TileEntityBase implements IGregtechP this.oX = this.xCoord; this.oY = this.yCoord; this.oZ = this.zCoord; - + this.worldObj.markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, (TileEntity) this); this.onFirstTick(this); @@ -887,7 +866,7 @@ public abstract class TilePoweredGT extends TileEntityBase implements IGregtechP ++tCode; if (!aSideClient) { break Label_1743; - } + } if (this.mNeedsUpdate) { this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); this.mNeedsUpdate = false; @@ -902,7 +881,7 @@ public abstract class TilePoweredGT extends TileEntityBase implements IGregtechP case 7 : { if (aSideServer && this.mTickTimer > 10L) { for (byte i = (byte) (tCode - 2); i < 6; ++i) { - + } } } @@ -932,7 +911,7 @@ public abstract class TilePoweredGT extends TileEntityBase implements IGregtechP if (!aSideServer) { break Label_1743; } - + if (this.xCoord != this.oX || this.yCoord != this.oY || this.zCoord != this.oZ) { this.oX = this.xCoord; this.oY = this.yCoord; @@ -941,7 +920,7 @@ public abstract class TilePoweredGT extends TileEntityBase implements IGregtechP this.clearTileEntityBuffer(); } if (this.mFacing != this.oFacing) { - this.oFacing = this.mFacing; + this.oFacing = this.mFacing; this.issueBlockUpdate(); } if (this.mTickTimer > 20L && this.isElectric()) { @@ -986,7 +965,7 @@ public abstract class TilePoweredGT extends TileEntityBase implements IGregtechP if (!this.hasValidMetaTileEntity()) { this.mRunningThroughTick = false; return; - } + } } } if (!this.hasValidMetaTileEntity()) { @@ -1144,7 +1123,7 @@ public abstract class TilePoweredGT extends TileEntityBase implements IGregtechP private void onFirstTick(TilePoweredGT tilePoweredGT) { // TODO Auto-generated method stub - + } private boolean hasValidMetaTileEntity() { @@ -1158,11 +1137,11 @@ public abstract class TilePoweredGT extends TileEntityBase implements IGregtechP public void issueClientUpdate() { this.mSendClientData = true; } - + public Packet getDescriptionPacket() { this.issueClientUpdate(); return null; } - + } -*/ \ No newline at end of file +*/ diff --git a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java index 835d9da2cd..63cda85458 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java +++ b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java @@ -1,5 +1,10 @@ package gtPlusPlus.core.tileentities.general; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.inventories.InventoryCircuitProgrammer; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.slots.SlotIntegratedCircuit; +import gtPlusPlus.core.util.minecraft.PlayerUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; @@ -8,300 +13,287 @@ import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; -import gtPlusPlus.api.objects.data.AutoMap; -import gtPlusPlus.core.inventories.InventoryCircuitProgrammer; -import gtPlusPlus.core.recipe.common.CI; -import gtPlusPlus.core.slots.SlotIntegratedCircuit; -import gtPlusPlus.core.util.minecraft.PlayerUtils; public class TileEntityCircuitProgrammer extends TileEntity implements ISidedInventory { - private int tickCount = 0; - private final InventoryCircuitProgrammer inventoryContents; - private String customName; - public int locationX; - public int locationY; - public int locationZ; - private int aCurrentMode = 0; - - public TileEntityCircuitProgrammer() { - this.inventoryContents = new InventoryCircuitProgrammer(); - this.setTileLocation(); - } - - public boolean setTileLocation() { - if (this.hasWorldObj()) { - if (!this.getWorldObj().isRemote) { - this.locationX = this.xCoord; - this.locationY = this.yCoord; - this.locationZ = this.zCoord; - return true; - } - } - return false; - } - - //Rename to hasCircuitToConfigure - public final boolean hasCircuitToConfigure() { - for (ItemStack i : this.getInventory().getInventory()) { - if (i == null) { - continue; - } - else { - return true; - } - } - return false; - } - - public InventoryCircuitProgrammer getInventory() { - return this.inventoryContents; - } - - public boolean addOutput() { - ItemStack[] aInputs = this.getInventory().getInventory().clone(); - //Check if there is output in slot. - Boolean hasOutput = false; - if (aInputs[25] != null) { - hasOutput = true; - } - AutoMap aValidSlots = new AutoMap(); - int aSlotCount = 0; - for (ItemStack i : aInputs) { - if (i != null) { - aValidSlots.put(aSlotCount); - } - aSlotCount++; - } - for (int e : aValidSlots) { - boolean doAdd = false; - ItemStack g = this.getStackInSlot(e); - int aSize = 0; - ItemStack aInputStack = null; - int aTypeInSlot = SlotIntegratedCircuit.isRegularProgrammableCircuit(g); - if (aTypeInSlot >= 0 && g != null) { - // No Existing Output - if (!hasOutput) { - aSize = g.stackSize; - doAdd = true; - } - // Existing Output - else { - ItemStack f = this.getStackInSlot(25); - int aTypeInCheckedSlot = SlotIntegratedCircuit.isRegularProgrammableCircuit(f); - // Check that the Circuit in the Output slot is not null and the same type as the circuit input. - if (aTypeInCheckedSlot >= 0 && (aTypeInSlot == aTypeInCheckedSlot) && f != null) { - if (g.getItem() == f.getItem() && f.getItemDamage() == e) { - aSize = f.stackSize + g.stackSize; - if (aSize > 64) { - aInputStack = g.copy(); - aInputStack.stackSize = (aSize-64); - } - doAdd = true; - } - } - } - if (doAdd) { - // Check Circuit Type - ItemStack aOutput; - if (aTypeInSlot == 0) { - aOutput = CI.getNumberedCircuit(e); - } - else if (aTypeInSlot == 1) { - aOutput = CI.getNumberedBioCircuit(e); - } - else if (aTypeInSlot == 2) { - aOutput = CI.getNumberedAdvancedCircuit(e); - } - else { - aOutput = null; - } - - if (aOutput != null) { - aOutput.stackSize = aSize; - this.setInventorySlotContents(e, aInputStack); - this.setInventorySlotContents(25, aOutput); - return true; - } - } - } - continue; - } - return false; - } - - @Override - public void updateEntity() { - try{ - if (!this.worldObj.isRemote) { - if (tickCount % 10 == 0) { - if (hasCircuitToConfigure()) { - this.addOutput(); - this.markDirty(); - } - } - this.tickCount++; - } - } - catch (final Throwable t){} - } - - public boolean anyPlayerInRange() { - return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) != null; - } - - public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) { - if (!nbt.hasKey(tag)) { - nbt.setTag(tag, new NBTTagCompound()); - } - return nbt.getCompoundTag(tag); - } - - @Override - public void writeToNBT(final NBTTagCompound nbt) { - super.writeToNBT(nbt); - // Utils.LOG_WARNING("Trying to write NBT data to TE."); - final NBTTagCompound chestData = new NBTTagCompound(); - this.inventoryContents.writeToNBT(chestData); - nbt.setTag("ContentsChest", chestData); - if (this.hasCustomInventoryName()) { - nbt.setString("CustomName", this.getCustomName()); - } - nbt.setInteger("aCurrentMode", aCurrentMode); - } - - @Override - public void readFromNBT(final NBTTagCompound nbt) { - super.readFromNBT(nbt); - // Utils.LOG_WARNING("Trying to read NBT data from TE."); - this.inventoryContents.readFromNBT(nbt.getCompoundTag("ContentsChest")); - if (nbt.hasKey("CustomName", 8)) { - this.setCustomName(nbt.getString("CustomName")); - } - aCurrentMode = nbt.getInteger("aCurrentMode"); - } - - @Override - public int getSizeInventory() { - return this.getInventory().getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(final int slot) { - return this.getInventory().getStackInSlot(slot); - } - - @Override - public ItemStack decrStackSize(final int slot, final int count) { - return this.getInventory().decrStackSize(slot, count); - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) { - return this.getInventory().getStackInSlotOnClosing(slot); - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) { - this.getInventory().setInventorySlotContents(slot, stack); - } - - @Override - public int getInventoryStackLimit() { - return this.getInventory().getInventoryStackLimit(); - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) { - return this.getInventory().isUseableByPlayer(entityplayer); - } - - @Override - public void openInventory() { - this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); - this.getInventory().openInventory(); - } - - @Override - public void closeInventory() { - this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); - this.getInventory().closeInventory(); - } - - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { - return this.getInventory().isItemValidForSlot(slot, itemstack); - } - - @Override - public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { - final int[] accessibleSides = new int[this.getSizeInventory()]; - for (int r=0; r= 0 && p_102007_1_ <= 24; - } - - @Override - public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { - return p_102008_1_ == 25; - } - - public String getCustomName() { - return this.customName; - } - - public void setCustomName(final String customName) { - this.customName = customName; - } - - @Override - public String getInventoryName() { - return this.hasCustomInventoryName() ? this.customName : "container.circuitprogrammer"; - } - - @Override - public boolean hasCustomInventoryName() { - return (this.customName != null) && !this.customName.equals(""); - } - - @Override - public Packet getDescriptionPacket() { - final NBTTagCompound tag = new NBTTagCompound(); - this.writeToNBT(tag); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, this.blockMetadata, tag); - } - - @Override - public void onDataPacket(final NetworkManager net, final S35PacketUpdateTileEntity pkt) { - final NBTTagCompound tag = pkt.func_148857_g(); - this.readFromNBT(tag); - } - - public boolean onScrewdriverRightClick(byte side, EntityPlayer player, int x, int y, int z) { - try { - if (aCurrentMode == 24) { - aCurrentMode = 0; - } - else { - aCurrentMode++; - } - PlayerUtils.messagePlayer(player, "Now configuring units for type "+aCurrentMode+"."); - return true; - } - catch (Throwable t) { - return false; - } - } - + private int tickCount = 0; + private final InventoryCircuitProgrammer inventoryContents; + private String customName; + public int locationX; + public int locationY; + public int locationZ; + private int aCurrentMode = 0; + + public TileEntityCircuitProgrammer() { + this.inventoryContents = new InventoryCircuitProgrammer(); + this.setTileLocation(); + } + + public boolean setTileLocation() { + if (this.hasWorldObj()) { + if (!this.getWorldObj().isRemote) { + this.locationX = this.xCoord; + this.locationY = this.yCoord; + this.locationZ = this.zCoord; + return true; + } + } + return false; + } + + // Rename to hasCircuitToConfigure + public final boolean hasCircuitToConfigure() { + for (ItemStack i : this.getInventory().getInventory()) { + if (i == null) { + continue; + } else { + return true; + } + } + return false; + } + + public InventoryCircuitProgrammer getInventory() { + return this.inventoryContents; + } + + public boolean addOutput() { + ItemStack[] aInputs = this.getInventory().getInventory().clone(); + // Check if there is output in slot. + Boolean hasOutput = false; + if (aInputs[25] != null) { + hasOutput = true; + } + AutoMap aValidSlots = new AutoMap(); + int aSlotCount = 0; + for (ItemStack i : aInputs) { + if (i != null) { + aValidSlots.put(aSlotCount); + } + aSlotCount++; + } + for (int e : aValidSlots) { + boolean doAdd = false; + ItemStack g = this.getStackInSlot(e); + int aSize = 0; + ItemStack aInputStack = null; + int aTypeInSlot = SlotIntegratedCircuit.isRegularProgrammableCircuit(g); + if (aTypeInSlot >= 0 && g != null) { + // No Existing Output + if (!hasOutput) { + aSize = g.stackSize; + doAdd = true; + } + // Existing Output + else { + ItemStack f = this.getStackInSlot(25); + int aTypeInCheckedSlot = SlotIntegratedCircuit.isRegularProgrammableCircuit(f); + // Check that the Circuit in the Output slot is not null and the same type as the circuit input. + if (aTypeInCheckedSlot >= 0 && (aTypeInSlot == aTypeInCheckedSlot) && f != null) { + if (g.getItem() == f.getItem() && f.getItemDamage() == e) { + aSize = f.stackSize + g.stackSize; + if (aSize > 64) { + aInputStack = g.copy(); + aInputStack.stackSize = (aSize - 64); + } + doAdd = true; + } + } + } + if (doAdd) { + // Check Circuit Type + ItemStack aOutput; + if (aTypeInSlot == 0) { + aOutput = CI.getNumberedCircuit(e); + } else if (aTypeInSlot == 1) { + aOutput = CI.getNumberedBioCircuit(e); + } else if (aTypeInSlot == 2) { + aOutput = CI.getNumberedAdvancedCircuit(e); + } else { + aOutput = null; + } + + if (aOutput != null) { + aOutput.stackSize = aSize; + this.setInventorySlotContents(e, aInputStack); + this.setInventorySlotContents(25, aOutput); + return true; + } + } + } + continue; + } + return false; + } + + @Override + public void updateEntity() { + try { + if (!this.worldObj.isRemote) { + if (tickCount % 10 == 0) { + if (hasCircuitToConfigure()) { + this.addOutput(); + this.markDirty(); + } + } + this.tickCount++; + } + } catch (final Throwable t) { + } + } + + public boolean anyPlayerInRange() { + return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) != null; + } + + public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) { + if (!nbt.hasKey(tag)) { + nbt.setTag(tag, new NBTTagCompound()); + } + return nbt.getCompoundTag(tag); + } + + @Override + public void writeToNBT(final NBTTagCompound nbt) { + super.writeToNBT(nbt); + // Utils.LOG_WARNING("Trying to write NBT data to TE."); + final NBTTagCompound chestData = new NBTTagCompound(); + this.inventoryContents.writeToNBT(chestData); + nbt.setTag("ContentsChest", chestData); + if (this.hasCustomInventoryName()) { + nbt.setString("CustomName", this.getCustomName()); + } + nbt.setInteger("aCurrentMode", aCurrentMode); + } + + @Override + public void readFromNBT(final NBTTagCompound nbt) { + super.readFromNBT(nbt); + // Utils.LOG_WARNING("Trying to read NBT data from TE."); + this.inventoryContents.readFromNBT(nbt.getCompoundTag("ContentsChest")); + if (nbt.hasKey("CustomName", 8)) { + this.setCustomName(nbt.getString("CustomName")); + } + aCurrentMode = nbt.getInteger("aCurrentMode"); + } + + @Override + public int getSizeInventory() { + return this.getInventory().getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.getInventory().getStackInSlot(slot); + } + + @Override + public ItemStack decrStackSize(final int slot, final int count) { + return this.getInventory().decrStackSize(slot, count); + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + return this.getInventory().getStackInSlotOnClosing(slot); + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.getInventory().setInventorySlotContents(slot, stack); + } + + @Override + public int getInventoryStackLimit() { + return this.getInventory().getInventoryStackLimit(); + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return this.getInventory().isUseableByPlayer(entityplayer); + } + + @Override + public void openInventory() { + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + this.getInventory().openInventory(); + } + + @Override + public void closeInventory() { + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + this.getInventory().closeInventory(); + } + + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + return this.getInventory().isItemValidForSlot(slot, itemstack); + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + final int[] accessibleSides = new int[this.getSizeInventory()]; + for (int r = 0; r < this.getInventory().getSizeInventory(); r++) { + accessibleSides[r] = r; + } + return accessibleSides; + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return p_102007_1_ >= 0 && p_102007_1_ <= 24; + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return p_102008_1_ == 25; + } + + public String getCustomName() { + return this.customName; + } + + public void setCustomName(final String customName) { + this.customName = customName; + } + + @Override + public String getInventoryName() { + return this.hasCustomInventoryName() ? this.customName : "container.circuitprogrammer"; + } + + @Override + public boolean hasCustomInventoryName() { + return (this.customName != null) && !this.customName.equals(""); + } + + @Override + public Packet getDescriptionPacket() { + final NBTTagCompound tag = new NBTTagCompound(); + this.writeToNBT(tag); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, this.blockMetadata, tag); + } + + @Override + public void onDataPacket(final NetworkManager net, final S35PacketUpdateTileEntity pkt) { + final NBTTagCompound tag = pkt.func_148857_g(); + this.readFromNBT(tag); + } + + public boolean onScrewdriverRightClick(byte side, EntityPlayer player, int x, int y, int z) { + try { + if (aCurrentMode == 24) { + aCurrentMode = 0; + } else { + aCurrentMode++; + } + PlayerUtils.messagePlayer(player, "Now configuring units for type " + aCurrentMode + "."); + return true; + } catch (Throwable t) { + return false; + } + } } diff --git a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java index db93e9c4fc..aaf95a3291 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java +++ b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java @@ -13,347 +13,353 @@ import net.minecraft.world.World; public class TileEntityDecayablesChest extends TileEntity implements ISidedInventory { - private final Inventory_DecayablesChest inventoryContents; - - /** Determines if the check for adjacent chests has taken place. */ - public boolean adjacentChestChecked; - /** Contains the chest tile located adjacent to this one (if any) */ - public TileEntityDecayablesChest adjacentChestZNeg; - /** Contains the chest tile located adjacent to this one (if any) */ - public TileEntityDecayablesChest adjacentChestXPos; - /** Contains the chest tile located adjacent to this one (if any) */ - public TileEntityDecayablesChest adjacentChestXNeg; - /** Contains the chest tile located adjacent to this one (if any) */ - public TileEntityDecayablesChest adjacentChestZPos; - /** The current angle of the lid (between 0 and 1) */ - public float lidAngle; - /** The angle of the lid last tick */ - public float prevLidAngle; - /** The number of players currently using this chest */ - public int numPlayersUsing; - - private String customName; - - private int cachedChestType; - private int tickCount = 0; - - public TileEntityDecayablesChest() { - this.inventoryContents = new Inventory_DecayablesChest(); - } - - public Inventory_DecayablesChest getInventory() { - return this.inventoryContents; - } - - @Override - public void updateEntity() { - - // Try do chesty stuff - try { - this.updateEntityChest(); - } catch (Throwable t) { - - } - - try { - if (!this.worldObj.isRemote) { - this.tickCount++; - if ((this.tickCount % 10) == 0) { - cachedChestType = 1; - } - - if ((this.tickCount % 20) == 0) { - for (ItemStack inv : this.getInventory().getInventory()) { - if (inv == null) { - continue; - } - if (inv.getItem() instanceof DustDecayable) { - DustDecayable D = (DustDecayable) inv.getItem(); - tryUpdateDecayable(D, inv, this.worldObj); - } - } - - } - updateSlots(); - } - } catch (final Throwable t) { - } - } - - public void tryUpdateDecayable(final DustDecayable b, ItemStack iStack, final World world) { - if (world == null || iStack == null) { - return; - } - if (world.isRemote) { - return; - } - - boolean a1, a2; - int u = 0; - a1 = b.isTicking(world, iStack); - a2 = false; - int SECONDS_TO_PROCESS = 1; - while (u < (20 * SECONDS_TO_PROCESS)) { - if (!a1) { - break; - } - a1 = b.isTicking(world, iStack); - a2 = b.tickItemTag(world, iStack); - u++; - } - Logger.MACHINE_INFO("| "+b.getUnlocalizedName()+" | "+a1+"/"+a2); - - if (!a1 && !a2) { - ItemStack replacement = ItemUtils.getSimpleStack(b.getDecayResult()); - replacement.stackSize = 1; - //iStack = replacement.copy(); - for (int fff = 0; fff < this.inventoryContents.getSizeInventory(); fff++) { - if (this.inventoryContents.getStackInSlot(fff) == iStack) { - this.inventoryContents.setInventorySlotContents(fff, replacement.copy()); - } - } - - updateSlots(); - this.inventoryContents. - markDirty(); - } - } - - public boolean anyPlayerInRange() { - return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) != null; - } - - public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) { - if (!nbt.hasKey(tag)) { - nbt.setTag(tag, new NBTTagCompound()); - } - return nbt.getCompoundTag(tag); - } - - @Override - public void writeToNBT(final NBTTagCompound nbt) { - super.writeToNBT(nbt); - // Utils.LOG_WARNING("Trying to write NBT data to TE."); - final NBTTagCompound chestData = new NBTTagCompound(); - this.inventoryContents.writeToNBT(chestData); - nbt.setTag("ContentsChest", chestData); - if (this.hasCustomInventoryName()) { - nbt.setString("CustomName", this.getCustomName()); - } - } - - @Override - public void readFromNBT(final NBTTagCompound nbt) { - super.readFromNBT(nbt); - // Utils.LOG_WARNING("Trying to read NBT data from TE."); - this.inventoryContents.readFromNBT(nbt.getCompoundTag("ContentsChest")); - if (nbt.hasKey("CustomName", 8)) { - this.setCustomName(nbt.getString("CustomName")); - } - } - - @Override - public int getSizeInventory() { - return this.getInventory().getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(final int slot) { - return this.getInventory().getStackInSlot(slot); - } - - @Override - public ItemStack decrStackSize(final int slot, final int count) { - return this.getInventory().decrStackSize(slot, count); - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) { - return this.getInventory().getStackInSlotOnClosing(slot); - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) { - this.getInventory().setInventorySlotContents(slot, stack); - } - - @Override - public int getInventoryStackLimit() { - return this.getInventory().getInventoryStackLimit(); - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) { - return this.getInventory().isUseableByPlayer(entityplayer); - } - - @Override - public void openInventory() { - if (this.numPlayersUsing < 0) { - this.numPlayersUsing = 0; - } - if (!this.worldObj.isRemote) { - this.numPlayersUsing++; - cachedChestType = 1; - } - this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.numPlayersUsing); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); - this.getInventory().openInventory(); - } - - @Override - public void closeInventory() { - if (!this.worldObj.isRemote) { - this.numPlayersUsing--; - cachedChestType = 1; - } - this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.numPlayersUsing); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); - this.getInventory().closeInventory(); - } - - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { - return this.getInventory().isItemValidForSlot(slot, itemstack); - } - - @Override - public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { - final int[] accessibleSides = new int[this.getSizeInventory()]; - for (int r = 0; r < this.getInventory().getSizeInventory(); r++) { - accessibleSides[r] = r; - } - return accessibleSides; - - } - - @Override - public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { - return this.getInventory().isItemValidForSlot(0, p_102007_2_); - } - - @Override - public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { - return this.getInventory().isItemValidForSlot(0, p_102008_2_); - } - - public String getCustomName() { - return this.customName; - } - - public void setCustomName(final String customName) { - this.customName = customName; - } - - @Override - public String getInventoryName() { - return this.hasCustomInventoryName() ? this.customName : "container.DecayablesChest"; - } - - @Override - public boolean hasCustomInventoryName() { - return (this.customName != null) && !this.customName.equals(""); - } - - /** - * Causes the TileEntity to reset all it's cached values for it's container - * Block, metadata and in the case of chests, the adjacent chest check - */ - public void updateContainingBlockInfo() { - super.updateContainingBlockInfo(); - this.adjacentChestChecked = false; - } - - /** - * Performs the check for adjacent chests to determine if this chest is double - * or not. - */ - public void checkForAdjacentChests() { - if (!this.adjacentChestChecked) { - this.adjacentChestChecked = true; - this.adjacentChestZNeg = null; - this.adjacentChestXPos = null; - this.adjacentChestXNeg = null; - this.adjacentChestZPos = null; - } - } - - public void updateEntityChest() { - float f; - this.prevLidAngle = this.lidAngle; - f = 0.04F; - double d2; - if (this.numPlayersUsing > 0 && this.lidAngle == 0.0F && this.adjacentChestZNeg == null - && this.adjacentChestXNeg == null) { - double d1 = (double) this.xCoord + 0.5D; - d2 = (double) this.zCoord + 0.5D; - this.worldObj.playSoundEffect(d1, (double) this.yCoord + 0.5D, d2, "random.chestopen", 0.5F, - this.worldObj.rand.nextFloat() * 0.1F + 0.9F); - } - - if (this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F) { - float f1 = this.lidAngle; - if (this.numPlayersUsing > 0) { - //this.lidAngle += f; - this.lidAngle += (float) (f * (1 + 0.10 * 0.01)); - } else { - //this.lidAngle -= f; - this.lidAngle -= (float) (f * (1 + 0.10 * 0.01)); - } - if (this.lidAngle > 1.0F) { - this.lidAngle = 1.0F; - } - float f2 = 0.5F; - if (this.lidAngle < f2 && f1 >= f2 && this.adjacentChestZNeg == null && this.adjacentChestXNeg == null) { - d2 = (double) this.xCoord + 0.5D; - double d0 = (double) this.zCoord + 0.5D; - this.worldObj.playSoundEffect(d2, (double) this.yCoord + 0.5D, d0, "random.chestclosed", 0.5F, - this.worldObj.rand.nextFloat() * 0.1F + 0.9F); - } - - if (this.lidAngle < 0.0F) { - this.lidAngle = 0.0F; - } - } - } - - /** - * Called when a client event is received with the event number and argument, - * see World.sendClientEvent - */ - public boolean receiveClientEvent(int p_145842_1_, int p_145842_2_) { - if (p_145842_1_ == 1) - { - this.numPlayersUsing = p_145842_2_; - return true; - } - else - { - return super.receiveClientEvent(p_145842_1_, p_145842_2_); - } - } - - /** - * invalidates a tile entity - */ - public final void invalidate() { - super.invalidate(); - cachedChestType = 1; - this.updateContainingBlockInfo(); - this.checkForAdjacentChests(); - } - - private final int updateSlots() { - //Have slots changed? - if (cachedChestType == 0) { - return 0; - } - ItemUtils.organiseInventory(getInventory()); - cachedChestType = 0; - return cachedChestType; - - } - + private final Inventory_DecayablesChest inventoryContents; + + /** Determines if the check for adjacent chests has taken place. */ + public boolean adjacentChestChecked; + /** Contains the chest tile located adjacent to this one (if any) */ + public TileEntityDecayablesChest adjacentChestZNeg; + /** Contains the chest tile located adjacent to this one (if any) */ + public TileEntityDecayablesChest adjacentChestXPos; + /** Contains the chest tile located adjacent to this one (if any) */ + public TileEntityDecayablesChest adjacentChestXNeg; + /** Contains the chest tile located adjacent to this one (if any) */ + public TileEntityDecayablesChest adjacentChestZPos; + /** The current angle of the lid (between 0 and 1) */ + public float lidAngle; + /** The angle of the lid last tick */ + public float prevLidAngle; + /** The number of players currently using this chest */ + public int numPlayersUsing; + + private String customName; + + private int cachedChestType; + private int tickCount = 0; + + public TileEntityDecayablesChest() { + this.inventoryContents = new Inventory_DecayablesChest(); + } + + public Inventory_DecayablesChest getInventory() { + return this.inventoryContents; + } + + @Override + public void updateEntity() { + + // Try do chesty stuff + try { + this.updateEntityChest(); + } catch (Throwable t) { + + } + + try { + if (!this.worldObj.isRemote) { + this.tickCount++; + if ((this.tickCount % 10) == 0) { + cachedChestType = 1; + } + + if ((this.tickCount % 20) == 0) { + for (ItemStack inv : this.getInventory().getInventory()) { + if (inv == null) { + continue; + } + if (inv.getItem() instanceof DustDecayable) { + DustDecayable D = (DustDecayable) inv.getItem(); + tryUpdateDecayable(D, inv, this.worldObj); + } + } + } + updateSlots(); + } + } catch (final Throwable t) { + } + } + + public void tryUpdateDecayable(final DustDecayable b, ItemStack iStack, final World world) { + if (world == null || iStack == null) { + return; + } + if (world.isRemote) { + return; + } + + boolean a1, a2; + int u = 0; + a1 = b.isTicking(world, iStack); + a2 = false; + int SECONDS_TO_PROCESS = 1; + while (u < (20 * SECONDS_TO_PROCESS)) { + if (!a1) { + break; + } + a1 = b.isTicking(world, iStack); + a2 = b.tickItemTag(world, iStack); + u++; + } + Logger.MACHINE_INFO("| " + b.getUnlocalizedName() + " | " + a1 + "/" + a2); + + if (!a1 && !a2) { + ItemStack replacement = ItemUtils.getSimpleStack(b.getDecayResult()); + replacement.stackSize = 1; + // iStack = replacement.copy(); + for (int fff = 0; fff < this.inventoryContents.getSizeInventory(); fff++) { + if (this.inventoryContents.getStackInSlot(fff) == iStack) { + this.inventoryContents.setInventorySlotContents(fff, replacement.copy()); + } + } + + updateSlots(); + this.inventoryContents.markDirty(); + } + } + + public boolean anyPlayerInRange() { + return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) != null; + } + + public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) { + if (!nbt.hasKey(tag)) { + nbt.setTag(tag, new NBTTagCompound()); + } + return nbt.getCompoundTag(tag); + } + + @Override + public void writeToNBT(final NBTTagCompound nbt) { + super.writeToNBT(nbt); + // Utils.LOG_WARNING("Trying to write NBT data to TE."); + final NBTTagCompound chestData = new NBTTagCompound(); + this.inventoryContents.writeToNBT(chestData); + nbt.setTag("ContentsChest", chestData); + if (this.hasCustomInventoryName()) { + nbt.setString("CustomName", this.getCustomName()); + } + } + + @Override + public void readFromNBT(final NBTTagCompound nbt) { + super.readFromNBT(nbt); + // Utils.LOG_WARNING("Trying to read NBT data from TE."); + this.inventoryContents.readFromNBT(nbt.getCompoundTag("ContentsChest")); + if (nbt.hasKey("CustomName", 8)) { + this.setCustomName(nbt.getString("CustomName")); + } + } + + @Override + public int getSizeInventory() { + return this.getInventory().getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.getInventory().getStackInSlot(slot); + } + + @Override + public ItemStack decrStackSize(final int slot, final int count) { + return this.getInventory().decrStackSize(slot, count); + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + return this.getInventory().getStackInSlotOnClosing(slot); + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.getInventory().setInventorySlotContents(slot, stack); + } + + @Override + public int getInventoryStackLimit() { + return this.getInventory().getInventoryStackLimit(); + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return this.getInventory().isUseableByPlayer(entityplayer); + } + + @Override + public void openInventory() { + if (this.numPlayersUsing < 0) { + this.numPlayersUsing = 0; + } + if (!this.worldObj.isRemote) { + this.numPlayersUsing++; + cachedChestType = 1; + } + this.worldObj.addBlockEvent( + this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.numPlayersUsing); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + this.getInventory().openInventory(); + } + + @Override + public void closeInventory() { + if (!this.worldObj.isRemote) { + this.numPlayersUsing--; + cachedChestType = 1; + } + this.worldObj.addBlockEvent( + this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.numPlayersUsing); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + this.getInventory().closeInventory(); + } + + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + return this.getInventory().isItemValidForSlot(slot, itemstack); + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + final int[] accessibleSides = new int[this.getSizeInventory()]; + for (int r = 0; r < this.getInventory().getSizeInventory(); r++) { + accessibleSides[r] = r; + } + return accessibleSides; + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return this.getInventory().isItemValidForSlot(0, p_102007_2_); + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return this.getInventory().isItemValidForSlot(0, p_102008_2_); + } + + public String getCustomName() { + return this.customName; + } + + public void setCustomName(final String customName) { + this.customName = customName; + } + + @Override + public String getInventoryName() { + return this.hasCustomInventoryName() ? this.customName : "container.DecayablesChest"; + } + + @Override + public boolean hasCustomInventoryName() { + return (this.customName != null) && !this.customName.equals(""); + } + + /** + * Causes the TileEntity to reset all it's cached values for it's container + * Block, metadata and in the case of chests, the adjacent chest check + */ + public void updateContainingBlockInfo() { + super.updateContainingBlockInfo(); + this.adjacentChestChecked = false; + } + + /** + * Performs the check for adjacent chests to determine if this chest is double + * or not. + */ + public void checkForAdjacentChests() { + if (!this.adjacentChestChecked) { + this.adjacentChestChecked = true; + this.adjacentChestZNeg = null; + this.adjacentChestXPos = null; + this.adjacentChestXNeg = null; + this.adjacentChestZPos = null; + } + } + + public void updateEntityChest() { + float f; + this.prevLidAngle = this.lidAngle; + f = 0.04F; + double d2; + if (this.numPlayersUsing > 0 + && this.lidAngle == 0.0F + && this.adjacentChestZNeg == null + && this.adjacentChestXNeg == null) { + double d1 = (double) this.xCoord + 0.5D; + d2 = (double) this.zCoord + 0.5D; + this.worldObj.playSoundEffect( + d1, + (double) this.yCoord + 0.5D, + d2, + "random.chestopen", + 0.5F, + this.worldObj.rand.nextFloat() * 0.1F + 0.9F); + } + + if (this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F) { + float f1 = this.lidAngle; + if (this.numPlayersUsing > 0) { + // this.lidAngle += f; + this.lidAngle += (float) (f * (1 + 0.10 * 0.01)); + } else { + // this.lidAngle -= f; + this.lidAngle -= (float) (f * (1 + 0.10 * 0.01)); + } + if (this.lidAngle > 1.0F) { + this.lidAngle = 1.0F; + } + float f2 = 0.5F; + if (this.lidAngle < f2 && f1 >= f2 && this.adjacentChestZNeg == null && this.adjacentChestXNeg == null) { + d2 = (double) this.xCoord + 0.5D; + double d0 = (double) this.zCoord + 0.5D; + this.worldObj.playSoundEffect( + d2, + (double) this.yCoord + 0.5D, + d0, + "random.chestclosed", + 0.5F, + this.worldObj.rand.nextFloat() * 0.1F + 0.9F); + } + + if (this.lidAngle < 0.0F) { + this.lidAngle = 0.0F; + } + } + } + + /** + * Called when a client event is received with the event number and argument, + * see World.sendClientEvent + */ + public boolean receiveClientEvent(int p_145842_1_, int p_145842_2_) { + if (p_145842_1_ == 1) { + this.numPlayersUsing = p_145842_2_; + return true; + } else { + return super.receiveClientEvent(p_145842_1_, p_145842_2_); + } + } + + /** + * invalidates a tile entity + */ + public final void invalidate() { + super.invalidate(); + cachedChestType = 1; + this.updateContainingBlockInfo(); + this.checkForAdjacentChests(); + } + + private final int updateSlots() { + // Have slots changed? + if (cachedChestType == 0) { + return 0; + } + ItemUtils.organiseInventory(getInventory()); + cachedChestType = 0; + return cachedChestType; + } } diff --git a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityEggBox.java b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityEggBox.java index 0c428537cb..c47a6fa092 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityEggBox.java +++ b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityEggBox.java @@ -13,347 +13,353 @@ import net.minecraft.world.World; public class TileEntityEggBox extends TileEntity implements ISidedInventory { - private final Inventory_EggBox inventoryContents; - - /** Determines if the check for adjacent chests has taken place. */ - public boolean adjacentChestChecked; - /** Contains the chest tile located adjacent to this one (if any) */ - public TileEntityEggBox adjacentChestZNeg; - /** Contains the chest tile located adjacent to this one (if any) */ - public TileEntityEggBox adjacentChestXPos; - /** Contains the chest tile located adjacent to this one (if any) */ - public TileEntityEggBox adjacentChestXNeg; - /** Contains the chest tile located adjacent to this one (if any) */ - public TileEntityEggBox adjacentChestZPos; - /** The current angle of the lid (between 0 and 1) */ - public float lidAngle; - /** The angle of the lid last tick */ - public float prevLidAngle; - /** The number of players currently using this chest */ - public int numPlayersUsing; - - private String customName; - - private int cachedChestType; - private int tickCount = 0; - - public TileEntityEggBox() { - this.inventoryContents = new Inventory_EggBox(); - } - - public Inventory_EggBox getInventory() { - return this.inventoryContents; - } - - @Override - public void updateEntity() { - - // Try do chesty stuff - try { - this.updateEntityChest(); - } catch (Throwable t) { - - } - - try { - if (!this.worldObj.isRemote) { - this.tickCount++; - if ((this.tickCount % 10) == 0) { - cachedChestType = 1; - } - - if ((this.tickCount % 20) == 0) { - for (ItemStack inv : this.getInventory().getInventory()) { - if (inv == null) { - continue; - } - if (inv.getItem() instanceof ItemGiantEgg) { - ItemGiantEgg D = (ItemGiantEgg) inv.getItem(); - tryUpdateDecayable(D, inv, this.worldObj); - } - } - - } - updateSlots(); - } - } catch (final Throwable t) { - } - } - - public void tryUpdateDecayable(final ItemGiantEgg d, ItemStack iStack, final World world) { - if (world == null || iStack == null) { - return; - } - if (world.isRemote) { - return; - } - - boolean a1, a2; - int u = 0; - a1 = d.isTicking(world, iStack); - a2 = false; - int SECONDS_TO_PROCESS = 1; - while (u < (20 * SECONDS_TO_PROCESS)) { - if (!a1) { - break; - } - a1 = d.isTicking(world, iStack); - a2 = d.tickItemTag(world, iStack); - u++; - } - Logger.MACHINE_INFO("| "+d.getUnlocalizedName()+" | "+a1+"/"+a2); - - if (!a1 && !a2) { - ItemStack replacement = ItemUtils.getSimpleStack(d.getHatchResult(), 1); - replacement.stackSize = 1; - //iStack = replacement.copy(); - for (int fff = 0; fff < this.inventoryContents.getSizeInventory(); fff++) { - if (this.inventoryContents.getStackInSlot(fff) == iStack) { - this.inventoryContents.setInventorySlotContents(fff, replacement.copy()); - } - } - - updateSlots(); - this.inventoryContents. - markDirty(); - } - } - - public boolean anyPlayerInRange() { - return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) != null; - } - - public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) { - if (!nbt.hasKey(tag)) { - nbt.setTag(tag, new NBTTagCompound()); - } - return nbt.getCompoundTag(tag); - } - - @Override - public void writeToNBT(final NBTTagCompound nbt) { - super.writeToNBT(nbt); - // Utils.LOG_WARNING("Trying to write NBT data to TE."); - final NBTTagCompound chestData = new NBTTagCompound(); - this.inventoryContents.writeToNBT(chestData); - nbt.setTag("ContentsChest", chestData); - if (this.hasCustomInventoryName()) { - nbt.setString("CustomName", this.getCustomName()); - } - } - - @Override - public void readFromNBT(final NBTTagCompound nbt) { - super.readFromNBT(nbt); - // Utils.LOG_WARNING("Trying to read NBT data from TE."); - this.inventoryContents.readFromNBT(nbt.getCompoundTag("ContentsChest")); - if (nbt.hasKey("CustomName", 8)) { - this.setCustomName(nbt.getString("CustomName")); - } - } - - @Override - public int getSizeInventory() { - return this.getInventory().getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(final int slot) { - return this.getInventory().getStackInSlot(slot); - } - - @Override - public ItemStack decrStackSize(final int slot, final int count) { - return this.getInventory().decrStackSize(slot, count); - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) { - return this.getInventory().getStackInSlotOnClosing(slot); - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) { - this.getInventory().setInventorySlotContents(slot, stack); - } - - @Override - public int getInventoryStackLimit() { - return this.getInventory().getInventoryStackLimit(); - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) { - return this.getInventory().isUseableByPlayer(entityplayer); - } - - @Override - public void openInventory() { - if (this.numPlayersUsing < 0) { - this.numPlayersUsing = 0; - } - if (!this.worldObj.isRemote) { - this.numPlayersUsing++; - cachedChestType = 1; - } - this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.numPlayersUsing); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); - this.getInventory().openInventory(); - } - - @Override - public void closeInventory() { - if (!this.worldObj.isRemote) { - this.numPlayersUsing--; - cachedChestType = 1; - } - this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.numPlayersUsing); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); - this.getInventory().closeInventory(); - } - - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { - return this.getInventory().isItemValidForSlot(slot, itemstack); - } - - @Override - public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { - final int[] accessibleSides = new int[this.getSizeInventory()]; - for (int r = 0; r < this.getInventory().getSizeInventory(); r++) { - accessibleSides[r] = r; - } - return accessibleSides; - - } - - @Override - public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { - return this.getInventory().isItemValidForSlot(0, p_102007_2_); - } - - @Override - public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { - return this.getInventory().isItemValidForSlot(0, p_102008_2_); - } - - public String getCustomName() { - return this.customName; - } - - public void setCustomName(final String customName) { - this.customName = customName; - } - - @Override - public String getInventoryName() { - return this.hasCustomInventoryName() ? this.customName : "container.EggBox"; - } - - @Override - public boolean hasCustomInventoryName() { - return (this.customName != null) && !this.customName.equals(""); - } - - /** - * Causes the TileEntity to reset all it's cached values for it's container - * Block, metadata and in the case of chests, the adjacent chest check - */ - public void updateContainingBlockInfo() { - super.updateContainingBlockInfo(); - this.adjacentChestChecked = false; - } - - /** - * Performs the check for adjacent chests to determine if this chest is double - * or not. - */ - public void checkForAdjacentChests() { - if (!this.adjacentChestChecked) { - this.adjacentChestChecked = true; - this.adjacentChestZNeg = null; - this.adjacentChestXPos = null; - this.adjacentChestXNeg = null; - this.adjacentChestZPos = null; - } - } - - public void updateEntityChest() { - float f; - this.prevLidAngle = this.lidAngle; - f = 0.04F; - double d2; - if (this.numPlayersUsing > 0 && this.lidAngle == 0.0F && this.adjacentChestZNeg == null - && this.adjacentChestXNeg == null) { - double d1 = (double) this.xCoord + 0.5D; - d2 = (double) this.zCoord + 0.5D; - this.worldObj.playSoundEffect(d1, (double) this.yCoord + 0.5D, d2, "random.chestopen", 0.5F, - this.worldObj.rand.nextFloat() * 0.1F + 0.9F); - } - - if (this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F) { - float f1 = this.lidAngle; - if (this.numPlayersUsing > 0) { - //this.lidAngle += f; - this.lidAngle += (float) (f * (1 + 0.10 * 0.01)); - } else { - //this.lidAngle -= f; - this.lidAngle -= (float) (f * (1 + 0.10 * 0.01)); - } - if (this.lidAngle > 1.0F) { - this.lidAngle = 1.0F; - } - float f2 = 0.5F; - if (this.lidAngle < f2 && f1 >= f2 && this.adjacentChestZNeg == null && this.adjacentChestXNeg == null) { - d2 = (double) this.xCoord + 0.5D; - double d0 = (double) this.zCoord + 0.5D; - this.worldObj.playSoundEffect(d2, (double) this.yCoord + 0.5D, d0, "random.chestclosed", 0.5F, - this.worldObj.rand.nextFloat() * 0.1F + 0.9F); - } - - if (this.lidAngle < 0.0F) { - this.lidAngle = 0.0F; - } - } - } - - /** - * Called when a client event is received with the event number and argument, - * see World.sendClientEvent - */ - public boolean receiveClientEvent(int p_145842_1_, int p_145842_2_) { - if (p_145842_1_ == 1) - { - this.numPlayersUsing = p_145842_2_; - return true; - } - else - { - return super.receiveClientEvent(p_145842_1_, p_145842_2_); - } - } - - /** - * invalidates a tile entity - */ - public final void invalidate() { - super.invalidate(); - cachedChestType = 1; - this.updateContainingBlockInfo(); - this.checkForAdjacentChests(); - } - - private final int updateSlots() { - //Have slots changed? - if (cachedChestType == 0) { - return 0; - } - ItemUtils.organiseInventory(getInventory()); - cachedChestType = 0; - return cachedChestType; - - } - + private final Inventory_EggBox inventoryContents; + + /** Determines if the check for adjacent chests has taken place. */ + public boolean adjacentChestChecked; + /** Contains the chest tile located adjacent to this one (if any) */ + public TileEntityEggBox adjacentChestZNeg; + /** Contains the chest tile located adjacent to this one (if any) */ + public TileEntityEggBox adjacentChestXPos; + /** Contains the chest tile located adjacent to this one (if any) */ + public TileEntityEggBox adjacentChestXNeg; + /** Contains the chest tile located adjacent to this one (if any) */ + public TileEntityEggBox adjacentChestZPos; + /** The current angle of the lid (between 0 and 1) */ + public float lidAngle; + /** The angle of the lid last tick */ + public float prevLidAngle; + /** The number of players currently using this chest */ + public int numPlayersUsing; + + private String customName; + + private int cachedChestType; + private int tickCount = 0; + + public TileEntityEggBox() { + this.inventoryContents = new Inventory_EggBox(); + } + + public Inventory_EggBox getInventory() { + return this.inventoryContents; + } + + @Override + public void updateEntity() { + + // Try do chesty stuff + try { + this.updateEntityChest(); + } catch (Throwable t) { + + } + + try { + if (!this.worldObj.isRemote) { + this.tickCount++; + if ((this.tickCount % 10) == 0) { + cachedChestType = 1; + } + + if ((this.tickCount % 20) == 0) { + for (ItemStack inv : this.getInventory().getInventory()) { + if (inv == null) { + continue; + } + if (inv.getItem() instanceof ItemGiantEgg) { + ItemGiantEgg D = (ItemGiantEgg) inv.getItem(); + tryUpdateDecayable(D, inv, this.worldObj); + } + } + } + updateSlots(); + } + } catch (final Throwable t) { + } + } + + public void tryUpdateDecayable(final ItemGiantEgg d, ItemStack iStack, final World world) { + if (world == null || iStack == null) { + return; + } + if (world.isRemote) { + return; + } + + boolean a1, a2; + int u = 0; + a1 = d.isTicking(world, iStack); + a2 = false; + int SECONDS_TO_PROCESS = 1; + while (u < (20 * SECONDS_TO_PROCESS)) { + if (!a1) { + break; + } + a1 = d.isTicking(world, iStack); + a2 = d.tickItemTag(world, iStack); + u++; + } + Logger.MACHINE_INFO("| " + d.getUnlocalizedName() + " | " + a1 + "/" + a2); + + if (!a1 && !a2) { + ItemStack replacement = ItemUtils.getSimpleStack(d.getHatchResult(), 1); + replacement.stackSize = 1; + // iStack = replacement.copy(); + for (int fff = 0; fff < this.inventoryContents.getSizeInventory(); fff++) { + if (this.inventoryContents.getStackInSlot(fff) == iStack) { + this.inventoryContents.setInventorySlotContents(fff, replacement.copy()); + } + } + + updateSlots(); + this.inventoryContents.markDirty(); + } + } + + public boolean anyPlayerInRange() { + return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) != null; + } + + public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) { + if (!nbt.hasKey(tag)) { + nbt.setTag(tag, new NBTTagCompound()); + } + return nbt.getCompoundTag(tag); + } + + @Override + public void writeToNBT(final NBTTagCompound nbt) { + super.writeToNBT(nbt); + // Utils.LOG_WARNING("Trying to write NBT data to TE."); + final NBTTagCompound chestData = new NBTTagCompound(); + this.inventoryContents.writeToNBT(chestData); + nbt.setTag("ContentsChest", chestData); + if (this.hasCustomInventoryName()) { + nbt.setString("CustomName", this.getCustomName()); + } + } + + @Override + public void readFromNBT(final NBTTagCompound nbt) { + super.readFromNBT(nbt); + // Utils.LOG_WARNING("Trying to read NBT data from TE."); + this.inventoryContents.readFromNBT(nbt.getCompoundTag("ContentsChest")); + if (nbt.hasKey("CustomName", 8)) { + this.setCustomName(nbt.getString("CustomName")); + } + } + + @Override + public int getSizeInventory() { + return this.getInventory().getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.getInventory().getStackInSlot(slot); + } + + @Override + public ItemStack decrStackSize(final int slot, final int count) { + return this.getInventory().decrStackSize(slot, count); + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + return this.getInventory().getStackInSlotOnClosing(slot); + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.getInventory().setInventorySlotContents(slot, stack); + } + + @Override + public int getInventoryStackLimit() { + return this.getInventory().getInventoryStackLimit(); + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return this.getInventory().isUseableByPlayer(entityplayer); + } + + @Override + public void openInventory() { + if (this.numPlayersUsing < 0) { + this.numPlayersUsing = 0; + } + if (!this.worldObj.isRemote) { + this.numPlayersUsing++; + cachedChestType = 1; + } + this.worldObj.addBlockEvent( + this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.numPlayersUsing); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + this.getInventory().openInventory(); + } + + @Override + public void closeInventory() { + if (!this.worldObj.isRemote) { + this.numPlayersUsing--; + cachedChestType = 1; + } + this.worldObj.addBlockEvent( + this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.numPlayersUsing); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + this.getInventory().closeInventory(); + } + + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + return this.getInventory().isItemValidForSlot(slot, itemstack); + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + final int[] accessibleSides = new int[this.getSizeInventory()]; + for (int r = 0; r < this.getInventory().getSizeInventory(); r++) { + accessibleSides[r] = r; + } + return accessibleSides; + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return this.getInventory().isItemValidForSlot(0, p_102007_2_); + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return this.getInventory().isItemValidForSlot(0, p_102008_2_); + } + + public String getCustomName() { + return this.customName; + } + + public void setCustomName(final String customName) { + this.customName = customName; + } + + @Override + public String getInventoryName() { + return this.hasCustomInventoryName() ? this.customName : "container.EggBox"; + } + + @Override + public boolean hasCustomInventoryName() { + return (this.customName != null) && !this.customName.equals(""); + } + + /** + * Causes the TileEntity to reset all it's cached values for it's container + * Block, metadata and in the case of chests, the adjacent chest check + */ + public void updateContainingBlockInfo() { + super.updateContainingBlockInfo(); + this.adjacentChestChecked = false; + } + + /** + * Performs the check for adjacent chests to determine if this chest is double + * or not. + */ + public void checkForAdjacentChests() { + if (!this.adjacentChestChecked) { + this.adjacentChestChecked = true; + this.adjacentChestZNeg = null; + this.adjacentChestXPos = null; + this.adjacentChestXNeg = null; + this.adjacentChestZPos = null; + } + } + + public void updateEntityChest() { + float f; + this.prevLidAngle = this.lidAngle; + f = 0.04F; + double d2; + if (this.numPlayersUsing > 0 + && this.lidAngle == 0.0F + && this.adjacentChestZNeg == null + && this.adjacentChestXNeg == null) { + double d1 = (double) this.xCoord + 0.5D; + d2 = (double) this.zCoord + 0.5D; + this.worldObj.playSoundEffect( + d1, + (double) this.yCoord + 0.5D, + d2, + "random.chestopen", + 0.5F, + this.worldObj.rand.nextFloat() * 0.1F + 0.9F); + } + + if (this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F) { + float f1 = this.lidAngle; + if (this.numPlayersUsing > 0) { + // this.lidAngle += f; + this.lidAngle += (float) (f * (1 + 0.10 * 0.01)); + } else { + // this.lidAngle -= f; + this.lidAngle -= (float) (f * (1 + 0.10 * 0.01)); + } + if (this.lidAngle > 1.0F) { + this.lidAngle = 1.0F; + } + float f2 = 0.5F; + if (this.lidAngle < f2 && f1 >= f2 && this.adjacentChestZNeg == null && this.adjacentChestXNeg == null) { + d2 = (double) this.xCoord + 0.5D; + double d0 = (double) this.zCoord + 0.5D; + this.worldObj.playSoundEffect( + d2, + (double) this.yCoord + 0.5D, + d0, + "random.chestclosed", + 0.5F, + this.worldObj.rand.nextFloat() * 0.1F + 0.9F); + } + + if (this.lidAngle < 0.0F) { + this.lidAngle = 0.0F; + } + } + } + + /** + * Called when a client event is received with the event number and argument, + * see World.sendClientEvent + */ + public boolean receiveClientEvent(int p_145842_1_, int p_145842_2_) { + if (p_145842_1_ == 1) { + this.numPlayersUsing = p_145842_2_; + return true; + } else { + return super.receiveClientEvent(p_145842_1_, p_145842_2_); + } + } + + /** + * invalidates a tile entity + */ + public final void invalidate() { + super.invalidate(); + cachedChestType = 1; + this.updateContainingBlockInfo(); + this.checkForAdjacentChests(); + } + + private final int updateSlots() { + // Have slots changed? + if (cachedChestType == 0) { + return 0; + } + ItemUtils.organiseInventory(getInventory()); + cachedChestType = 0; + return cachedChestType; + } } diff --git a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityFirepit.java b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityFirepit.java index 49fde8ee64..67e044fc36 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityFirepit.java +++ b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityFirepit.java @@ -1,39 +1,37 @@ package gtPlusPlus.core.tileentities.general; import java.util.UUID; - import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -public class TileEntityFirepit extends TileEntity{ - - private UUID ownerUUID; +public class TileEntityFirepit extends TileEntity { - public UUID getOwnerUUID() { - return this.ownerUUID; - } + private UUID ownerUUID; - public void setOwnerUUID(final UUID ownerUUID) { - this.ownerUUID = ownerUUID; - this.markDirty(); - } + public UUID getOwnerUUID() { + return this.ownerUUID; + } - @Override - public void writeToNBT(final NBTTagCompound tagCompound) { - super.writeToNBT(tagCompound); + public void setOwnerUUID(final UUID ownerUUID) { + this.ownerUUID = ownerUUID; + this.markDirty(); + } - final UUID ownerUUID = this.getOwnerUUID(); - if (ownerUUID != null){ - tagCompound.setLong("OwnerUUIDMost", ownerUUID.getMostSignificantBits()); - tagCompound.setLong("OwnerUUIDLeast", ownerUUID.getLeastSignificantBits()); - } - } + @Override + public void writeToNBT(final NBTTagCompound tagCompound) { + super.writeToNBT(tagCompound); - @Override - public void readFromNBT(final NBTTagCompound tagCompound) { - super.readFromNBT(tagCompound); + final UUID ownerUUID = this.getOwnerUUID(); + if (ownerUUID != null) { + tagCompound.setLong("OwnerUUIDMost", ownerUUID.getMostSignificantBits()); + tagCompound.setLong("OwnerUUIDLeast", ownerUUID.getLeastSignificantBits()); + } + } - this.setOwnerUUID(new UUID(tagCompound.getLong("OwnerUUIDMost"), tagCompound.getLong("OwnerUUIDLeast"))); - } + @Override + public void readFromNBT(final NBTTagCompound tagCompound) { + super.readFromNBT(tagCompound); + this.setOwnerUUID(new UUID(tagCompound.getLong("OwnerUUIDMost"), tagCompound.getLong("OwnerUUIDLeast"))); + } } diff --git a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java index beff269428..bd49b67f73 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java +++ b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java @@ -1,7 +1,13 @@ package gtPlusPlus.core.tileentities.general; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.inventories.InventoryFishTrap; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -10,401 +16,404 @@ import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; - -import gregtech.api.util.GT_Utility; - -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.inventories.InventoryFishTrap; -import gtPlusPlus.core.lib.LoadedMods; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.ItemUtils; import net.minecraftforge.common.FishingHooks; public class TileEntityFishTrap extends TileEntity implements ISidedInventory { - private int tickCount = 0; - private boolean isInWater = false; - private final InventoryFishTrap inventoryContents; - private String customName; - private int locationX; - private int locationY; - private int locationZ; - private int waterSides = 0; - private int baseTickRate = 600 * 5; - - public TileEntityFishTrap() { - this.inventoryContents = new InventoryFishTrap();// number of slots - - // without product - // slot - this.setTileLocation(); - } - - public boolean setTileLocation() { - if (this.hasWorldObj()) { - if (!this.getWorldObj().isRemote) { - this.locationX = this.xCoord; - this.locationY = this.yCoord; - this.locationZ = this.zCoord; - return true; - } - } - return false; - } - - public final boolean isSurroundedByWater() { - this.setTileLocation(); - final Block[] surroundingBlocks = new Block[6]; - if (this.hasWorldObj()) { - if (!this.getWorldObj().isRemote) { - surroundingBlocks[0] = this.worldObj.getBlock(this.locationX, this.locationY + 1, this.locationZ); // Above - surroundingBlocks[1] = this.worldObj.getBlock(this.locationX, this.locationY - 1, this.locationZ); // Below - surroundingBlocks[2] = this.worldObj.getBlock(this.locationX + 1, this.locationY, this.locationZ); - surroundingBlocks[3] = this.worldObj.getBlock(this.locationX - 1, this.locationY, this.locationZ); - surroundingBlocks[4] = this.worldObj.getBlock(this.locationX, this.locationY, this.locationZ + 1); - surroundingBlocks[5] = this.worldObj.getBlock(this.locationX, this.locationY, this.locationZ - 1); - int waterCount = 0; - int trapCount = 0; - for (final Block checkBlock : surroundingBlocks) { - if ((checkBlock == Blocks.water) || (checkBlock == Blocks.flowing_water) - || checkBlock.getUnlocalizedName().toLowerCase().contains("water") - || (checkBlock == ModBlocks.blockFishTrap)) { - if (checkBlock != ModBlocks.blockFishTrap) { - waterCount++; - } - else { - waterCount++; - trapCount++; - } - } - } - if ((waterCount >= 2) && (trapCount <= 4)) { - int aCheck = trapCount + waterCount; - this.waterSides = MathUtils.balance(aCheck, 0, 6); - Logger.MACHINE_INFO("Valid Trap. "+waterCount+" | "+(this.tickCount/20)+"/"+(this.baseTickRate/20)); - return true; - } - else if ((waterCount >= 2) && (trapCount > 4)) { - Logger.MACHINE_INFO("Too many fish traps surrounding this one."); - Logger.MACHINE_INFO("Not adding Loot to the fishtrap at x[" + this.locationX + "] y[" + this.locationY - + "] z[" + this.locationZ + "] (Ticking for loot every " + this.baseTickRate + " ticks)"); - } - } - } - // Utils.LOG_MACHINE_INFO("Error finding water"); - return false; - } - - public InventoryFishTrap getInventory() { - return this.inventoryContents; - } - - public boolean tryAddLoot() { - if (this.getInventory().getInventory() != null) { - int checkingSlot = 0; - ItemUtils.organiseInventory(getInventory()); - final ItemStack loot = this.generateLootForFishTrap().copy(); - try { - //Utils.LOG_MACHINE_INFO("Trying to add "+loot.getDisplayName()+" | "+loot.getItemDamage()); - for (final ItemStack contents : this.getInventory().getInventory()) { - - - if (GT_Utility.areStacksEqual(loot, contents)){ - if (contents.stackSize < contents.getMaxStackSize()) { - //Utils.LOG_MACHINE_INFO("3-Trying to add one more "+loot.getDisplayName()+"meta: "+loot.getItemDamage()+" to an existing stack of "+contents.getDisplayName()+" with a size of "+contents.stackSize); - contents.stackSize++; - this.markDirty(); - return true; - } - } - checkingSlot++; - } - checkingSlot = 0; - for (final ItemStack contents : this.getInventory().getInventory()) { - if (contents == null) { - //Utils.LOG_MACHINE_INFO("Adding Item To Empty Slot. "+(checkingSlot+1)); - this.getInventory().setInventorySlotContents(checkingSlot, loot); - this.markDirty(); - return true; - } - checkingSlot++; - } - } - catch (final NullPointerException n) { - } - } - this.markDirty(); - return false; - } - - private ItemStack generateLootForFishTrap() { - final int lootWeight = MathUtils.randInt(0, 100); - ItemStack loot; - if (lootWeight <= 5) { - loot = ItemUtils.getSimpleStack(Items.slime_ball); - } - else if (lootWeight <= 10) { - loot = ItemUtils.getSimpleStack(Items.bone); - } - else if (lootWeight <= 15) { - loot = ItemUtils.getSimpleStack(Blocks.sand); - } - else if (lootWeight <= 20) { - loot = ItemUtils.simpleMetaStack(Items.dye, 0, 1); - } - // Junk Loot - else if (lootWeight <= 23) { - if (LoadedMods.PamsHarvestcraft) { - loot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken(seaweed, 1); - } - else { - loot = ItemUtils.getSimpleStack(Blocks.dirt); - } - } - // Pam Fish - else if (lootWeight <= 99) { - final Random xstr = new Random(); - loot = FishingHooks.getRandomFishable(xstr, 100); - } - - else if (lootWeight == 100){ - final int rareLoot = MathUtils.randInt(1, 10); - if (rareLoot <= 4) { - loot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("nuggetIron", 1); - if (loot == null){ - loot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("ingotIron", 1); - } - } - else if (rareLoot <= 7) { - loot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("nuggetGold", 1); - if (loot == null){ - loot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("ingotGold", 1); - } - } - else if (rareLoot <= 9){ - loot = ItemUtils.getSimpleStack(Items.emerald); - } - else { - loot = ItemUtils.getSimpleStack(Items.diamond); - } - } - else { - loot = ItemUtils.getSimpleStack(Blocks.diamond_ore); - } - loot.stackSize=1; - Logger.MACHINE_INFO("Adding x"+loot.stackSize+" "+loot.getDisplayName()+"."); - return loot; - } - - @Override - public void updateEntity() { - try{ - if (!this.worldObj.isRemote) { - this.tickCount++; - //Logger.MACHINE_INFO("Ticking "+this.tickCount); - // Check if the Tile is within water once per second. - if ((this.tickCount % 20) == 0) { - this.isInWater = this.isSurroundedByWater(); - } - - if (this.isInWater) { - this.calculateTickrate(); - } - - // Try add some loot once every 30 seconds. - if (this.tickCount >= this.baseTickRate) { - if (this.isInWater) { - // Add loot - Logger.MACHINE_INFO("Adding Loot to the fishtrap at x["+this.locationX+"] y["+this.locationY+"] z["+this.locationZ+"] (Ticking for loot every "+this.baseTickRate+" ticks)"); - - int aExtraLootChance = MathUtils.randInt(1, 1000); - if (aExtraLootChance >= 999) { - this.tryAddLoot(); - this.tryAddLoot(); - this.tryAddLoot(); - } - else { - this.tryAddLoot(); - } - - this.markDirty(); - } - else { - Logger.MACHINE_INFO("Not in water."); - this.markDirty(); - } - this.tickCount = 0; - } - if (this.tickCount >= (this.baseTickRate + 500)) { - Logger.MACHINE_INFO("Resetting tick counter"); - this.tickCount = 0; - } - - } - } - catch (final Throwable t){} - } - - public void calculateTickrate() { - int water = this.waterSides; - //int variance = (int) ((MathUtils.randInt(-200, 200)/water)*0.5); - if (water <= 1) { - this.baseTickRate = 0; - } else if (water == 2) { - this.baseTickRate = 6800; - } else if (water == 3) { - this.baseTickRate = 5600; - } else if (water == 4) { - this.baseTickRate = 4400; - } else if (water == 5) { - this.baseTickRate = 3200; - } else { - this.baseTickRate = 1750; - } - if (water > 1) { - //this.baseTickRate += variance; - } - } - - public boolean anyPlayerInRange() { - return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) != null; - } - - public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) { - if (!nbt.hasKey(tag)) { - nbt.setTag(tag, new NBTTagCompound()); - } - return nbt.getCompoundTag(tag); - } - - @Override - public void writeToNBT(final NBTTagCompound nbt) { - super.writeToNBT(nbt); - // Utils.LOG_MACHINE_INFO("Trying to write NBT data to TE."); - final NBTTagCompound chestData = new NBTTagCompound(); - this.inventoryContents.writeToNBT(chestData); - nbt.setTag("ContentsChest", chestData); - if (this.hasCustomInventoryName()) { - nbt.setString("CustomName", this.getCustomName()); - } - } - - @Override - public void readFromNBT(final NBTTagCompound nbt) { - super.readFromNBT(nbt); - // Utils.LOG_MACHINE_INFO("Trying to read NBT data from TE."); - this.inventoryContents.readFromNBT(nbt.getCompoundTag("ContentsChest")); - if (nbt.hasKey("CustomName", 8)) { - this.setCustomName(nbt.getString("CustomName")); - } - } - - final static String prefix = "food"; - final static String suffix = "raw"; - final static String seaweed = "cropSeaweed"; - final static String greenheartFish = "Greenheartfish"; - private static final String[] harvestcraftFish = { "Anchovy", "Bass", "Carp", "Catfish", "Charr", "Clam", "Crab", - "Crayfish", "Eel", "Frog", "Grouper", "Herring", "Jellyfish", "Mudfish", "Octopus", "Perch", "Scallop", - "Shrimp", "Snail", "Snapper", "Tilapia", "Trout", "Tuna", "Turtle", "Walleye" }; - - public static void pamsHarvestCraftCompat() { - for (int i = 0; i < harvestcraftFish.length; i++) { - - } - } - - @Override - public int getSizeInventory() { - return this.getInventory().getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(final int slot) { - return this.getInventory().getStackInSlot(slot); - } - - @Override - public ItemStack decrStackSize(final int slot, final int count) { - return this.getInventory().decrStackSize(slot, count); - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) { - return this.getInventory().getStackInSlotOnClosing(slot); - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) { - this.getInventory().setInventorySlotContents(slot, stack); - } - - @Override - public int getInventoryStackLimit() { - return this.getInventory().getInventoryStackLimit(); - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) { - return this.getInventory().isUseableByPlayer(entityplayer); - } - - @Override - public void openInventory() { - this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); - this.getInventory().openInventory(); - } - - @Override - public void closeInventory() { - this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); - this.getInventory().closeInventory(); - } - - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { - return this.getInventory().isItemValidForSlot(slot, itemstack); - } - - @Override - public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { - final int[] accessibleSides = new int[this.getSizeInventory()]; - for (int r=0; r= 2) && (trapCount <= 4)) { + int aCheck = trapCount + waterCount; + this.waterSides = MathUtils.balance(aCheck, 0, 6); + Logger.MACHINE_INFO("Valid Trap. " + waterCount + " | " + (this.tickCount / 20) + "/" + + (this.baseTickRate / 20)); + return true; + } else if ((waterCount >= 2) && (trapCount > 4)) { + Logger.MACHINE_INFO("Too many fish traps surrounding this one."); + Logger.MACHINE_INFO( + "Not adding Loot to the fishtrap at x[" + this.locationX + "] y[" + this.locationY + "] z[" + + this.locationZ + "] (Ticking for loot every " + this.baseTickRate + " ticks)"); + } + } + } + // Utils.LOG_MACHINE_INFO("Error finding water"); + return false; + } + + public InventoryFishTrap getInventory() { + return this.inventoryContents; + } + + public boolean tryAddLoot() { + if (this.getInventory().getInventory() != null) { + int checkingSlot = 0; + ItemUtils.organiseInventory(getInventory()); + final ItemStack loot = this.generateLootForFishTrap().copy(); + try { + // Utils.LOG_MACHINE_INFO("Trying to add "+loot.getDisplayName()+" | "+loot.getItemDamage()); + for (final ItemStack contents : this.getInventory().getInventory()) { + + if (GT_Utility.areStacksEqual(loot, contents)) { + if (contents.stackSize < contents.getMaxStackSize()) { + // Utils.LOG_MACHINE_INFO("3-Trying to add one more "+loot.getDisplayName()+"meta: + // "+loot.getItemDamage()+" to an existing stack of "+contents.getDisplayName()+" with a + // size of "+contents.stackSize); + contents.stackSize++; + this.markDirty(); + return true; + } + } + checkingSlot++; + } + checkingSlot = 0; + for (final ItemStack contents : this.getInventory().getInventory()) { + if (contents == null) { + // Utils.LOG_MACHINE_INFO("Adding Item To Empty Slot. "+(checkingSlot+1)); + this.getInventory().setInventorySlotContents(checkingSlot, loot); + this.markDirty(); + return true; + } + checkingSlot++; + } + } catch (final NullPointerException n) { + } + } + this.markDirty(); + return false; + } + + private ItemStack generateLootForFishTrap() { + final int lootWeight = MathUtils.randInt(0, 100); + ItemStack loot; + if (lootWeight <= 5) { + loot = ItemUtils.getSimpleStack(Items.slime_ball); + } else if (lootWeight <= 10) { + loot = ItemUtils.getSimpleStack(Items.bone); + } else if (lootWeight <= 15) { + loot = ItemUtils.getSimpleStack(Blocks.sand); + } else if (lootWeight <= 20) { + loot = ItemUtils.simpleMetaStack(Items.dye, 0, 1); + } + // Junk Loot + else if (lootWeight <= 23) { + if (LoadedMods.PamsHarvestcraft) { + loot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken(seaweed, 1); + } else { + loot = ItemUtils.getSimpleStack(Blocks.dirt); + } + } + // Pam Fish + else if (lootWeight <= 99) { + final Random xstr = new Random(); + loot = FishingHooks.getRandomFishable(xstr, 100); + } else if (lootWeight == 100) { + final int rareLoot = MathUtils.randInt(1, 10); + if (rareLoot <= 4) { + loot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("nuggetIron", 1); + if (loot == null) { + loot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("ingotIron", 1); + } + } else if (rareLoot <= 7) { + loot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("nuggetGold", 1); + if (loot == null) { + loot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("ingotGold", 1); + } + } else if (rareLoot <= 9) { + loot = ItemUtils.getSimpleStack(Items.emerald); + } else { + loot = ItemUtils.getSimpleStack(Items.diamond); + } + } else { + loot = ItemUtils.getSimpleStack(Blocks.diamond_ore); + } + loot.stackSize = 1; + Logger.MACHINE_INFO("Adding x" + loot.stackSize + " " + loot.getDisplayName() + "."); + return loot; + } + + @Override + public void updateEntity() { + try { + if (!this.worldObj.isRemote) { + this.tickCount++; + // Logger.MACHINE_INFO("Ticking "+this.tickCount); + // Check if the Tile is within water once per second. + if ((this.tickCount % 20) == 0) { + this.isInWater = this.isSurroundedByWater(); + } + + if (this.isInWater) { + this.calculateTickrate(); + } + + // Try add some loot once every 30 seconds. + if (this.tickCount >= this.baseTickRate) { + if (this.isInWater) { + // Add loot + Logger.MACHINE_INFO("Adding Loot to the fishtrap at x[" + this.locationX + "] y[" + + this.locationY + "] z[" + this.locationZ + "] (Ticking for loot every " + + this.baseTickRate + " ticks)"); + + int aExtraLootChance = MathUtils.randInt(1, 1000); + if (aExtraLootChance >= 999) { + this.tryAddLoot(); + this.tryAddLoot(); + this.tryAddLoot(); + } else { + this.tryAddLoot(); + } + + this.markDirty(); + } else { + Logger.MACHINE_INFO("Not in water."); + this.markDirty(); + } + this.tickCount = 0; + } + if (this.tickCount >= (this.baseTickRate + 500)) { + Logger.MACHINE_INFO("Resetting tick counter"); + this.tickCount = 0; + } + } + } catch (final Throwable t) { + } + } + + public void calculateTickrate() { + int water = this.waterSides; + // int variance = (int) ((MathUtils.randInt(-200, 200)/water)*0.5); + if (water <= 1) { + this.baseTickRate = 0; + } else if (water == 2) { + this.baseTickRate = 6800; + } else if (water == 3) { + this.baseTickRate = 5600; + } else if (water == 4) { + this.baseTickRate = 4400; + } else if (water == 5) { + this.baseTickRate = 3200; + } else { + this.baseTickRate = 1750; + } + if (water > 1) { + // this.baseTickRate += variance; + } + } + + public boolean anyPlayerInRange() { + return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) != null; + } + + public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) { + if (!nbt.hasKey(tag)) { + nbt.setTag(tag, new NBTTagCompound()); + } + return nbt.getCompoundTag(tag); + } + + @Override + public void writeToNBT(final NBTTagCompound nbt) { + super.writeToNBT(nbt); + // Utils.LOG_MACHINE_INFO("Trying to write NBT data to TE."); + final NBTTagCompound chestData = new NBTTagCompound(); + this.inventoryContents.writeToNBT(chestData); + nbt.setTag("ContentsChest", chestData); + if (this.hasCustomInventoryName()) { + nbt.setString("CustomName", this.getCustomName()); + } + } + + @Override + public void readFromNBT(final NBTTagCompound nbt) { + super.readFromNBT(nbt); + // Utils.LOG_MACHINE_INFO("Trying to read NBT data from TE."); + this.inventoryContents.readFromNBT(nbt.getCompoundTag("ContentsChest")); + if (nbt.hasKey("CustomName", 8)) { + this.setCustomName(nbt.getString("CustomName")); + } + } + + static final String prefix = "food"; + static final String suffix = "raw"; + static final String seaweed = "cropSeaweed"; + static final String greenheartFish = "Greenheartfish"; + private static final String[] harvestcraftFish = { + "Anchovy", + "Bass", + "Carp", + "Catfish", + "Charr", + "Clam", + "Crab", + "Crayfish", + "Eel", + "Frog", + "Grouper", + "Herring", + "Jellyfish", + "Mudfish", + "Octopus", + "Perch", + "Scallop", + "Shrimp", + "Snail", + "Snapper", + "Tilapia", + "Trout", + "Tuna", + "Turtle", + "Walleye" + }; + + public static void pamsHarvestCraftCompat() { + for (int i = 0; i < harvestcraftFish.length; i++) {} + } + + @Override + public int getSizeInventory() { + return this.getInventory().getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.getInventory().getStackInSlot(slot); + } + + @Override + public ItemStack decrStackSize(final int slot, final int count) { + return this.getInventory().decrStackSize(slot, count); + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + return this.getInventory().getStackInSlotOnClosing(slot); + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.getInventory().setInventorySlotContents(slot, stack); + } + + @Override + public int getInventoryStackLimit() { + return this.getInventory().getInventoryStackLimit(); + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return this.getInventory().isUseableByPlayer(entityplayer); + } + + @Override + public void openInventory() { + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + this.getInventory().openInventory(); + } + + @Override + public void closeInventory() { + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + this.getInventory().closeInventory(); + } + + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + return this.getInventory().isItemValidForSlot(slot, itemstack); + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + final int[] accessibleSides = new int[this.getSizeInventory()]; + for (int r = 0; r < this.getInventory().getSizeInventory(); r++) { + accessibleSides[r] = r; + } + return accessibleSides; + } + + @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 true; + } + + public String getCustomName() { + return this.customName; + } + + public void setCustomName(final String customName) { + this.customName = customName; + } + + @Override + public String getInventoryName() { + return this.hasCustomInventoryName() ? this.customName : "container.fishtrap"; + } + + @Override + public boolean hasCustomInventoryName() { + return (this.customName != null) && !this.customName.equals(""); + } } diff --git a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityHeliumGenerator.java b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityHeliumGenerator.java index 8a2d9d9f51..d45ebd77f7 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityHeliumGenerator.java +++ b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityHeliumGenerator.java @@ -1,124 +1,116 @@ package gtPlusPlus.core.tileentities.general; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; - import gregtech.api.enums.GT_Values; - import gtPlusPlus.core.inventories.InventoryHeliumGenerator; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; -public class TileEntityHeliumGenerator extends TileEntity{ - - private int tickCount = 0; - private final InventoryHeliumGenerator inventoryContents; //TODO - private int locationX; - private int locationY; - private int locationZ; - private int baseTickRate = 1200; - - public TileEntityHeliumGenerator(){ - this.inventoryContents = new InventoryHeliumGenerator();//number of slots - without product slot - this.setTileLocation(); - } - - public boolean setTileLocation(){ - if (this.hasWorldObj()){ - if (!this.getWorldObj().isRemote){ - this.locationX = this.xCoord; - this.locationY = this.yCoord; - this.locationZ = this.zCoord; - return true; - } - } - return false; - } - - public InventoryHeliumGenerator getInventory(){ - return this.inventoryContents; - } - - public boolean tryAddLoot(){ - if (this.getInventory().getInventory() != null){ - int checkingSlot = 0; - final ItemStack loot = this.generateLootForFishTrap(); - for (final ItemStack contents : this.getInventory().getInventory()){ - if (contents == null){ - this.getInventory().setInventorySlotContents(checkingSlot, loot); - this.markDirty(); - return true; - } - else if (contents.getItem() == loot.getItem()){ - if (contents.stackSize < contents.getMaxStackSize()){ - contents.stackSize++; - this.markDirty(); - return true; - } - else { - this.getInventory().setInventorySlotContents(checkingSlot, loot); - this.markDirty(); - return true; - } - } - else { - - } - checkingSlot++; - } - } - this.markDirty(); - return false; - } - - private ItemStack generateLootForFishTrap() { - final int lootWeight = MathUtils.randInt(0, 1000); - ItemStack loot = GT_Values.NI; - if (lootWeight > 990){ - loot = ItemUtils.getSimpleStack(Items.slime_ball); - } - return loot; - } - - @Override - public void updateEntity(){ - if (!this.worldObj.isRemote){ - - } - } - - public void calculateTickrate(){ - int calculateTickrate = 0; - this.baseTickRate = calculateTickrate; - } - - public boolean anyPlayerInRange(){ - return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) != null; - } - - public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag){ - if(!nbt.hasKey(tag)){ - nbt.setTag(tag, new NBTTagCompound()); - } - return nbt.getCompoundTag(tag); - } - - @Override - public void writeToNBT(final NBTTagCompound nbt){ - super.writeToNBT(nbt); - //Utils.LOG_INFO("Trying to write NBT data to TE."); - final NBTTagCompound chestData = new NBTTagCompound(); - this.inventoryContents.writeToNBT(chestData); - nbt.setTag("ContentsChest", chestData); - } - - @Override - public void readFromNBT(final NBTTagCompound nbt){ - super.readFromNBT(nbt); - //Utils.LOG_INFO("Trying to read NBT data from TE."); - this.inventoryContents.readFromNBT(nbt.getCompoundTag("ContentsChest")); - } - +public class TileEntityHeliumGenerator extends TileEntity { + + private int tickCount = 0; + private final InventoryHeliumGenerator inventoryContents; // TODO + private int locationX; + private int locationY; + private int locationZ; + private int baseTickRate = 1200; + + public TileEntityHeliumGenerator() { + this.inventoryContents = new InventoryHeliumGenerator(); // number of slots - without product slot + this.setTileLocation(); + } + + public boolean setTileLocation() { + if (this.hasWorldObj()) { + if (!this.getWorldObj().isRemote) { + this.locationX = this.xCoord; + this.locationY = this.yCoord; + this.locationZ = this.zCoord; + return true; + } + } + return false; + } + + public InventoryHeliumGenerator getInventory() { + return this.inventoryContents; + } + + public boolean tryAddLoot() { + if (this.getInventory().getInventory() != null) { + int checkingSlot = 0; + final ItemStack loot = this.generateLootForFishTrap(); + for (final ItemStack contents : this.getInventory().getInventory()) { + if (contents == null) { + this.getInventory().setInventorySlotContents(checkingSlot, loot); + this.markDirty(); + return true; + } else if (contents.getItem() == loot.getItem()) { + if (contents.stackSize < contents.getMaxStackSize()) { + contents.stackSize++; + this.markDirty(); + return true; + } else { + this.getInventory().setInventorySlotContents(checkingSlot, loot); + this.markDirty(); + return true; + } + } else { + + } + checkingSlot++; + } + } + this.markDirty(); + return false; + } + + private ItemStack generateLootForFishTrap() { + final int lootWeight = MathUtils.randInt(0, 1000); + ItemStack loot = GT_Values.NI; + if (lootWeight > 990) { + loot = ItemUtils.getSimpleStack(Items.slime_ball); + } + return loot; + } + + @Override + public void updateEntity() { + if (!this.worldObj.isRemote) {} + } + + public void calculateTickrate() { + int calculateTickrate = 0; + this.baseTickRate = calculateTickrate; + } + + public boolean anyPlayerInRange() { + return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) != null; + } + + public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) { + if (!nbt.hasKey(tag)) { + nbt.setTag(tag, new NBTTagCompound()); + } + return nbt.getCompoundTag(tag); + } + + @Override + public void writeToNBT(final NBTTagCompound nbt) { + super.writeToNBT(nbt); + // Utils.LOG_INFO("Trying to write NBT data to TE."); + final NBTTagCompound chestData = new NBTTagCompound(); + this.inventoryContents.writeToNBT(chestData); + nbt.setTag("ContentsChest", chestData); + } + + @Override + public void readFromNBT(final NBTTagCompound nbt) { + super.readFromNBT(nbt); + // Utils.LOG_INFO("Trying to read NBT data from TE."); + this.inventoryContents.readFromNBT(nbt.getCompoundTag("ContentsChest")); + } } diff --git a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityInfiniteFluid.java b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityInfiniteFluid.java index 9ddf2065bc..a21448bce7 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityInfiniteFluid.java +++ b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityInfiniteFluid.java @@ -5,135 +5,132 @@ import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; - import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.*; public class TileEntityInfiniteFluid extends TileEntity implements IFluidHandler { - public FluidTank tank = new FluidTank(Integer.MAX_VALUE); - private boolean needsUpdate = false; - private int updateTimer = 0; - - public TileEntityInfiniteFluid() { - } - - @Override - public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { - needsUpdate = true; - return this.tank.fill(resource, doFill); - } - - @Override - public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { - needsUpdate = true; - return this.tank.drain(resource.amount, doDrain); - } - - @Override - public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { - needsUpdate = true; - FluidStack fluid = this.tank.getFluid(); - // return this.tank.drain(maxDrain, doDrain); - if (fluid == null) { - return null; - } - - int drained = maxDrain; - if (fluid.amount < drained) { - drained = fluid.amount; - } - - FluidStack stack = new FluidStack(fluid, drained); - if (doDrain) { - fluid.amount -= drained; - if (fluid.amount <= 0) { - fluid = null; - } - - if (this != null) { - FluidEvent.fireEvent(new FluidEvent.FluidDrainingEvent(fluid, this.getWorldObj(), this.xCoord, - this.yCoord, this.zCoord, this.tank, 0)); - } - } - return stack; - } - - @Override - public boolean canFill(ForgeDirection from, Fluid fluid) { - return true; - } - - @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) { - return true; - } - - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection from) { - return new FluidTankInfo[] { this.tank.getInfo() }; - } - - public float getAdjustedVolume() { - needsUpdate = true; - float amount = tank.getFluidAmount(); - float capacity = tank.getCapacity(); - float volume = (amount / capacity) * 0.8F; - return volume; - } - - @Override - public void updateEntity() { - - if (this.tank.getFluid() != null){ - FluidStack bigStorage = this.tank.getFluid(); - bigStorage.amount = this.tank.getCapacity(); - this.tank.setFluid(bigStorage); - } - - if (needsUpdate) { - - if (this.tank.getFluid() != null){ - FluidStack bigStorage = this.tank.getFluid(); - bigStorage.amount = this.tank.getCapacity(); - this.tank.setFluid(bigStorage); - } - - if (updateTimer == 0) { - updateTimer = 10; // every 10 ticks it will send an update - } else { - --updateTimer; - if (updateTimer == 0) { - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - needsUpdate = false; - } - } - } - } - - @Override - public void readFromNBT(NBTTagCompound tag) { - tank.readFromNBT(tag); - super.readFromNBT(tag); - } - - @Override - public void writeToNBT(NBTTagCompound tag) { - tank.writeToNBT(tag); - super.writeToNBT(tag); - } - - @Override - public Packet getDescriptionPacket() { - NBTTagCompound tag = new NBTTagCompound(); - writeToNBT(tag); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, this.blockMetadata, tag); - } - - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - NBTTagCompound tag = pkt.func_148857_g(); - readFromNBT(tag); - } - + public FluidTank tank = new FluidTank(Integer.MAX_VALUE); + private boolean needsUpdate = false; + private int updateTimer = 0; + + public TileEntityInfiniteFluid() {} + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + needsUpdate = true; + return this.tank.fill(resource, doFill); + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + needsUpdate = true; + return this.tank.drain(resource.amount, doDrain); + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + needsUpdate = true; + FluidStack fluid = this.tank.getFluid(); + // return this.tank.drain(maxDrain, doDrain); + if (fluid == null) { + return null; + } + + int drained = maxDrain; + if (fluid.amount < drained) { + drained = fluid.amount; + } + + FluidStack stack = new FluidStack(fluid, drained); + if (doDrain) { + fluid.amount -= drained; + if (fluid.amount <= 0) { + fluid = null; + } + + if (this != null) { + FluidEvent.fireEvent(new FluidEvent.FluidDrainingEvent( + fluid, this.getWorldObj(), this.xCoord, this.yCoord, this.zCoord, this.tank, 0)); + } + } + return stack; + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return true; + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return true; + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) { + return new FluidTankInfo[] {this.tank.getInfo()}; + } + + public float getAdjustedVolume() { + needsUpdate = true; + float amount = tank.getFluidAmount(); + float capacity = tank.getCapacity(); + float volume = (amount / capacity) * 0.8F; + return volume; + } + + @Override + public void updateEntity() { + + if (this.tank.getFluid() != null) { + FluidStack bigStorage = this.tank.getFluid(); + bigStorage.amount = this.tank.getCapacity(); + this.tank.setFluid(bigStorage); + } + + if (needsUpdate) { + + if (this.tank.getFluid() != null) { + FluidStack bigStorage = this.tank.getFluid(); + bigStorage.amount = this.tank.getCapacity(); + this.tank.setFluid(bigStorage); + } + + if (updateTimer == 0) { + updateTimer = 10; // every 10 ticks it will send an update + } else { + --updateTimer; + if (updateTimer == 0) { + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + needsUpdate = false; + } + } + } + } + + @Override + public void readFromNBT(NBTTagCompound tag) { + tank.readFromNBT(tag); + super.readFromNBT(tag); + } + + @Override + public void writeToNBT(NBTTagCompound tag) { + tank.writeToNBT(tag); + super.writeToNBT(tag); + } + + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tag = new NBTTagCompound(); + writeToNBT(tag); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, this.blockMetadata, tag); + } + + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + NBTTagCompound tag = pkt.func_148857_g(); + readFromNBT(tag); + } } diff --git a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityPlayerDoorBase.java b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityPlayerDoorBase.java index 48f05fe0fd..a9ac7683d4 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityPlayerDoorBase.java +++ b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityPlayerDoorBase.java @@ -1,11 +1,10 @@ package gtPlusPlus.core.tileentities.general; -import java.util.ArrayList; -import java.util.List; - import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.util.minecraft.EntityUtils; +import java.util.ArrayList; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.block.BlockDoor; import net.minecraft.entity.Entity; @@ -17,269 +16,261 @@ import net.minecraft.world.chunk.Chunk; public class TileEntityPlayerDoorBase extends TileEntity { - public boolean mIsOpen = false; - private short mMeta = 0; - private long mTickCounter = 0; - private final Block mBlockType; - private BlockPos mNeighbourDoor; + public boolean mIsOpen = false; + private short mMeta = 0; + private long mTickCounter = 0; + private final Block mBlockType; + private BlockPos mNeighbourDoor; + + public TileEntityPlayerDoorBase(Block aBlock, int meta) { + mBlockType = aBlock; + } - public TileEntityPlayerDoorBase(Block aBlock, int meta) { - mBlockType = aBlock; - } + @Override + public void readFromNBT(NBTTagCompound aNBT) { + super.readFromNBT(aNBT); + this.mIsOpen = aNBT.getBoolean("mIsOpen"); + } - @Override - public void readFromNBT(NBTTagCompound aNBT) { - super.readFromNBT(aNBT); - this.mIsOpen = aNBT.getBoolean("mIsOpen"); - } + @Override + public void writeToNBT(NBTTagCompound aNBT) { + super.writeToNBT(aNBT); + aNBT.setBoolean("mIsOpen", mIsOpen); + } - @Override - public void writeToNBT(NBTTagCompound aNBT) { - super.writeToNBT(aNBT); - aNBT.setBoolean("mIsOpen", mIsOpen); - } + public int getNeighbourState() { - public int getNeighbourState() { + if (mNeighbourDoor != null) { + World aWorld = this.worldObj; + if (aWorld != null) { + TileEntity t = aWorld.getTileEntity(mNeighbourDoor.xPos, mNeighbourDoor.yPos, mNeighbourDoor.zPos); + // Custom Door + if (t != null) { + if (t instanceof TileEntityPlayerDoorBase) { + TileEntityPlayerDoorBase d = (TileEntityPlayerDoorBase) t; + if (d.mIsOpen) { + return 100; + } else { + return -100; + } + } else return -100; + } + // Vanilla Door + else { + Block aBlock = mNeighbourDoor.getBlockAtPos(); + BlockDoor aDoor = (aBlock instanceof BlockDoor ? (BlockDoor) aBlock : null); + if (aDoor != null) { + int i1 = aDoor.func_150012_g( + mNeighbourDoor.world, mNeighbourDoor.xPos, mNeighbourDoor.yPos, mNeighbourDoor.zPos); + if ((i1 & 4) != 0) { + return 100; + } else { + return -100; + } + } + } + } + } + return 0; + } - if (mNeighbourDoor != null) { - World aWorld = this.worldObj; - if (aWorld != null) { - TileEntity t = aWorld.getTileEntity(mNeighbourDoor.xPos, mNeighbourDoor.yPos, mNeighbourDoor.zPos); - // Custom Door - if (t != null) { - if (t instanceof TileEntityPlayerDoorBase) { - TileEntityPlayerDoorBase d = (TileEntityPlayerDoorBase) t; - if (d.mIsOpen) { - return 100; - } else { - return -100; - } - } else - return -100; - } - // Vanilla Door - else { - Block aBlock = mNeighbourDoor.getBlockAtPos(); - BlockDoor aDoor = (aBlock instanceof BlockDoor ? (BlockDoor) aBlock : null); - if (aDoor != null) { - int i1 = aDoor.func_150012_g(mNeighbourDoor.world, mNeighbourDoor.xPos, mNeighbourDoor.yPos, - mNeighbourDoor.zPos); - if ((i1 & 4) != 0) { - return 100; - } else { - return -100; - } - } - } - } - } - return 0; - } + AutoMap mNearbyEntityCache = new AutoMap(); - AutoMap mNearbyEntityCache = new AutoMap(); - - @Override - public void updateEntity() { + @Override + public void updateEntity() { - if (this.getWorldObj().isRemote) { - return; - } + if (this.getWorldObj().isRemote) { + return; + } - // Look For Neighbours - if (mTickCounter % 100 == 0 || mTickCounter == 0) { - World aWorld = this.getWorldObj(); - BlockPos aThisPos = new BlockPos(xCoord, yCoord, zCoord, aWorld); - BlockPos[] aNeighbors = new BlockPos[4]; - aNeighbors[0] = aThisPos.getXNeg(); - aNeighbors[1] = aThisPos.getXPos(); - aNeighbors[2] = aThisPos.getZNeg(); - aNeighbors[3] = aThisPos.getZPos(); - boolean aFoundDoor = false; - for (BlockPos b : aNeighbors) { - Block aBlock = aWorld.getBlock(b.xPos, b.yPos, b.zPos); - BlockDoor aDoor = (aBlock instanceof BlockDoor ? (BlockDoor) aBlock : null); - if (aDoor != null) { - mNeighbourDoor = b; - aFoundDoor = true; - if (mMeta == 0) { - TileEntity t = aWorld.getTileEntity(b.xPos, b.yPos, b.zPos); - if (t != null) { - if (t instanceof TileEntityPlayerDoorBase) { - TileEntityPlayerDoorBase d = (TileEntityPlayerDoorBase) t; - if (d.mMeta != 0) { - //Logger.INFO("Found Door with Mode set other than 0, assuming slave role."); - mMeta = -1; - } - else { - //Logger.INFO("Found door with no mode set, assuming we are master."); - mMeta = 1; - } - } - else { - //Logger.INFO("Custom door from another mod, assuming slave role."); - mMeta = -1; - } - } - else { - //Logger.INFO("No Tile Entity found, Door is probably vanilla, assuming slave role."); - mMeta = -1; - } - } - break; - } - } - if (mMeta < 1 && !aFoundDoor) { - //Logger.INFO("Found No Valid Doors around, setting this one to master mode."); - mMeta = 1; - } - } + // Look For Neighbours + if (mTickCounter % 100 == 0 || mTickCounter == 0) { + World aWorld = this.getWorldObj(); + BlockPos aThisPos = new BlockPos(xCoord, yCoord, zCoord, aWorld); + BlockPos[] aNeighbors = new BlockPos[4]; + aNeighbors[0] = aThisPos.getXNeg(); + aNeighbors[1] = aThisPos.getXPos(); + aNeighbors[2] = aThisPos.getZNeg(); + aNeighbors[3] = aThisPos.getZPos(); + boolean aFoundDoor = false; + for (BlockPos b : aNeighbors) { + Block aBlock = aWorld.getBlock(b.xPos, b.yPos, b.zPos); + BlockDoor aDoor = (aBlock instanceof BlockDoor ? (BlockDoor) aBlock : null); + if (aDoor != null) { + mNeighbourDoor = b; + aFoundDoor = true; + if (mMeta == 0) { + TileEntity t = aWorld.getTileEntity(b.xPos, b.yPos, b.zPos); + if (t != null) { + if (t instanceof TileEntityPlayerDoorBase) { + TileEntityPlayerDoorBase d = (TileEntityPlayerDoorBase) t; + if (d.mMeta != 0) { + // Logger.INFO("Found Door with Mode set other than 0, assuming slave role."); + mMeta = -1; + } else { + // Logger.INFO("Found door with no mode set, assuming we are master."); + mMeta = 1; + } + } else { + // Logger.INFO("Custom door from another mod, assuming slave role."); + mMeta = -1; + } + } else { + // Logger.INFO("No Tile Entity found, Door is probably vanilla, assuming slave role."); + mMeta = -1; + } + } + break; + } + } + if (mMeta < 1 && !aFoundDoor) { + // Logger.INFO("Found No Valid Doors around, setting this one to master mode."); + mMeta = 1; + } + } - World aWorld = this.getWorldObj(); - Block aBlock = aWorld.getBlock(xCoord, yCoord, zCoord); - BlockPos aThisPos = new BlockPos(xCoord, yCoord, zCoord, this.worldObj); - - if (mTickCounter % 20 == 0) { - int x = 0, y = 0, z = 0; - x = this.xCoord; - y = this.yCoord; - z = this.zCoord; - //List aEntityList = aWorld.loadedEntityList; - List aEntityList = new ArrayList(); - Chunk aThisChunk = aWorld.getChunkFromBlockCoords(x, z); - for (List l : aThisChunk.entityLists) { - aEntityList.addAll(l); - } - for (Object o : aEntityList) { - if (o != null) { - if (o instanceof Entity) { - if (o instanceof EntityPlayer) { - continue; - } - else { - Entity e = (Entity) o; - BlockPos p = EntityUtils.findBlockPosUnderEntity(e); - if (p != null) { - int newY = p.yPos+1; - if (e.getDistance(xCoord, yCoord, zCoord) <= 2){ - mNearbyEntityCache.put(e); - } - else if (aThisPos.distanceFrom(p.xPos, newY, p.zPos) <= 2) { - mNearbyEntityCache.put(e); - } - } - } - } - } - } - } + World aWorld = this.getWorldObj(); + Block aBlock = aWorld.getBlock(xCoord, yCoord, zCoord); + BlockPos aThisPos = new BlockPos(xCoord, yCoord, zCoord, this.worldObj); - if (mTickCounter % 4 == 0) { - for (Entity y : mNearbyEntityCache) { - if (y.getDistance(xCoord, yCoord, zCoord) > 2){ - mNearbyEntityCache.remove(y); - } - } - - boolean foundMonster = mNearbyEntityCache.size() > 0; - int aNeighbourDoorState = 0; - if (mNeighbourDoor != null) { - aNeighbourDoorState = getNeighbourState(); - } - BlockDoor aDoor = (aBlock instanceof BlockDoor ? (BlockDoor) aBlock : null); - boolean aPlayers = checkForPlayers(this.getWorldObj()); + if (mTickCounter % 20 == 0) { + int x = 0, y = 0, z = 0; + x = this.xCoord; + y = this.yCoord; + z = this.zCoord; + // List aEntityList = aWorld.loadedEntityList; + List aEntityList = new ArrayList(); + Chunk aThisChunk = aWorld.getChunkFromBlockCoords(x, z); + for (List l : aThisChunk.entityLists) { + aEntityList.addAll(l); + } + for (Object o : aEntityList) { + if (o != null) { + if (o instanceof Entity) { + if (o instanceof EntityPlayer) { + continue; + } else { + Entity e = (Entity) o; + BlockPos p = EntityUtils.findBlockPosUnderEntity(e); + if (p != null) { + int newY = p.yPos + 1; + if (e.getDistance(xCoord, yCoord, zCoord) <= 2) { + mNearbyEntityCache.put(e); + } else if (aThisPos.distanceFrom(p.xPos, newY, p.zPos) <= 2) { + mNearbyEntityCache.put(e); + } + } + } + } + } + } + } - if (aDoor != null) { - //If neighbour state != 0 and we are in slave mode - if (aNeighbourDoorState != 0 && mMeta == -1) { - if (aNeighbourDoorState == 100) { - if (!mIsOpen && !foundMonster) { - //Logger.INFO("Opening Door (Slave)"); - aDoor.func_150014_a(aWorld, this.xCoord, this.yCoord, this.zCoord, true); - mIsOpen = true; - } - } else if (aNeighbourDoorState == -100 || foundMonster) { - if (mIsOpen) { - //Logger.INFO("Closing Door (Slave)"); - aDoor.func_150014_a(aWorld, this.xCoord, this.yCoord, this.zCoord, false); - mIsOpen = false; - } - } - //We are master, proceed - } else { - //No redstone found, allow automatic handling - if (aDoor != null && !hasRedstone()) { - //Found a nearby player - if (aPlayers) { - //If we are closed and there are no monsters nearby, open - if (!mIsOpen && !foundMonster) { - //Logger.INFO("Opening Door (Mstr)"); - aDoor.func_150014_a(aWorld, this.xCoord, this.yCoord, this.zCoord, true); - mIsOpen = true; - } else { - // Logger.INFO("Doing Nothing, Door is in correct state."); - } - //Did not find nearby player - } else { - //If we are open or there is a monster nearby, close. - if (mIsOpen || foundMonster) { - //Logger.INFO("Closing Door (Mstr)"); - aDoor.func_150014_a(aWorld, this.xCoord, this.yCoord, this.zCoord, false); - mIsOpen = false; - } else { - // Logger.INFO("Doing Nothing, Door is in correct state."); - } - } - } - } - } + if (mTickCounter % 4 == 0) { + for (Entity y : mNearbyEntityCache) { + if (y.getDistance(xCoord, yCoord, zCoord) > 2) { + mNearbyEntityCache.remove(y); + } + } - } - super.updateEntity(); - mTickCounter++; - } + boolean foundMonster = mNearbyEntityCache.size() > 0; + int aNeighbourDoorState = 0; + if (mNeighbourDoor != null) { + aNeighbourDoorState = getNeighbourState(); + } + BlockDoor aDoor = (aBlock instanceof BlockDoor ? (BlockDoor) aBlock : null); + boolean aPlayers = checkForPlayers(this.getWorldObj()); - @Override - public int getBlockMetadata() { - return this.mMeta; - } + if (aDoor != null) { + // If neighbour state != 0 and we are in slave mode + if (aNeighbourDoorState != 0 && mMeta == -1) { + if (aNeighbourDoorState == 100) { + if (!mIsOpen && !foundMonster) { + // Logger.INFO("Opening Door (Slave)"); + aDoor.func_150014_a(aWorld, this.xCoord, this.yCoord, this.zCoord, true); + mIsOpen = true; + } + } else if (aNeighbourDoorState == -100 || foundMonster) { + if (mIsOpen) { + // Logger.INFO("Closing Door (Slave)"); + aDoor.func_150014_a(aWorld, this.xCoord, this.yCoord, this.zCoord, false); + mIsOpen = false; + } + } + // We are master, proceed + } else { + // No redstone found, allow automatic handling + if (aDoor != null && !hasRedstone()) { + // Found a nearby player + if (aPlayers) { + // If we are closed and there are no monsters nearby, open + if (!mIsOpen && !foundMonster) { + // Logger.INFO("Opening Door (Mstr)"); + aDoor.func_150014_a(aWorld, this.xCoord, this.yCoord, this.zCoord, true); + mIsOpen = true; + } else { + // Logger.INFO("Doing Nothing, Door is in correct state."); + } + // Did not find nearby player + } else { + // If we are open or there is a monster nearby, close. + if (mIsOpen || foundMonster) { + // Logger.INFO("Closing Door (Mstr)"); + aDoor.func_150014_a(aWorld, this.xCoord, this.yCoord, this.zCoord, false); + mIsOpen = false; + } else { + // Logger.INFO("Doing Nothing, Door is in correct state."); + } + } + } + } + } + } + super.updateEntity(); + mTickCounter++; + } - public boolean hasRedstone() { - World aWorld = this.worldObj; - if (aWorld != null && !aWorld.isRemote) { - return aWorld.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord) - || aWorld.isBlockIndirectlyGettingPowered(xCoord, yCoord + 1, zCoord); - } - return false; - } + @Override + public int getBlockMetadata() { + return this.mMeta; + } - @Override - public Block getBlockType() { - return mBlockType; - } + public boolean hasRedstone() { + World aWorld = this.worldObj; + if (aWorld != null && !aWorld.isRemote) { + return aWorld.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord) + || aWorld.isBlockIndirectlyGettingPowered(xCoord, yCoord + 1, zCoord); + } + return false; + } - @Override - public boolean canUpdate() { - return true; - } + @Override + public Block getBlockType() { + return mBlockType; + } - private boolean checkForPlayers(World aWorld) { - int x = 0, y = 0, z = 0; - x = this.xCoord; - y = this.yCoord; - z = this.zCoord; - EntityPlayer aPlayer = aWorld.getClosestPlayer(x, y, z, 3.5D); - if (aPlayer != null) { - return true; - } - return false; - } + @Override + public boolean canUpdate() { + return true; + } - private short getClosedMeta() { - return 0; - } + private boolean checkForPlayers(World aWorld) { + int x = 0, y = 0, z = 0; + x = this.xCoord; + y = this.yCoord; + z = this.zCoord; + EntityPlayer aPlayer = aWorld.getClosestPlayer(x, y, z, 3.5D); + if (aPlayer != null) { + return true; + } + return false; + } - private short getOpenMeta() { - return 1; - } + private short getClosedMeta() { + return 0; + } + private short getOpenMeta() { + return 1; + } } diff --git a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityReverter.java b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityReverter.java index 6e18834786..bfb56180d2 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityReverter.java +++ b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityReverter.java @@ -1,312 +1,298 @@ package gtPlusPlus.core.tileentities.general; +import gtPlusPlus.core.block.ModBlocks; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.tileentity.TileEntity; -import gtPlusPlus.core.block.ModBlocks; - - - -public class TileEntityReverter extends TileEntity -{ - private static final int REVERT_CHANCE = 10; - public int radius = 16; - public int diameter = (8 * this.radius) + 4; - public double requiredPlayerRange = 64.0D; - public Random rand = new Random(); - private int tickCount; - private boolean slowScan; - private int ticksSinceChange; - private Block[] blockData; - private byte[] metaData; +public class TileEntityReverter extends TileEntity { + private static final int REVERT_CHANCE = 10; + public int radius = 16; + public int diameter = (8 * this.radius) + 4; + public double requiredPlayerRange = 64.0D; + public Random rand = new Random(); + private int tickCount; + private boolean slowScan; + private int ticksSinceChange; + private Block[] blockData; + private byte[] metaData; - @Override - public boolean canUpdate(){ - return true; - } + @Override + public boolean canUpdate() { + return true; + } - @Override - public void updateEntity() - { - if (this.anyPlayerInRange()) - { - this.tickCount += 1; - if (this.worldObj.isRemote) - { - final double var1 = this.xCoord + this.worldObj.rand.nextFloat(); - final double var3 = this.yCoord + this.worldObj.rand.nextFloat(); - final double var5 = this.zCoord + this.worldObj.rand.nextFloat(); + @Override + public void updateEntity() { + if (this.anyPlayerInRange()) { + this.tickCount += 1; + if (this.worldObj.isRemote) { + final double var1 = this.xCoord + this.worldObj.rand.nextFloat(); + final double var3 = this.yCoord + this.worldObj.rand.nextFloat(); + final double var5 = this.zCoord + this.worldObj.rand.nextFloat(); - this.worldObj.spawnParticle("enchantmenttable", var1, var3, var5, 0.0D, 0.0D, 0.0D); - if (this.rand.nextInt(5) == 0) - { - this.makeRandomOutline(); - this.makeRandomOutline(); - this.makeRandomOutline(); - } - } - else - { - if ((this.blockData == null) || (this.metaData == null)) - { - this.captureBlockData(); - this.slowScan = true; - } - if ((!this.slowScan) || ((this.tickCount % 20) == 0)) { - if (this.scanAndRevertChanges()) - { - this.slowScan = false; - this.ticksSinceChange = 0; - } - else - { - this.ticksSinceChange += 1; - if (this.ticksSinceChange > 20) { - this.slowScan = true; - } - } - } - } - } - else - { - this.blockData = null; - this.metaData = null; + this.worldObj.spawnParticle("enchantmenttable", var1, var3, var5, 0.0D, 0.0D, 0.0D); + if (this.rand.nextInt(5) == 0) { + this.makeRandomOutline(); + this.makeRandomOutline(); + this.makeRandomOutline(); + } + } else { + if ((this.blockData == null) || (this.metaData == null)) { + this.captureBlockData(); + this.slowScan = true; + } + if ((!this.slowScan) || ((this.tickCount % 20) == 0)) { + if (this.scanAndRevertChanges()) { + this.slowScan = false; + this.ticksSinceChange = 0; + } else { + this.ticksSinceChange += 1; + if (this.ticksSinceChange > 20) { + this.slowScan = true; + } + } + } + } + } else { + this.blockData = null; + this.metaData = null; - this.tickCount = 0; - } - } + this.tickCount = 0; + } + } - private void makeRandomOutline() - { - this.makeOutline(this.rand.nextInt(12)); - } + private void makeRandomOutline() { + this.makeOutline(this.rand.nextInt(12)); + } - private void makeOutline(final int outline) - { - double sx = this.xCoord; - double sy = this.yCoord; - double sz = this.zCoord; + private void makeOutline(final int outline) { + double sx = this.xCoord; + double sy = this.yCoord; + double sz = this.zCoord; - double dx = this.xCoord; - double dy = this.yCoord; - double dz = this.zCoord; - switch (outline) - { - case 0: - sx -= this.radius; - dx -= this.radius; - sz -= this.radius; - dz += this.radius + 1; - case 8: - sx -= this.radius; - dx += this.radius + 1; - sz -= this.radius; - dz -= this.radius; - break; - case 1: - case 9: - sx -= this.radius; - dx -= this.radius; - sz -= this.radius; - dz += this.radius + 1; - break; - case 2: - case 10: - sx -= this.radius; - dx += this.radius + 1; - sz += this.radius + 1; - dz += this.radius + 1; - break; - case 3: - case 11: - sx += this.radius + 1; - dx += this.radius + 1; - sz -= this.radius; - dz += this.radius + 1; - break; - case 4: - sx -= this.radius; - dx -= this.radius; - sz -= this.radius; - dz -= this.radius; - break; - case 5: - sx += this.radius + 1; - dx += this.radius + 1; - sz -= this.radius; - dz -= this.radius; - break; - case 6: - sx += this.radius + 1; - dx += this.radius + 1; - sz += this.radius + 1; - dz += this.radius + 1; - break; - case 7: - sx -= this.radius; - dx -= this.radius; - sz += this.radius + 1; - dz += this.radius + 1; - } - switch (outline) - { - case 0: - case 1: - case 2: - case 3: - sy += this.radius + 1; - dy += this.radius + 1; - break; - case 4: - case 5: - case 6: - case 7: - sy -= this.radius; - dy += this.radius + 1; - break; - case 8: - case 9: - case 10: - case 11: - sy -= this.radius; - dy -= this.radius; - } - if (this.rand.nextBoolean()) { - this.drawParticleLine(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, dx, dy, dz); - } else { - this.drawParticleLine(sx, sy, sz, this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D); - } - this.drawParticleLine(sx, sy, sz, dx, dy, dz); - } + double dx = this.xCoord; + double dy = this.yCoord; + double dz = this.zCoord; + switch (outline) { + case 0: + sx -= this.radius; + dx -= this.radius; + sz -= this.radius; + dz += this.radius + 1; + case 8: + sx -= this.radius; + dx += this.radius + 1; + sz -= this.radius; + dz -= this.radius; + break; + case 1: + case 9: + sx -= this.radius; + dx -= this.radius; + sz -= this.radius; + dz += this.radius + 1; + break; + case 2: + case 10: + sx -= this.radius; + dx += this.radius + 1; + sz += this.radius + 1; + dz += this.radius + 1; + break; + case 3: + case 11: + sx += this.radius + 1; + dx += this.radius + 1; + sz -= this.radius; + dz += this.radius + 1; + break; + case 4: + sx -= this.radius; + dx -= this.radius; + sz -= this.radius; + dz -= this.radius; + break; + case 5: + sx += this.radius + 1; + dx += this.radius + 1; + sz -= this.radius; + dz -= this.radius; + break; + case 6: + sx += this.radius + 1; + dx += this.radius + 1; + sz += this.radius + 1; + dz += this.radius + 1; + break; + case 7: + sx -= this.radius; + dx -= this.radius; + sz += this.radius + 1; + dz += this.radius + 1; + } + switch (outline) { + case 0: + case 1: + case 2: + case 3: + sy += this.radius + 1; + dy += this.radius + 1; + break; + case 4: + case 5: + case 6: + case 7: + sy -= this.radius; + dy += this.radius + 1; + break; + case 8: + case 9: + case 10: + case 11: + sy -= this.radius; + dy -= this.radius; + } + if (this.rand.nextBoolean()) { + this.drawParticleLine(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, dx, dy, dz); + } else { + this.drawParticleLine(sx, sy, sz, this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D); + } + this.drawParticleLine(sx, sy, sz, dx, dy, dz); + } - protected void drawParticleLine(final double srcX, final double srcY, final double srcZ, final double destX, final double destY, final double destZ) - { - final int particles = 16; - for (int i = 0; i < particles; i++) - { - final double trailFactor = i / (particles - 1.0D); + protected void drawParticleLine( + final double srcX, + final double srcY, + final double srcZ, + final double destX, + final double destY, + final double destZ) { + final int particles = 16; + for (int i = 0; i < particles; i++) { + final double trailFactor = i / (particles - 1.0D); - final double tx = srcX + ((destX - srcX) * trailFactor) + (this.rand.nextFloat() * 0.005D); - final double ty = srcY + ((destY - srcY) * trailFactor) + (this.rand.nextFloat() * 0.005D); - final double tz = srcZ + ((destZ - srcZ) * trailFactor) + (this.rand.nextFloat() * 0.005D); - this.worldObj.spawnParticle("portal", tx, ty, tz, 0.0D, 0.0D, 0.0D); - } - } + final double tx = srcX + ((destX - srcX) * trailFactor) + (this.rand.nextFloat() * 0.005D); + final double ty = srcY + ((destY - srcY) * trailFactor) + (this.rand.nextFloat() * 0.005D); + final double tz = srcZ + ((destZ - srcZ) * trailFactor) + (this.rand.nextFloat() * 0.005D); + this.worldObj.spawnParticle("portal", tx, ty, tz, 0.0D, 0.0D, 0.0D); + } + } - private boolean scanAndRevertChanges() - { - int index = 0; - boolean reverted = false; - for (int x = -this.radius; x <= this.radius; x++) { - for (int y = -this.radius; y <= this.radius; y++) { - for (int z = -this.radius; z <= this.radius; z++) - { - final Block blockID = this.worldObj.getBlock(this.xCoord + x, this.yCoord + y, this.zCoord + z); - final byte meta = (byte)this.worldObj.getBlockMetadata(this.xCoord + x, this.yCoord + y, this.zCoord + z); - if (this.blockData[index] != blockID) { - if (this.revertBlock(this.xCoord + x, this.yCoord + y, this.zCoord + z, blockID, meta, this.blockData[index], this.metaData[index])) - { - reverted = true; - } - else - { - this.blockData[index] = blockID; - this.metaData[index] = meta; - } - } - index++; - } - } - } - return reverted; - } + private boolean scanAndRevertChanges() { + int index = 0; + boolean reverted = false; + for (int x = -this.radius; x <= this.radius; x++) { + for (int y = -this.radius; y <= this.radius; y++) { + for (int z = -this.radius; z <= this.radius; z++) { + final Block blockID = this.worldObj.getBlock(this.xCoord + x, this.yCoord + y, this.zCoord + z); + final byte meta = + (byte) this.worldObj.getBlockMetadata(this.xCoord + x, this.yCoord + y, this.zCoord + z); + if (this.blockData[index] != blockID) { + if (this.revertBlock( + this.xCoord + x, + this.yCoord + y, + this.zCoord + z, + blockID, + meta, + this.blockData[index], + this.metaData[index])) { + reverted = true; + } else { + this.blockData[index] = blockID; + this.metaData[index] = meta; + } + } + index++; + } + } + } + return reverted; + } - private boolean revertBlock(final int x, final int y, final int z, final Block thereBlockID, final byte thereMeta, final Block replaceBlockID, byte replaceMeta) - { - /*if ((thereBlockID == Blocks.air) && (!replaceBlockID.getMaterial().blocksMovement())) - { - System.out.println("Not replacing block " + replaceBlockID + " because it doesn't block movement"); + private boolean revertBlock( + final int x, + final int y, + final int z, + final Block thereBlockID, + final byte thereMeta, + final Block replaceBlockID, + byte replaceMeta) { + /*if ((thereBlockID == Blocks.air) && (!replaceBlockID.getMaterial().blocksMovement())) + { + System.out.println("Not replacing block " + replaceBlockID + " because it doesn't block movement"); - return false; - }*/ - if (this.isUnrevertable(thereBlockID, thereMeta, replaceBlockID, replaceMeta)) { - return false; - } - if (this.rand.nextInt(5) == 0) - { - if (replaceBlockID != Blocks.air) - { - //replaceBlockID = null; - replaceMeta = 4; - } - this.worldObj.setBlock(x, y, z, replaceBlockID, replaceMeta, 2); - if (thereBlockID == Blocks.air) - { - this.worldObj.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(replaceBlockID) + (replaceMeta << 12)); - } - else if (replaceBlockID == Blocks.air) - { - this.worldObj.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(thereBlockID) + (thereMeta << 12)); - thereBlockID.dropBlockAsItem(this.worldObj, x, y, z, thereMeta, 0); - } - } - return true; - } + return false; + }*/ + if (this.isUnrevertable(thereBlockID, thereMeta, replaceBlockID, replaceMeta)) { + return false; + } + if (this.rand.nextInt(5) == 0) { + if (replaceBlockID != Blocks.air) { + // replaceBlockID = null; + replaceMeta = 4; + } + this.worldObj.setBlock(x, y, z, replaceBlockID, replaceMeta, 2); + if (thereBlockID == Blocks.air) { + this.worldObj.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(replaceBlockID) + (replaceMeta << 12)); + } else if (replaceBlockID == Blocks.air) { + this.worldObj.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(thereBlockID) + (thereMeta << 12)); + thereBlockID.dropBlockAsItem(this.worldObj, x, y, z, thereMeta, 0); + } + } + return true; + } - private boolean isUnrevertable(final Block thereBlockID, final byte thereMeta, final Block replaceBlockID, final byte replaceMeta) - { - if ((thereBlockID == ModBlocks.blockGriefSaver) || (replaceBlockID == ModBlocks.blockGriefSaver)) { - return true; - } - /*if (((thereBlockID == towerTranslucent) && (thereMeta != 4)) || ((replaceBlockID == towerTranslucent) && (replaceMeta != 4))) { - return true; - }*/ - if ((thereBlockID == Blocks.redstone_lamp) && (replaceBlockID == Blocks.lit_redstone_lamp)) { - return true; - } - if ((thereBlockID == Blocks.lit_redstone_lamp) && (replaceBlockID == Blocks.redstone_lamp)) { - return true; - } - /*if ((thereBlockID == Blocks.water) || (replaceBlockID == Blocks.flowing_water)) { - return true; - } - if ((thereBlockID == Blocks.flowing_water) || (replaceBlockID == Blocks.water)) { - return true; - }*/ - if (replaceBlockID == Blocks.tnt) { - return true; - } - return false; - } + private boolean isUnrevertable( + final Block thereBlockID, final byte thereMeta, final Block replaceBlockID, final byte replaceMeta) { + if ((thereBlockID == ModBlocks.blockGriefSaver) || (replaceBlockID == ModBlocks.blockGriefSaver)) { + return true; + } + /*if (((thereBlockID == towerTranslucent) && (thereMeta != 4)) || ((replaceBlockID == towerTranslucent) && (replaceMeta != 4))) { + return true; + }*/ + if ((thereBlockID == Blocks.redstone_lamp) && (replaceBlockID == Blocks.lit_redstone_lamp)) { + return true; + } + if ((thereBlockID == Blocks.lit_redstone_lamp) && (replaceBlockID == Blocks.redstone_lamp)) { + return true; + } + /*if ((thereBlockID == Blocks.water) || (replaceBlockID == Blocks.flowing_water)) { + return true; + } + if ((thereBlockID == Blocks.flowing_water) || (replaceBlockID == Blocks.water)) { + return true; + }*/ + if (replaceBlockID == Blocks.tnt) { + return true; + } + return false; + } - private void captureBlockData() - { - this.blockData = new Block[this.diameter * this.diameter * this.diameter]; - this.metaData = new byte[this.diameter * this.diameter * this.diameter]; + private void captureBlockData() { + this.blockData = new Block[this.diameter * this.diameter * this.diameter]; + this.metaData = new byte[this.diameter * this.diameter * this.diameter]; - int index = 0; - for (int x = -this.radius; x <= this.radius; x++) { - for (int y = -this.radius; y <= this.radius; y++) { - for (int z = -this.radius; z <= this.radius; z++) - { - final Block blockID = this.worldObj.getBlock(this.xCoord + x, this.yCoord + y, this.zCoord + z); - final int meta = this.worldObj.getBlockMetadata(this.xCoord + x, this.yCoord + y, this.zCoord + z); + int index = 0; + for (int x = -this.radius; x <= this.radius; x++) { + for (int y = -this.radius; y <= this.radius; y++) { + for (int z = -this.radius; z <= this.radius; z++) { + final Block blockID = this.worldObj.getBlock(this.xCoord + x, this.yCoord + y, this.zCoord + z); + final int meta = this.worldObj.getBlockMetadata(this.xCoord + x, this.yCoord + y, this.zCoord + z); - this.blockData[index] = blockID; - this.metaData[index] = ((byte)meta); + this.blockData[index] = blockID; + this.metaData[index] = ((byte) meta); - index++; - } - } - } - } + index++; + } + } + } + } - public boolean anyPlayerInRange() - { - return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, this.requiredPlayerRange) != null; - } + public boolean anyPlayerInRange() { + return this.worldObj.getClosestPlayer( + this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, this.requiredPlayerRange) + != null; + } } diff --git a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java index bc096c0d53..f063abb53c 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java +++ b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java @@ -19,389 +19,383 @@ import net.minecraftforge.fluids.FluidStack; public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISidedInventory { - private int tickCount = 0; - private final Inventory_VolumetricFlaskSetter inventoryContents; - private String customName; - public int locationX; - public int locationY; - public int locationZ; - private int aCurrentMode = 0; - private int aCustomValue = 1000; - - public TileEntityVolumetricFlaskSetter() { - this.inventoryContents = new Inventory_VolumetricFlaskSetter(); - this.setTileLocation(); - } - - public int getCustomValue() { - //Logger.INFO("Value: "+this.aCustomValue); - return this.aCustomValue; - } - - public void setCustomValue(int aVal) { - log("Old Value: "+this.aCustomValue); - this.aCustomValue = (short) MathUtils.balance(aVal, 0, Short.MAX_VALUE); - log("New Value: "+this.aCustomValue); - markDirty(); - } - - public boolean setTileLocation() { - if (this.hasWorldObj()) { - if (!this.getWorldObj().isRemote) { - this.locationX = this.xCoord; - this.locationY = this.yCoord; - this.locationZ = this.zCoord; - return true; - } - } - return false; - } - - //Rename to hasCircuitToConfigure - public final boolean hasFlask() { - for (int i=0;i= 16) { - return false; - } - } - AutoMap aValidSlots = new AutoMap(); - int aSlotCount = 0; - for (ItemStack i : aInputs) { - if (i != null) { - aValidSlots.put(aSlotCount); - } - aSlotCount++; - } - for (int e : aValidSlots) { - - // Skip slot 7 (Custom) unless it has a value > 0 - if (e == 7 && getCustomValue() <= 0) { - log("Skipping Custom slot as value <= 0"); - continue; - } - if (e == Container_VolumetricFlaskSetter.SLOT_OUTPUT) { - continue; - } - - boolean doAdd = false; - ItemStack g = this.getStackInSlot(e); - FluidStack aInputFluidStack = VolumetricFlaskHelper.getFlaskFluid(g); - int aSize = 0; - ItemStack aInputStack = null; - int aTypeInSlot = getFlaskType(g); - if (aTypeInSlot > 0 && g != null) { - // No Existing Output - if (!hasOutput) { - aSize = g.stackSize; - doAdd = true; - } - // Existing Output - else { - ItemStack f = aInputs[Container_VolumetricFlaskSetter.SLOT_OUTPUT]; - FluidStack aFluidInCheckedSlot = VolumetricFlaskHelper.getFlaskFluid(f); - int aTypeInCheckedSlot = getFlaskType(f); - // Check that the Circuit in the Output slot is not null and the same type as the circuit input. - if (aTypeInCheckedSlot > 0 && (aTypeInSlot == aTypeInCheckedSlot) && f != null) { - if (g.getItem() == f.getItem() && VolumetricFlaskHelper.getFlaskCapacity(f) == getCapacityForSlot(e) && ((aInputFluidStack == null && aFluidInCheckedSlot == null) || aInputFluidStack.isFluidEqual(aFluidInCheckedSlot))) { - log("Input Slot Flask Contains: "+(aInputFluidStack != null ? aInputFluidStack.getLocalizedName() : "Empty")); - log("Output Slot Flask Contains: "+(aFluidInCheckedSlot != null ? aFluidInCheckedSlot.getLocalizedName() : "Empty")); - aSize = f.stackSize + g.stackSize; - if (aSize > 16) { - aInputStack = g.copy(); - aInputStack.stackSize = (aSize-16); - } - doAdd = true; - } - } - } - if (doAdd) { - // Check Circuit Type - ItemStack aOutput; - FluidStack aOutputFluid = null; - if (!VolumetricFlaskHelper.isFlaskEmpty(g)) { - aOutputFluid = aInputFluidStack.copy(); - } - if (aTypeInSlot == 1) { - aOutput = VolumetricFlaskHelper.getVolumetricFlask(1); - } - else if (aTypeInSlot == 2) { - aOutput = VolumetricFlaskHelper.getLargeVolumetricFlask(1); - } - else if (aTypeInSlot == 3) { - aOutput = VolumetricFlaskHelper.getGiganticVolumetricFlask(1); - } - else { - aOutput = null; - } - if (aOutput != null) { - aOutput.stackSize = aSize; - int aCapacity = getCapacityForSlot(e); - VolumetricFlaskHelper.setNewFlaskCapacity(aOutput, aCapacity); - if (aOutputFluid != null) { - if (aOutputFluid.amount > aCapacity) { - aOutputFluid.amount = aCapacity; - } - VolumetricFlaskHelper.setFluid(aOutput, aOutputFluid); - } - this.setInventorySlotContents(e, aInputStack); - this.setInventorySlotContents(Container_VolumetricFlaskSetter.SLOT_OUTPUT, aOutput); - return true; - } - } - } - continue; - } - return false; - } - - @Override - public void updateEntity() { - try{ - if (!this.worldObj.isRemote) { - if (tickCount % 10 == 0) { - if (hasFlask()) { - this.addOutput(); - this.markDirty(); - } - } - this.tickCount++; - } - } - catch (final Throwable t){} - } - - public boolean anyPlayerInRange() { - return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) != null; - } - - public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) { - if (!nbt.hasKey(tag)) { - nbt.setTag(tag, new NBTTagCompound()); - } - return nbt.getCompoundTag(tag); - } - - @Override - public void writeToNBT(final NBTTagCompound nbt) { - super.writeToNBT(nbt); - // Utils.LOG_WARNING("Trying to write NBT data to TE."); - final NBTTagCompound chestData = new NBTTagCompound(); - this.inventoryContents.writeToNBT(chestData); - nbt.setTag("ContentsChest", chestData); - nbt.setInteger("aCustomValue", aCustomValue); - if (this.hasCustomInventoryName()) { - nbt.setString("CustomName", this.getCustomName()); - } - nbt.setInteger("aCurrentMode", aCurrentMode); - } - - @Override - public void readFromNBT(final NBTTagCompound nbt) { - super.readFromNBT(nbt); - // Utils.LOG_WARNING("Trying to read NBT data from TE."); - this.inventoryContents.readFromNBT(nbt.getCompoundTag("ContentsChest")); - this.aCustomValue = nbt.getInteger("aCustomValue"); - if (nbt.hasKey("CustomName", 8)) { - this.setCustomName(nbt.getString("CustomName")); - } - aCurrentMode = nbt.getInteger("aCurrentMode"); - } - - @Override - public int getSizeInventory() { - return this.getInventory().getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(final int slot) { - return this.getInventory().getStackInSlot(slot); - } - - @Override - public ItemStack decrStackSize(final int slot, final int count) { - return this.getInventory().decrStackSize(slot, count); - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) { - return this.getInventory().getStackInSlotOnClosing(slot); - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) { - this.getInventory().setInventorySlotContents(slot, stack); - } - - @Override - public int getInventoryStackLimit() { - return this.getInventory().getInventoryStackLimit(); - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) { - return this.getInventory().isUseableByPlayer(entityplayer); - } - - @Override - public void openInventory() { - this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); - this.getInventory().openInventory(); - } - - @Override - public void closeInventory() { - this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); - this.getInventory().closeInventory(); - } - - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { - return this.getInventory().isItemValidForSlot(slot, itemstack); - } - - @Override - public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { - final int[] accessibleSides = new int[this.getSizeInventory()]; - for (int r=0; r= 16) { + return false; + } + } + AutoMap aValidSlots = new AutoMap(); + int aSlotCount = 0; + for (ItemStack i : aInputs) { + if (i != null) { + aValidSlots.put(aSlotCount); + } + aSlotCount++; + } + for (int e : aValidSlots) { + + // Skip slot 7 (Custom) unless it has a value > 0 + if (e == 7 && getCustomValue() <= 0) { + log("Skipping Custom slot as value <= 0"); + continue; + } + if (e == Container_VolumetricFlaskSetter.SLOT_OUTPUT) { + continue; + } + + boolean doAdd = false; + ItemStack g = this.getStackInSlot(e); + FluidStack aInputFluidStack = VolumetricFlaskHelper.getFlaskFluid(g); + int aSize = 0; + ItemStack aInputStack = null; + int aTypeInSlot = getFlaskType(g); + if (aTypeInSlot > 0 && g != null) { + // No Existing Output + if (!hasOutput) { + aSize = g.stackSize; + doAdd = true; + } + // Existing Output + else { + ItemStack f = aInputs[Container_VolumetricFlaskSetter.SLOT_OUTPUT]; + FluidStack aFluidInCheckedSlot = VolumetricFlaskHelper.getFlaskFluid(f); + int aTypeInCheckedSlot = getFlaskType(f); + // Check that the Circuit in the Output slot is not null and the same type as the circuit input. + if (aTypeInCheckedSlot > 0 && (aTypeInSlot == aTypeInCheckedSlot) && f != null) { + if (g.getItem() == f.getItem() + && VolumetricFlaskHelper.getFlaskCapacity(f) == getCapacityForSlot(e) + && ((aInputFluidStack == null && aFluidInCheckedSlot == null) + || aInputFluidStack.isFluidEqual(aFluidInCheckedSlot))) { + log("Input Slot Flask Contains: " + + (aInputFluidStack != null ? aInputFluidStack.getLocalizedName() : "Empty")); + log("Output Slot Flask Contains: " + + (aFluidInCheckedSlot != null ? aFluidInCheckedSlot.getLocalizedName() : "Empty")); + aSize = f.stackSize + g.stackSize; + if (aSize > 16) { + aInputStack = g.copy(); + aInputStack.stackSize = (aSize - 16); + } + doAdd = true; + } + } + } + if (doAdd) { + // Check Circuit Type + ItemStack aOutput; + FluidStack aOutputFluid = null; + if (!VolumetricFlaskHelper.isFlaskEmpty(g)) { + aOutputFluid = aInputFluidStack.copy(); + } + if (aTypeInSlot == 1) { + aOutput = VolumetricFlaskHelper.getVolumetricFlask(1); + } else if (aTypeInSlot == 2) { + aOutput = VolumetricFlaskHelper.getLargeVolumetricFlask(1); + } else if (aTypeInSlot == 3) { + aOutput = VolumetricFlaskHelper.getGiganticVolumetricFlask(1); + } else { + aOutput = null; + } + if (aOutput != null) { + aOutput.stackSize = aSize; + int aCapacity = getCapacityForSlot(e); + VolumetricFlaskHelper.setNewFlaskCapacity(aOutput, aCapacity); + if (aOutputFluid != null) { + if (aOutputFluid.amount > aCapacity) { + aOutputFluid.amount = aCapacity; + } + VolumetricFlaskHelper.setFluid(aOutput, aOutputFluid); + } + this.setInventorySlotContents(e, aInputStack); + this.setInventorySlotContents(Container_VolumetricFlaskSetter.SLOT_OUTPUT, aOutput); + return true; + } + } + } + continue; + } + return false; + } + + @Override + public void updateEntity() { + try { + if (!this.worldObj.isRemote) { + if (tickCount % 10 == 0) { + if (hasFlask()) { + this.addOutput(); + this.markDirty(); + } + } + this.tickCount++; + } + } catch (final Throwable t) { + } + } + + public boolean anyPlayerInRange() { + return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) != null; + } + + public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) { + if (!nbt.hasKey(tag)) { + nbt.setTag(tag, new NBTTagCompound()); + } + return nbt.getCompoundTag(tag); + } + + @Override + public void writeToNBT(final NBTTagCompound nbt) { + super.writeToNBT(nbt); + // Utils.LOG_WARNING("Trying to write NBT data to TE."); + final NBTTagCompound chestData = new NBTTagCompound(); + this.inventoryContents.writeToNBT(chestData); + nbt.setTag("ContentsChest", chestData); + nbt.setInteger("aCustomValue", aCustomValue); + if (this.hasCustomInventoryName()) { + nbt.setString("CustomName", this.getCustomName()); + } + nbt.setInteger("aCurrentMode", aCurrentMode); + } + + @Override + public void readFromNBT(final NBTTagCompound nbt) { + super.readFromNBT(nbt); + // Utils.LOG_WARNING("Trying to read NBT data from TE."); + this.inventoryContents.readFromNBT(nbt.getCompoundTag("ContentsChest")); + this.aCustomValue = nbt.getInteger("aCustomValue"); + if (nbt.hasKey("CustomName", 8)) { + this.setCustomName(nbt.getString("CustomName")); + } + aCurrentMode = nbt.getInteger("aCurrentMode"); + } + + @Override + public int getSizeInventory() { + return this.getInventory().getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.getInventory().getStackInSlot(slot); + } + + @Override + public ItemStack decrStackSize(final int slot, final int count) { + return this.getInventory().decrStackSize(slot, count); + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + return this.getInventory().getStackInSlotOnClosing(slot); + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.getInventory().setInventorySlotContents(slot, stack); + } + + @Override + public int getInventoryStackLimit() { + return this.getInventory().getInventoryStackLimit(); + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return this.getInventory().isUseableByPlayer(entityplayer); + } + + @Override + public void openInventory() { + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + this.getInventory().openInventory(); + } + + @Override + public void closeInventory() { + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + this.getInventory().closeInventory(); + } + + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + return this.getInventory().isItemValidForSlot(slot, itemstack); + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + final int[] accessibleSides = new int[this.getSizeInventory()]; + for (int r = 0; r < this.getInventory().getSizeInventory(); r++) { + accessibleSides[r] = r; + } + return accessibleSides; + } + + @Override + public boolean canInsertItem(final int aSlot, final ItemStack p_102007_2_, final int p_102007_3_) { + return aSlot == aCurrentMode; + } + + @Override + public boolean canExtractItem(final int aSlot, final ItemStack p_102008_2_, final int p_102008_3_) { + return aSlot == Container_VolumetricFlaskSetter.SLOT_OUTPUT; + } + + public String getCustomName() { + return this.customName; + } + + public void setCustomName(final String customName) { + this.customName = customName; + } + + @Override + public String getInventoryName() { + return this.hasCustomInventoryName() ? this.customName : "container.VolumetricFlaskSetter"; + } + + @Override + public boolean hasCustomInventoryName() { + return (this.customName != null) && !this.customName.equals(""); + } + + @Override + public Packet getDescriptionPacket() { + final NBTTagCompound tag = new NBTTagCompound(); + this.writeToNBT(tag); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, this.blockMetadata, tag); + } + + @Override + public void onDataPacket(final NetworkManager net, final S35PacketUpdateTileEntity pkt) { + final NBTTagCompound tag = pkt.func_148857_g(); + this.readFromNBT(tag); + } + + public boolean onScrewdriverRightClick(byte side, EntityPlayer player, int x, int y, int z) { + + if (player.isSneaking()) { + PlayerUtils.messagePlayer(player, "Value: " + this.getCustomValue()); + } + + try { + if (aCurrentMode == 7) { + aCurrentMode = 0; + } else { + aCurrentMode++; + } + PlayerUtils.messagePlayer(player, "Slot " + aCurrentMode + " is now default."); + return true; + } catch (Throwable t) { + return false; + } + } + + public void log(String aString) { + Logger.INFO("[Flask-Tile] " + aString); + } } diff --git a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java index 2816596515..8b72ca911f 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java +++ b/src/main/java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java @@ -1,298 +1,296 @@ package gtPlusPlus.core.tileentities.general; -import org.lwjgl.input.Keyboard; - +import gtPlusPlus.api.objects.minecraft.BTF_FluidTank; +import gtPlusPlus.core.tileentities.base.TileBasicTank; +import gtPlusPlus.core.util.minecraft.EnchantingUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; -import gtPlusPlus.api.objects.minecraft.BTF_FluidTank; -import gtPlusPlus.core.tileentities.base.TileBasicTank; -import gtPlusPlus.core.util.minecraft.EnchantingUtils; -import gtPlusPlus.core.util.minecraft.PlayerUtils; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.*; +import org.lwjgl.input.Keyboard; public class TileEntityXpConverter extends TileBasicTank { - public BTF_FluidTank tankEssence = new BTF_FluidTank((int) (64000*EnchantingUtils.RATIO_MOB_ESSENCE_TO_LIQUID_XP)); - public BTF_FluidTank tankLiquidXp = new BTF_FluidTank(64000); - private boolean mConvertToEssence = true; - - public TileEntityXpConverter() { - super (4, 32000); - } - - private void changeMode(){ - if (this.mConvertToEssence){ - this.mConvertToEssence = false; - return; - } - else { - this.mConvertToEssence = true; - return; - } - } + public BTF_FluidTank tankEssence = + new BTF_FluidTank((int) (64000 * EnchantingUtils.RATIO_MOB_ESSENCE_TO_LIQUID_XP)); + public BTF_FluidTank tankLiquidXp = new BTF_FluidTank(64000); + private boolean mConvertToEssence = true; - public float getAdjustedVolume() { - if (this.mConvertToEssence){ - if ((this.tankLiquidXp.getFluid() != null) && (this.tankLiquidXp.getFluidAmount() >= 100) && (this.tankEssence.getFluidAmount() <= (this.tankEssence.getCapacity()-(100*EnchantingUtils.RATIO_MOB_ESSENCE_TO_LIQUID_XP)))){ - final FluidStack bigStorage = EnchantingUtils.getEssenceFromLiquidXp(100); - this.tankEssence.fill(bigStorage, true); - this.tankLiquidXp.drain(100, true); - return (this.tankEssence.getCapacity()-this.tankEssence.getFluidAmount()); - } - } - else { - final double rm = EnchantingUtils.RATIO_MOB_ESSENCE_TO_LIQUID_XP; - if ((this.tankEssence.getFluid() != null) && (this.tankEssence.getFluidAmount() >= rm) && (this.tankLiquidXp.getFluidAmount() <= (this.tankLiquidXp.getCapacity()-rm))){ - final FluidStack bigStorage = EnchantingUtils.getLiquidXP(1); - this.tankLiquidXp.fill(bigStorage, true); - this.tankEssence.drain((int) rm, true); - return (this.tankLiquidXp.getCapacity()-this.tankLiquidXp.getFluidAmount()); - } - } - return 0f; - } + public TileEntityXpConverter() { + super(4, 32000); + } - @Override - public void readFromNBT(final NBTTagCompound tag) { - this.tankEssence.readFromNBT(tag); - this.tankLiquidXp.readFromNBT(tag); - this.mConvertToEssence = tag.getBoolean("mConvertToEssence"); - super.readFromNBT(tag); - } + private void changeMode() { + if (this.mConvertToEssence) { + this.mConvertToEssence = false; + return; + } else { + this.mConvertToEssence = true; + return; + } + } - @Override - public void writeToNBT(final NBTTagCompound tag) { - this.tankEssence.writeToNBT(tag); - this.tankLiquidXp.writeToNBT(tag); - tag.setBoolean("mConvertToEssence", this.mConvertToEssence); - super.writeToNBT(tag); - } + public float getAdjustedVolume() { + if (this.mConvertToEssence) { + if ((this.tankLiquidXp.getFluid() != null) + && (this.tankLiquidXp.getFluidAmount() >= 100) + && (this.tankEssence.getFluidAmount() + <= (this.tankEssence.getCapacity() + - (100 * EnchantingUtils.RATIO_MOB_ESSENCE_TO_LIQUID_XP)))) { + final FluidStack bigStorage = EnchantingUtils.getEssenceFromLiquidXp(100); + this.tankEssence.fill(bigStorage, true); + this.tankLiquidXp.drain(100, true); + return (this.tankEssence.getCapacity() - this.tankEssence.getFluidAmount()); + } + } else { + final double rm = EnchantingUtils.RATIO_MOB_ESSENCE_TO_LIQUID_XP; + if ((this.tankEssence.getFluid() != null) + && (this.tankEssence.getFluidAmount() >= rm) + && (this.tankLiquidXp.getFluidAmount() <= (this.tankLiquidXp.getCapacity() - rm))) { + final FluidStack bigStorage = EnchantingUtils.getLiquidXP(1); + this.tankLiquidXp.fill(bigStorage, true); + this.tankEssence.drain((int) rm, true); + return (this.tankLiquidXp.getCapacity() - this.tankLiquidXp.getFluidAmount()); + } + } + return 0f; + } - @Override - public Packet getDescriptionPacket() { - final NBTTagCompound tag = new NBTTagCompound(); - this.writeToNBT(tag); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, this.blockMetadata, tag); - } + @Override + public void readFromNBT(final NBTTagCompound tag) { + this.tankEssence.readFromNBT(tag); + this.tankLiquidXp.readFromNBT(tag); + this.mConvertToEssence = tag.getBoolean("mConvertToEssence"); + super.readFromNBT(tag); + } - @Override - public void onDataPacket(final NetworkManager net, final S35PacketUpdateTileEntity pkt) { - final NBTTagCompound tag = pkt.func_148857_g(); - this.readFromNBT(tag); - } + @Override + public void writeToNBT(final NBTTagCompound tag) { + this.tankEssence.writeToNBT(tag); + this.tankLiquidXp.writeToNBT(tag); + tag.setBoolean("mConvertToEssence", this.mConvertToEssence); + super.writeToNBT(tag); + } - public void onScrewdriverRightClick(final byte aSide, final EntityPlayer aPlayer, final float aX, final float aY, final float aZ) { - if (this.isServerSide()){ - if (this.mConvertToEssence){ - PlayerUtils.messagePlayer(aPlayer, "Converting from Mob Essence to Liquid Xp."); - } - else { - PlayerUtils.messagePlayer(aPlayer, "Converting from Liquid Xp to Mob Essence."); - } - //Mode Change - this.changeMode(); - } - } + @Override + public Packet getDescriptionPacket() { + final NBTTagCompound tag = new NBTTagCompound(); + this.writeToNBT(tag); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, this.blockMetadata, tag); + } - public void onRightClick(final byte aSide, final EntityPlayer aPlayer, final int aX, final int aY, final int aZ) { - if ((Keyboard.isKeyDown(42)) || (Keyboard.isKeyDown(54))) { - String mInput; - String mOutput; + @Override + public void onDataPacket(final NetworkManager net, final S35PacketUpdateTileEntity pkt) { + final NBTTagCompound tag = pkt.func_148857_g(); + this.readFromNBT(tag); + } - if (this.mConvertToEssence){ - mInput = "Liquid Xp"; - mOutput = "Mob Essence"; - } - else { - mInput = "Mob Essence"; - mOutput = "Liquid Xp"; - } + public void onScrewdriverRightClick( + final byte aSide, final EntityPlayer aPlayer, final float aX, final float aY, final float aZ) { + if (this.isServerSide()) { + if (this.mConvertToEssence) { + PlayerUtils.messagePlayer(aPlayer, "Converting from Mob Essence to Liquid Xp."); + } else { + PlayerUtils.messagePlayer(aPlayer, "Converting from Liquid Xp to Mob Essence."); + } + // Mode Change + this.changeMode(); + } + } - PlayerUtils.messagePlayer(aPlayer, "Input: "+mInput+"."); - PlayerUtils.messagePlayer(aPlayer, "Output: "+mOutput+"."); - } - } + public void onRightClick(final byte aSide, final EntityPlayer aPlayer, final int aX, final int aY, final int aZ) { + if ((Keyboard.isKeyDown(42)) || (Keyboard.isKeyDown(54))) { + String mInput; + String mOutput; - @Override - public boolean onPreTick(long aTick) { - boolean aSuperResult = super.onPreTick(aTick); - long aTankSpaceLeft = 0; - double aAmount = 0; - int aRuns = 0; - if (this.mConvertToEssence) { - aTankSpaceLeft = (this.tankEssence.getCapacity()-this.tankEssence.getFluidAmount()); - aAmount = EnchantingUtils.getEssenceFromLiquidXp(100).amount; - } - else { - aTankSpaceLeft = (this.tankLiquidXp.getCapacity()-this.tankLiquidXp.getFluidAmount()); - aAmount = EnchantingUtils.RATIO_MOB_ESSENCE_TO_LIQUID_XP; - } - aRuns = (int) (aTankSpaceLeft / aAmount); - for (int i=0;i getTileEntityClass(); - - protected abstract String getTileEntityNameForRegistration(); - - public Block getBlock() { - return mTilePos != null ? mTilePos.getBlockAtPos() : Blocks.redstone_block; - } - - public final boolean isLight() { - return mLightMode; - } - - public final float getLightBrightness() { - if (!isLight()) { - return 0; - } - else { - return mLightValue; - } - } - - @Override - public void readFromNBT(NBTTagCompound aNBT) { - mStartTime = aNBT.getLong("mStartTime"); - mInvName = aNBT.getString("mInvName"); - mLightValue = aNBT.getFloat("mLightValue"); - mLightMode = aNBT.getBoolean("mLightMode"); - mRedstoneLevel = aNBT.getByte("mRedstoneLevel"); - super.readFromNBT(aNBT); - } - - @Override - public void writeToNBT(NBTTagCompound aNBT) { - aNBT.setInteger("mTileType", mTileType); - aNBT.setLong("mStartTime", mStartTime); - aNBT.setString("mInvName", mInvName); - aNBT.setFloat("mLightValue", getLightBrightness()); - aNBT.setBoolean("mLightMode", isLight()); - aNBT.setByte("mRedstoneLevel", mRedstoneLevel); - super.writeToNBT(aNBT); - } - - - private boolean mHasUpdatedRecently = false; - - private final boolean init() { - if (mTilePos == null) { - try { - mTilePos = new BlockPos(this); - } catch (Throwable t) { - return false; - } - } - if (mStartTime == null) { - try { - mStartTime = System.currentTimeMillis(); - } catch (Throwable t) { - return false; - } - } - return true; - } - private Long mLastUpdate; - private String mInvName = ""; - - @Override - public void updateEntity() { - //Handle init - if (!init()) { - return; - } - if (mRequiresUpdate || mLastUpdate == null) { - mRequiresUpdate = false; - mHasUpdatedRecently = true; - mLastUpdate = System.currentTimeMillis(); - if (mTilePos.world.getBlockLightValue(xCoord, yCoord, zCoord) != getLightBrightness()/0.0625f) { - mTilePos.getBlockAtPos().setLightLevel(getLightBrightness()/0.0625f); - mTilePos.world.setLightValue(EnumSkyBlock.Block, xCoord, yCoord, zCoord, (int) (getLightBrightness()/0.0625f)); - mTilePos.world.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord); - Logger.INFO("Updating Light"); - } - mTilePos.world.scheduleBlockUpdate(xCoord, yCoord, zCoord, mTilePos.getBlockAtPos(), 1); - markDirty(); - } - if (Utils.getMillisSince(mLastUpdate, System.currentTimeMillis()) >= 5000) { - if (mHasUpdatedRecently) { - mHasUpdatedRecently = false; - this.markForUpdate(); - } - } - - if (Utils.getMillisSince(mStartTime, System.currentTimeMillis()) % 50 == 0) { - - } - - - - super.updateEntity(); - } - - public final void markForUpdate() { - mRequiresUpdate = true; - } - - public final boolean hasUpdatedRecently() { - return mHasUpdatedRecently; - } - - @Override - public int getBlockMetadata() { - return super.getBlockMetadata(); - } - - @Override - public void markDirty() { - super.markDirty(); - } - - @Override - public boolean canUpdate() { - return true; - } - - public void setRedstoneState(boolean aRedstoneActive) { - - } - - public void setCurrentTextureArray(IIcon[] aTextures) { - - } - + private final int mTileType; + private BlockPos mTilePos; + private boolean mRequiresUpdate = false; + private Long mStartTime; + private Byte mRedstoneLevel; + + public boolean mLightMode = false; + public float mLightValue = 0; + + /** + * Sets the Redstone Handler Type. + * @param aTileType - A type of the handler designated by an int. 0 = receiver, 1 = emitter, 2 = both, anything else = nothing. + */ + public TileEntityRedstoneHandler(int aTileType) { + mTileType = aTileType; + registerTileEntity(); + } + + private void registerTileEntity() { + if (!EntityUtils.isTileEntityRegistered(getTileEntityClass(), getTileEntityNameForRegistration())) { + GameRegistry.registerTileEntity(getTileEntityClass(), getTileEntityNameForRegistration()); + } + } + + protected abstract Class getTileEntityClass(); + + protected abstract String getTileEntityNameForRegistration(); + + public Block getBlock() { + return mTilePos != null ? mTilePos.getBlockAtPos() : Blocks.redstone_block; + } + + public final boolean isLight() { + return mLightMode; + } + + public final float getLightBrightness() { + if (!isLight()) { + return 0; + } else { + return mLightValue; + } + } + + @Override + public void readFromNBT(NBTTagCompound aNBT) { + mStartTime = aNBT.getLong("mStartTime"); + mInvName = aNBT.getString("mInvName"); + mLightValue = aNBT.getFloat("mLightValue"); + mLightMode = aNBT.getBoolean("mLightMode"); + mRedstoneLevel = aNBT.getByte("mRedstoneLevel"); + super.readFromNBT(aNBT); + } + + @Override + public void writeToNBT(NBTTagCompound aNBT) { + aNBT.setInteger("mTileType", mTileType); + aNBT.setLong("mStartTime", mStartTime); + aNBT.setString("mInvName", mInvName); + aNBT.setFloat("mLightValue", getLightBrightness()); + aNBT.setBoolean("mLightMode", isLight()); + aNBT.setByte("mRedstoneLevel", mRedstoneLevel); + super.writeToNBT(aNBT); + } + + private boolean mHasUpdatedRecently = false; + + private final boolean init() { + if (mTilePos == null) { + try { + mTilePos = new BlockPos(this); + } catch (Throwable t) { + return false; + } + } + if (mStartTime == null) { + try { + mStartTime = System.currentTimeMillis(); + } catch (Throwable t) { + return false; + } + } + return true; + } + + private Long mLastUpdate; + private String mInvName = ""; + + @Override + public void updateEntity() { + // Handle init + if (!init()) { + return; + } + if (mRequiresUpdate || mLastUpdate == null) { + mRequiresUpdate = false; + mHasUpdatedRecently = true; + mLastUpdate = System.currentTimeMillis(); + if (mTilePos.world.getBlockLightValue(xCoord, yCoord, zCoord) != getLightBrightness() / 0.0625f) { + mTilePos.getBlockAtPos().setLightLevel(getLightBrightness() / 0.0625f); + mTilePos.world.setLightValue( + EnumSkyBlock.Block, xCoord, yCoord, zCoord, (int) (getLightBrightness() / 0.0625f)); + mTilePos.world.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord); + Logger.INFO("Updating Light"); + } + mTilePos.world.scheduleBlockUpdate(xCoord, yCoord, zCoord, mTilePos.getBlockAtPos(), 1); + markDirty(); + } + if (Utils.getMillisSince(mLastUpdate, System.currentTimeMillis()) >= 5000) { + if (mHasUpdatedRecently) { + mHasUpdatedRecently = false; + this.markForUpdate(); + } + } + + if (Utils.getMillisSince(mStartTime, System.currentTimeMillis()) % 50 == 0) {} + + super.updateEntity(); + } + + public final void markForUpdate() { + mRequiresUpdate = true; + } + + public final boolean hasUpdatedRecently() { + return mHasUpdatedRecently; + } + + @Override + public int getBlockMetadata() { + return super.getBlockMetadata(); + } + + @Override + public void markDirty() { + super.markDirty(); + } + + @Override + public boolean canUpdate() { + return true; + } + + public void setRedstoneState(boolean aRedstoneActive) {} + + public void setCurrentTextureArray(IIcon[] aTextures) {} + /** * Used to see if one of the blocks next to you or your block is getting power from a neighboring block. Used by * items like TNT or Doors so they don't have redstone going straight into them. Args: x, y, z */ - public boolean isGettingIndirectlyPowered() { - if (mTilePos == null) { - return false; - } - return mTilePos.world.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord); - } - - public int getStrongestIndirectPower() { - if (mTilePos == null) { - return 0; - } - return mTilePos.world.getStrongestIndirectPower(xCoord, yCoord, zCoord); - } - + public boolean isGettingIndirectlyPowered() { + if (mTilePos == null) { + return false; + } + return mTilePos.world.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord); + } + + public int getStrongestIndirectPower() { + if (mTilePos == null) { + return 0; + } + return mTilePos.world.getStrongestIndirectPower(xCoord, yCoord, zCoord); + } + /** * Gets the power level from a certain block face. Args: x, y, z, direction */ - public int getIndirectPowerForSide(int aSide) { - if (mTilePos == null || aSide <0 || aSide > 5) { - return 0; - } - return mTilePos.world.getIndirectPowerLevelTo(xCoord, yCoord, zCoord, aSide); - } - - /** + public int getIndirectPowerForSide(int aSide) { + if (mTilePos == null || aSide < 0 || aSide > 5) { + return 0; + } + return mTilePos.world.getIndirectPowerLevelTo(xCoord, yCoord, zCoord, aSide); + } + + /** * Returns the highest redstone signal strength powering the given block. Args: X, Y, Z. */ - public int getBlockPowerInput() { - if (mTilePos == null) { - return 0; - } - return mTilePos.world.getBlockPowerInput(xCoord, yCoord, zCoord); - } - + public int getBlockPowerInput() { + if (mTilePos == null) { + return 0; + } + return mTilePos.world.getBlockPowerInput(xCoord, yCoord, zCoord); + } + /** * Determine if this block can make a redstone connection on the side provided, * Useful to control which sides are inputs and outputs for redstone wires. @@ -227,12 +219,12 @@ public abstract class TileEntityRedstoneHandler extends TileEntity implements IT * @param side The side that is trying to make the connection * @return True to make the connection */ - public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) { - if (mTilePos == null) { - return false; - } - return canAcceptRedstoneSignal() || canSupplyRedstoneSignal(); - } + public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) { + if (mTilePos == null) { + return false; + } + return canAcceptRedstoneSignal() || canSupplyRedstoneSignal(); + } /** * Called to determine whether to allow the a block to handle its own indirect power rather than using the default rules. @@ -243,12 +235,12 @@ public abstract class TileEntityRedstoneHandler extends TileEntity implements IT * @param side The INPUT side of the block to be powered - ie the opposite of this block's output side * @return Whether Block#isProvidingWeakPower should be called when determining indirect power */ - public boolean shouldCheckWeakPower(IBlockAccess world, int x, int y, int z, int side) { - if (mTilePos == null) { - return false; - } + public boolean shouldCheckWeakPower(IBlockAccess world, int x, int y, int z, int side) { + if (mTilePos == null) { + return false; + } return getBlock().isNormalCube(); - } + } /** * If this block should be notified of weak changes. @@ -262,207 +254,181 @@ public abstract class TileEntityRedstoneHandler extends TileEntity implements IT * @param side The side to check * @return true To be notified of changes */ - public boolean getWeakChanges(IBlockAccess world, int x, int y, int z) { - if (mTilePos == null) { - return false; - } - return false; - } - - - /** - * Override this to change the level of redstone output. - * @return - */ - public int getRedstoneLevel() { - if (mTilePos == null || mRedstoneLevel == null) { - return 0; - } - else { - if (canSupplyRedstoneSignal()) { - if (this.hasUpdatedRecently()) { - int aInputPower = getInputPowerLevel(); - mRedstoneLevel = (byte) ((aInputPower >= 0 && aInputPower <= 127) ? aInputPower : 0); - } - return mRedstoneLevel; - } - } - return 0; - } - - - public boolean providesWeakPower() { - return isProvidingPower(); - } - - public boolean providesStrongPower() { - return isProvidingPower(); - } - - - /** - * Returns the amount of week power this block is providing to a side. - * @param world - * @param x - * @param y - * @param z - * @param side - * @return - */ - public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { - if (!providesWeakPower()) { - return 0; - } - return getOutputPowerLevel(); - } - /** - * Returns the amount of strong power this block is providing to a side. - * @param world - * @param x - * @param y - * @param z - * @param side - * @return - */ - public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side) { - if (!providesStrongPower()) { - return 0; - } - return getOutputPowerLevel(); - } - - - - - - - - /* - * Alk's Simplified Redstone Handling functions (Fuck redstone) - */ - - /** - * - * @return - Does this Block supply redstone signal at all? - */ - public final boolean isPowered() { - return canAcceptRedstoneSignal() && getInputPowerLevel() > 0; - } - - /** - * - * @return - Can this Block provide redstone signal at all? - */ - public final boolean isProvidingPower() { - return canSupplyRedstoneSignal() && getOutputPowerLevel() > 0; - } - - /** - * - * @return - (0-15) Redstone Output signal level - */ - public final int getOutputPowerLevel() { - return getRedstoneLevel(); - } - - /** - * - * @return (0-15) Redstone Input Signal level - */ - public final int getInputPowerLevel() { - return getBlockPowerInput(); - } - - /** - * - * @return - Does this Tile Entity support outputting redstone? - */ - public final boolean canSupplyRedstoneSignal() { - return mTileType == 1 || mTileType == 2; - } - - /** - * - * @return - Does this Tile Entity support inputting redstone? - */ - public final boolean canAcceptRedstoneSignal() { - return mTileType == 0 || mTileType == 2; - } - - - @Override - public boolean isScrewdriverable() { - return false; - } - - - @Override - public boolean onScrewdriverLMB() { - return false; - } - - - @Override - public boolean onScrewdriverRMB() { - return false; - } - - - @Override - public boolean isWrenchable() { - return false; - } - - - @Override - public boolean onWrenchLMB() { - return false; - } - - - @Override - public boolean onWrenchRMB() { - return false; - } - - - @Override - public boolean isMalletable() { - return false; - } - - - @Override - public boolean onMalletLMB() { - return false; - } - - - @Override - public boolean onMalletRMB() { - return false; - } - - - public void setCustomName(String displayName) { - this.mInvName = displayName; - } - - public String getCustomName() { - return this.mInvName; - } - - public String getInventoryName() { - return this.hasCustomInventoryName() ? this.mInvName : "container.redstone.generic"; - } - - public boolean hasCustomInventoryName() { - return (this.mInvName != null) && !this.mInvName.equals(""); - } - - - - - - + public boolean getWeakChanges(IBlockAccess world, int x, int y, int z) { + if (mTilePos == null) { + return false; + } + return false; + } + + /** + * Override this to change the level of redstone output. + * @return + */ + public int getRedstoneLevel() { + if (mTilePos == null || mRedstoneLevel == null) { + return 0; + } else { + if (canSupplyRedstoneSignal()) { + if (this.hasUpdatedRecently()) { + int aInputPower = getInputPowerLevel(); + mRedstoneLevel = (byte) ((aInputPower >= 0 && aInputPower <= 127) ? aInputPower : 0); + } + return mRedstoneLevel; + } + } + return 0; + } + + public boolean providesWeakPower() { + return isProvidingPower(); + } + + public boolean providesStrongPower() { + return isProvidingPower(); + } + + /** + * Returns the amount of week power this block is providing to a side. + * @param world + * @param x + * @param y + * @param z + * @param side + * @return + */ + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { + if (!providesWeakPower()) { + return 0; + } + return getOutputPowerLevel(); + } + /** + * Returns the amount of strong power this block is providing to a side. + * @param world + * @param x + * @param y + * @param z + * @param side + * @return + */ + public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side) { + if (!providesStrongPower()) { + return 0; + } + return getOutputPowerLevel(); + } + + /* + * Alk's Simplified Redstone Handling functions (Fuck redstone) + */ + + /** + * + * @return - Does this Block supply redstone signal at all? + */ + public final boolean isPowered() { + return canAcceptRedstoneSignal() && getInputPowerLevel() > 0; + } + + /** + * + * @return - Can this Block provide redstone signal at all? + */ + public final boolean isProvidingPower() { + return canSupplyRedstoneSignal() && getOutputPowerLevel() > 0; + } + + /** + * + * @return - (0-15) Redstone Output signal level + */ + public final int getOutputPowerLevel() { + return getRedstoneLevel(); + } + + /** + * + * @return (0-15) Redstone Input Signal level + */ + public final int getInputPowerLevel() { + return getBlockPowerInput(); + } + + /** + * + * @return - Does this Tile Entity support outputting redstone? + */ + public final boolean canSupplyRedstoneSignal() { + return mTileType == 1 || mTileType == 2; + } + + /** + * + * @return - Does this Tile Entity support inputting redstone? + */ + public final boolean canAcceptRedstoneSignal() { + return mTileType == 0 || mTileType == 2; + } + + @Override + public boolean isScrewdriverable() { + return false; + } + + @Override + public boolean onScrewdriverLMB() { + return false; + } + + @Override + public boolean onScrewdriverRMB() { + return false; + } + + @Override + public boolean isWrenchable() { + return false; + } + + @Override + public boolean onWrenchLMB() { + return false; + } + + @Override + public boolean onWrenchRMB() { + return false; + } + + @Override + public boolean isMalletable() { + return false; + } + + @Override + public boolean onMalletLMB() { + return false; + } + + @Override + public boolean onMalletRMB() { + return false; + } + + public void setCustomName(String displayName) { + this.mInvName = displayName; + } + + public String getCustomName() { + return this.mInvName; + } + + public String getInventoryName() { + return this.hasCustomInventoryName() ? this.mInvName : "container.redstone.generic"; + } + + public boolean hasCustomInventoryName() { + return (this.mInvName != null) && !this.mInvName.equals(""); + } } diff --git a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java index 6bb4c932dc..258e0e88e6 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java +++ b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java @@ -19,137 +19,118 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; public class TileEntityAdvPooCollector extends TileEntityBaseFluidCollector { - - public TileEntityAdvPooCollector() { - super(18, 128000); - } + public TileEntityAdvPooCollector() { + super(18, 128000); + } - @Override - public boolean canFill(ForgeDirection from, Fluid fluid) { - return false; - } + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return false; + } - @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) { - return true; - } - - public void onPreLogicTick() { - - } - - public boolean addDrop(V aPooMaker) { - int aChance = MathUtils.randInt(0, 50000); - if (aChance > 0) { - ItemStack aPoop; - if (aChance<= 200) { - aPoop = ItemUtils.getItemStackOfAmountFromOreDict("dustManureByproducts", 1); - } - else if (aChance <= 1000) { - aPoop = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallManureByproducts", 1); - } - else if (aChance <= 2000) { - aPoop = ItemUtils.getItemStackOfAmountFromOreDict("dustTinyManureByproducts", 1); - } - else { - return false; - } - - //Add to inventory if not full, else espawn in world - if (!this.mInventory.addItemStack(aPoop)) { - EntityItem entity = new EntityItem(worldObj, xCoord, yCoord+1.5, zCoord, aPoop); - worldObj.spawnEntityInWorld(entity); - } - - } - - - return false; - } + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return true; + } - private static AutoMap aEntityToDrain = new AutoMap(); - - @Override - public AutoMap aThingsToLookFor() { - if (aEntityToDrain.isEmpty()) { - aEntityToDrain.add(EntityAnimal.class); - aEntityToDrain.add(IAnimals.class); - aEntityToDrain.add(EntityVillager.class); - aEntityToDrain.add(EntityPlayer.class); - } - return aEntityToDrain; - } + public void onPreLogicTick() {} - @Override - public int onPostTick(V aPooMaker) { - if (this.tank.getFluidAmount() < this.tank.getCapacity()) { - int aPooAmount = 0; - // Vanilla Animals - if (aPooMaker instanceof EntityChicken) { - aPooAmount = MathUtils.randInt(1, 40); - } - else if (aPooMaker instanceof EntityHorse) { - aPooAmount = MathUtils.randInt(20, 40); - } - else if (aPooMaker instanceof EntityCow) { - aPooAmount = MathUtils.randInt(18, 45); - } - else if (aPooMaker instanceof EntityMooshroom) { - aPooAmount = 17; - } - else if (aPooMaker instanceof EntitySheep) { - aPooAmount = MathUtils.randInt(8, 30); - } - - else { - if (aPooMaker instanceof EntityAnimal || aPooMaker instanceof IAnimals) { - aPooAmount = MathUtils.randInt(5, 35); - } - else if (aPooMaker instanceof EntityVillager) { - aPooAmount = MathUtils.randInt(25, 30); - } - else if (aPooMaker instanceof EntityPlayer) { - aPooAmount = MathUtils.randInt(1, 3); - } - else { - aPooAmount = MathUtils.randInt(1, 10); - } - } - aPooAmount = Math.max(Math.min(this.tank.getCapacity()-this.tank.getFluidAmount(), aPooAmount), 1); - return Math.max(1, (aPooAmount * MathUtils.getRandomFromArray(new int[] {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 4}) / 10)); - } - else { - return 0; - } - } + public boolean addDrop(V aPooMaker) { + int aChance = MathUtils.randInt(0, 50000); + if (aChance > 0) { + ItemStack aPoop; + if (aChance <= 200) { + aPoop = ItemUtils.getItemStackOfAmountFromOreDict("dustManureByproducts", 1); + } else if (aChance <= 1000) { + aPoop = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallManureByproducts", 1); + } else if (aChance <= 2000) { + aPoop = ItemUtils.getItemStackOfAmountFromOreDict("dustTinyManureByproducts", 1); + } else { + return false; + } - @Override - public Fluid fluidToProvide() { - return AgriculturalChem.PoopJuice; - } + // Add to inventory if not full, else espawn in world + if (!this.mInventory.addItemStack(aPoop)) { + EntityItem entity = new EntityItem(worldObj, xCoord, yCoord + 1.5, zCoord, aPoop); + worldObj.spawnEntityInWorld(entity); + } + } - @Override - public ItemStack itemToSpawnInWorldIfTankIsFull() { - int a = MathUtils.randInt(0, 75); - ItemStack aItem = null; - if (a <= 30) { - aItem = ItemUtils.getSimpleStack(AgriculturalChem.dustDirt); - } - else if (a <= 40) { - aItem = ItemUtils.getItemStackOfAmountFromOreDict("dustManureByproducts", 1); - } - else if (a <= 55) { - aItem = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallManureByproducts", 1); - } - return aItem; - } - - public int getBaseTickRate() { - return MathUtils.randInt(50, 200); - } - - - + return false; + } + private static AutoMap aEntityToDrain = new AutoMap(); + + @Override + public AutoMap aThingsToLookFor() { + if (aEntityToDrain.isEmpty()) { + aEntityToDrain.add(EntityAnimal.class); + aEntityToDrain.add(IAnimals.class); + aEntityToDrain.add(EntityVillager.class); + aEntityToDrain.add(EntityPlayer.class); + } + return aEntityToDrain; + } + + @Override + public int onPostTick(V aPooMaker) { + if (this.tank.getFluidAmount() < this.tank.getCapacity()) { + int aPooAmount = 0; + // Vanilla Animals + if (aPooMaker instanceof EntityChicken) { + aPooAmount = MathUtils.randInt(1, 40); + } else if (aPooMaker instanceof EntityHorse) { + aPooAmount = MathUtils.randInt(20, 40); + } else if (aPooMaker instanceof EntityCow) { + aPooAmount = MathUtils.randInt(18, 45); + } else if (aPooMaker instanceof EntityMooshroom) { + aPooAmount = 17; + } else if (aPooMaker instanceof EntitySheep) { + aPooAmount = MathUtils.randInt(8, 30); + } else { + if (aPooMaker instanceof EntityAnimal || aPooMaker instanceof IAnimals) { + aPooAmount = MathUtils.randInt(5, 35); + } else if (aPooMaker instanceof EntityVillager) { + aPooAmount = MathUtils.randInt(25, 30); + } else if (aPooMaker instanceof EntityPlayer) { + aPooAmount = MathUtils.randInt(1, 3); + } else { + aPooAmount = MathUtils.randInt(1, 10); + } + } + aPooAmount = Math.max(Math.min(this.tank.getCapacity() - this.tank.getFluidAmount(), aPooAmount), 1); + return Math.max( + 1, + (aPooAmount + * MathUtils.getRandomFromArray( + new int[] {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 4}) + / 10)); + } else { + return 0; + } + } + + @Override + public Fluid fluidToProvide() { + return AgriculturalChem.PoopJuice; + } + + @Override + public ItemStack itemToSpawnInWorldIfTankIsFull() { + int a = MathUtils.randInt(0, 75); + ItemStack aItem = null; + if (a <= 30) { + aItem = ItemUtils.getSimpleStack(AgriculturalChem.dustDirt); + } else if (a <= 40) { + aItem = ItemUtils.getItemStackOfAmountFromOreDict("dustManureByproducts", 1); + } else if (a <= 55) { + aItem = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallManureByproducts", 1); + } + return aItem; + } + + public int getBaseTickRate() { + return MathUtils.randInt(50, 200); + } } diff --git a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java index cdae4cf829..b7985b5b7f 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java +++ b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java @@ -1,7 +1,5 @@ package gtPlusPlus.core.tileentities.machines; -import java.util.List; - import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.BTF_FluidTank; import gtPlusPlus.api.objects.minecraft.BlockPos; @@ -9,6 +7,7 @@ import gtPlusPlus.core.tileentities.base.TileEntityBase; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import java.util.List; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -28,211 +27,205 @@ import net.minecraftforge.fluids.IFluidHandler; public abstract class TileEntityBaseFluidCollector extends TileEntityBase implements IFluidHandler { - public final FluidTank tank; - private boolean needsUpdate = false; - private int updateTimer = 0; - private long internalTickCounter = 0; - private BlockPos internalBlockLocation; - - public TileEntityBaseFluidCollector(int aInvSlotCount, int aTankCapcity) { - super(aInvSlotCount); - tank = new BTF_FluidTank(aTankCapcity); - } - - @Override - public final int fill(ForgeDirection from, FluidStack resource, boolean doFill) { - needsUpdate = true; - return this.tank.fill(resource, doFill); - } - - @Override - public final FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { - needsUpdate = true; - return this.tank.drain(resource.amount, doDrain); - } - - @Override - public final FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { - needsUpdate = true; - FluidStack fluid = this.tank.getFluid(); - // return this.tank.drain(maxDrain, doDrain); - if (fluid == null) { - return null; - } - - int drained = maxDrain; - if (fluid.amount < drained) { - drained = fluid.amount; - } - - FluidStack stack = new FluidStack(fluid, drained); - if (doDrain) { - fluid.amount -= drained; - if (fluid.amount <= 0) { - fluid = null; - } - - if (this != null) { - FluidEvent.fireEvent(new FluidEvent.FluidDrainingEvent(fluid, this.getWorldObj(), this.xCoord, - this.yCoord, this.zCoord, this.tank, 0)); - } - } - return stack; - } - - @Override - public boolean canFill(ForgeDirection from, Fluid fluid) { - return false; - } - - @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) { - return true; - } - - @Override - public final FluidTankInfo[] getTankInfo(ForgeDirection from) { - return new FluidTankInfo[] { this.tank.getInfo() }; - } - - @Override - public final void updateEntity() { - super.updateEntity(); - onPreLogicTick(); - logicTick(); - if (needsUpdate) { - if (updateTimer == 0) { - updateTimer = 10; // every 10 ticks it will send an update - } else { - --updateTimer; - if (updateTimer == 0) { - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - needsUpdate = false; - } - } - } - } - - @Override - public void readFromNBT(NBTTagCompound tag) { - tank.readFromNBT(tag); - super.readFromNBT(tag); - } - - @Override - public void writeToNBT(NBTTagCompound tag) { - tank.writeToNBT(tag); - super.writeToNBT(tag); - } - - @Override - public final Packet getDescriptionPacket() { - NBTTagCompound tag = new NBTTagCompound(); - writeToNBT(tag); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, this.blockMetadata, tag); - } - - @Override - public final void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - NBTTagCompound tag = pkt.func_148857_g(); - readFromNBT(tag); - } - - public int getBaseTickRate() { - return MathUtils.randInt(200, 300); - } - - public abstract AutoMap aThingsToLookFor(); - - public abstract void onPreLogicTick(); - - public final void logicTick() { - - if (this.worldObj == null || this.worldObj.isRemote) { - return; - } - if (internalTickCounter % getBaseTickRate() == 0) { - if (internalBlockLocation == null) { - internalBlockLocation = new BlockPos(this); - } - BlockPos p = internalBlockLocation; - if (p != null) { - if (p.world != null) { - World w = this.worldObj; - if (w == null) { - return; - } - Chunk c = w.getChunkFromBlockCoords(p.xPos, p.zPos); - if (c != null) { - if (c.isChunkLoaded) { - int startX = p.xPos - 2; - int startY = p.yPos; - int startZ = p.zPos - 2; - int endX = p.xPos + 3; - int endY = p.yPos + 5; - int endZ = p.zPos + 3; - AxisAlignedBB box = AxisAlignedBB.getBoundingBox(startX, startY, startZ, endX, endY, endZ); - if (box != null) { - for (Class c2 : aThingsToLookFor()) { - tickEntityType(w, box, c2); - } - } else { - return; - } - } - } - } - } - - } - - internalTickCounter++; - } - - @SuppressWarnings("unchecked") - public final void tickEntityType(World w, AxisAlignedBB box, Class aClassToFind) { - List entities = w.getEntitiesWithinAABB(aClassToFind, box); - if (entities != null && !entities.isEmpty()) { - interactWithEntities(entities); - } - } - - public final void interactWithEntities(List entities) { - for (V aEntity : entities) { - addDrop(aEntity); - if (this.tank.getFluidAmount() < this.tank.getCapacity()) { - int aFluidAmount = onPostTick(aEntity); - aFluidAmount = Math.max(Math.min(this.tank.getCapacity()-this.tank.getFluidAmount(), aFluidAmount), 1); - this.tank.fill(FluidUtils.getFluidStack(fluidToProvide(), aFluidAmount), true); - } - else { - ItemStack aDirtStack = ItemUtils.getSimpleStack(itemToSpawnInWorldIfTankIsFull(), 1); - if (!ItemUtils.checkForInvalidItems(aDirtStack)) { - return; - } - if (!this.mInventory.addItemStack(aDirtStack)) { - EntityItem entity = new EntityItem(worldObj, xCoord, yCoord+1.5, zCoord, aDirtStack); - worldObj.spawnEntityInWorld(entity); - } - } - } - } - - - /** - * Return the amount of fluid for this entity type - * @param aEntity - * @return - */ - public abstract int onPostTick(V aEntity); - - public abstract boolean addDrop(V aPooMaker); - - public abstract Fluid fluidToProvide(); - - public abstract ItemStack itemToSpawnInWorldIfTankIsFull(); - - - - + public final FluidTank tank; + private boolean needsUpdate = false; + private int updateTimer = 0; + private long internalTickCounter = 0; + private BlockPos internalBlockLocation; + + public TileEntityBaseFluidCollector(int aInvSlotCount, int aTankCapcity) { + super(aInvSlotCount); + tank = new BTF_FluidTank(aTankCapcity); + } + + @Override + public final int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + needsUpdate = true; + return this.tank.fill(resource, doFill); + } + + @Override + public final FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + needsUpdate = true; + return this.tank.drain(resource.amount, doDrain); + } + + @Override + public final FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + needsUpdate = true; + FluidStack fluid = this.tank.getFluid(); + // return this.tank.drain(maxDrain, doDrain); + if (fluid == null) { + return null; + } + + int drained = maxDrain; + if (fluid.amount < drained) { + drained = fluid.amount; + } + + FluidStack stack = new FluidStack(fluid, drained); + if (doDrain) { + fluid.amount -= drained; + if (fluid.amount <= 0) { + fluid = null; + } + + if (this != null) { + FluidEvent.fireEvent(new FluidEvent.FluidDrainingEvent( + fluid, this.getWorldObj(), this.xCoord, this.yCoord, this.zCoord, this.tank, 0)); + } + } + return stack; + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return false; + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return true; + } + + @Override + public final FluidTankInfo[] getTankInfo(ForgeDirection from) { + return new FluidTankInfo[] {this.tank.getInfo()}; + } + + @Override + public final void updateEntity() { + super.updateEntity(); + onPreLogicTick(); + logicTick(); + if (needsUpdate) { + if (updateTimer == 0) { + updateTimer = 10; // every 10 ticks it will send an update + } else { + --updateTimer; + if (updateTimer == 0) { + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + needsUpdate = false; + } + } + } + } + + @Override + public void readFromNBT(NBTTagCompound tag) { + tank.readFromNBT(tag); + super.readFromNBT(tag); + } + + @Override + public void writeToNBT(NBTTagCompound tag) { + tank.writeToNBT(tag); + super.writeToNBT(tag); + } + + @Override + public final Packet getDescriptionPacket() { + NBTTagCompound tag = new NBTTagCompound(); + writeToNBT(tag); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, this.blockMetadata, tag); + } + + @Override + public final void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + NBTTagCompound tag = pkt.func_148857_g(); + readFromNBT(tag); + } + + public int getBaseTickRate() { + return MathUtils.randInt(200, 300); + } + + public abstract AutoMap aThingsToLookFor(); + + public abstract void onPreLogicTick(); + + public final void logicTick() { + + if (this.worldObj == null || this.worldObj.isRemote) { + return; + } + if (internalTickCounter % getBaseTickRate() == 0) { + if (internalBlockLocation == null) { + internalBlockLocation = new BlockPos(this); + } + BlockPos p = internalBlockLocation; + if (p != null) { + if (p.world != null) { + World w = this.worldObj; + if (w == null) { + return; + } + Chunk c = w.getChunkFromBlockCoords(p.xPos, p.zPos); + if (c != null) { + if (c.isChunkLoaded) { + int startX = p.xPos - 2; + int startY = p.yPos; + int startZ = p.zPos - 2; + int endX = p.xPos + 3; + int endY = p.yPos + 5; + int endZ = p.zPos + 3; + AxisAlignedBB box = AxisAlignedBB.getBoundingBox(startX, startY, startZ, endX, endY, endZ); + if (box != null) { + for (Class c2 : aThingsToLookFor()) { + tickEntityType(w, box, c2); + } + } else { + return; + } + } + } + } + } + } + + internalTickCounter++; + } + + @SuppressWarnings("unchecked") + public final void tickEntityType(World w, AxisAlignedBB box, Class aClassToFind) { + List entities = w.getEntitiesWithinAABB(aClassToFind, box); + if (entities != null && !entities.isEmpty()) { + interactWithEntities(entities); + } + } + + public final void interactWithEntities(List entities) { + for (V aEntity : entities) { + addDrop(aEntity); + if (this.tank.getFluidAmount() < this.tank.getCapacity()) { + int aFluidAmount = onPostTick(aEntity); + aFluidAmount = + Math.max(Math.min(this.tank.getCapacity() - this.tank.getFluidAmount(), aFluidAmount), 1); + this.tank.fill(FluidUtils.getFluidStack(fluidToProvide(), aFluidAmount), true); + } else { + ItemStack aDirtStack = ItemUtils.getSimpleStack(itemToSpawnInWorldIfTankIsFull(), 1); + if (!ItemUtils.checkForInvalidItems(aDirtStack)) { + return; + } + if (!this.mInventory.addItemStack(aDirtStack)) { + EntityItem entity = new EntityItem(worldObj, xCoord, yCoord + 1.5, zCoord, aDirtStack); + worldObj.spawnEntityInWorld(entity); + } + } + } + } + + /** + * Return the amount of fluid for this entity type + * @param aEntity + * @return + */ + public abstract int onPostTick(V aEntity); + + public abstract boolean addDrop(V aPooMaker); + + public abstract Fluid fluidToProvide(); + + public abstract ItemStack itemToSpawnInWorldIfTankIsFull(); } diff --git a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityModularityTable.java b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityModularityTable.java index 8ba43bb197..0e8000ebb3 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityModularityTable.java +++ b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityModularityTable.java @@ -1,18 +1,6 @@ package gtPlusPlus.core.tileentities.machines; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - import gregtech.api.enums.ItemList; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.container.Container_ModularityTable; @@ -24,457 +12,461 @@ import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.ModularArmourUtils; import gtPlusPlus.core.util.minecraft.ModularArmourUtils.BT; import gtPlusPlus.core.util.minecraft.ModularArmourUtils.Modifiers; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; -public class TileEntityModularityTable extends TileEntityBase implements ISidedInventory{ - - public InventoryModularMain inventoryGrid; - public InventoryModularOutput inventoryOutputs; - public InventoryModularOutput mTempRecipeStorage; - private Container_ModularityTable container; - private String customName; - private int mRecipeTimeRemaining = -1; - - public TileEntityModularityTable() { - super(16); - this.inventoryGrid = new InventoryModularMain(); - this.inventoryOutputs = new InventoryModularOutput(); - this.mTempRecipeStorage = new InventoryModularOutput(); - this.canUpdate(); - generateAllValidUpgrades(); - } - - public void setContainer(Container_ModularityTable container_ModularityTable) { - this.container = container_ModularityTable; - } - - public Container_ModularityTable getContainer() { - return this.container; - } - - public int getRecipeTime(){ - return this.mRecipeTimeRemaining; - } - - @Override - public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) { - if (!nbt.hasKey(tag)) { - nbt.setTag(tag, new NBTTagCompound()); - } - return nbt.getCompoundTag(tag); - } - - @Override - public void writeToNBT(final NBTTagCompound nbt) { - super.writeToNBT(nbt); - nbt.setInteger("mRecipeTime", this.mRecipeTimeRemaining); - this.inventoryOutputs.writeToNBT(this.getTag(nbt, "ContentsOutput")); - this.inventoryGrid.writeToNBT(this.getTag(nbt, "ContentsGrid")); - this.mTempRecipeStorage.writeToNBT(this.getTag(nbt, "ContentsRecipeTemp")); - if (this.hasCustomInventoryName()) { - nbt.setString("CustomName", this.getCustomName()); - } - } - - @Override - public void readFromNBT(final NBTTagCompound nbt) { - super.readFromNBT(nbt); - this.mRecipeTimeRemaining = nbt.getInteger("mRecipeTime"); - this.inventoryOutputs.readFromNBT(nbt.getCompoundTag("ContentsOutput")); - this.inventoryGrid.readFromNBT(nbt.getCompoundTag("ContentsGrid")); - this.mTempRecipeStorage.readFromNBT(nbt.getCompoundTag("ContentsRecipeTemp")); - if (nbt.hasKey("CustomName", 8)) { - this.setCustomName(nbt.getString("CustomName")); - } - } - - protected ItemStack mOutputStack; //Upgraded Bauble - protected ItemStack mInputstackA; //Bauble - protected ItemStack mInputstackB; //Upgrade - - public ItemStack getPendingOutputItem(){ - this.mRecipeTimeRemaining--; - return this.mOutputStack; - } - - public ItemStack[] getCurrentInputItems(){ - if (this.mRecipeTimeRemaining < 0){ - return null; - } - else { - return new ItemStack[]{this.mInputstackA, this.mInputstackB}; - } - } - - public boolean setInputStacks(ItemStack tBauble, ItemStack tUpgrade){ - if (tBauble != null){ - this.mInputstackA = tBauble; - } - else { - this.mInputstackA = null; - } - if (tUpgrade != null){ - this.mInputstackB = tBauble; - } - else { - this.mInputstackB = null; - } - if (this.mInputstackA != null && this.mInputstackB != null){ - return true; - } - return false; - } - - public boolean setOutputStack(ItemStack mNewBauble){ - if (mNewBauble != null){ - this.mOutputStack = mNewBauble; - return true; - } - else { - this.mOutputStack = null; - return false; - } - } - - public boolean clearRecipeData(){ - this.mInputstackA = null; - this.mInputstackB = null; - this.mOutputStack = null; - return true; - } - - @Override - public boolean canUpdate() { - return true; - } - - public static Map> mValidUpgradeList = new HashMap>(); - public static Map mValidUpgradeListFormChange = new HashMap(); - - private static boolean generateAllValidUpgrades() { - - // Form Change - generateUpgradeFormData(ItemList.Sensor_MV.get(1), BT.TYPE_RING); - generateUpgradeFormData(ItemList.Electric_Piston_MV.get(1), BT.TYPE_BELT); - generateUpgradeFormData(ItemList.Emitter_MV.get(1), BT.TYPE_AMULET); - - // Damage Boost - generateUpgradeData(ItemList.Electric_Motor_LV.get(1), Modifiers.BOOST_DAMAGE, 1); - generateUpgradeData(ItemList.Electric_Motor_MV.get(1), Modifiers.BOOST_DAMAGE, 2); - generateUpgradeData(ItemList.Electric_Motor_HV.get(1), Modifiers.BOOST_DAMAGE, 3); - generateUpgradeData(ItemList.Electric_Motor_EV.get(1), Modifiers.BOOST_DAMAGE, 4); - generateUpgradeData(ItemList.Electric_Motor_IV.get(1), Modifiers.BOOST_DAMAGE, 5); - - // Defence Boost - generateUpgradeData(ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateAluminium", 1), Modifiers.BOOST_DEF, 1); - generateUpgradeData(ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateStainlessSteel", 1), Modifiers.BOOST_DEF, 2); - generateUpgradeData(ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateTungsten", 1), Modifiers.BOOST_DEF, 3); - generateUpgradeData(ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateTungstenSteel", 1), Modifiers.BOOST_DEF, 4); - generateUpgradeData(ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateNaquadah", 1), Modifiers.BOOST_DEF, 5); - - // Hp Boost - generateUpgradeData(ItemUtils.simpleMetaStack(Items.golden_apple, 0, 1), Modifiers.BOOST_HP, 1); - generateUpgradeData(ItemUtils.simpleMetaStack(Items.golden_apple, 1, 1), Modifiers.BOOST_HP, 2); - generateUpgradeData(ItemUtils.simpleMetaStack(Items.nether_star, 0, 1), Modifiers.BOOST_HP, 3); - generateUpgradeData(ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32725", 32725, 1), Modifiers.BOOST_HP, - 4); - generateUpgradeData(ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32726", 32726, 1), Modifiers.BOOST_HP, - 5); - - return true; - } - - public static boolean generateUpgradeData(ItemStack tStack, Modifiers tMod, int tLevel) { - Pair tTemp = new Pair(tMod, tLevel); - if (mValidUpgradeList.put(tStack, tTemp) != null) { - return true; - } - return false; - } - - public static boolean generateUpgradeFormData(ItemStack tStack, BT tMod) { - if (mValidUpgradeListFormChange.put(tStack, tMod) != null) { - return true; - } - return false; - } - - public static boolean addUpgrade(ItemStack tStack, ItemStack tBauble) { - - try { - Iterator> it = mValidUpgradeListFormChange.entrySet().iterator(); - while (it.hasNext()) { - Entry pair = it.next(); - if (pair.getKey().getItem() == tStack.getItem() - && pair.getKey().getItemDamage() == tStack.getItemDamage()) { - ModularArmourUtils.setBaubleType(tBauble, pair.getValue()); - tBauble.setItemDamage(ModularArmourUtils.getBaubleTypeID(tBauble)); - return true; - } - } - } catch (Throwable t) { - - } - try { - Iterator>> it2 = mValidUpgradeList.entrySet().iterator(); - while (it2.hasNext()) { - Entry> pair = it2.next(); - if (pair.getKey().getItem() == tStack.getItem() - && pair.getKey().getItemDamage() == tStack.getItemDamage()) { - Pair newPair = pair.getValue(); - ModularArmourUtils.setModifierLevel(tBauble, newPair); - return true; - } - } - } catch (Throwable t) { - - } - return false; - } - - @Override - public int getSizeInventory() { - return 11; - } - - @Override - public ItemStack getStackInSlot(int slot) { - if (slot >= this.inventoryGrid.getSizeInventory()){ - return this.inventoryOutputs.getStackInSlot(slot-9); - } - else if (slot < this.inventoryGrid.getSizeInventory()){ - return this.inventoryGrid.getStackInSlot(slot); - } - else { - return null; - } - } - - @Override - public ItemStack decrStackSize(int slot, int count) { - if (slot < this.inventoryGrid.getSizeInventory()){ - return this.inventoryGrid.decrStackSize(slot, count); - } - else if (slot >= this.inventoryGrid.getSizeInventory()){ - return this.inventoryOutputs.decrStackSize(slot-9, count); - } - else { - return null; - } - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return this.getStackInSlot(slot); - } - - @Override - public void setInventorySlotContents(int slot, ItemStack stack) { - if (slot >= this.inventoryGrid.getSizeInventory()){ - this.inventoryOutputs.setInventorySlotContents(slot-9, stack); - } - else if (slot < this.inventoryGrid.getSizeInventory()){ - this.inventoryGrid.setInventorySlotContents(slot, stack); - } - } - - @Override - public int getInventoryStackLimit() { - return 64; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) { - return true; - } - - @Override - public void openInventory() { - this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); - this.inventoryGrid.openInventory(); - this.inventoryOutputs.openInventory(); - } - - @Override - public void closeInventory() { - this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); - this.inventoryGrid.openInventory(); - this.inventoryOutputs.openInventory(); - } - - @Override - public boolean isItemValidForSlot(int slot, ItemStack itemstack) { - if (slot >= this.inventoryGrid.getSizeInventory()){ - return this.inventoryOutputs.isItemValidForSlot(slot-9, itemstack); - } - else if (slot < this.inventoryGrid.getSizeInventory()){ - return this.inventoryGrid.isItemValidForSlot(slot, itemstack); - } - else { - return false; - } - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) { - int[] accessibleSides = new int[this.getSizeInventory()]; - for (int r=0; r= 9){ - return this.inventoryOutputs.isItemValidForSlot(slot-9, item); - } - else { - return this.inventoryGrid.isItemValidForSlot(slot, item); - } - } - - @Override - public boolean canExtractItem(int slot, ItemStack item, int side) { - Logger.INFO("Slot:"+slot+" | side? "+side); - if (slot == 11 || slot <= 8){ - return true; - } - return false; - } - - @Override - public String getCustomName() { - return this.customName; - } - - @Override - public void setCustomName(String customName) { - this.customName = customName; - } - - @Override - public String getInventoryName() { - return this.hasCustomInventoryName() ? this.customName : "container.fishtrap"; - } - - @Override - public boolean hasCustomInventoryName() { - return this.customName != null && !this.customName.equals(""); - } - - @Override - public boolean onPreTick(long aTick) { - //Check for active recipe - if (this.mRecipeTimeRemaining > -1 || (this.mTempRecipeStorage != null) && (this.mTempRecipeStorage.getRecipeTime() > -1)){ - if ((this.mTempRecipeStorage != null) && this.mTempRecipeStorage.getRecipeTime() > -1){ - if (this.mRecipeTimeRemaining < this.mTempRecipeStorage.getRecipeTime()){ - this.mRecipeTimeRemaining = this.mTempRecipeStorage.getRecipeTime(); - this.markDirty(); - } - } - if (this.mInputstackA != null && this.mInputstackB != null && this.mOutputStack != null){ - this.mTempRecipeStorage.setInventorySlotContents(0, this.mInputstackA); - this.mTempRecipeStorage.setInventorySlotContents(1, this.mInputstackB); - this.mTempRecipeStorage.setInventorySlotContents(2, this.mOutputStack); - this.mTempRecipeStorage.setRecipeTime(this.mRecipeTimeRemaining); - this.markDirty(); - } - } - return true; - } - - @Override - public boolean onPostTick(long aTick) { - if (mRecipeTimeRemaining == 0){ - this.inventoryOutputs.setInventorySlotContents(2, this.getPendingOutputItem()); - clearRecipeData(); - this.mTempRecipeStorage.setRecipeTime(this.mRecipeTimeRemaining); - this.markDirty(); - } - else if (mRecipeTimeRemaining > 0){ - mRecipeTimeRemaining--; - this.mTempRecipeStorage.setRecipeTime(this.mRecipeTimeRemaining); - } - return true; - } - - @Override - public boolean processRecipe() { - boolean removeInputA = false; - boolean removeInputB = false; - // Data stick - ItemStack tBauble = this.inventoryOutputs.getStackInSlot(0); - ItemStack tUpgrade = this.inventoryOutputs.getStackInSlot(1); - if (tBauble != null && tUpgrade != null && this.container != null) { - if (tBauble.getItem() instanceof ModularBauble && this.mRecipeTimeRemaining == -1) { - if (tUpgrade != null && tBauble != null) { - removeInputA = true; - this.setInputStacks(tBauble, tUpgrade); - try { - removeInputB = addUpgrade(tUpgrade, tBauble); - if (!removeInputB) { - } - } catch (Throwable t) { - } - if (removeInputA && removeInputB) { - if (this.setOutputStack(tBauble)){ - if (this.inventoryOutputs.getStackInSlot(1).stackSize > 1) { - ItemStack mTempStack = this.inventoryOutputs.getStackInSlot(1); - mTempStack.stackSize--; - this.inventoryOutputs.setInventorySlotContents(1, mTempStack); - } else { - this.inventoryOutputs.setInventorySlotContents(1, null); - } - this.inventoryOutputs.setInventorySlotContents(0, null); - this.mRecipeTimeRemaining = 80; - this.markDirty(); - return true; - } - } - } - } - } - return false; - } - - public static boolean isValidModularPiece(final ItemStack itemstack){ - if (itemstack.getItem() instanceof ModularBauble){ - return true; - } - return false; - } - - public static boolean isValidUpgrade(final ItemStack itemstack) { - boolean isValid = false; - if (itemstack != null){ - Iterator> it = mValidUpgradeListFormChange.entrySet().iterator(); - while (it.hasNext()) { - Entry pair = it.next(); - if (pair.getKey().getItem() == itemstack.getItem() - && pair.getKey().getItemDamage() == itemstack.getItemDamage()){ - isValid = true; - } - } - Iterator>> it2 = mValidUpgradeList.entrySet().iterator(); - while (it2.hasNext()) { - Entry> pair = it2.next(); - if (pair.getKey().getItem() == itemstack.getItem() - && pair.getKey().getItemDamage() == itemstack.getItemDamage()){ - isValid = true; - } - } - } - return isValid; - } - -} \ No newline at end of file +public class TileEntityModularityTable extends TileEntityBase implements ISidedInventory { + + public InventoryModularMain inventoryGrid; + public InventoryModularOutput inventoryOutputs; + public InventoryModularOutput mTempRecipeStorage; + private Container_ModularityTable container; + private String customName; + private int mRecipeTimeRemaining = -1; + + public TileEntityModularityTable() { + super(16); + this.inventoryGrid = new InventoryModularMain(); + this.inventoryOutputs = new InventoryModularOutput(); + this.mTempRecipeStorage = new InventoryModularOutput(); + this.canUpdate(); + generateAllValidUpgrades(); + } + + public void setContainer(Container_ModularityTable container_ModularityTable) { + this.container = container_ModularityTable; + } + + public Container_ModularityTable getContainer() { + return this.container; + } + + public int getRecipeTime() { + return this.mRecipeTimeRemaining; + } + + @Override + public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) { + if (!nbt.hasKey(tag)) { + nbt.setTag(tag, new NBTTagCompound()); + } + return nbt.getCompoundTag(tag); + } + + @Override + public void writeToNBT(final NBTTagCompound nbt) { + super.writeToNBT(nbt); + nbt.setInteger("mRecipeTime", this.mRecipeTimeRemaining); + this.inventoryOutputs.writeToNBT(this.getTag(nbt, "ContentsOutput")); + this.inventoryGrid.writeToNBT(this.getTag(nbt, "ContentsGrid")); + this.mTempRecipeStorage.writeToNBT(this.getTag(nbt, "ContentsRecipeTemp")); + if (this.hasCustomInventoryName()) { + nbt.setString("CustomName", this.getCustomName()); + } + } + + @Override + public void readFromNBT(final NBTTagCompound nbt) { + super.readFromNBT(nbt); + this.mRecipeTimeRemaining = nbt.getInteger("mRecipeTime"); + this.inventoryOutputs.readFromNBT(nbt.getCompoundTag("ContentsOutput")); + this.inventoryGrid.readFromNBT(nbt.getCompoundTag("ContentsGrid")); + this.mTempRecipeStorage.readFromNBT(nbt.getCompoundTag("ContentsRecipeTemp")); + if (nbt.hasKey("CustomName", 8)) { + this.setCustomName(nbt.getString("CustomName")); + } + } + + protected ItemStack mOutputStack; // Upgraded Bauble + protected ItemStack mInputstackA; // Bauble + protected ItemStack mInputstackB; // Upgrade + + public ItemStack getPendingOutputItem() { + this.mRecipeTimeRemaining--; + return this.mOutputStack; + } + + public ItemStack[] getCurrentInputItems() { + if (this.mRecipeTimeRemaining < 0) { + return null; + } else { + return new ItemStack[] {this.mInputstackA, this.mInputstackB}; + } + } + + public boolean setInputStacks(ItemStack tBauble, ItemStack tUpgrade) { + if (tBauble != null) { + this.mInputstackA = tBauble; + } else { + this.mInputstackA = null; + } + if (tUpgrade != null) { + this.mInputstackB = tBauble; + } else { + this.mInputstackB = null; + } + if (this.mInputstackA != null && this.mInputstackB != null) { + return true; + } + return false; + } + + public boolean setOutputStack(ItemStack mNewBauble) { + if (mNewBauble != null) { + this.mOutputStack = mNewBauble; + return true; + } else { + this.mOutputStack = null; + return false; + } + } + + public boolean clearRecipeData() { + this.mInputstackA = null; + this.mInputstackB = null; + this.mOutputStack = null; + return true; + } + + @Override + public boolean canUpdate() { + return true; + } + + public static Map> mValidUpgradeList = + new HashMap>(); + public static Map mValidUpgradeListFormChange = new HashMap(); + + private static boolean generateAllValidUpgrades() { + + // Form Change + generateUpgradeFormData(ItemList.Sensor_MV.get(1), BT.TYPE_RING); + generateUpgradeFormData(ItemList.Electric_Piston_MV.get(1), BT.TYPE_BELT); + generateUpgradeFormData(ItemList.Emitter_MV.get(1), BT.TYPE_AMULET); + + // Damage Boost + generateUpgradeData(ItemList.Electric_Motor_LV.get(1), Modifiers.BOOST_DAMAGE, 1); + generateUpgradeData(ItemList.Electric_Motor_MV.get(1), Modifiers.BOOST_DAMAGE, 2); + generateUpgradeData(ItemList.Electric_Motor_HV.get(1), Modifiers.BOOST_DAMAGE, 3); + generateUpgradeData(ItemList.Electric_Motor_EV.get(1), Modifiers.BOOST_DAMAGE, 4); + generateUpgradeData(ItemList.Electric_Motor_IV.get(1), Modifiers.BOOST_DAMAGE, 5); + + // Defence Boost + generateUpgradeData( + ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateAluminium", 1), Modifiers.BOOST_DEF, 1); + generateUpgradeData( + ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateStainlessSteel", 1), Modifiers.BOOST_DEF, 2); + generateUpgradeData( + ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateTungsten", 1), Modifiers.BOOST_DEF, 3); + generateUpgradeData( + ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateTungstenSteel", 1), Modifiers.BOOST_DEF, 4); + generateUpgradeData( + ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateNaquadah", 1), Modifiers.BOOST_DEF, 5); + + // Hp Boost + generateUpgradeData(ItemUtils.simpleMetaStack(Items.golden_apple, 0, 1), Modifiers.BOOST_HP, 1); + generateUpgradeData(ItemUtils.simpleMetaStack(Items.golden_apple, 1, 1), Modifiers.BOOST_HP, 2); + generateUpgradeData(ItemUtils.simpleMetaStack(Items.nether_star, 0, 1), Modifiers.BOOST_HP, 3); + generateUpgradeData( + ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32725", 32725, 1), Modifiers.BOOST_HP, 4); + generateUpgradeData( + ItemUtils.simpleMetaStack("gregtech:gt.metaitem.01:32726", 32726, 1), Modifiers.BOOST_HP, 5); + + return true; + } + + public static boolean generateUpgradeData(ItemStack tStack, Modifiers tMod, int tLevel) { + Pair tTemp = new Pair(tMod, tLevel); + if (mValidUpgradeList.put(tStack, tTemp) != null) { + return true; + } + return false; + } + + public static boolean generateUpgradeFormData(ItemStack tStack, BT tMod) { + if (mValidUpgradeListFormChange.put(tStack, tMod) != null) { + return true; + } + return false; + } + + public static boolean addUpgrade(ItemStack tStack, ItemStack tBauble) { + + try { + Iterator> it = + mValidUpgradeListFormChange.entrySet().iterator(); + while (it.hasNext()) { + Entry pair = it.next(); + if (pair.getKey().getItem() == tStack.getItem() + && pair.getKey().getItemDamage() == tStack.getItemDamage()) { + ModularArmourUtils.setBaubleType(tBauble, pair.getValue()); + tBauble.setItemDamage(ModularArmourUtils.getBaubleTypeID(tBauble)); + return true; + } + } + } catch (Throwable t) { + + } + try { + Iterator>> it2 = + mValidUpgradeList.entrySet().iterator(); + while (it2.hasNext()) { + Entry> pair = it2.next(); + if (pair.getKey().getItem() == tStack.getItem() + && pair.getKey().getItemDamage() == tStack.getItemDamage()) { + Pair newPair = pair.getValue(); + ModularArmourUtils.setModifierLevel(tBauble, newPair); + return true; + } + } + } catch (Throwable t) { + + } + return false; + } + + @Override + public int getSizeInventory() { + return 11; + } + + @Override + public ItemStack getStackInSlot(int slot) { + if (slot >= this.inventoryGrid.getSizeInventory()) { + return this.inventoryOutputs.getStackInSlot(slot - 9); + } else if (slot < this.inventoryGrid.getSizeInventory()) { + return this.inventoryGrid.getStackInSlot(slot); + } else { + return null; + } + } + + @Override + public ItemStack decrStackSize(int slot, int count) { + if (slot < this.inventoryGrid.getSizeInventory()) { + return this.inventoryGrid.decrStackSize(slot, count); + } else if (slot >= this.inventoryGrid.getSizeInventory()) { + return this.inventoryOutputs.decrStackSize(slot - 9, count); + } else { + return null; + } + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) { + return this.getStackInSlot(slot); + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack) { + if (slot >= this.inventoryGrid.getSizeInventory()) { + this.inventoryOutputs.setInventorySlotContents(slot - 9, stack); + } else if (slot < this.inventoryGrid.getSizeInventory()) { + this.inventoryGrid.setInventorySlotContents(slot, stack); + } + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer entityplayer) { + return true; + } + + @Override + public void openInventory() { + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + this.inventoryGrid.openInventory(); + this.inventoryOutputs.openInventory(); + } + + @Override + public void closeInventory() { + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + this.inventoryGrid.openInventory(); + this.inventoryOutputs.openInventory(); + } + + @Override + public boolean isItemValidForSlot(int slot, ItemStack itemstack) { + if (slot >= this.inventoryGrid.getSizeInventory()) { + return this.inventoryOutputs.isItemValidForSlot(slot - 9, itemstack); + } else if (slot < this.inventoryGrid.getSizeInventory()) { + return this.inventoryGrid.isItemValidForSlot(slot, itemstack); + } else { + return false; + } + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + int[] accessibleSides = new int[this.getSizeInventory()]; + for (int r = 0; r < this.getSizeInventory(); r++) { + accessibleSides[r] = r; + } + return accessibleSides; + } + + @Override + public boolean canInsertItem(int slot, ItemStack item, int side) { + Logger.INFO("Slot:" + slot + " | side? " + side); + + /*if (side == 1){ + return this.inventoryOutputs.isItemValidForSlot(slot-9, item); + } */ + if (slot >= 9) { + return this.inventoryOutputs.isItemValidForSlot(slot - 9, item); + } else { + return this.inventoryGrid.isItemValidForSlot(slot, item); + } + } + + @Override + public boolean canExtractItem(int slot, ItemStack item, int side) { + Logger.INFO("Slot:" + slot + " | side? " + side); + if (slot == 11 || slot <= 8) { + return true; + } + return false; + } + + @Override + public String getCustomName() { + return this.customName; + } + + @Override + public void setCustomName(String customName) { + this.customName = customName; + } + + @Override + public String getInventoryName() { + return this.hasCustomInventoryName() ? this.customName : "container.fishtrap"; + } + + @Override + public boolean hasCustomInventoryName() { + return this.customName != null && !this.customName.equals(""); + } + + @Override + public boolean onPreTick(long aTick) { + // Check for active recipe + if (this.mRecipeTimeRemaining > -1 + || (this.mTempRecipeStorage != null) && (this.mTempRecipeStorage.getRecipeTime() > -1)) { + if ((this.mTempRecipeStorage != null) && this.mTempRecipeStorage.getRecipeTime() > -1) { + if (this.mRecipeTimeRemaining < this.mTempRecipeStorage.getRecipeTime()) { + this.mRecipeTimeRemaining = this.mTempRecipeStorage.getRecipeTime(); + this.markDirty(); + } + } + if (this.mInputstackA != null && this.mInputstackB != null && this.mOutputStack != null) { + this.mTempRecipeStorage.setInventorySlotContents(0, this.mInputstackA); + this.mTempRecipeStorage.setInventorySlotContents(1, this.mInputstackB); + this.mTempRecipeStorage.setInventorySlotContents(2, this.mOutputStack); + this.mTempRecipeStorage.setRecipeTime(this.mRecipeTimeRemaining); + this.markDirty(); + } + } + return true; + } + + @Override + public boolean onPostTick(long aTick) { + if (mRecipeTimeRemaining == 0) { + this.inventoryOutputs.setInventorySlotContents(2, this.getPendingOutputItem()); + clearRecipeData(); + this.mTempRecipeStorage.setRecipeTime(this.mRecipeTimeRemaining); + this.markDirty(); + } else if (mRecipeTimeRemaining > 0) { + mRecipeTimeRemaining--; + this.mTempRecipeStorage.setRecipeTime(this.mRecipeTimeRemaining); + } + return true; + } + + @Override + public boolean processRecipe() { + boolean removeInputA = false; + boolean removeInputB = false; + // Data stick + ItemStack tBauble = this.inventoryOutputs.getStackInSlot(0); + ItemStack tUpgrade = this.inventoryOutputs.getStackInSlot(1); + if (tBauble != null && tUpgrade != null && this.container != null) { + if (tBauble.getItem() instanceof ModularBauble && this.mRecipeTimeRemaining == -1) { + if (tUpgrade != null && tBauble != null) { + removeInputA = true; + this.setInputStacks(tBauble, tUpgrade); + try { + removeInputB = addUpgrade(tUpgrade, tBauble); + if (!removeInputB) {} + } catch (Throwable t) { + } + if (removeInputA && removeInputB) { + if (this.setOutputStack(tBauble)) { + if (this.inventoryOutputs.getStackInSlot(1).stackSize > 1) { + ItemStack mTempStack = this.inventoryOutputs.getStackInSlot(1); + mTempStack.stackSize--; + this.inventoryOutputs.setInventorySlotContents(1, mTempStack); + } else { + this.inventoryOutputs.setInventorySlotContents(1, null); + } + this.inventoryOutputs.setInventorySlotContents(0, null); + this.mRecipeTimeRemaining = 80; + this.markDirty(); + return true; + } + } + } + } + } + return false; + } + + public static boolean isValidModularPiece(final ItemStack itemstack) { + if (itemstack.getItem() instanceof ModularBauble) { + return true; + } + return false; + } + + public static boolean isValidUpgrade(final ItemStack itemstack) { + boolean isValid = false; + if (itemstack != null) { + Iterator> it = + mValidUpgradeListFormChange.entrySet().iterator(); + while (it.hasNext()) { + Entry pair = it.next(); + if (pair.getKey().getItem() == itemstack.getItem() + && pair.getKey().getItemDamage() == itemstack.getItemDamage()) { + isValid = true; + } + } + Iterator>> it2 = + mValidUpgradeList.entrySet().iterator(); + while (it2.hasNext()) { + Entry> pair = it2.next(); + if (pair.getKey().getItem() == itemstack.getItem() + && pair.getKey().getItemDamage() == itemstack.getItemDamage()) { + isValid = true; + } + } + } + return isValid; + } +} diff --git a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPestKiller.java b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPestKiller.java index a16a9e91a7..df50bd98a9 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPestKiller.java +++ b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPestKiller.java @@ -1,8 +1,5 @@ package gtPlusPlus.core.tileentities.machines; -import java.util.ArrayList; -import java.util.List; - import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.BTF_FluidTank; @@ -14,6 +11,8 @@ import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.EntityUtils; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import java.util.ArrayList; +import java.util.List; import net.minecraft.entity.Entity; import net.minecraft.entity.passive.EntityBat; import net.minecraft.entity.player.EntityPlayer; @@ -38,468 +37,462 @@ import net.minecraftforge.oredict.OreDictionary; public class TileEntityPestKiller extends TileEntity implements ISidedInventory, IFluidHandler { - private final int mBaseTickRate = 20 * 30; - private final InventoryPestKiller mInventory; - private final FluidTank mTank; - private int mChunkX; - private int mChunkZ; - private boolean mSet = false; - - private int mTickCounter = 0; - private int mUpdateTick = 0; - private boolean mNeedsUpdate = false; - private String mCustomName; - - private static final AutoMap> mEntityMap = new AutoMap>(); - - static { - mEntityMap.put(EntityBat.class); - if (LoadedMods.Forestry) { - mEntityMap.put(ReflectionUtils.getClass("forestry.lepidopterology.entities.EntityButterfly")); - } - } - - public TileEntityPestKiller() { - this.mInventory = new InventoryPestKiller(); - mTank = new BTF_FluidTank(2000); - } - - public InventoryPestKiller getInventory() { - return this.mInventory; - } - - public FluidTank getTank() { - return mTank; - } - - private final void setup() { - World w = this.worldObj; - if (w != null) { - Chunk c = w.getChunkFromBlockCoords(this.xCoord, this.zCoord); - if (c != null) { - mChunkX = c.xPosition; - mChunkZ = c.zPosition; - mSet = true; - } - } - } - - @SuppressWarnings("rawtypes") - public boolean tryKillPests() { - int min = 0; - int max = 0; - switch (getTier()) { - case 1: - min = -2; - max = 3; - break; - case 2: - min = -4; - max = 5; - break; - default: - // code block - } - int aChunkCount = 0; - AutoMap entities = new AutoMap(); - if (min != 0 && max != 0) { - for (int x = min; x < max; x++) { - for (int z = min; z < max; z++) { - Chunk c = getChunkFromOffsetIfLoaded(x, z); - if (c != null) { - if (c.hasEntities) { - aChunkCount++; - List[] lists = c.entityLists; - for (List o : lists) { - for (Object e : o) { - if (e instanceof Entity) { - for (Class C : mEntityMap) { - if (e.getClass().equals(C) || C.isAssignableFrom(e.getClass())) { - entities.put((Entity) e); - } - } - } - } - } - } - } - } - } - } else { - Chunk c = getChunkFromOffsetIfLoaded(0, 0); - if (c != null) { - if (c.hasEntities) { - List[] lists = c.entityLists; - for (List o : lists) { - for (Object e : o) { - if (e instanceof Entity) { - for (Class C : mEntityMap) { - if (e.getClass().equals(C) || C.isAssignableFrom(e.getClass())) { - entities.put((Entity) e); - } - } - } - } - } - } - } - } - boolean killed = false; - if (!entities.isEmpty()) { - for (Entity e : entities) { - if (e != null) { - if (e.isEntityAlive()) { - if (this.mTank.getFluidAmount() >= 1 || getTier() == 0) { - if (getTier() > 0) { - int aChanceToUse = MathUtils.randInt(1, (100 * getTier())); - if (aChanceToUse == 1) { - this.mTank.drain(1, true); - } - } - EntityUtils.doDamage(e, DamageSource.generic, Short.MAX_VALUE); - e.setDead(); - killed = true; - } - } - } - } - } - updateTileEntity(); - return killed; - } - - public Chunk getChunkFromOffsetIfLoaded(int x, int y) { - Chunk c = this.worldObj.getChunkFromChunkCoords(mChunkX + x, mChunkZ + y); - if (c.isChunkLoaded) { - return c; - } - return null; - } - - public int getTier() { - if (this.mTank != null) { - FluidStack f = mTank.getFluid(); - if (f != null) { - if (f.isFluidEqual(FluidUtils.getWildcardFluidStack("formaldehyde", 1))) { - return 1; - } else if (f.isFluidEqual(MISC_MATERIALS.HYDROGEN_CYANIDE.getFluidStack(1))) { - return 2; - } - } - } - return 0; - } - - @Override - public void updateEntity() { - if (worldObj.isRemote) { - return; - } - if (!mSet) { - setup(); - } - this.mTickCounter++; - if (this.mTank != null) { - if (this.hasFluidSpace()) { - handleInventory(); - } - } - if (this.mTickCounter % this.mBaseTickRate == 0) { - tryKillPests(); - } - updateTick(); - } - - public boolean anyPlayerInRange() { - return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) != null; - } - - public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) { - if (!nbt.hasKey(tag)) { - nbt.setTag(tag, new NBTTagCompound()); - } - return nbt.getCompoundTag(tag); - } - - @Override - public void writeToNBT(final NBTTagCompound nbt) { - mTank.writeToNBT(nbt); - super.writeToNBT(nbt); - // Utils.LOG_MACHINE_INFO("Trying to write NBT data to TE."); - final NBTTagCompound chestData = new NBTTagCompound(); - this.mInventory.writeToNBT(chestData); - nbt.setTag("ContentsChest", chestData); - if (this.hasCustomInventoryName()) { - nbt.setString("CustomName", this.getCustomName()); - } - } - - @Override - public void readFromNBT(final NBTTagCompound nbt) { - mTank.readFromNBT(nbt); - super.readFromNBT(nbt); - // Utils.LOG_MACHINE_INFO("Trying to read NBT data from TE."); - this.mInventory.readFromNBT(nbt.getCompoundTag("ContentsChest")); - if (nbt.hasKey("CustomName", 8)) { - this.setCustomName(nbt.getString("CustomName")); - } - } - - @Override - public int getSizeInventory() { - return this.getInventory().getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(final int slot) { - return this.getInventory().getStackInSlot(slot); - } - - @Override - public ItemStack decrStackSize(final int slot, final int count) { - return this.getInventory().decrStackSize(slot, count); - } - - @Override - public ItemStack getStackInSlotOnClosing(final int slot) { - return this.getInventory().getStackInSlotOnClosing(slot); - } - - @Override - public void setInventorySlotContents(final int slot, final ItemStack stack) { - this.getInventory().setInventorySlotContents(slot, stack); - } - - @Override - public int getInventoryStackLimit() { - return this.getInventory().getInventoryStackLimit(); - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) { - return this.getInventory().isUseableByPlayer(entityplayer); - } - - @Override - public void openInventory() { - this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); - this.getInventory().openInventory(); - } - - @Override - public void closeInventory() { - this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); - this.getInventory().closeInventory(); - } - - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { - return this.getInventory().isItemValidForSlot(slot, itemstack); - } - - @Override - public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { - final int[] accessibleSides = new int[this.getSizeInventory()]; - for (int r = 0; r < this.getInventory().getSizeInventory(); r++) { - accessibleSides[r] = r; - } - return accessibleSides; - - } - - @Override - public boolean canInsertItem(final int aSlot, final ItemStack aStack, final int p_102007_3_) { - if (this.getInventory().getInventory()[0] == null) { - return true; - } else if (GT_Utility.areStacksEqual(aStack, this.getInventory().getInventory()[0])) { - if (this.getInventory().getInventory()[0].stackSize < 64) { - int diff = 64 - this.getInventory().getInventory()[0].stackSize; - if (aStack.stackSize <= diff) { - return true; - } - } - } - return false; - } - - @Override - public boolean canExtractItem(final int aSlot, final ItemStack aStack, final int p_102008_3_) { - if (this.getInventory().getInventory()[1] == null) { - return false; - } else { - return true; - } - } - - public String getCustomName() { - return this.mCustomName; - } - - public void setCustomName(final String customName) { - this.mCustomName = customName; - } - - @Override - public String getInventoryName() { - return this.hasCustomInventoryName() ? this.mCustomName : "container.pestkiller"; - } - - @Override - public boolean hasCustomInventoryName() { - return (this.mCustomName != null) && !this.mCustomName.equals(""); - } - - @Override - public final int fill(ForgeDirection from, FluidStack resource, boolean doFill) { - updateTileEntity(); - return this.mTank.fill(resource, doFill); - } - - @Override - public final FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { - updateTileEntity(); - return this.mTank.drain(resource.amount, doDrain); - } - - @Override - public final FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { - FluidStack fluid = this.mTank.getFluid(); - // return this.tank.drain(maxDrain, doDrain); - if (fluid == null) { - return null; - } - - int drained = maxDrain; - if (fluid.amount < drained) { - drained = fluid.amount; - } - - FluidStack stack = new FluidStack(fluid, drained); - if (doDrain) { - fluid.amount -= drained; - if (fluid.amount <= 0) { - fluid = null; - } - - if (this != null) { - FluidEvent.fireEvent(new FluidEvent.FluidDrainingEvent(fluid, this.getWorldObj(), this.xCoord, - this.yCoord, this.zCoord, this.mTank, 0)); - } - } - updateTileEntity(); - return stack; - } - - @Override - public boolean canFill(ForgeDirection from, Fluid fluid) { - return mTank.getFluid() == null || mTank.getFluid().getFluid().equals(fluid); - } - - @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) { - return false; - } - - @Override - public final FluidTankInfo[] getTankInfo(ForgeDirection from) { - return new FluidTankInfo[] { this.mTank.getInfo() }; - } - - @Override - public final Packet getDescriptionPacket() { - NBTTagCompound tag = new NBTTagCompound(); - writeToNBT(tag); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, this.blockMetadata, tag); - } - - @Override - public final void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - NBTTagCompound tag = pkt.func_148857_g(); - readFromNBT(tag); - } - - - public boolean hasFluidSpace() { - if (this.mTank.getFluidAmount() <= 1000) { - return true; - } - return false; - } - - public boolean drainCell() { - boolean didFill = false; - ItemStack aInput = this.getStackInSlot(0); - if (aInput == null) { - return false; - } - aInput = aInput.copy(); - if (aInput != null && (this.getStackInSlot(1) == null || this.getStackInSlot(1).stackSize < 64)) { - ArrayList t1Cells = OreDictionary.getOres("cellFormaldehyde"); - ArrayList t2Cells = OreDictionary.getOres("cellHydrogenCyanide"); - didFill = addFluid(t1Cells, aInput, FluidUtils.getWildcardFluidStack("formaldehyde", 1000)); - if (!didFill) { - didFill = addFluid(t2Cells, aInput, MISC_MATERIALS.HYDROGEN_CYANIDE.getFluidStack(1000)); - } - } - - return didFill; - } - - public boolean handleInventory() { - if (this.getInventory() != null && drainCell()) { - this.decrStackSize(0, 1); - if (this.getStackInSlot(1) == null) { - this.setInventorySlotContents(1, CI.emptyCells(1)); - } else { - this.getStackInSlot(1).stackSize++; - } - this.updateTileEntity(); - return true; - } else { - return false; - } - } - - public boolean addFluid(ArrayList inputs, ItemStack aInput, FluidStack aFluidForInput) { - for (ItemStack a : inputs) { - if (GT_Utility.areStacksEqual(a, aInput)) { - if (mTank.getFluid() == null || mTank.getFluid() - .isFluidEqual(aFluidForInput)) { - boolean didFill = fill(ForgeDirection.UNKNOWN, aFluidForInput, true) > 0; - return didFill; - } - } else { - continue; - } - } - return false; - } - - public void updateTileEntity() { - this.getInventory().markDirty(); - this.markDirty(); - this.mNeedsUpdate = true; - } - - private final void updateTick() { - if (mNeedsUpdate) { - if (mUpdateTick == 0) { - mUpdateTick = 4; // every 4 ticks it will send an update - } else { - --mUpdateTick; - if (mUpdateTick == 0) { - markDirty(); - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - mNeedsUpdate = false; - } - } - } - } - - - + private final int mBaseTickRate = 20 * 30; + private final InventoryPestKiller mInventory; + private final FluidTank mTank; + private int mChunkX; + private int mChunkZ; + private boolean mSet = false; + + private int mTickCounter = 0; + private int mUpdateTick = 0; + private boolean mNeedsUpdate = false; + private String mCustomName; + + private static final AutoMap> mEntityMap = new AutoMap>(); + + static { + mEntityMap.put(EntityBat.class); + if (LoadedMods.Forestry) { + mEntityMap.put(ReflectionUtils.getClass("forestry.lepidopterology.entities.EntityButterfly")); + } + } + + public TileEntityPestKiller() { + this.mInventory = new InventoryPestKiller(); + mTank = new BTF_FluidTank(2000); + } + + public InventoryPestKiller getInventory() { + return this.mInventory; + } + + public FluidTank getTank() { + return mTank; + } + + private final void setup() { + World w = this.worldObj; + if (w != null) { + Chunk c = w.getChunkFromBlockCoords(this.xCoord, this.zCoord); + if (c != null) { + mChunkX = c.xPosition; + mChunkZ = c.zPosition; + mSet = true; + } + } + } + + @SuppressWarnings("rawtypes") + public boolean tryKillPests() { + int min = 0; + int max = 0; + switch (getTier()) { + case 1: + min = -2; + max = 3; + break; + case 2: + min = -4; + max = 5; + break; + default: + // code block + } + int aChunkCount = 0; + AutoMap entities = new AutoMap(); + if (min != 0 && max != 0) { + for (int x = min; x < max; x++) { + for (int z = min; z < max; z++) { + Chunk c = getChunkFromOffsetIfLoaded(x, z); + if (c != null) { + if (c.hasEntities) { + aChunkCount++; + List[] lists = c.entityLists; + for (List o : lists) { + for (Object e : o) { + if (e instanceof Entity) { + for (Class C : mEntityMap) { + if (e.getClass().equals(C) || C.isAssignableFrom(e.getClass())) { + entities.put((Entity) e); + } + } + } + } + } + } + } + } + } + } else { + Chunk c = getChunkFromOffsetIfLoaded(0, 0); + if (c != null) { + if (c.hasEntities) { + List[] lists = c.entityLists; + for (List o : lists) { + for (Object e : o) { + if (e instanceof Entity) { + for (Class C : mEntityMap) { + if (e.getClass().equals(C) || C.isAssignableFrom(e.getClass())) { + entities.put((Entity) e); + } + } + } + } + } + } + } + } + boolean killed = false; + if (!entities.isEmpty()) { + for (Entity e : entities) { + if (e != null) { + if (e.isEntityAlive()) { + if (this.mTank.getFluidAmount() >= 1 || getTier() == 0) { + if (getTier() > 0) { + int aChanceToUse = MathUtils.randInt(1, (100 * getTier())); + if (aChanceToUse == 1) { + this.mTank.drain(1, true); + } + } + EntityUtils.doDamage(e, DamageSource.generic, Short.MAX_VALUE); + e.setDead(); + killed = true; + } + } + } + } + } + updateTileEntity(); + return killed; + } + + public Chunk getChunkFromOffsetIfLoaded(int x, int y) { + Chunk c = this.worldObj.getChunkFromChunkCoords(mChunkX + x, mChunkZ + y); + if (c.isChunkLoaded) { + return c; + } + return null; + } + + public int getTier() { + if (this.mTank != null) { + FluidStack f = mTank.getFluid(); + if (f != null) { + if (f.isFluidEqual(FluidUtils.getWildcardFluidStack("formaldehyde", 1))) { + return 1; + } else if (f.isFluidEqual(MISC_MATERIALS.HYDROGEN_CYANIDE.getFluidStack(1))) { + return 2; + } + } + } + return 0; + } + + @Override + public void updateEntity() { + if (worldObj.isRemote) { + return; + } + if (!mSet) { + setup(); + } + this.mTickCounter++; + if (this.mTank != null) { + if (this.hasFluidSpace()) { + handleInventory(); + } + } + if (this.mTickCounter % this.mBaseTickRate == 0) { + tryKillPests(); + } + updateTick(); + } + + public boolean anyPlayerInRange() { + return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) != null; + } + + public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) { + if (!nbt.hasKey(tag)) { + nbt.setTag(tag, new NBTTagCompound()); + } + return nbt.getCompoundTag(tag); + } + + @Override + public void writeToNBT(final NBTTagCompound nbt) { + mTank.writeToNBT(nbt); + super.writeToNBT(nbt); + // Utils.LOG_MACHINE_INFO("Trying to write NBT data to TE."); + final NBTTagCompound chestData = new NBTTagCompound(); + this.mInventory.writeToNBT(chestData); + nbt.setTag("ContentsChest", chestData); + if (this.hasCustomInventoryName()) { + nbt.setString("CustomName", this.getCustomName()); + } + } + + @Override + public void readFromNBT(final NBTTagCompound nbt) { + mTank.readFromNBT(nbt); + super.readFromNBT(nbt); + // Utils.LOG_MACHINE_INFO("Trying to read NBT data from TE."); + this.mInventory.readFromNBT(nbt.getCompoundTag("ContentsChest")); + if (nbt.hasKey("CustomName", 8)) { + this.setCustomName(nbt.getString("CustomName")); + } + } + + @Override + public int getSizeInventory() { + return this.getInventory().getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.getInventory().getStackInSlot(slot); + } + + @Override + public ItemStack decrStackSize(final int slot, final int count) { + return this.getInventory().decrStackSize(slot, count); + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + return this.getInventory().getStackInSlotOnClosing(slot); + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.getInventory().setInventorySlotContents(slot, stack); + } + + @Override + public int getInventoryStackLimit() { + return this.getInventory().getInventoryStackLimit(); + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return this.getInventory().isUseableByPlayer(entityplayer); + } + + @Override + public void openInventory() { + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + this.getInventory().openInventory(); + } + + @Override + public void closeInventory() { + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + this.getInventory().closeInventory(); + } + + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + return this.getInventory().isItemValidForSlot(slot, itemstack); + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + final int[] accessibleSides = new int[this.getSizeInventory()]; + for (int r = 0; r < this.getInventory().getSizeInventory(); r++) { + accessibleSides[r] = r; + } + return accessibleSides; + } + + @Override + public boolean canInsertItem(final int aSlot, final ItemStack aStack, final int p_102007_3_) { + if (this.getInventory().getInventory()[0] == null) { + return true; + } else if (GT_Utility.areStacksEqual(aStack, this.getInventory().getInventory()[0])) { + if (this.getInventory().getInventory()[0].stackSize < 64) { + int diff = 64 - this.getInventory().getInventory()[0].stackSize; + if (aStack.stackSize <= diff) { + return true; + } + } + } + return false; + } + + @Override + public boolean canExtractItem(final int aSlot, final ItemStack aStack, final int p_102008_3_) { + if (this.getInventory().getInventory()[1] == null) { + return false; + } else { + return true; + } + } + + public String getCustomName() { + return this.mCustomName; + } + + public void setCustomName(final String customName) { + this.mCustomName = customName; + } + + @Override + public String getInventoryName() { + return this.hasCustomInventoryName() ? this.mCustomName : "container.pestkiller"; + } + + @Override + public boolean hasCustomInventoryName() { + return (this.mCustomName != null) && !this.mCustomName.equals(""); + } + + @Override + public final int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + updateTileEntity(); + return this.mTank.fill(resource, doFill); + } + + @Override + public final FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + updateTileEntity(); + return this.mTank.drain(resource.amount, doDrain); + } + + @Override + public final FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + FluidStack fluid = this.mTank.getFluid(); + // return this.tank.drain(maxDrain, doDrain); + if (fluid == null) { + return null; + } + + int drained = maxDrain; + if (fluid.amount < drained) { + drained = fluid.amount; + } + + FluidStack stack = new FluidStack(fluid, drained); + if (doDrain) { + fluid.amount -= drained; + if (fluid.amount <= 0) { + fluid = null; + } + + if (this != null) { + FluidEvent.fireEvent(new FluidEvent.FluidDrainingEvent( + fluid, this.getWorldObj(), this.xCoord, this.yCoord, this.zCoord, this.mTank, 0)); + } + } + updateTileEntity(); + return stack; + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return mTank.getFluid() == null || mTank.getFluid().getFluid().equals(fluid); + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return false; + } + + @Override + public final FluidTankInfo[] getTankInfo(ForgeDirection from) { + return new FluidTankInfo[] {this.mTank.getInfo()}; + } + + @Override + public final Packet getDescriptionPacket() { + NBTTagCompound tag = new NBTTagCompound(); + writeToNBT(tag); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, this.blockMetadata, tag); + } + + @Override + public final void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + NBTTagCompound tag = pkt.func_148857_g(); + readFromNBT(tag); + } + + public boolean hasFluidSpace() { + if (this.mTank.getFluidAmount() <= 1000) { + return true; + } + return false; + } + + public boolean drainCell() { + boolean didFill = false; + ItemStack aInput = this.getStackInSlot(0); + if (aInput == null) { + return false; + } + aInput = aInput.copy(); + if (aInput != null && (this.getStackInSlot(1) == null || this.getStackInSlot(1).stackSize < 64)) { + ArrayList t1Cells = OreDictionary.getOres("cellFormaldehyde"); + ArrayList t2Cells = OreDictionary.getOres("cellHydrogenCyanide"); + didFill = addFluid(t1Cells, aInput, FluidUtils.getWildcardFluidStack("formaldehyde", 1000)); + if (!didFill) { + didFill = addFluid(t2Cells, aInput, MISC_MATERIALS.HYDROGEN_CYANIDE.getFluidStack(1000)); + } + } + + return didFill; + } + + public boolean handleInventory() { + if (this.getInventory() != null && drainCell()) { + this.decrStackSize(0, 1); + if (this.getStackInSlot(1) == null) { + this.setInventorySlotContents(1, CI.emptyCells(1)); + } else { + this.getStackInSlot(1).stackSize++; + } + this.updateTileEntity(); + return true; + } else { + return false; + } + } + + public boolean addFluid(ArrayList inputs, ItemStack aInput, FluidStack aFluidForInput) { + for (ItemStack a : inputs) { + if (GT_Utility.areStacksEqual(a, aInput)) { + if (mTank.getFluid() == null || mTank.getFluid().isFluidEqual(aFluidForInput)) { + boolean didFill = fill(ForgeDirection.UNKNOWN, aFluidForInput, true) > 0; + return didFill; + } + } else { + continue; + } + } + return false; + } + + public void updateTileEntity() { + this.getInventory().markDirty(); + this.markDirty(); + this.mNeedsUpdate = true; + } + + private final void updateTick() { + if (mNeedsUpdate) { + if (mUpdateTick == 0) { + mUpdateTick = 4; // every 4 ticks it will send an update + } else { + --mUpdateTick; + if (mUpdateTick == 0) { + markDirty(); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + mNeedsUpdate = false; + } + } + } + } } diff --git a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java index 25348a31f8..4087472ce3 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java +++ b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java @@ -17,131 +17,109 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; public class TileEntityPooCollector extends TileEntityBaseFluidCollector { - - public TileEntityPooCollector() { - super(9, 8000); - } + public TileEntityPooCollector() { + super(9, 8000); + } - @Override - public boolean canFill(ForgeDirection from, Fluid fluid) { - return false; - } + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return false; + } - @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) { - return true; - } - - public void onPreLogicTick() { - - } - - public boolean addDrop(V aPooMaker) { - int aChance = MathUtils.randInt(0, 50000); - if (aChance > 0) { - ItemStack aPoop; - if (aChance<= 100) { - aPoop = ItemUtils.getItemStackOfAmountFromOreDict("dustManureByproducts", 1); - } - else if (aChance <= 500) { - aPoop = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallManureByproducts", 1); - } - else if (aChance <= 1250) { - aPoop = ItemUtils.getItemStackOfAmountFromOreDict("dustTinyManureByproducts", 1); - } - else { - return false; - } - if (!ItemUtils.checkForInvalidItems(aPoop)) { - return false; - } - - //Add poop to world - //Logger.INFO("Adding animal waste for "+aPooMaker.getCommandSenderName()); - - //Add to inventory if not full, else espawn in world - if (!this.mInventory.addItemStack(aPoop)) { - EntityItem entity = new EntityItem(worldObj, xCoord, yCoord+1.5, zCoord, aPoop); - worldObj.spawnEntityInWorld(entity); - } - - } - - - return false; - } + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return true; + } - private static AutoMap aEntityToDrain = new AutoMap(); - - @Override - public AutoMap aThingsToLookFor() { - if (aEntityToDrain.isEmpty()) { - aEntityToDrain.add(EntityAnimal.class); - aEntityToDrain.add(IAnimals.class); - } - return aEntityToDrain; - } + public void onPreLogicTick() {} - @Override - public int onPostTick(V aPooMaker) { - if (this.tank.getFluidAmount() < this.tank.getCapacity()) { - int aPooAmount = 0; - // Vanilla Animals - if (aPooMaker instanceof EntityChicken) { - aPooAmount = MathUtils.randInt(1, 40); - } - else if (aPooMaker instanceof EntityHorse) { - aPooAmount = MathUtils.randInt(20, 40); - } - else if (aPooMaker instanceof EntityCow) { - aPooAmount = MathUtils.randInt(18, 45); - } - else if (aPooMaker instanceof EntityMooshroom) { - aPooAmount = 17; - } - else if (aPooMaker instanceof EntitySheep) { - aPooAmount = MathUtils.randInt(8, 30); - } - - else { - if (aPooMaker instanceof EntityAnimal || aPooMaker instanceof IAnimals) { - aPooAmount = MathUtils.randInt(5, 35); - } - else { - aPooAmount = MathUtils.randInt(1, 10); - } - } - aPooAmount = Math.max((Math.min(this.tank.getCapacity()-this.tank.getFluidAmount(), aPooAmount)/10), 1); - return aPooAmount; - } - else { - return 0; - } - } + public boolean addDrop(V aPooMaker) { + int aChance = MathUtils.randInt(0, 50000); + if (aChance > 0) { + ItemStack aPoop; + if (aChance <= 100) { + aPoop = ItemUtils.getItemStackOfAmountFromOreDict("dustManureByproducts", 1); + } else if (aChance <= 500) { + aPoop = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallManureByproducts", 1); + } else if (aChance <= 1250) { + aPoop = ItemUtils.getItemStackOfAmountFromOreDict("dustTinyManureByproducts", 1); + } else { + return false; + } + if (!ItemUtils.checkForInvalidItems(aPoop)) { + return false; + } - @Override - public Fluid fluidToProvide() { - return AgriculturalChem.PoopJuice; - } + // Add poop to world + // Logger.INFO("Adding animal waste for "+aPooMaker.getCommandSenderName()); - @Override - public ItemStack itemToSpawnInWorldIfTankIsFull() { - int a = MathUtils.randInt(0, 100); - ItemStack aItem = null; - if (a <= 30) { - aItem = ItemUtils.getSimpleStack(AgriculturalChem.dustDirt); - } - else if (a <= 40) { - aItem = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallManureByproducts", 1); - } - else if (a <= 55) { - aItem = ItemUtils.getItemStackOfAmountFromOreDict("dustTinyManureByproducts", 1); - } - return aItem; - } - - - + // Add to inventory if not full, else espawn in world + if (!this.mInventory.addItemStack(aPoop)) { + EntityItem entity = new EntityItem(worldObj, xCoord, yCoord + 1.5, zCoord, aPoop); + worldObj.spawnEntityInWorld(entity); + } + } + return false; + } + + private static AutoMap aEntityToDrain = new AutoMap(); + + @Override + public AutoMap aThingsToLookFor() { + if (aEntityToDrain.isEmpty()) { + aEntityToDrain.add(EntityAnimal.class); + aEntityToDrain.add(IAnimals.class); + } + return aEntityToDrain; + } + + @Override + public int onPostTick(V aPooMaker) { + if (this.tank.getFluidAmount() < this.tank.getCapacity()) { + int aPooAmount = 0; + // Vanilla Animals + if (aPooMaker instanceof EntityChicken) { + aPooAmount = MathUtils.randInt(1, 40); + } else if (aPooMaker instanceof EntityHorse) { + aPooAmount = MathUtils.randInt(20, 40); + } else if (aPooMaker instanceof EntityCow) { + aPooAmount = MathUtils.randInt(18, 45); + } else if (aPooMaker instanceof EntityMooshroom) { + aPooAmount = 17; + } else if (aPooMaker instanceof EntitySheep) { + aPooAmount = MathUtils.randInt(8, 30); + } else { + if (aPooMaker instanceof EntityAnimal || aPooMaker instanceof IAnimals) { + aPooAmount = MathUtils.randInt(5, 35); + } else { + aPooAmount = MathUtils.randInt(1, 10); + } + } + aPooAmount = Math.max((Math.min(this.tank.getCapacity() - this.tank.getFluidAmount(), aPooAmount) / 10), 1); + return aPooAmount; + } else { + return 0; + } + } + + @Override + public Fluid fluidToProvide() { + return AgriculturalChem.PoopJuice; + } + + @Override + public ItemStack itemToSpawnInWorldIfTankIsFull() { + int a = MathUtils.randInt(0, 100); + ItemStack aItem = null; + if (a <= 30) { + aItem = ItemUtils.getSimpleStack(AgriculturalChem.dustDirt); + } else if (a <= 40) { + aItem = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallManureByproducts", 1); + } else if (a <= 55) { + aItem = ItemUtils.getItemStackOfAmountFromOreDict("dustTinyManureByproducts", 1); + } + return aItem; + } } diff --git a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityProjectTable.java b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityProjectTable.java index 8c87baf6a9..0ca1b24ef4 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityProjectTable.java +++ b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityProjectTable.java @@ -1,19 +1,7 @@ package gtPlusPlus.core.tileentities.machines; -import java.util.List; -import java.util.Vector; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; - import gregtech.api.enums.ItemList; import gregtech.common.items.GT_MetaGenerated_Item_01; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.container.Container_ProjectTable; import gtPlusPlus.core.inventories.projecttable.InventoryProjectMain; @@ -30,259 +18,295 @@ import ic2.api.network.INetworkDataProvider; import ic2.api.network.INetworkUpdateListener; import ic2.api.tile.IWrenchable; import ic2.core.IC2; +import java.util.List; +import java.util.Vector; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; -public class TileEntityProjectTable extends TileEntity implements INetworkDataProvider, INetworkUpdateListener, IWrenchable{ - - public InventoryProjectMain inventoryGrid; - public InventoryProjectOutput inventoryOutputs; - - /** The crafting matrix inventory (3x3). */ - public InventoryCrafting craftMatrix; - public IInventory craftResult; - private Container_ProjectTable container; - - public TileEntityProjectTable(){ - this.inventoryGrid = new InventoryProjectMain();//number of slots - without product slot - this.inventoryOutputs = new InventoryProjectOutput();//number of slots - without product slot - this.canUpdate(); - } - - public void setContainer(Container_ProjectTable container){ - this.container = container; - } - - public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag){ - if(!nbt.hasKey(tag)) - { - nbt.setTag(tag, new NBTTagCompound()); - } - return nbt.getCompoundTag(tag); - } - - @Override - public void writeToNBT(final NBTTagCompound nbt){ - super.writeToNBT(nbt); - nbt.setShort("facing", this.facing); - this.inventoryGrid.writeToNBT(this.getTag(nbt, "ContentsGrid")); - this.inventoryOutputs.writeToNBT(this.getTag(nbt, "ContentsOutput")); - - } - - @Override - public void readFromNBT(final NBTTagCompound nbt){ - super.readFromNBT(nbt); - this.prevFacing = (this.facing = nbt.getShort("facing")); - this.inventoryGrid.readFromNBT(nbt.getCompoundTag("ContentsGrid")); - this.inventoryOutputs.readFromNBT(nbt.getCompoundTag("ContentsOutput")); - } - - @Override - public List getNetworkedFields(){ - final List ret = new Vector(2); - ret.add("facing"); - return ret; - } - - - @Override - public boolean wrenchCanSetFacing(final EntityPlayer entityPlayer, final int side){ - return false; - } - - private short facing = 0; - public short prevFacing = 0; - - @Override - public void setFacing(final short facing1){ - this.facing = facing1; - if (this.prevFacing != facing1) { - IC2.network.get().updateTileEntityField(this, "facing"); - } - this.prevFacing = facing1; - } - - @Override - public short getFacing(){ - return this.facing; - } - - - @Override - public boolean wrenchCanRemove(final EntityPlayer entityPlayer){ - return true; - } - - @Override - public float getWrenchDropRate(){ - return 1.0F; - } - - @Override - public ItemStack getWrenchDrop(final EntityPlayer entityPlayer){ - return new ItemStack(this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord), 1, this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord)); - } - - @Override - public void onNetworkUpdate(final String field) { - this.prevFacing = this.facing; - - } - - @Override - public void updateEntity() { - if (!this.worldObj.isRemote){ - //Data stick - ItemStack dataStick = this.inventoryOutputs.getStackInSlot(0); - if (dataStick != null && this.container != null && container.getOutputContent() != null){ - if ((dataStick.getItem() instanceof GT_MetaGenerated_Item_01 && dataStick.getItemDamage() == 32708) - || (dataStick == ItemList.Tool_DataStick.get(1)) - || (dataStick == GregtechItemList.Old_Tool_DataStick.get(1)) - || (dataStick.getItem() instanceof MetaGeneratedGregtechItems && dataStick.getItemDamage() == 32208)){ - - Logger.INFO("Found Data Stick and valid container."); - - - ItemStack outputComponent = container.getOutputContent(); - ItemStack[] craftInputComponent = container.getInputComponents(); - - - ItemStack newStick = NBTUtils.writeItemsToNBT(dataStick, new ItemStack[]{outputComponent}, "Output"); - newStick = NBTUtils.writeItemsToNBT(newStick, craftInputComponent); - NBTUtils.setBookTitle(newStick, "Encrypted Project Data"); - NBTUtils.setBoolean(newStick, "mEncrypted", true); - int slotm=0; - Logger.WARNING("Uploading to Data Stick."); - for (ItemStack is : NBTUtils.readItemsFromNBT(newStick)){ - if (is != null){ - Logger.WARNING("Uploaded "+is.getDisplayName()+" into memory slot "+slotm+"."); - } - else { - Logger.WARNING("Left memory slot "+slotm+" blank."); - } - slotm++; - } - Logger.WARNING("Encrypting Data Stick."); - this.inventoryOutputs.setInventorySlotContents(1, newStick); - this.inventoryOutputs.setInventorySlotContents(0, null); - } - } - - //Utils.LOG_INFO("Doing thing 1"); - if (dataStick != null) - if (dataStick.getItem() instanceof ModularBauble){ - Logger.INFO("Doing thing 2"); - ItemStack tBauble = dataStick; - dataStick = null; - this.inventoryOutputs.setInventorySlotContents(0, dataStick); - if (this.inventoryGrid != null){ - Logger.INFO("Doing things"); - ItemStack[] tStack = container.getInputComponents(); - if (tStack != null){ - //Utils.LOG_INFO(""+tStack.length); - if (tBauble != null){ - for (int i=0;i getNetworkedFields() { + final List ret = new Vector(2); + ret.add("facing"); + return ret; + } + + @Override + public boolean wrenchCanSetFacing(final EntityPlayer entityPlayer, final int side) { + return false; + } + + private short facing = 0; + public short prevFacing = 0; + + @Override + public void setFacing(final short facing1) { + this.facing = facing1; + if (this.prevFacing != facing1) { + IC2.network.get().updateTileEntityField(this, "facing"); + } + this.prevFacing = facing1; + } + + @Override + public short getFacing() { + return this.facing; + } + + @Override + public boolean wrenchCanRemove(final EntityPlayer entityPlayer) { + return true; + } + + @Override + public float getWrenchDropRate() { + return 1.0F; + } + + @Override + public ItemStack getWrenchDrop(final EntityPlayer entityPlayer) { + return new ItemStack( + this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord), + 1, + this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord)); + } + + @Override + public void onNetworkUpdate(final String field) { + this.prevFacing = this.facing; + } + + @Override + public void updateEntity() { + if (!this.worldObj.isRemote) { + // Data stick + ItemStack dataStick = this.inventoryOutputs.getStackInSlot(0); + if (dataStick != null && this.container != null && container.getOutputContent() != null) { + if ((dataStick.getItem() instanceof GT_MetaGenerated_Item_01 && dataStick.getItemDamage() == 32708) + || (dataStick == ItemList.Tool_DataStick.get(1)) + || (dataStick == GregtechItemList.Old_Tool_DataStick.get(1)) + || (dataStick.getItem() instanceof MetaGeneratedGregtechItems + && dataStick.getItemDamage() == 32208)) { + + Logger.INFO("Found Data Stick and valid container."); + + ItemStack outputComponent = container.getOutputContent(); + ItemStack[] craftInputComponent = container.getInputComponents(); + + ItemStack newStick = + NBTUtils.writeItemsToNBT(dataStick, new ItemStack[] {outputComponent}, "Output"); + newStick = NBTUtils.writeItemsToNBT(newStick, craftInputComponent); + NBTUtils.setBookTitle(newStick, "Encrypted Project Data"); + NBTUtils.setBoolean(newStick, "mEncrypted", true); + int slotm = 0; + Logger.WARNING("Uploading to Data Stick."); + for (ItemStack is : NBTUtils.readItemsFromNBT(newStick)) { + if (is != null) { + Logger.WARNING("Uploaded " + is.getDisplayName() + " into memory slot " + slotm + "."); + } else { + Logger.WARNING("Left memory slot " + slotm + " blank."); + } + slotm++; + } + Logger.WARNING("Encrypting Data Stick."); + this.inventoryOutputs.setInventorySlotContents(1, newStick); + this.inventoryOutputs.setInventorySlotContents(0, null); + } + } + + // Utils.LOG_INFO("Doing thing 1"); + if (dataStick != null) + if (dataStick.getItem() instanceof ModularBauble) { + Logger.INFO("Doing thing 2"); + ItemStack tBauble = dataStick; + dataStick = null; + this.inventoryOutputs.setInventorySlotContents(0, dataStick); + if (this.inventoryGrid != null) { + Logger.INFO("Doing things"); + ItemStack[] tStack = container.getInputComponents(); + if (tStack != null) { + // Utils.LOG_INFO(""+tStack.length); + if (tBauble != null) { + for (int i = 0; i < tStack.length; i++) { + + ItemStack testStack; + if ((testStack = container.inventoryGrid.getStackInSlot(i)) != null) { + Logger.INFO("FOUND: " + testStack.getDisplayName()); + } + + if (tStack[i] != null) { + Logger.INFO("found " + tStack[i].getDisplayName()); + try { + if (tStack[i].getItem() == Items.feather) { + ModularArmourUtils.setBaubleType(tBauble, BT.TYPE_BELT); + Logger.INFO("buffed Modular bauble"); + tStack[i] = null; + container.inventoryGrid.setInventorySlotContents(i, null); + this.inventoryGrid.setInventorySlotContents(i, null); + } + if (tStack[i].getItem() == Items.bed) { + ModularArmourUtils.setBaubleType(tBauble, BT.TYPE_RING); + Logger.INFO("buffed Modular bauble"); + tStack[i] = null; + container.inventoryGrid.setInventorySlotContents(i, null); + this.inventoryGrid.setInventorySlotContents(i, null); + } + if (tStack[i].getItem() == Items.boat) { + ModularArmourUtils.setBaubleType(tBauble, BT.TYPE_AMULET); + Logger.INFO("buffed Modular bauble"); + tStack[i] = null; + container.inventoryGrid.setInventorySlotContents(i, null); + this.inventoryGrid.setInventorySlotContents(i, null); + } + + if (tStack[i].getItem() == Items.egg) { + ModularArmourUtils.setModifierLevel( + tBauble, + Modifiers.BOOST_HOLY, + ModularArmourUtils.getModifierLevel( + tBauble, Modifiers.BOOST_HOLY) + + 1); + Logger.INFO("buffed Modular bauble"); + tStack[i] = null; + container.inventoryGrid.setInventorySlotContents(i, null); + this.inventoryGrid.setInventorySlotContents(i, null); + } + + if (tStack[i].getItem() == Items.baked_potato) { + ModularArmourUtils.setModifierLevel( + tBauble, + Modifiers.BOOST_DEF, + ModularArmourUtils.getModifierLevel( + tBauble, Modifiers.BOOST_DEF) + + 1); + Logger.INFO("buffed Modular bauble"); + tStack[i] = null; + container.inventoryGrid.setInventorySlotContents(i, null); + this.inventoryGrid.setInventorySlotContents(i, null); + } + + if (tStack[i].getItem() == Items.cooked_beef) { + ModularArmourUtils.setModifierLevel( + tBauble, + Modifiers.BOOST_HP, + ModularArmourUtils.getModifierLevel(tBauble, Modifiers.BOOST_HP) + + 1); + Logger.INFO("buffed Modular bauble"); + tStack[i] = null; + container.inventoryGrid.setInventorySlotContents(i, null); + this.inventoryGrid.setInventorySlotContents(i, null); + } + + if (tStack[i] + == ItemUtils.simpleMetaStack( + "gregtech:gt.metaitem.01:17019", 17019, 1)) { + ModularArmourUtils.setModifierLevel( + tBauble, + Modifiers.BOOST_DEF, + ModularArmourUtils.getModifierLevel( + tBauble, Modifiers.BOOST_DEF) + + 1); + Logger.INFO("buffed Modular bauble"); + tStack[i] = null; + container.inventoryGrid.setInventorySlotContents(i, null); + } + if (tStack[i] == ItemList.Electric_Motor_LV.get(1)) { + ModularArmourUtils.setModifierLevel( + tBauble, + Modifiers.BOOST_DAMAGE, + ModularArmourUtils.getModifierLevel( + tBauble, Modifiers.BOOST_DAMAGE) + + 1); + Logger.INFO("buffed Modular bauble"); + tStack[i] = null; + container.inventoryGrid.setInventorySlotContents(i, null); + } else if (tStack[i] == ItemList.Electric_Motor_MV.get(1)) { + ModularArmourUtils.setModifierLevel( + tBauble, + Modifiers.BOOST_DAMAGE, + ModularArmourUtils.getModifierLevel( + tBauble, Modifiers.BOOST_DAMAGE) + + 2); + Logger.INFO("buffed Modular bauble"); + tStack[i] = null; + container.inventoryGrid.setInventorySlotContents(i, null); + } else if (tStack[i] == ItemList.Electric_Motor_HV.get(1)) { + ModularArmourUtils.setModifierLevel( + tBauble, + Modifiers.BOOST_DAMAGE, + ModularArmourUtils.getModifierLevel( + tBauble, Modifiers.BOOST_DAMAGE) + + 3); + Logger.INFO("buffed Modular bauble"); + tStack[i] = null; + container.inventoryGrid.setInventorySlotContents(i, null); + } + } catch (Throwable t) { + + } + } + } + Logger.INFO("set new Modular bauble"); + this.inventoryOutputs.setInventorySlotContents(1, tBauble); + } + } + } + } + } + super.updateEntity(); + } + + @Override + public boolean canUpdate() { + return true; + } +} diff --git a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityRoundRobinator.java b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityRoundRobinator.java index a220997c84..840893703a 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityRoundRobinator.java +++ b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityRoundRobinator.java @@ -1,7 +1,5 @@ package gtPlusPlus.core.tileentities.machines; -import java.util.List; - import gtPlusPlus.GTplusplus; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.handler.GuiHandler; @@ -9,6 +7,7 @@ import gtPlusPlus.core.inventories.Inventory_RoundRobinator; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.core.util.sys.KeyboardUtils; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.block.BlockChest; import net.minecraft.command.IEntitySelector; @@ -32,708 +31,645 @@ import net.minecraft.world.World; public class TileEntityRoundRobinator extends TileEntity implements ISidedInventory, IHopper { - private int tickCount = 0; - private final Inventory_RoundRobinator inventoryContents; - private String customName; - public int locationX; - public int locationY; - public int locationZ; - private int aData = 1111; - private int aTier = 1; - private int aTickRate = 100; - - public TileEntityRoundRobinator() { - this.inventoryContents = new Inventory_RoundRobinator(); - this.setTileLocation(); - } - - public boolean setTileLocation() { - if (this.hasWorldObj()) { - if (!this.getWorldObj().isRemote) { - this.locationX = this.xCoord; - this.locationY = this.yCoord; - this.locationZ = this.zCoord; - this.aTier = this.getWorldObj().getBlockMetadata(locationX, locationY, locationZ) + 1; - return true; - } - } - return false; - } - - //Rename to hasCircuitToConfigure - public final boolean hasInventoryContents() { - for (ItemStack i : this.aHopperInventory) { - if (i == null) { - continue; - } - else { - return true; - } - } - return false; - } - - public Inventory_RoundRobinator getInventory() { - return this.inventoryContents; - } - - public int getTier() { - return this.aTier; - } - - public int getTickRate() { - return this.aTickRate; - } - - @Override - public void updateEntity() { - try{ - // TODO - if (this.worldObj != null && !this.worldObj.isRemote){ - setTileLocation(); - aTickRate = (60-(aTier*10)); - if (this.getTier() == 1) { - // 20 s - aTickRate = 400; - } - else if (this.getTier() == 2) { - // 5 - aTickRate = 100; - } - else if (this.getTier() == 3) { - // 1 - aTickRate = 20; - } - else if (this.getTier() == 4) { - // 1/5 - aTickRate = 10; - } - else if (this.getTier() == 5) { - // 1/20 - aTickRate = 1; - } - else { - aTickRate = 999999; - } - - if (tickCount % getTickRate() == 0) { - if (hasInventoryContents()) { - Logger.WARNING("Trying to move items. "+aTickRate); - this.tryProcessItems(); - } - } - this.tickCount++; - } - } - catch (final Throwable t){ - t.printStackTrace(); - } - } - - public boolean anyPlayerInRange() { - return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) != null; - } - - public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) { - if (!nbt.hasKey(tag)) { - nbt.setTag(tag, new NBTTagCompound()); - } - return nbt.getCompoundTag(tag); - } - - @Override - public void writeToNBT(final NBTTagCompound nbt) { - super.writeToNBT(nbt); - if (this.hasCustomInventoryName()) { - nbt.setString("CustomName", this.getCustomName()); - } - nbt.setInteger("aCurrentMode", aData); - this.writeToNBT2(nbt); - } - - @Override - public void readFromNBT(final NBTTagCompound nbt) { - super.readFromNBT(nbt); - if (nbt.hasKey("CustomName", 8)) { - this.setCustomName(nbt.getString("CustomName")); - } - aData = nbt.getInteger("aCurrentMode"); - this.readFromNBT2(nbt); - } - - @Override - public int getInventoryStackLimit() { - return 64; - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer entityplayer) { - return this.getInventory().isUseableByPlayer(entityplayer); - } - - @Override - public void openInventory() { - this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); - //this.getInventory().openInventory(); - } - - @Override - public void closeInventory() { - this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); - //this.getInventory().closeInventory(); - } - - @Override - public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { - return true; - } - - @Override - public int[] getAccessibleSlotsFromSide(final int aSide) { - return new int[] {0, 1, 2, 3, 4}; - } - - @Override - public boolean canInsertItem(final int aSlot, final ItemStack aStack, final int aSide) { - return aSide < 2; - } - - @Override - public boolean canExtractItem(final int aSlot, final ItemStack aStack, final int aSide) { - return false; - } - - public String getCustomName() { - return this.customName; - } - - public void setCustomName(final String customName) { - this.customName = customName; - } - - @Override - public String getInventoryName() { - return this.hasCustomInventoryName() ? this.customName : "container.roundrobinator"; - } - - @Override - public boolean hasCustomInventoryName() { - return (this.customName != null) && !this.customName.equals(""); - } - - @Override - public Packet getDescriptionPacket() { - final NBTTagCompound tag = new NBTTagCompound(); - this.writeToNBT(tag); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, this.blockMetadata, tag); - } - - @Override - public void onDataPacket(final NetworkManager net, final S35PacketUpdateTileEntity pkt) { - final NBTTagCompound tag = pkt.func_148857_g(); - this.readFromNBT(tag); - } - - - public boolean onRightClick(byte side, EntityPlayer player, int x, int y, int z) { - if (player != null && player.getHeldItem() == null) { - if (!player.isSneaking() && !KeyboardUtils.isShiftKeyDown()) { - player.openGui(GTplusplus.instance, GuiHandler.GUI16, player.getEntityWorld(), x, y, z); - } - else { - String InventoryContents = ItemUtils.getArrayStackNames(this.aHopperInventory); - PlayerUtils.messagePlayer(player, "Contents: "+InventoryContents+" | "+getDataString()); - } - return true; - } - else { - return false; - } - } - - public boolean onScrewdriverRightClick(byte side, EntityPlayer player, int x, int y, int z) { - try { - if (side < 2) { - // Top/Bottom - } - else { - if (toggleSide(side)) { - PlayerUtils.messagePlayer(player, "Enabling side "+side+"."); - } - else { - PlayerUtils.messagePlayer(player, "Disabling side "+side+"."); - } - PlayerUtils.messagePlayer(player, "Mode String: "+aData+""); - } - return true; - } - catch (Throwable t) { - t.printStackTrace(); - return false; - } - } - - public int getDataString() { - return aData; - } - - public boolean[] getActiveSides() { - this.markDirty(); - String s = String.valueOf(aData); - if (s == null || s.length() != 4) { - s = "1111"; - } - boolean[] aActiveSides = new boolean[4]; - for (int i=0;i<4;i++) { - char ch = s.charAt(i); - if (ch == '1') { - aActiveSides[i] = true; - } - else { - aActiveSides[i] = false; - } - } - return aActiveSides; - } - - /** - * Toggle active state of side - * @param aSide - Forge Direction / Side - * @return - True if the side is now Active, false if now disabled. - */ - public boolean toggleSide(int aSide) { - setSideActive(!getSideActive(aSide), aSide); - return getSideActive(aSide); - } - - - public void setSideActive(boolean aActive, int aSide) { - try { - if (aSide < 2) { - } - else { - if (aData < 1111) { - aData = 1111; - } - else if (aData > 2222) { - aData = 2222; - } - String s = String.valueOf(aData); - StringBuilder aDataString = new StringBuilder(s); - int aIndex = aSide - 2; - if (aActive) { - aDataString.setCharAt(aIndex, '1'); - } - else { - aDataString.setCharAt(aIndex, '2'); - } - aData = Integer.valueOf(aDataString.toString()); - this.markDirty(); - } - } - catch (Throwable t) { - t.printStackTrace(); - } - } - - public boolean getSideActive(int aSide) { - this.markDirty(); - try { - if (aSide < 2) { - return false; - } - else { - if (aData < 1111) { - aData = 1111; - } - else if (aData > 2222) { - aData = 2222; - } - String s = String.valueOf(aData); - int aIndex = aSide - 2; - char ch = s.charAt(aIndex); - if (ch == '1') { - return true; - } - else { - return false; - } - - } - } - catch (Throwable t) { - t.printStackTrace(); - return false; - } - } - - @Override - public double getXPos() { - return this.locationX; - } - - @Override - public double getYPos() { - return this.locationY; - } - - @Override - public double getZPos() { - return this.locationZ; - } - - - - - - - - - // TODO - - - - /* - * Hopper Code - */ - - - private ItemStack[] aHopperInventory = new ItemStack[5]; - - public int getSizeInventory() { - return this.aHopperInventory.length; - } - - public ItemStack getStackInSlot(int aSlot) { - return this.aHopperInventory[aSlot]; - } - - /** - * Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a - * new stack. - */ - public ItemStack decrStackSize(int aSlot, int aMinimumSizeOfExistingStack) - { - if (this.aHopperInventory[aSlot] != null) - { - ItemStack itemstack; - - if (this.aHopperInventory[aSlot].stackSize <= aMinimumSizeOfExistingStack) - { - itemstack = this.aHopperInventory[aSlot]; - this.aHopperInventory[aSlot] = null; - return itemstack; - } - else - { - itemstack = this.aHopperInventory[aSlot].splitStack(aMinimumSizeOfExistingStack); - - if (this.aHopperInventory[aSlot].stackSize == 0) - { - this.aHopperInventory[aSlot] = null; - } - - return itemstack; - } - } - else - { - return null; - } - } - - /** - * When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem - - * like when you close a workbench GUI. - */ - public ItemStack getStackInSlotOnClosing(int aSlot) - { - if (this.aHopperInventory[aSlot] != null) - { - ItemStack itemstack = this.aHopperInventory[aSlot]; - this.aHopperInventory[aSlot] = null; - return itemstack; - } - else - { - return null; - } - } - - /** - * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections). - */ - public void setInventorySlotContents(int aSlot, ItemStack aStack) - { - this.aHopperInventory[aSlot] = aStack; - - if (aStack != null && aStack.stackSize > this.getInventoryStackLimit()) - { - aStack.stackSize = this.getInventoryStackLimit(); - } - } - - public boolean tryProcessItems() { - if (this.worldObj != null && !this.worldObj.isRemote) { - boolean didSomething = false; - if (!this.isEmpty()) { - Logger.WARNING("Has Items, Trying to push to all active directions."); - didSomething = this.tryPushItemsIntoNeighbours(); - } - if (didSomething) { - this.markDirty(); - return true; - } - } - return false; - } - - /** - * Is Empty - * @return - */ - private boolean isEmpty() { - ItemStack[] aitemstack = this.aHopperInventory; - int i = aitemstack.length; - - for (int j = 0; j < i; ++j) { - ItemStack itemstack = aitemstack[j]; - - if (itemstack != null) { - return false; - } - } - - return true; - } - - private boolean tryPushItemsIntoNeighbours() { - - boolean aDidPush = false; - - for (int u = 2; u < 6; u++) { - if (!this.getSideActive(u)) { - Logger.WARNING("Not pushing on side "+u); - continue; - } - - Logger.WARNING("Pushing on side "+u); - IInventory iinventory = this.getInventoryFromFacing(u); - - if (iinventory == null) { - Logger.WARNING("No inventory found."); - continue; - } - else { - - int i = Facing.oppositeSide[u]; - Logger.WARNING("Using Opposite direction: "+i); - - if (this.isInventoryFull(iinventory, i)) { - Logger.WARNING("Target is full, skipping."); - continue; - } - else { - Logger.WARNING("Target has space, let's move a single item."); - for (int j = 0; j < this.getSizeInventory(); ++j) { - if (this.getStackInSlot(j) != null) { - ItemStack itemstack = this.getStackInSlot(j).copy(); - ItemStack itemstack1 = setStackInNeighbour(iinventory, this.decrStackSize(j, 1), i); - if (itemstack1 == null || itemstack1.stackSize == 0) { - iinventory.markDirty(); - aDidPush = true; - continue; - } - this.setInventorySlotContents(j, itemstack); - } - } - } - } - } - - return aDidPush; - } - - private boolean isInventoryFull(IInventory aInv, int aSide) { - if (aInv instanceof ISidedInventory && aSide > -1) { - ISidedInventory isidedinventory = (ISidedInventory)aInv; - int[] aint = isidedinventory.getAccessibleSlotsFromSide(aSide); - - for (int l = 0; l < aint.length; ++l) - { - ItemStack itemstack1 = isidedinventory.getStackInSlot(aint[l]); - - if (itemstack1 == null || itemstack1.stackSize != itemstack1.getMaxStackSize()) - { - return false; - } - } - } - else { - int j = aInv.getSizeInventory(); - - for (int k = 0; k < j; ++k) - { - ItemStack itemstack = aInv.getStackInSlot(k); - - if (itemstack == null || itemstack.stackSize != itemstack.getMaxStackSize()) - { - return false; - } - } - } - return true; - } - - public static ItemStack setStackInNeighbour(IInventory aNeighbour, ItemStack aStack, int aSide) { - if (aNeighbour instanceof ISidedInventory && aSide > -1) - { - ISidedInventory isidedinventory = (ISidedInventory)aNeighbour; - int[] aint = isidedinventory.getAccessibleSlotsFromSide(aSide); - - for (int l = 0; l < aint.length && aStack != null && aStack.stackSize > 0; ++l) - { - aStack = tryMoveStack(aNeighbour, aStack, aint[l], aSide); - } - } - else - { - int j = aNeighbour.getSizeInventory(); - - for (int k = 0; k < j && aStack != null && aStack.stackSize > 0; ++k) - { - aStack = tryMoveStack(aNeighbour, aStack, k, aSide); - } - } - - if (aStack != null && aStack.stackSize == 0) - { - aStack = null; - } - - return aStack; - } - - private static boolean canInsertItemIntoNeighbour(IInventory aNeighbour, ItemStack aStack, int aSlot, int aSide) { - return !aNeighbour.isItemValidForSlot(aSlot, aStack) ? false : !(aNeighbour instanceof ISidedInventory) || ((ISidedInventory)aNeighbour).canInsertItem(aSlot, aStack, aSide); - } - - private static ItemStack tryMoveStack(IInventory aNeighbour, ItemStack aStack, int aSlot, int aSide) { - ItemStack itemstack1 = aNeighbour.getStackInSlot(aSlot); - if (canInsertItemIntoNeighbour(aNeighbour, aStack, aSlot, aSide)) { - boolean aDidSomething = false; - if (itemstack1 == null) { - //Forge: BUGFIX: Again, make things respect max stack sizes. - int max = Math.min(aStack.getMaxStackSize(), aNeighbour.getInventoryStackLimit()); - if (max >= aStack.stackSize) { - aNeighbour.setInventorySlotContents(aSlot, aStack); - aStack = null; - } - else { - aNeighbour.setInventorySlotContents(aSlot, aStack.splitStack(max)); - } - aDidSomething = true; - } - else if (areItemStacksEqual(itemstack1, aStack)) { - //Forge: BUGFIX: Again, make things respect max stack sizes. - int max = Math.min(aStack.getMaxStackSize(), aNeighbour.getInventoryStackLimit()); - if (max > itemstack1.stackSize) { - int l = Math.min(aStack.stackSize, max - itemstack1.stackSize); - aStack.stackSize -= l; - itemstack1.stackSize += l; - aDidSomething = l > 0; - } - } - if (aDidSomething){ - aNeighbour.markDirty(); - } - } - return aStack; - } - - private IInventory getInventoryFromFacing(int aSide) - { - int i = aSide; - return tryFindInvetoryAtXYZ(this.getWorldObj(), (double)(this.xCoord + Facing.offsetsXForSide[i]), (double)(this.yCoord + Facing.offsetsYForSide[i]), (double)(this.zCoord + Facing.offsetsZForSide[i])); - } - - public static IInventory tryFindInvetoryAtXYZ(World aWorld, double aX, double aY, double aZ) - { - IInventory iinventory = null; - int sX = MathHelper.floor_double(aX); - int sY = MathHelper.floor_double(aY); - int sZ = MathHelper.floor_double(aZ); - TileEntity tileentity = aWorld.getTileEntity(sX, sY, sZ); - - if (tileentity != null && tileentity instanceof IInventory) - { - iinventory = (IInventory)tileentity; - - if (iinventory instanceof TileEntityChest) - { - Block block = aWorld.getBlock(sX, sY, sZ); - - if (block instanceof BlockChest) - { - iinventory = ((BlockChest)block).func_149951_m(aWorld, sX, sY, sZ); - } - } - } - - if (iinventory == null) - { - List list = aWorld.getEntitiesWithinAABBExcludingEntity((Entity)null, AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1.0D, aY + 1.0D, aZ + 1.0D), IEntitySelector.selectInventories); - - if (list != null && list.size() > 0) - { - iinventory = (IInventory)list.get(aWorld.rand.nextInt(list.size())); - } - } - - return iinventory; - } - - private static boolean areItemStacksEqual(ItemStack aStack, ItemStack aStack2) { - return aStack.getItem() != aStack2.getItem() ? false : (aStack.getItemDamage() != aStack2.getItemDamage() ? false : (aStack.stackSize > aStack.getMaxStackSize() ? false : ItemStack.areItemStackTagsEqual(aStack, aStack2))); - } - - public void readFromNBT2(NBTTagCompound p_145839_1_) { - super.readFromNBT(p_145839_1_); - NBTTagList nbttaglist = p_145839_1_.getTagList("Items", 10); - this.aHopperInventory = new ItemStack[this.getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); ++i) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - byte b0 = nbttagcompound1.getByte("Slot"); - if (b0 >= 0 && b0 < this.aHopperInventory.length) { - this.aHopperInventory[b0] = ItemStack.loadItemStackFromNBT( - nbttagcompound1 - ); - } - } - } - - public void writeToNBT2(NBTTagCompound aNBT) { - super.writeToNBT(aNBT); - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < this.aHopperInventory.length; ++i) { - if (this.aHopperInventory[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - this.aHopperInventory[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - aNBT.setTag("Items", nbttaglist); - } - - - - - - - + private int tickCount = 0; + private final Inventory_RoundRobinator inventoryContents; + private String customName; + public int locationX; + public int locationY; + public int locationZ; + private int aData = 1111; + private int aTier = 1; + private int aTickRate = 100; + + public TileEntityRoundRobinator() { + this.inventoryContents = new Inventory_RoundRobinator(); + this.setTileLocation(); + } + + public boolean setTileLocation() { + if (this.hasWorldObj()) { + if (!this.getWorldObj().isRemote) { + this.locationX = this.xCoord; + this.locationY = this.yCoord; + this.locationZ = this.zCoord; + this.aTier = this.getWorldObj().getBlockMetadata(locationX, locationY, locationZ) + 1; + return true; + } + } + return false; + } + + // Rename to hasCircuitToConfigure + public final boolean hasInventoryContents() { + for (ItemStack i : this.aHopperInventory) { + if (i == null) { + continue; + } else { + return true; + } + } + return false; + } + + public Inventory_RoundRobinator getInventory() { + return this.inventoryContents; + } + + public int getTier() { + return this.aTier; + } + + public int getTickRate() { + return this.aTickRate; + } + + @Override + public void updateEntity() { + try { + // TODO + if (this.worldObj != null && !this.worldObj.isRemote) { + setTileLocation(); + aTickRate = (60 - (aTier * 10)); + if (this.getTier() == 1) { + // 20 s + aTickRate = 400; + } else if (this.getTier() == 2) { + // 5 + aTickRate = 100; + } else if (this.getTier() == 3) { + // 1 + aTickRate = 20; + } else if (this.getTier() == 4) { + // 1/5 + aTickRate = 10; + } else if (this.getTier() == 5) { + // 1/20 + aTickRate = 1; + } else { + aTickRate = 999999; + } + + if (tickCount % getTickRate() == 0) { + if (hasInventoryContents()) { + Logger.WARNING("Trying to move items. " + aTickRate); + this.tryProcessItems(); + } + } + this.tickCount++; + } + } catch (final Throwable t) { + t.printStackTrace(); + } + } + + public boolean anyPlayerInRange() { + return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) != null; + } + + public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) { + if (!nbt.hasKey(tag)) { + nbt.setTag(tag, new NBTTagCompound()); + } + return nbt.getCompoundTag(tag); + } + + @Override + public void writeToNBT(final NBTTagCompound nbt) { + super.writeToNBT(nbt); + if (this.hasCustomInventoryName()) { + nbt.setString("CustomName", this.getCustomName()); + } + nbt.setInteger("aCurrentMode", aData); + this.writeToNBT2(nbt); + } + + @Override + public void readFromNBT(final NBTTagCompound nbt) { + super.readFromNBT(nbt); + if (nbt.hasKey("CustomName", 8)) { + this.setCustomName(nbt.getString("CustomName")); + } + aData = nbt.getInteger("aCurrentMode"); + this.readFromNBT2(nbt); + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return this.getInventory().isUseableByPlayer(entityplayer); + } + + @Override + public void openInventory() { + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + // this.getInventory().openInventory(); + } + + @Override + public void closeInventory() { + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + // this.getInventory().closeInventory(); + } + + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + return true; + } + + @Override + public int[] getAccessibleSlotsFromSide(final int aSide) { + return new int[] {0, 1, 2, 3, 4}; + } + + @Override + public boolean canInsertItem(final int aSlot, final ItemStack aStack, final int aSide) { + return aSide < 2; + } + + @Override + public boolean canExtractItem(final int aSlot, final ItemStack aStack, final int aSide) { + return false; + } + + public String getCustomName() { + return this.customName; + } + + public void setCustomName(final String customName) { + this.customName = customName; + } + + @Override + public String getInventoryName() { + return this.hasCustomInventoryName() ? this.customName : "container.roundrobinator"; + } + + @Override + public boolean hasCustomInventoryName() { + return (this.customName != null) && !this.customName.equals(""); + } + + @Override + public Packet getDescriptionPacket() { + final NBTTagCompound tag = new NBTTagCompound(); + this.writeToNBT(tag); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, this.blockMetadata, tag); + } + + @Override + public void onDataPacket(final NetworkManager net, final S35PacketUpdateTileEntity pkt) { + final NBTTagCompound tag = pkt.func_148857_g(); + this.readFromNBT(tag); + } + + public boolean onRightClick(byte side, EntityPlayer player, int x, int y, int z) { + if (player != null && player.getHeldItem() == null) { + if (!player.isSneaking() && !KeyboardUtils.isShiftKeyDown()) { + player.openGui(GTplusplus.instance, GuiHandler.GUI16, player.getEntityWorld(), x, y, z); + } else { + String InventoryContents = ItemUtils.getArrayStackNames(this.aHopperInventory); + PlayerUtils.messagePlayer(player, "Contents: " + InventoryContents + " | " + getDataString()); + } + return true; + } else { + return false; + } + } + + public boolean onScrewdriverRightClick(byte side, EntityPlayer player, int x, int y, int z) { + try { + if (side < 2) { + // Top/Bottom + } else { + if (toggleSide(side)) { + PlayerUtils.messagePlayer(player, "Enabling side " + side + "."); + } else { + PlayerUtils.messagePlayer(player, "Disabling side " + side + "."); + } + PlayerUtils.messagePlayer(player, "Mode String: " + aData + ""); + } + return true; + } catch (Throwable t) { + t.printStackTrace(); + return false; + } + } + + public int getDataString() { + return aData; + } + + public boolean[] getActiveSides() { + this.markDirty(); + String s = String.valueOf(aData); + if (s == null || s.length() != 4) { + s = "1111"; + } + boolean[] aActiveSides = new boolean[4]; + for (int i = 0; i < 4; i++) { + char ch = s.charAt(i); + if (ch == '1') { + aActiveSides[i] = true; + } else { + aActiveSides[i] = false; + } + } + return aActiveSides; + } + + /** + * Toggle active state of side + * @param aSide - Forge Direction / Side + * @return - True if the side is now Active, false if now disabled. + */ + public boolean toggleSide(int aSide) { + setSideActive(!getSideActive(aSide), aSide); + return getSideActive(aSide); + } + + public void setSideActive(boolean aActive, int aSide) { + try { + if (aSide < 2) { + } else { + if (aData < 1111) { + aData = 1111; + } else if (aData > 2222) { + aData = 2222; + } + String s = String.valueOf(aData); + StringBuilder aDataString = new StringBuilder(s); + int aIndex = aSide - 2; + if (aActive) { + aDataString.setCharAt(aIndex, '1'); + } else { + aDataString.setCharAt(aIndex, '2'); + } + aData = Integer.valueOf(aDataString.toString()); + this.markDirty(); + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + + public boolean getSideActive(int aSide) { + this.markDirty(); + try { + if (aSide < 2) { + return false; + } else { + if (aData < 1111) { + aData = 1111; + } else if (aData > 2222) { + aData = 2222; + } + String s = String.valueOf(aData); + int aIndex = aSide - 2; + char ch = s.charAt(aIndex); + if (ch == '1') { + return true; + } else { + return false; + } + } + } catch (Throwable t) { + t.printStackTrace(); + return false; + } + } + + @Override + public double getXPos() { + return this.locationX; + } + + @Override + public double getYPos() { + return this.locationY; + } + + @Override + public double getZPos() { + return this.locationZ; + } + + // TODO + + /* + * Hopper Code + */ + + private ItemStack[] aHopperInventory = new ItemStack[5]; + + public int getSizeInventory() { + return this.aHopperInventory.length; + } + + public ItemStack getStackInSlot(int aSlot) { + return this.aHopperInventory[aSlot]; + } + + /** + * Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a + * new stack. + */ + public ItemStack decrStackSize(int aSlot, int aMinimumSizeOfExistingStack) { + if (this.aHopperInventory[aSlot] != null) { + ItemStack itemstack; + + if (this.aHopperInventory[aSlot].stackSize <= aMinimumSizeOfExistingStack) { + itemstack = this.aHopperInventory[aSlot]; + this.aHopperInventory[aSlot] = null; + return itemstack; + } else { + itemstack = this.aHopperInventory[aSlot].splitStack(aMinimumSizeOfExistingStack); + + if (this.aHopperInventory[aSlot].stackSize == 0) { + this.aHopperInventory[aSlot] = null; + } + + return itemstack; + } + } else { + return null; + } + } + + /** + * When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem - + * like when you close a workbench GUI. + */ + public ItemStack getStackInSlotOnClosing(int aSlot) { + if (this.aHopperInventory[aSlot] != null) { + ItemStack itemstack = this.aHopperInventory[aSlot]; + this.aHopperInventory[aSlot] = null; + return itemstack; + } else { + return null; + } + } + + /** + * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections). + */ + public void setInventorySlotContents(int aSlot, ItemStack aStack) { + this.aHopperInventory[aSlot] = aStack; + + if (aStack != null && aStack.stackSize > this.getInventoryStackLimit()) { + aStack.stackSize = this.getInventoryStackLimit(); + } + } + + public boolean tryProcessItems() { + if (this.worldObj != null && !this.worldObj.isRemote) { + boolean didSomething = false; + if (!this.isEmpty()) { + Logger.WARNING("Has Items, Trying to push to all active directions."); + didSomething = this.tryPushItemsIntoNeighbours(); + } + if (didSomething) { + this.markDirty(); + return true; + } + } + return false; + } + + /** + * Is Empty + * @return + */ + private boolean isEmpty() { + ItemStack[] aitemstack = this.aHopperInventory; + int i = aitemstack.length; + + for (int j = 0; j < i; ++j) { + ItemStack itemstack = aitemstack[j]; + + if (itemstack != null) { + return false; + } + } + + return true; + } + + private boolean tryPushItemsIntoNeighbours() { + + boolean aDidPush = false; + + for (int u = 2; u < 6; u++) { + if (!this.getSideActive(u)) { + Logger.WARNING("Not pushing on side " + u); + continue; + } + + Logger.WARNING("Pushing on side " + u); + IInventory iinventory = this.getInventoryFromFacing(u); + + if (iinventory == null) { + Logger.WARNING("No inventory found."); + continue; + } else { + + int i = Facing.oppositeSide[u]; + Logger.WARNING("Using Opposite direction: " + i); + + if (this.isInventoryFull(iinventory, i)) { + Logger.WARNING("Target is full, skipping."); + continue; + } else { + Logger.WARNING("Target has space, let's move a single item."); + for (int j = 0; j < this.getSizeInventory(); ++j) { + if (this.getStackInSlot(j) != null) { + ItemStack itemstack = this.getStackInSlot(j).copy(); + ItemStack itemstack1 = setStackInNeighbour(iinventory, this.decrStackSize(j, 1), i); + if (itemstack1 == null || itemstack1.stackSize == 0) { + iinventory.markDirty(); + aDidPush = true; + continue; + } + this.setInventorySlotContents(j, itemstack); + } + } + } + } + } + + return aDidPush; + } + + private boolean isInventoryFull(IInventory aInv, int aSide) { + if (aInv instanceof ISidedInventory && aSide > -1) { + ISidedInventory isidedinventory = (ISidedInventory) aInv; + int[] aint = isidedinventory.getAccessibleSlotsFromSide(aSide); + + for (int l = 0; l < aint.length; ++l) { + ItemStack itemstack1 = isidedinventory.getStackInSlot(aint[l]); + + if (itemstack1 == null || itemstack1.stackSize != itemstack1.getMaxStackSize()) { + return false; + } + } + } else { + int j = aInv.getSizeInventory(); + + for (int k = 0; k < j; ++k) { + ItemStack itemstack = aInv.getStackInSlot(k); + + if (itemstack == null || itemstack.stackSize != itemstack.getMaxStackSize()) { + return false; + } + } + } + return true; + } + + public static ItemStack setStackInNeighbour(IInventory aNeighbour, ItemStack aStack, int aSide) { + if (aNeighbour instanceof ISidedInventory && aSide > -1) { + ISidedInventory isidedinventory = (ISidedInventory) aNeighbour; + int[] aint = isidedinventory.getAccessibleSlotsFromSide(aSide); + + for (int l = 0; l < aint.length && aStack != null && aStack.stackSize > 0; ++l) { + aStack = tryMoveStack(aNeighbour, aStack, aint[l], aSide); + } + } else { + int j = aNeighbour.getSizeInventory(); + + for (int k = 0; k < j && aStack != null && aStack.stackSize > 0; ++k) { + aStack = tryMoveStack(aNeighbour, aStack, k, aSide); + } + } + + if (aStack != null && aStack.stackSize == 0) { + aStack = null; + } + + return aStack; + } + + private static boolean canInsertItemIntoNeighbour(IInventory aNeighbour, ItemStack aStack, int aSlot, int aSide) { + return !aNeighbour.isItemValidForSlot(aSlot, aStack) + ? false + : !(aNeighbour instanceof ISidedInventory) + || ((ISidedInventory) aNeighbour).canInsertItem(aSlot, aStack, aSide); + } + + private static ItemStack tryMoveStack(IInventory aNeighbour, ItemStack aStack, int aSlot, int aSide) { + ItemStack itemstack1 = aNeighbour.getStackInSlot(aSlot); + if (canInsertItemIntoNeighbour(aNeighbour, aStack, aSlot, aSide)) { + boolean aDidSomething = false; + if (itemstack1 == null) { + // Forge: BUGFIX: Again, make things respect max stack sizes. + int max = Math.min(aStack.getMaxStackSize(), aNeighbour.getInventoryStackLimit()); + if (max >= aStack.stackSize) { + aNeighbour.setInventorySlotContents(aSlot, aStack); + aStack = null; + } else { + aNeighbour.setInventorySlotContents(aSlot, aStack.splitStack(max)); + } + aDidSomething = true; + } else if (areItemStacksEqual(itemstack1, aStack)) { + // Forge: BUGFIX: Again, make things respect max stack sizes. + int max = Math.min(aStack.getMaxStackSize(), aNeighbour.getInventoryStackLimit()); + if (max > itemstack1.stackSize) { + int l = Math.min(aStack.stackSize, max - itemstack1.stackSize); + aStack.stackSize -= l; + itemstack1.stackSize += l; + aDidSomething = l > 0; + } + } + if (aDidSomething) { + aNeighbour.markDirty(); + } + } + return aStack; + } + + private IInventory getInventoryFromFacing(int aSide) { + int i = aSide; + return tryFindInvetoryAtXYZ( + this.getWorldObj(), + (double) (this.xCoord + Facing.offsetsXForSide[i]), + (double) (this.yCoord + Facing.offsetsYForSide[i]), + (double) (this.zCoord + Facing.offsetsZForSide[i])); + } + + public static IInventory tryFindInvetoryAtXYZ(World aWorld, double aX, double aY, double aZ) { + IInventory iinventory = null; + int sX = MathHelper.floor_double(aX); + int sY = MathHelper.floor_double(aY); + int sZ = MathHelper.floor_double(aZ); + TileEntity tileentity = aWorld.getTileEntity(sX, sY, sZ); + + if (tileentity != null && tileentity instanceof IInventory) { + iinventory = (IInventory) tileentity; + + if (iinventory instanceof TileEntityChest) { + Block block = aWorld.getBlock(sX, sY, sZ); + + if (block instanceof BlockChest) { + iinventory = ((BlockChest) block).func_149951_m(aWorld, sX, sY, sZ); + } + } + } + + if (iinventory == null) { + List list = aWorld.getEntitiesWithinAABBExcludingEntity( + (Entity) null, + AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1.0D, aY + 1.0D, aZ + 1.0D), + IEntitySelector.selectInventories); + + if (list != null && list.size() > 0) { + iinventory = (IInventory) list.get(aWorld.rand.nextInt(list.size())); + } + } + + return iinventory; + } + + private static boolean areItemStacksEqual(ItemStack aStack, ItemStack aStack2) { + return aStack.getItem() != aStack2.getItem() + ? false + : (aStack.getItemDamage() != aStack2.getItemDamage() + ? false + : (aStack.stackSize > aStack.getMaxStackSize() + ? false + : ItemStack.areItemStackTagsEqual(aStack, aStack2))); + } + + public void readFromNBT2(NBTTagCompound p_145839_1_) { + super.readFromNBT(p_145839_1_); + NBTTagList nbttaglist = p_145839_1_.getTagList("Items", 10); + this.aHopperInventory = new ItemStack[this.getSizeInventory()]; + for (int i = 0; i < nbttaglist.tagCount(); ++i) { + NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); + byte b0 = nbttagcompound1.getByte("Slot"); + if (b0 >= 0 && b0 < this.aHopperInventory.length) { + this.aHopperInventory[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1); + } + } + } + + public void writeToNBT2(NBTTagCompound aNBT) { + super.writeToNBT(aNBT); + NBTTagList nbttaglist = new NBTTagList(); + for (int i = 0; i < this.aHopperInventory.length; ++i) { + if (this.aHopperInventory[i] != null) { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + nbttagcompound1.setByte("Slot", (byte) i); + this.aHopperInventory[i].writeToNBT(nbttagcompound1); + nbttaglist.appendTag(nbttagcompound1); + } + } + aNBT.setTag("Items", nbttaglist); + } } diff --git a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityTradeTable.java b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityTradeTable.java index ad7ec3d0b3..260e559c09 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityTradeTable.java +++ b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityTradeTable.java @@ -1,133 +1,122 @@ package gtPlusPlus.core.tileentities.machines; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - import gtPlusPlus.core.container.Container_TradeTable; import gtPlusPlus.core.inventories.tradetable.InventoryTradeMain; import gtPlusPlus.core.inventories.tradetable.InventoryTradeOutput; import gtPlusPlus.core.tileentities.base.TileEntityBase; import gtPlusPlus.core.util.minecraft.NBTUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; public class TileEntityTradeTable extends TileEntityBase { - public InventoryTradeMain inventoryGrid; - public InventoryTradeOutput inventoryOutputs; - - private Container_TradeTable container; - - public TileEntityTradeTable(){ - super(2); - this.inventoryGrid = new InventoryTradeMain();//number of slots - without product slot - this.inventoryOutputs = new InventoryTradeOutput();//number of slots - without product slot - } - - public void setContainer(Container_TradeTable container_TradeTable){ - this.container = container_TradeTable; - } - - @Override - public void writeToNBT(final NBTTagCompound nbt){ - super.writeToNBT(nbt); - this.inventoryGrid.writeToNBT(this.getTag(nbt, "ContentsGrid")); - this.inventoryOutputs.writeToNBT(this.getTag(nbt, "ContentsOutput")); - - } - - @Override - public void readFromNBT(final NBTTagCompound nbt){ - this.inventoryGrid.readFromNBT(nbt); - this.inventoryOutputs.readFromNBT(nbt); - super.readFromNBT(nbt); - } - - @Override - public void updateEntity() { - if (!this.worldObj.isRemote){ - ItemStack slot0; - try{ - - slot0 = this.inventoryOutputs.getStackInSlot(0); - if (slot0 != null && slot0.hasTagCompound()){ - NBTUtils.tryIterateNBTData(slot0); - this.inventoryOutputs.setInventorySlotContents(0, null); - this.inventoryOutputs.setInventorySlotContents(1, slot0); - } - - } - catch (Throwable t){ - t.printStackTrace(); - this.inventoryOutputs.setInventorySlotContents(0, null); - } - - } - super.updateEntity(); - } - - @Override - public int getSizeInventory() { - return 0; - } - - @Override - public ItemStack getStackInSlot(int p_70301_1_) { - return null; - } - - @Override - public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) { - return null; - } - - @Override - public ItemStack getStackInSlotOnClosing(int p_70304_1_) { - return null; - } - - @Override - public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) { - - } - - @Override - public int getInventoryStackLimit() { - return 64; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { - return true; - } - - @Override - public void openInventory() { - - } - - @Override - public void closeInventory() { - - } - - @Override - public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { - return false; - } - - @Override - public int[] getAccessibleSlotsFromSide(int p_94128_1_) { - return new int[] {}; - } - - @Override - public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) { - return false; - } - - @Override - public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { - return false; - } - -} \ No newline at end of file + public InventoryTradeMain inventoryGrid; + public InventoryTradeOutput inventoryOutputs; + + private Container_TradeTable container; + + public TileEntityTradeTable() { + super(2); + this.inventoryGrid = new InventoryTradeMain(); // number of slots - without product slot + this.inventoryOutputs = new InventoryTradeOutput(); // number of slots - without product slot + } + + public void setContainer(Container_TradeTable container_TradeTable) { + this.container = container_TradeTable; + } + + @Override + public void writeToNBT(final NBTTagCompound nbt) { + super.writeToNBT(nbt); + this.inventoryGrid.writeToNBT(this.getTag(nbt, "ContentsGrid")); + this.inventoryOutputs.writeToNBT(this.getTag(nbt, "ContentsOutput")); + } + + @Override + public void readFromNBT(final NBTTagCompound nbt) { + this.inventoryGrid.readFromNBT(nbt); + this.inventoryOutputs.readFromNBT(nbt); + super.readFromNBT(nbt); + } + + @Override + public void updateEntity() { + if (!this.worldObj.isRemote) { + ItemStack slot0; + try { + + slot0 = this.inventoryOutputs.getStackInSlot(0); + if (slot0 != null && slot0.hasTagCompound()) { + NBTUtils.tryIterateNBTData(slot0); + this.inventoryOutputs.setInventorySlotContents(0, null); + this.inventoryOutputs.setInventorySlotContents(1, slot0); + } + + } catch (Throwable t) { + t.printStackTrace(); + this.inventoryOutputs.setInventorySlotContents(0, null); + } + } + super.updateEntity(); + } + + @Override + public int getSizeInventory() { + return 0; + } + + @Override + public ItemStack getStackInSlot(int p_70301_1_) { + return null; + } + + @Override + public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) { + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(int p_70304_1_) { + return null; + } + + @Override + public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) {} + + @Override + public int getInventoryStackLimit() { + return 64; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { + return true; + } + + @Override + public void openInventory() {} + + @Override + public void closeInventory() {} + + @Override + public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { + return false; + } + + @Override + public int[] getAccessibleSlotsFromSide(int p_94128_1_) { + return new int[] {}; + } + + @Override + public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) { + return false; + } + + @Override + public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { + return false; + } +} diff --git a/src/main/java/gtPlusPlus/core/util/MovingAverageLong.java b/src/main/java/gtPlusPlus/core/util/MovingAverageLong.java index f59aa20ecd..fee1fe84bc 100644 --- a/src/main/java/gtPlusPlus/core/util/MovingAverageLong.java +++ b/src/main/java/gtPlusPlus/core/util/MovingAverageLong.java @@ -1,11 +1,10 @@ package gtPlusPlus.core.util; -import net.minecraft.nbt.NBTTagCompound; - import java.math.BigInteger; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.Arrays; +import net.minecraft.nbt.NBTTagCompound; public class MovingAverageLong { private final long[] storage; diff --git a/src/main/java/gtPlusPlus/core/util/Utils.java b/src/main/java/gtPlusPlus/core/util/Utils.java index ac61abdd30..274d180de8 100644 --- a/src/main/java/gtPlusPlus/core/util/Utils.java +++ b/src/main/java/gtPlusPlus/core/util/Utils.java @@ -1,36 +1,11 @@ package gtPlusPlus.core.util; -import java.awt.Color; -import java.awt.Graphics; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.ObjectOutput; -import java.io.ObjectOutputStream; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Timer; -import java.util.TimerTask; - -import javax.xml.bind.DatatypeConverter; - -import org.apache.commons.lang3.EnumUtils; - import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration; import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; -import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.enums.TC_Aspects; import gregtech.api.enums.TC_Aspects.TC_AspectStack; @@ -55,6 +30,26 @@ import gtPlusPlus.plugin.villagers.tile.TileEntityGenericSpawner; import ic2.core.Ic2Items; import ic2.core.init.InternalName; import ic2.core.item.resources.ItemCell; +import java.awt.Color; +import java.awt.Graphics; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.ObjectOutput; +import java.io.ObjectOutputStream; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Timer; +import java.util.TimerTask; +import javax.xml.bind.DatatypeConverter; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; @@ -73,888 +68,921 @@ import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; +import org.apache.commons.lang3.EnumUtils; public class Utils { - public static final int WILDCARD_VALUE = Short.MAX_VALUE; - - public static final boolean isServer() { - return FMLCommonHandler.instance().getEffectiveSide().isServer(); - } - - public static final boolean isClient() { - return FMLCommonHandler.instance().getEffectiveSide().isClient(); - } - - static class ShortTimerTask extends TimerTask { - @Override - public void run() { - Logger.WARNING("Timer expired."); - } - } - - public static TC_AspectStack getTcAspectStack(final TC_Aspects aspect, final long size) { - return getTcAspectStack(aspect.name(), (int) size); - } - - public static TC_AspectStack getTcAspectStack(final String aspect, final long size) { - return getTcAspectStack(aspect, (int) size); - } - - public static TC_AspectStack getTcAspectStack(final TC_Aspects aspect, final int size) { - return getTcAspectStack(aspect.name(), size); - } - - public static TC_AspectStack getTcAspectStack(final String aspect, final int size) { - - TC_AspectStack returnValue = null; - - if (aspect.toUpperCase().equals("COGNITIO")) { - // Adds in Compat for older GT Versions which Misspell aspects. - try { - if (EnumUtils.isValidEnum(TC_Aspects.class, "COGNITIO")) { - Logger.WARNING("TC Aspect found - " + aspect); - returnValue = new TC_AspectStack(TC_Aspects.valueOf("COGNITIO"), size); - } else { - Logger.INFO("Fallback TC Aspect found - " + aspect - + " - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); - returnValue = new TC_AspectStack(TC_Aspects.valueOf("COGNITO"), size); - } - } catch (final NoSuchFieldError r) { - Logger.INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); - } - } else if (aspect.toUpperCase().equals("EXANIMUS")) { - // Adds in Compat for older GT Versions which Misspell aspects. - try { - if (EnumUtils.isValidEnum(TC_Aspects.class, "EXANIMUS")) { - Logger.WARNING("TC Aspect found - " + aspect); - returnValue = new TC_AspectStack(TC_Aspects.valueOf("EXANIMUS"), size); - } else { - Logger.INFO("Fallback TC Aspect found - " + aspect - + " - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); - returnValue = new TC_AspectStack(TC_Aspects.valueOf("EXAMINIS"), size); - } - } catch (final NoSuchFieldError r) { - Logger.INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); - } - - } else if (aspect.toUpperCase().equals("PRAECANTATIO")) { - // Adds in Compat for older GT Versions which Misspell aspects. - try { - if (EnumUtils.isValidEnum(TC_Aspects.class, "PRAECANTATIO")) { - Logger.WARNING("TC Aspect found - " + aspect); - returnValue = new TC_AspectStack(TC_Aspects.valueOf("PRAECANTATIO"), size); - } else { - Logger.INFO("Fallback TC Aspect found - " + aspect - + " - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); - returnValue = new TC_AspectStack(TC_Aspects.valueOf("PRAECANTIO"), size); - } - } catch (final NoSuchFieldError r) { - Logger.INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); - } - } else { - Logger.WARNING("TC Aspect found - " + aspect); - returnValue = new TC_AspectStack(TC_Aspects.valueOf(aspect), size); - } - - return returnValue; - } - - public static boolean containsMatch(final boolean strict, final ItemStack[] inputs, final ItemStack... targets) { - for (final ItemStack input : inputs) { - for (final ItemStack target : targets) { - if (itemMatches(target, input, strict)) { - return true; - } - } - } - return false; - } - - public static boolean itemMatches(final ItemStack target, final ItemStack input, final boolean strict) { - if ((input == null) || (target == null)) { - return false; - } - return ((target.getItem() == input.getItem()) && (((target.getItemDamage() == WILDCARD_VALUE) && !strict) - || (target.getItemDamage() == input.getItemDamage()))); - } - - //Register an event to both busses. - public static void registerEvent(Object o){ - MinecraftForge.EVENT_BUS.register(o); - FMLCommonHandler.instance().bus().register(o); - } - - public static void paintBox(final Graphics g, final int MinA, final int MinB, final int MaxA, final int MaxB) { - g.drawRect(MinA, MinB, MaxA, MaxB); - } - - // Send a message to all players on the server - public static void sendServerMessage(final String translationKey) { - sendServerMessage(new ChatComponentText(translationKey)); - } - - // Send a message to all players on the server - public static void sendServerMessage(final IChatComponent chatComponent) { - MinecraftServer.getServer().getConfigurationManager().sendChatMsg(chatComponent); - } - - /** - * Returns if that Liquid is IC2Steam. - */ - public static boolean isIC2Steam(final FluidStack aFluid) { - if (aFluid == null) { - return false; - } - return aFluid.isFluidEqual(getIC2Steam(1)); - } - - /** - * Returns a Liquid Stack with given amount of IC2Steam. - */ - public static FluidStack getIC2Steam(final long aAmount) { - return FluidRegistry.getFluidStack("ic2steam", (int) aAmount); - } - - /* - * public static void recipeBuilderBlock(ItemStack slot_1, ItemStack slot_2, - * ItemStack slot_3, ItemStack slot_4, ItemStack slot_5, ItemStack slot_6, - * ItemStack slot_7, ItemStack slot_8, ItemStack slot_9, Block resultBlock){ - * GameRegistry.addRecipe(new ItemStack(resultBlock), new Object[] {"ABC", - * "DEF", "GHI", 'A',slot_1,'B',slot_2,'C',slot_3, - * 'D',slot_4,'E',slot_5,'F',slot_6, 'G',slot_7,'H',slot_8,'I',slot_9 }); } - */ - - public static String checkCorrectMiningToolForBlock(final Block currentBlock, final World currentWorld) { - String correctTool = ""; - if (!currentWorld.isRemote) { - try { - correctTool = currentBlock.getHarvestTool(0); - Logger.WARNING(correctTool); - - } catch (final NullPointerException e) { - - } - } - - return correctTool; - } - - /** - * - * @param colourStr - * e.g. "#FFFFFF" - * @return String - formatted "rgb(0,0,0)" - */ - public static String hex2RgbFormatted(final String hexString) { - final Color c = new Color(Integer.valueOf(hexString.substring(1, 3), 16), - Integer.valueOf(hexString.substring(3, 5), 16), Integer.valueOf(hexString.substring(5, 7), 16)); - - final StringBuffer sb = new StringBuffer(); - sb.append("rgb("); - sb.append(c.getRed()); - sb.append(","); - sb.append(c.getGreen()); - sb.append(","); - sb.append(c.getBlue()); - sb.append(")"); - return sb.toString(); - } - - /** - * - * @param colourStr - * e.g. "#FFFFFF" - * @return - */ - public static Color hex2Rgb(final String colorStr) { - return new Color(Integer.valueOf(colorStr.substring(1, 3), 16), Integer.valueOf(colorStr.substring(3, 5), 16), - Integer.valueOf(colorStr.substring(5, 7), 16)); - } - - /** - * - * @param colourInt - * e.g. 0XFFFFFF - * @return Colour - */ - public static Color hex2Rgb(final int colourInt) { - return Color.decode(String.valueOf(colourInt)); - } - - /** - * - * @param colourInt - * e.g. 0XFFFFFF - * @return short[] - */ - public static short[] hex2RgbShort(final int colourInt) { - final Color rgb = Color.decode(String.valueOf(colourInt)); - final short[] rgba = { (short) rgb.getRed(), (short) rgb.getGreen(), (short) rgb.getBlue(), - (short) rgb.getAlpha() }; - return rgba; - } - - public static Timer ShortTimer(final int seconds) { - Timer timer; - timer = new Timer(); - timer.schedule(new ShortTimerTask(), seconds * 1000); - return timer; - } - - public static String byteToHex(final byte b) { - final int i = b & 0xFF; - return Integer.toHexString(i); - } - - public static Object[] convertListToArray(final List sourceList) { - final Object[] targetArray = sourceList.toArray(new Object[sourceList.size()]); - return targetArray; - } - - public static List convertArrayToFixedSizeList(final Object[] sourceArray) { - final List targetList = Arrays.asList(sourceArray); - return targetList; - } - - public static List convertArrayToList(final Object[] sourceArray) { - final List targetList = new ArrayList<>(Arrays.asList(sourceArray)); - return targetList; - } - - public static List convertArrayListToList(final ArrayList sourceArray) { - final List targetList = new ArrayList(Arrays.asList(sourceArray)); - return targetList; - } - - public static void spawnCustomParticle(final Entity entity) { - GTplusplus.proxy.generateMysteriousParticles(entity); - } - - public static void spawnFX(final World world, final int x, final int y, final int z, final String particleName, - Object particleName2) { - if (!world.isRemote) { - if ((particleName2 == null) || particleName2.equals("")) { - particleName2 = particleName; - } - final int l = MathUtils.randInt(0, 4); - final double d0 = x + 0.5F; - final double d1 = y + 0.7F; - final double d2 = z + 0.5F; - final double d3 = 0.2199999988079071D; - final double d4 = 0.27000001072883606D; - - if (l == 1) { - world.spawnParticle(particleName, d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); - } else if (l == 2) { - world.spawnParticle((String) particleName2, d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); - } else if (l == 3) { - world.spawnParticle(particleName, d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D); - } else if (l == 4) { - world.spawnParticle((String) particleName2, d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D); - } else { - world.spawnParticle(particleName, d0, d1, d2, 0.0D, 0.0D, 0.0D); - if (particleName2 != null) { - world.spawnParticle((String) particleName2, d0, d1, d2, 0.0D, 0.0D, 0.0D); - } - } - } - } - - public static int rgbtoHexValue(final int r, final int g, final int b) { - if ((r > 255) || (g > 255) || (b > 255) || (r < 0) || (g < 0) || (b < 0)) { - return 0; - } - final Color c = new Color(r, g, b); - String temp = Integer.toHexString(c.getRGB() & 0xFFFFFF).toUpperCase(); - temp = Utils.appenedHexNotationToString(String.valueOf(temp)); - Logger.WARNING("Made " + temp + " - Hopefully it's not a mess."); - Logger.WARNING("It will decode into " + Integer.decode(temp) + "."); - return Integer.decode(temp); - } - - /* - * http://javadevnotes.com/java-left-pad-string-with-zeros-examples - */ - public static String padWithZerosLefts(final String originalString, final int length) { - final StringBuilder sb = new StringBuilder(); - while ((sb.length() + originalString.length()) < length) { - sb.append('0'); - } - sb.append(originalString); - final String paddedString = sb.toString(); - return paddedString; - } - - public static String padWithZerosRight(final int value, final int length) { - String originalString = String.valueOf(value); - final StringBuilder sb = new StringBuilder(); - while ((sb.length() + originalString.length()) < length) { - sb.append('0'); - } - //sb.append(originalString); - if (sb.length() > 0) - originalString = (originalString + sb.toString()); - final String paddedString = sb.toString(); - return originalString; - } - - /* - * Original Code by Chandana Napagoda - - * https://cnapagoda.blogspot.com.au/2011/03/java-hex-color-code-generator. - * html - */ - public static Map hexColourGenerator(final int colorCount) { - final int maxColorValue = 16777215; - // this is decimal value of the "FFFFFF" - final int devidedvalue = maxColorValue / colorCount; - int countValue = 0; - final HashMap hexColorMap = new HashMap<>(); - for (int a = 0; (a < colorCount) && (maxColorValue >= countValue); a++) { - if (a != 0) { - countValue += devidedvalue; - hexColorMap.put(a, Integer.toHexString(0x10000 | countValue).substring(1).toUpperCase()); - } else { - hexColorMap.put(a, Integer.toHexString(0x10000 | countValue).substring(1).toUpperCase()); - } - } - return hexColorMap; - } - - /* - * Original Code by Chandana Napagoda - - * https://cnapagoda.blogspot.com.au/2011/03/java-hex-color-code-generator. - * html - */ - public static Map hexColourGeneratorRandom(final int colorCount) { - final HashMap hexColorMap = new HashMap<>(); - for (int a = 0; a < colorCount; a++) { - String code = "" + (int) (Math.random() * 256); - code = code + code + code; - final int i = Integer.parseInt(code); - hexColorMap.put(a, Integer.toHexString(0x1000000 | i).substring(1).toUpperCase()); - Logger.WARNING("" + Integer.toHexString(0x1000000 | i).substring(1).toUpperCase()); - } - return hexColorMap; - } - - public static String appenedHexNotationToString(final Object hexAsStringOrInt) { - final String hexChar = "0x"; - String result; - if (hexAsStringOrInt.getClass() == String.class) { - - if (((String) hexAsStringOrInt).length() != 6) { - final String temp = padWithZerosLefts((String) hexAsStringOrInt, 6); - result = temp; - } - result = hexChar + hexAsStringOrInt; - return result; - } else if (hexAsStringOrInt.getClass() == Integer.class || hexAsStringOrInt.getClass() == int.class) { - String aa = String.valueOf(hexAsStringOrInt); - if (aa.length() != 6) { - final String temp = padWithZerosLefts(aa, 6); - result = temp; - } - else { - result = hexChar + String.valueOf(hexAsStringOrInt); - } - return result; - } else { - return null; - } - } - - public static Integer appenedHexNotationToInteger(final int hexAsStringOrInt) { - final String hexChar = "0x"; - String result; - Logger.WARNING(String.valueOf(hexAsStringOrInt)); - result = hexChar + String.valueOf(hexAsStringOrInt); - return Integer.getInteger(result); - } - - public static boolean doesEntryExistAlreadyInOreDictionary(final String OreDictName) { - if (OreDictionary.getOres(OreDictName).size() != 0) { - return true; - } - return false; - } - - public static boolean invertBoolean(final boolean booleans) { - if (booleans == true) { - return false; - } - return true; - } - - public static File getMcDir() { - if (Utils.isClient()) { - if (Minecraft.getMinecraft() != null) { - return Minecraft.getMinecraft().mcDataDir; - } - } - return new File("."); - } - - private static short cellID = 15; - - public static ItemStack createInternalNameAndFluidCell(final String s) { - Logger.WARNING("1"); - final InternalName yourName = EnumHelper.addEnum(InternalName.class, s, new Class[0], new Object[0]); - Logger.WARNING("2 " + yourName.name()); - final ItemCell item = (ItemCell) Ic2Items.cell.getItem(); - Logger.WARNING("3 " + item.getUnlocalizedName()); - try { - Logger.WARNING("4"); - final Class clz = item.getClass(); - Logger.WARNING("5 " + clz.getSimpleName()); - final Method methode = clz.getDeclaredMethod("addCell", int.class, InternalName.class, Block[].class); - Logger.WARNING("6 " + methode.getName()); - methode.setAccessible(true); - Logger.WARNING("7 " + methode.isAccessible()); - final ItemStack temp = (ItemStack) methode.invoke(item, cellID++, yourName, new Block[0]); - Logger.WARNING("Successfully created " + temp.getDisplayName() + "s."); - FluidContainerRegistry.registerFluidContainer(FluidUtils.getFluidStack(s.toLowerCase(), 1000), temp.copy(), - Ic2Items.cell.copy()); - ItemUtils.addItemToOreDictionary(temp.copy(), "cell" + s); - return temp; - } catch (final Exception e) { - e.printStackTrace(); - } - return null; - } - - public static ItemStack createInternalNameAndFluidCellNoOreDict(final String s) { - Logger.WARNING("1"); - final InternalName yourName = EnumHelper.addEnum(InternalName.class, s, new Class[0], new Object[0]); - Logger.WARNING("2 " + yourName.name()); - final ItemCell item = (ItemCell) Ic2Items.cell.getItem(); - Logger.WARNING("3 " + item.getUnlocalizedName()); - try { - Logger.WARNING("4"); - final Class clz = item.getClass(); - Logger.WARNING("5 " + clz.getSimpleName()); - final Method methode = clz.getDeclaredMethod("addCell", int.class, InternalName.class, Block[].class); - Logger.WARNING("6 " + methode.getName()); - methode.setAccessible(true); - Logger.WARNING("7 " + methode.isAccessible()); - final ItemStack temp = (ItemStack) methode.invoke(item, cellID++, yourName, new Block[0]); - Logger.WARNING("Successfully created " + temp.getDisplayName() + "s."); - FluidContainerRegistry.registerFluidContainer(FluidUtils.getFluidStack(s.toLowerCase(), 1000), temp.copy(), - Ic2Items.cell.copy()); - // ItemUtils.addItemToOreDictionary(temp.copy(), "cell"+s); - return temp; - } catch (final Exception e) { - e.printStackTrace(); - } - return null; - } - - public static String sanitizeString(final String input, final char[] aDontRemove) { - - String output; - AutoMap aToRemoveMap = new AutoMap(); - - aToRemoveMap.put(" "); - aToRemoveMap.put("-"); - aToRemoveMap.put("_"); - aToRemoveMap.put("~"); - aToRemoveMap.put("?"); - aToRemoveMap.put("!"); - aToRemoveMap.put("@"); - aToRemoveMap.put("#"); - aToRemoveMap.put("$"); - aToRemoveMap.put("%"); - aToRemoveMap.put("^"); - aToRemoveMap.put("&"); - aToRemoveMap.put("*"); - aToRemoveMap.put("("); - aToRemoveMap.put(")"); - aToRemoveMap.put("{"); - aToRemoveMap.put("}"); - aToRemoveMap.put("["); - aToRemoveMap.put("]"); - aToRemoveMap.put(" "); - - for (String s : aToRemoveMap) { - for (char e : aDontRemove) { - if (s.charAt(0) == e) { - aToRemoveMap.remove("s"); - } - } - } - output = input; - for (String A : aToRemoveMap) { - output = output.replace(A, ""); - } - return output; - - } - - public static String sanitizeString(final String input) { - String temp; - String output; - - temp = input.replace(" ", ""); - temp = temp.replace("-", ""); - temp = temp.replace("_", ""); - temp = temp.replace("?", ""); - temp = temp.replace("!", ""); - temp = temp.replace("@", ""); - temp = temp.replace("#", ""); - temp = temp.replace("(", ""); - temp = temp.replace(")", ""); - temp = temp.replace("{", ""); - temp = temp.replace("}", ""); - temp = temp.replace("[", ""); - temp = temp.replace("]", ""); - temp = temp.replace(" ", ""); - output = temp; - return output; - - } - - public static String sanitizeStringKeepBrackets(final String input) { - String temp; - String output; - - temp = input.replace(" ", ""); - temp = temp.replace("-", ""); - temp = temp.replace("_", ""); - temp = temp.replace("?", ""); - temp = temp.replace("!", ""); - temp = temp.replace("@", ""); - temp = temp.replace("#", ""); - temp = temp.replace(" ", ""); - output = temp; - return output; - - } - - public static String[] parseVersion(final String version) { - return parseVersion(version, "//."); - } - - public static String[] parseVersion(final String version, final String delimiter) { - final String[] versionArray = version.split(delimiter); - return versionArray; - } - - public static Versioning compareModVersion(final String currentVersion, final String expectedVersion) { - return compareModVersion(currentVersion, expectedVersion, "//."); - } - - public static Versioning compareModVersion(final String currentVersion, final String expectedVersion, - final String delimiter) { - final String[] a = parseVersion(currentVersion, delimiter); - final String[] b = parseVersion(expectedVersion, delimiter); - final int[] c = new int[a.length]; - final int[] d = new int[b.length]; - for (int r = 0; r < a.length; r++) { - c[r] = Integer.parseInt(a[r]); - } - for (int r = 0; r < b.length; r++) { - d[r] = Integer.parseInt(b[r]); - } - final Versioning[] e = new Versioning[MathUtils.returnLargestNumber(c.length, d.length)]; - for (int r = 0; r < e.length; r++) { - - if (c[r] > d[r]) { - e[r] = Versioning.NEWER; - } else if (c[r] < d[r]) { - e[r] = Versioning.OLDER; - } else if (c[r] == d[r]) { - e[r] = Versioning.EQUAL; - } - } - - for (int r = 0; r < e.length; r++) { - if (e[0] == Versioning.NEWER) { - return Versioning.NEWER; - } else if (e[0] == Versioning.OLDER) { - return Versioning.OLDER; - } else { - if (e[r] == Versioning.OLDER) { - - } - - return Versioning.NEWER; - } - } - - return null; - } - - public static ToolMaterial generateToolMaterialFromGT(final Materials gtMaterial) { - final String name = Utils.sanitizeString(gtMaterial.mDefaultLocalName); - final int harvestLevel = gtMaterial.mToolQuality; - final int durability = gtMaterial.mDurability; - final float damage = gtMaterial.mToolQuality; - final int efficiency = (int) gtMaterial.mToolSpeed; - final int enchantability = gtMaterial.mEnchantmentToolsLevel; - final ToolMaterial temp = EnumHelper.addToolMaterial(name, harvestLevel, durability, efficiency, damage, - enchantability); - return temp; - - } - - public static ToolMaterial generateToolMaterial(final Material material) { - final String name = material.getLocalizedName(); - final int harvestLevel = material.vHarvestLevel; - final int durability = (int) material.vDurability; - final float damage = material.vToolQuality; - final int efficiency = material.vToolQuality; - // int enchantability = material.mEnchantmentToolsLevel; - Logger.INFO("ToolMaterial stats for " + material.getLocalizedName() + " | harvestLevel:" + harvestLevel - + " | durability:" + durability + " | toolQuality:" + damage + " | toolSpeed:" + damage); - final ToolMaterial temp = EnumHelper.addToolMaterial(name, harvestLevel, durability, efficiency, damage, 0); - return temp; - - } - - public static enum Versioning { - EQUAL(0), NEWER(1), OLDER(-1); - private final int versioningInfo; - - private Versioning(final int versionStatus) { - this.versioningInfo = versionStatus; - } - - public int getTexture() { - return this.versioningInfo; - } - } + public static final int WILDCARD_VALUE = Short.MAX_VALUE; + + public static final boolean isServer() { + return FMLCommonHandler.instance().getEffectiveSide().isServer(); + } + + public static final boolean isClient() { + return FMLCommonHandler.instance().getEffectiveSide().isClient(); + } + + static class ShortTimerTask extends TimerTask { + @Override + public void run() { + Logger.WARNING("Timer expired."); + } + } + + public static TC_AspectStack getTcAspectStack(final TC_Aspects aspect, final long size) { + return getTcAspectStack(aspect.name(), (int) size); + } + + public static TC_AspectStack getTcAspectStack(final String aspect, final long size) { + return getTcAspectStack(aspect, (int) size); + } + + public static TC_AspectStack getTcAspectStack(final TC_Aspects aspect, final int size) { + return getTcAspectStack(aspect.name(), size); + } + + public static TC_AspectStack getTcAspectStack(final String aspect, final int size) { + + TC_AspectStack returnValue = null; + + if (aspect.toUpperCase().equals("COGNITIO")) { + // Adds in Compat for older GT Versions which Misspell aspects. + try { + if (EnumUtils.isValidEnum(TC_Aspects.class, "COGNITIO")) { + Logger.WARNING("TC Aspect found - " + aspect); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("COGNITIO"), size); + } else { + Logger.INFO( + "Fallback TC Aspect found - " + aspect + + " - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("COGNITO"), size); + } + } catch (final NoSuchFieldError r) { + Logger.INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); + } + } else if (aspect.toUpperCase().equals("EXANIMUS")) { + // Adds in Compat for older GT Versions which Misspell aspects. + try { + if (EnumUtils.isValidEnum(TC_Aspects.class, "EXANIMUS")) { + Logger.WARNING("TC Aspect found - " + aspect); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("EXANIMUS"), size); + } else { + Logger.INFO( + "Fallback TC Aspect found - " + aspect + + " - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("EXAMINIS"), size); + } + } catch (final NoSuchFieldError r) { + Logger.INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); + } + + } else if (aspect.toUpperCase().equals("PRAECANTATIO")) { + // Adds in Compat for older GT Versions which Misspell aspects. + try { + if (EnumUtils.isValidEnum(TC_Aspects.class, "PRAECANTATIO")) { + Logger.WARNING("TC Aspect found - " + aspect); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("PRAECANTATIO"), size); + } else { + Logger.INFO( + "Fallback TC Aspect found - " + aspect + + " - PLEASE UPDATE GREGTECH TO A NEWER VERSION TO REMOVE THIS MESSAGE - THIS IS NOT AN ERROR"); + returnValue = new TC_AspectStack(TC_Aspects.valueOf("PRAECANTIO"), size); + } + } catch (final NoSuchFieldError r) { + Logger.INFO("Invalid Thaumcraft Aspects - Report this issue to Alkalus"); + } + } else { + Logger.WARNING("TC Aspect found - " + aspect); + returnValue = new TC_AspectStack(TC_Aspects.valueOf(aspect), size); + } + + return returnValue; + } + + public static boolean containsMatch(final boolean strict, final ItemStack[] inputs, final ItemStack... targets) { + for (final ItemStack input : inputs) { + for (final ItemStack target : targets) { + if (itemMatches(target, input, strict)) { + return true; + } + } + } + return false; + } + + public static boolean itemMatches(final ItemStack target, final ItemStack input, final boolean strict) { + if ((input == null) || (target == null)) { + return false; + } + return ((target.getItem() == input.getItem()) + && (((target.getItemDamage() == WILDCARD_VALUE) && !strict) + || (target.getItemDamage() == input.getItemDamage()))); + } + + // Register an event to both busses. + public static void registerEvent(Object o) { + MinecraftForge.EVENT_BUS.register(o); + FMLCommonHandler.instance().bus().register(o); + } + + public static void paintBox(final Graphics g, final int MinA, final int MinB, final int MaxA, final int MaxB) { + g.drawRect(MinA, MinB, MaxA, MaxB); + } + + // Send a message to all players on the server + public static void sendServerMessage(final String translationKey) { + sendServerMessage(new ChatComponentText(translationKey)); + } + + // Send a message to all players on the server + public static void sendServerMessage(final IChatComponent chatComponent) { + MinecraftServer.getServer().getConfigurationManager().sendChatMsg(chatComponent); + } + + /** + * Returns if that Liquid is IC2Steam. + */ + public static boolean isIC2Steam(final FluidStack aFluid) { + if (aFluid == null) { + return false; + } + return aFluid.isFluidEqual(getIC2Steam(1)); + } + + /** + * Returns a Liquid Stack with given amount of IC2Steam. + */ + public static FluidStack getIC2Steam(final long aAmount) { + return FluidRegistry.getFluidStack("ic2steam", (int) aAmount); + } + + /* + * public static void recipeBuilderBlock(ItemStack slot_1, ItemStack slot_2, + * ItemStack slot_3, ItemStack slot_4, ItemStack slot_5, ItemStack slot_6, + * ItemStack slot_7, ItemStack slot_8, ItemStack slot_9, Block resultBlock){ + * GameRegistry.addRecipe(new ItemStack(resultBlock), new Object[] {"ABC", + * "DEF", "GHI", 'A',slot_1,'B',slot_2,'C',slot_3, + * 'D',slot_4,'E',slot_5,'F',slot_6, 'G',slot_7,'H',slot_8,'I',slot_9 }); } + */ + + public static String checkCorrectMiningToolForBlock(final Block currentBlock, final World currentWorld) { + String correctTool = ""; + if (!currentWorld.isRemote) { + try { + correctTool = currentBlock.getHarvestTool(0); + Logger.WARNING(correctTool); + + } catch (final NullPointerException e) { + + } + } + + return correctTool; + } + + /** + * + * @param colourStr + * e.g. "#FFFFFF" + * @return String - formatted "rgb(0,0,0)" + */ + public static String hex2RgbFormatted(final String hexString) { + final Color c = new Color( + Integer.valueOf(hexString.substring(1, 3), 16), + Integer.valueOf(hexString.substring(3, 5), 16), + Integer.valueOf(hexString.substring(5, 7), 16)); + + final StringBuffer sb = new StringBuffer(); + sb.append("rgb("); + sb.append(c.getRed()); + sb.append(","); + sb.append(c.getGreen()); + sb.append(","); + sb.append(c.getBlue()); + sb.append(")"); + return sb.toString(); + } + + /** + * + * @param colourStr + * e.g. "#FFFFFF" + * @return + */ + public static Color hex2Rgb(final String colorStr) { + return new Color( + Integer.valueOf(colorStr.substring(1, 3), 16), + Integer.valueOf(colorStr.substring(3, 5), 16), + Integer.valueOf(colorStr.substring(5, 7), 16)); + } + + /** + * + * @param colourInt + * e.g. 0XFFFFFF + * @return Colour + */ + public static Color hex2Rgb(final int colourInt) { + return Color.decode(String.valueOf(colourInt)); + } + + /** + * + * @param colourInt + * e.g. 0XFFFFFF + * @return short[] + */ + public static short[] hex2RgbShort(final int colourInt) { + final Color rgb = Color.decode(String.valueOf(colourInt)); + final short[] rgba = { + (short) rgb.getRed(), (short) rgb.getGreen(), (short) rgb.getBlue(), (short) rgb.getAlpha() + }; + return rgba; + } + + public static Timer ShortTimer(final int seconds) { + Timer timer; + timer = new Timer(); + timer.schedule(new ShortTimerTask(), seconds * 1000); + return timer; + } + + public static String byteToHex(final byte b) { + final int i = b & 0xFF; + return Integer.toHexString(i); + } + + public static Object[] convertListToArray(final List sourceList) { + final Object[] targetArray = sourceList.toArray(new Object[sourceList.size()]); + return targetArray; + } + + public static List convertArrayToFixedSizeList(final Object[] sourceArray) { + final List targetList = Arrays.asList(sourceArray); + return targetList; + } + + public static List convertArrayToList(final Object[] sourceArray) { + final List targetList = new ArrayList<>(Arrays.asList(sourceArray)); + return targetList; + } + + public static List convertArrayListToList(final ArrayList sourceArray) { + final List targetList = new ArrayList(Arrays.asList(sourceArray)); + return targetList; + } + + public static void spawnCustomParticle(final Entity entity) { + GTplusplus.proxy.generateMysteriousParticles(entity); + } + + public static void spawnFX( + final World world, final int x, final int y, final int z, final String particleName, Object particleName2) { + if (!world.isRemote) { + if ((particleName2 == null) || particleName2.equals("")) { + particleName2 = particleName; + } + final int l = MathUtils.randInt(0, 4); + final double d0 = x + 0.5F; + final double d1 = y + 0.7F; + final double d2 = z + 0.5F; + final double d3 = 0.2199999988079071D; + final double d4 = 0.27000001072883606D; + + if (l == 1) { + world.spawnParticle(particleName, d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); + } else if (l == 2) { + world.spawnParticle((String) particleName2, d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); + } else if (l == 3) { + world.spawnParticle(particleName, d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D); + } else if (l == 4) { + world.spawnParticle((String) particleName2, d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D); + } else { + world.spawnParticle(particleName, d0, d1, d2, 0.0D, 0.0D, 0.0D); + if (particleName2 != null) { + world.spawnParticle((String) particleName2, d0, d1, d2, 0.0D, 0.0D, 0.0D); + } + } + } + } + + public static int rgbtoHexValue(final int r, final int g, final int b) { + if ((r > 255) || (g > 255) || (b > 255) || (r < 0) || (g < 0) || (b < 0)) { + return 0; + } + final Color c = new Color(r, g, b); + String temp = Integer.toHexString(c.getRGB() & 0xFFFFFF).toUpperCase(); + temp = Utils.appenedHexNotationToString(String.valueOf(temp)); + Logger.WARNING("Made " + temp + " - Hopefully it's not a mess."); + Logger.WARNING("It will decode into " + Integer.decode(temp) + "."); + return Integer.decode(temp); + } + + /* + * http://javadevnotes.com/java-left-pad-string-with-zeros-examples + */ + public static String padWithZerosLefts(final String originalString, final int length) { + final StringBuilder sb = new StringBuilder(); + while ((sb.length() + originalString.length()) < length) { + sb.append('0'); + } + sb.append(originalString); + final String paddedString = sb.toString(); + return paddedString; + } + + public static String padWithZerosRight(final int value, final int length) { + String originalString = String.valueOf(value); + final StringBuilder sb = new StringBuilder(); + while ((sb.length() + originalString.length()) < length) { + sb.append('0'); + } + // sb.append(originalString); + if (sb.length() > 0) originalString = (originalString + sb.toString()); + final String paddedString = sb.toString(); + return originalString; + } + + /* + * Original Code by Chandana Napagoda - + * https://cnapagoda.blogspot.com.au/2011/03/java-hex-color-code-generator. + * html + */ + public static Map hexColourGenerator(final int colorCount) { + final int maxColorValue = 16777215; + // this is decimal value of the "FFFFFF" + final int devidedvalue = maxColorValue / colorCount; + int countValue = 0; + final HashMap hexColorMap = new HashMap<>(); + for (int a = 0; (a < colorCount) && (maxColorValue >= countValue); a++) { + if (a != 0) { + countValue += devidedvalue; + hexColorMap.put( + a, + Integer.toHexString(0x10000 | countValue).substring(1).toUpperCase()); + } else { + hexColorMap.put( + a, + Integer.toHexString(0x10000 | countValue).substring(1).toUpperCase()); + } + } + return hexColorMap; + } + + /* + * Original Code by Chandana Napagoda - + * https://cnapagoda.blogspot.com.au/2011/03/java-hex-color-code-generator. + * html + */ + public static Map hexColourGeneratorRandom(final int colorCount) { + final HashMap hexColorMap = new HashMap<>(); + for (int a = 0; a < colorCount; a++) { + String code = "" + (int) (Math.random() * 256); + code = code + code + code; + final int i = Integer.parseInt(code); + hexColorMap.put(a, Integer.toHexString(0x1000000 | i).substring(1).toUpperCase()); + Logger.WARNING("" + Integer.toHexString(0x1000000 | i).substring(1).toUpperCase()); + } + return hexColorMap; + } + + public static String appenedHexNotationToString(final Object hexAsStringOrInt) { + final String hexChar = "0x"; + String result; + if (hexAsStringOrInt.getClass() == String.class) { + + if (((String) hexAsStringOrInt).length() != 6) { + final String temp = padWithZerosLefts((String) hexAsStringOrInt, 6); + result = temp; + } + result = hexChar + hexAsStringOrInt; + return result; + } else if (hexAsStringOrInt.getClass() == Integer.class || hexAsStringOrInt.getClass() == int.class) { + String aa = String.valueOf(hexAsStringOrInt); + if (aa.length() != 6) { + final String temp = padWithZerosLefts(aa, 6); + result = temp; + } else { + result = hexChar + String.valueOf(hexAsStringOrInt); + } + return result; + } else { + return null; + } + } + + public static Integer appenedHexNotationToInteger(final int hexAsStringOrInt) { + final String hexChar = "0x"; + String result; + Logger.WARNING(String.valueOf(hexAsStringOrInt)); + result = hexChar + String.valueOf(hexAsStringOrInt); + return Integer.getInteger(result); + } + + public static boolean doesEntryExistAlreadyInOreDictionary(final String OreDictName) { + if (OreDictionary.getOres(OreDictName).size() != 0) { + return true; + } + return false; + } + + public static boolean invertBoolean(final boolean booleans) { + if (booleans == true) { + return false; + } + return true; + } + + public static File getMcDir() { + if (Utils.isClient()) { + if (Minecraft.getMinecraft() != null) { + return Minecraft.getMinecraft().mcDataDir; + } + } + return new File("."); + } + + private static short cellID = 15; + + public static ItemStack createInternalNameAndFluidCell(final String s) { + Logger.WARNING("1"); + final InternalName yourName = EnumHelper.addEnum(InternalName.class, s, new Class[0], new Object[0]); + Logger.WARNING("2 " + yourName.name()); + final ItemCell item = (ItemCell) Ic2Items.cell.getItem(); + Logger.WARNING("3 " + item.getUnlocalizedName()); + try { + Logger.WARNING("4"); + final Class clz = item.getClass(); + Logger.WARNING("5 " + clz.getSimpleName()); + final Method methode = clz.getDeclaredMethod("addCell", int.class, InternalName.class, Block[].class); + Logger.WARNING("6 " + methode.getName()); + methode.setAccessible(true); + Logger.WARNING("7 " + methode.isAccessible()); + final ItemStack temp = (ItemStack) methode.invoke(item, cellID++, yourName, new Block[0]); + Logger.WARNING("Successfully created " + temp.getDisplayName() + "s."); + FluidContainerRegistry.registerFluidContainer( + FluidUtils.getFluidStack(s.toLowerCase(), 1000), temp.copy(), Ic2Items.cell.copy()); + ItemUtils.addItemToOreDictionary(temp.copy(), "cell" + s); + return temp; + } catch (final Exception e) { + e.printStackTrace(); + } + return null; + } + + public static ItemStack createInternalNameAndFluidCellNoOreDict(final String s) { + Logger.WARNING("1"); + final InternalName yourName = EnumHelper.addEnum(InternalName.class, s, new Class[0], new Object[0]); + Logger.WARNING("2 " + yourName.name()); + final ItemCell item = (ItemCell) Ic2Items.cell.getItem(); + Logger.WARNING("3 " + item.getUnlocalizedName()); + try { + Logger.WARNING("4"); + final Class clz = item.getClass(); + Logger.WARNING("5 " + clz.getSimpleName()); + final Method methode = clz.getDeclaredMethod("addCell", int.class, InternalName.class, Block[].class); + Logger.WARNING("6 " + methode.getName()); + methode.setAccessible(true); + Logger.WARNING("7 " + methode.isAccessible()); + final ItemStack temp = (ItemStack) methode.invoke(item, cellID++, yourName, new Block[0]); + Logger.WARNING("Successfully created " + temp.getDisplayName() + "s."); + FluidContainerRegistry.registerFluidContainer( + FluidUtils.getFluidStack(s.toLowerCase(), 1000), temp.copy(), Ic2Items.cell.copy()); + // ItemUtils.addItemToOreDictionary(temp.copy(), "cell"+s); + return temp; + } catch (final Exception e) { + e.printStackTrace(); + } + return null; + } + + public static String sanitizeString(final String input, final char[] aDontRemove) { + + String output; + AutoMap aToRemoveMap = new AutoMap(); + + aToRemoveMap.put(" "); + aToRemoveMap.put("-"); + aToRemoveMap.put("_"); + aToRemoveMap.put("~"); + aToRemoveMap.put("?"); + aToRemoveMap.put("!"); + aToRemoveMap.put("@"); + aToRemoveMap.put("#"); + aToRemoveMap.put("$"); + aToRemoveMap.put("%"); + aToRemoveMap.put("^"); + aToRemoveMap.put("&"); + aToRemoveMap.put("*"); + aToRemoveMap.put("("); + aToRemoveMap.put(")"); + aToRemoveMap.put("{"); + aToRemoveMap.put("}"); + aToRemoveMap.put("["); + aToRemoveMap.put("]"); + aToRemoveMap.put(" "); + + for (String s : aToRemoveMap) { + for (char e : aDontRemove) { + if (s.charAt(0) == e) { + aToRemoveMap.remove("s"); + } + } + } + output = input; + for (String A : aToRemoveMap) { + output = output.replace(A, ""); + } + return output; + } + + public static String sanitizeString(final String input) { + String temp; + String output; + + temp = input.replace(" ", ""); + temp = temp.replace("-", ""); + temp = temp.replace("_", ""); + temp = temp.replace("?", ""); + temp = temp.replace("!", ""); + temp = temp.replace("@", ""); + temp = temp.replace("#", ""); + temp = temp.replace("(", ""); + temp = temp.replace(")", ""); + temp = temp.replace("{", ""); + temp = temp.replace("}", ""); + temp = temp.replace("[", ""); + temp = temp.replace("]", ""); + temp = temp.replace(" ", ""); + output = temp; + return output; + } + + public static String sanitizeStringKeepBrackets(final String input) { + String temp; + String output; + + temp = input.replace(" ", ""); + temp = temp.replace("-", ""); + temp = temp.replace("_", ""); + temp = temp.replace("?", ""); + temp = temp.replace("!", ""); + temp = temp.replace("@", ""); + temp = temp.replace("#", ""); + temp = temp.replace(" ", ""); + output = temp; + return output; + } + + public static String[] parseVersion(final String version) { + return parseVersion(version, "//."); + } + + public static String[] parseVersion(final String version, final String delimiter) { + final String[] versionArray = version.split(delimiter); + return versionArray; + } + + public static Versioning compareModVersion(final String currentVersion, final String expectedVersion) { + return compareModVersion(currentVersion, expectedVersion, "//."); + } + + public static Versioning compareModVersion( + final String currentVersion, final String expectedVersion, final String delimiter) { + final String[] a = parseVersion(currentVersion, delimiter); + final String[] b = parseVersion(expectedVersion, delimiter); + final int[] c = new int[a.length]; + final int[] d = new int[b.length]; + for (int r = 0; r < a.length; r++) { + c[r] = Integer.parseInt(a[r]); + } + for (int r = 0; r < b.length; r++) { + d[r] = Integer.parseInt(b[r]); + } + final Versioning[] e = new Versioning[MathUtils.returnLargestNumber(c.length, d.length)]; + for (int r = 0; r < e.length; r++) { + + if (c[r] > d[r]) { + e[r] = Versioning.NEWER; + } else if (c[r] < d[r]) { + e[r] = Versioning.OLDER; + } else if (c[r] == d[r]) { + e[r] = Versioning.EQUAL; + } + } + + for (int r = 0; r < e.length; r++) { + if (e[0] == Versioning.NEWER) { + return Versioning.NEWER; + } else if (e[0] == Versioning.OLDER) { + return Versioning.OLDER; + } else { + if (e[r] == Versioning.OLDER) {} + + return Versioning.NEWER; + } + } + + return null; + } + + public static ToolMaterial generateToolMaterialFromGT(final Materials gtMaterial) { + final String name = Utils.sanitizeString(gtMaterial.mDefaultLocalName); + final int harvestLevel = gtMaterial.mToolQuality; + final int durability = gtMaterial.mDurability; + final float damage = gtMaterial.mToolQuality; + final int efficiency = (int) gtMaterial.mToolSpeed; + final int enchantability = gtMaterial.mEnchantmentToolsLevel; + final ToolMaterial temp = + EnumHelper.addToolMaterial(name, harvestLevel, durability, efficiency, damage, enchantability); + return temp; + } + + public static ToolMaterial generateToolMaterial(final Material material) { + final String name = material.getLocalizedName(); + final int harvestLevel = material.vHarvestLevel; + final int durability = (int) material.vDurability; + final float damage = material.vToolQuality; + final int efficiency = material.vToolQuality; + // int enchantability = material.mEnchantmentToolsLevel; + Logger.INFO("ToolMaterial stats for " + material.getLocalizedName() + " | harvestLevel:" + harvestLevel + + " | durability:" + durability + " | toolQuality:" + damage + " | toolSpeed:" + damage); + final ToolMaterial temp = EnumHelper.addToolMaterial(name, harvestLevel, durability, efficiency, damage, 0); + return temp; + } + + public static enum Versioning { + EQUAL(0), + NEWER(1), + OLDER(-1); + private final int versioningInfo; + + private Versioning(final int versionStatus) { + this.versioningInfo = versionStatus; + } + + public int getTexture() { + return this.versioningInfo; + } + } public static String addBookTitleLocalization(final String aTitle) { return GT_LanguageManager.addStringLocalization( - new StringBuilder().append("Book.").append(aTitle).append(".Name").toString(), aTitle, !GregTech_API.sPostloadFinished); + new StringBuilder() + .append("Book.") + .append(aTitle) + .append(".Name") + .toString(), + aTitle, + !GregTech_API.sPostloadFinished); } public static String[] addBookPagesLocalization(final String aTitle, final String[] aPages) { String[] aLocalizationPages = new String[aPages.length]; for (byte i = 0; i < aPages.length; i = (byte) (i + 1)) { - aLocalizationPages[i] = GT_LanguageManager - .addStringLocalization(new StringBuilder().append("Book.").append(aTitle).append(".Page") - .append((i < 10) ? new StringBuilder().append("0").append(i).toString() : Byte.valueOf(i)) - .toString(), aPages[i], !GregTech_API.sPostloadFinished); + aLocalizationPages[i] = GT_LanguageManager.addStringLocalization( + new StringBuilder() + .append("Book.") + .append(aTitle) + .append(".Page") + .append( + (i < 10) + ? new StringBuilder() + .append("0") + .append(i) + .toString() + : Byte.valueOf(i)) + .toString(), + aPages[i], + !GregTech_API.sPostloadFinished); } return aLocalizationPages; } - public static ItemStack getWrittenBook(final ItemStack aBook, final int aID, final String aMapping, final String aTitle, final String aAuthor, - final String[] aPages) { - if (GT_Utility.isStringInvalid(aMapping)) { - return null; - } - ItemStack rStack = CORE.sBookList.get(aMapping); - if (rStack != null) { - return GT_Utility.copyAmount(1L, new Object[] { rStack }); - } - if ((GT_Utility.isStringInvalid(aTitle)) || (GT_Utility.isStringInvalid(aAuthor)) || (aPages.length <= 0)) { - return null; - } - final int vMeta = aID; - rStack = (aBook == null ? new ItemStack(ModItems.itemCustomBook, 1, vMeta) : aBook); - final NBTTagCompound tNBT = new NBTTagCompound(); + public static ItemStack getWrittenBook( + final ItemStack aBook, + final int aID, + final String aMapping, + final String aTitle, + final String aAuthor, + final String[] aPages) { + if (GT_Utility.isStringInvalid(aMapping)) { + return null; + } + ItemStack rStack = CORE.sBookList.get(aMapping); + if (rStack != null) { + return GT_Utility.copyAmount(1L, new Object[] {rStack}); + } + if ((GT_Utility.isStringInvalid(aTitle)) || (GT_Utility.isStringInvalid(aAuthor)) || (aPages.length <= 0)) { + return null; + } + final int vMeta = aID; + rStack = (aBook == null ? new ItemStack(ModItems.itemCustomBook, 1, vMeta) : aBook); + final NBTTagCompound tNBT = new NBTTagCompound(); String localizationTitle = addBookTitleLocalization(aTitle); - tNBT.setString("title", localizationTitle); - tNBT.setString("author", aAuthor); - final NBTTagList tNBTList = new NBTTagList(); + tNBT.setString("title", localizationTitle); + tNBT.setString("author", aAuthor); + final NBTTagList tNBTList = new NBTTagList(); final String[] aLocalizationPages = addBookPagesLocalization(aTitle, aPages); for (byte i = 0; i < aPages.length; i = (byte) (i + 1)) { - aPages[i] = aLocalizationPages[i].replaceAll("
", "\n"); - if (i < 48) { - if (aPages[i].length() < 256) { - tNBTList.appendTag(new NBTTagString(aPages[i])); - } - else { - Logger.INFO("WARNING: String for written Book too long! -> "+aPages[i]); - GT_Log.err.println(new StringBuilder().append("WARNING: String for written Book too long! -> ") - .append(aPages[i]).toString()); - } - } else { - Logger.INFO("WARNING: Too much Pages for written Book! -> "+aTitle); - GT_Log.err.println(new StringBuilder().append("WARNING: Too much Pages for written Book! -> ") - .append(aTitle).toString()); - break; - } - } - tNBTList.appendTag(new NBTTagString(new StringBuilder().append("Credits to ").append(aAuthor) - .append(" for writing this Book. This was Book Nr. ").append(aID) - .append(" at its creation. Gotta get 'em all!").toString())); - tNBT.setTag("pages", tNBTList); - rStack.setTagCompound(tNBT); - GT_Log.out.println(new StringBuilder().append("GT++_Mod: Added Book to Book++ List - Mapping: '") - .append(aMapping).append("' - Name: '").append(aTitle).append("' - Author: '").append(aAuthor) - .append("'").toString()); - NBTUtils.createIntegerTagCompound(rStack, "stats", "mMeta", vMeta); - CORE.sBookList.put(aMapping, rStack); - Logger.INFO("Creating book: " + aTitle + " by " + aAuthor + ". Using Meta " + vMeta + "."); - return GT_Utility.copy(new Object[] { rStack }); - } - - @SuppressWarnings({ "unused", "unchecked" }) - public static Pair getGregtechVersion(){ - Pair version; - if (GT_Mod.VERSION == 509){ - Class clazz; - try { - - if (LoadedMods.BeyondRealityCore) { - //Safely assume it's Beyond Reality running .28-pre (If it's not, tough shit really?) - return new Pair(9, 28); - } - - clazz = (Class) ReflectionUtils.getClass("gregtech.GT_Mod"); - Field mSubversion = ReflectionUtils.getField(clazz, "SUBVERSION"); - if (mSubversion != null){ - int mSub = 0; - mSub = mSubversion.getInt(clazz); - if (mSub != 0){ - version = new Pair(9, mSub); - return version; - } - } - } - catch (Throwable t){ - - } - } - //5.08.33 - else if (GT_Mod.VERSION == 508){ - version = new Pair(8, 33); - return version; - - } - //5.07.07 - else if (GT_Mod.VERSION == 507){ - version = new Pair(7, 7); - return version; - - } - //Returb Bad Value - version = new Pair(0, 0); - return version; - } - - public static int getGregtechVersionAsInt(){ - Pair ver = getGregtechVersion(); - return 50000+(ver.getKey()*100)+(ver.getValue()); - } - - public static String getGregtechVersionAsString(){ - Pair ver = getGregtechVersion(); - return "5."+ver.getKey()+"."+ver.getValue(); - } - - public static int getGregtechSubVersion(){ - Pair ver = getGregtechVersion(); - return ver.getValue(); - } - - public static SecureRandom generateSecureRandom(){ - SecureRandom secRan; - String secRanType; - - if (SystemUtils.isWindows()){ - secRanType = "Windows-PRNG"; - } - else { - secRanType = "NativePRNG"; - } - try { - secRan = SecureRandom.getInstance(secRanType); - // Default constructor would have returned insecure SHA1PRNG algorithm, so make an explicit call. - byte[] b = new byte[64] ; - secRan.nextBytes(b); - return secRan; - } - catch (NoSuchAlgorithmException e) { - return null; - } - } - - - public static String calculateChecksumMD5(Object bytes) { - byte[] result = new byte[] {}; - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - ObjectOutput out = null; - try { - out = new ObjectOutputStream(bos); - out.writeObject(bytes); - out.flush(); - result = bos.toByteArray(); - } - catch (IOException e) { - } finally { - try { - bos.close(); - } - catch (IOException e) {} - } - return calculateChecksumMD5(result); - } - - public static String calculateChecksumMD5(byte[] bytes) { - MessageDigest md; - try { - md = MessageDigest.getInstance("MD5"); - md.update(bytes); - byte[] digest = md.digest(); - String myHash = DatatypeConverter.printHexBinary(digest).toUpperCase(); - return myHash; - } - catch (NoSuchAlgorithmException e) { - return null; - } - } - - public static boolean createNewMobSpawner(int aID, Entity aEntity) { - if (aEntity instanceof Entity) { - Class c = aEntity.getClass(); - return createNewMobSpawner(aID, c); - } - return false; - } - - public static boolean createNewMobSpawner(int aID, Class aEntity) { - Logger.INFO("[Spawn] Generating new spawner for entity with class ("+aEntity.getSimpleName()+")."); - if (TileEntityGenericSpawner.registerNewMobSpawner(aID, (Class) aEntity)) { - EntityRegistration x = EntityRegistry.instance().lookupModSpawn((Class) aEntity, true); - if (x != null) { - Logger.INFO("[Spawn] Registration for "+x.getEntityName()+" successful"); - return true; - } - else { - Logger.INFO("[Spawn] Registration for "+aEntity.getSimpleName()+" successful"); - return true; - } - } - Logger.INFO("[Spawn] Mob Spawner creation for "+aEntity.getName()+" failed"); - return false; - } - - public static long getMillisSince(long aStartTime, long aCurrentTime) { - return (aCurrentTime - aStartTime); - } - - public static long getSecondsFromMillis(long aMillis) { - return (aMillis/1000); - } - - public static long getTicksFromSeconds(long aSeconds) { - return (aSeconds*20); - } - - public static byte getTier(long l) { - byte i = -1; - do { - ++i; - if (i >= GT_Values.V.length) { - return i; - } - } while (l > GT_Values.V[i]); - i = (byte) MathUtils.getValueWithinRange(i, 0, 15); - return i; - } + aPages[i] = aLocalizationPages[i].replaceAll("
", "\n"); + if (i < 48) { + if (aPages[i].length() < 256) { + tNBTList.appendTag(new NBTTagString(aPages[i])); + } else { + Logger.INFO("WARNING: String for written Book too long! -> " + aPages[i]); + GT_Log.err.println(new StringBuilder() + .append("WARNING: String for written Book too long! -> ") + .append(aPages[i]) + .toString()); + } + } else { + Logger.INFO("WARNING: Too much Pages for written Book! -> " + aTitle); + GT_Log.err.println(new StringBuilder() + .append("WARNING: Too much Pages for written Book! -> ") + .append(aTitle) + .toString()); + break; + } + } + tNBTList.appendTag(new NBTTagString(new StringBuilder() + .append("Credits to ") + .append(aAuthor) + .append(" for writing this Book. This was Book Nr. ") + .append(aID) + .append(" at its creation. Gotta get 'em all!") + .toString())); + tNBT.setTag("pages", tNBTList); + rStack.setTagCompound(tNBT); + GT_Log.out.println(new StringBuilder() + .append("GT++_Mod: Added Book to Book++ List - Mapping: '") + .append(aMapping) + .append("' - Name: '") + .append(aTitle) + .append("' - Author: '") + .append(aAuthor) + .append("'") + .toString()); + NBTUtils.createIntegerTagCompound(rStack, "stats", "mMeta", vMeta); + CORE.sBookList.put(aMapping, rStack); + Logger.INFO("Creating book: " + aTitle + " by " + aAuthor + ". Using Meta " + vMeta + "."); + return GT_Utility.copy(new Object[] {rStack}); + } + + @SuppressWarnings({"unused", "unchecked"}) + public static Pair getGregtechVersion() { + Pair version; + if (GT_Mod.VERSION == 509) { + Class clazz; + try { + + if (LoadedMods.BeyondRealityCore) { + // Safely assume it's Beyond Reality running .28-pre (If it's not, tough shit really?) + return new Pair(9, 28); + } + + clazz = (Class) ReflectionUtils.getClass("gregtech.GT_Mod"); + Field mSubversion = ReflectionUtils.getField(clazz, "SUBVERSION"); + if (mSubversion != null) { + int mSub = 0; + mSub = mSubversion.getInt(clazz); + if (mSub != 0) { + version = new Pair(9, mSub); + return version; + } + } + } catch (Throwable t) { + + } + } + // 5.08.33 + else if (GT_Mod.VERSION == 508) { + version = new Pair(8, 33); + return version; + + } + // 5.07.07 + else if (GT_Mod.VERSION == 507) { + version = new Pair(7, 7); + return version; + } + // Returb Bad Value + version = new Pair(0, 0); + return version; + } + + public static int getGregtechVersionAsInt() { + Pair ver = getGregtechVersion(); + return 50000 + (ver.getKey() * 100) + (ver.getValue()); + } + + public static String getGregtechVersionAsString() { + Pair ver = getGregtechVersion(); + return "5." + ver.getKey() + "." + ver.getValue(); + } + + public static int getGregtechSubVersion() { + Pair ver = getGregtechVersion(); + return ver.getValue(); + } + + public static SecureRandom generateSecureRandom() { + SecureRandom secRan; + String secRanType; + + if (SystemUtils.isWindows()) { + secRanType = "Windows-PRNG"; + } else { + secRanType = "NativePRNG"; + } + try { + secRan = SecureRandom.getInstance(secRanType); + // Default constructor would have returned insecure SHA1PRNG algorithm, so make an explicit call. + byte[] b = new byte[64]; + secRan.nextBytes(b); + return secRan; + } catch (NoSuchAlgorithmException e) { + return null; + } + } + + public static String calculateChecksumMD5(Object bytes) { + byte[] result = new byte[] {}; + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ObjectOutput out = null; + try { + out = new ObjectOutputStream(bos); + out.writeObject(bytes); + out.flush(); + result = bos.toByteArray(); + } catch (IOException e) { + } finally { + try { + bos.close(); + } catch (IOException e) { + } + } + return calculateChecksumMD5(result); + } + + public static String calculateChecksumMD5(byte[] bytes) { + MessageDigest md; + try { + md = MessageDigest.getInstance("MD5"); + md.update(bytes); + byte[] digest = md.digest(); + String myHash = DatatypeConverter.printHexBinary(digest).toUpperCase(); + return myHash; + } catch (NoSuchAlgorithmException e) { + return null; + } + } + public static boolean createNewMobSpawner(int aID, Entity aEntity) { + if (aEntity instanceof Entity) { + Class c = aEntity.getClass(); + return createNewMobSpawner(aID, c); + } + return false; + } + + public static boolean createNewMobSpawner(int aID, Class aEntity) { + Logger.INFO("[Spawn] Generating new spawner for entity with class (" + aEntity.getSimpleName() + ")."); + if (TileEntityGenericSpawner.registerNewMobSpawner(aID, (Class) aEntity)) { + EntityRegistration x = EntityRegistry.instance().lookupModSpawn((Class) aEntity, true); + if (x != null) { + Logger.INFO("[Spawn] Registration for " + x.getEntityName() + " successful"); + return true; + } else { + Logger.INFO("[Spawn] Registration for " + aEntity.getSimpleName() + " successful"); + return true; + } + } + Logger.INFO("[Spawn] Mob Spawner creation for " + aEntity.getName() + " failed"); + return false; + } + + public static long getMillisSince(long aStartTime, long aCurrentTime) { + return (aCurrentTime - aStartTime); + } + + public static long getSecondsFromMillis(long aMillis) { + return (aMillis / 1000); + } + + public static long getTicksFromSeconds(long aSeconds) { + return (aSeconds * 20); + } + + public static byte getTier(long l) { + byte i = -1; + do { + ++i; + if (i >= GT_Values.V.length) { + return i; + } + } while (l > GT_Values.V[i]); + i = (byte) MathUtils.getValueWithinRange(i, 0, 15); + return i; + } } diff --git a/src/main/java/gtPlusPlus/core/util/data/AES.java b/src/main/java/gtPlusPlus/core/util/data/AES.java index 1183cdd8e7..e782a48148 100644 --- a/src/main/java/gtPlusPlus/core/util/data/AES.java +++ b/src/main/java/gtPlusPlus/core/util/data/AES.java @@ -1 +1,153 @@ -\u0070\u0061\u0063\u006b\u0061\u0067\u0065\u0020\u0067\u0074\u0050\u006c\u0075\u0073\u0050\u006c\u0075\u0073\u002e\u0063\u006f\u0072\u0065\u002e\u0075\u0074\u0069\u006c\u002e\u0064\u0061\u0074\u0061\u003b\u000d\u000a\u0069\u006d\u0070\u006f\u0072\u0074\u0020\u006a\u0061\u0076\u0061\u002e\u0069\u006f\u002e\u0055\u006e\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u003b\u000d\u000a\u0069\u006d\u0070\u006f\u0072\u0074\u0020\u006a\u0061\u0076\u0061\u002e\u006d\u0061\u0074\u0068\u002e\u0042\u0069\u0067\u0049\u006e\u0074\u0065\u0067\u0065\u0072\u003b\u000d\u000a\u0069\u006d\u0070\u006f\u0072\u0074\u0020\u006a\u0061\u0076\u0061\u002e\u006e\u0069\u006f\u002e\u0063\u0068\u0061\u0072\u0073\u0065\u0074\u002e\u0053\u0074\u0061\u006e\u0064\u0061\u0072\u0064\u0043\u0068\u0061\u0072\u0073\u0065\u0074\u0073\u003b\u000d\u000a\u0069\u006d\u0070\u006f\u0072\u0074\u0020\u006a\u0061\u0076\u0061\u002e\u0073\u0065\u0063\u0075\u0072\u0069\u0074\u0079\u002e\u004d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u003b\u000d\u000a\u0069\u006d\u0070\u006f\u0072\u0074\u0020\u006a\u0061\u0076\u0061\u002e\u0073\u0065\u0063\u0075\u0072\u0069\u0074\u0079\u002e\u004e\u006f\u0053\u0075\u0063\u0068\u0041\u006c\u0067\u006f\u0072\u0069\u0074\u0068\u006d\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u003b\u000d\u000a\u0069\u006d\u0070\u006f\u0072\u0074\u0020\u006a\u0061\u0076\u0061\u002e\u0075\u0074\u0069\u006c\u002e\u0041\u0072\u0072\u0061\u0079\u0073\u003b\u000d\u000a\u0069\u006d\u0070\u006f\u0072\u0074\u0020\u006a\u0061\u0076\u0061\u002e\u0075\u0074\u0069\u006c\u002e\u0042\u0061\u0073\u0065\u0036\u0034\u003b\u000d\u000a\u0069\u006d\u0070\u006f\u0072\u0074\u0020\u006a\u0061\u0076\u0061\u0078\u002e\u0063\u0072\u0079\u0070\u0074\u006f\u002e\u0043\u0069\u0070\u0068\u0065\u0072\u003b\u000d\u000a\u0069\u006d\u0070\u006f\u0072\u0074\u0020\u006a\u0061\u0076\u0061\u0078\u002e\u0063\u0072\u0079\u0070\u0074\u006f\u002e\u0073\u0070\u0065\u0063\u002e\u0053\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0053\u0070\u0065\u0063\u003b\u000d\u000a\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0063\u006c\u0061\u0073\u0073\u0020\u0041\u0045\u0053\u0020\u007b\u000d\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0073\u0065\u0063\u0072\u0065\u0074\u003b\u003b\u000d\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0053\u0070\u0065\u0063\u0020\u0073\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u003b\u000d\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u006b\u0065\u0079\u003b\u0009\u000d\u000a\u0009\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0041\u0045\u0053\u0028\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0074\u0068\u0069\u0073\u0028\u0022\u0044\u0061\u0072\u006b\u006e\u0065\u0073\u0073\u0020\u0049\u006e\u0020\u0054\u0068\u0065\u0069\u0072\u0020\u0048\u0065\u0061\u0072\u0074\u0073\u0022\u0029\u003b\u0009\u0009\u000d\u000a\u0009\u007d\u0009\u000d\u000a\u0009\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0041\u0045\u0053\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0061\u0053\u0065\u0063\u0072\u0065\u0074\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0073\u0065\u0063\u0072\u0065\u0074\u0020\u003d\u0020\u0061\u0053\u0065\u0063\u0072\u0065\u0074\u003b\u000d\u000a\u0009\u0009\u006b\u0065\u0079\u0020\u003d\u0020\u0067\u0065\u0074\u0042\u0079\u0074\u0065\u0073\u0028\u0067\u0065\u0074\u0048\u0061\u0073\u0068\u0065\u0064\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0073\u0065\u0063\u0072\u0065\u0074\u0029\u0029\u003b\u000d\u000a\u0009\u0009\u0073\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0020\u003d\u0020\u0067\u0065\u006e\u0065\u0072\u0061\u0074\u0065\u004b\u0065\u0079\u0028\u006b\u0065\u0079\u0029\u003b\u000d\u000a\u0009\u007d\u000d\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0067\u0065\u0074\u0048\u0061\u0073\u0068\u0065\u0064\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0061\u0053\u0074\u0072\u0069\u006e\u0067\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0074\u006f\u0048\u0065\u0078\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0067\u0065\u0074\u0053\u0048\u0041\u0028\u0061\u0053\u0074\u0072\u0069\u006e\u0067\u0029\u0029\u003b\u000d\u000a\u0009\u007d\u000d\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u0067\u0065\u0074\u0053\u0048\u0041\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0069\u006e\u0070\u0075\u0074\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u004d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u0020\u006d\u0064\u003b\u000d\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u006d\u0064\u0020\u003d\u0020\u004d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0022\u0053\u0048\u0041\u002d\u0032\u0035\u0036\u0022\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u006d\u0064\u002e\u0064\u0069\u0067\u0065\u0073\u0074\u0028\u0069\u006e\u0070\u0075\u0074\u002e\u0067\u0065\u0074\u0042\u0079\u0074\u0065\u0073\u0028\u0053\u0074\u0061\u006e\u0064\u0061\u0072\u0064\u0043\u0068\u0061\u0072\u0073\u0065\u0074\u0073\u002e\u0055\u0054\u0046\u005f\u0038\u0029\u0029\u003b\u000d\u000a\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u004e\u006f\u0053\u0075\u0063\u0068\u0041\u006c\u0067\u006f\u0072\u0069\u0074\u0068\u006d\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u0065\u002e\u0070\u0072\u0069\u006e\u0074\u0053\u0074\u0061\u0063\u006b\u0054\u0072\u0061\u0063\u0065\u0028\u0029\u003b\u000d\u000a\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u006e\u0065\u0077\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u007b\u007d\u003b\u000d\u000a\u0009\u007d\u000d\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0074\u006f\u0048\u0065\u0078\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u0068\u0061\u0073\u0068\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0042\u0069\u0067\u0049\u006e\u0074\u0065\u0067\u0065\u0072\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0042\u0069\u0067\u0049\u006e\u0074\u0065\u0067\u0065\u0072\u0028\u0031\u002c\u0020\u0068\u0061\u0073\u0068\u0029\u003b\u000d\u000a\u0009\u0009\u0053\u0074\u0072\u0069\u006e\u0067\u0042\u0075\u0069\u006c\u0064\u0065\u0072\u0020\u0068\u0065\u0078\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0042\u0075\u0069\u006c\u0064\u0065\u0072\u0028\u006e\u0075\u006d\u0062\u0065\u0072\u002e\u0074\u006f\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0031\u0036\u0029\u0029\u003b\u000d\u000a\u0009\u0009\u0077\u0068\u0069\u006c\u0065\u0020\u0028\u0068\u0065\u0078\u0053\u0074\u0072\u0069\u006e\u0067\u002e\u006c\u0065\u006e\u0067\u0074\u0068\u0028\u0029\u0020\u003c\u0020\u0033\u0032\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u0068\u0065\u0078\u0053\u0074\u0072\u0069\u006e\u0067\u002e\u0069\u006e\u0073\u0065\u0072\u0074\u0028\u0030\u002c\u0020\u0027\u0030\u0027\u0029\u003b\u000d\u000a\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0068\u0065\u0078\u0053\u0074\u0072\u0069\u006e\u0067\u002e\u0074\u006f\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0029\u003b\u000d\u000a\u0009\u007d\u000d\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u0067\u0065\u0074\u0042\u0079\u0074\u0065\u0073\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0061\u004b\u0065\u0079\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u0061\u004b\u0065\u0079\u0044\u0061\u0074\u0061\u003b\u000d\u000a\u0009\u0009\u004d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u0020\u0073\u0068\u0061\u003b\u000d\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u0073\u0068\u0061\u0020\u003d\u0020\u004d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0022\u0053\u0048\u0041\u002d\u0032\u0035\u0036\u0022\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0073\u0068\u0061\u002e\u0064\u0069\u0067\u0065\u0073\u0074\u0028\u0061\u004b\u0065\u0079\u002e\u0067\u0065\u0074\u0042\u0079\u0074\u0065\u0073\u0028\u0053\u0074\u0061\u006e\u0064\u0061\u0072\u0064\u0043\u0068\u0061\u0072\u0073\u0065\u0074\u0073\u002e\u0055\u0054\u0046\u005f\u0038\u0029\u0029\u003b\u0020\u000d\u000a\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u004e\u006f\u0053\u0075\u0063\u0068\u0041\u006c\u0067\u006f\u0072\u0069\u0074\u0068\u006d\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0031\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u0065\u0031\u002e\u0070\u0072\u0069\u006e\u0074\u0053\u0074\u0061\u0063\u006b\u0054\u0072\u0061\u0063\u0065\u0028\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u0009\u0061\u004b\u0065\u0079\u0044\u0061\u0074\u0061\u0020\u003d\u0020\u0061\u004b\u0065\u0079\u002e\u0067\u0065\u0074\u0042\u0079\u0074\u0065\u0073\u0028\u0022\u0055\u0054\u0046\u002d\u0038\u0022\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0009\u0073\u0068\u0061\u0020\u003d\u0020\u004d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0022\u0053\u0048\u0041\u002d\u0031\u0022\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0009\u0061\u004b\u0065\u0079\u0044\u0061\u0074\u0061\u0020\u003d\u0020\u0073\u0068\u0061\u002e\u0064\u0069\u0067\u0065\u0073\u0074\u0028\u006b\u0065\u0079\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0009\u0061\u004b\u0065\u0079\u0044\u0061\u0074\u0061\u0020\u003d\u0020\u0041\u0072\u0072\u0061\u0079\u0073\u002e\u0063\u006f\u0070\u0079\u004f\u0066\u0028\u006b\u0065\u0079\u002c\u0020\u0031\u0036\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0061\u004b\u0065\u0079\u0044\u0061\u0074\u0061\u003b\u000d\u000a\u0009\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0009\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u004e\u006f\u0053\u0075\u0063\u0068\u0041\u006c\u0067\u006f\u0072\u0069\u0074\u0068\u006d\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u0009\u0065\u002e\u0070\u0072\u0069\u006e\u0074\u0053\u0074\u0061\u0063\u006b\u0054\u0072\u0061\u0063\u0065\u0028\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0009\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0055\u006e\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u0009\u0065\u002e\u0070\u0072\u0069\u006e\u0074\u0053\u0074\u0061\u0063\u006b\u0054\u0072\u0061\u0063\u0065\u0028\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u007d\u0009\u0009\u000d\u000a\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u006e\u0065\u0077\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u007b\u007d\u003b\u000d\u000a\u0009\u007d\u000d\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0053\u0070\u0065\u0063\u0020\u0067\u0065\u006e\u0065\u0072\u0061\u0074\u0065\u004b\u0065\u0079\u0028\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u0061\u004b\u0065\u0079\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u006e\u0065\u0077\u0020\u0053\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0053\u0070\u0065\u0063\u0028\u0061\u004b\u0065\u0079\u002c\u0020\u0022\u0041\u0045\u0053\u0022\u0029\u003b\u000d\u000a\u0009\u007d\u000d\u000a\u0009\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0065\u006e\u0063\u006f\u0064\u0065\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0073\u0074\u0072\u0054\u006f\u0045\u006e\u0063\u0072\u0079\u0070\u0074\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u0043\u0069\u0070\u0068\u0065\u0072\u0020\u0063\u0069\u0070\u0068\u0065\u0072\u0020\u003d\u0020\u0043\u0069\u0070\u0068\u0065\u0072\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0022\u0041\u0045\u0053\u002f\u0045\u0043\u0042\u002f\u0050\u004b\u0043\u0053\u0035\u0050\u0061\u0064\u0064\u0069\u006e\u0067\u0022\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0063\u0069\u0070\u0068\u0065\u0072\u002e\u0069\u006e\u0069\u0074\u0028\u0043\u0069\u0070\u0068\u0065\u0072\u002e\u0045\u004e\u0043\u0052\u0059\u0050\u0054\u005f\u004d\u004f\u0044\u0045\u002c\u0020\u0073\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0042\u0061\u0073\u0065\u0036\u0034\u002e\u0067\u0065\u0074\u0045\u006e\u0063\u006f\u0064\u0065\u0072\u0028\u0029\u002e\u0065\u006e\u0063\u006f\u0064\u0065\u0054\u006f\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0063\u0069\u0070\u0068\u0065\u0072\u002e\u0064\u006f\u0046\u0069\u006e\u0061\u006c\u0028\u0073\u0074\u0072\u0054\u006f\u0045\u006e\u0063\u0072\u0079\u0070\u0074\u002e\u0067\u0065\u0074\u0042\u0079\u0074\u0065\u0073\u0028\u0022\u0055\u0054\u0046\u002d\u0038\u0022\u0029\u0029\u0029\u003b\u000d\u000a\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u0053\u0079\u0073\u0074\u0065\u006d\u002e\u006f\u0075\u0074\u002e\u0070\u0072\u0069\u006e\u0074\u006c\u006e\u0028\u0022\u0045\u0072\u0072\u006f\u0072\u0020\u0077\u0068\u0069\u006c\u0065\u0020\u0065\u006e\u0063\u0072\u0079\u0070\u0074\u0069\u006e\u0067\u003a\u0020\u0022\u0020\u002b\u0020\u0065\u002e\u0074\u006f\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0029\u0029\u003b\u000d\u000a\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u006e\u0075\u006c\u006c\u003b\u000d\u000a\u0009\u007d\u000d\u000a\u0009\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0064\u0065\u0063\u006f\u0064\u0065\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0073\u0074\u0072\u0054\u006f\u0044\u0065\u0063\u0072\u0079\u0070\u0074\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u0043\u0069\u0070\u0068\u0065\u0072\u0020\u0063\u0069\u0070\u0068\u0065\u0072\u0020\u003d\u0020\u0043\u0069\u0070\u0068\u0065\u0072\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0022\u0041\u0045\u0053\u002f\u0045\u0043\u0042\u002f\u0050\u004b\u0043\u0053\u0035\u0050\u0041\u0044\u0044\u0049\u004e\u0047\u0022\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0063\u0069\u0070\u0068\u0065\u0072\u002e\u0069\u006e\u0069\u0074\u0028\u0043\u0069\u0070\u0068\u0065\u0072\u002e\u0044\u0045\u0043\u0052\u0059\u0050\u0054\u005f\u004d\u004f\u0044\u0045\u002c\u0020\u0073\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u006e\u0065\u0077\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0063\u0069\u0070\u0068\u0065\u0072\u002e\u0064\u006f\u0046\u0069\u006e\u0061\u006c\u0028\u0042\u0061\u0073\u0065\u0036\u0034\u002e\u0067\u0065\u0074\u0044\u0065\u0063\u006f\u0064\u0065\u0072\u0028\u0029\u002e\u0064\u0065\u0063\u006f\u0064\u0065\u0028\u0073\u0074\u0072\u0054\u006f\u0044\u0065\u0063\u0072\u0079\u0070\u0074\u0029\u0029\u0029\u003b\u000d\u000a\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u006e\u0075\u006c\u006c\u003b\u000d\u000a\u0009\u007d\u000d\u000a\u007d \ No newline at end of file +package gtPlusPlus.core.util.data; + +import java.io.UnsupportedEncodingException; +import java.math.BigInteger; +import java.nio.charset.StandardCharsets; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.Arrays; +import java.util.Base64; +import javax.crypto.Cipher; +import javax.crypto.spec.SecretKeySpec; + +public class AES { + + private final String secret; + ; + + private final SecretKeySpec secretKey; + + private final byte[] key; + + public AES() { + + this("Darkness In Their Hearts"); + } + + public AES(String aSecret) { + + secret = aSecret; + + key = getBytes(getHashedString(secret)); + + secretKey = generateKey(key); + } + + private static final String getHashedString(String aString) { + + return toHexString(getSHA(aString)); + } + + private static final byte[] getSHA(String input) { + + MessageDigest md; + + try { + + md = MessageDigest.getInstance("SHA-256"); + + return md.digest(input.getBytes(StandardCharsets.UTF_8)); + + } catch (NoSuchAlgorithmException e) { + + e.printStackTrace(); + } + + return new byte[] {}; + } + + private static final String toHexString(byte[] hash) { + + BigInteger number = new BigInteger(1, hash); + + StringBuilder hexString = new StringBuilder(number.toString(16)); + + while (hexString.length() < 32) { + + hexString.insert(0, '0'); + } + + return hexString.toString(); + } + + private final byte[] getBytes(String aKey) { + + byte[] aKeyData; + + MessageDigest sha; + + try { + + sha = MessageDigest.getInstance("SHA-256"); + + return sha.digest(aKey.getBytes(StandardCharsets.UTF_8)); + + } catch (NoSuchAlgorithmException e1) { + + e1.printStackTrace(); + + try { + + aKeyData = aKey.getBytes("UTF-8"); + + sha = MessageDigest.getInstance("SHA-1"); + + aKeyData = sha.digest(key); + + aKeyData = Arrays.copyOf(key, 16); + + return aKeyData; + + } catch (NoSuchAlgorithmException e) { + + e.printStackTrace(); + + } catch (UnsupportedEncodingException e) { + + e.printStackTrace(); + } + } + + return new byte[] {}; + } + + private final SecretKeySpec generateKey(byte[] aKey) { + + return new SecretKeySpec(aKey, "AES"); + } + + public String encode(String strToEncrypt) { + + try { + + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + + cipher.init(Cipher.ENCRYPT_MODE, secretKey); + + return Base64.getEncoder().encodeToString(cipher.doFinal(strToEncrypt.getBytes("UTF-8"))); + + } catch (Exception e) { + + System.out.println("Error while encrypting: " + e.toString()); + } + + return null; + } + + public String decode(String strToDecrypt) { + + try { + + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING"); + + cipher.init(Cipher.DECRYPT_MODE, secretKey); + + return new String(cipher.doFinal(Base64.getDecoder().decode(strToDecrypt))); + + } catch (Exception e) { + + } + + return null; + } +} diff --git a/src/main/java/gtPlusPlus/core/util/data/ArrayUtils.java b/src/main/java/gtPlusPlus/core/util/data/ArrayUtils.java index 62f703f5f5..8630ac5abf 100644 --- a/src/main/java/gtPlusPlus/core/util/data/ArrayUtils.java +++ b/src/main/java/gtPlusPlus/core/util/data/ArrayUtils.java @@ -1,121 +1,115 @@ package gtPlusPlus.core.util.data; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; - -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.data.AutoMap; import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; public class ArrayUtils { - public static V[] expandArray(final V[] someArray, final V newValueToAdd) { - V[] series = someArray; - series = addElement(series, newValueToAdd); - return series; - } + public static V[] expandArray(final V[] someArray, final V newValueToAdd) { + V[] series = someArray; + series = addElement(series, newValueToAdd); + return series; + } - private static V[] addElement(V[] series, final V newValueToAdd) { - series = Arrays.copyOf(series, series.length + 1); - series[series.length - 1] = newValueToAdd; - return series; - } - - public static V[] insertElementAtIndex(V[] aArray, int aIndex, V aObjectToInsert) { - V[] newArray = Arrays.copyOf(aArray, aArray.length + 1); - for (int i=0;i Object getMostCommonElement(List list) { - Optional r = list.stream().map(V::getTextureSet).collect(Collectors.groupingBy(Function.identity(), Collectors.counting())).entrySet().stream().max(Map.Entry.comparingByValue()).map(Map.Entry::getKey); - return r.get(); - }*/ + private static V[] addElement(V[] series, final V newValueToAdd) { + series = Arrays.copyOf(series, series.length + 1); + series[series.length - 1] = newValueToAdd; + return series; + } + public static V[] insertElementAtIndex(V[] aArray, int aIndex, V aObjectToInsert) { + V[] newArray = Arrays.copyOf(aArray, aArray.length + 1); + for (int i = 0; i < aIndex; i++) { + newArray[i] = aArray[i]; + } + newArray[aIndex] = aObjectToInsert; + for (int i = (aIndex + 1); i < newArray.length; i++) { + newArray[i] = aArray[i - 1]; + } + return newArray; + } - public static Object[] removeNulls(final Object[] v) { - List list = new ArrayList(Arrays.asList(v)); - list.removeAll(Collections.singleton((Object)null)); - return list.toArray(new Object[list.size()]); - } - - public static ItemStack[] removeNulls(final ItemStack[] v) { - List list = new ArrayList(Arrays.asList(v)); - list.removeAll(Collections.singleton((ItemStack)null)); - return list.toArray(new ItemStack[list.size()]); - } + /*public static Object getMostCommonElement(List list) { + Optional r = list.stream().map(V::getTextureSet).collect(Collectors.groupingBy(Function.identity(), Collectors.counting())).entrySet().stream().max(Map.Entry.comparingByValue()).map(Map.Entry::getKey); + return r.get(); + }*/ - @SuppressWarnings("unchecked") - public static Set combineSetData(Set S, Set J) { - Set mData = new HashSet(); - T[] array1 = (T[]) S.toArray(); - Collections.addAll(mData, array1); - T[] array2 = (T[]) J.toArray(); - Collections.addAll(mData, array2); - return mData; - } + public static Object[] removeNulls(final Object[] v) { + List list = new ArrayList(Arrays.asList(v)); + list.removeAll(Collections.singleton((Object) null)); + return list.toArray(new Object[list.size()]); + } - public static AutoMap mergeTwoMaps(AutoMap a, AutoMap b) { - AutoMap c = new AutoMap(); - for (A g : a.values()) { - c.put(g); - } - for (A g : b.values()) { - c.put(g); - } - return c; - } - - public static T[][] rotateArrayClockwise(T[][] mat) { - Logger.INFO("Rotating Array 90' Clockwise"); - try { - final int M = mat.length; - final int N = mat[0].length; - Logger.INFO("Dimension X: "+M); - Logger.INFO("Dimension Z: "+N); - @SuppressWarnings("unchecked") - T[][] ret = (T[][]) new Object[N][M]; - for (int r = 0; r < M; r++) { - for (int c = 0; c < N; c++) { - ret[c][M-1-r] = mat[r][c]; - } - } - Logger.INFO("Returning Rotated Array"); - return ret; - } - catch (Throwable t) { - t.printStackTrace(); - return null; - } - } + public static ItemStack[] removeNulls(final ItemStack[] v) { + List list = new ArrayList(Arrays.asList(v)); + list.removeAll(Collections.singleton((ItemStack) null)); + return list.toArray(new ItemStack[list.size()]); + } - public static String toString(Object[] aArray, String string) { - return org.apache.commons.lang3.ArrayUtils.toString(aArray, string); - } + @SuppressWarnings("unchecked") + public static Set combineSetData(Set S, Set J) { + Set mData = new HashSet(); + T[] array1 = (T[]) S.toArray(); + Collections.addAll(mData, array1); + T[] array2 = (T[]) J.toArray(); + Collections.addAll(mData, array2); + return mData; + } - public static String toString(Object[] aArray) { - return org.apache.commons.lang3.ArrayUtils.toString(aArray); - } + public static AutoMap mergeTwoMaps(AutoMap a, AutoMap b) { + AutoMap c = new AutoMap(); + for (A g : a.values()) { + c.put(g); + } + for (A g : b.values()) { + c.put(g); + } + return c; + } - public static Object[] getArrayFromArrayList(ArrayList aArrayList) { - Object[] aGenericArray = new Object[aArrayList.size()]; - int aIndex = 0; - for (T object : aArrayList) { - aGenericArray[aIndex++] = object; - } - return aGenericArray; - } + public static T[][] rotateArrayClockwise(T[][] mat) { + Logger.INFO("Rotating Array 90' Clockwise"); + try { + final int M = mat.length; + final int N = mat[0].length; + Logger.INFO("Dimension X: " + M); + Logger.INFO("Dimension Z: " + N); + @SuppressWarnings("unchecked") + T[][] ret = (T[][]) new Object[N][M]; + for (int r = 0; r < M; r++) { + for (int c = 0; c < N; c++) { + ret[c][M - 1 - r] = mat[r][c]; + } + } + Logger.INFO("Returning Rotated Array"); + return ret; + } catch (Throwable t) { + t.printStackTrace(); + return null; + } + } -} + public static String toString(Object[] aArray, String string) { + return org.apache.commons.lang3.ArrayUtils.toString(aArray, string); + } + public static String toString(Object[] aArray) { + return org.apache.commons.lang3.ArrayUtils.toString(aArray); + } + + public static Object[] getArrayFromArrayList(ArrayList aArrayList) { + Object[] aGenericArray = new Object[aArrayList.size()]; + int aIndex = 0; + for (T object : aArrayList) { + aGenericArray[aIndex++] = object; + } + return aGenericArray; + } +} diff --git a/src/main/java/gtPlusPlus/core/util/data/EnumUtils.java b/src/main/java/gtPlusPlus/core/util/data/EnumUtils.java index edcc071b54..2a74edb5aa 100644 --- a/src/main/java/gtPlusPlus/core/util/data/EnumUtils.java +++ b/src/main/java/gtPlusPlus/core/util/data/EnumUtils.java @@ -5,47 +5,42 @@ import com.google.common.base.Optional; public class EnumUtils { - /** - * Returns the value of an Enum if it exists. - * If value is not found, case-insensitive search will occur. - * If value still not found, an IllegalArgumentException is thrown. - **/ - public static > T getValue(Class enumeration, String name) { - Optional j = Enums.getIfPresent(enumeration, name); - T VALUE; - if (j == null || !j.isPresent()) { - VALUE = valueOfIgnoreCase(enumeration, name); - } - else { - VALUE = j.get(); - } - return VALUE; - } - - /** - * Finds the value of the given enumeration by name, case-insensitive. - * Throws an IllegalArgumentException if no match is found. - **/ - private static > T valueOfIgnoreCase(Class enumeration, String name) { + /** + * Returns the value of an Enum if it exists. + * If value is not found, case-insensitive search will occur. + * If value still not found, an IllegalArgumentException is thrown. + **/ + public static > T getValue(Class enumeration, String name) { + Optional j = Enums.getIfPresent(enumeration, name); + T VALUE; + if (j == null || !j.isPresent()) { + VALUE = valueOfIgnoreCase(enumeration, name); + } else { + VALUE = j.get(); + } + return VALUE; + } - for (T enumValue : enumeration.getEnumConstants()) { - if (enumValue.name().equalsIgnoreCase(name)) { - return enumValue; - } - } + /** + * Finds the value of the given enumeration by name, case-insensitive. + * Throws an IllegalArgumentException if no match is found. + **/ + private static > T valueOfIgnoreCase(Class enumeration, String name) { - throw new IllegalArgumentException(String.format( - "There is no value with name '%s' in Enum %s", - name, enumeration.getName() - )); - } + for (T enumValue : enumeration.getEnumConstants()) { + if (enumValue.name().equalsIgnoreCase(name)) { + return enumValue; + } + } - public static Object getValue(Class class1, String materialName, boolean bool) { - if (Enum.class.isInstance(class1)){ - return getValue(class1, materialName); - } - return null; - } - - + throw new IllegalArgumentException( + String.format("There is no value with name '%s' in Enum %s", name, enumeration.getName())); + } + + public static Object getValue(Class class1, String materialName, boolean bool) { + if (Enum.class.isInstance(class1)) { + return getValue(class1, materialName); + } + return null; + } } diff --git a/src/main/java/gtPlusPlus/core/util/data/FileUtils.java b/src/main/java/gtPlusPlus/core/util/data/FileUtils.java index bec5e0eeff..19f868c2a9 100644 --- a/src/main/java/gtPlusPlus/core/util/data/FileUtils.java +++ b/src/main/java/gtPlusPlus/core/util/data/FileUtils.java @@ -1,5 +1,7 @@ package gtPlusPlus.core.util.data; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.Utils; import java.io.File; import java.io.IOException; import java.nio.charset.Charset; @@ -11,94 +13,89 @@ import java.nio.file.StandardOpenOption; import java.util.ArrayList; import java.util.List; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.util.Utils; - public class FileUtils { - private static final Charset utf8 = StandardCharsets.UTF_8; + private static final Charset utf8 = StandardCharsets.UTF_8; + + public static boolean doesFileExist(File f) { + if (f != null && f.exists() && !f.isDirectory()) { + return true; + } + return false; + } - public static boolean doesFileExist(File f) { - if (f != null && f.exists() && !f.isDirectory()) { - return true; - } - return false; - } + public static File createFile(String path, String filename, String extension) { + File file = new File(Utils.getMcDir(), path + filename + extension); + return createFile(file); + } - public static File createFile(String path, String filename, String extension) { - File file = new File(Utils.getMcDir(), path + filename + extension); - return createFile(file); - } - - public static File createFile(File aFile) { - boolean blnCreated = false; - Logger.INFO("Trying to use path "+aFile.getPath()); - try { - Logger.INFO("Trying to use path "+aFile.getCanonicalPath()); - Logger.INFO("Trying to use absolute path "+aFile.getAbsolutePath()); - blnCreated = aFile.createNewFile(); - } catch (IOException ioe) { - Logger.INFO("Error while creating a new empty file :" + ioe); - return null; - } - return blnCreated ? aFile : null; - } + public static File createFile(File aFile) { + boolean blnCreated = false; + Logger.INFO("Trying to use path " + aFile.getPath()); + try { + Logger.INFO("Trying to use path " + aFile.getCanonicalPath()); + Logger.INFO("Trying to use absolute path " + aFile.getAbsolutePath()); + blnCreated = aFile.createNewFile(); + } catch (IOException ioe) { + Logger.INFO("Error while creating a new empty file :" + ioe); + return null; + } + return blnCreated ? aFile : null; + } - public static File getFile(String filename, String extension) { - return getFile("", filename, extension); - } + public static File getFile(String filename, String extension) { + return getFile("", filename, extension); + } - public static File getFile(String path, String filename, String extension) { - if (path == null || path.length() <= 0) { - path = ""; - } - else { - path = path + "/"; - } - if (filename == null || filename.length() <= 0) { - return null; - } - if (extension == null || extension.length() <= 0) { - extension = ".txt"; - } - else { - extension = "." + extension; - } - File file = new File(Utils.getMcDir(), path + filename + extension); - boolean doesExist = doesFileExist(file); + public static File getFile(String path, String filename, String extension) { + if (path == null || path.length() <= 0) { + path = ""; + } else { + path = path + "/"; + } + if (filename == null || filename.length() <= 0) { + return null; + } + if (extension == null || extension.length() <= 0) { + extension = ".txt"; + } else { + extension = "." + extension; + } + File file = new File(Utils.getMcDir(), path + filename + extension); + boolean doesExist = doesFileExist(file); - if (doesExist) { - Logger.INFO("Found File: " + file.getAbsolutePath()); - return file; - } else { - Logger.INFO("Creating file, as it was not found."); - return createFile(path, filename, extension); - } - } + if (doesExist) { + Logger.INFO("Found File: " + file.getAbsolutePath()); + return file; + } else { + Logger.INFO("Creating file, as it was not found."); + return createFile(path, filename, extension); + } + } - public static boolean appendListToFile(File file, List content) { - try { - long oldSize; - long newSize; - if (doesFileExist(file)) { - Path p = Paths.get(file.getPath()); - if (p != null && Files.isWritable(p)) { - oldSize = Files.size(p); - try { - Files.write(p, content, utf8, StandardOpenOption.APPEND); - } catch (IOException e) { - e.printStackTrace(); - } - newSize = Files.size(p); - return newSize > oldSize; - } - } - } catch (IOException e) { - } - return false; - } + public static boolean appendListToFile(File file, List content) { + try { + long oldSize; + long newSize; + if (doesFileExist(file)) { + Path p = Paths.get(file.getPath()); + if (p != null && Files.isWritable(p)) { + oldSize = Files.size(p); + try { + Files.write(p, content, utf8, StandardOpenOption.APPEND); + } catch (IOException e) { + e.printStackTrace(); + } + newSize = Files.size(p); + return newSize > oldSize; + } + } + } catch (IOException e) { + } + return false; + } - /** + /** * Reads the contents of a file line by line to a List of Strings using the default encoding for the VM. * The file is always closed. * @@ -109,10 +106,9 @@ public class FileUtils { */ public static List readLines(File file) { try { - return org.apache.commons.io.FileUtils.readLines(file, utf8); - } - catch (IOException e) { - return new ArrayList(); - } + return org.apache.commons.io.FileUtils.readLines(file, utf8); + } catch (IOException e) { + return new ArrayList(); + } } } diff --git a/src/main/java/gtPlusPlus/core/util/data/LocaleUtils.java b/src/main/java/gtPlusPlus/core/util/data/LocaleUtils.java index d1a35a661b..a67262c4bd 100644 --- a/src/main/java/gtPlusPlus/core/util/data/LocaleUtils.java +++ b/src/main/java/gtPlusPlus/core/util/data/LocaleUtils.java @@ -1,90 +1,82 @@ package gtPlusPlus.core.util.data; -import java.io.*; - import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.ModContainer; import cpw.mods.fml.common.registry.GameData; - +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import java.io.*; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.minecraft.ItemUtils; - public class LocaleUtils { - public static boolean generateFakeLocaleFile() { - for (ModContainer modcontainer : Loader.instance().getModList()){ - if (modcontainer.getModId().toLowerCase().equals("miscutils")) { - String S = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"; - writeToFile(S); - dumpItemsAndBlocksForModContainer(modcontainer); - } - } - return true; - } + public static boolean generateFakeLocaleFile() { + for (ModContainer modcontainer : Loader.instance().getModList()) { + if (modcontainer.getModId().toLowerCase().equals("miscutils")) { + String S = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"; + writeToFile(S); + dumpItemsAndBlocksForModContainer(modcontainer); + } + } + return true; + } + + public static boolean dumpItemsAndBlocksForModContainer(ModContainer mod) { + writeToFile("Dumping Items from " + mod.getModId() + "."); + for (Object C : GameData.getItemRegistry()) { + + try { + + if (C != null) { + if (C instanceof Item) { + Item R = (Item) C; + ItemStack IS = ItemUtils.getSimpleStack(R); + String modid = ItemUtils.getModId(IS); + if (modid.equals("miscutils") || modid.equals("ToxicEverglades")) { + String S = "[" + modid + "] " + IS.getUnlocalizedName() + ".name="; + writeToFile(S); + } + } + } - public static boolean dumpItemsAndBlocksForModContainer(ModContainer mod) { - writeToFile("Dumping Items from "+mod.getModId()+"."); - for (Object C : GameData.getItemRegistry()) { - - try { - - if (C != null) { - if (C instanceof Item) { - Item R = (Item) C; - ItemStack IS = ItemUtils.getSimpleStack(R); - String modid = ItemUtils.getModId(IS); - if (modid.equals("miscutils") || modid.equals("ToxicEverglades")) { - String S = "["+modid+"] "+IS.getUnlocalizedName()+".name="; - writeToFile(S); - } - } - } - - } - catch (Throwable T) {} - - } - writeToFile("Dumping Blocks from "+mod.getModId()+"."); - for (Object B : GameData.getBlockRegistry()) { - - try { - - if (B != null) { - if (B instanceof Block) { - Block R = (Block) B; - ItemStack IS = ItemUtils.getSimpleStack(R); - String modid = ItemUtils.getModId(IS); - if (modid.equals("miscutils") || modid.equals("ToxicEverglades")) { - String S = "["+modid+"] "+IS.getUnlocalizedName()+".name="; - writeToFile(S); - } - } - } - - } - catch (Throwable T) {} - - } + } catch (Throwable T) { + } + } + writeToFile("Dumping Blocks from " + mod.getModId() + "."); + for (Object B : GameData.getBlockRegistry()) { + try { - return true; - } + if (B != null) { + if (B instanceof Block) { + Block R = (Block) B; + ItemStack IS = ItemUtils.getSimpleStack(R); + String modid = ItemUtils.getModId(IS); + if (modid.equals("miscutils") || modid.equals("ToxicEverglades")) { + String S = "[" + modid + "] " + IS.getUnlocalizedName() + ".name="; + writeToFile(S); + } + } + } - public static void writeToFile(String S) { - try { - File F = new File(Utils.getMcDir(), "config/GTplusplus/en_US.lang"); - BufferedWriter writer; - writer = new BufferedWriter(new FileWriter(F, true)); - writer.write(S); - writer.newLine(); - writer.close(); - } - catch (IOException e) {} - } + } catch (Throwable T) { + } + } + return true; + } + public static void writeToFile(String S) { + try { + File F = new File(Utils.getMcDir(), "config/GTplusplus/en_US.lang"); + BufferedWriter writer; + writer = new BufferedWriter(new FileWriter(F, true)); + writer.write(S); + writer.newLine(); + writer.close(); + } catch (IOException e) { + } + } } diff --git a/src/main/java/gtPlusPlus/core/util/data/LoggingUtils.java b/src/main/java/gtPlusPlus/core/util/data/LoggingUtils.java index 8415ab32fe..16c04f2c34 100644 --- a/src/main/java/gtPlusPlus/core/util/data/LoggingUtils.java +++ b/src/main/java/gtPlusPlus/core/util/data/LoggingUtils.java @@ -5,45 +5,43 @@ import java.util.Date; public class LoggingUtils { - public static void profileLog(final Object o) { - try { - String content; - final File file = new File("GregtechTimingsTC.txt"); - // if file doesnt exists, then create it - if (!file.exists()) { - file.createNewFile(); - final FileWriter fw = new FileWriter(file.getAbsoluteFile(), true); - final BufferedWriter bw = new BufferedWriter(fw); - bw.write("============================================================"); - bw.write(System.lineSeparator()); - bw.close(); - } - if (o instanceof String) { - content = (String) o; - } else { - content = o.toString(); - } - final FileWriter fw = new FileWriter(file.getAbsoluteFile(), true); - final BufferedWriter bw = new BufferedWriter(fw); - bw.write(content); - bw.write(System.lineSeparator()); - bw.close(); - System.out.println("Data Logged."); + public static void profileLog(final Object o) { + try { + String content; + final File file = new File("GregtechTimingsTC.txt"); + // if file doesnt exists, then create it + if (!file.exists()) { + file.createNewFile(); + final FileWriter fw = new FileWriter(file.getAbsoluteFile(), true); + final BufferedWriter bw = new BufferedWriter(fw); + bw.write("============================================================"); + bw.write(System.lineSeparator()); + bw.close(); + } + if (o instanceof String) { + content = (String) o; + } else { + content = o.toString(); + } + final FileWriter fw = new FileWriter(file.getAbsoluteFile(), true); + final BufferedWriter bw = new BufferedWriter(fw); + bw.write(content); + bw.write(System.lineSeparator()); + bw.close(); + System.out.println("Data Logged."); - } catch (final IOException e) { - System.out.println("Data logging failed."); - } - } - - public static boolean logCurrentSystemTime(final String message) { - final Date date = new Date(System.currentTimeMillis()); - try { - profileLog(message + " | " + date.toString()); - return true; - } catch (final Throwable r) { - return false; - } - - } + } catch (final IOException e) { + System.out.println("Data logging failed."); + } + } + public static boolean logCurrentSystemTime(final String message) { + final Date date = new Date(System.currentTimeMillis()); + try { + profileLog(message + " | " + date.toString()); + return true; + } catch (final Throwable r) { + return false; + } + } } diff --git a/src/main/java/gtPlusPlus/core/util/data/StringUtils.java b/src/main/java/gtPlusPlus/core/util/data/StringUtils.java index 2372d04c15..af40dbae41 100644 --- a/src/main/java/gtPlusPlus/core/util/data/StringUtils.java +++ b/src/main/java/gtPlusPlus/core/util/data/StringUtils.java @@ -6,214 +6,219 @@ import gtPlusPlus.core.util.Utils; public class StringUtils { - public static String superscript(String str) { - str = str.replaceAll("0", "\u2070"); - str = str.replaceAll("1", "\u00B9"); - str = str.replaceAll("2", "\u00B2"); - str = str.replaceAll("3", "\u00B3"); - str = str.replaceAll("4", "\u2074"); - str = str.replaceAll("5", "\u2075"); - str = str.replaceAll("6", "\u2076"); - str = str.replaceAll("7", "\u2077"); - str = str.replaceAll("8", "\u2078"); - str = str.replaceAll("9", "\u2079"); - return str; - } - - public static String subscript(String str) { - str = str.replaceAll("0", "\u2080"); - str = str.replaceAll("1", "\u2081"); - str = str.replaceAll("2", "\u2082"); - str = str.replaceAll("3", "\u2083"); - str = str.replaceAll("4", "\u2084"); - str = str.replaceAll("5", "\u2085"); - str = str.replaceAll("6", "\u2086"); - str = str.replaceAll("7", "\u2087"); - str = str.replaceAll("8", "\u2088"); - str = str.replaceAll("9", "\u2089"); - return str; - } - - public static boolean containsSuperOrSubScript(final String s){ - if (s.contains(StringUtils.superscript("0"))) { - return true; - } - else if (s.contains(StringUtils.superscript("1"))) { - return true; - } - else if (s.contains(StringUtils.superscript("2"))) { - return true; - } - else if (s.contains(StringUtils.superscript("3"))) { - return true; - } - else if (s.contains(StringUtils.superscript("4"))) { - return true; - } - else if (s.contains(StringUtils.superscript("5"))) { - return true; - } - else if (s.contains(StringUtils.superscript("6"))) { - return true; - } - else if (s.contains(StringUtils.superscript("7"))) { - return true; - } - else if (s.contains(StringUtils.superscript("8"))) { - return true; - } - else if (s.contains(StringUtils.superscript("9"))) { - return true; - } - if (s.contains(StringUtils.subscript("0"))) { - return true; - } - else if (s.contains(StringUtils.subscript("1"))) { - return true; - } - else if (s.contains(StringUtils.subscript("2"))) { - return true; - } - else if (s.contains(StringUtils.subscript("3"))) { - return true; - } - else if (s.contains(StringUtils.subscript("4"))) { - return true; - } - else if (s.contains(StringUtils.subscript("5"))) { - return true; - } - else if (s.contains(StringUtils.subscript("6"))) { - return true; - } - else if (s.contains(StringUtils.subscript("7"))) { - return true; - } - else if (s.contains(StringUtils.subscript("8"))) { - return true; - } - else if (s.contains(StringUtils.subscript("9"))) { - return true; - } - return false; - } - - //Can call this Enum for formatting. - public static enum TextUtils { - blue('1'), green('2'), teal('3'), maroon('4'), purple('5'), orange('6'), lightGray('7'), darkGray('8'), lightBlue( - '9'), black('0'), lime('a'), aqua('b'), red('c'), pink('d'), yellow('e'), white('f'); - - private char colourValue; - private TextUtils(final char value) { - this.colourValue = value; - } - public String colour() { - return getFormatter() + this.colourValue; - } - private String getFormatter() { - return "\u00A7"; // Returns §. - } - } - - public static String firstLetterCaps(String data) { - String firstLetter = data.substring(0,1).toUpperCase(); - String restLetters = data.substring(1).toLowerCase(); - return firstLetter + restLetters; - } - - public static String getDataStringFromArray(V[] parameterTypes) { - if (parameterTypes == null || parameterTypes.length == 0) { - return "empty/null"; - } - else { - String aData = ""; - for (V y : parameterTypes) { - if (y != null) { - aData += ", "+y.toString(); - } - } - return aData; - } - } - - - - /** - * Is this a special regex character for delimination? (.$|()[]{}^?*+\\) - * @param aChar - The char to test - * @return - Is this a special character? - */ - public static boolean isSpecialCharacter(char aChar) { - if (aChar == '"' || aChar == '.' || aChar == '$' || aChar == '|' || aChar == '(' || aChar == ')' || aChar == '[' - || aChar == ']' || aChar == '{' || aChar == '}' || aChar == '^' || aChar == '?' || aChar == '*' - || aChar == '+' || aChar == '\\') { - return true; - } - return false; - } - - public static boolean isEscaped(String aString) { - return aString.substring(0, 1).equals("\\"); - } - - public static String splitAndUppercase(String aInput, String aDelim) { - - if (!isEscaped(aDelim)) { - boolean isSpecial = false; - for (int o=0;o aTemp = new AutoMap(); - for (String s : aSplit) { - Logger.INFO("Found: "+s); - s = s.replace(".", ""); - s = Utils.sanitizeString(s); - s = firstLetterCaps(s); - Logger.INFO("Formatted & Captilized: "+s); - aTemp.put(s); - } - Logger.INFO("Rebuilding"); - String aReturn = ""; - for (String s : aTemp) { - aReturn += s; - Logger.INFO("Step: "+aReturn); - } - return aReturn; - } - } - - public static int characterCount(String aString, char aChar) { - return characterCount(aString, ""+aChar); - } - - public static int characterCount(String aString, String aChar) { - int aLength = aString.length(); - int aFound = 0; - if (aLength == 0 || !aString.contains(aChar)) { - return 0; - } - else { - for (int index = 0; index < aLength; index++) { - if (aString.substring(index, index+1).equals(aChar)) { - aFound++; - } - } - return aFound; - } - } + public static String superscript(String str) { + str = str.replaceAll("0", "\u2070"); + str = str.replaceAll("1", "\u00B9"); + str = str.replaceAll("2", "\u00B2"); + str = str.replaceAll("3", "\u00B3"); + str = str.replaceAll("4", "\u2074"); + str = str.replaceAll("5", "\u2075"); + str = str.replaceAll("6", "\u2076"); + str = str.replaceAll("7", "\u2077"); + str = str.replaceAll("8", "\u2078"); + str = str.replaceAll("9", "\u2079"); + return str; + } + + public static String subscript(String str) { + str = str.replaceAll("0", "\u2080"); + str = str.replaceAll("1", "\u2081"); + str = str.replaceAll("2", "\u2082"); + str = str.replaceAll("3", "\u2083"); + str = str.replaceAll("4", "\u2084"); + str = str.replaceAll("5", "\u2085"); + str = str.replaceAll("6", "\u2086"); + str = str.replaceAll("7", "\u2087"); + str = str.replaceAll("8", "\u2088"); + str = str.replaceAll("9", "\u2089"); + return str; + } + + public static boolean containsSuperOrSubScript(final String s) { + if (s.contains(StringUtils.superscript("0"))) { + return true; + } else if (s.contains(StringUtils.superscript("1"))) { + return true; + } else if (s.contains(StringUtils.superscript("2"))) { + return true; + } else if (s.contains(StringUtils.superscript("3"))) { + return true; + } else if (s.contains(StringUtils.superscript("4"))) { + return true; + } else if (s.contains(StringUtils.superscript("5"))) { + return true; + } else if (s.contains(StringUtils.superscript("6"))) { + return true; + } else if (s.contains(StringUtils.superscript("7"))) { + return true; + } else if (s.contains(StringUtils.superscript("8"))) { + return true; + } else if (s.contains(StringUtils.superscript("9"))) { + return true; + } + if (s.contains(StringUtils.subscript("0"))) { + return true; + } else if (s.contains(StringUtils.subscript("1"))) { + return true; + } else if (s.contains(StringUtils.subscript("2"))) { + return true; + } else if (s.contains(StringUtils.subscript("3"))) { + return true; + } else if (s.contains(StringUtils.subscript("4"))) { + return true; + } else if (s.contains(StringUtils.subscript("5"))) { + return true; + } else if (s.contains(StringUtils.subscript("6"))) { + return true; + } else if (s.contains(StringUtils.subscript("7"))) { + return true; + } else if (s.contains(StringUtils.subscript("8"))) { + return true; + } else if (s.contains(StringUtils.subscript("9"))) { + return true; + } + return false; + } + + // Can call this Enum for formatting. + public static enum TextUtils { + blue('1'), + green('2'), + teal('3'), + maroon('4'), + purple('5'), + orange('6'), + lightGray('7'), + darkGray('8'), + lightBlue('9'), + black('0'), + lime('a'), + aqua('b'), + red('c'), + pink('d'), + yellow('e'), + white('f'); + + private char colourValue; + + private TextUtils(final char value) { + this.colourValue = value; + } + + public String colour() { + return getFormatter() + this.colourValue; + } + + private String getFormatter() { + return "\u00A7"; // Returns §. + } + } + + public static String firstLetterCaps(String data) { + String firstLetter = data.substring(0, 1).toUpperCase(); + String restLetters = data.substring(1).toLowerCase(); + return firstLetter + restLetters; + } + + public static String getDataStringFromArray(V[] parameterTypes) { + if (parameterTypes == null || parameterTypes.length == 0) { + return "empty/null"; + } else { + String aData = ""; + for (V y : parameterTypes) { + if (y != null) { + aData += ", " + y.toString(); + } + } + return aData; + } + } + + /** + * Is this a special regex character for delimination? (.$|()[]{}^?*+\\) + * @param aChar - The char to test + * @return - Is this a special character? + */ + public static boolean isSpecialCharacter(char aChar) { + if (aChar == '"' + || aChar == '.' + || aChar == '$' + || aChar == '|' + || aChar == '(' + || aChar == ')' + || aChar == '[' + || aChar == ']' + || aChar == '{' + || aChar == '}' + || aChar == '^' + || aChar == '?' + || aChar == '*' + || aChar == '+' + || aChar == '\\') { + return true; + } + return false; + } + + public static boolean isEscaped(String aString) { + return aString.substring(0, 1).equals("\\"); + } + + public static String splitAndUppercase(String aInput, String aDelim) { + + if (!isEscaped(aDelim)) { + boolean isSpecial = false; + for (int o = 0; o < aInput.length(); o++) { + if (isSpecialCharacter(aInput.charAt(o))) { + isSpecial = true; + } + } + if (isSpecial) { + aDelim = "\\" + aDelim; + } + } + + Logger.INFO("Splitting " + aInput); + String[] aSplit = aInput.split(aDelim); + Logger.INFO("Split into " + aSplit == null ? "" + 0 : aSplit.length + " parts."); + if (aSplit == null || aSplit.length == 0) { + return aInput; + } else { + AutoMap aTemp = new AutoMap(); + for (String s : aSplit) { + Logger.INFO("Found: " + s); + s = s.replace(".", ""); + s = Utils.sanitizeString(s); + s = firstLetterCaps(s); + Logger.INFO("Formatted & Captilized: " + s); + aTemp.put(s); + } + Logger.INFO("Rebuilding"); + String aReturn = ""; + for (String s : aTemp) { + aReturn += s; + Logger.INFO("Step: " + aReturn); + } + return aReturn; + } + } + + public static int characterCount(String aString, char aChar) { + return characterCount(aString, "" + aChar); + } + + public static int characterCount(String aString, String aChar) { + int aLength = aString.length(); + int aFound = 0; + if (aLength == 0 || !aString.contains(aChar)) { + return 0; + } else { + for (int index = 0; index < aLength; index++) { + if (aString.substring(index, index + 1).equals(aChar)) { + aFound++; + } + } + return aFound; + } + } } diff --git a/src/main/java/gtPlusPlus/core/util/data/UUIDUtils.java b/src/main/java/gtPlusPlus/core/util/data/UUIDUtils.java index d6b32314b1..71634b3af7 100644 --- a/src/main/java/gtPlusPlus/core/util/data/UUIDUtils.java +++ b/src/main/java/gtPlusPlus/core/util/data/UUIDUtils.java @@ -5,21 +5,20 @@ import java.util.UUID; public class UUIDUtils { - //UUID Methods below created by https://gist.github.com/jeffjohnson9046 - //https://gist.github.com/jeffjohnson9046/c663dd22bbe6bb0b3f5e + // UUID Methods below created by https://gist.github.com/jeffjohnson9046 + // https://gist.github.com/jeffjohnson9046/c663dd22bbe6bb0b3f5e - public static byte[] getBytesFromUUID(UUID uuid) { - ByteBuffer bb = ByteBuffer.wrap(new byte[16]); - bb.putLong(uuid.getMostSignificantBits()); - bb.putLong(uuid.getLeastSignificantBits()); - return bb.array(); - } - - public static UUID getUUIDFromBytes(byte[] bytes) { - ByteBuffer byteBuffer = ByteBuffer.wrap(bytes); - Long high = byteBuffer.getLong(); - Long low = byteBuffer.getLong(); - return new UUID(high, low); - } + public static byte[] getBytesFromUUID(UUID uuid) { + ByteBuffer bb = ByteBuffer.wrap(new byte[16]); + bb.putLong(uuid.getMostSignificantBits()); + bb.putLong(uuid.getLeastSignificantBits()); + return bb.array(); + } + public static UUID getUUIDFromBytes(byte[] bytes) { + ByteBuffer byteBuffer = ByteBuffer.wrap(bytes); + Long high = byteBuffer.getLong(); + Long low = byteBuffer.getLong(); + return new UUID(high, low); + } } diff --git a/src/main/java/gtPlusPlus/core/util/debug/DEBUG_INIT.java b/src/main/java/gtPlusPlus/core/util/debug/DEBUG_INIT.java index f8fc15c778..a6441ee558 100644 --- a/src/main/java/gtPlusPlus/core/util/debug/DEBUG_INIT.java +++ b/src/main/java/gtPlusPlus/core/util/debug/DEBUG_INIT.java @@ -4,34 +4,25 @@ import gtPlusPlus.preloader.CORE_Preloader; public class DEBUG_INIT { - public static void registerBlocks(){ - //Debug Loading - if (CORE_Preloader.DEBUG_MODE){ - - } - } - - public static void registerItems(){ - /*ModItems.itemDebugShapeSpawner = new DEBUG_ITEM_ShapeSpawner("itemDebugShapeSpawner", AddToCreativeTab.tabMisc, 1, 500); - GameRegistry.registerItem(ModItems.itemDebugShapeSpawner, "itemDebugShapeSpawner"); - ModItems.itemBedLocator_Base = new BedLocator_Base("itemBedLocator_Base"); - GameRegistry.registerItem(ModItems.itemBedLocator_Base, "itemBedLocator_Base"); - ModItems.itemBaseItemWithCharge = new BaseItemWithCharge("itemBaseItemWithCharge", 0, 1000); - GameRegistry.registerItem(ModItems.itemBaseItemWithCharge, "itemBaseItemWithCharge");*/ - } - - public static void registerTEs(){ - - } - - public static void registerMisc(){ - - - - } - - public static void registerHandlers(){ - //MinecraftForge.EVENT_BUS.register(new DEBUG_ScreenOverlay()); - } - + public static void registerBlocks() { + // Debug Loading + if (CORE_Preloader.DEBUG_MODE) {} + } + + public static void registerItems() { + /*ModItems.itemDebugShapeSpawner = new DEBUG_ITEM_ShapeSpawner("itemDebugShapeSpawner", AddToCreativeTab.tabMisc, 1, 500); + GameRegistry.registerItem(ModItems.itemDebugShapeSpawner, "itemDebugShapeSpawner"); + ModItems.itemBedLocator_Base = new BedLocator_Base("itemBedLocator_Base"); + GameRegistry.registerItem(ModItems.itemBedLocator_Base, "itemBedLocator_Base"); + ModItems.itemBaseItemWithCharge = new BaseItemWithCharge("itemBaseItemWithCharge", 0, 1000); + GameRegistry.registerItem(ModItems.itemBaseItemWithCharge, "itemBaseItemWithCharge");*/ + } + + public static void registerTEs() {} + + public static void registerMisc() {} + + public static void registerHandlers() { + // MinecraftForge.EVENT_BUS.register(new DEBUG_ScreenOverlay()); + } } diff --git a/src/main/java/gtPlusPlus/core/util/debug/DEBUG_ITEM_ShapeSpawner.java b/src/main/java/gtPlusPlus/core/util/debug/DEBUG_ITEM_ShapeSpawner.java index d1e65afe3e..cd8ca0e536 100644 --- a/src/main/java/gtPlusPlus/core/util/debug/DEBUG_ITEM_ShapeSpawner.java +++ b/src/main/java/gtPlusPlus/core/util/debug/DEBUG_ITEM_ShapeSpawner.java @@ -2,57 +2,50 @@ package gtPlusPlus.core.util.debug; import static net.minecraftforge.event.entity.player.PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK; -import java.util.List; - import cpw.mods.fml.common.eventhandler.SubscribeEvent; - +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.BaseItemGeneric; +import java.util.List; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; - -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.item.base.BaseItemGeneric; import net.minecraftforge.event.entity.player.PlayerInteractEvent; -public class DEBUG_ITEM_ShapeSpawner extends BaseItemGeneric{ - - public DEBUG_ITEM_ShapeSpawner(String s, CreativeTabs c, int stackSize, int maxDmg) { - super(s, c, stackSize, maxDmg); - s = "itemDebugShapeSpawner"; - c = AddToCreativeTab.tabMisc; - stackSize = 1; - maxDmg = 500; - } - - @Override - public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player){ - - if (!world.isRemote){ - Logger.INFO("Constructing the shape for the "+"VACUUM FREEZER"); - final Thread thread = new Thread(new DEBUG_TimerThread(world, player)); - thread.start(); - } - return stack; - } - - - - @SubscribeEvent - public void playerInteractEventHandler(final PlayerInteractEvent event) - { - if (event.isCanceled() || event.world.isRemote || (event.action != RIGHT_CLICK_BLOCK)) { - return; - } - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - list.add(EnumChatFormatting.GOLD+"For Testing Gregtech Shapes!"); - super.addInformation(stack, aPlayer, list, bool); - } - +public class DEBUG_ITEM_ShapeSpawner extends BaseItemGeneric { + + public DEBUG_ITEM_ShapeSpawner(String s, CreativeTabs c, int stackSize, int maxDmg) { + super(s, c, stackSize, maxDmg); + s = "itemDebugShapeSpawner"; + c = AddToCreativeTab.tabMisc; + stackSize = 1; + maxDmg = 500; + } + + @Override + public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player) { + + if (!world.isRemote) { + Logger.INFO("Constructing the shape for the " + "VACUUM FREEZER"); + final Thread thread = new Thread(new DEBUG_TimerThread(world, player)); + thread.start(); + } + return stack; + } + + @SubscribeEvent + public void playerInteractEventHandler(final PlayerInteractEvent event) { + if (event.isCanceled() || event.world.isRemote || (event.action != RIGHT_CLICK_BLOCK)) { + return; + } + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add(EnumChatFormatting.GOLD + "For Testing Gregtech Shapes!"); + super.addInformation(stack, aPlayer, list, bool); + } } diff --git a/src/main/java/gtPlusPlus/core/util/debug/DEBUG_MULTIBLOCK_ShapeSpawner.java b/src/main/java/gtPlusPlus/core/util/debug/DEBUG_MULTIBLOCK_ShapeSpawner.java index 2e46b171f9..b4d2480a02 100644 --- a/src/main/java/gtPlusPlus/core/util/debug/DEBUG_MULTIBLOCK_ShapeSpawner.java +++ b/src/main/java/gtPlusPlus/core/util/debug/DEBUG_MULTIBLOCK_ShapeSpawner.java @@ -2,13 +2,6 @@ package gtPlusPlus.core.util.debug; import static gregtech.api.enums.GT_Values.V; -import java.util.ArrayList; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.ConfigCategories; @@ -27,892 +20,966 @@ import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; import gregtech.common.items.GT_MetaGenerated_Tool_01; - +import java.util.ArrayList; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; public abstract class DEBUG_MULTIBLOCK_ShapeSpawner extends MetaTileEntity { - public static boolean disableMaintenance; - public boolean mMachine = false, mWrench = false, mScrewdriver = false, mSoftHammer = false, mHardHammer = false, mSolderingTool = false, mCrowbar = false, mRunningOnLoad = false; - public int mPollution = 0, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mEfficiencyIncrease = 0, mUpdate = 0, mStartUpCheck = 100, mRuntime = 0, mEfficiency = 0; - public ItemStack[] mOutputItems = null; - public FluidStack[] mOutputFluids = null; - public ArrayList mInputHatches = new ArrayList<>(); - public ArrayList mOutputHatches = new ArrayList<>(); - public ArrayList mInputBusses = new ArrayList<>(); - public ArrayList mOutputBusses = new ArrayList<>(); - public ArrayList mDynamoHatches = new ArrayList<>(); - public ArrayList mMufflerHatches = new ArrayList<>(); - public ArrayList mEnergyHatches = new ArrayList<>(); - public ArrayList mMaintenanceHatches = new ArrayList<>(); - - public DEBUG_MULTIBLOCK_ShapeSpawner(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional, 2); - DEBUG_MULTIBLOCK_ShapeSpawner.disableMaintenance = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "MultiBlockMachines.disableMaintenance", false); - } - - public DEBUG_MULTIBLOCK_ShapeSpawner(final String aName) { - super(aName, 2); - DEBUG_MULTIBLOCK_ShapeSpawner.disableMaintenance = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "MultiBlockMachines.disableMaintenance", false); - } - - public static boolean isValidMetaTileEntity(final MetaTileEntity aMetaTileEntity) { - return (aMetaTileEntity.getBaseMetaTileEntity() != null) && (aMetaTileEntity.getBaseMetaTileEntity().getMetaTileEntity() == aMetaTileEntity) && !aMetaTileEntity.getBaseMetaTileEntity().isDead(); - } - - @Override - public boolean allowCoverOnSide(final byte aSide, final GT_ItemStack aCoverID) { - return aSide != this.getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isFacingValid(final byte aFacing) { - return true; - } - - @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return true; - } - - @Override - public boolean isValidSlot(final int aIndex) { - return aIndex > 0; - } - - @Override - public int getProgresstime() { - return this.mProgresstime; - } - - @Override - public int maxProgresstime() { - return this.mMaxProgresstime; - } - - @Override - public int increaseProgress(final int aProgress) { - return aProgress; - } - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - aNBT.setInteger("mEUt", this.mEUt); - aNBT.setInteger("mProgresstime", this.mProgresstime); - aNBT.setInteger("mMaxProgresstime", this.mMaxProgresstime); - aNBT.setInteger("mEfficiencyIncrease", this.mEfficiencyIncrease); - aNBT.setInteger("mEfficiency", this.mEfficiency); - aNBT.setInteger("mPollution", this.mPollution); - aNBT.setInteger("mRuntime", this.mRuntime); - - if (this.mOutputItems != null) { - for (int i = 0; i < this.mOutputItems.length; i++) { - if (this.mOutputItems[i] != null) { - final NBTTagCompound tNBT = new NBTTagCompound(); - this.mOutputItems[i].writeToNBT(tNBT); - aNBT.setTag("mOutputItem" + i, tNBT); - } - } - } - if (this.mOutputFluids != null) { - for (int i = 0; i < this.mOutputFluids.length; i++) { - if (this.mOutputFluids[i] != null) { - final NBTTagCompound tNBT = new NBTTagCompound(); - this.mOutputFluids[i].writeToNBT(tNBT); - aNBT.setTag("mOutputFluids" + i, tNBT); - } - } - } - - aNBT.setBoolean("mWrench", this.mWrench); - aNBT.setBoolean("mScrewdriver", this.mScrewdriver); - aNBT.setBoolean("mSoftHammer", this.mSoftHammer); - aNBT.setBoolean("mHardHammer", this.mHardHammer); - aNBT.setBoolean("mSolderingTool", this.mSolderingTool); - aNBT.setBoolean("mCrowbar", this.mCrowbar); - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - this.mEUt = aNBT.getInteger("mEUt"); - this.mProgresstime = aNBT.getInteger("mProgresstime"); - this.mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); - if (this.mMaxProgresstime > 0) { - this.mRunningOnLoad = true; - } - this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); - this.mEfficiency = aNBT.getInteger("mEfficiency"); - this.mPollution = aNBT.getInteger("mPollution"); - this.mRuntime = aNBT.getInteger("mRuntime"); - this.mOutputItems = new ItemStack[this.getAmountOfOutputs()]; - for (int i = 0; i < this.mOutputItems.length; i++) { - this.mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i); - } - this.mOutputFluids = new FluidStack[this.getAmountOfOutputs()]; - for (int i = 0; i < this.mOutputFluids.length; i++) { - this.mOutputFluids[i] = GT_Utility.loadFluid(aNBT, "mOutputFluids" + i); - } - this.mWrench = aNBT.getBoolean("mWrench"); - this.mScrewdriver = aNBT.getBoolean("mScrewdriver"); - this.mSoftHammer = aNBT.getBoolean("mSoftHammer"); - this.mHardHammer = aNBT.getBoolean("mHardHammer"); - this.mSolderingTool = aNBT.getBoolean("mSolderingTool"); - this.mCrowbar = aNBT.getBoolean("mCrowbar"); - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_MultiMachine(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "MultiblockDisplay.png"); - } - - @Override - public byte getTileEntityBaseType() { - return 2; - } - - @Override - public void onMachineBlockUpdate() { - this.mUpdate = 50; - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - if (this.mEfficiency < 0) { - this.mEfficiency = 0; - } - if ((--this.mUpdate == 0) || (--this.mStartUpCheck == 0)) { - this.mInputHatches.clear(); - this.mInputBusses.clear(); - this.mOutputHatches.clear(); - this.mOutputBusses.clear(); - this.mDynamoHatches.clear(); - this.mEnergyHatches.clear(); - this.mMufflerHatches.clear(); - this.mMaintenanceHatches.clear(); - this.mMachine = this.checkMachine(aBaseMetaTileEntity, this.mInventory[1]); - } - if (this.mStartUpCheck < 0) { - if (this.mMachine) { - for (final GT_MetaTileEntity_Hatch_Maintenance tHatch : this.mMaintenanceHatches) { - if (isValidMetaTileEntity(tHatch)) { - if (!DEBUG_MULTIBLOCK_ShapeSpawner.disableMaintenance) { - if (tHatch.mWrench) { - this.mWrench = true; - } - if (tHatch.mScrewdriver) { - this.mScrewdriver = true; - } - if (tHatch.mSoftHammer) { - this.mSoftHammer = true; - } - if (tHatch.mHardHammer) { - this.mHardHammer = true; - } - if (tHatch.mSolderingTool) { - this.mSolderingTool = true; - } - if (tHatch.mCrowbar) { - this.mCrowbar = true; - } - } else { - this.mWrench = true; - this.mScrewdriver = true; - this.mSoftHammer = true; - this.mHardHammer = true; - this.mSolderingTool = true; - this.mCrowbar = true; - } - - tHatch.mWrench = false; - tHatch.mScrewdriver = false; - tHatch.mSoftHammer = false; - tHatch.mHardHammer = false; - tHatch.mSolderingTool = false; - tHatch.mCrowbar = false; - } - } - if (this.getRepairStatus() > 0) { - if ((this.mMaxProgresstime > 0) && this.doRandomMaintenanceDamage()) { - if (this.onRunningTick(this.mInventory[1])) { - if (!this.polluteEnvironment(this.getPollutionPerTick(this.mInventory[1]))) { - this.stopMachine(); - } - if ((this.mMaxProgresstime > 0) && (++this.mProgresstime >= this.mMaxProgresstime)) { - if (this.mOutputItems != null) { - for (final ItemStack tStack : this.mOutputItems) { - if (tStack != null) { - try { - GT_Mod.achievements.issueAchivementHatch(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), tStack); - } catch (final Exception e) { - } - this.addOutput(tStack); - } - } - } - if ((this.mOutputFluids != null) && (this.mOutputFluids.length == 1)) { - for (final FluidStack tStack : this.mOutputFluids) { - if (tStack != null) { - this.addOutput(tStack); - } - } - } else if ((this.mOutputFluids != null) && (this.mOutputFluids.length > 1)) { - this.addFluidOutputs(this.mOutputFluids); - } - this.mEfficiency = Math.max(0, Math.min(this.mEfficiency + this.mEfficiencyIncrease, this.getMaxEfficiency(this.mInventory[1]) - ((this.getIdealStatus() - this.getRepairStatus()) * 1000))); - this.mOutputItems = null; - this.mProgresstime = 0; - this.mMaxProgresstime = 0; - this.mEfficiencyIncrease = 0; - if (aBaseMetaTileEntity.isAllowedToWork()) { - this.checkRecipe(this.mInventory[1]); - } - if ((this.mOutputFluids != null) && (this.mOutputFluids.length > 0)) { - if (this.mOutputFluids.length > 1) { - GT_Mod.achievements.issueAchievement(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), "oilplant"); - } - } - } - } - } else { - if (((aTick % 100) == 0) || aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified()) { - - if (aBaseMetaTileEntity.isAllowedToWork()) { - this.checkRecipe(this.mInventory[1]); - } - if (this.mMaxProgresstime <= 0) { - this.mEfficiency = Math.max(0, this.mEfficiency - 1000); - } - } - } - } else { - this.stopMachine(); - } - } else { - this.stopMachine(); - } - } - aBaseMetaTileEntity.setErrorDisplayID((aBaseMetaTileEntity.getErrorDisplayID() & ~127) | (this.mWrench ? 0 : 1) | (this.mScrewdriver ? 0 : 2) | (this.mSoftHammer ? 0 : 4) | (this.mHardHammer ? 0 : 8) | (this.mSolderingTool ? 0 : 16) | (this.mCrowbar ? 0 : 32) | (this.mMachine ? 0 : 64)); - aBaseMetaTileEntity.setActive(this.mMaxProgresstime > 0); - } - } - - public boolean polluteEnvironment(final int aPollutionLevel) { - this.mPollution += aPollutionLevel; - for (final GT_MetaTileEntity_Hatch_Muffler tHatch : this.mMufflerHatches) { - if (isValidMetaTileEntity(tHatch)) { - if (this.mPollution >= 10000) { - if (tHatch.polluteEnvironment()) { - this.mPollution -= 10000; - } - } else { - break; - } - } - } - return this.mPollution < 10000; - } - - /** - * Called every tick the Machine runs - */ - public boolean onRunningTick(final ItemStack aStack) { - if (this.mEUt > 0) { - this.addEnergyOutput(((long) this.mEUt * this.mEfficiency) / 10000); - return true; - } - if (this.mEUt < 0) { - if (!this.drainEnergyInput(((long) -this.mEUt * 10000) / Math.max(1000, this.mEfficiency))) { - this.stopMachine(); - return false; - } - } - return true; - } - - /** - * Checks if this is a Correct Machine Part for this kind of Machine (Turbine Rotor for example) - */ - public abstract boolean isCorrectMachinePart(ItemStack aStack); - - /** - * Checks the Recipe - */ - public abstract boolean checkRecipe(ItemStack aStack); - - /** - * Checks the Machine. You have to assign the MetaTileEntities for the Hatches here. - */ - public abstract boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack); - - /** - * Gets the maximum Efficiency that spare Part can get (0 - 10000) - */ - public abstract int getMaxEfficiency(ItemStack aStack); - - /** - * Gets the pollution this Device outputs to a Muffler per tick (10000 = one Pullution Block) - */ - public abstract int getPollutionPerTick(ItemStack aStack); - - /** - * Gets the damage to the ItemStack, usually 0 or 1. - */ - public abstract int getDamageToComponent(ItemStack aStack); - - /** - * Gets the Amount of possibly outputted Items for loading the Output Stack Array from NBT. - * This should be the largest Amount that can ever happen legitimately. - */ - public abstract int getAmountOfOutputs(); - - /** - * If it explodes when the Component has to be replaced. - */ - public abstract boolean explodesOnComponentBreak(ItemStack aStack); - - public void stopMachine() { - this.mOutputItems = null; - this.mEUt = 0; - this.mEfficiency = 0; - this.mProgresstime = 0; - this.mMaxProgresstime = 0; - this.mEfficiencyIncrease = 0; - this.getBaseMetaTileEntity().disableWorking(); - } - - public int getRepairStatus() { - return (this.mWrench ? 1 : 0) + (this.mScrewdriver ? 1 : 0) + (this.mSoftHammer ? 1 : 0) + (this.mHardHammer ? 1 : 0) + (this.mSolderingTool ? 1 : 0) + (this.mCrowbar ? 1 : 0); - } - - public int getIdealStatus() { - return 6; - } - - public boolean doRandomMaintenanceDamage() { - if (!this.isCorrectMachinePart(this.mInventory[1]) || (this.getRepairStatus() == 0)) { - this.stopMachine(); - return false; - } - if (this.mRuntime++ > 1000) { - this.mRuntime = 0; - if (this.getBaseMetaTileEntity().getRandomNumber(6000) == 0) { - switch (this.getBaseMetaTileEntity().getRandomNumber(6)) { - case 0: - this.mWrench = false; - break; - case 1: - this.mScrewdriver = false; - break; - case 2: - this.mSoftHammer = false; - break; - case 3: - this.mHardHammer = false; - break; - case 4: - this.mSolderingTool = false; - break; - case 5: - this.mCrowbar = false; - break; - } - } - if ((this.mInventory[1] != null) && (this.getBaseMetaTileEntity().getRandomNumber(2) == 0) && !this.mInventory[1].getUnlocalizedName().startsWith("gt.blockmachines.basicmachine.")) { - if (this.mInventory[1].getItem() instanceof GT_MetaGenerated_Tool_01) { - final NBTTagCompound tNBT = this.mInventory[1].getTagCompound(); - if (tNBT != null) { - NBTTagCompound tNBT2 = tNBT.getCompoundTag("GT.CraftingComponents"); - if (!tNBT.getBoolean("mDis")) { - tNBT2 = new NBTTagCompound(); - final Materials tMaterial = GT_MetaGenerated_Tool.getPrimaryMaterial(this.mInventory[1]); - final ItemStack tTurbine = GT_OreDictUnificator.get(OrePrefixes.turbineBlade, tMaterial, 1); - final int i = this.mInventory[1].getItemDamage(); - if (i == 170) { - ItemStack tStack = GT_Utility.copyAmount(1, tTurbine); - tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound())); - tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Magnalium, 1); - tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound())); - } else if (i == 172) { - ItemStack tStack = GT_Utility.copyAmount(1, tTurbine); - tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.5", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.6", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.7", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.8", tStack.writeToNBT(new NBTTagCompound())); - tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Titanium, 1); - tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound())); - } else if (i == 174) { - ItemStack tStack = GT_Utility.copyAmount(2, tTurbine); - tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.5", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.6", tStack.writeToNBT(new NBTTagCompound())); - tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.TungstenSteel, 1); - tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound())); - } else if (i == 176) { - ItemStack tStack = GT_Utility.copyAmount(2, tTurbine); - tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.5", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.6", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.7", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.8", tStack.writeToNBT(new NBTTagCompound())); - tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Americium, 1); - tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound())); - } - tNBT.setTag("GT.CraftingComponents", tNBT2); - tNBT.setBoolean("mDis", true); - this.mInventory[1].setTagCompound(tNBT); - - } - } - - ((GT_MetaGenerated_Tool) this.mInventory[1].getItem()).doDamage(this.mInventory[1], (long) Math.min(this.mEUt / 5, Math.pow(this.mEUt, 0.7))); - if (this.mInventory[1].stackSize == 0) { - this.mInventory[1] = null; - } - } - } - } - return true; - } - - public void explodeMultiblock() { - this.mInventory[1] = null; - for (final MetaTileEntity tTileEntity : this.mInputBusses) { - tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); - } - for (final MetaTileEntity tTileEntity : this.mOutputBusses) { - tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); - } - for (final MetaTileEntity tTileEntity : this.mInputHatches) { - tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); - } - for (final MetaTileEntity tTileEntity : this.mOutputHatches) { - tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); - } - for (final MetaTileEntity tTileEntity : this.mDynamoHatches) { - tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); - } - for (final MetaTileEntity tTileEntity : this.mMufflerHatches) { - tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); - } - for (final MetaTileEntity tTileEntity : this.mEnergyHatches) { - tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); - } - for (final MetaTileEntity tTileEntity : this.mMaintenanceHatches) { - tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); - } - this.getBaseMetaTileEntity().doExplosion(V[8]); - } - - public boolean addEnergyOutput(final long aEU) { - if (aEU <= 0) { - return true; - } - for (final GT_MetaTileEntity_Hatch_Dynamo tHatch : this.mDynamoHatches) { - if (isValidMetaTileEntity(tHatch)) { - if (tHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(aEU, false)) { - return true; - } - } - } - return false; - } - - public long getMaxInputVoltage() { - long rVoltage = 0; - for (final GT_MetaTileEntity_Hatch_Energy tHatch : this.mEnergyHatches) { - if (isValidMetaTileEntity(tHatch)) { - rVoltage += tHatch.getBaseMetaTileEntity().getInputVoltage(); - } - } - return rVoltage; - } - - public boolean drainEnergyInput(final long aEU) { - if (aEU <= 0) { - return true; - } - for (final GT_MetaTileEntity_Hatch_Energy tHatch : this.mEnergyHatches) { - if (isValidMetaTileEntity(tHatch)) { - if (tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEU, false)) { - return true; - } - } - } - return false; - } - - public boolean addOutput(final FluidStack aLiquid) { - if (aLiquid == null) { - return false; - } - final FluidStack tLiquid = aLiquid.copy(); - for (final GT_MetaTileEntity_Hatch_Output tHatch : this.mOutputHatches) { - if (isValidMetaTileEntity(tHatch) && GT_ModHandler.isSteam(aLiquid) ? tHatch.outputsSteam() : tHatch.outputsLiquids()) { - final int tAmount = tHatch.fill(tLiquid, false); - if (tAmount >= tLiquid.amount) { - return tHatch.fill(tLiquid, true) >= tLiquid.amount; - } else if (tAmount > 0) { - tLiquid.amount = tLiquid.amount - tHatch.fill(tLiquid, true); - } - } - } - return false; - } - - private void addFluidOutputs(final FluidStack[] mOutputFluids2) { - for (int i = 0; i < mOutputFluids2.length; i++) { - if ((this.mOutputHatches.size() > i) && (this.mOutputHatches.get(i) != null) && (mOutputFluids2[i] != null) && isValidMetaTileEntity(this.mOutputHatches.get(i))) { - this.mOutputHatches.get(i).fill(mOutputFluids2[i], true); - } - } - - } - - public boolean depleteInput(final FluidStack aLiquid) { - if (aLiquid == null) { - return false; - } - for (final GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) { - tHatch.mRecipeMap = this.getRecipeMap(); - if (isValidMetaTileEntity(tHatch)) { - FluidStack tLiquid = tHatch.getFluid(); - if ((tLiquid != null) && tLiquid.isFluidEqual(aLiquid)) { - tLiquid = tHatch.drain(aLiquid.amount, false); - if ((tLiquid != null) && (tLiquid.amount >= aLiquid.amount)) { - tLiquid = tHatch.drain(aLiquid.amount, true); - return (tLiquid != null) && (tLiquid.amount >= aLiquid.amount); - } - } - } - } - return false; - } - - public boolean addOutput(ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack)) { - return false; - } - aStack = GT_Utility.copy(aStack); - // FluidStack aLiquid = GT_Utility.getFluidForFilledItem(aStack, true); - // if (aLiquid == null) { - for (final GT_MetaTileEntity_Hatch_OutputBus tHatch : this.mOutputBusses) { - if (isValidMetaTileEntity(tHatch)) { - for (int i = tHatch.getSizeInventory() - 1; i >= 0; i--) { - if (tHatch.getBaseMetaTileEntity().addStackToSlot(i, aStack)) { - return true; - } - } - } - } - for (final GT_MetaTileEntity_Hatch_Output tHatch : this.mOutputHatches) { - if (isValidMetaTileEntity(tHatch) && tHatch.outputsItems()) { - if (tHatch.getBaseMetaTileEntity().addStackToSlot(1, aStack)) { - return true; - } - } - } - // }else { - // for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { - // if (isValidMetaTileEntity(tHatch) && GT_ModHandler.isSteam(aLiquid)?tHatch.outputsSteam():tHatch.outputsLiquids()) { - // int tAmount = tHatch.fill(aLiquid, false); - // if (tAmount >= aLiquid.amount) { - // return tHatch.fill(aLiquid, true) >= aLiquid.amount; - // } - // } - // } - // } - return false; - } - - public boolean depleteInput(final ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack)) { - return false; - } - final FluidStack aLiquid = GT_Utility.getFluidForFilledItem(aStack, true); - if (aLiquid != null) { - return this.depleteInput(aLiquid); - } - for (final GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) { - tHatch.mRecipeMap = this.getRecipeMap(); - if (isValidMetaTileEntity(tHatch)) { - if (GT_Utility.areStacksEqual(aStack, tHatch.getBaseMetaTileEntity().getStackInSlot(0))) { - if (tHatch.getBaseMetaTileEntity().getStackInSlot(0).stackSize >= aStack.stackSize) { - tHatch.getBaseMetaTileEntity().decrStackSize(0, aStack.stackSize); - return true; - } - } - } - } - for (final GT_MetaTileEntity_Hatch_InputBus tHatch : this.mInputBusses) { - tHatch.mRecipeMap = this.getRecipeMap(); - if (isValidMetaTileEntity(tHatch)) { - for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { - if (GT_Utility.areStacksEqual(aStack, tHatch.getBaseMetaTileEntity().getStackInSlot(i))) { - if (tHatch.getBaseMetaTileEntity().getStackInSlot(0).stackSize >= aStack.stackSize) { - tHatch.getBaseMetaTileEntity().decrStackSize(0, aStack.stackSize); - return true; - } - } - } - } - } - return false; - } - - public ArrayList getStoredOutputs() { - final ArrayList rList = new ArrayList<>(); - for (final GT_MetaTileEntity_Hatch_Output tHatch : this.mOutputHatches) { - if (isValidMetaTileEntity(tHatch)) { - rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(1)); - } - } - for (final GT_MetaTileEntity_Hatch_OutputBus tHatch : this.mOutputBusses) { - if (isValidMetaTileEntity(tHatch)) { - for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { - rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i)); - } - } - } - return rList; - } - - public ArrayList getStoredFluids() { - final ArrayList rList = new ArrayList<>(); - for (final GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) { - tHatch.mRecipeMap = this.getRecipeMap(); - if (isValidMetaTileEntity(tHatch) && (tHatch.getFillableStack() != null)) { - rList.add(tHatch.getFillableStack()); - } - } - return rList; - } - - public ArrayList getStoredInputs() { - final ArrayList rList = new ArrayList<>(); - for (final GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) { - tHatch.mRecipeMap = this.getRecipeMap(); - if (isValidMetaTileEntity(tHatch) && (tHatch.getBaseMetaTileEntity().getStackInSlot(0) != null)) { - rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(0)); - } - } - for (final GT_MetaTileEntity_Hatch_InputBus tHatch : this.mInputBusses) { - tHatch.mRecipeMap = this.getRecipeMap(); - if (isValidMetaTileEntity(tHatch)) { - for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { - if (tHatch.getBaseMetaTileEntity().getStackInSlot(i) != null) { - rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i)); - } - } - } - } - return rList; - } - - public GT_Recipe_Map getRecipeMap() { - return null; - } - - public void updateSlots() { - for (final GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) { - if (isValidMetaTileEntity(tHatch)) { - tHatch.updateSlots(); - } - } - for (final GT_MetaTileEntity_Hatch_InputBus tHatch : this.mInputBusses) { - if (isValidMetaTileEntity(tHatch)) { - tHatch.updateSlots(); - } - } - } - - public boolean addToMachineList(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) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { - return this.mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { - return this.mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { - return this.mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { - return this.mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { - return this.mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { - return this.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { - return this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { - return this.mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); - } - return false; - } - - public boolean addMaintenanceToMachineList(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_Maintenance) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - return this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); - } - return false; - } - - public boolean addEnergyInputToMachineList(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_Energy) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - return this.mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); - } - return false; - } - - public boolean addDynamoToMachineList(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_Dynamo) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - return this.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); - } - return false; - } - - public boolean addMufflerToMachineList(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_Muffler) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - return this.mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); - } - return false; - } - - public boolean addInputToMachineList(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_Input) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = this.getRecipeMap(); - return this.mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = this.getRecipeMap(); - return this.mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); - } - return false; - } - - public boolean addOutputToMachineList(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_Output) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - return this.mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; - return this.mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); - } - return false; - } - - @Override - public String[] getInfoData() { - return new String[]{"Progress:", (this.mProgresstime / 20) + "secs", (this.mMaxProgresstime / 20) + "secs", "Efficiency:", (this.mEfficiency / 100.0F) + "%", "Problems:", "" + (this.getIdealStatus() - this.getRepairStatus())}; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { - return false; - } + public static boolean disableMaintenance; + public boolean mMachine = false, + mWrench = false, + mScrewdriver = false, + mSoftHammer = false, + mHardHammer = false, + mSolderingTool = false, + mCrowbar = false, + mRunningOnLoad = false; + public int mPollution = 0, + mProgresstime = 0, + mMaxProgresstime = 0, + mEUt = 0, + mEfficiencyIncrease = 0, + mUpdate = 0, + mStartUpCheck = 100, + mRuntime = 0, + mEfficiency = 0; + public ItemStack[] mOutputItems = null; + public FluidStack[] mOutputFluids = null; + public ArrayList mInputHatches = new ArrayList<>(); + public ArrayList mOutputHatches = new ArrayList<>(); + public ArrayList mInputBusses = new ArrayList<>(); + public ArrayList mOutputBusses = new ArrayList<>(); + public ArrayList mDynamoHatches = new ArrayList<>(); + public ArrayList mMufflerHatches = new ArrayList<>(); + public ArrayList mEnergyHatches = new ArrayList<>(); + public ArrayList mMaintenanceHatches = new ArrayList<>(); + + public DEBUG_MULTIBLOCK_ShapeSpawner(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional, 2); + DEBUG_MULTIBLOCK_ShapeSpawner.disableMaintenance = GregTech_API.sMachineFile.get( + ConfigCategories.machineconfig, "MultiBlockMachines.disableMaintenance", false); + } + + public DEBUG_MULTIBLOCK_ShapeSpawner(final String aName) { + super(aName, 2); + DEBUG_MULTIBLOCK_ShapeSpawner.disableMaintenance = GregTech_API.sMachineFile.get( + ConfigCategories.machineconfig, "MultiBlockMachines.disableMaintenance", false); + } + + public static boolean isValidMetaTileEntity(final MetaTileEntity aMetaTileEntity) { + return (aMetaTileEntity.getBaseMetaTileEntity() != null) + && (aMetaTileEntity.getBaseMetaTileEntity().getMetaTileEntity() == aMetaTileEntity) + && !aMetaTileEntity.getBaseMetaTileEntity().isDead(); + } + + @Override + public boolean allowCoverOnSide(final byte aSide, final GT_ItemStack aCoverID) { + return aSide != this.getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return true; + } + + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(final int aIndex) { + return aIndex > 0; + } + + @Override + public int getProgresstime() { + return this.mProgresstime; + } + + @Override + public int maxProgresstime() { + return this.mMaxProgresstime; + } + + @Override + public int increaseProgress(final int aProgress) { + return aProgress; + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setInteger("mEUt", this.mEUt); + aNBT.setInteger("mProgresstime", this.mProgresstime); + aNBT.setInteger("mMaxProgresstime", this.mMaxProgresstime); + aNBT.setInteger("mEfficiencyIncrease", this.mEfficiencyIncrease); + aNBT.setInteger("mEfficiency", this.mEfficiency); + aNBT.setInteger("mPollution", this.mPollution); + aNBT.setInteger("mRuntime", this.mRuntime); + + if (this.mOutputItems != null) { + for (int i = 0; i < this.mOutputItems.length; i++) { + if (this.mOutputItems[i] != null) { + final NBTTagCompound tNBT = new NBTTagCompound(); + this.mOutputItems[i].writeToNBT(tNBT); + aNBT.setTag("mOutputItem" + i, tNBT); + } + } + } + if (this.mOutputFluids != null) { + for (int i = 0; i < this.mOutputFluids.length; i++) { + if (this.mOutputFluids[i] != null) { + final NBTTagCompound tNBT = new NBTTagCompound(); + this.mOutputFluids[i].writeToNBT(tNBT); + aNBT.setTag("mOutputFluids" + i, tNBT); + } + } + } + + aNBT.setBoolean("mWrench", this.mWrench); + aNBT.setBoolean("mScrewdriver", this.mScrewdriver); + aNBT.setBoolean("mSoftHammer", this.mSoftHammer); + aNBT.setBoolean("mHardHammer", this.mHardHammer); + aNBT.setBoolean("mSolderingTool", this.mSolderingTool); + aNBT.setBoolean("mCrowbar", this.mCrowbar); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + this.mEUt = aNBT.getInteger("mEUt"); + this.mProgresstime = aNBT.getInteger("mProgresstime"); + this.mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); + if (this.mMaxProgresstime > 0) { + this.mRunningOnLoad = true; + } + this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); + this.mEfficiency = aNBT.getInteger("mEfficiency"); + this.mPollution = aNBT.getInteger("mPollution"); + this.mRuntime = aNBT.getInteger("mRuntime"); + this.mOutputItems = new ItemStack[this.getAmountOfOutputs()]; + for (int i = 0; i < this.mOutputItems.length; i++) { + this.mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i); + } + this.mOutputFluids = new FluidStack[this.getAmountOfOutputs()]; + for (int i = 0; i < this.mOutputFluids.length; i++) { + this.mOutputFluids[i] = GT_Utility.loadFluid(aNBT, "mOutputFluids" + i); + } + this.mWrench = aNBT.getBoolean("mWrench"); + this.mScrewdriver = aNBT.getBoolean("mScrewdriver"); + this.mSoftHammer = aNBT.getBoolean("mSoftHammer"); + this.mHardHammer = aNBT.getBoolean("mHardHammer"); + this.mSolderingTool = aNBT.getBoolean("mSolderingTool"); + this.mCrowbar = aNBT.getBoolean("mCrowbar"); + } + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public Object getServerGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_MultiMachine(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI( + final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine( + aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "MultiblockDisplay.png"); + } + + @Override + public byte getTileEntityBaseType() { + return 2; + } + + @Override + public void onMachineBlockUpdate() { + this.mUpdate = 50; + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mEfficiency < 0) { + this.mEfficiency = 0; + } + if ((--this.mUpdate == 0) || (--this.mStartUpCheck == 0)) { + this.mInputHatches.clear(); + this.mInputBusses.clear(); + this.mOutputHatches.clear(); + this.mOutputBusses.clear(); + this.mDynamoHatches.clear(); + this.mEnergyHatches.clear(); + this.mMufflerHatches.clear(); + this.mMaintenanceHatches.clear(); + this.mMachine = this.checkMachine(aBaseMetaTileEntity, this.mInventory[1]); + } + if (this.mStartUpCheck < 0) { + if (this.mMachine) { + for (final GT_MetaTileEntity_Hatch_Maintenance tHatch : this.mMaintenanceHatches) { + if (isValidMetaTileEntity(tHatch)) { + if (!DEBUG_MULTIBLOCK_ShapeSpawner.disableMaintenance) { + if (tHatch.mWrench) { + this.mWrench = true; + } + if (tHatch.mScrewdriver) { + this.mScrewdriver = true; + } + if (tHatch.mSoftHammer) { + this.mSoftHammer = true; + } + if (tHatch.mHardHammer) { + this.mHardHammer = true; + } + if (tHatch.mSolderingTool) { + this.mSolderingTool = true; + } + if (tHatch.mCrowbar) { + this.mCrowbar = true; + } + } else { + this.mWrench = true; + this.mScrewdriver = true; + this.mSoftHammer = true; + this.mHardHammer = true; + this.mSolderingTool = true; + this.mCrowbar = true; + } + + tHatch.mWrench = false; + tHatch.mScrewdriver = false; + tHatch.mSoftHammer = false; + tHatch.mHardHammer = false; + tHatch.mSolderingTool = false; + tHatch.mCrowbar = false; + } + } + if (this.getRepairStatus() > 0) { + if ((this.mMaxProgresstime > 0) && this.doRandomMaintenanceDamage()) { + if (this.onRunningTick(this.mInventory[1])) { + if (!this.polluteEnvironment(this.getPollutionPerTick(this.mInventory[1]))) { + this.stopMachine(); + } + if ((this.mMaxProgresstime > 0) && (++this.mProgresstime >= this.mMaxProgresstime)) { + if (this.mOutputItems != null) { + for (final ItemStack tStack : this.mOutputItems) { + if (tStack != null) { + try { + GT_Mod.achievements.issueAchivementHatch( + aBaseMetaTileEntity + .getWorld() + .getPlayerEntityByName( + aBaseMetaTileEntity.getOwnerName()), + tStack); + } catch (final Exception e) { + } + this.addOutput(tStack); + } + } + } + if ((this.mOutputFluids != null) && (this.mOutputFluids.length == 1)) { + for (final FluidStack tStack : this.mOutputFluids) { + if (tStack != null) { + this.addOutput(tStack); + } + } + } else if ((this.mOutputFluids != null) && (this.mOutputFluids.length > 1)) { + this.addFluidOutputs(this.mOutputFluids); + } + this.mEfficiency = Math.max( + 0, + Math.min( + this.mEfficiency + this.mEfficiencyIncrease, + this.getMaxEfficiency(this.mInventory[1]) + - ((this.getIdealStatus() - this.getRepairStatus()) + * 1000))); + this.mOutputItems = null; + this.mProgresstime = 0; + this.mMaxProgresstime = 0; + this.mEfficiencyIncrease = 0; + if (aBaseMetaTileEntity.isAllowedToWork()) { + this.checkRecipe(this.mInventory[1]); + } + if ((this.mOutputFluids != null) && (this.mOutputFluids.length > 0)) { + if (this.mOutputFluids.length > 1) { + GT_Mod.achievements.issueAchievement( + aBaseMetaTileEntity + .getWorld() + .getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), + "oilplant"); + } + } + } + } + } else { + if (((aTick % 100) == 0) + || aBaseMetaTileEntity.hasWorkJustBeenEnabled() + || aBaseMetaTileEntity.hasInventoryBeenModified()) { + + if (aBaseMetaTileEntity.isAllowedToWork()) { + this.checkRecipe(this.mInventory[1]); + } + if (this.mMaxProgresstime <= 0) { + this.mEfficiency = Math.max(0, this.mEfficiency - 1000); + } + } + } + } else { + this.stopMachine(); + } + } else { + this.stopMachine(); + } + } + aBaseMetaTileEntity.setErrorDisplayID((aBaseMetaTileEntity.getErrorDisplayID() & ~127) + | (this.mWrench ? 0 : 1) + | (this.mScrewdriver ? 0 : 2) + | (this.mSoftHammer ? 0 : 4) + | (this.mHardHammer ? 0 : 8) + | (this.mSolderingTool ? 0 : 16) + | (this.mCrowbar ? 0 : 32) + | (this.mMachine ? 0 : 64)); + aBaseMetaTileEntity.setActive(this.mMaxProgresstime > 0); + } + } + + public boolean polluteEnvironment(final int aPollutionLevel) { + this.mPollution += aPollutionLevel; + for (final GT_MetaTileEntity_Hatch_Muffler tHatch : this.mMufflerHatches) { + if (isValidMetaTileEntity(tHatch)) { + if (this.mPollution >= 10000) { + if (tHatch.polluteEnvironment()) { + this.mPollution -= 10000; + } + } else { + break; + } + } + } + return this.mPollution < 10000; + } + + /** + * Called every tick the Machine runs + */ + public boolean onRunningTick(final ItemStack aStack) { + if (this.mEUt > 0) { + this.addEnergyOutput(((long) this.mEUt * this.mEfficiency) / 10000); + return true; + } + if (this.mEUt < 0) { + if (!this.drainEnergyInput(((long) -this.mEUt * 10000) / Math.max(1000, this.mEfficiency))) { + this.stopMachine(); + return false; + } + } + return true; + } + + /** + * Checks if this is a Correct Machine Part for this kind of Machine (Turbine Rotor for example) + */ + public abstract boolean isCorrectMachinePart(ItemStack aStack); + + /** + * Checks the Recipe + */ + public abstract boolean checkRecipe(ItemStack aStack); + + /** + * Checks the Machine. You have to assign the MetaTileEntities for the Hatches here. + */ + public abstract boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack); + + /** + * Gets the maximum Efficiency that spare Part can get (0 - 10000) + */ + public abstract int getMaxEfficiency(ItemStack aStack); + + /** + * Gets the pollution this Device outputs to a Muffler per tick (10000 = one Pullution Block) + */ + public abstract int getPollutionPerTick(ItemStack aStack); + + /** + * Gets the damage to the ItemStack, usually 0 or 1. + */ + public abstract int getDamageToComponent(ItemStack aStack); + + /** + * Gets the Amount of possibly outputted Items for loading the Output Stack Array from NBT. + * This should be the largest Amount that can ever happen legitimately. + */ + public abstract int getAmountOfOutputs(); + + /** + * If it explodes when the Component has to be replaced. + */ + public abstract boolean explodesOnComponentBreak(ItemStack aStack); + + public void stopMachine() { + this.mOutputItems = null; + this.mEUt = 0; + this.mEfficiency = 0; + this.mProgresstime = 0; + this.mMaxProgresstime = 0; + this.mEfficiencyIncrease = 0; + this.getBaseMetaTileEntity().disableWorking(); + } + + public int getRepairStatus() { + return (this.mWrench ? 1 : 0) + + (this.mScrewdriver ? 1 : 0) + + (this.mSoftHammer ? 1 : 0) + + (this.mHardHammer ? 1 : 0) + + (this.mSolderingTool ? 1 : 0) + + (this.mCrowbar ? 1 : 0); + } + + public int getIdealStatus() { + return 6; + } + + public boolean doRandomMaintenanceDamage() { + if (!this.isCorrectMachinePart(this.mInventory[1]) || (this.getRepairStatus() == 0)) { + this.stopMachine(); + return false; + } + if (this.mRuntime++ > 1000) { + this.mRuntime = 0; + if (this.getBaseMetaTileEntity().getRandomNumber(6000) == 0) { + switch (this.getBaseMetaTileEntity().getRandomNumber(6)) { + case 0: + this.mWrench = false; + break; + case 1: + this.mScrewdriver = false; + break; + case 2: + this.mSoftHammer = false; + break; + case 3: + this.mHardHammer = false; + break; + case 4: + this.mSolderingTool = false; + break; + case 5: + this.mCrowbar = false; + break; + } + } + if ((this.mInventory[1] != null) + && (this.getBaseMetaTileEntity().getRandomNumber(2) == 0) + && !this.mInventory[1].getUnlocalizedName().startsWith("gt.blockmachines.basicmachine.")) { + if (this.mInventory[1].getItem() instanceof GT_MetaGenerated_Tool_01) { + final NBTTagCompound tNBT = this.mInventory[1].getTagCompound(); + if (tNBT != null) { + NBTTagCompound tNBT2 = tNBT.getCompoundTag("GT.CraftingComponents"); + if (!tNBT.getBoolean("mDis")) { + tNBT2 = new NBTTagCompound(); + final Materials tMaterial = GT_MetaGenerated_Tool.getPrimaryMaterial(this.mInventory[1]); + final ItemStack tTurbine = GT_OreDictUnificator.get(OrePrefixes.turbineBlade, tMaterial, 1); + final int i = this.mInventory[1].getItemDamage(); + if (i == 170) { + ItemStack tStack = GT_Utility.copyAmount(1, tTurbine); + tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound())); + tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Magnalium, 1); + tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound())); + } else if (i == 172) { + ItemStack tStack = GT_Utility.copyAmount(1, tTurbine); + tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.5", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.6", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.7", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.8", tStack.writeToNBT(new NBTTagCompound())); + tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Titanium, 1); + tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound())); + } else if (i == 174) { + ItemStack tStack = GT_Utility.copyAmount(2, tTurbine); + tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.5", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.6", tStack.writeToNBT(new NBTTagCompound())); + tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.TungstenSteel, 1); + tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound())); + } else if (i == 176) { + ItemStack tStack = GT_Utility.copyAmount(2, tTurbine); + tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.5", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.6", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.7", tStack.writeToNBT(new NBTTagCompound())); + tNBT2.setTag("Ingredient.8", tStack.writeToNBT(new NBTTagCompound())); + tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Americium, 1); + tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound())); + } + tNBT.setTag("GT.CraftingComponents", tNBT2); + tNBT.setBoolean("mDis", true); + this.mInventory[1].setTagCompound(tNBT); + } + } + + ((GT_MetaGenerated_Tool) this.mInventory[1].getItem()) + .doDamage(this.mInventory[1], (long) Math.min(this.mEUt / 5, Math.pow(this.mEUt, 0.7))); + if (this.mInventory[1].stackSize == 0) { + this.mInventory[1] = null; + } + } + } + } + return true; + } + + public void explodeMultiblock() { + this.mInventory[1] = null; + for (final MetaTileEntity tTileEntity : this.mInputBusses) { + tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + } + for (final MetaTileEntity tTileEntity : this.mOutputBusses) { + tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + } + for (final MetaTileEntity tTileEntity : this.mInputHatches) { + tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + } + for (final MetaTileEntity tTileEntity : this.mOutputHatches) { + tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + } + for (final MetaTileEntity tTileEntity : this.mDynamoHatches) { + tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + } + for (final MetaTileEntity tTileEntity : this.mMufflerHatches) { + tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + } + for (final MetaTileEntity tTileEntity : this.mEnergyHatches) { + tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + } + for (final MetaTileEntity tTileEntity : this.mMaintenanceHatches) { + tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + } + this.getBaseMetaTileEntity().doExplosion(V[8]); + } + + public boolean addEnergyOutput(final long aEU) { + if (aEU <= 0) { + return true; + } + for (final GT_MetaTileEntity_Hatch_Dynamo tHatch : this.mDynamoHatches) { + if (isValidMetaTileEntity(tHatch)) { + if (tHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(aEU, false)) { + return true; + } + } + } + return false; + } + + public long getMaxInputVoltage() { + long rVoltage = 0; + for (final GT_MetaTileEntity_Hatch_Energy tHatch : this.mEnergyHatches) { + if (isValidMetaTileEntity(tHatch)) { + rVoltage += tHatch.getBaseMetaTileEntity().getInputVoltage(); + } + } + return rVoltage; + } + + public boolean drainEnergyInput(final long aEU) { + if (aEU <= 0) { + return true; + } + for (final GT_MetaTileEntity_Hatch_Energy tHatch : this.mEnergyHatches) { + if (isValidMetaTileEntity(tHatch)) { + if (tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEU, false)) { + return true; + } + } + } + return false; + } + + public boolean addOutput(final FluidStack aLiquid) { + if (aLiquid == null) { + return false; + } + final FluidStack tLiquid = aLiquid.copy(); + for (final GT_MetaTileEntity_Hatch_Output tHatch : this.mOutputHatches) { + if (isValidMetaTileEntity(tHatch) && GT_ModHandler.isSteam(aLiquid) + ? tHatch.outputsSteam() + : tHatch.outputsLiquids()) { + final int tAmount = tHatch.fill(tLiquid, false); + if (tAmount >= tLiquid.amount) { + return tHatch.fill(tLiquid, true) >= tLiquid.amount; + } else if (tAmount > 0) { + tLiquid.amount = tLiquid.amount - tHatch.fill(tLiquid, true); + } + } + } + return false; + } + + private void addFluidOutputs(final FluidStack[] mOutputFluids2) { + for (int i = 0; i < mOutputFluids2.length; i++) { + if ((this.mOutputHatches.size() > i) + && (this.mOutputHatches.get(i) != null) + && (mOutputFluids2[i] != null) + && isValidMetaTileEntity(this.mOutputHatches.get(i))) { + this.mOutputHatches.get(i).fill(mOutputFluids2[i], true); + } + } + } + + public boolean depleteInput(final FluidStack aLiquid) { + if (aLiquid == null) { + return false; + } + for (final GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) { + tHatch.mRecipeMap = this.getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + FluidStack tLiquid = tHatch.getFluid(); + if ((tLiquid != null) && tLiquid.isFluidEqual(aLiquid)) { + tLiquid = tHatch.drain(aLiquid.amount, false); + if ((tLiquid != null) && (tLiquid.amount >= aLiquid.amount)) { + tLiquid = tHatch.drain(aLiquid.amount, true); + return (tLiquid != null) && (tLiquid.amount >= aLiquid.amount); + } + } + } + } + return false; + } + + public boolean addOutput(ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack)) { + return false; + } + aStack = GT_Utility.copy(aStack); + // FluidStack aLiquid = GT_Utility.getFluidForFilledItem(aStack, true); + // if (aLiquid == null) { + for (final GT_MetaTileEntity_Hatch_OutputBus tHatch : this.mOutputBusses) { + if (isValidMetaTileEntity(tHatch)) { + for (int i = tHatch.getSizeInventory() - 1; i >= 0; i--) { + if (tHatch.getBaseMetaTileEntity().addStackToSlot(i, aStack)) { + return true; + } + } + } + } + for (final GT_MetaTileEntity_Hatch_Output tHatch : this.mOutputHatches) { + if (isValidMetaTileEntity(tHatch) && tHatch.outputsItems()) { + if (tHatch.getBaseMetaTileEntity().addStackToSlot(1, aStack)) { + return true; + } + } + } + // }else { + // for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { + // if (isValidMetaTileEntity(tHatch) && + // GT_ModHandler.isSteam(aLiquid)?tHatch.outputsSteam():tHatch.outputsLiquids()) { + // int tAmount = tHatch.fill(aLiquid, false); + // if (tAmount >= aLiquid.amount) { + // return tHatch.fill(aLiquid, true) >= aLiquid.amount; + // } + // } + // } + // } + return false; + } + + public boolean depleteInput(final ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack)) { + return false; + } + final FluidStack aLiquid = GT_Utility.getFluidForFilledItem(aStack, true); + if (aLiquid != null) { + return this.depleteInput(aLiquid); + } + for (final GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) { + tHatch.mRecipeMap = this.getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + if (GT_Utility.areStacksEqual( + aStack, tHatch.getBaseMetaTileEntity().getStackInSlot(0))) { + if (tHatch.getBaseMetaTileEntity().getStackInSlot(0).stackSize >= aStack.stackSize) { + tHatch.getBaseMetaTileEntity().decrStackSize(0, aStack.stackSize); + return true; + } + } + } + } + for (final GT_MetaTileEntity_Hatch_InputBus tHatch : this.mInputBusses) { + tHatch.mRecipeMap = this.getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + if (GT_Utility.areStacksEqual( + aStack, tHatch.getBaseMetaTileEntity().getStackInSlot(i))) { + if (tHatch.getBaseMetaTileEntity().getStackInSlot(0).stackSize >= aStack.stackSize) { + tHatch.getBaseMetaTileEntity().decrStackSize(0, aStack.stackSize); + return true; + } + } + } + } + } + return false; + } + + public ArrayList getStoredOutputs() { + final ArrayList rList = new ArrayList<>(); + for (final GT_MetaTileEntity_Hatch_Output tHatch : this.mOutputHatches) { + if (isValidMetaTileEntity(tHatch)) { + rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(1)); + } + } + for (final GT_MetaTileEntity_Hatch_OutputBus tHatch : this.mOutputBusses) { + if (isValidMetaTileEntity(tHatch)) { + for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + } + return rList; + } + + public ArrayList getStoredFluids() { + final ArrayList rList = new ArrayList<>(); + for (final GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) { + tHatch.mRecipeMap = this.getRecipeMap(); + if (isValidMetaTileEntity(tHatch) && (tHatch.getFillableStack() != null)) { + rList.add(tHatch.getFillableStack()); + } + } + return rList; + } + + public ArrayList getStoredInputs() { + final ArrayList rList = new ArrayList<>(); + for (final GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) { + tHatch.mRecipeMap = this.getRecipeMap(); + if (isValidMetaTileEntity(tHatch) && (tHatch.getBaseMetaTileEntity().getStackInSlot(0) != null)) { + rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(0)); + } + } + for (final GT_MetaTileEntity_Hatch_InputBus tHatch : this.mInputBusses) { + tHatch.mRecipeMap = this.getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { + if (tHatch.getBaseMetaTileEntity().getStackInSlot(i) != null) { + rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + } + } + return rList; + } + + public GT_Recipe_Map getRecipeMap() { + return null; + } + + public void updateSlots() { + for (final GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) { + if (isValidMetaTileEntity(tHatch)) { + tHatch.updateSlots(); + } + } + for (final GT_MetaTileEntity_Hatch_InputBus tHatch : this.mInputBusses) { + if (isValidMetaTileEntity(tHatch)) { + tHatch.updateSlots(); + } + } + } + + public boolean addToMachineList(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) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + return this.mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { + return this.mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + return this.mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + return this.mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { + return this.mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { + return this.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { + return this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + return this.mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); + } + return false; + } + + public boolean addMaintenanceToMachineList(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_Maintenance) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + return this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); + } + return false; + } + + public boolean addEnergyInputToMachineList(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_Energy) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + return this.mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); + } + return false; + } + + public boolean addDynamoToMachineList(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_Dynamo) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + return this.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); + } + return false; + } + + public boolean addMufflerToMachineList(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_Muffler) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + return this.mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); + } + return false; + } + + public boolean addInputToMachineList(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_Input) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = this.getRecipeMap(); + return this.mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = this.getRecipeMap(); + return this.mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); + } + return false; + } + + public boolean addOutputToMachineList(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_Output) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + return this.mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + return this.mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); + } + return false; + } + + @Override + public String[] getInfoData() { + return new String[] { + "Progress:", + (this.mProgresstime / 20) + "secs", + (this.mMaxProgresstime / 20) + "secs", + "Efficiency:", + (this.mEfficiency / 100.0F) + "%", + "Problems:", + "" + (this.getIdealStatus() - this.getRepairStatus()) + }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public boolean allowPullStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack( + final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } } diff --git a/src/main/java/gtPlusPlus/core/util/debug/DEBUG_ScreenOverlay.java b/src/main/java/gtPlusPlus/core/util/debug/DEBUG_ScreenOverlay.java index 1c6a8e9278..de29c35820 100644 --- a/src/main/java/gtPlusPlus/core/util/debug/DEBUG_ScreenOverlay.java +++ b/src/main/java/gtPlusPlus/core/util/debug/DEBUG_ScreenOverlay.java @@ -1,47 +1,45 @@ package gtPlusPlus.core.util.debug; import cpw.mods.fml.common.eventhandler.SubscribeEvent; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.item.Item; - import net.minecraftforge.client.event.RenderGameOverlayEvent; public class DEBUG_ScreenOverlay extends Gui { - int width, height; - Minecraft mc = Minecraft.getMinecraft(); - - @SubscribeEvent - public void eventHandler(final RenderGameOverlayEvent.Text event) - { + int width, height; + Minecraft mc = Minecraft.getMinecraft(); - //if (mc.thePlayer.getHeldItem().equals(ModItems.itemStaballoyPickaxe)){ - final ScaledResolution res = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight); - final FontRenderer fontRender = this.mc.fontRenderer; - this.width = res.getScaledWidth(); - this.height = res.getScaledHeight(); - Minecraft.getMinecraft().entityRenderer.setupOverlayRendering(); - final String str = "Words"; - Item heldItem = null; + @SubscribeEvent + public void eventHandler(final RenderGameOverlayEvent.Text event) { - try{heldItem = this.mc.thePlayer.getHeldItem().getItem(); + // if (mc.thePlayer.getHeldItem().equals(ModItems.itemStaballoyPickaxe)){ + final ScaledResolution res = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight); + final FontRenderer fontRender = this.mc.fontRenderer; + this.width = res.getScaledWidth(); + this.height = res.getScaledHeight(); + Minecraft.getMinecraft().entityRenderer.setupOverlayRendering(); + final String str = "Words"; + Item heldItem = null; - if (heldItem != null){ - /*if (heldItem instanceof StaballoyPickaxe){ + try { + heldItem = this.mc.thePlayer.getHeldItem().getItem(); - int dmg =((StaballoyPickaxe) heldItem).getDamage(((StaballoyPickaxe) heldItem).thisPickaxe); + if (heldItem != null) { + /*if (heldItem instanceof StaballoyPickaxe){ - ((StaballoyPickaxe) heldItem).checkFacing(((StaballoyPickaxe) heldItem).localWorld); - str = "DAMAGE: "+ dmg +" | FACING: "+((StaballoyPickaxe) heldItem).FACING+" | FACING_HORIZONTAL: "+((StaballoyPickaxe) heldItem).FACING_HORIZONTAL+" | LOOKING DIRECTION: "+((StaballoyPickaxe) heldItem).lookingDirection; + int dmg =((StaballoyPickaxe) heldItem).getDamage(((StaballoyPickaxe) heldItem).thisPickaxe); - drawString(fontRender, str, (this.width - fontRender.getStringWidth(str)) / 2, this.height / 10, 0xFFAA00); - }*/ - } - }catch(final NullPointerException e){} + ((StaballoyPickaxe) heldItem).checkFacing(((StaballoyPickaxe) heldItem).localWorld); + str = "DAMAGE: "+ dmg +" | FACING: "+((StaballoyPickaxe) heldItem).FACING+" | FACING_HORIZONTAL: "+((StaballoyPickaxe) heldItem).FACING_HORIZONTAL+" | LOOKING DIRECTION: "+((StaballoyPickaxe) heldItem).lookingDirection; - } -} \ No newline at end of file + drawString(fontRender, str, (this.width - fontRender.getStringWidth(str)) / 2, this.height / 10, 0xFFAA00); + }*/ + } + } catch (final NullPointerException e) { + } + } +} diff --git a/src/main/java/gtPlusPlus/core/util/debug/DEBUG_TimerThread.java b/src/main/java/gtPlusPlus/core/util/debug/DEBUG_TimerThread.java index 50d12871cb..004657ebcc 100644 --- a/src/main/java/gtPlusPlus/core/util/debug/DEBUG_TimerThread.java +++ b/src/main/java/gtPlusPlus/core/util/debug/DEBUG_TimerThread.java @@ -1,64 +1,62 @@ package gtPlusPlus.core.util.debug; +import gtPlusPlus.api.objects.Logger; import java.util.concurrent.TimeUnit; - import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.world.World; - -import gtPlusPlus.api.objects.Logger; import net.minecraftforge.common.util.ForgeDirection; public class DEBUG_TimerThread implements Runnable { - private final World world; - private final EntityPlayer player; - - - public DEBUG_TimerThread(final World WORLD, final EntityPlayer PLAYER) { - this.world = WORLD; - this.player = PLAYER; - } - - @Override - public void run(){ - int xDir = ForgeDirection.getOrientation(this.player.getPlayerCoordinates().posX).offsetX; - int zDir = ForgeDirection.getOrientation(this.player.getPlayerCoordinates().posZ).offsetZ; - - final int stepX = Minecraft.getMinecraft().objectMouseOver.blockX; - final int stepY = Minecraft.getMinecraft().objectMouseOver.blockY; - final int stepZ = Minecraft.getMinecraft().objectMouseOver.blockZ; - Logger.INFO("Clicked on a Block @ "+"[X:"+stepX+"][Y:"+stepY+"][Z:"+stepZ+"]"+" with xDir:"+xDir+" zDir:"+zDir); - this.world.setBlock(stepX, stepY, stepZ, Blocks.bedrock,0,3); - Logger.INFO("Makng it Bedrock for future investment."); - //for (int i = -1; i <= 1; i++) { - //stepX = stepX+i; - for (int i = stepX-1; i <= (stepX+1); i++){ - for (int j = stepZ-1; j <= (stepZ+1); j++){ - for (int h = stepY-1; h <= (stepY+1); h++){ - - xDir = ForgeDirection.getOrientation(this.player.getPlayerCoordinates().posX).offsetX; - zDir = ForgeDirection.getOrientation(this.player.getPlayerCoordinates().posZ).offsetZ; - - //for (int j = -1; j <= 1; j++) { - //stepZ = stepZ+j; - //for (int h = -1; h <= 1; h++) { - //stepY = stepY+h; - Logger.INFO("Placing Block @ "+"[X:"+i+"][Y:"+h+"][Z:"+j+"]"+" with xDir:"+xDir+" zDir:"+zDir); - if ((h != 0) || ((((xDir + i) != 0) || ((zDir + j) != 0)) && ((i != 0) || (j != 0)))) { - this.world.setBlock(i, h, j, Blocks.stone,0,3); - } - else { - Logger.INFO("Not even sure what this is for, but I got here."); - } - try { - TimeUnit.MILLISECONDS.sleep(500); - } catch (final InterruptedException e1) { - e1.printStackTrace(); - } - } - } - } - } -} \ No newline at end of file + private final World world; + private final EntityPlayer player; + + public DEBUG_TimerThread(final World WORLD, final EntityPlayer PLAYER) { + this.world = WORLD; + this.player = PLAYER; + } + + @Override + public void run() { + int xDir = ForgeDirection.getOrientation(this.player.getPlayerCoordinates().posX).offsetX; + int zDir = ForgeDirection.getOrientation(this.player.getPlayerCoordinates().posZ).offsetZ; + + final int stepX = Minecraft.getMinecraft().objectMouseOver.blockX; + final int stepY = Minecraft.getMinecraft().objectMouseOver.blockY; + final int stepZ = Minecraft.getMinecraft().objectMouseOver.blockZ; + Logger.INFO("Clicked on a Block @ " + "[X:" + stepX + "][Y:" + stepY + "][Z:" + stepZ + "]" + " with xDir:" + + xDir + " zDir:" + zDir); + this.world.setBlock(stepX, stepY, stepZ, Blocks.bedrock, 0, 3); + Logger.INFO("Makng it Bedrock for future investment."); + // for (int i = -1; i <= 1; i++) { + // stepX = stepX+i; + for (int i = stepX - 1; i <= (stepX + 1); i++) { + for (int j = stepZ - 1; j <= (stepZ + 1); j++) { + for (int h = stepY - 1; h <= (stepY + 1); h++) { + + xDir = ForgeDirection.getOrientation(this.player.getPlayerCoordinates().posX).offsetX; + zDir = ForgeDirection.getOrientation(this.player.getPlayerCoordinates().posZ).offsetZ; + + // for (int j = -1; j <= 1; j++) { + // stepZ = stepZ+j; + // for (int h = -1; h <= 1; h++) { + // stepY = stepY+h; + Logger.INFO("Placing Block @ " + "[X:" + i + "][Y:" + h + "][Z:" + j + "]" + " with xDir:" + xDir + + " zDir:" + zDir); + if ((h != 0) || ((((xDir + i) != 0) || ((zDir + j) != 0)) && ((i != 0) || (j != 0)))) { + this.world.setBlock(i, h, j, Blocks.stone, 0, 3); + } else { + Logger.INFO("Not even sure what this is for, but I got here."); + } + try { + TimeUnit.MILLISECONDS.sleep(500); + } catch (final InterruptedException e1) { + e1.printStackTrace(); + } + } + } + } + } +} diff --git a/src/main/java/gtPlusPlus/core/util/debug/UtilityGL11Debug.java b/src/main/java/gtPlusPlus/core/util/debug/UtilityGL11Debug.java index 7cb1054d53..cf3580f5b7 100644 --- a/src/main/java/gtPlusPlus/core/util/debug/UtilityGL11Debug.java +++ b/src/main/java/gtPlusPlus/core/util/debug/UtilityGL11Debug.java @@ -1,343 +1,1139 @@ package gtPlusPlus.core.util.debug; import java.nio.ByteBuffer; - import org.lwjgl.BufferUtils; import org.lwjgl.opengl.GL11; - /** * User: The Grey Ghost * Date: 9/02/14 */ -public class UtilityGL11Debug -{ - public class GLproperty - { - public GLproperty(final int init_gLconstant, final String init_name, final String init_description, final String init_category, final String init_fetchCommand) { - this.gLconstant = init_gLconstant; - this.name = init_name; - this.description = init_description; - this.category = init_category; - this.fetchCommand = init_fetchCommand; - } +public class UtilityGL11Debug { + public class GLproperty { + public GLproperty( + final int init_gLconstant, + final String init_name, + final String init_description, + final String init_category, + final String init_fetchCommand) { + this.gLconstant = init_gLconstant; + this.name = init_name; + this.description = init_description; + this.category = init_category; + this.fetchCommand = init_fetchCommand; + } - public int gLconstant; - public String name; - public String description; - public String category; - public String fetchCommand; - } + public int gLconstant; + public String name; + public String description; + public String category; + public String fetchCommand; + } - public static UtilityGL11Debug instance = new UtilityGL11Debug(); + public static UtilityGL11Debug instance = new UtilityGL11Debug(); - public GLproperty[] propertyList = + public GLproperty[] propertyList = { + new GLproperty(GL11.GL_CURRENT_COLOR, "GL_CURRENT_COLOR", "Current color", "current", "glGetFloatv()"), + new GLproperty(GL11.GL_CURRENT_INDEX, "GL_CURRENT_INDEX", "Current color index", "current", "glGetFloatv()"), + new GLproperty( + GL11.GL_CURRENT_TEXTURE_COORDS, + "GL_CURRENT_TEXTURE_COORDS", + "Current texture coordinates", + "current", + "glGetFloatv()"), + new GLproperty(GL11.GL_CURRENT_NORMAL, "GL_CURRENT_NORMAL", "Current normal", "current", "glGetFloatv()"), + new GLproperty( + GL11.GL_CURRENT_RASTER_POSITION, + "GL_CURRENT_RASTER_POSITION", + "Current raster position", + "current", + "glGetFloatv()"), + new GLproperty( + GL11.GL_CURRENT_RASTER_DISTANCE, + "GL_CURRENT_RASTER_DISTANCE", + "Current raster distance", + "current", + "glGetFloatv()"), + new GLproperty( + GL11.GL_CURRENT_RASTER_COLOR, + "GL_CURRENT_RASTER_COLOR", + "Color associated with raster position", + "current", + "glGetFloatv()"), + new GLproperty( + GL11.GL_CURRENT_RASTER_INDEX, + "GL_CURRENT_RASTER_INDEX", + "Color index associated with raster position", + "current", + "glGetFloatv()"), + new GLproperty( + GL11.GL_CURRENT_RASTER_TEXTURE_COORDS, + "GL_CURRENT_RASTER_TEXTURE_COORDS", + "Texture coordinates associated with raster position", + "current", + "glGetFloatv()"), + new GLproperty( + GL11.GL_CURRENT_RASTER_POSITION_VALID, + "GL_CURRENT_RASTER_POSITION_VALID", + "Raster position valid bit", + "current", + "glGetBooleanv()"), + new GLproperty(GL11.GL_EDGE_FLAG, "GL_EDGE_FLAG", "Edge flag", "current", "glGetBooleanv()"), + new GLproperty(GL11.GL_VERTEX_ARRAY, "GL_VERTEX_ARRAY", "Vertex array enable", "vertex-array", "glIsEnabled()"), + new GLproperty( + GL11.GL_VERTEX_ARRAY_SIZE, + "GL_VERTEX_ARRAY_SIZE", + "Coordinates per vertex", + "vertex-array", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_VERTEX_ARRAY_TYPE, + "GL_VERTEX_ARRAY_TYPE", + "Type of vertex coordinates", + "vertex-array", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_VERTEX_ARRAY_STRIDE, + "GL_VERTEX_ARRAY_STRIDE", + "Stride between vertices", + "vertex-array", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_VERTEX_ARRAY_POINTER, + "GL_VERTEX_ARRAY_POINTER", + "Pointer to the vertex array", + "vertex-array", + "glGetPointerv()"), + new GLproperty(GL11.GL_NORMAL_ARRAY, "GL_NORMAL_ARRAY", "Normal array enable", "vertex-array", "glIsEnabled()"), + new GLproperty( + GL11.GL_NORMAL_ARRAY_TYPE, + "GL_NORMAL_ARRAY_TYPE", + "Type of normal coordinates", + "vertex-array", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_NORMAL_ARRAY_STRIDE, + "GL_NORMAL_ARRAY_STRIDE", + "Stride between normals", + "vertex-array", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_NORMAL_ARRAY_POINTER, + "GL_NORMAL_ARRAY_POINTER", + "Pointer to the normal array", + "vertex-array", + "glGetPointerv()"), + new GLproperty( + GL11.GL_COLOR_ARRAY, "GL_COLOR_ARRAY", "RGBA color array enable", "vertex-array", "glIsEnabled()"), + new GLproperty( + GL11.GL_COLOR_ARRAY_SIZE, + "GL_COLOR_ARRAY_SIZE", + "Colors per vertex", + "vertex-array", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_COLOR_ARRAY_TYPE, + "GL_COLOR_ARRAY_TYPE", + "Type of color components", + "vertex-array", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_COLOR_ARRAY_STRIDE, + "GL_COLOR_ARRAY_STRIDE", + "Stride between colors", + "vertex-array", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_COLOR_ARRAY_POINTER, + "GL_COLOR_ARRAY_POINTER", + "Pointer to the color array", + "vertex-array", + "glGetPointerv()"), + new GLproperty( + GL11.GL_INDEX_ARRAY, "GL_INDEX_ARRAY", "Color-index array enable", "vertex-array", "glIsEnabled()"), + new GLproperty( + GL11.GL_INDEX_ARRAY_TYPE, + "GL_INDEX_ARRAY_TYPE", + "Type of color indices", + "vertex-array", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_INDEX_ARRAY_STRIDE, + "GL_INDEX_ARRAY_STRIDE", + "Stride between color indices", + "vertex-array", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_INDEX_ARRAY_POINTER, + "GL_INDEX_ARRAY_POINTER", + "Pointer to the index array", + "vertex-array", + "glGetPointerv()"), + new GLproperty( + GL11.GL_TEXTURE_COORD_ARRAY, + "GL_TEXTURE_COORD_ARRAY", + "Texture coordinate array enable", + "vertex-array", + "glIsEnabled()"), + new GLproperty( + GL11.GL_TEXTURE_COORD_ARRAY_SIZE, + "GL_TEXTURE_COORD_ARRAY_SIZE", + "Texture coordinates per element", + "vertex-array", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_TEXTURE_COORD_ARRAY_TYPE, + "GL_TEXTURE_COORD_ARRAY_TYPE", + "Type of texture coordinates", + "vertex-array", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_TEXTURE_COORD_ARRAY_STRIDE, + "GL_TEXTURE_COORD_ARRAY_STRIDE", + "Stride between texture coordinates", + "vertex-array", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_TEXTURE_COORD_ARRAY_POINTER, + "GL_TEXTURE_COORD_ARRAY_POINTER", + "Pointer to the texture coordinate array", + "vertex-array", + "glGetPointerv()"), + new GLproperty( + GL11.GL_EDGE_FLAG_ARRAY, + "GL_EDGE_FLAG_ARRAY", + "Edge flag array enable", + "vertex-array", + "glIsEnabled()"), + new GLproperty( + GL11.GL_EDGE_FLAG_ARRAY_STRIDE, + "GL_EDGE_FLAG_ARRAY_STRIDE", + "Stride between edge flags", + "vertex-array", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_EDGE_FLAG_ARRAY_POINTER, + "GL_EDGE_FLAG_ARRAY_POINTER", + "Pointer to the edge flag array", + "vertex-array", + "glGetPointerv()"), + new GLproperty( + GL11.GL_MODELVIEW_MATRIX, "GL_MODELVIEW_MATRIX", "Modelview matrix stack", "matrix", "glGetFloatv()"), + new GLproperty( + GL11.GL_PROJECTION_MATRIX, + "GL_PROJECTION_MATRIX", + "Projection matrix stack", + "matrix", + "glGetFloatv()"), + new GLproperty(GL11.GL_TEXTURE_MATRIX, "GL_TEXTURE_MATRIX", "Texture matrix stack", "matrix", "glGetFloatv()"), + new GLproperty(GL11.GL_VIEWPORT, "GL_VIEWPORT", "Viewport origin and extent", "viewport", "glGetIntegerv()"), + new GLproperty(GL11.GL_DEPTH_RANGE, "GL_DEPTH_RANGE", "Depth range near and far", "viewport", "glGetFloatv()"), + new GLproperty( + GL11.GL_MODELVIEW_STACK_DEPTH, + "GL_MODELVIEW_STACK_DEPTH", + "Modelview matrix stack pointer", + "matrix", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_PROJECTION_STACK_DEPTH, + "GL_PROJECTION_STACK_DEPTH", + "Projection matrix stack pointer", + "matrix", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_TEXTURE_STACK_DEPTH, + "GL_TEXTURE_STACK_DEPTH", + "Texture matrix stack pointer", + "matrix", + "glGetIntegerv()"), + new GLproperty(GL11.GL_MATRIX_MODE, "GL_MATRIX_MODE", "Current matrix mode", "transform", "glGetIntegerv()"), + new GLproperty( + GL11.GL_NORMALIZE, + "GL_NORMALIZE", + "Current normal normalization on/off", + "transform/ enable", + "glIsEnabled()"), + new GLproperty(GL11.GL_FOG_COLOR, "GL_FOG_COLOR", "Fog color", "fog", "glGetFloatv()"), + new GLproperty(GL11.GL_FOG_INDEX, "GL_FOG_INDEX", "Fog index", "fog", "glGetFloatv()"), + new GLproperty(GL11.GL_FOG_DENSITY, "GL_FOG_DENSITY", "Exponential fog density", "fog", "glGetFloatv()"), + new GLproperty(GL11.GL_FOG_START, "GL_FOG_START", "Linear fog start", "fog", "glGetFloatv()"), + new GLproperty(GL11.GL_FOG_END, "GL_FOG_END", "Linear fog end", "fog", "glGetFloatv()"), + new GLproperty(GL11.GL_FOG_MODE, "GL_FOG_MODE", "Fog mode", "fog", "glGetIntegerv()"), + new GLproperty(GL11.GL_FOG, "GL_FOG", "True if fog enabled", "fog/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_SHADE_MODEL, "GL_SHADE_MODEL", "glShadeModel() setting", "lighting", "glGetIntegerv()"), + new GLproperty( + GL11.GL_LIGHTING, "GL_LIGHTING", "True if lighting is enabled", "lighting/e nable", "glIsEnabled()"), + new GLproperty( + GL11.GL_COLOR_MATERIAL, + "GL_COLOR_MATERIAL", + "True if color tracking is enabled", + "lighting", + "glIsEnabled()"), + new GLproperty( + GL11.GL_COLOR_MATERIAL_PARAMETER, + "GL_COLOR_MATERIAL_PARAMETER", + "Material properties tracking current color", + "lighting", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_COLOR_MATERIAL_FACE, + "GL_COLOR_MATERIAL_FACE", + "Face(s) affected by color tracking", + "lighting", + "glGetIntegerv()"), + new GLproperty(GL11.GL_AMBIENT, "GL_AMBIENT", "Ambient material color", "lighting", "glGetMaterialfv()"), + new GLproperty(GL11.GL_DIFFUSE, "GL_DIFFUSE", "Diffuse material color", "lighting", "glGetMaterialfv()"), + new GLproperty(GL11.GL_SPECULAR, "GL_SPECULAR", "Specular material color", "lighting", "glGetMaterialfv()"), + new GLproperty(GL11.GL_EMISSION, "GL_EMISSION", "Emissive material color", "lighting", "glGetMaterialfv()"), + new GLproperty( + GL11.GL_SHININESS, "GL_SHININESS", "Specular exponent of material", "lighting", "glGetMaterialfv()"), + new GLproperty( + GL11.GL_LIGHT_MODEL_AMBIENT, + "GL_LIGHT_MODEL_AMBIENT", + "Ambient scene color", + "lighting", + "glGetFloatv()"), + new GLproperty( + GL11.GL_LIGHT_MODEL_LOCAL_VIEWER, + "GL_LIGHT_MODEL_LOCAL_VIEWER", + "Viewer is local", + "lighting", + "glGetBooleanv()"), + new GLproperty( + GL11.GL_LIGHT_MODEL_TWO_SIDE, + "GL_LIGHT_MODEL_TWO_SIDE", + "Use two-sided lighting", + "lighting", + "glGetBooleanv()"), + new GLproperty(GL11.GL_AMBIENT, "GL_AMBIENT", "Ambient intensity of light i", "lighting", "glGetLightfv()"), + new GLproperty(GL11.GL_DIFFUSE, "GL_DIFFUSE", "Diffuse intensity of light i", "lighting", "glGetLightfv()"), + new GLproperty(GL11.GL_SPECULAR, "GL_SPECULAR", "Specular intensity of light i", "lighting", "glGetLightfv()"), + new GLproperty(GL11.GL_POSITION, "GL_POSITION", "Position of light i", "lighting", "glGetLightfv()"), + new GLproperty( + GL11.GL_CONSTANT_ATTENUATION, + "GL_CONSTANT_ATTENUATION", + "Constant attenuation factor", + "lighting", + "glGetLightfv()"), + new GLproperty( + GL11.GL_LINEAR_ATTENUATION, + "GL_LINEAR_ATTENUATION", + "Linear attenuation factor", + "lighting", + "glGetLightfv()"), + new GLproperty( + GL11.GL_QUADRATIC_ATTENUATION, + "GL_QUADRATIC_ATTENUATION", + "Quadratic attenuation factor", + "lighting", + "glGetLightfv()"), + new GLproperty( + GL11.GL_SPOT_DIRECTION, + "GL_SPOT_DIRECTION", + "Spotlight direction of light i", + "lighting", + "glGetLightfv()"), + new GLproperty( + GL11.GL_SPOT_EXPONENT, + "GL_SPOT_EXPONENT", + "Spotlight exponent of light i", + "lighting", + "glGetLightfv()"), + new GLproperty( + GL11.GL_SPOT_CUTOFF, "GL_SPOT_CUTOFF", "Spotlight angle of light i", "lighting", "glGetLightfv()"), + new GLproperty(GL11.GL_LIGHT0, "GL_LIGHT0", "True if light 0 enabled", "lighting/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_LIGHT1, "GL_LIGHT1", "True if light 1 enabled", "lighting/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_LIGHT2, "GL_LIGHT2", "True if light 2 enabled", "lighting/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_LIGHT3, "GL_LIGHT3", "True if light 3 enabled", "lighting/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_LIGHT4, "GL_LIGHT4", "True if light 4 enabled", "lighting/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_LIGHT5, "GL_LIGHT5", "True if light 5 enabled", "lighting/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_LIGHT6, "GL_LIGHT6", "True if light 6 enabled", "lighting/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_LIGHT7, "GL_LIGHT7", "True if light 7 enabled", "lighting/enable", "glIsEnabled()"), + new GLproperty( + GL11.GL_COLOR_INDEXES, + "GL_COLOR_INDEXES", + "ca, cd, and cs for color-index lighting", + "lighting/e nable", + "glGetMaterialfv()"), + new GLproperty(GL11.GL_POINT_SIZE, "GL_POINT_SIZE", "Point size", "point", "glGetFloatv()"), + new GLproperty( + GL11.GL_POINT_SMOOTH, "GL_POINT_SMOOTH", "Point antialiasing on", "point/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_LINE_WIDTH, "GL_LINE_WIDTH", "Line width", "line", "glGetFloatv()"), + new GLproperty(GL11.GL_LINE_SMOOTH, "GL_LINE_SMOOTH", "Line antialiasing on", "line/enable", "glIsEnabled()"), + new GLproperty( + GL11.GL_LINE_STIPPLE_PATTERN, "GL_LINE_STIPPLE_PATTERN", "Line stipple", "line", "glGetIntegerv()"), + new GLproperty( + GL11.GL_LINE_STIPPLE_REPEAT, + "GL_LINE_STIPPLE_REPEAT", + "Line stipple repeat", + "line", + "glGetIntegerv()"), + new GLproperty(GL11.GL_LINE_STIPPLE, "GL_LINE_STIPPLE", "Line stipple enable", "line/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_CULL_FACE, "GL_CULL_FACE", "Polygon culling enabled", "polygon/enable", "glIsEnabled()"), + new GLproperty( + GL11.GL_CULL_FACE_MODE, + "GL_CULL_FACE_MODE", + "Cull front-/back-facing polygons", + "polygon", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_FRONT_FACE, + "GL_FRONT_FACE", + "Polygon front-face CW/CCW indicator", + "polygon", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_POLYGON_SMOOTH, + "GL_POLYGON_SMOOTH", + "Polygon antialiasing on", + "polygon/enable", + "glIsEnabled()"), + new GLproperty( + GL11.GL_POLYGON_MODE, + "GL_POLYGON_MODE", + "Polygon rasterization mode (front and back)", + "polygon", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_POLYGON_OFFSET_FACTOR, + "GL_POLYGON_OFFSET_FACTOR", + "Polygon offset factor", + "polygon", + "glGetFloatv()"), + new GLproperty( + GL11.GL_POLYGON_OFFSET_POINT, + "GL_POLYGON_OFFSET_POINT", + "Polygon offset enable for GL_POINT mode rasterization", + "polygon/enable", + "glIsEnabled()"), + new GLproperty( + GL11.GL_POLYGON_OFFSET_LINE, + "GL_POLYGON_OFFSET_LINE", + "Polygon offset enable for GL_LINE mode rasterization", + "polygon/enable", + "glIsEnabled()"), + new GLproperty( + GL11.GL_POLYGON_OFFSET_FILL, + "GL_POLYGON_OFFSET_FILL", + "Polygon offset enable for GL_FILL mode rasterization", + "polygon/enable", + "glIsEnabled()"), + new GLproperty( + GL11.GL_POLYGON_STIPPLE, + "GL_POLYGON_STIPPLE", + "Polygon stipple enable", + "polygon/enable", + "glIsEnabled()"), + new GLproperty( + GL11.GL_TEXTURE_1D, + "GL_TEXTURE_1D", + "True if 1-D texturing enabled ", + "texture/enable", + "glIsEnabled()"), + new GLproperty( + GL11.GL_TEXTURE_2D, + "GL_TEXTURE_2D", + "True if 2-D texturing enabled ", + "texture/enable", + "glIsEnabled()"), + new GLproperty( + GL11.GL_TEXTURE_BINDING_1D, + "GL_TEXTURE_BINDING_1D", + "Texture object bound to GL_TEXTURE_1D", + "texture", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_TEXTURE_BINDING_2D, + "GL_TEXTURE_BINDING_2D", + "Texture object bound to GL_TEXTURE_2D", + "texture", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_TEXTURE, "GL_TEXTURE", "x-D texture image at level of detail i", "UNUSED", "glGetTexImage()"), + new GLproperty( + GL11.GL_TEXTURE_WIDTH, + "GL_TEXTURE_WIDTH", + "x-D texture image i's width", + "UNUSED", + "glGetTexLevelParameter*()"), + new GLproperty( + GL11.GL_TEXTURE_HEIGHT, + "GL_TEXTURE_HEIGHT", + "x-D texture image i's height", + "UNUSED", + "glGetTexLevelParameter*()"), + new GLproperty( + GL11.GL_TEXTURE_BORDER, + "GL_TEXTURE_BORDER", + "x-D texture image i's border width", + "UNUSED", + "glGetTexLevelParameter*()"), + new GLproperty( + GL11.GL_TEXTURE_RED_SIZE, + "GL_TEXTURE_RED_SIZE", + "x-D texture image i's red resolution", + "UNUSED", + "glGetTexLevelParameter*()"), + new GLproperty( + GL11.GL_TEXTURE_GREEN_SIZE, + "GL_TEXTURE_GREEN_SIZE", + "x-D texture image i's green resolution", + "UNUSED", + "glGetTexLevelParameter*()"), + new GLproperty( + GL11.GL_TEXTURE_BLUE_SIZE, + "GL_TEXTURE_BLUE_SIZE", + "x-D texture image i's blue resolution", + "UNUSED", + "glGetTexLevelParameter*()"), + new GLproperty( + GL11.GL_TEXTURE_ALPHA_SIZE, + "GL_TEXTURE_ALPHA_SIZE", + "x-D texture image i's alpha resolution", + "UNUSED", + "glGetTexLevelParameter*()"), + new GLproperty( + GL11.GL_TEXTURE_LUMINANCE_SIZE, + "GL_TEXTURE_LUMINANCE_SIZE", + "x-D texture image i's luminance resolution", + "UNUSED", + "glGetTexLevelParameter*()"), + new GLproperty( + GL11.GL_TEXTURE_INTENSITY_SIZE, + "GL_TEXTURE_INTENSITY_SIZE", + "x-D texture image i's intensity resolution", + "UNUSED", + "glGetTexLevelParameter*()"), + new GLproperty( + GL11.GL_TEXTURE_BORDER_COLOR, + "GL_TEXTURE_BORDER_COLOR", + "Texture border color", + "texture", + "glGetTexParameter*()"), + new GLproperty( + GL11.GL_TEXTURE_MIN_FILTER, + "GL_TEXTURE_MIN_FILTER", + "Texture minification function", + "texture", + "glGetTexParameter*()"), + new GLproperty( + GL11.GL_TEXTURE_MAG_FILTER, + "GL_TEXTURE_MAG_FILTER", + "Texture magnification function", + "texture", + "glGetTexParameter*()"), + new GLproperty( + GL11.GL_TEXTURE_WRAP_S, + "GL_TEXTURE_WRAP_S", + "Texture wrap mode (x is S or T)", + "texture", + "glGetTexParameter*()"), + new GLproperty( + GL11.GL_TEXTURE_WRAP_T, + "GL_TEXTURE_WRAP_T", + "Texture wrap mode (x is S or T)", + "texture", + "glGetTexParameter*()"), + new GLproperty( + GL11.GL_TEXTURE_PRIORITY, + "GL_TEXTURE_PRIORITY", + "Texture object priority", + "texture", + "glGetTexParameter*()"), + new GLproperty( + GL11.GL_TEXTURE_ENV_MODE, + "GL_TEXTURE_ENV_MODE", + "Texture application function", + "texture", + "glGetTexEnviv()"), + new GLproperty( + GL11.GL_TEXTURE_ENV_COLOR, + "GL_TEXTURE_ENV_COLOR", + "Texture environment color", + "texture", + "glGetTexEnvfv()"), + new GLproperty( + GL11.GL_TEXTURE_GEN_S, + "GL_TEXTURE_GEN_S", + "Texgen enabled (x is S, T, R, or Q)", + "texture/enable", + "glIsEnabled()"), + new GLproperty( + GL11.GL_TEXTURE_GEN_T, + "GL_TEXTURE_GEN_T", + "Texgen enabled (x is S, T, R, or Q)", + "texture/enable", + "glIsEnabled()"), + new GLproperty( + GL11.GL_TEXTURE_GEN_R, + "GL_TEXTURE_GEN_R", + "Texgen enabled (x is S, T, R, or Q)", + "texture/enable", + "glIsEnabled()"), + new GLproperty( + GL11.GL_TEXTURE_GEN_Q, + "GL_TEXTURE_GEN_Q", + "Texgen enabled (x is S, T, R, or Q)", + "texture/enable", + "glIsEnabled()"), + new GLproperty( + GL11.GL_EYE_PLANE, "GL_EYE_PLANE", "Texgen plane equation coefficients", "texture", "glGetTexGenfv()"), + new GLproperty( + GL11.GL_OBJECT_PLANE, + "GL_OBJECT_PLANE", + "Texgen object linear coefficients", + "texture", + "glGetTexGenfv()"), + new GLproperty( + GL11.GL_TEXTURE_GEN_MODE, + "GL_TEXTURE_GEN_MODE", + "Function used for texgen", + "texture", + "glGetTexGeniv()"), + new GLproperty( + GL11.GL_SCISSOR_TEST, "GL_SCISSOR_TEST", "Scissoring enabled", "scissor/enable", "glIsEnabled()"), + new GLproperty(GL11.GL_SCISSOR_BOX, "GL_SCISSOR_BOX", "Scissor box", "scissor", "glGetIntegerv()"), + new GLproperty( + GL11.GL_ALPHA_TEST, "GL_ALPHA_TEST", "Alpha test enabled", "color-buffer/enable", "glIsEnabled()"), + new GLproperty( + GL11.GL_ALPHA_TEST_FUNC, + "GL_ALPHA_TEST_FUNC", + "Alpha test function", + "color-buffer", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_ALPHA_TEST_REF, + "GL_ALPHA_TEST_REF", + "Alpha test reference value", + "color-buffer", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_STENCIL_TEST, + "GL_STENCIL_TEST", + "Stenciling enabled", + "stencil-buffer/enable", + "glIsEnabled()"), + new GLproperty( + GL11.GL_STENCIL_FUNC, "GL_STENCIL_FUNC", "Stencil function", "stencil-buffer", "glGetIntegerv()"), + new GLproperty( + GL11.GL_STENCIL_VALUE_MASK, + "GL_STENCIL_VALUE_MASK", + "Stencil mask", + "stencil-buffer", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_STENCIL_REF, "GL_STENCIL_REF", "Stencil reference value", "stencil-buffer", "glGetIntegerv()"), + new GLproperty( + GL11.GL_STENCIL_FAIL, "GL_STENCIL_FAIL", "Stencil fail action", "stencil-buffer", "glGetIntegerv()"), + new GLproperty( + GL11.GL_STENCIL_PASS_DEPTH_FAIL, + "GL_STENCIL_PASS_DEPTH_FAIL", + "Stencil depth buffer fail action", + "stencil-buffer", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_STENCIL_PASS_DEPTH_PASS, + "GL_STENCIL_PASS_DEPTH_PASS", + "Stencil depth buffer pass action", + "stencil-buffer", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_DEPTH_TEST, "GL_DEPTH_TEST", "Depth buffer enabled", "depth-buffer/ena ble", "glIsEnabled()"), + new GLproperty( + GL11.GL_DEPTH_FUNC, "GL_DEPTH_FUNC", "Depth buffer test function", "depth-buffer", "glGetIntegerv()"), + new GLproperty(GL11.GL_BLEND, "GL_BLEND", "Blending enabled", "color-buffer/enable", "glIsEnabled()"), + new GLproperty( + GL11.GL_BLEND_SRC, "GL_BLEND_SRC", "Blending source function", "color-buffer", "glGetIntegerv()"), + new GLproperty( + GL11.GL_BLEND_DST, "GL_BLEND_DST", "Blending destination function", "color-buffer", "glGetIntegerv()"), + new GLproperty(GL11.GL_DITHER, "GL_DITHER", "Dithering enabled", "color-buffer/enable", "glIsEnabled()"), + new GLproperty( + GL11.GL_INDEX_LOGIC_OP, + "GL_INDEX_LOGIC_OP", + "Color index logical operation enabled", + "color-buffer/enable", + "glIsEnabled()"), + new GLproperty( + GL11.GL_COLOR_LOGIC_OP, + "GL_COLOR_LOGIC_OP", + "RGBA color logical operation enabled", + "color-buffer/enable", + "glIsEnabled()"), + new GLproperty( + GL11.GL_LOGIC_OP_MODE, + "GL_LOGIC_OP_MODE", + "Logical operation function", + "color-buffer", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_DRAW_BUFFER, + "GL_DRAW_BUFFER", + "Buffers selected for drawing", + "color-buffer", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_INDEX_WRITEMASK, + "GL_INDEX_WRITEMASK", + "Color-index writemask", + "color-buffer", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_COLOR_WRITEMASK, + "GL_COLOR_WRITEMASK", + "Color write enables; R, G, B, or A", + "color-buffer", + "glGetBooleanv()"), + new GLproperty( + GL11.GL_DEPTH_WRITEMASK, + "GL_DEPTH_WRITEMASK", + "Depth buffer enabled for writing", + "depth-buffer", + "glGetBooleanv()"), + new GLproperty( + GL11.GL_STENCIL_WRITEMASK, + "GL_STENCIL_WRITEMASK", + "Stencil-buffer writemask", + "stencil-buffer", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_COLOR_CLEAR_VALUE, + "GL_COLOR_CLEAR_VALUE", + "Color-buffer clear value (RGBA mode)", + "color-buffer", + "glGetFloatv()"), + new GLproperty( + GL11.GL_INDEX_CLEAR_VALUE, + "GL_INDEX_CLEAR_VALUE", + "Color-buffer clear value (color-index mode)", + "color-buffer", + "glGetFloatv()"), + new GLproperty( + GL11.GL_DEPTH_CLEAR_VALUE, + "GL_DEPTH_CLEAR_VALUE", + "Depth-buffer clear value", + "depth-buffer", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_STENCIL_CLEAR_VALUE, + "GL_STENCIL_CLEAR_VALUE", + "Stencil-buffer clear value", + "stencil-buffer", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_ACCUM_CLEAR_VALUE, + "GL_ACCUM_CLEAR_VALUE", + "Accumulation-buffer clear value", + "accum-buffer", + "glGetFloatv()"), + new GLproperty( + GL11.GL_UNPACK_SWAP_BYTES, + "GL_UNPACK_SWAP_BYTES", + "Value of GL_UNPACK_SWAP_BYTES", + "pixel-store", + "glGetBooleanv()"), + new GLproperty( + GL11.GL_UNPACK_LSB_FIRST, + "GL_UNPACK_LSB_FIRST", + "Value of GL_UNPACK_LSB_FIRST", + "pixel-store", + "glGetBooleanv()"), + new GLproperty( + GL11.GL_UNPACK_ROW_LENGTH, + "GL_UNPACK_ROW_LENGTH", + "Value of GL_UNPACK_ROW_LENGTH", + "pixel-store", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_UNPACK_SKIP_ROWS, + "GL_UNPACK_SKIP_ROWS", + "Value of GL_UNPACK_SKIP_ROWS", + "pixel-store", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_UNPACK_SKIP_PIXELS, + "GL_UNPACK_SKIP_PIXELS", + "Value of GL_UNPACK_SKIP_PIXELS", + "pixel-store", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_UNPACK_ALIGNMENT, + "GL_UNPACK_ALIGNMENT", + "Value of GL_UNPACK_ALIGNMENT", + "pixel-store", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_PACK_SWAP_BYTES, + "GL_PACK_SWAP_BYTES", + "Value of GL_PACK_SWAP_BYTES", + "pixel-store", + "glGetBooleanv()"), + new GLproperty( + GL11.GL_PACK_LSB_FIRST, + "GL_PACK_LSB_FIRST", + "Value of GL_PACK_LSB_FIRST", + "pixel-store", + "glGetBooleanv()"), + new GLproperty( + GL11.GL_PACK_ROW_LENGTH, + "GL_PACK_ROW_LENGTH", + "Value of GL_PACK_ROW_LENGTH", + "pixel-store", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_PACK_SKIP_ROWS, + "GL_PACK_SKIP_ROWS", + "Value of GL_PACK_SKIP_ROWS", + "pixel-store", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_PACK_SKIP_PIXELS, + "GL_PACK_SKIP_PIXELS", + "Value of GL_PACK_SKIP_PIXELS", + "pixel-store", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_PACK_ALIGNMENT, + "GL_PACK_ALIGNMENT", + "Value of GL_PACK_ALIGNMENT", + "pixel-store", + "glGetIntegerv()"), + new GLproperty(GL11.GL_MAP_COLOR, "GL_MAP_COLOR", "True if colors are mapped", "pixel", "glGetBooleanv()"), + new GLproperty( + GL11.GL_MAP_STENCIL, "GL_MAP_STENCIL", "True if stencil values are mapped", "pixel", "glGetBooleanv()"), + new GLproperty(GL11.GL_INDEX_SHIFT, "GL_INDEX_SHIFT", "Value of GL_INDEX_SHIFT", "pixel", "glGetIntegerv()"), + new GLproperty(GL11.GL_INDEX_OFFSET, "GL_INDEX_OFFSET", "Value of GL_INDEX_OFFSET", "pixel", "glGetIntegerv()"), + new GLproperty(GL11.GL_ZOOM_X, "GL_ZOOM_X", "x zoom factor", "pixel", "glGetFloatv()"), + new GLproperty(GL11.GL_ZOOM_Y, "GL_ZOOM_Y", "y zoom factor", "pixel", "glGetFloatv()"), + new GLproperty(GL11.GL_READ_BUFFER, "GL_READ_BUFFER", "Read source buffer", "pixel", "glGetIntegerv()"), + new GLproperty(GL11.GL_ORDER, "GL_ORDER", "1D map order", "capability", "glGetMapiv()"), + new GLproperty(GL11.GL_ORDER, "GL_ORDER", "2D map orders", "capability", "glGetMapiv()"), + new GLproperty(GL11.GL_COEFF, "GL_COEFF", "1D control points", "capability", "glGetMapfv()"), + new GLproperty(GL11.GL_COEFF, "GL_COEFF", "2D control points", "capability", "glGetMapfv()"), + new GLproperty(GL11.GL_DOMAIN, "GL_DOMAIN", "1D domain endpoints", "capability", "glGetMapfv()"), + new GLproperty(GL11.GL_DOMAIN, "GL_DOMAIN", "2D domain endpoints", "capability", "glGetMapfv()"), + new GLproperty(GL11.GL_MAP1_GRID_DOMAIN, "GL_MAP1_GRID_DOMAIN", "1D grid endpoints", "eval", "glGetFloatv()"), + new GLproperty(GL11.GL_MAP2_GRID_DOMAIN, "GL_MAP2_GRID_DOMAIN", "2D grid endpoints", "eval", "glGetFloatv()"), + new GLproperty( + GL11.GL_MAP1_GRID_SEGMENTS, "GL_MAP1_GRID_SEGMENTS", "1D grid divisions", "eval", "glGetFloatv()"), + new GLproperty( + GL11.GL_MAP2_GRID_SEGMENTS, "GL_MAP2_GRID_SEGMENTS", "2D grid divisions", "eval", "glGetFloatv()"), + new GLproperty( + GL11.GL_AUTO_NORMAL, + "GL_AUTO_NORMAL", + "True if automatic normal generation enabled", + "eval", + "glIsEnabled()"), + new GLproperty( + GL11.GL_PERSPECTIVE_CORRECTION_HINT, + "GL_PERSPECTIVE_CORRECTION_HINT", + "Perspective correction hint", + "hint", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_POINT_SMOOTH_HINT, "GL_POINT_SMOOTH_HINT", "Point smooth hint", "hint", "glGetIntegerv()"), + new GLproperty(GL11.GL_LINE_SMOOTH_HINT, "GL_LINE_SMOOTH_HINT", "Line smooth hint", "hint", "glGetIntegerv()"), + new GLproperty( + GL11.GL_POLYGON_SMOOTH_HINT, + "GL_POLYGON_SMOOTH_HINT", + "Polygon smooth hint", + "hint", + "glGetIntegerv()"), + new GLproperty(GL11.GL_FOG_HINT, "GL_FOG_HINT", "Fog hint", "hint", "glGetIntegerv()"), + new GLproperty( + GL11.GL_MAX_LIGHTS, "GL_MAX_LIGHTS", "Maximum number of lights", "capability", "glGetIntegerv()"), + new GLproperty( + GL11.GL_MAX_CLIP_PLANES, + "GL_MAX_CLIP_PLANES", + "Maximum number of user clipping planes", + "capability", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_MAX_MODELVIEW_STACK_DEPTH, + "GL_MAX_MODELVIEW_STACK_DEPTH", + "Maximum modelview-matrix stack depth", + "capability", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_MAX_PROJECTION_STACK_DEPTH, + "GL_MAX_PROJECTION_STACK_DEPTH", + "Maximum projection-matrix stack depth", + "capability", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_MAX_TEXTURE_STACK_DEPTH, + "GL_MAX_TEXTURE_STACK_DEPTH", + "Maximum depth of texture matrix stack", + "capability", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_SUBPIXEL_BITS, + "GL_SUBPIXEL_BITS", + "Number of bits of subpixel precision in x and y", + "capability", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_MAX_TEXTURE_SIZE, + "GL_MAX_TEXTURE_SIZE", + "See discussion in Texture Proxy in Chapter 9", + "capability", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_MAX_PIXEL_MAP_TABLE, + "GL_MAX_PIXEL_MAP_TABLE", + "Maximum size of a glPixelMap() translation table", + "capability", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_MAX_NAME_STACK_DEPTH, + "GL_MAX_NAME_STACK_DEPTH", + "Maximum selection-name stack depth", + "capability", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_MAX_LIST_NESTING, + "GL_MAX_LIST_NESTING", + "Maximum display-list call nesting", + "capability", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_MAX_EVAL_ORDER, + "GL_MAX_EVAL_ORDER", + "Maximum evaluator polynomial order", + "capability", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_MAX_VIEWPORT_DIMS, + "GL_MAX_VIEWPORT_DIMS", + "Maximum viewport dimensions", + "capability", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_MAX_ATTRIB_STACK_DEPTH, + "GL_MAX_ATTRIB_STACK_DEPTH", + "Maximum depth of the attribute stack", + "capability", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_MAX_CLIENT_ATTRIB_STACK_DEPTH, + "GL_MAX_CLIENT_ATTRIB_STACK_DEPTH", + "Maximum depth of the client attribute stack", + "capability", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_AUX_BUFFERS, "GL_AUX_BUFFERS", "Number of auxiliary buffers", "capability", "glGetBooleanv()"), + new GLproperty( + GL11.GL_RGBA_MODE, "GL_RGBA_MODE", "True if color buffers store RGBA", "capability", "glGetBooleanv()"), + new GLproperty( + GL11.GL_INDEX_MODE, + "GL_INDEX_MODE", + "True if color buffers store indices", + "capability", + "glGetBooleanv()"), + new GLproperty( + GL11.GL_DOUBLEBUFFER, + "GL_DOUBLEBUFFER", + "True if front and back buffers exist", + "capability", + "glGetBooleanv()"), + new GLproperty( + GL11.GL_STEREO, "GL_STEREO", "True if left and right buffers exist", "capability", "glGetBooleanv()"), + new GLproperty( + GL11.GL_POINT_SIZE_RANGE, + "GL_POINT_SIZE_RANGE", + "Range (low to high) of antialiased point sizes", + "capability", + "glGetFloatv()"), + new GLproperty( + GL11.GL_POINT_SIZE_GRANULARITY, + "GL_POINT_SIZE_GRANULARITY", + "Antialiased point-size granularity", + "capability", + "glGetFloatv()"), + new GLproperty( + GL11.GL_LINE_WIDTH_RANGE, + "GL_LINE_WIDTH_RANGE", + "Range (low to high) of antialiased line widths", + "capability", + "glGetFloatv()"), + new GLproperty( + GL11.GL_LINE_WIDTH_GRANULARITY, + "GL_LINE_WIDTH_GRANULARITY", + "Antialiased line-width granularity", + "capability", + "glGetFloatv()"), + new GLproperty( + GL11.GL_RED_BITS, + "GL_RED_BITS", + "Number of bits per red component in color buffers", + "capability", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_GREEN_BITS, + "GL_GREEN_BITS", + "Number of bits per green component in color buffers", + "capability", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_BLUE_BITS, + "GL_BLUE_BITS", + "Number of bits per blue component in color buffers", + "capability", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_ALPHA_BITS, + "GL_ALPHA_BITS", + "Number of bits per alpha component in color buffers", + "capability", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_INDEX_BITS, + "GL_INDEX_BITS", + "Number of bits per index in color buffers", + "capability", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_DEPTH_BITS, + "GL_DEPTH_BITS", + "Number of depth-buffer bitplanes", + "capability", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_STENCIL_BITS, + "GL_STENCIL_BITS", + "Number of stencil bitplanes", + "capability", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_ACCUM_RED_BITS, + "GL_ACCUM_RED_BITS", + "Number of bits per red component in the accumulation buffer", + "capability", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_ACCUM_GREEN_BITS, + "GL_ACCUM_GREEN_BITS", + "Number of bits per green component in the accumulation buffer", + "capability", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_ACCUM_BLUE_BITS, + "GL_ACCUM_BLUE_BITS", + "Number of bits per blue component in the accumulation buffer", + "capability", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_ACCUM_ALPHA_BITS, + "GL_ACCUM_ALPHA_BITS", + "Number of bits per alpha component in the accumulation buffer", + "capability", + "glGetIntegerv()"), + new GLproperty(GL11.GL_LIST_BASE, "GL_LIST_BASE", "Setting of glListBase()", "list", "glGetIntegerv()"), + new GLproperty( + GL11.GL_LIST_INDEX, + "GL_LIST_INDEX", + "Number of display list under construction; 0 if none", + "current", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_LIST_MODE, + "GL_LIST_MODE", + "Mode of display list under construction; undefined if none", + "current", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_ATTRIB_STACK_DEPTH, + "GL_ATTRIB_STACK_DEPTH", + "Attribute stack pointer", + "current", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_CLIENT_ATTRIB_STACK_DEPTH, + "GL_CLIENT_ATTRIB_STACK_DEPTH", + "Client attribute stack pointer", + "current", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_NAME_STACK_DEPTH, "GL_NAME_STACK_DEPTH", "Name stack depth", "current", "glGetIntegerv()"), + new GLproperty(GL11.GL_RENDER_MODE, "GL_RENDER_MODE", "glRenderMode() setting", "current", "glGetIntegerv()"), + new GLproperty( + GL11.GL_SELECTION_BUFFER_POINTER, + "GL_SELECTION_BUFFER_POINTER", + "Pointer to selection buffer", + "select", + "glGetPointerv()"), + new GLproperty( + GL11.GL_SELECTION_BUFFER_SIZE, + "GL_SELECTION_BUFFER_SIZE", + "Size of selection buffer", + "select", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_FEEDBACK_BUFFER_POINTER, + "GL_FEEDBACK_BUFFER_POINTER", + "Pointer to feedback buffer", + "feedback", + "glGetPointerv()"), + new GLproperty( + GL11.GL_FEEDBACK_BUFFER_SIZE, + "GL_FEEDBACK_BUFFER_SIZE", + "Size of feedback buffer", + "feedback", + "glGetIntegerv()"), + new GLproperty( + GL11.GL_FEEDBACK_BUFFER_TYPE, + "GL_FEEDBACK_BUFFER_TYPE", + "Type of feedback buffer", + "feedback", + "glGetIntegerv()"), + }; - { - new GLproperty(GL11.GL_CURRENT_COLOR, "GL_CURRENT_COLOR", "Current color", "current", "glGetFloatv()"), - new GLproperty(GL11.GL_CURRENT_INDEX, "GL_CURRENT_INDEX", "Current color index", "current", "glGetFloatv()"), - new GLproperty(GL11.GL_CURRENT_TEXTURE_COORDS, "GL_CURRENT_TEXTURE_COORDS", "Current texture coordinates", "current", "glGetFloatv()"), - new GLproperty(GL11.GL_CURRENT_NORMAL, "GL_CURRENT_NORMAL", "Current normal", "current", "glGetFloatv()"), - new GLproperty(GL11.GL_CURRENT_RASTER_POSITION, "GL_CURRENT_RASTER_POSITION", "Current raster position", "current", "glGetFloatv()"), - new GLproperty(GL11.GL_CURRENT_RASTER_DISTANCE, "GL_CURRENT_RASTER_DISTANCE", "Current raster distance", "current", "glGetFloatv()"), - new GLproperty(GL11.GL_CURRENT_RASTER_COLOR, "GL_CURRENT_RASTER_COLOR", "Color associated with raster position", "current", "glGetFloatv()"), - new GLproperty(GL11.GL_CURRENT_RASTER_INDEX, "GL_CURRENT_RASTER_INDEX", "Color index associated with raster position", "current", "glGetFloatv()"), - new GLproperty(GL11.GL_CURRENT_RASTER_TEXTURE_COORDS, "GL_CURRENT_RASTER_TEXTURE_COORDS", "Texture coordinates associated with raster position", "current", "glGetFloatv()"), - new GLproperty(GL11.GL_CURRENT_RASTER_POSITION_VALID, "GL_CURRENT_RASTER_POSITION_VALID", "Raster position valid bit", "current", "glGetBooleanv()"), - new GLproperty(GL11.GL_EDGE_FLAG, "GL_EDGE_FLAG", "Edge flag", "current", "glGetBooleanv()"), - new GLproperty(GL11.GL_VERTEX_ARRAY, "GL_VERTEX_ARRAY", "Vertex array enable", "vertex-array", "glIsEnabled()"), - new GLproperty(GL11.GL_VERTEX_ARRAY_SIZE, "GL_VERTEX_ARRAY_SIZE", "Coordinates per vertex", "vertex-array", "glGetIntegerv()"), - new GLproperty(GL11.GL_VERTEX_ARRAY_TYPE, "GL_VERTEX_ARRAY_TYPE", "Type of vertex coordinates", "vertex-array", "glGetIntegerv()"), - new GLproperty(GL11.GL_VERTEX_ARRAY_STRIDE, "GL_VERTEX_ARRAY_STRIDE", "Stride between vertices", "vertex-array", "glGetIntegerv()"), - new GLproperty(GL11.GL_VERTEX_ARRAY_POINTER, "GL_VERTEX_ARRAY_POINTER", "Pointer to the vertex array", "vertex-array", "glGetPointerv()"), - new GLproperty(GL11.GL_NORMAL_ARRAY, "GL_NORMAL_ARRAY", "Normal array enable", "vertex-array", "glIsEnabled()"), - new GLproperty(GL11.GL_NORMAL_ARRAY_TYPE, "GL_NORMAL_ARRAY_TYPE", "Type of normal coordinates", "vertex-array", "glGetIntegerv()"), - new GLproperty(GL11.GL_NORMAL_ARRAY_STRIDE, "GL_NORMAL_ARRAY_STRIDE", "Stride between normals", "vertex-array", "glGetIntegerv()"), - new GLproperty(GL11.GL_NORMAL_ARRAY_POINTER, "GL_NORMAL_ARRAY_POINTER", "Pointer to the normal array", "vertex-array", "glGetPointerv()"), - new GLproperty(GL11.GL_COLOR_ARRAY, "GL_COLOR_ARRAY", "RGBA color array enable", "vertex-array", "glIsEnabled()"), - new GLproperty(GL11.GL_COLOR_ARRAY_SIZE, "GL_COLOR_ARRAY_SIZE", "Colors per vertex", "vertex-array", "glGetIntegerv()"), - new GLproperty(GL11.GL_COLOR_ARRAY_TYPE, "GL_COLOR_ARRAY_TYPE", "Type of color components", "vertex-array", "glGetIntegerv()"), - new GLproperty(GL11.GL_COLOR_ARRAY_STRIDE, "GL_COLOR_ARRAY_STRIDE", "Stride between colors", "vertex-array", "glGetIntegerv()"), - new GLproperty(GL11.GL_COLOR_ARRAY_POINTER, "GL_COLOR_ARRAY_POINTER", "Pointer to the color array", "vertex-array", "glGetPointerv()"), - new GLproperty(GL11.GL_INDEX_ARRAY, "GL_INDEX_ARRAY", "Color-index array enable", "vertex-array", "glIsEnabled()"), - new GLproperty(GL11.GL_INDEX_ARRAY_TYPE, "GL_INDEX_ARRAY_TYPE", "Type of color indices", "vertex-array", "glGetIntegerv()"), - new GLproperty(GL11.GL_INDEX_ARRAY_STRIDE, "GL_INDEX_ARRAY_STRIDE", "Stride between color indices", "vertex-array", "glGetIntegerv()"), - new GLproperty(GL11.GL_INDEX_ARRAY_POINTER, "GL_INDEX_ARRAY_POINTER", "Pointer to the index array", "vertex-array", "glGetPointerv()"), - new GLproperty(GL11.GL_TEXTURE_COORD_ARRAY, "GL_TEXTURE_COORD_ARRAY", "Texture coordinate array enable", "vertex-array", "glIsEnabled()"), - new GLproperty(GL11.GL_TEXTURE_COORD_ARRAY_SIZE, "GL_TEXTURE_COORD_ARRAY_SIZE", "Texture coordinates per element", "vertex-array", "glGetIntegerv()"), - new GLproperty(GL11.GL_TEXTURE_COORD_ARRAY_TYPE, "GL_TEXTURE_COORD_ARRAY_TYPE", "Type of texture coordinates", "vertex-array", "glGetIntegerv()"), - new GLproperty(GL11.GL_TEXTURE_COORD_ARRAY_STRIDE, "GL_TEXTURE_COORD_ARRAY_STRIDE", "Stride between texture coordinates", "vertex-array", "glGetIntegerv()"), - new GLproperty(GL11.GL_TEXTURE_COORD_ARRAY_POINTER, "GL_TEXTURE_COORD_ARRAY_POINTER", "Pointer to the texture coordinate array", "vertex-array", "glGetPointerv()"), - new GLproperty(GL11.GL_EDGE_FLAG_ARRAY, "GL_EDGE_FLAG_ARRAY", "Edge flag array enable", "vertex-array", "glIsEnabled()"), - new GLproperty(GL11.GL_EDGE_FLAG_ARRAY_STRIDE, "GL_EDGE_FLAG_ARRAY_STRIDE", "Stride between edge flags", "vertex-array", "glGetIntegerv()"), - new GLproperty(GL11.GL_EDGE_FLAG_ARRAY_POINTER, "GL_EDGE_FLAG_ARRAY_POINTER", "Pointer to the edge flag array", "vertex-array", "glGetPointerv()"), - new GLproperty(GL11.GL_MODELVIEW_MATRIX, "GL_MODELVIEW_MATRIX", "Modelview matrix stack", "matrix", "glGetFloatv()"), - new GLproperty(GL11.GL_PROJECTION_MATRIX, "GL_PROJECTION_MATRIX", "Projection matrix stack", "matrix", "glGetFloatv()"), - new GLproperty(GL11.GL_TEXTURE_MATRIX, "GL_TEXTURE_MATRIX", "Texture matrix stack", "matrix", "glGetFloatv()"), - new GLproperty(GL11.GL_VIEWPORT, "GL_VIEWPORT", "Viewport origin and extent", "viewport", "glGetIntegerv()"), - new GLproperty(GL11.GL_DEPTH_RANGE, "GL_DEPTH_RANGE", "Depth range near and far", "viewport", "glGetFloatv()"), - new GLproperty(GL11.GL_MODELVIEW_STACK_DEPTH, "GL_MODELVIEW_STACK_DEPTH", "Modelview matrix stack pointer", "matrix", "glGetIntegerv()"), - new GLproperty(GL11.GL_PROJECTION_STACK_DEPTH, "GL_PROJECTION_STACK_DEPTH", "Projection matrix stack pointer", "matrix", "glGetIntegerv()"), - new GLproperty(GL11.GL_TEXTURE_STACK_DEPTH, "GL_TEXTURE_STACK_DEPTH", "Texture matrix stack pointer", "matrix", "glGetIntegerv()"), - new GLproperty(GL11.GL_MATRIX_MODE, "GL_MATRIX_MODE", "Current matrix mode", "transform", "glGetIntegerv()"), - new GLproperty(GL11.GL_NORMALIZE, "GL_NORMALIZE", "Current normal normalization on/off", "transform/ enable", "glIsEnabled()"), - new GLproperty(GL11.GL_FOG_COLOR, "GL_FOG_COLOR", "Fog color", "fog", "glGetFloatv()"), - new GLproperty(GL11.GL_FOG_INDEX, "GL_FOG_INDEX", "Fog index", "fog", "glGetFloatv()"), - new GLproperty(GL11.GL_FOG_DENSITY, "GL_FOG_DENSITY", "Exponential fog density", "fog", "glGetFloatv()"), - new GLproperty(GL11.GL_FOG_START, "GL_FOG_START", "Linear fog start", "fog", "glGetFloatv()"), - new GLproperty(GL11.GL_FOG_END, "GL_FOG_END", "Linear fog end", "fog", "glGetFloatv()"), - new GLproperty(GL11.GL_FOG_MODE, "GL_FOG_MODE", "Fog mode", "fog", "glGetIntegerv()"), - new GLproperty(GL11.GL_FOG, "GL_FOG", "True if fog enabled", "fog/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_SHADE_MODEL, "GL_SHADE_MODEL", "glShadeModel() setting", "lighting", "glGetIntegerv()"), - new GLproperty(GL11.GL_LIGHTING, "GL_LIGHTING", "True if lighting is enabled", "lighting/e nable", "glIsEnabled()"), - new GLproperty(GL11.GL_COLOR_MATERIAL, "GL_COLOR_MATERIAL", "True if color tracking is enabled", "lighting", "glIsEnabled()"), - new GLproperty(GL11.GL_COLOR_MATERIAL_PARAMETER, "GL_COLOR_MATERIAL_PARAMETER", "Material properties tracking current color", "lighting", "glGetIntegerv()"), - new GLproperty(GL11.GL_COLOR_MATERIAL_FACE, "GL_COLOR_MATERIAL_FACE", "Face(s) affected by color tracking", "lighting", "glGetIntegerv()"), - new GLproperty(GL11.GL_AMBIENT, "GL_AMBIENT", "Ambient material color", "lighting", "glGetMaterialfv()"), - new GLproperty(GL11.GL_DIFFUSE, "GL_DIFFUSE", "Diffuse material color", "lighting", "glGetMaterialfv()"), - new GLproperty(GL11.GL_SPECULAR, "GL_SPECULAR", "Specular material color", "lighting", "glGetMaterialfv()"), - new GLproperty(GL11.GL_EMISSION, "GL_EMISSION", "Emissive material color", "lighting", "glGetMaterialfv()"), - new GLproperty(GL11.GL_SHININESS, "GL_SHININESS", "Specular exponent of material", "lighting", "glGetMaterialfv()"), - new GLproperty(GL11.GL_LIGHT_MODEL_AMBIENT, "GL_LIGHT_MODEL_AMBIENT", "Ambient scene color", "lighting", "glGetFloatv()"), - new GLproperty(GL11.GL_LIGHT_MODEL_LOCAL_VIEWER, "GL_LIGHT_MODEL_LOCAL_VIEWER", "Viewer is local", "lighting", "glGetBooleanv()"), - new GLproperty(GL11.GL_LIGHT_MODEL_TWO_SIDE, "GL_LIGHT_MODEL_TWO_SIDE", "Use two-sided lighting", "lighting", "glGetBooleanv()"), - new GLproperty(GL11.GL_AMBIENT, "GL_AMBIENT", "Ambient intensity of light i", "lighting", "glGetLightfv()"), - new GLproperty(GL11.GL_DIFFUSE, "GL_DIFFUSE", "Diffuse intensity of light i", "lighting", "glGetLightfv()"), - new GLproperty(GL11.GL_SPECULAR, "GL_SPECULAR", "Specular intensity of light i", "lighting", "glGetLightfv()"), - new GLproperty(GL11.GL_POSITION, "GL_POSITION", "Position of light i", "lighting", "glGetLightfv()"), - new GLproperty(GL11.GL_CONSTANT_ATTENUATION, "GL_CONSTANT_ATTENUATION", "Constant attenuation factor", "lighting", "glGetLightfv()"), - new GLproperty(GL11.GL_LINEAR_ATTENUATION, "GL_LINEAR_ATTENUATION", "Linear attenuation factor", "lighting", "glGetLightfv()"), - new GLproperty(GL11.GL_QUADRATIC_ATTENUATION, "GL_QUADRATIC_ATTENUATION", "Quadratic attenuation factor", "lighting", "glGetLightfv()"), - new GLproperty(GL11.GL_SPOT_DIRECTION, "GL_SPOT_DIRECTION", "Spotlight direction of light i", "lighting", "glGetLightfv()"), - new GLproperty(GL11.GL_SPOT_EXPONENT, "GL_SPOT_EXPONENT", "Spotlight exponent of light i", "lighting", "glGetLightfv()"), - new GLproperty(GL11.GL_SPOT_CUTOFF, "GL_SPOT_CUTOFF", "Spotlight angle of light i", "lighting", "glGetLightfv()"), - new GLproperty(GL11.GL_LIGHT0, "GL_LIGHT0", "True if light 0 enabled", "lighting/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_LIGHT1, "GL_LIGHT1", "True if light 1 enabled", "lighting/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_LIGHT2, "GL_LIGHT2", "True if light 2 enabled", "lighting/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_LIGHT3, "GL_LIGHT3", "True if light 3 enabled", "lighting/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_LIGHT4, "GL_LIGHT4", "True if light 4 enabled", "lighting/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_LIGHT5, "GL_LIGHT5", "True if light 5 enabled", "lighting/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_LIGHT6, "GL_LIGHT6", "True if light 6 enabled", "lighting/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_LIGHT7, "GL_LIGHT7", "True if light 7 enabled", "lighting/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_COLOR_INDEXES, "GL_COLOR_INDEXES", "ca, cd, and cs for color-index lighting", "lighting/e nable", "glGetMaterialfv()"), - new GLproperty(GL11.GL_POINT_SIZE, "GL_POINT_SIZE", "Point size", "point", "glGetFloatv()"), - new GLproperty(GL11.GL_POINT_SMOOTH, "GL_POINT_SMOOTH", "Point antialiasing on", "point/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_LINE_WIDTH, "GL_LINE_WIDTH", "Line width", "line", "glGetFloatv()"), - new GLproperty(GL11.GL_LINE_SMOOTH, "GL_LINE_SMOOTH", "Line antialiasing on", "line/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_LINE_STIPPLE_PATTERN, "GL_LINE_STIPPLE_PATTERN", "Line stipple", "line", "glGetIntegerv()"), - new GLproperty(GL11.GL_LINE_STIPPLE_REPEAT, "GL_LINE_STIPPLE_REPEAT", "Line stipple repeat", "line", "glGetIntegerv()"), - new GLproperty(GL11.GL_LINE_STIPPLE, "GL_LINE_STIPPLE", "Line stipple enable", "line/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_CULL_FACE, "GL_CULL_FACE", "Polygon culling enabled", "polygon/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_CULL_FACE_MODE, "GL_CULL_FACE_MODE", "Cull front-/back-facing polygons", "polygon", "glGetIntegerv()"), - new GLproperty(GL11.GL_FRONT_FACE, "GL_FRONT_FACE", "Polygon front-face CW/CCW indicator", "polygon", "glGetIntegerv()"), - new GLproperty(GL11.GL_POLYGON_SMOOTH, "GL_POLYGON_SMOOTH", "Polygon antialiasing on", "polygon/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_POLYGON_MODE, "GL_POLYGON_MODE", "Polygon rasterization mode (front and back)", "polygon", "glGetIntegerv()"), - new GLproperty(GL11.GL_POLYGON_OFFSET_FACTOR, "GL_POLYGON_OFFSET_FACTOR", "Polygon offset factor", "polygon", "glGetFloatv()"), - new GLproperty(GL11.GL_POLYGON_OFFSET_POINT, "GL_POLYGON_OFFSET_POINT", "Polygon offset enable for GL_POINT mode rasterization", "polygon/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_POLYGON_OFFSET_LINE, "GL_POLYGON_OFFSET_LINE", "Polygon offset enable for GL_LINE mode rasterization", "polygon/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_POLYGON_OFFSET_FILL, "GL_POLYGON_OFFSET_FILL", "Polygon offset enable for GL_FILL mode rasterization", "polygon/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_POLYGON_STIPPLE, "GL_POLYGON_STIPPLE", "Polygon stipple enable", "polygon/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_TEXTURE_1D, "GL_TEXTURE_1D", "True if 1-D texturing enabled ", "texture/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_TEXTURE_2D, "GL_TEXTURE_2D", "True if 2-D texturing enabled ", "texture/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_TEXTURE_BINDING_1D, "GL_TEXTURE_BINDING_1D", "Texture object bound to GL_TEXTURE_1D", "texture", "glGetIntegerv()"), - new GLproperty(GL11.GL_TEXTURE_BINDING_2D, "GL_TEXTURE_BINDING_2D", "Texture object bound to GL_TEXTURE_2D", "texture", "glGetIntegerv()"), - new GLproperty(GL11.GL_TEXTURE, "GL_TEXTURE", "x-D texture image at level of detail i", "UNUSED", "glGetTexImage()"), - new GLproperty(GL11.GL_TEXTURE_WIDTH, "GL_TEXTURE_WIDTH", "x-D texture image i's width", "UNUSED", "glGetTexLevelParameter*()"), - new GLproperty(GL11.GL_TEXTURE_HEIGHT, "GL_TEXTURE_HEIGHT", "x-D texture image i's height", "UNUSED", "glGetTexLevelParameter*()"), - new GLproperty(GL11.GL_TEXTURE_BORDER, "GL_TEXTURE_BORDER", "x-D texture image i's border width", "UNUSED", "glGetTexLevelParameter*()"), - new GLproperty(GL11.GL_TEXTURE_RED_SIZE, "GL_TEXTURE_RED_SIZE", "x-D texture image i's red resolution", "UNUSED", "glGetTexLevelParameter*()"), - new GLproperty(GL11.GL_TEXTURE_GREEN_SIZE, "GL_TEXTURE_GREEN_SIZE", "x-D texture image i's green resolution", "UNUSED", "glGetTexLevelParameter*()"), - new GLproperty(GL11.GL_TEXTURE_BLUE_SIZE, "GL_TEXTURE_BLUE_SIZE", "x-D texture image i's blue resolution", "UNUSED", "glGetTexLevelParameter*()"), - new GLproperty(GL11.GL_TEXTURE_ALPHA_SIZE, "GL_TEXTURE_ALPHA_SIZE", "x-D texture image i's alpha resolution", "UNUSED", "glGetTexLevelParameter*()"), - new GLproperty(GL11.GL_TEXTURE_LUMINANCE_SIZE, "GL_TEXTURE_LUMINANCE_SIZE", "x-D texture image i's luminance resolution", "UNUSED", "glGetTexLevelParameter*()"), - new GLproperty(GL11.GL_TEXTURE_INTENSITY_SIZE, "GL_TEXTURE_INTENSITY_SIZE", "x-D texture image i's intensity resolution", "UNUSED", "glGetTexLevelParameter*()"), - new GLproperty(GL11.GL_TEXTURE_BORDER_COLOR, "GL_TEXTURE_BORDER_COLOR", "Texture border color", "texture", "glGetTexParameter*()"), - new GLproperty(GL11.GL_TEXTURE_MIN_FILTER, "GL_TEXTURE_MIN_FILTER", "Texture minification function", "texture", "glGetTexParameter*()"), - new GLproperty(GL11.GL_TEXTURE_MAG_FILTER, "GL_TEXTURE_MAG_FILTER", "Texture magnification function", "texture", "glGetTexParameter*()"), - new GLproperty(GL11.GL_TEXTURE_WRAP_S, "GL_TEXTURE_WRAP_S", "Texture wrap mode (x is S or T)", "texture", "glGetTexParameter*()"), - new GLproperty(GL11.GL_TEXTURE_WRAP_T, "GL_TEXTURE_WRAP_T", "Texture wrap mode (x is S or T)", "texture", "glGetTexParameter*()"), - new GLproperty(GL11.GL_TEXTURE_PRIORITY, "GL_TEXTURE_PRIORITY", "Texture object priority", "texture", "glGetTexParameter*()"), - new GLproperty(GL11.GL_TEXTURE_ENV_MODE, "GL_TEXTURE_ENV_MODE", "Texture application function", "texture", "glGetTexEnviv()"), - new GLproperty(GL11.GL_TEXTURE_ENV_COLOR, "GL_TEXTURE_ENV_COLOR", "Texture environment color", "texture", "glGetTexEnvfv()"), - new GLproperty(GL11.GL_TEXTURE_GEN_S, "GL_TEXTURE_GEN_S", "Texgen enabled (x is S, T, R, or Q)", "texture/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_TEXTURE_GEN_T, "GL_TEXTURE_GEN_T", "Texgen enabled (x is S, T, R, or Q)", "texture/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_TEXTURE_GEN_R, "GL_TEXTURE_GEN_R", "Texgen enabled (x is S, T, R, or Q)", "texture/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_TEXTURE_GEN_Q, "GL_TEXTURE_GEN_Q", "Texgen enabled (x is S, T, R, or Q)", "texture/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_EYE_PLANE, "GL_EYE_PLANE", "Texgen plane equation coefficients", "texture", "glGetTexGenfv()"), - new GLproperty(GL11.GL_OBJECT_PLANE, "GL_OBJECT_PLANE", "Texgen object linear coefficients", "texture", "glGetTexGenfv()"), - new GLproperty(GL11.GL_TEXTURE_GEN_MODE, "GL_TEXTURE_GEN_MODE", "Function used for texgen", "texture", "glGetTexGeniv()"), - new GLproperty(GL11.GL_SCISSOR_TEST, "GL_SCISSOR_TEST", "Scissoring enabled", "scissor/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_SCISSOR_BOX, "GL_SCISSOR_BOX", "Scissor box", "scissor", "glGetIntegerv()"), - new GLproperty(GL11.GL_ALPHA_TEST, "GL_ALPHA_TEST", "Alpha test enabled", "color-buffer/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_ALPHA_TEST_FUNC, "GL_ALPHA_TEST_FUNC", "Alpha test function", "color-buffer", "glGetIntegerv()"), - new GLproperty(GL11.GL_ALPHA_TEST_REF, "GL_ALPHA_TEST_REF", "Alpha test reference value", "color-buffer", "glGetIntegerv()"), - new GLproperty(GL11.GL_STENCIL_TEST, "GL_STENCIL_TEST", "Stenciling enabled", "stencil-buffer/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_STENCIL_FUNC, "GL_STENCIL_FUNC", "Stencil function", "stencil-buffer", "glGetIntegerv()"), - new GLproperty(GL11.GL_STENCIL_VALUE_MASK, "GL_STENCIL_VALUE_MASK", "Stencil mask", "stencil-buffer", "glGetIntegerv()"), - new GLproperty(GL11.GL_STENCIL_REF, "GL_STENCIL_REF", "Stencil reference value", "stencil-buffer", "glGetIntegerv()"), - new GLproperty(GL11.GL_STENCIL_FAIL, "GL_STENCIL_FAIL", "Stencil fail action", "stencil-buffer", "glGetIntegerv()"), - new GLproperty(GL11.GL_STENCIL_PASS_DEPTH_FAIL, "GL_STENCIL_PASS_DEPTH_FAIL", "Stencil depth buffer fail action", "stencil-buffer", "glGetIntegerv()"), - new GLproperty(GL11.GL_STENCIL_PASS_DEPTH_PASS, "GL_STENCIL_PASS_DEPTH_PASS", "Stencil depth buffer pass action", "stencil-buffer", "glGetIntegerv()"), - new GLproperty(GL11.GL_DEPTH_TEST, "GL_DEPTH_TEST", "Depth buffer enabled", "depth-buffer/ena ble", "glIsEnabled()"), - new GLproperty(GL11.GL_DEPTH_FUNC, "GL_DEPTH_FUNC", "Depth buffer test function", "depth-buffer", "glGetIntegerv()"), - new GLproperty(GL11.GL_BLEND, "GL_BLEND", "Blending enabled", "color-buffer/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_BLEND_SRC, "GL_BLEND_SRC", "Blending source function", "color-buffer", "glGetIntegerv()"), - new GLproperty(GL11.GL_BLEND_DST, "GL_BLEND_DST", "Blending destination function", "color-buffer", "glGetIntegerv()"), - new GLproperty(GL11.GL_DITHER, "GL_DITHER", "Dithering enabled", "color-buffer/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_INDEX_LOGIC_OP, "GL_INDEX_LOGIC_OP", "Color index logical operation enabled", "color-buffer/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_COLOR_LOGIC_OP, "GL_COLOR_LOGIC_OP", "RGBA color logical operation enabled", "color-buffer/enable", "glIsEnabled()"), - new GLproperty(GL11.GL_LOGIC_OP_MODE, "GL_LOGIC_OP_MODE", "Logical operation function", "color-buffer", "glGetIntegerv()"), - new GLproperty(GL11.GL_DRAW_BUFFER, "GL_DRAW_BUFFER", "Buffers selected for drawing", "color-buffer", "glGetIntegerv()"), - new GLproperty(GL11.GL_INDEX_WRITEMASK, "GL_INDEX_WRITEMASK", "Color-index writemask", "color-buffer", "glGetIntegerv()"), - new GLproperty(GL11.GL_COLOR_WRITEMASK, "GL_COLOR_WRITEMASK", "Color write enables; R, G, B, or A", "color-buffer", "glGetBooleanv()"), - new GLproperty(GL11.GL_DEPTH_WRITEMASK, "GL_DEPTH_WRITEMASK", "Depth buffer enabled for writing", "depth-buffer", "glGetBooleanv()"), - new GLproperty(GL11.GL_STENCIL_WRITEMASK, "GL_STENCIL_WRITEMASK", "Stencil-buffer writemask", "stencil-buffer", "glGetIntegerv()"), - new GLproperty(GL11.GL_COLOR_CLEAR_VALUE, "GL_COLOR_CLEAR_VALUE", "Color-buffer clear value (RGBA mode)", "color-buffer", "glGetFloatv()"), - new GLproperty(GL11.GL_INDEX_CLEAR_VALUE, "GL_INDEX_CLEAR_VALUE", "Color-buffer clear value (color-index mode)", "color-buffer", "glGetFloatv()"), - new GLproperty(GL11.GL_DEPTH_CLEAR_VALUE, "GL_DEPTH_CLEAR_VALUE", "Depth-buffer clear value", "depth-buffer", "glGetIntegerv()"), - new GLproperty(GL11.GL_STENCIL_CLEAR_VALUE, "GL_STENCIL_CLEAR_VALUE", "Stencil-buffer clear value", "stencil-buffer", "glGetIntegerv()"), - new GLproperty(GL11.GL_ACCUM_CLEAR_VALUE, "GL_ACCUM_CLEAR_VALUE", "Accumulation-buffer clear value", "accum-buffer", "glGetFloatv()"), - new GLproperty(GL11.GL_UNPACK_SWAP_BYTES, "GL_UNPACK_SWAP_BYTES", "Value of GL_UNPACK_SWAP_BYTES", "pixel-store", "glGetBooleanv()"), - new GLproperty(GL11.GL_UNPACK_LSB_FIRST, "GL_UNPACK_LSB_FIRST", "Value of GL_UNPACK_LSB_FIRST", "pixel-store", "glGetBooleanv()"), - new GLproperty(GL11.GL_UNPACK_ROW_LENGTH, "GL_UNPACK_ROW_LENGTH", "Value of GL_UNPACK_ROW_LENGTH", "pixel-store", "glGetIntegerv()"), - new GLproperty(GL11.GL_UNPACK_SKIP_ROWS, "GL_UNPACK_SKIP_ROWS", "Value of GL_UNPACK_SKIP_ROWS", "pixel-store", "glGetIntegerv()"), - new GLproperty(GL11.GL_UNPACK_SKIP_PIXELS, "GL_UNPACK_SKIP_PIXELS", "Value of GL_UNPACK_SKIP_PIXELS", "pixel-store", "glGetIntegerv()"), - new GLproperty(GL11.GL_UNPACK_ALIGNMENT, "GL_UNPACK_ALIGNMENT", "Value of GL_UNPACK_ALIGNMENT", "pixel-store", "glGetIntegerv()"), - new GLproperty(GL11.GL_PACK_SWAP_BYTES, "GL_PACK_SWAP_BYTES", "Value of GL_PACK_SWAP_BYTES", "pixel-store", "glGetBooleanv()"), - new GLproperty(GL11.GL_PACK_LSB_FIRST, "GL_PACK_LSB_FIRST", "Value of GL_PACK_LSB_FIRST", "pixel-store", "glGetBooleanv()"), - new GLproperty(GL11.GL_PACK_ROW_LENGTH, "GL_PACK_ROW_LENGTH", "Value of GL_PACK_ROW_LENGTH", "pixel-store", "glGetIntegerv()"), - new GLproperty(GL11.GL_PACK_SKIP_ROWS, "GL_PACK_SKIP_ROWS", "Value of GL_PACK_SKIP_ROWS", "pixel-store", "glGetIntegerv()"), - new GLproperty(GL11.GL_PACK_SKIP_PIXELS, "GL_PACK_SKIP_PIXELS", "Value of GL_PACK_SKIP_PIXELS", "pixel-store", "glGetIntegerv()"), - new GLproperty(GL11.GL_PACK_ALIGNMENT, "GL_PACK_ALIGNMENT", "Value of GL_PACK_ALIGNMENT", "pixel-store", "glGetIntegerv()"), - new GLproperty(GL11.GL_MAP_COLOR, "GL_MAP_COLOR", "True if colors are mapped", "pixel", "glGetBooleanv()"), - new GLproperty(GL11.GL_MAP_STENCIL, "GL_MAP_STENCIL", "True if stencil values are mapped", "pixel", "glGetBooleanv()"), - new GLproperty(GL11.GL_INDEX_SHIFT, "GL_INDEX_SHIFT", "Value of GL_INDEX_SHIFT", "pixel", "glGetIntegerv()"), - new GLproperty(GL11.GL_INDEX_OFFSET, "GL_INDEX_OFFSET", "Value of GL_INDEX_OFFSET", "pixel", "glGetIntegerv()"), - new GLproperty(GL11.GL_ZOOM_X, "GL_ZOOM_X", "x zoom factor", "pixel", "glGetFloatv()"), - new GLproperty(GL11.GL_ZOOM_Y, "GL_ZOOM_Y", "y zoom factor", "pixel", "glGetFloatv()"), - new GLproperty(GL11.GL_READ_BUFFER, "GL_READ_BUFFER", "Read source buffer", "pixel", "glGetIntegerv()"), - new GLproperty(GL11.GL_ORDER, "GL_ORDER", "1D map order", "capability", "glGetMapiv()"), - new GLproperty(GL11.GL_ORDER, "GL_ORDER", "2D map orders", "capability", "glGetMapiv()"), - new GLproperty(GL11.GL_COEFF, "GL_COEFF", "1D control points", "capability", "glGetMapfv()"), - new GLproperty(GL11.GL_COEFF, "GL_COEFF", "2D control points", "capability", "glGetMapfv()"), - new GLproperty(GL11.GL_DOMAIN, "GL_DOMAIN", "1D domain endpoints", "capability", "glGetMapfv()"), - new GLproperty(GL11.GL_DOMAIN, "GL_DOMAIN", "2D domain endpoints", "capability", "glGetMapfv()"), - new GLproperty(GL11.GL_MAP1_GRID_DOMAIN, "GL_MAP1_GRID_DOMAIN", "1D grid endpoints", "eval", "glGetFloatv()"), - new GLproperty(GL11.GL_MAP2_GRID_DOMAIN, "GL_MAP2_GRID_DOMAIN", "2D grid endpoints", "eval", "glGetFloatv()"), - new GLproperty(GL11.GL_MAP1_GRID_SEGMENTS, "GL_MAP1_GRID_SEGMENTS", "1D grid divisions", "eval", "glGetFloatv()"), - new GLproperty(GL11.GL_MAP2_GRID_SEGMENTS, "GL_MAP2_GRID_SEGMENTS", "2D grid divisions", "eval", "glGetFloatv()"), - new GLproperty(GL11.GL_AUTO_NORMAL, "GL_AUTO_NORMAL", "True if automatic normal generation enabled", "eval", "glIsEnabled()"), - new GLproperty(GL11.GL_PERSPECTIVE_CORRECTION_HINT, "GL_PERSPECTIVE_CORRECTION_HINT", "Perspective correction hint", "hint", "glGetIntegerv()"), - new GLproperty(GL11.GL_POINT_SMOOTH_HINT, "GL_POINT_SMOOTH_HINT", "Point smooth hint", "hint", "glGetIntegerv()"), - new GLproperty(GL11.GL_LINE_SMOOTH_HINT, "GL_LINE_SMOOTH_HINT", "Line smooth hint", "hint", "glGetIntegerv()"), - new GLproperty(GL11.GL_POLYGON_SMOOTH_HINT, "GL_POLYGON_SMOOTH_HINT", "Polygon smooth hint", "hint", "glGetIntegerv()"), - new GLproperty(GL11.GL_FOG_HINT, "GL_FOG_HINT", "Fog hint", "hint", "glGetIntegerv()"), - new GLproperty(GL11.GL_MAX_LIGHTS, "GL_MAX_LIGHTS", "Maximum number of lights", "capability", "glGetIntegerv()"), - new GLproperty(GL11.GL_MAX_CLIP_PLANES, "GL_MAX_CLIP_PLANES", "Maximum number of user clipping planes", "capability", "glGetIntegerv()"), - new GLproperty(GL11.GL_MAX_MODELVIEW_STACK_DEPTH, "GL_MAX_MODELVIEW_STACK_DEPTH", "Maximum modelview-matrix stack depth", "capability", "glGetIntegerv()"), - new GLproperty(GL11.GL_MAX_PROJECTION_STACK_DEPTH, "GL_MAX_PROJECTION_STACK_DEPTH", "Maximum projection-matrix stack depth", "capability", "glGetIntegerv()"), - new GLproperty(GL11.GL_MAX_TEXTURE_STACK_DEPTH, "GL_MAX_TEXTURE_STACK_DEPTH", "Maximum depth of texture matrix stack", "capability", "glGetIntegerv()"), - new GLproperty(GL11.GL_SUBPIXEL_BITS, "GL_SUBPIXEL_BITS", "Number of bits of subpixel precision in x and y", "capability", "glGetIntegerv()"), - new GLproperty(GL11.GL_MAX_TEXTURE_SIZE, "GL_MAX_TEXTURE_SIZE", "See discussion in Texture Proxy in Chapter 9", "capability", "glGetIntegerv()"), - new GLproperty(GL11.GL_MAX_PIXEL_MAP_TABLE, "GL_MAX_PIXEL_MAP_TABLE", "Maximum size of a glPixelMap() translation table", "capability", "glGetIntegerv()"), - new GLproperty(GL11.GL_MAX_NAME_STACK_DEPTH, "GL_MAX_NAME_STACK_DEPTH", "Maximum selection-name stack depth", "capability", "glGetIntegerv()"), - new GLproperty(GL11.GL_MAX_LIST_NESTING, "GL_MAX_LIST_NESTING", "Maximum display-list call nesting", "capability", "glGetIntegerv()"), - new GLproperty(GL11.GL_MAX_EVAL_ORDER, "GL_MAX_EVAL_ORDER", "Maximum evaluator polynomial order", "capability", "glGetIntegerv()"), - new GLproperty(GL11.GL_MAX_VIEWPORT_DIMS, "GL_MAX_VIEWPORT_DIMS", "Maximum viewport dimensions", "capability", "glGetIntegerv()"), - new GLproperty(GL11.GL_MAX_ATTRIB_STACK_DEPTH, "GL_MAX_ATTRIB_STACK_DEPTH", "Maximum depth of the attribute stack", "capability", "glGetIntegerv()"), - new GLproperty(GL11.GL_MAX_CLIENT_ATTRIB_STACK_DEPTH, "GL_MAX_CLIENT_ATTRIB_STACK_DEPTH", "Maximum depth of the client attribute stack", "capability", "glGetIntegerv()"), - new GLproperty(GL11.GL_AUX_BUFFERS, "GL_AUX_BUFFERS", "Number of auxiliary buffers", "capability", "glGetBooleanv()"), - new GLproperty(GL11.GL_RGBA_MODE, "GL_RGBA_MODE", "True if color buffers store RGBA", "capability", "glGetBooleanv()"), - new GLproperty(GL11.GL_INDEX_MODE, "GL_INDEX_MODE", "True if color buffers store indices", "capability", "glGetBooleanv()"), - new GLproperty(GL11.GL_DOUBLEBUFFER, "GL_DOUBLEBUFFER", "True if front and back buffers exist", "capability", "glGetBooleanv()"), - new GLproperty(GL11.GL_STEREO, "GL_STEREO", "True if left and right buffers exist", "capability", "glGetBooleanv()"), - new GLproperty(GL11.GL_POINT_SIZE_RANGE, "GL_POINT_SIZE_RANGE", "Range (low to high) of antialiased point sizes", "capability", "glGetFloatv()"), - new GLproperty(GL11.GL_POINT_SIZE_GRANULARITY, "GL_POINT_SIZE_GRANULARITY", "Antialiased point-size granularity", "capability", "glGetFloatv()"), - new GLproperty(GL11.GL_LINE_WIDTH_RANGE, "GL_LINE_WIDTH_RANGE", "Range (low to high) of antialiased line widths", "capability", "glGetFloatv()"), - new GLproperty(GL11.GL_LINE_WIDTH_GRANULARITY, "GL_LINE_WIDTH_GRANULARITY", "Antialiased line-width granularity", "capability", "glGetFloatv()"), - new GLproperty(GL11.GL_RED_BITS, "GL_RED_BITS", "Number of bits per red component in color buffers", "capability", "glGetIntegerv()"), - new GLproperty(GL11.GL_GREEN_BITS, "GL_GREEN_BITS", "Number of bits per green component in color buffers", "capability", "glGetIntegerv()"), - new GLproperty(GL11.GL_BLUE_BITS, "GL_BLUE_BITS", "Number of bits per blue component in color buffers", "capability", "glGetIntegerv()"), - new GLproperty(GL11.GL_ALPHA_BITS, "GL_ALPHA_BITS", "Number of bits per alpha component in color buffers", "capability", "glGetIntegerv()"), - new GLproperty(GL11.GL_INDEX_BITS, "GL_INDEX_BITS", "Number of bits per index in color buffers", "capability", "glGetIntegerv()"), - new GLproperty(GL11.GL_DEPTH_BITS, "GL_DEPTH_BITS", "Number of depth-buffer bitplanes", "capability", "glGetIntegerv()"), - new GLproperty(GL11.GL_STENCIL_BITS, "GL_STENCIL_BITS", "Number of stencil bitplanes", "capability", "glGetIntegerv()"), - new GLproperty(GL11.GL_ACCUM_RED_BITS, "GL_ACCUM_RED_BITS", "Number of bits per red component in the accumulation buffer", "capability", "glGetIntegerv()"), - new GLproperty(GL11.GL_ACCUM_GREEN_BITS, "GL_ACCUM_GREEN_BITS", "Number of bits per green component in the accumulation buffer", "capability", "glGetIntegerv()"), - new GLproperty(GL11.GL_ACCUM_BLUE_BITS, "GL_ACCUM_BLUE_BITS", "Number of bits per blue component in the accumulation buffer", "capability", "glGetIntegerv()"), - new GLproperty(GL11.GL_ACCUM_ALPHA_BITS, "GL_ACCUM_ALPHA_BITS", "Number of bits per alpha component in the accumulation buffer", "capability", "glGetIntegerv()"), - new GLproperty(GL11.GL_LIST_BASE, "GL_LIST_BASE", "Setting of glListBase()", "list", "glGetIntegerv()"), - new GLproperty(GL11.GL_LIST_INDEX, "GL_LIST_INDEX", "Number of display list under construction; 0 if none", "current", "glGetIntegerv()"), - new GLproperty(GL11.GL_LIST_MODE, "GL_LIST_MODE", "Mode of display list under construction; undefined if none", "current", "glGetIntegerv()"), - new GLproperty(GL11.GL_ATTRIB_STACK_DEPTH, "GL_ATTRIB_STACK_DEPTH", "Attribute stack pointer", "current", "glGetIntegerv()"), - new GLproperty(GL11.GL_CLIENT_ATTRIB_STACK_DEPTH, "GL_CLIENT_ATTRIB_STACK_DEPTH", "Client attribute stack pointer", "current", "glGetIntegerv()"), - new GLproperty(GL11.GL_NAME_STACK_DEPTH, "GL_NAME_STACK_DEPTH", "Name stack depth", "current", "glGetIntegerv()"), - new GLproperty(GL11.GL_RENDER_MODE, "GL_RENDER_MODE", "glRenderMode() setting", "current", "glGetIntegerv()"), - new GLproperty(GL11.GL_SELECTION_BUFFER_POINTER, "GL_SELECTION_BUFFER_POINTER", "Pointer to selection buffer", "select", "glGetPointerv()"), - new GLproperty(GL11.GL_SELECTION_BUFFER_SIZE, "GL_SELECTION_BUFFER_SIZE", "Size of selection buffer", "select", "glGetIntegerv()"), - new GLproperty(GL11.GL_FEEDBACK_BUFFER_POINTER, "GL_FEEDBACK_BUFFER_POINTER", "Pointer to feedback buffer", "feedback", "glGetPointerv()"), - new GLproperty(GL11.GL_FEEDBACK_BUFFER_SIZE, "GL_FEEDBACK_BUFFER_SIZE", "Size of feedback buffer", "feedback", "glGetIntegerv()"), - new GLproperty(GL11.GL_FEEDBACK_BUFFER_TYPE, "GL_FEEDBACK_BUFFER_TYPE", "Type of feedback buffer", "feedback", "glGetIntegerv()"), - }; + public static void dumpOpenGLstate() {} - public static void dumpOpenGLstate() - { - } + public static void dumpAllIsEnabled() // Call This + { + for (int i = 0; i < instance.propertyList.length; ++i) { - public static void dumpAllIsEnabled() //Call This - { - for (int i = 0; i < instance.propertyList.length; ++i) + if (instance.propertyList[i].fetchCommand == "glIsEnabled()") { - { - if (instance.propertyList[i].fetchCommand == "glIsEnabled()") + System.out.print(instance.propertyList[i].name + ":"); + System.out.print(GL11.glIsEnabled(instance.propertyList[i].gLconstant)); + System.out.println(" (" + instance.propertyList[i].description + ")"); + } + } + } - { - System.out.print(instance.propertyList[i].name + ":"); - System.out.print(GL11.glIsEnabled(instance.propertyList[i].gLconstant)); - System.out.println(" (" + instance.propertyList[i].description + ")"); - } - } - } + public static void dumpAllType(final String type) { - public static void dumpAllType(final String type) + for (int i = 0; i < instance.propertyList.length; ++i) { - { - for (int i = 0; i < instance.propertyList.length; ++i) + if (instance.propertyList[i].category.equals(type)) { - { - if (instance.propertyList[i].category.equals(type)) + System.out.print(instance.propertyList[i].name + ":"); + System.out.println(getPropertyAsString(i)); + System.out.println(" (" + instance.propertyList[i].description + ")"); + } + } + } - { - System.out.print(instance.propertyList[i].name + ":"); - System.out.println(getPropertyAsString(i)); - System.out.println(" (" + instance.propertyList[i].description + ")"); - } - } - } + private static String getPropertyAsString(final int propertyListIndex) { + final int gLconstant = instance.propertyList[propertyListIndex].gLconstant; + if (instance.propertyList[propertyListIndex].fetchCommand.equals("glIsEnabled()")) { + return "" + GL11.glIsEnabled(gLconstant); + } - private static String getPropertyAsString(final int propertyListIndex) - { - final int gLconstant = instance.propertyList[propertyListIndex].gLconstant; - if (instance.propertyList[propertyListIndex].fetchCommand.equals("glIsEnabled()")) { - return "" + GL11.glIsEnabled(gLconstant); - } + if (instance.propertyList[propertyListIndex].fetchCommand == "glGetBooleanv()") { - if (instance.propertyList[propertyListIndex].fetchCommand == "glGetBooleanv()") + final ByteBuffer params = BufferUtils.createByteBuffer(16); - { - final ByteBuffer params = BufferUtils.createByteBuffer(16); + GL11.glGetBoolean(gLconstant, params); + String out = ""; + for (int i = 0; i < params.capacity(); ++i) { - GL11.glGetBoolean(gLconstant, params); - String out = ""; - for (int i = 0; i < params.capacity(); ++i) + out += (i == 0 ? "" : ", ") + params.get(i); + } + return out; + } - { - out += (i == 0 ? "" : ", ") + params.get(i); - } - return out; - } - - return ""; - } + return ""; + } } - diff --git a/src/main/java/gtPlusPlus/core/util/math/MathUtils.java b/src/main/java/gtPlusPlus/core/util/math/MathUtils.java index 4ff929c643..54a5ef8668 100644 --- a/src/main/java/gtPlusPlus/core/util/math/MathUtils.java +++ b/src/main/java/gtPlusPlus/core/util/math/MathUtils.java @@ -1,811 +1,772 @@ package gtPlusPlus.core.util.math; -import java.text.NumberFormat; -import java.util.Map; -import java.util.Random; - import gregtech.api.enums.GT_Values; - 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.util.Utils; +import java.text.NumberFormat; +import java.util.Map; +import java.util.Random; public class MathUtils { - final static Random rand = CORE.RANDOM; - - /** Formats a number with group separator and at most 2 fraction digits. */ - private static final NumberFormat sNumberFormat = NumberFormat.getInstance(); - - static { - sNumberFormat.setMaximumFractionDigits(2); - } - - /** - * Returns a psuedo-random number between min and max, inclusive. - * The difference between min and max can be at most - * Integer.MAX_VALUE - 1. - * - * @param min Minimim value - * @param max Maximim value. Must be greater than min. - * @return Integer between min and max, inclusive. - * @see java.util.Random#nextInt(int) - */ - public static int randInt(final int min, final int max) { - // nextInt is normally exclusive of the top value, - // so add 1 to make it inclusive - return rand.nextInt((max - min) + 1) + min; - } - - public static double getChanceOfXOverYRuns(final double x, final double y){ - return (1-Math.pow((1-x), y)); - } - - - /** - * Returns a psuedo-random number between min and max, inclusive. - * The difference between min and max can be at most - * Long.MAX_VALUE - 1. - * - * @param min Minimim value - * @param max Maximim value. Must be greater than min. - * @return Long between min and max, inclusive. - * @see java.util.Random#nextLong(long) - */ - public static long randLong(final long min, final long max) { - // nextInt is normally exclusive of the top value, - // so add 1 to make it inclusive - return MathUtils.nextLong(rand,(max - min) + 1) + min; - } - private static long nextLong(final Random rng, final long n) { - // error checking and 2^x checking removed for simplicity. - long bits, val; - do { - bits = (rng.nextLong() << 1) >>> 1; - val = bits % n; - } while (((bits-val)+(n-1)) < 0L); - return val; - } - - - /** - * Returns a psuedo-random number between min and max, inclusive. - * The difference between min and max can be at most - * Double.MAX_VALUE - 1. - * - * @param min Minimim value - * @param max Maximim value. Must be greater than min. - * @return Double between min and max, inclusive. - * @see java.util.Random#nextDouble(double) - */ - public static double randDouble(final double min, final double max) { - // nextInt is normally exclusive of the top value, - // so add 1 to make it inclusive - return MathUtils.nextDouble(rand,(max - min) + 1) + min; - } - - private static double nextDouble(final Random rng, final double n) { - // error checking and 2^x checking removed for simplicity. - double bits, val; - do { - bits = (rng.nextLong() << 1) >>> 1; - val = bits % n; - } while (((bits-val)+(n-1)) < 0L); - return val; - } - - /** - * Returns a psuedo-random number between min and max, inclusive. - * The difference between min and max can be at most - * Float.MAX_VALUE - 1. - * - * @param min Minimim value - * @param max Maximim value. Must be greater than min. - * @return Float between min and max, inclusive. - * @see java.util.Random#nextFloat(float) - */ - public static float randFloat(final float min, final float max) { - // nextInt is normally exclusive of the top value, - // so add 1 to make it inclusive - return MathUtils.nextFloat(rand,(max - min) + 1) + min; - } - - private static float nextFloat(final Random rng, final float n) { - // error checking and 2^x checking removed for simplicity. - float bits, val; - do { - bits = (rng.nextLong() << 1) >>> 1; - val = bits % n; - } while (((bits-val)+(n-1)) < 0L); - return val; - } - - - /** - * Returns a percentage. - * The returned number is the % of X in Y. - * Supports Doubles. - * - * @param current Current value. - * @param max Maximim value. Must be greater than min. - * @return double between min and max, inclusive. - */ - public static double findPercentage(final double current, final double max){ - return Math.round(((current / max) * 100) * 100.00) / 100.00; - } - - /** - * Returns a percentage. - * The returned number is the % of X in Y. - * Supports Floats. - * - * @param current Current value. - * @param max Maximim value. Must be greater than min. - * @return double between min and max, inclusive. - */ - public static float findPercentage(final float current, final float max){ - return (float) (Math.round(((current / max) * 100) * 100.00) / 100.00); - } - - public static int findPercentageOfInt(long input, float percentage){ - return (int)(input*(percentage/100.0f)); - } - - - //Smooth Rounding Function - /** - * Returns a double. - * The returned number is d rounded to the nearest d.01. - * Supports Doubles. - * - * @param current Current value. - * @return double Rounded value. - */ - public static double decimalRounding(final double d) { - return Math.round(d * 2) / 2.0; - } - - - //Smooth Rounding Function (Nearest 5) - /** - * Returns a double. - * The returned number is d rounded to the nearest d.5. - * Supports Doubles. - * - * @param current Current value. - * @return double Rounded value. - */ - public static double decimalRoundingToWholes(final double d) { - return 5*(Math.round(d/5)); - } - - //Smooth Rounding Function - /** - * Returns a integer. - * The returned number is d rounded to the nearest flat integer. - * Supports Doubles as input. - * - * @param current Current value. - * @return integer Rounded value. - */ - public static int roundToClosestInt(final double d) { - return (int) (Math.round(d * 2) / 2.0); - } - - public static int roundToClosestMultiple(final double number, final int multiple) { - int result = multiple; - if ((number % multiple) == 0) { - return (int) number; - } - // If not already multiple of given number - if ((number % multiple) != 0) { - final int division = (int) ((number / multiple) + 1); - result = division * multiple; - } - return result; - } - - - //Smooth Rounding Function - /** - * Returns a long. - * The returned number is d rounded to the nearest flat long. - * Supports Doubles as input. - * - * @param current Current value. - * @return long Rounded value. - */ - public static long roundToClosestLong(final double d) { - return (long) (Math.round(d * 2) / 2.0); - } - - - /** - * Returns a boolean. - * The returned boolean is wether or not X evenly fits in to Y. - * Supports ints. - * - * @param x Value A. - * @param y Value B. Must be greater than min. - * @return boolean Whether or not it divides evenly. - */ - public static boolean divideXintoY(final int x, final int y){ - if ((x % y) == 0) - { - return true; - } - return false; - } - - - /** - * Returns a boolean. - * The returned boolean is based on the odd/eveness of the input. - * Supports ints. - * - * @param x Value A. - * @return boolean Whether or not it divides evenly. - */ - public static boolean isNumberEven(final long x){ - if ((x % 2) == 0) - { - return true; - } - return false; - } - - - - /** - * Returns an int. - * The returned number is the value on i + 273.15F. - * Supports ints. - * - * @param i Temp in Celcius. - * @return int The celcius temp returned as Kelvin, rounded to the readest whole. - */ - public static float celsiusToKelvin(final int i){ - final double f = i + 273.15F; - return (int)decimalRoundingToWholes(f); - } - - - /** - * Returns a hexInteger. - * The returned number is the hex value of the input. - * Supports ints. - * - * @param input Current value. - * @return hexInteger. - */ - public static int getHexNumberFromInt(final int input){ - final String result = Integer.toHexString(input); - final int resultINT = Integer.getInteger(result); - return resultINT; - } - - - /** - * Returns a hexInteger. - * The returned value is between min and max. - * Supports ints. - * - * @param min Minimum value. - * @param max Maximium value. Must be greater than min. - * @return hexInteger between min and max, inclusive. - */ - public static int generateRandomHexValue(final int min, final int max){ - return getHexNumberFromInt(randInt(min, max)); - } - - - /** - * Returns a random hex value. - * The returned value is between 000000-ffffff. - * - * @return hexInteger between min and max, inclusive. - */ - public static int generateSingularRandomHexValue(){ - String temp; - final int randomInt = randInt(1, 5); - final Map colours = Utils.hexColourGeneratorRandom(5); - - if ((colours.get(randomInt) != null) && (colours.size() > 0)){ - temp = colours.get(randomInt); - } - else { - temp = "0F0F0F"; - } - - Logger.WARNING("Operating with "+temp); - temp = Utils.appenedHexNotationToString(String.valueOf(temp)); - Logger.WARNING("Made "+temp+" - Hopefully it's not a mess."); - Logger.WARNING("It will decode into "+Integer.decode(temp)+"."); - return Integer.decode(temp); - } - - public static long[] simplifyNumbersToSmallestForm(final long[] inputArray){ - final long GCD = gcd(inputArray); - final long[] outputArray = new long[inputArray.length]; - for (int i=0;i 0) { - return outputArray; - } - return new long[] {}; - } - - private static long gcd(long a, long b){ - while (b > 0) - { - final long temp = b; - b = a % b; // % is remainder - a = temp; - } - return a; - } - - private static long gcd(final long[] input){ - long result = input[0]; - for(int i = 1; i < input.length; i++) { - result = gcd(result, input[i]); - } - return result; - } - - final public static int getRgbAsHex(final short[] RGBA){ - final int returnValue = Utils.rgbtoHexValue(RGBA[0], RGBA[1], RGBA[2]); - return (returnValue == 0) ? 0 : returnValue; - } - - - public final static int returnLargestNumber(final int a, final int b){ - if (a > b){ - return a; - } - else if (a == b){ - return a; - } - else { - return b; - } - } - - public static byte safeByte(long number){ - return number>Byte.MAX_VALUE ? Byte.MAX_VALUE :(byte)number; - } - - public static short safeShort(long number){ - return number>Short.MAX_VALUE ? Short.MAX_VALUE :(short)number; - } - - public static int safeInt(long number, int margin){ - return number>Integer.MAX_VALUE-margin ? Integer.MAX_VALUE-margin :(int)number; - } - - public static int safeInt(long number){ - return number>GT_Values.V[GT_Values.V.length-1] ? safeInt(GT_Values.V[GT_Values.V.length-1],1) : number aDataSet) { - byte[] aNewSet = new byte[aDataSet.size()]; - for (int u=0;u aDataSet) { - short[] aNewSet = new short[aDataSet.size()]; - for (int u=0;u aDataSet) { - int[] aNewSet = new int[aDataSet.size()]; - for (int u=0;u aDataSet) { - float[] aNewSet = new float[aDataSet.size()]; - for (int u=0;u aDataSet) { - long[] aNewSet = new long[aDataSet.size()]; - for (int u=0;u aDataSet) { - double[] aNewSet = new double[aDataSet.size()]; - for (int u=0;u 0) { - return -aPositive; - } - else if (aPositive < 0) { - return +aPositive; - } - else { - return 0; - } - } - - public static V safeCast(Object aNumberType) { - long a1; - double a2; - a1 = Long.parseLong(aNumberType.toString()); - a2 = Double.parseDouble(aNumberType.toString()); - - if ((aNumberType.getClass() == byte.class) || (aNumberType instanceof Byte)){ - if (a1 >= Byte.MIN_VALUE && a1 <= Byte.MAX_VALUE) { - String s = ""+a1; - Byte s1 = Byte.valueOf(s); - return (V) s1; - } - } - else if ((aNumberType.getClass() == short.class) || (aNumberType instanceof Short)){ - if (a1 >= Short.MIN_VALUE && a1 <= Short.MAX_VALUE) { - String s = ""+a1; - Short s1 = Short.valueOf(s); - return (V) s1; - - } - } - else if ((aNumberType.getClass() == int.class) || (aNumberType instanceof Integer)){ - if (a1 >= Integer.MIN_VALUE && a1 <= Integer.MAX_VALUE) { - String s = ""+a1; - Integer s1 = Integer.valueOf(s); - return (V) s1; - - } - } - else if ((aNumberType.getClass() == long.class) || (aNumberType instanceof Long)){ - if (a1 >= Long.MIN_VALUE && a1 <= Long.MAX_VALUE) { - String s = ""+a1; - Long s1 = Long.valueOf(s); - return (V) s1; - } - } - else if ((aNumberType.getClass() == float.class) || (aNumberType instanceof Float)){ - if (a2 >= Float.MIN_VALUE && a2 <= Float.MAX_VALUE) { - String s = ""+a1; - Float s1 = Float.valueOf(s); - return (V) s1; - - } - } - else if ((aNumberType.getClass() == double.class) || (aNumberType instanceof Double)){ - if (a2 >= Double.MIN_VALUE && a2 <= Double.MAX_VALUE) { - String s = ""+a1; - Double s1 = Double.valueOf(s); - return (V) s1; - - } - } - - Integer o = 0; - return (V) o; - - } - - public static byte getSafeByte(Byte b) { - Byte a = safeCast(b); - return a.byteValue(); - } - - public static short getSafeShort(Short b) { - Short a = safeCast(b); - return a.shortValue(); - } - - public static int getSafeInt(Integer b) { - Integer a = safeCast(b); - return a.intValue(); - } - - public static long getSafeLong(Long b) { - Long a = safeCast(b); - return a.longValue(); - } - - public static float getSafeFloat(Float b) { - Float a = safeCast(b); - return a.floatValue(); - } - - public static double getSafeDouble(Double b) { - Double a = safeCast(b); - return a.doubleValue(); - } - - - public static long safeCast_IntToLong(int o) { - long i = o; - return i; - } - - public static int safeCast_LongToInt(long o) { - if (o > Integer.MAX_VALUE) { - return Integer.MAX_VALUE; - } - else { - int i = (int) o; - return i; - } - } - - public static short safeCast_IntToShort(int o) { - if (o > Short.MAX_VALUE) { - return Short.MAX_VALUE; - } - else { - short i = (short) o; - return i; - } - } - - public static int safeCast_ShortToInt(short o) { - int i = (int) o; - return i; - } - - public static byte safeCast_ShortToByte(short o) { - if (o > Byte.MAX_VALUE) { - return Byte.MAX_VALUE; - } - else { - byte i = (byte) o; - return i; - } - } - - public static short safeCast_ByteToshort(byte o) { - short i = (short) o; - return i; - } - - /** - * Balances a number within a range. - * @param aInput - The number to balance - * @param aMin - The minimum bounds - * @param aMax - The maximum bounds - * @return - An Integer which will be between the bounds, or a boundary value. - */ - public static int balance(int aInput, int aMin, int aMax) { - return Math.max(Math.min(aInput, aMax), aMin); - } - - /** - * Balances a number within a range. - * @param aInput - The number to balance - * @param aMin - The minimum bounds - * @param aMax - The maximum bounds - * @return - A Number which will be between the bounds, or a boundary value. - */ - public static Number balance(Number aInput, Number aMin, Number aMax) { - return max(min(aInput, aMax), aMin); - } - - /** - * Balances a number within a range. - * @param aInput - The number to balance - * @param aMin - The minimum bounds - * @param aMax - The maximum bounds - * @return - An Integer which will be between the bounds, or a boundary value. - */ - public static int balanceInt(Number aInput, Number aMin, Number aMax) { - return MathUtils.safeCast_LongToInt((long) balance(max(min(aInput, aMax), aMin), Integer.MIN_VALUE, Integer.MAX_VALUE)); - } - - /** - * Balances a number within a range. - * @param aInput - The number to balance - * @param aMin - The minimum bounds - * @param aMax - The maximum bounds - * @return - A Long which will be between the bounds, or a boundary value. - */ - public static long balanceLong(Number aInput, Number aMin, Number aMax) { - return (long) balance(max(min(aInput, aMax), aMin), Long.MIN_VALUE, Long.MAX_VALUE); - } - - public static int getValueWithinRange(int i, int aMin, int aMax) { - int aAmount = Math.max(Math.min(i, aMax), aMin); - return aAmount; - } - - public static Pair splitLongIntoIntegers(long aLong){ - int aIntMaxInLong = (int) Math.min(Integer.MAX_VALUE, Math.floor(aLong/Integer.MAX_VALUE)); - int aRemainder = (int) (aLong - (aIntMaxInLong * Integer.MAX_VALUE)); - return new Pair(aIntMaxInLong, aRemainder); - } - - - - - /** - * Returns the smaller of two {@code Number}s. That is, - * the result the argument closer to the value of - * {@link Long#MIN_VALUE}. If the arguments have the same - * value, the result is that same value. - * - * @param a an argument. - * @param b another argument. - * @return the smaller of {@code a} and {@code b}. - */ - public static Number min(Number a, Number b) { - return (a.longValue() <= b.longValue()) ? a : b; - } - - /** - * Returns the greater of two {@code Number}s. That is, the - * result is the argument closer to the value of - * {@link Long#MAX_VALUE}. If the arguments have the same value, - * the result is that same value. - * - * @param a an argument. - * @param b another argument. - * @return the larger of {@code a} and {@code b}. - */ - public static Number max(Number a, Number b) { - return (a.longValue() >= b.longValue()) ? a : b; - } - - public static long combineTwoIntegersToLong(int a, int b) { - long val = (((long) a) << 32) | (b & 0xffffffffL); - return val; - } - - public static int[] splitLongIntoTwoIntegers(long aNum) { - int a = (int) (aNum >> 32); - int b = (int) aNum; - return new int[] {a, b}; - } - - public static String formatNumbers(long aNumber) { - return sNumberFormat.format(aNumber); - } - - public static String formatNumbers(double aNumber) { - return sNumberFormat.format(aNumber); - } - - + static final Random rand = CORE.RANDOM; + + /** Formats a number with group separator and at most 2 fraction digits. */ + private static final NumberFormat sNumberFormat = NumberFormat.getInstance(); + + static { + sNumberFormat.setMaximumFractionDigits(2); + } + + /** + * Returns a psuedo-random number between min and max, inclusive. + * The difference between min and max can be at most + * Integer.MAX_VALUE - 1. + * + * @param min Minimim value + * @param max Maximim value. Must be greater than min. + * @return Integer between min and max, inclusive. + * @see java.util.Random#nextInt(int) + */ + public static int randInt(final int min, final int max) { + // nextInt is normally exclusive of the top value, + // so add 1 to make it inclusive + return rand.nextInt((max - min) + 1) + min; + } + + public static double getChanceOfXOverYRuns(final double x, final double y) { + return (1 - Math.pow((1 - x), y)); + } + + /** + * Returns a psuedo-random number between min and max, inclusive. + * The difference between min and max can be at most + * Long.MAX_VALUE - 1. + * + * @param min Minimim value + * @param max Maximim value. Must be greater than min. + * @return Long between min and max, inclusive. + * @see java.util.Random#nextLong(long) + */ + public static long randLong(final long min, final long max) { + // nextInt is normally exclusive of the top value, + // so add 1 to make it inclusive + return MathUtils.nextLong(rand, (max - min) + 1) + min; + } + + private static long nextLong(final Random rng, final long n) { + // error checking and 2^x checking removed for simplicity. + long bits, val; + do { + bits = (rng.nextLong() << 1) >>> 1; + val = bits % n; + } while (((bits - val) + (n - 1)) < 0L); + return val; + } + + /** + * Returns a psuedo-random number between min and max, inclusive. + * The difference between min and max can be at most + * Double.MAX_VALUE - 1. + * + * @param min Minimim value + * @param max Maximim value. Must be greater than min. + * @return Double between min and max, inclusive. + * @see java.util.Random#nextDouble(double) + */ + public static double randDouble(final double min, final double max) { + // nextInt is normally exclusive of the top value, + // so add 1 to make it inclusive + return MathUtils.nextDouble(rand, (max - min) + 1) + min; + } + + private static double nextDouble(final Random rng, final double n) { + // error checking and 2^x checking removed for simplicity. + double bits, val; + do { + bits = (rng.nextLong() << 1) >>> 1; + val = bits % n; + } while (((bits - val) + (n - 1)) < 0L); + return val; + } + + /** + * Returns a psuedo-random number between min and max, inclusive. + * The difference between min and max can be at most + * Float.MAX_VALUE - 1. + * + * @param min Minimim value + * @param max Maximim value. Must be greater than min. + * @return Float between min and max, inclusive. + * @see java.util.Random#nextFloat(float) + */ + public static float randFloat(final float min, final float max) { + // nextInt is normally exclusive of the top value, + // so add 1 to make it inclusive + return MathUtils.nextFloat(rand, (max - min) + 1) + min; + } + + private static float nextFloat(final Random rng, final float n) { + // error checking and 2^x checking removed for simplicity. + float bits, val; + do { + bits = (rng.nextLong() << 1) >>> 1; + val = bits % n; + } while (((bits - val) + (n - 1)) < 0L); + return val; + } + + /** + * Returns a percentage. + * The returned number is the % of X in Y. + * Supports Doubles. + * + * @param current Current value. + * @param max Maximim value. Must be greater than min. + * @return double between min and max, inclusive. + */ + public static double findPercentage(final double current, final double max) { + return Math.round(((current / max) * 100) * 100.00) / 100.00; + } + + /** + * Returns a percentage. + * The returned number is the % of X in Y. + * Supports Floats. + * + * @param current Current value. + * @param max Maximim value. Must be greater than min. + * @return double between min and max, inclusive. + */ + public static float findPercentage(final float current, final float max) { + return (float) (Math.round(((current / max) * 100) * 100.00) / 100.00); + } + + public static int findPercentageOfInt(long input, float percentage) { + return (int) (input * (percentage / 100.0f)); + } + + // Smooth Rounding Function + /** + * Returns a double. + * The returned number is d rounded to the nearest d.01. + * Supports Doubles. + * + * @param current Current value. + * @return double Rounded value. + */ + public static double decimalRounding(final double d) { + return Math.round(d * 2) / 2.0; + } + + // Smooth Rounding Function (Nearest 5) + /** + * Returns a double. + * The returned number is d rounded to the nearest d.5. + * Supports Doubles. + * + * @param current Current value. + * @return double Rounded value. + */ + public static double decimalRoundingToWholes(final double d) { + return 5 * (Math.round(d / 5)); + } + + // Smooth Rounding Function + /** + * Returns a integer. + * The returned number is d rounded to the nearest flat integer. + * Supports Doubles as input. + * + * @param current Current value. + * @return integer Rounded value. + */ + public static int roundToClosestInt(final double d) { + return (int) (Math.round(d * 2) / 2.0); + } + + public static int roundToClosestMultiple(final double number, final int multiple) { + int result = multiple; + if ((number % multiple) == 0) { + return (int) number; + } + // If not already multiple of given number + if ((number % multiple) != 0) { + final int division = (int) ((number / multiple) + 1); + result = division * multiple; + } + return result; + } + + // Smooth Rounding Function + /** + * Returns a long. + * The returned number is d rounded to the nearest flat long. + * Supports Doubles as input. + * + * @param current Current value. + * @return long Rounded value. + */ + public static long roundToClosestLong(final double d) { + return (long) (Math.round(d * 2) / 2.0); + } + + /** + * Returns a boolean. + * The returned boolean is wether or not X evenly fits in to Y. + * Supports ints. + * + * @param x Value A. + * @param y Value B. Must be greater than min. + * @return boolean Whether or not it divides evenly. + */ + public static boolean divideXintoY(final int x, final int y) { + if ((x % y) == 0) { + return true; + } + return false; + } + + /** + * Returns a boolean. + * The returned boolean is based on the odd/eveness of the input. + * Supports ints. + * + * @param x Value A. + * @return boolean Whether or not it divides evenly. + */ + public static boolean isNumberEven(final long x) { + if ((x % 2) == 0) { + return true; + } + return false; + } + + /** + * Returns an int. + * The returned number is the value on i + 273.15F. + * Supports ints. + * + * @param i Temp in Celcius. + * @return int The celcius temp returned as Kelvin, rounded to the readest whole. + */ + public static float celsiusToKelvin(final int i) { + final double f = i + 273.15F; + return (int) decimalRoundingToWholes(f); + } + + /** + * Returns a hexInteger. + * The returned number is the hex value of the input. + * Supports ints. + * + * @param input Current value. + * @return hexInteger. + */ + public static int getHexNumberFromInt(final int input) { + final String result = Integer.toHexString(input); + final int resultINT = Integer.getInteger(result); + return resultINT; + } + + /** + * Returns a hexInteger. + * The returned value is between min and max. + * Supports ints. + * + * @param min Minimum value. + * @param max Maximium value. Must be greater than min. + * @return hexInteger between min and max, inclusive. + */ + public static int generateRandomHexValue(final int min, final int max) { + return getHexNumberFromInt(randInt(min, max)); + } + + /** + * Returns a random hex value. + * The returned value is between 000000-ffffff. + * + * @return hexInteger between min and max, inclusive. + */ + public static int generateSingularRandomHexValue() { + String temp; + final int randomInt = randInt(1, 5); + final Map colours = Utils.hexColourGeneratorRandom(5); + + if ((colours.get(randomInt) != null) && (colours.size() > 0)) { + temp = colours.get(randomInt); + } else { + temp = "0F0F0F"; + } + + Logger.WARNING("Operating with " + temp); + temp = Utils.appenedHexNotationToString(String.valueOf(temp)); + Logger.WARNING("Made " + temp + " - Hopefully it's not a mess."); + Logger.WARNING("It will decode into " + Integer.decode(temp) + "."); + return Integer.decode(temp); + } + + public static long[] simplifyNumbersToSmallestForm(final long[] inputArray) { + final long GCD = gcd(inputArray); + final long[] outputArray = new long[inputArray.length]; + for (int i = 0; i < inputArray.length; i++) { + if (GCD != 0) { + outputArray[i] = (inputArray[i] / GCD); + } else { + outputArray[i] = inputArray[i]; + } + } + if (outputArray.length > 0) { + return outputArray; + } + return new long[] {}; + } + + private static long gcd(long a, long b) { + while (b > 0) { + final long temp = b; + b = a % b; // % is remainder + a = temp; + } + return a; + } + + private static long gcd(final long[] input) { + long result = input[0]; + for (int i = 1; i < input.length; i++) { + result = gcd(result, input[i]); + } + return result; + } + + public static final int getRgbAsHex(final short[] RGBA) { + final int returnValue = Utils.rgbtoHexValue(RGBA[0], RGBA[1], RGBA[2]); + return (returnValue == 0) ? 0 : returnValue; + } + + public static final int returnLargestNumber(final int a, final int b) { + if (a > b) { + return a; + } else if (a == b) { + return a; + } else { + return b; + } + } + + public static byte safeByte(long number) { + return number > Byte.MAX_VALUE ? Byte.MAX_VALUE : (byte) number; + } + + public static short safeShort(long number) { + return number > Short.MAX_VALUE ? Short.MAX_VALUE : (short) number; + } + + public static int safeInt(long number, int margin) { + return number > Integer.MAX_VALUE - margin ? Integer.MAX_VALUE - margin : (int) number; + } + + public static int safeInt(long number) { + return number > GT_Values.V[GT_Values.V.length - 1] + ? safeInt(GT_Values.V[GT_Values.V.length - 1], 1) + : number < Integer.MIN_VALUE ? Integer.MIN_VALUE : (int) number; + } + + public static int getRandomFromArray(int[] mValues) { + int[] mLargeChanceArray = new int[(mValues.length - 1) * 1000]; + int mValueSelection; + for (int g = 0; g < mLargeChanceArray.length; g++) { + mValueSelection = randInt(0, mValues.length - 1); + mLargeChanceArray[g] = mValues[mValueSelection]; + } + return mLargeChanceArray[randInt(0, mLargeChanceArray.length - 1)]; + } + + /* + * Averages + */ + + public static byte getByteAverage(AutoMap aDataSet) { + byte[] aNewSet = new byte[aDataSet.size()]; + for (int u = 0; u < aDataSet.size(); u++) { + byte b = getSafeByte(aDataSet.get(u)); + aNewSet[u] = b; + } + return getByteAverage(aNewSet); + } + + public static short getShortAverage(AutoMap aDataSet) { + short[] aNewSet = new short[aDataSet.size()]; + for (int u = 0; u < aDataSet.size(); u++) { + short b = getSafeShort(aDataSet.get(u)); + aNewSet[u] = b; + } + return getShortAverage(aNewSet); + } + + public static int getIntAverage(AutoMap aDataSet) { + int[] aNewSet = new int[aDataSet.size()]; + for (int u = 0; u < aDataSet.size(); u++) { + int b = getSafeInt(aDataSet.get(u)); + aNewSet[u] = b; + } + return getIntAverage(aNewSet); + } + + public static float getFloatAverage(AutoMap aDataSet) { + float[] aNewSet = new float[aDataSet.size()]; + for (int u = 0; u < aDataSet.size(); u++) { + float b = getSafeFloat(aDataSet.get(u)); + aNewSet[u] = b; + } + return getFloatAverage(aNewSet); + } + + public static long getLongAverage(AutoMap aDataSet) { + long[] aNewSet = new long[aDataSet.size()]; + for (int u = 0; u < aDataSet.size(); u++) { + long b = getSafeLong(aDataSet.get(u)); + aNewSet[u] = b; + } + return getLongAverage(aNewSet); + } + + public static double getDoubleAverage(AutoMap aDataSet) { + double[] aNewSet = new double[aDataSet.size()]; + for (int u = 0; u < aDataSet.size(); u++) { + double b = getSafeDouble(aDataSet.get(u)); + aNewSet[u] = b; + } + return getDoubleAverage(aNewSet); + } + + public static byte getByteAverage(byte[] aDataSet) { + if (aDataSet.length <= 0) { + return 0; + } + int divisor = aDataSet.length; + byte total = 0; + for (byte i : aDataSet) { + total += i; + } + byte result = safeByte(total / divisor); + return result; + } + + public static short getShortAverage(short[] aDataSet) { + if (aDataSet.length <= 0) { + return 0; + } + int divisor = aDataSet.length; + Logger.WARNING("Calculating Average Short. Divisor: " + divisor); + short total = 0; + for (short i : aDataSet) { + Logger.WARNING("Adding " + i); + total += i; + } + short result = safeShort((total / divisor)); + Logger.WARNING("Average: " + result); + return result; + } + + public static int getIntAverage(int[] aDataSet) { + if (aDataSet.length <= 0) { + return 0; + } + int divisor = aDataSet.length; + int total = 0; + for (int i : aDataSet) { + total += i; + } + int result = safeInt(total / divisor); + return result; + } + + public static float getFloatAverage(float[] aDataSet) { + if (aDataSet.length <= 0) { + return 0; + } + int divisor = aDataSet.length; + float total = 0; + for (float i : aDataSet) { + total += i; + } + float result = (total / divisor); + return result; + } + + public static long getLongAverage(long[] aDataSet) { + if (aDataSet.length <= 0) { + return 0; + } + int divisor = aDataSet.length; + long total = 0; + for (long i : aDataSet) { + total += i; + } + long result = (total / divisor); + return result; + } + + public static double getDoubleAverage(double[] aDataSet) { + if (aDataSet.length <= 0) { + return 0; + } + int divisor = aDataSet.length; + double total = 0; + for (double i : aDataSet) { + total += i; + } + double result = (total / divisor); + return result; + } + + public static int howManyPlaces(int aValueForGen) { + if (aValueForGen < 0) { + aValueForGen = makeNegative(aValueForGen); + } + String a = String.valueOf(aValueForGen); + return a.length(); + } + + /** + * Inverts the value, making Positives into Negatives and vice versa. + * @param aPositive - An int value, either positive or negative. + * @return - Inverted int Value. + */ + public static int makeNegative(int aPositive) { + if (aPositive > 0) { + return -aPositive; + } else if (aPositive < 0) { + return +aPositive; + } else { + return 0; + } + } + + public static V safeCast(Object aNumberType) { + long a1; + double a2; + a1 = Long.parseLong(aNumberType.toString()); + a2 = Double.parseDouble(aNumberType.toString()); + + if ((aNumberType.getClass() == byte.class) || (aNumberType instanceof Byte)) { + if (a1 >= Byte.MIN_VALUE && a1 <= Byte.MAX_VALUE) { + String s = "" + a1; + Byte s1 = Byte.valueOf(s); + return (V) s1; + } + } else if ((aNumberType.getClass() == short.class) || (aNumberType instanceof Short)) { + if (a1 >= Short.MIN_VALUE && a1 <= Short.MAX_VALUE) { + String s = "" + a1; + Short s1 = Short.valueOf(s); + return (V) s1; + } + } else if ((aNumberType.getClass() == int.class) || (aNumberType instanceof Integer)) { + if (a1 >= Integer.MIN_VALUE && a1 <= Integer.MAX_VALUE) { + String s = "" + a1; + Integer s1 = Integer.valueOf(s); + return (V) s1; + } + } else if ((aNumberType.getClass() == long.class) || (aNumberType instanceof Long)) { + if (a1 >= Long.MIN_VALUE && a1 <= Long.MAX_VALUE) { + String s = "" + a1; + Long s1 = Long.valueOf(s); + return (V) s1; + } + } else if ((aNumberType.getClass() == float.class) || (aNumberType instanceof Float)) { + if (a2 >= Float.MIN_VALUE && a2 <= Float.MAX_VALUE) { + String s = "" + a1; + Float s1 = Float.valueOf(s); + return (V) s1; + } + } else if ((aNumberType.getClass() == double.class) || (aNumberType instanceof Double)) { + if (a2 >= Double.MIN_VALUE && a2 <= Double.MAX_VALUE) { + String s = "" + a1; + Double s1 = Double.valueOf(s); + return (V) s1; + } + } + + Integer o = 0; + return (V) o; + } + + public static byte getSafeByte(Byte b) { + Byte a = safeCast(b); + return a.byteValue(); + } + + public static short getSafeShort(Short b) { + Short a = safeCast(b); + return a.shortValue(); + } + + public static int getSafeInt(Integer b) { + Integer a = safeCast(b); + return a.intValue(); + } + + public static long getSafeLong(Long b) { + Long a = safeCast(b); + return a.longValue(); + } + + public static float getSafeFloat(Float b) { + Float a = safeCast(b); + return a.floatValue(); + } + + public static double getSafeDouble(Double b) { + Double a = safeCast(b); + return a.doubleValue(); + } + + public static long safeCast_IntToLong(int o) { + long i = o; + return i; + } + + public static int safeCast_LongToInt(long o) { + if (o > Integer.MAX_VALUE) { + return Integer.MAX_VALUE; + } else { + int i = (int) o; + return i; + } + } + + public static short safeCast_IntToShort(int o) { + if (o > Short.MAX_VALUE) { + return Short.MAX_VALUE; + } else { + short i = (short) o; + return i; + } + } + + public static int safeCast_ShortToInt(short o) { + int i = (int) o; + return i; + } + + public static byte safeCast_ShortToByte(short o) { + if (o > Byte.MAX_VALUE) { + return Byte.MAX_VALUE; + } else { + byte i = (byte) o; + return i; + } + } + + public static short safeCast_ByteToshort(byte o) { + short i = (short) o; + return i; + } + + /** + * Balances a number within a range. + * @param aInput - The number to balance + * @param aMin - The minimum bounds + * @param aMax - The maximum bounds + * @return - An Integer which will be between the bounds, or a boundary value. + */ + public static int balance(int aInput, int aMin, int aMax) { + return Math.max(Math.min(aInput, aMax), aMin); + } + + /** + * Balances a number within a range. + * @param aInput - The number to balance + * @param aMin - The minimum bounds + * @param aMax - The maximum bounds + * @return - A Number which will be between the bounds, or a boundary value. + */ + public static Number balance(Number aInput, Number aMin, Number aMax) { + return max(min(aInput, aMax), aMin); + } + + /** + * Balances a number within a range. + * @param aInput - The number to balance + * @param aMin - The minimum bounds + * @param aMax - The maximum bounds + * @return - An Integer which will be between the bounds, or a boundary value. + */ + public static int balanceInt(Number aInput, Number aMin, Number aMax) { + return MathUtils.safeCast_LongToInt( + (long) balance(max(min(aInput, aMax), aMin), Integer.MIN_VALUE, Integer.MAX_VALUE)); + } + + /** + * Balances a number within a range. + * @param aInput - The number to balance + * @param aMin - The minimum bounds + * @param aMax - The maximum bounds + * @return - A Long which will be between the bounds, or a boundary value. + */ + public static long balanceLong(Number aInput, Number aMin, Number aMax) { + return (long) balance(max(min(aInput, aMax), aMin), Long.MIN_VALUE, Long.MAX_VALUE); + } + + public static int getValueWithinRange(int i, int aMin, int aMax) { + int aAmount = Math.max(Math.min(i, aMax), aMin); + return aAmount; + } + + public static Pair splitLongIntoIntegers(long aLong) { + int aIntMaxInLong = (int) Math.min(Integer.MAX_VALUE, Math.floor(aLong / Integer.MAX_VALUE)); + int aRemainder = (int) (aLong - (aIntMaxInLong * Integer.MAX_VALUE)); + return new Pair(aIntMaxInLong, aRemainder); + } + + /** + * Returns the smaller of two {@code Number}s. That is, + * the result the argument closer to the value of + * {@link Long#MIN_VALUE}. If the arguments have the same + * value, the result is that same value. + * + * @param a an argument. + * @param b another argument. + * @return the smaller of {@code a} and {@code b}. + */ + public static Number min(Number a, Number b) { + return (a.longValue() <= b.longValue()) ? a : b; + } + + /** + * Returns the greater of two {@code Number}s. That is, the + * result is the argument closer to the value of + * {@link Long#MAX_VALUE}. If the arguments have the same value, + * the result is that same value. + * + * @param a an argument. + * @param b another argument. + * @return the larger of {@code a} and {@code b}. + */ + public static Number max(Number a, Number b) { + return (a.longValue() >= b.longValue()) ? a : b; + } + + public static long combineTwoIntegersToLong(int a, int b) { + long val = (((long) a) << 32) | (b & 0xffffffffL); + return val; + } + + public static int[] splitLongIntoTwoIntegers(long aNum) { + int a = (int) (aNum >> 32); + int b = (int) aNum; + return new int[] {a, b}; + } + + public static String formatNumbers(long aNumber) { + return sNumberFormat.format(aNumber); + } + + public static String formatNumbers(double aNumber) { + return sNumberFormat.format(aNumber); + } } diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/ClientUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/ClientUtils.java index 806f83d830..ce14c07489 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/ClientUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/ClientUtils.java @@ -7,12 +7,11 @@ import gtPlusPlus.core.lib.CORE; public class ClientUtils { - static { - if (FMLCommonHandler.instance().getSide() == Side.SERVER) { - Logger.ERROR("Something tried to access the ClientUtils class from the Server Side."); - Logger.ERROR("Soft crashing to prevent data corruption."); - CORE.crash(); - } - } - + static { + if (FMLCommonHandler.instance().getSide() == Side.SERVER) { + Logger.ERROR("Something tried to access the ClientUtils class from the Server Side."); + Logger.ERROR("Soft crashing to prevent data corruption."); + CORE.crash(); + } + } } diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/EnchantingUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/EnchantingUtils.java index 2f273d5f7f..3871d11941 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/EnchantingUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/EnchantingUtils.java @@ -6,97 +6,84 @@ import net.minecraftforge.fluids.FluidStack; public class EnchantingUtils { - - public static final int XP_PER_BOTTLE = 8; - public static final int RATIO = 20; - public static final int LIQUID_PER_XP_BOTTLE = 160; - public static final double RATIO_MOB_ESSENCE_TO_LIQUID_XP = 13.32; - - public static int liquidToXpRatio(final int liquid) { - return liquid / RATIO; - } - - public static int xpToLiquidRatio(final int xp) { - return xp * RATIO; - } - - public static FluidStack getEssenceFromLiquidXp(final int xpAmount){ - if (xpAmount <= 0){ - return null; - } - return getMobEssence((int) (xpAmount*RATIO_MOB_ESSENCE_TO_LIQUID_XP)); - } - - public static FluidStack getLiquidXpFromEssence(final int essenceAmount){ - if (essenceAmount <= 0){ - return null; - } - return getLiquidXP((int) (essenceAmount/RATIO_MOB_ESSENCE_TO_LIQUID_XP)); - } - - public static int getLiquidForLevel(final int level) { - final int xp = getExperienceForLevel(level); - return xpToLiquidRatio(xp); - } - - public static int getLevelForLiquid(final int liquid) { - final int xp = liquidToXpRatio(liquid); - return getLevelForExperience(xp); - } - - public static int getExperienceForLevel(final int level) { - if (level == 0) { - return 0; - } - if ((level > 0) && (level < 16)) { - return level * 17; - } - if ((level > 15) && (level < 31)) { - return (int) (((1.5 * Math.pow(level, 2.0)) - (29.5 * level)) + 360.0); - } - return (int) (((3.5 * Math.pow(level, 2.0)) - (151.5 * level)) + 2220.0); - } - - public static int getXpToNextLevel(final int level) { - final int levelXP = getLevelForExperience(level); - final int nextXP = getExperienceForLevel(level + 1); - return nextXP - levelXP; - } - - public static int getLevelForExperience(final int experience) { - int i; - for (i = 0; getExperienceForLevel(i) <= experience; ++i) { - } - return i - 1; - } - - - - - - - - //Xp Fluids - public static FluidStack getMobEssence(final int amount){ - Logger.WARNING("Trying to get a fluid stack of Mob Essence."); - try { - return FluidRegistry.getFluidStack("mobessence", amount).copy(); - } - catch (final Throwable e){ - return null; - } - - } - - public static FluidStack getLiquidXP(final int amount){ - Logger.WARNING("Trying to get a fluid stack of Liquid XP."); - try { - return FluidRegistry.getFluidStack("xpjuice", amount).copy(); - } - catch (final Throwable e){ - return null; - } - - } - + public static final int XP_PER_BOTTLE = 8; + public static final int RATIO = 20; + public static final int LIQUID_PER_XP_BOTTLE = 160; + public static final double RATIO_MOB_ESSENCE_TO_LIQUID_XP = 13.32; + + public static int liquidToXpRatio(final int liquid) { + return liquid / RATIO; + } + + public static int xpToLiquidRatio(final int xp) { + return xp * RATIO; + } + + public static FluidStack getEssenceFromLiquidXp(final int xpAmount) { + if (xpAmount <= 0) { + return null; + } + return getMobEssence((int) (xpAmount * RATIO_MOB_ESSENCE_TO_LIQUID_XP)); + } + + public static FluidStack getLiquidXpFromEssence(final int essenceAmount) { + if (essenceAmount <= 0) { + return null; + } + return getLiquidXP((int) (essenceAmount / RATIO_MOB_ESSENCE_TO_LIQUID_XP)); + } + + public static int getLiquidForLevel(final int level) { + final int xp = getExperienceForLevel(level); + return xpToLiquidRatio(xp); + } + + public static int getLevelForLiquid(final int liquid) { + final int xp = liquidToXpRatio(liquid); + return getLevelForExperience(xp); + } + + public static int getExperienceForLevel(final int level) { + if (level == 0) { + return 0; + } + if ((level > 0) && (level < 16)) { + return level * 17; + } + if ((level > 15) && (level < 31)) { + return (int) (((1.5 * Math.pow(level, 2.0)) - (29.5 * level)) + 360.0); + } + return (int) (((3.5 * Math.pow(level, 2.0)) - (151.5 * level)) + 2220.0); + } + + public static int getXpToNextLevel(final int level) { + final int levelXP = getLevelForExperience(level); + final int nextXP = getExperienceForLevel(level + 1); + return nextXP - levelXP; + } + + public static int getLevelForExperience(final int experience) { + int i; + for (i = 0; getExperienceForLevel(i) <= experience; ++i) {} + return i - 1; + } + + // Xp Fluids + public static FluidStack getMobEssence(final int amount) { + Logger.WARNING("Trying to get a fluid stack of Mob Essence."); + try { + return FluidRegistry.getFluidStack("mobessence", amount).copy(); + } catch (final Throwable e) { + return null; + } + } + + public static FluidStack getLiquidXP(final int amount) { + Logger.WARNING("Trying to get a fluid stack of Liquid XP."); + try { + return FluidRegistry.getFluidStack("xpjuice", amount).copy(); + } catch (final Throwable e) { + return null; + } + } } diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/EnergyUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/EnergyUtils.java index 8b02ea9c7c..207faeefce 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/EnergyUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/EnergyUtils.java @@ -9,126 +9,115 @@ import net.minecraft.item.ItemStack; public class EnergyUtils { - public static class EU { - - public static boolean isElectricItem(ItemStack aStack) { - if (aStack == null || aStack.getItem() == null || aStack.getItem() instanceof ItemRedstone) { - return false; - } - if (aStack.getItem() instanceof ISpecialElectricItem) { - return true; - } - else if (aStack.getItem() instanceof IElectricItem) { - return true; - } - else if (aStack.getItem() instanceof IElectricItemManager) { - return true; - } - else { - return GT_ModHandler.isElectricItem(aStack); - } - } - - public static boolean isChargerItem(ItemStack aStack) { - return GT_ModHandler.isChargerItem(aStack); - } - - public static boolean charge(ItemStack aStack, int aEnergyToInsert, int aTier) { - return 0 != GT_ModHandler.chargeElectricItem(aStack, aEnergyToInsert, aTier, true, false); - } - - public static boolean discharge(ItemStack aStack, int aEnergyToDrain, int aTier) { - if (isElectricItem(aStack)) { - int tTier = ((IElectricItem) aStack.getItem()).getTier(aStack); - int aDischargeValue = GT_ModHandler.dischargeElectricItem(aStack, aEnergyToDrain, tTier, true, false, false); - //Logger.INFO("Trying to drain "+aDischargeValue); - return aDischargeValue > 0; - } - else { - return false; - } - } - - public static long getMaxStorage(ItemStack aStack) { - if (isElectricItem(aStack)) { - if (aStack.getItem() instanceof ISpecialElectricItem) { - ISpecialElectricItem bStack = (ISpecialElectricItem) aStack.getItem(); - return (long) bStack.getMaxCharge(aStack); - } - if (aStack.getItem() instanceof IElectricItem) { - IElectricItem bStack = (IElectricItem) aStack.getItem(); - return (long) bStack.getMaxCharge(aStack); - } - if (aStack.getItem() instanceof IElectricItemManager) { - IElectricItemManager bStack = (IElectricItemManager) aStack.getItem(); - return (long) bStack.getCharge(aStack); - } - } - else { - return 0; - } - return 0; - } - - public static long getCharge(ItemStack aStack) { - if (isElectricItem(aStack)) { - if (aStack.getItem() instanceof ISpecialElectricItem) { - ISpecialElectricItem bStack = (ISpecialElectricItem) aStack.getItem(); - return (long) bStack.getManager(aStack).getCharge(aStack); - } - if (aStack.getItem() instanceof IElectricItemManager) { - IElectricItemManager bStack = (IElectricItemManager) aStack.getItem(); - return (long) bStack.getCharge(aStack); - } - } - else { - return 0; - } - return 0; - } - - public static boolean hasCharge(ItemStack aStack) { - if (isElectricItem(aStack)) { - if (aStack.getItem() instanceof ISpecialElectricItem) { - ISpecialElectricItem bStack = (ISpecialElectricItem) aStack.getItem(); - return bStack.canProvideEnergy(aStack); - } - if (aStack.getItem() instanceof IElectricItem) { - IElectricItem bStack = (IElectricItem) aStack.getItem(); - return bStack.canProvideEnergy(aStack); - } - if (aStack.getItem() instanceof IElectricItemManager) { - IElectricItemManager bStack = (IElectricItemManager) aStack.getItem(); - return bStack.getCharge(aStack) > 0; - } - } - else { - return false; - } - return false; - } - - public static int getTier(ItemStack aStack) { - if (isElectricItem(aStack)) { - if (aStack.getItem() instanceof ISpecialElectricItem) { - ISpecialElectricItem bStack = (ISpecialElectricItem) aStack.getItem(); - return bStack.getTier(aStack); - } - if (aStack.getItem() instanceof IElectricItem) { - IElectricItem bStack = (IElectricItem) aStack.getItem(); - return bStack.getTier(aStack); - } - } - else { - return 0; - } - return 0; - } - - } - - public static class RF { - - } - + public static class EU { + + public static boolean isElectricItem(ItemStack aStack) { + if (aStack == null || aStack.getItem() == null || aStack.getItem() instanceof ItemRedstone) { + return false; + } + if (aStack.getItem() instanceof ISpecialElectricItem) { + return true; + } else if (aStack.getItem() instanceof IElectricItem) { + return true; + } else if (aStack.getItem() instanceof IElectricItemManager) { + return true; + } else { + return GT_ModHandler.isElectricItem(aStack); + } + } + + public static boolean isChargerItem(ItemStack aStack) { + return GT_ModHandler.isChargerItem(aStack); + } + + public static boolean charge(ItemStack aStack, int aEnergyToInsert, int aTier) { + return 0 != GT_ModHandler.chargeElectricItem(aStack, aEnergyToInsert, aTier, true, false); + } + + public static boolean discharge(ItemStack aStack, int aEnergyToDrain, int aTier) { + if (isElectricItem(aStack)) { + int tTier = ((IElectricItem) aStack.getItem()).getTier(aStack); + int aDischargeValue = + GT_ModHandler.dischargeElectricItem(aStack, aEnergyToDrain, tTier, true, false, false); + // Logger.INFO("Trying to drain "+aDischargeValue); + return aDischargeValue > 0; + } else { + return false; + } + } + + public static long getMaxStorage(ItemStack aStack) { + if (isElectricItem(aStack)) { + if (aStack.getItem() instanceof ISpecialElectricItem) { + ISpecialElectricItem bStack = (ISpecialElectricItem) aStack.getItem(); + return (long) bStack.getMaxCharge(aStack); + } + if (aStack.getItem() instanceof IElectricItem) { + IElectricItem bStack = (IElectricItem) aStack.getItem(); + return (long) bStack.getMaxCharge(aStack); + } + if (aStack.getItem() instanceof IElectricItemManager) { + IElectricItemManager bStack = (IElectricItemManager) aStack.getItem(); + return (long) bStack.getCharge(aStack); + } + } else { + return 0; + } + return 0; + } + + public static long getCharge(ItemStack aStack) { + if (isElectricItem(aStack)) { + if (aStack.getItem() instanceof ISpecialElectricItem) { + ISpecialElectricItem bStack = (ISpecialElectricItem) aStack.getItem(); + return (long) bStack.getManager(aStack).getCharge(aStack); + } + if (aStack.getItem() instanceof IElectricItemManager) { + IElectricItemManager bStack = (IElectricItemManager) aStack.getItem(); + return (long) bStack.getCharge(aStack); + } + } else { + return 0; + } + return 0; + } + + public static boolean hasCharge(ItemStack aStack) { + if (isElectricItem(aStack)) { + if (aStack.getItem() instanceof ISpecialElectricItem) { + ISpecialElectricItem bStack = (ISpecialElectricItem) aStack.getItem(); + return bStack.canProvideEnergy(aStack); + } + if (aStack.getItem() instanceof IElectricItem) { + IElectricItem bStack = (IElectricItem) aStack.getItem(); + return bStack.canProvideEnergy(aStack); + } + if (aStack.getItem() instanceof IElectricItemManager) { + IElectricItemManager bStack = (IElectricItemManager) aStack.getItem(); + return bStack.getCharge(aStack) > 0; + } + } else { + return false; + } + return false; + } + + public static int getTier(ItemStack aStack) { + if (isElectricItem(aStack)) { + if (aStack.getItem() instanceof ISpecialElectricItem) { + ISpecialElectricItem bStack = (ISpecialElectricItem) aStack.getItem(); + return bStack.getTier(aStack); + } + if (aStack.getItem() instanceof IElectricItem) { + IElectricItem bStack = (IElectricItem) aStack.getItem(); + return bStack.getTier(aStack); + } + } else { + return 0; + } + return 0; + } + } + + public static class RF {} } diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/EntityUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/EntityUtils.java index fda7b0b738..9c6fab90cd 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/EntityUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/EntityUtils.java @@ -1,11 +1,5 @@ package gtPlusPlus.core.util.minecraft; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.List; -import java.util.Map; - import cpw.mods.fml.common.registry.EntityRegistry; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.data.AutoMap; @@ -15,6 +9,11 @@ import gtPlusPlus.core.handler.events.EntityDeathHandler; import gtPlusPlus.core.util.reflect.ReflectionUtils; import ic2.core.IC2Potion; import ic2.core.item.armor.ItemArmorHazmat; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.List; +import java.util.Map; import net.minecraft.block.Block; import net.minecraft.entity.*; import net.minecraft.entity.player.EntityPlayer; @@ -28,93 +27,99 @@ import net.minecraft.world.biome.BiomeGenBase; public class EntityUtils { - public static void setEntityOnFire(final Entity aEntity, final int length){ - if (!isEntityImmuneToFire(aEntity)) { - aEntity.setFire(length); - } - } - - public static boolean isEntityOnFire(final Entity aEntity) { - Field aIsOnFire = ReflectionUtils.getField(Entity.class, "fire"); - if (aIsOnFire != null) { - int aFireTime = (int) ReflectionUtils.getFieldValue(aIsOnFire, aEntity); - return aFireTime > 0; - } - return false; - } - - public static boolean isEntityImmuneToFire(Entity aEntity) { - return aEntity.isImmuneToFire(); - } + public static void setEntityOnFire(final Entity aEntity, final int length) { + if (!isEntityImmuneToFire(aEntity)) { + aEntity.setFire(length); + } + } - public static int getFacingDirection(final Entity entity){ - final int d = MathHelper.floor_double((entity.rotationYaw * 4.0F) / 360 + 0.50) & 3; - return d; - } + public static boolean isEntityOnFire(final Entity aEntity) { + Field aIsOnFire = ReflectionUtils.getField(Entity.class, "fire"); + if (aIsOnFire != null) { + int aFireTime = (int) ReflectionUtils.getFieldValue(aIsOnFire, aEntity); + return aFireTime > 0; + } + return false; + } - @Deprecated - public static Block findBlockUnderEntityNonBoundingBox(final Entity parEntity){ - final int blockX = MathHelper.floor_double(parEntity.posX); - final int blockY = MathHelper.floor_double(parEntity.posY-0.2D - parEntity.yOffset); - final int blockZ = MathHelper.floor_double(parEntity.posZ); - return parEntity.worldObj.getBlock(blockX, blockY, blockZ); - } + public static boolean isEntityImmuneToFire(Entity aEntity) { + return aEntity.isImmuneToFire(); + } - public static Block findBlockUnderEntity(final Entity parEntity){ - final int blockX = MathHelper.floor_double(parEntity.posX); - final int blockY = MathHelper.floor_double(parEntity.boundingBox.minY)-1; - final int blockZ = MathHelper.floor_double(parEntity.posZ); - return parEntity.worldObj.getBlock(blockX, blockY, blockZ); - } + public static int getFacingDirection(final Entity entity) { + final int d = MathHelper.floor_double((entity.rotationYaw * 4.0F) / 360 + 0.50) & 3; + return d; + } - public static BlockPos findBlockPosUnderEntity(final Entity parEntity){ - final int blockX = MathHelper.floor_double(parEntity.posX); - final int blockY = MathHelper.floor_double(parEntity.boundingBox.minY)-1; - final int blockZ = MathHelper.floor_double(parEntity.posZ); - return new BlockPos(blockX, blockY, blockZ, parEntity.worldObj); - } - - public static BlockPos findBlockPosOfEntity(final Entity parEntity){ - final int blockX = MathHelper.floor_double(parEntity.posX); - final int blockY = MathHelper.floor_double(parEntity.boundingBox.minY); - final int blockZ = MathHelper.floor_double(parEntity.posZ); - return new BlockPos(blockX, blockY, blockZ, parEntity.worldObj); - } + @Deprecated + public static Block findBlockUnderEntityNonBoundingBox(final Entity parEntity) { + final int blockX = MathHelper.floor_double(parEntity.posX); + final int blockY = MathHelper.floor_double(parEntity.posY - 0.2D - parEntity.yOffset); + final int blockZ = MathHelper.floor_double(parEntity.posZ); + return parEntity.worldObj.getBlock(blockX, blockY, blockZ); + } - //TODO - public static void registerEntityToBiomeSpawns(final Class classy, final EnumCreatureType EntityType, final BiomeGenBase baseBiomeGen){ - EntityRegistry.addSpawn(classy, 6, 1, 5, EntityType, baseBiomeGen); //change the values to vary the spawn rarity, biome, etc. - } + public static Block findBlockUnderEntity(final Entity parEntity) { + final int blockX = MathHelper.floor_double(parEntity.posX); + final int blockY = MathHelper.floor_double(parEntity.boundingBox.minY) - 1; + final int blockZ = MathHelper.floor_double(parEntity.posZ); + return parEntity.worldObj.getBlock(blockX, blockY, blockZ); + } + + public static BlockPos findBlockPosUnderEntity(final Entity parEntity) { + final int blockX = MathHelper.floor_double(parEntity.posX); + final int blockY = MathHelper.floor_double(parEntity.boundingBox.minY) - 1; + final int blockZ = MathHelper.floor_double(parEntity.posZ); + return new BlockPos(blockX, blockY, blockZ, parEntity.worldObj); + } + + public static BlockPos findBlockPosOfEntity(final Entity parEntity) { + final int blockX = MathHelper.floor_double(parEntity.posX); + final int blockY = MathHelper.floor_double(parEntity.boundingBox.minY); + final int blockZ = MathHelper.floor_double(parEntity.posZ); + return new BlockPos(blockX, blockY, blockZ, parEntity.worldObj); + } + + // TODO + public static void registerEntityToBiomeSpawns( + final Class classy, final EnumCreatureType EntityType, final BiomeGenBase baseBiomeGen) { + EntityRegistry.addSpawn( + classy, 6, 1, 5, EntityType, baseBiomeGen); // change the values to vary the spawn rarity, biome, etc. + } + + public static boolean applyRadiationDamageToEntity( + final int stackSize, final int radiationLevel, final World world, final Entity entityHolding) { + if (!world.isRemote) { + if ((radiationLevel > 0) && (entityHolding instanceof EntityLivingBase)) { + final EntityLivingBase entityLiving = (EntityLivingBase) entityHolding; + if (!((EntityPlayer) entityHolding).capabilities.isCreativeMode) { + if (!ItemArmorHazmat.hasCompleteHazmat(entityLiving) + && !GT_Utility.isWearingFullRadioHazmat(entityLiving)) { + int duration; + if (entityLiving.getActivePotionEffect(IC2Potion.radiation) != null) { + // Utils.LOG_INFO("t"); + duration = (radiationLevel * 5) + + entityLiving + .getActivePotionEffect(IC2Potion.radiation) + .getDuration(); + } else { + // Utils.LOG_INFO("f"); + duration = radiationLevel * 30; + } + // IC2Potion.radiation.applyTo(entityLiving, duration, damage * 15); + applyRadioactivity(entityLiving, radiationLevel, stackSize); + } + } + } + return true; + } + return false; + } - public static boolean applyRadiationDamageToEntity(final int stackSize, final int radiationLevel, final World world, final Entity entityHolding){ - if (!world.isRemote){ - if ((radiationLevel > 0) && (entityHolding instanceof EntityLivingBase)) { - final EntityLivingBase entityLiving = (EntityLivingBase) entityHolding; - if (!((EntityPlayer) entityHolding).capabilities.isCreativeMode){ - if (!ItemArmorHazmat.hasCompleteHazmat(entityLiving) && !GT_Utility.isWearingFullRadioHazmat(entityLiving)) { - int duration; - if (entityLiving.getActivePotionEffect(IC2Potion.radiation) != null){ - //Utils.LOG_INFO("t"); - duration = (radiationLevel*5)+entityLiving.getActivePotionEffect(IC2Potion.radiation).getDuration(); - } - else { - //Utils.LOG_INFO("f"); - duration = radiationLevel*30; - } - //IC2Potion.radiation.applyTo(entityLiving, duration, damage * 15); - applyRadioactivity(entityLiving, radiationLevel, stackSize); - } - } - } - return true; - } - return false; - } - public static boolean isWearingFullFrostHazmat(EntityLivingBase aEntity) { for (byte i = 1; i < 5; i++) if (!HazmatUtils.providesProtetion_Frost(aEntity.getEquipmentInSlot(i))) { - return false; + return false; } return true; } @@ -122,7 +127,7 @@ public class EntityUtils { public static boolean isWearingFullHeatHazmat(EntityLivingBase aEntity) { for (byte i = 1; i < 5; i++) if (!HazmatUtils.providesProtetion_Fire(aEntity.getEquipmentInSlot(i))) { - return false; + return false; } return true; } @@ -130,7 +135,7 @@ public class EntityUtils { public static boolean isWearingFullBioHazmat(EntityLivingBase aEntity) { for (byte i = 1; i < 5; i++) if (!HazmatUtils.providesProtetion_Biohazard(aEntity.getEquipmentInSlot(i))) { - return false; + return false; } return true; } @@ -138,7 +143,7 @@ public class EntityUtils { public static boolean isWearingFullRadioHazmat(EntityLivingBase aEntity) { for (byte i = 1; i < 5; i++) if (!HazmatUtils.providesProtetion_Radiation(aEntity.getEquipmentInSlot(i))) { - return false; + return false; } return true; } @@ -146,7 +151,7 @@ public class EntityUtils { public static boolean isWearingFullElectroHazmat(EntityLivingBase aEntity) { for (byte i = 1; i < 5; i++) if (!HazmatUtils.providesProtetion_Electricity(aEntity.getEquipmentInSlot(i))) { - return false; + return false; } return true; } @@ -154,137 +159,186 @@ public class EntityUtils { public static boolean isWearingFullGasHazmat(EntityLivingBase aEntity) { for (byte i = 1; i < 5; i++) if (!HazmatUtils.providesProtetion_Gas(aEntity.getEquipmentInSlot(i))) { - return false; + return false; } return true; } - + public static boolean applyRadioactivity(EntityLivingBase aEntity, int aLevel, int aAmountOfItems) { - if (aLevel > 0 && aEntity != null && aEntity.getCreatureAttribute() != EnumCreatureAttribute.UNDEAD && aEntity.getCreatureAttribute() != EnumCreatureAttribute.ARTHROPOD && !ItemArmorHazmat.hasCompleteHazmat(aEntity)) { + if (aLevel > 0 + && aEntity != null + && aEntity.getCreatureAttribute() != EnumCreatureAttribute.UNDEAD + && aEntity.getCreatureAttribute() != EnumCreatureAttribute.ARTHROPOD + && !ItemArmorHazmat.hasCompleteHazmat(aEntity)) { PotionEffect tEffect = null; - aEntity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, aLevel * 140 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.moveSlowdown)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7))); - aEntity.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, aLevel * 150 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.digSlowdown)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7))); - aEntity.addPotionEffect(new PotionEffect(Potion.confusion.id, aLevel * 130 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.confusion)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7))); - aEntity.addPotionEffect(new PotionEffect(Potion.weakness.id, aLevel * 150 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.weakness)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7))); - aEntity.addPotionEffect(new PotionEffect(Potion.hunger.id, aLevel * 130 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.hunger)) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7))); - aEntity.addPotionEffect(new PotionEffect(IC2Potion.radiation.id, aLevel * 180 * aAmountOfItems + Math.max(0, ((tEffect = aEntity.getActivePotionEffect(Potion.potionTypes[24])) == null ? 0 : tEffect.getDuration())), Math.max(0, (5 * aLevel) / 7))); + aEntity.addPotionEffect(new PotionEffect( + Potion.moveSlowdown.id, + aLevel * 140 * aAmountOfItems + + Math.max( + 0, + ((tEffect = aEntity.getActivePotionEffect(Potion.moveSlowdown)) == null + ? 0 + : tEffect.getDuration())), + Math.max(0, (5 * aLevel) / 7))); + aEntity.addPotionEffect(new PotionEffect( + Potion.digSlowdown.id, + aLevel * 150 * aAmountOfItems + + Math.max( + 0, + ((tEffect = aEntity.getActivePotionEffect(Potion.digSlowdown)) == null + ? 0 + : tEffect.getDuration())), + Math.max(0, (5 * aLevel) / 7))); + aEntity.addPotionEffect(new PotionEffect( + Potion.confusion.id, + aLevel * 130 * aAmountOfItems + + Math.max( + 0, + ((tEffect = aEntity.getActivePotionEffect(Potion.confusion)) == null + ? 0 + : tEffect.getDuration())), + Math.max(0, (5 * aLevel) / 7))); + aEntity.addPotionEffect(new PotionEffect( + Potion.weakness.id, + aLevel * 150 * aAmountOfItems + + Math.max( + 0, + ((tEffect = aEntity.getActivePotionEffect(Potion.weakness)) == null + ? 0 + : tEffect.getDuration())), + Math.max(0, (5 * aLevel) / 7))); + aEntity.addPotionEffect(new PotionEffect( + Potion.hunger.id, + aLevel * 130 * aAmountOfItems + + Math.max( + 0, + ((tEffect = aEntity.getActivePotionEffect(Potion.hunger)) == null + ? 0 + : tEffect.getDuration())), + Math.max(0, (5 * aLevel) / 7))); + aEntity.addPotionEffect(new PotionEffect( + IC2Potion.radiation.id, + aLevel * 180 * aAmountOfItems + + Math.max( + 0, + ((tEffect = aEntity.getActivePotionEffect(Potion.potionTypes[24])) == null + ? 0 + : tEffect.getDuration())), + Math.max(0, (5 * aLevel) / 7))); return true; } return false; } - public static boolean applyHeatDamageToEntity(final int heatLevel, final World world, final Entity entityHolding){ - if (!world.isRemote){ - if ((heatLevel > 0) && (entityHolding instanceof EntityLivingBase)) { - final EntityLivingBase entityLiving = (EntityLivingBase) entityHolding; - if (!((EntityPlayer) entityHolding).capabilities.isCreativeMode){ - if (!GT_Utility.isWearingFullHeatHazmat(entityLiving)) { - return GT_Utility.applyHeatDamage(entityLiving, heatLevel); - } - } - } - } - return false; - } + public static boolean applyHeatDamageToEntity(final int heatLevel, final World world, final Entity entityHolding) { + if (!world.isRemote) { + if ((heatLevel > 0) && (entityHolding instanceof EntityLivingBase)) { + final EntityLivingBase entityLiving = (EntityLivingBase) entityHolding; + if (!((EntityPlayer) entityHolding).capabilities.isCreativeMode) { + if (!GT_Utility.isWearingFullHeatHazmat(entityLiving)) { + return GT_Utility.applyHeatDamage(entityLiving, heatLevel); + } + } + } + } + return false; + } + /** + * Static Version of the method used in {@code doFireDamage(entity, int)} to save memory. + */ + private static volatile Method dealFireDamage = null; - /** - * Static Version of the method used in {@code doFireDamage(entity, int)} to save memory. - */ - private volatile static Method dealFireDamage = null; + /** + * Reflective Call to do Fire Damage to an entity (Does not set entity on fire though) + */ + public static synchronized boolean doFireDamage(Entity entity, int amount) { + if (dealFireDamage == null) { + dealFireDamage = ReflectionUtils.getMethod(Entity.class, "dealFireDamage", int.class); + } else { + try { + dealFireDamage.invoke(entity, amount); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + } + } + return false; + } - /** - * Reflective Call to do Fire Damage to an entity (Does not set entity on fire though) - */ - public synchronized static boolean doFireDamage(Entity entity, int amount){ - if (dealFireDamage == null){ - dealFireDamage = ReflectionUtils.getMethod(Entity.class, "dealFireDamage", int.class); - } - else { - try { - dealFireDamage.invoke(entity, amount); - } - catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {} - } - return false; - } + public static void doDamage(Entity entity, DamageSource dmg, int i) { + entity.attackEntityFrom(dmg, i); + } - public static void doDamage(Entity entity, DamageSource dmg, int i) { - entity.attackEntityFrom(dmg, i); - } + public static boolean isTileEntityRegistered(Class aTileClass, String aTileName) { + Field aRegistry = ReflectionUtils.getField( + ReflectionUtils.getClass("net.minecraft.tileentity.TileEntity"), "nameToClassMap"); + Field aRegistry2 = ReflectionUtils.getField( + ReflectionUtils.getClass("net.minecraft.tileentity.TileEntity"), "classToNameMap"); + try { + Object o = aRegistry.get(null); + if (o != null) { + Map nameToClassMap = (Map) o; + if (!nameToClassMap.containsKey(aTileName)) { + o = aRegistry2.get(null); + if (o != null) { + Map classToNameMap = (Map) o; + if (!classToNameMap.containsKey(aTileClass)) { + return false; + } else { + return true; + } + } + } else { + return true; + } + } + } catch (IllegalArgumentException | IllegalAccessException e) { + e.printStackTrace(); + } + return false; + } - public static boolean isTileEntityRegistered(Class aTileClass, String aTileName) { - Field aRegistry = ReflectionUtils.getField(ReflectionUtils.getClass("net.minecraft.tileentity.TileEntity"), "nameToClassMap"); - Field aRegistry2 = ReflectionUtils.getField(ReflectionUtils.getClass("net.minecraft.tileentity.TileEntity"), "classToNameMap"); - try { - Object o = aRegistry.get(null); - if (o != null) { - Map nameToClassMap = (Map) o; - if (!nameToClassMap.containsKey(aTileName)) { - o = aRegistry2.get(null); - if (o != null) { - Map classToNameMap = (Map) o; - if (!classToNameMap.containsKey(aTileClass)) { - return false; - } - else { - return true; - } - } - } - else { - return true; - } - } - } catch (IllegalArgumentException | IllegalAccessException e) { - e.printStackTrace(); - } - return false; - } + public static double getDistance(Entity p1, Entity p2) { + return Math.sqrt( + Math.pow(p1.posX - p2.posX, 2) + Math.pow(p1.posY - p2.posY, 2) + Math.pow(p1.posZ - p2.posZ, 2)); + } - public static double getDistance(Entity p1, Entity p2) { - return Math.sqrt( Math.pow(p1.posX - p2.posX, 2) + Math.pow(p1.posY - p2.posY, 2) + Math.pow(p1.posZ - p2.posZ, 2)); - } + public static AutoMap getEntitiesWithinBoundingBoxExcluding(Entity aExclusion, AABB aBoundingBox) { + if (aExclusion == null) { + return new AutoMap(); + } else { + List aEntities = + aBoundingBox.world().getEntitiesWithinAABBExcludingEntity(aExclusion, aBoundingBox.get()); + return new AutoMap(aEntities); + } + } - public static AutoMap getEntitiesWithinBoundingBoxExcluding(Entity aExclusion, AABB aBoundingBox){ - if (aExclusion == null) { - return new AutoMap(); - } - else { - List aEntities = aBoundingBox.world().getEntitiesWithinAABBExcludingEntity(aExclusion, aBoundingBox.get()); - return new AutoMap(aEntities); - } - } + public static AutoMap getEntitiesWithinBoundingBox(Class aEntityType, AABB aBoundingBox) { + if (aEntityType == null) { + return new AutoMap(); + } else { + List aEntities = aBoundingBox.world().getEntitiesWithinAABB(aEntityType, aBoundingBox.get()); + return new AutoMap(aEntities); + } + } - public static AutoMap getEntitiesWithinBoundingBox(Class aEntityType, AABB aBoundingBox){ - if (aEntityType == null) { - return new AutoMap(); - } - else { - List aEntities = aBoundingBox.world().getEntitiesWithinAABB(aEntityType, aBoundingBox.get()); - return new AutoMap(aEntities); - } - } - - /** - * Provides the ability to provide custom drops upon the death of EntityLivingBase objects. Simplified function with static Max drop size of 1. - * @param aMobClass - The Base Class you want to drop this item. - * @param aStack - The ItemStack, stack size is not respected. - * @param aChance - Chance out of 10000, where 100 is 1%. (1 = 0.01% - this is ok) - */ - public static void registerDropsForMob(Class aMobClass, ItemStack aStack, int aChance) { - registerDropsForMob(aMobClass, aStack, 1, aChance); - } - - /** - * Provides the ability to provide custom drops upon the death of EntityLivingBase objects. - * @param aMobClass - The Base Class you want to drop this item. - * @param aStack - The ItemStack, stack size is not respected. - * @param aMaxAmount - The maximum size of the ItemStack which drops. - * @param aChance - Chance out of 10000, where 100 is 1%. (1 = 0.01% - this is ok) - */ - public static void registerDropsForMob(Class aMobClass, ItemStack aStack, int aMaxAmount, int aChance) { - EntityDeathHandler.registerDropsForMob(aMobClass, aStack, aMaxAmount, aChance); - } + /** + * Provides the ability to provide custom drops upon the death of EntityLivingBase objects. Simplified function with static Max drop size of 1. + * @param aMobClass - The Base Class you want to drop this item. + * @param aStack - The ItemStack, stack size is not respected. + * @param aChance - Chance out of 10000, where 100 is 1%. (1 = 0.01% - this is ok) + */ + public static void registerDropsForMob(Class aMobClass, ItemStack aStack, int aChance) { + registerDropsForMob(aMobClass, aStack, 1, aChance); + } + /** + * Provides the ability to provide custom drops upon the death of EntityLivingBase objects. + * @param aMobClass - The Base Class you want to drop this item. + * @param aStack - The ItemStack, stack size is not respected. + * @param aMaxAmount - The maximum size of the ItemStack which drops. + * @param aChance - Chance out of 10000, where 100 is 1%. (1 = 0.01% - this is ok) + */ + public static void registerDropsForMob(Class aMobClass, ItemStack aStack, int aMaxAmount, int aChance) { + EntityDeathHandler.registerDropsForMob(aMobClass, aStack, aMaxAmount, aChance); + } } diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/FluidUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/FluidUtils.java index fe190fa107..2125eff0e5 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/FluidUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/FluidUtils.java @@ -1,7 +1,5 @@ package gtPlusPlus.core.util.minecraft; -import java.util.HashMap; - import gregtech.api.enums.Dyes; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; @@ -16,6 +14,7 @@ import gtPlusPlus.core.material.MaterialStack; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; +import java.util.HashMap; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -26,643 +25,810 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidContainerItem; public class FluidUtils { - - private static HashMap sFluidCache = new HashMap(); - - public static FluidStack getWater(final int amount){ - return FluidUtils.getFluidStack("water", amount); - } - - public static FluidStack getDistilledWater(final int amount){ - return FluidUtils.getFluidStack("ic2distilledwater", amount); - } - - public static FluidStack getHotWater(final int amount) { - return FluidUtils.getFluidStack("ic2hotwater", amount); - } - - public static FluidStack getLava(final int amount){ - return FluidUtils.getFluidStack("lava", amount); - } - - public static FluidStack getPahoehoeLava(final int amount){ - return FluidUtils.getFluidStack("ic2pahoehoelava", amount); - } - - public static FluidStack getMilk(final int amount){ - return FluidUtils.getFluidStack("milk", amount); - } - - public static FluidStack getColdCoolant(final int amount){ - return FluidUtils.getFluidStack("ic2coolant", amount); - } - - public static FluidStack getHotCoolant(final int amount){ - return FluidUtils.getFluidStack("ic2hotcoolant", amount); - } - - public static FluidStack getSteam(final int amount){ - return FluidUtils.getFluidStack("steam", amount); - } - - public static FluidStack getIC2Steam(final int amount){ - return FluidUtils.getFluidStack("ic2steam", amount); - } - - public static FluidStack getSuperHeatedSteam(final int amount){ - return FluidUtils.getFluidStack("ic2superheatedsteam", amount); - } - - @Deprecated - /** - * Do not use - Gives third tier steam - Not implemented - * @param amount - * @return - */ - public static FluidStack getHyperSteam(final int amount){ - return FluidUtils.getFluidStack("water", amount); - } - - public static FluidStack getUUA(final int amount){ - return FluidUtils.getFluidStack("uuamplifier", amount); - } - - public static FluidStack getUUM(final int amount){ - return FluidUtils.getFluidStack("ic2uumatter", amount); - } - - public static FluidStack getHydrofluoricAcid(int amount) { - return FluidUtils.getFluidStack("hydrofluoricacid", amount); - } - - public static Fluid sGregtechHydrofluoricAcid = null; - - public static FluidStack getHydrofluoricAcidGT(int amount) { - if (sGregtechHydrofluoricAcid == null) { - FluidStack aGTHF = FluidUtils.getFluidStack("hydrofluoricacid_gt5u", 1); - sGregtechHydrofluoricAcid = aGTHF != null ? aGTHF.getFluid() : getHydrofluoricAcid(1).getFluid(); - } - return FluidUtils.getFluidStack(sGregtechHydrofluoricAcid, amount); - } - - public static boolean doesHydrofluoricAcidGtExist() { - if (sGregtechHydrofluoricAcid == null) { - getHydrofluoricAcidGT(1); - } - return sGregtechHydrofluoricAcid != null && sGregtechHydrofluoricAcid != getHydrofluoricAcid(1).getFluid(); - } - - private static FluidStack createFluidStack(Fluid aFluid, int aAmount) { - if (aFluid != null) { - return new FluidStack(aFluid, aAmount); - } - return null; - } - - public static FluidStack getFluidStack(final String aFluidName, final int aAmount){ - Fluid aFluid = sFluidCache.get(aFluidName); - if (aFluid != null) { - return createFluidStack(aFluid, aAmount); - } - else { - Fluid aLookupFluid = FluidRegistry.getFluid(aFluidName); - if (aLookupFluid != null) { - sFluidCache.put(aFluidName, aLookupFluid); - return createFluidStack(aLookupFluid, aAmount); - } - } - return null; - } - - public static FluidStack getFluidStack(final FluidStack aFluidStack, final int aAmount) { - if (aFluidStack == null) { - return null; - } - return new FluidStack(aFluidStack, aAmount); - } - - public static FluidStack getFluidStack(final Fluid aFluid, final int aAmount) { - if (aFluid == null) { - return null; - } - return new FluidStack(aFluid, aAmount); - } - - public static FluidStack[] getFluidStackArray(final String fluidName, final int amount){ - Logger.WARNING("Trying to get a fluid stack of "+fluidName); - try { - final FluidStack[] singleFluid = {getFluidStack(fluidName, amount)}; - return singleFluid; - } - catch (final Throwable e){ - return null; - } - - } - - public static FluidStack[] getFluidStackArray(final FluidStack fluidName, final int amount){ - Logger.WARNING("Trying to get a fluid stack of "+fluidName); - try { - final FluidStack[] singleFluid = {getFluidStack(fluidName, amount)}; - return singleFluid; - } - catch (final Throwable e){ - return null; - } - - } - - public static Fluid addGtFluid(final String aName, final String aLocalized, final GT_Materials aMaterial, final int aState, final long aTemperatureK, final ItemStack aFullContainer, final ItemStack aEmptyContainer, final int aFluidAmount) { - return addGtFluid(aName, aLocalized, aMaterial, aState, aTemperatureK, aFullContainer, aEmptyContainer, aFluidAmount, true); - } - - - public static Fluid addGtFluid(final String aName, final String aLocalized, final GT_Materials aMaterial, final int aState, final long aTemperatureK, final ItemStack aFullContainer, final ItemStack aEmptyContainer, final int aFluidAmount, final boolean aGenerateCell) { - Fluid g = addGTFluid(aName, "fluid.autogenerated", aLocalized, aMaterial != null ? aMaterial.mRGBa : new short[]{255, 255, 255, 0}, aState, aTemperatureK, aFullContainer, aEmptyContainer, aFluidAmount, aGenerateCell); - if (g != null) { - if (aMaterial != null) { - switch (aState) { - case 1: { - aMaterial.mFluid = (g); - break; - } - case 2: { - aMaterial.mGas = (g); - break; - } - case 3: { - aMaterial.mPlasma = (g); - break; - } - } - } - return g; - } - return null; - } - - public static Fluid addGTFluid(final String aName, final String aLocalized, final short[] aRGBa, final int aState, final long aTemperatureK, final ItemStack aFullContainer, final ItemStack aEmptyContainer, final int aFluidAmount, final boolean aGenerateCell) { - return addGTFluid("molten."+aName, "molten.autogenerated", aLocalized, aRGBa, aState, aTemperatureK, aFullContainer, aEmptyContainer, aFluidAmount, aGenerateCell); - } - - public static Fluid addGTFluidNonMolten(final String aName, final String aLocalized, final short[] aRGBa, final int aState, final long aTemperatureK, final ItemStack aFullContainer, final ItemStack aEmptyContainer, final int aFluidAmount, final boolean aGenerateCell) { - return addGTFluid("fluid."+aName, "fluid.autogenerated", aLocalized, aRGBa, aState, aTemperatureK, aFullContainer, aEmptyContainer, aFluidAmount, aGenerateCell); - } - - public static Fluid addGTFluidNoPrefix(final String aName, final String aLocalized, final short[] aRGBa, final int aState, final long aTemperatureK, final ItemStack aFullContainer, final ItemStack aEmptyContainer, final int aFluidAmount, final boolean aGenerateCell) { - return addGTFluid(aName, "fluid.autogenerated", aLocalized, aRGBa, aState, aTemperatureK, aFullContainer, aEmptyContainer, aFluidAmount, aGenerateCell); - } - //Gass - public static Fluid addGtGas(final String aName, final String aLocalized, final short[] aRGBa, final int aState, final long aTemperatureK, final ItemStack aFullContainer, final ItemStack aEmptyContainer, final int aFluidAmount, final boolean aGenerateCell) { - return addGTFluid(aName, "fluid.autogenerated", aLocalized, aRGBa, aState, aTemperatureK, aFullContainer, aEmptyContainer, aFluidAmount, aGenerateCell); - } - - public static Fluid addGTPlasma(final Material aMaterial) { - if (aMaterial.getLocalizedName().toLowerCase().contains("clay") || (aMaterial.getComposites().size()>1) || aMaterial.getLocalizedName().toLowerCase().contains("wrought")){ - return null; - } - Logger.INFO("Generating a "+aMaterial.getLocalizedName()+" Plasma Cell"); - if (aMaterial.vComponentCount != 1){ - Logger.INFO("Compound made from: "); - for (final MaterialStack x : aMaterial.getComposites()){ - Logger.INFO(x.getStackMaterial().getLocalizedName()); - } - Logger.INFO("Material is a composite, not generating plasma."); - return null; - } - - ItemStack temp = null; - //Generate a Cell if we need to - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cellPlasma"+aMaterial.getUnlocalizedName(), 1) == null){ - new BaseItemPlasmaCell(aMaterial); - temp = aMaterial.getPlasmaCell(1); - } - else { - temp = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cellPlasma"+aMaterial.getUnlocalizedName(), 1); - } - if (temp != null){ - return addGTFluid( - "plasma." + Utils.sanitizeString(aMaterial.getLocalizedName().toLowerCase()), - "plasma.autogenerated", - aMaterial.getLocalizedName() + " Plasma", - aMaterial.getRGBA(), - 3, - 10000, - temp, - ItemUtils.getEmptyCell(), - 1000, - false); - } - return null; - } - - public static Fluid addGTFluid(String aName, final String aTexture, final String aLocalized, final short[] aRGBa, final int aState, final long aTemperatureK, ItemStack aFullContainer, final ItemStack aEmptyContainer, final int aFluidAmount, final boolean aGenerateFilledCell) { - - String aNameOriginal = aName; - Logger.INFO("Generating Fluid for "+aName); - - aName = Utils.sanitizeString(aName.toLowerCase()); - - String aLocalName = (aLocalized == null) ? aName : aLocalized; - - Fluid rFluid; - Fluid gFluid = FluidRegistry.getFluid(aName); - FluidStack aCheck = FluidUtils.getWildcardFluidStack(aName.toLowerCase(), 1000); - boolean register = false; - if (aCheck != null) { - rFluid = aCheck.getFluid(); - } - else if (gFluid != null) { - rFluid = gFluid; - } - else { - rFluid = new FluidGT6(aName, aTexture, (aRGBa != null) ? aRGBa : Dyes._NULL.getRGBA()); - register = true; - - } - - if (register) { - GT_LanguageManager.addStringLocalization(rFluid.getUnlocalizedName(), aLocalName); - if (FluidRegistry.registerFluid(rFluid)) { - switch (aState) { - case 0: { - rFluid.setGaseous(false); - rFluid.setViscosity(10000); - break; - } - case 1: - case 4: { - rFluid.setGaseous(false); - rFluid.setViscosity(1000); - break; - } - case 2: { - rFluid.setGaseous(true); - rFluid.setDensity(-100); - rFluid.setViscosity(200); - break; - } - case 3: { - rFluid.setGaseous(true); - rFluid.setDensity(-10000); - rFluid.setViscosity(10); - rFluid.setLuminosity(15); - break; - } - } - } - } - - - String aNameNonMolten = aLocalName.contains("Molten") ? aLocalName.replace("Molten", "") : aLocalName; - - if (aFullContainer == null) { - ItemStack oreStack = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+aLocalName, 1); - aFullContainer = oreStack; - if (aFullContainer == null) { - oreStack = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+aNameOriginal, 1); - aFullContainer = oreStack; - if (aFullContainer == null) { - oreStack = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+aNameNonMolten, 1); - aFullContainer = oreStack; - if (aFullContainer != null) { - Logger.INFO("Found cell for "+aNameNonMolten); - } - } - else { - Logger.INFO("Found cell for "+aNameOriginal); - } - } - else { - Logger.INFO("Found cell for "+aLocalName); - } - } - - Item tempCell = null; - //Generate a Cell if we need to - if (aGenerateFilledCell && aFullContainer == null) { - String aMatName = aNameOriginal; - if (aMatName.contains("molten.")) { - aMatName = aMatName.replace("molten.", ""); - aMatName = aMatName.substring(0, 1).toUpperCase() + aMatName.substring(1); - } - if (aMatName.contains("fluid.")) { - aMatName = aMatName.replace("fluid.", ""); - aMatName = aMatName.substring(0, 1).toUpperCase() + aMatName.substring(1); - } - Logger.INFO("Generating cell for "+aMatName+", "+aLocalName); - tempCell = new BaseItemComponent(aMatName, aLocalName, aRGBa); - aFullContainer = ItemUtils.getSimpleStack(tempCell); - } - - if ((rFluid.getTemperature() == new Fluid("test").getTemperature()) || (rFluid.getTemperature() <= 0)) { - rFluid.setTemperature((int) (aTemperatureK)); - } - if ((aFullContainer != null) && (aEmptyContainer != null) && !FluidContainerRegistry.registerFluidContainer(new FluidStack(rFluid, aFluidAmount), aFullContainer, aEmptyContainer)) { - CORE.RA.addFluidCannerRecipe(CI.emptyCells(1), aFullContainer, new FluidStack(rFluid, aFluidAmount)); - } - else { - //Utils.LOG_INFO("Failed creating recipes to fill/empty cells of "+aName+"."); - } - return rFluid; - } - - public static boolean valid(final Object aStack) { - return (aStack != null) && (aStack instanceof ItemStack) && (((ItemStack)aStack).getItem() != null) && (((ItemStack)aStack).stackSize >= 0); - } - - public static boolean invalid(final Object aStack) { - return (aStack == null) || !(aStack instanceof ItemStack) || (((ItemStack)aStack).getItem() == null) || (((ItemStack)aStack).stackSize < 0); - } - - public static boolean equal(final ItemStack aStack1, final ItemStack aStack2) { - return equal(aStack1, aStack2, false); - } - - public static boolean equal(final ItemStack aStack1, final ItemStack aStack2, final boolean aIgnoreNBT) { - return (aStack1 != null) && (aStack2 != null) && equal_(aStack1, aStack2, aIgnoreNBT); - } - - public static boolean equal_(final ItemStack aStack1, final ItemStack aStack2, final boolean aIgnoreNBT) { - return (aStack1.getItem() == aStack2.getItem()) && (aIgnoreNBT || ((aStack1.getTagCompound() == null == (aStack2.getTagCompound() == null)) && ((aStack1.getTagCompound() == null) || aStack1.getTagCompound().equals(aStack2.getTagCompound())))) && ((meta(aStack1) == meta(aStack2)) || (meta(aStack1) == 32767) || (meta(aStack2) == 32767)); - } - - public static ItemStack copy(final Object... aStacks) { - for (final Object tStack : aStacks) { - if (valid(tStack)) { - return ((ItemStack)tStack).copy(); - } - } - return null; - } - - public static ItemStack copyMeta(final long aMetaData, final Object... aStacks) { - final ItemStack rStack = copy(aStacks); - if (invalid(rStack)) { - return null; - } - return meta(rStack, aMetaData); - } - - public static short meta(final ItemStack aStack) { - return (short)Items.feather.getDamage(aStack); - } - - public static ItemStack meta(final ItemStack aStack, final long aMeta) { - Items.feather.setDamage(aStack, (short)aMeta); - return aStack; - } - - public static ItemStack amount(final long aAmount, final Object... aStacks) { - final ItemStack rStack = copy(aStacks); - if (invalid(rStack)) { - return null; - } - rStack.stackSize = (int)aAmount; - return rStack; - } - - public static ItemStack container(final ItemStack aStack, final boolean aCheckIFluidContainerItems) { - if (invalid(aStack)) { - return null; - } - if (aStack.getItem().hasContainerItem(aStack)) { - return aStack.getItem().getContainerItem(aStack); - } - if (equal(aStack, ItemUtils.getEmptyCell(), true)) { - return null; - } - if (aCheckIFluidContainerItems && (aStack.getItem() instanceof IFluidContainerItem) && (((IFluidContainerItem)aStack.getItem()).getCapacity(aStack) > 0)) { - final ItemStack tStack = amount(1L, aStack); - ((IFluidContainerItem)aStack.getItem()).drain(tStack, Integer.MAX_VALUE, true); - if (!equal(aStack, tStack)) { - return tStack; - } - return null; - } - if (equal(aStack, ItemList.IC2_ForgeHammer.get(1)) || equal(aStack, ItemList.IC2_WireCutter.get(1))) { - return copyMeta(meta(aStack) + 1, aStack); - } - return null; - } - - public static ItemStack container(final ItemStack aStack, final boolean aCheckIFluidContainerItems, final int aStacksize) { - return amount(aStacksize, container(aStack, aCheckIFluidContainerItems)); - } - - public final static Fluid generateFluid(final String unlocalizedName, final String localizedName, final int MeltingPoint, final short[] RGBA, boolean aGenerateCell){ - FluidStack aFStack = (FluidUtils.getFluidStack("molten"+"."+unlocalizedName.toLowerCase(), 1)); - if (aFStack == null){ - Logger.WARNING("Generating our own fluid."); -/* ItemStack cell = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+unlocalizedName, 1); - if (cell == null){ - final Item temp = new BaseItemComponent(unlocalizedName, localizedName, RGBA); - cell = ItemUtils.getSimpleStack(temp); - }*/ - final Fluid gtFluid = FluidUtils.addGTFluid( - unlocalizedName, - "Molten "+localizedName, - RGBA, - 4, - MeltingPoint, - null, - ItemUtils.getEmptyCell(), - 1000, - aGenerateCell); - - return gtFluid; - } - else { - Logger.INFO("FLUID GENERATION FAILED FOR "+localizedName+", ALREADY EXISTS"); - return aFStack.getFluid(); - } - } - - public final static Fluid generateFluidNonMolten(final String unlocalizedName, final String localizedName, final int MeltingPoint, final short[] RGBA, final boolean aGenerateCell){ - return generateFluidNonMolten(unlocalizedName, localizedName, MeltingPoint, RGBA, null, null, 0, aGenerateCell); - } - - - public final static Fluid generateFluidNonMolten(final String unlocalizedName, final String localizedName, final int MeltingPoint, final short[] RGBA, final ItemStack dustStack, final ItemStack dustStack2){ - return generateFluidNonMolten(unlocalizedName, localizedName, MeltingPoint, RGBA, dustStack, dustStack2, 144, true); - } - - public final static Fluid generateFluidNonMolten(final String unlocalizedName, final String localizedName, final int MeltingPoint, final short[] RGBA, final ItemStack dustStack, final ItemStack dustStack2, final boolean aGenerateCell){ - return generateFluidNonMolten(unlocalizedName, localizedName, MeltingPoint, RGBA, dustStack, dustStack2, 144, aGenerateCell); - } - - public final static Fluid generateFluidNonMolten(final String unlocalizedName, final String localizedName, final int MeltingPoint, final short[] RGBA, ItemStack dustStack, final ItemStack dustStack2, final int amountPerItem, final boolean aGenerateCell){ - if (dustStack == null){ - dustStack = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dust"+Utils.sanitizeString(localizedName), 1); - } - FluidStack aFStack = (FluidUtils.getFluidStack(unlocalizedName.toLowerCase(), 1)); - if (aFStack == null){ - Logger.WARNING("Generating our own fluid."); - - final Fluid gtFluid = FluidUtils.addGTFluidNonMolten( - unlocalizedName, - localizedName, - RGBA, - 4, - MeltingPoint, - null, - ItemUtils.getEmptyCell(), - 1000, - aGenerateCell); - - if (dustStack != null){ - CORE.RA.addFluidExtractionRecipe( - dustStack, //Input 2 - FluidUtils.getFluidStack(gtFluid, amountPerItem), //Fluid Output - 1*20, //Duration - 16 //Eu Tick - ); - } - if (dustStack2 != null){ - CORE.RA.addFluidExtractionRecipe( - dustStack2, //Input 2 - FluidUtils.getFluidStack(gtFluid, amountPerItem), //Fluid Output - 1*20, //Duration - 16 //Eu Tick - ); - } - - return gtFluid; - } - else { - Logger.INFO("FLUID GENERATION FAILED FOR "+localizedName+", ALREADY EXISTS"); - return aFStack.getFluid(); - } - } - - public final static Fluid generateFluidNoPrefix(final String unlocalizedName, final String localizedName, final int MeltingPoint, final short[] RGBA){ - return generateFluidNoPrefix(unlocalizedName, localizedName, MeltingPoint, RGBA, true); - } - - public final static Fluid generateFluidNoPrefix(final String unlocalizedName, final String localizedName, final int MeltingPoint, final short[] RGBA, final boolean aGenerateCell){ - Fluid gtFluid; - if (FluidUtils.getFluidStack(unlocalizedName.toLowerCase(), 1) == null){ - Logger.WARNING("Generating our own fluid."); - gtFluid = FluidUtils.addGTFluidNoPrefix( - unlocalizedName, - localizedName, - RGBA, - 4, - MeltingPoint, - null, - ItemUtils.getEmptyCell(), - 1000, - aGenerateCell); - } - else { - gtFluid = FluidUtils.getFluidStack(unlocalizedName.toLowerCase(), 1).getFluid(); - } - //Generate a Cell if we need to -// if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+unlocalizedName, 1) == null){ -// new BaseItemCell(unlocalizedName, localizedName, RGBA, gtFluid); -// } - return gtFluid; - } - - public final static Fluid generateGas(final String unlocalizedName, final String localizedName, final int MeltingPoint, final short[] RGBA, final boolean aGenerateCell){ - Fluid gtFluid; - if (FluidUtils.getFluidStack(unlocalizedName.toLowerCase(), 1) == null){ - Logger.WARNING("Generating our own gas."); - gtFluid = FluidUtils.addGtGas( - unlocalizedName, - localizedName, - RGBA, - 3, - MeltingPoint, - null, - ItemUtils.getEmptyCell(), - 1000, - aGenerateCell); - } - else { - gtFluid = FluidUtils.getFluidStack(unlocalizedName.toLowerCase(), 1).getFluid(); - } - //Generate a Cell if we need to -/* if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+unlocalizedName, 1) == null){ - new BaseItemCell(unlocalizedName, localizedName, RGBA, gtFluid); - }*/ - return gtFluid; - } - - - - - public static FluidStack getMobEssence(final int amount){ - return EnchantingUtils.getMobEssence(amount); - } - - public static FluidStack getLiquidXP(final int amount){ - return EnchantingUtils.getLiquidXP(amount); - } - - public static boolean doesFluidExist(String aFluidName) { - FluidStack aFStack1 = (FluidUtils.getFluidStack("molten"+"."+aFluidName.toLowerCase(), 1)); - FluidStack aFStack2 = (FluidUtils.getFluidStack("fluid"+"."+aFluidName.toLowerCase(), 1)); - FluidStack aFStack3 = (FluidUtils.getFluidStack(aFluidName.toLowerCase(), 1)); - FluidStack aFStack4 = (FluidUtils.getFluidStack(aFluidName, 1)); - FluidStack aFStack5 = (FluidUtils.getFluidStack("liquid_"+aFluidName.toLowerCase(), 1)); - FluidStack aFStack6 = (FluidUtils.getFluidStack("liquid"+"."+aFluidName.toLowerCase(), 1)); - return aFStack1 != null || aFStack2 != null || aFStack3 != null || aFStack4 != null || aFStack5 != null || aFStack6 != null; - } - - public static FluidStack getWildcardFluidStack(String aFluidName, int amount) { - FluidStack aFStack1 = (FluidUtils.getFluidStack(aFluidName, amount)); - FluidStack aFStack2 = (FluidUtils.getFluidStack(aFluidName.toLowerCase(), amount)); - FluidStack aFStack3 = (FluidUtils.getFluidStack("molten"+"."+aFluidName.toLowerCase(), amount)); - FluidStack aFStack4 = (FluidUtils.getFluidStack("fluid"+"."+aFluidName.toLowerCase(), amount)); - FluidStack aFStack5 = (FluidUtils.getFluidStack("liquid_"+aFluidName.toLowerCase(), amount)); - FluidStack aFStack6 = (FluidUtils.getFluidStack("liquid"+"."+aFluidName.toLowerCase(), amount)); - if (aFStack1 != null) { - return aFStack1; - } - if (aFStack2 != null) { - return aFStack2; - } - if (aFStack3 != null) { - return aFStack3; - } - if (aFStack4 != null) { - return aFStack4; - } - if (aFStack5 != null) { - return aFStack5; - } - if (aFStack6 != null) { - return aFStack6; - } - return null; - } - - public static FluidStack getWildcardFluidStack(Materials aMaterial, int amount) { - FluidStack aFStack1 = aMaterial.getFluid(amount); - FluidStack aFStack2 = aMaterial.getGas(amount); - FluidStack aFStack3 = aMaterial.getMolten(amount); - FluidStack aFStack4 = aMaterial.getSolid(amount); - if (aFStack1 != null) { - return aFStack1; - } - else if (aFStack2 != null) { - return aFStack2; - } - else if (aFStack3 != null) { - return aFStack3; - } - else if (aFStack4 != null) { - return aFStack4; - } - else { - return null; - } - } - - public static FluidStack getAir(int aAmount) { - return FluidUtils.getFluidStack("air", aAmount); - } - + private static HashMap sFluidCache = new HashMap(); + + public static FluidStack getWater(final int amount) { + return FluidUtils.getFluidStack("water", amount); + } + + public static FluidStack getDistilledWater(final int amount) { + return FluidUtils.getFluidStack("ic2distilledwater", amount); + } + + public static FluidStack getHotWater(final int amount) { + return FluidUtils.getFluidStack("ic2hotwater", amount); + } + + public static FluidStack getLava(final int amount) { + return FluidUtils.getFluidStack("lava", amount); + } + + public static FluidStack getPahoehoeLava(final int amount) { + return FluidUtils.getFluidStack("ic2pahoehoelava", amount); + } + + public static FluidStack getMilk(final int amount) { + return FluidUtils.getFluidStack("milk", amount); + } + + public static FluidStack getColdCoolant(final int amount) { + return FluidUtils.getFluidStack("ic2coolant", amount); + } + + public static FluidStack getHotCoolant(final int amount) { + return FluidUtils.getFluidStack("ic2hotcoolant", amount); + } + + public static FluidStack getSteam(final int amount) { + return FluidUtils.getFluidStack("steam", amount); + } + + public static FluidStack getIC2Steam(final int amount) { + return FluidUtils.getFluidStack("ic2steam", amount); + } + + public static FluidStack getSuperHeatedSteam(final int amount) { + return FluidUtils.getFluidStack("ic2superheatedsteam", amount); + } + + @Deprecated + /** + * Do not use - Gives third tier steam - Not implemented + * @param amount + * @return + */ + public static FluidStack getHyperSteam(final int amount) { + return FluidUtils.getFluidStack("water", amount); + } + + public static FluidStack getUUA(final int amount) { + return FluidUtils.getFluidStack("uuamplifier", amount); + } + + public static FluidStack getUUM(final int amount) { + return FluidUtils.getFluidStack("ic2uumatter", amount); + } + + public static FluidStack getHydrofluoricAcid(int amount) { + return FluidUtils.getFluidStack("hydrofluoricacid", amount); + } + + public static Fluid sGregtechHydrofluoricAcid = null; + + public static FluidStack getHydrofluoricAcidGT(int amount) { + if (sGregtechHydrofluoricAcid == null) { + FluidStack aGTHF = FluidUtils.getFluidStack("hydrofluoricacid_gt5u", 1); + sGregtechHydrofluoricAcid = + aGTHF != null ? aGTHF.getFluid() : getHydrofluoricAcid(1).getFluid(); + } + return FluidUtils.getFluidStack(sGregtechHydrofluoricAcid, amount); + } + + public static boolean doesHydrofluoricAcidGtExist() { + if (sGregtechHydrofluoricAcid == null) { + getHydrofluoricAcidGT(1); + } + return sGregtechHydrofluoricAcid != null + && sGregtechHydrofluoricAcid != getHydrofluoricAcid(1).getFluid(); + } + + private static FluidStack createFluidStack(Fluid aFluid, int aAmount) { + if (aFluid != null) { + return new FluidStack(aFluid, aAmount); + } + return null; + } + + public static FluidStack getFluidStack(final String aFluidName, final int aAmount) { + Fluid aFluid = sFluidCache.get(aFluidName); + if (aFluid != null) { + return createFluidStack(aFluid, aAmount); + } else { + Fluid aLookupFluid = FluidRegistry.getFluid(aFluidName); + if (aLookupFluid != null) { + sFluidCache.put(aFluidName, aLookupFluid); + return createFluidStack(aLookupFluid, aAmount); + } + } + return null; + } + + public static FluidStack getFluidStack(final FluidStack aFluidStack, final int aAmount) { + if (aFluidStack == null) { + return null; + } + return new FluidStack(aFluidStack, aAmount); + } + + public static FluidStack getFluidStack(final Fluid aFluid, final int aAmount) { + if (aFluid == null) { + return null; + } + return new FluidStack(aFluid, aAmount); + } + + public static FluidStack[] getFluidStackArray(final String fluidName, final int amount) { + Logger.WARNING("Trying to get a fluid stack of " + fluidName); + try { + final FluidStack[] singleFluid = {getFluidStack(fluidName, amount)}; + return singleFluid; + } catch (final Throwable e) { + return null; + } + } + + public static FluidStack[] getFluidStackArray(final FluidStack fluidName, final int amount) { + Logger.WARNING("Trying to get a fluid stack of " + fluidName); + try { + final FluidStack[] singleFluid = {getFluidStack(fluidName, amount)}; + return singleFluid; + } catch (final Throwable e) { + return null; + } + } + + public static Fluid addGtFluid( + final String aName, + final String aLocalized, + final GT_Materials aMaterial, + final int aState, + final long aTemperatureK, + final ItemStack aFullContainer, + final ItemStack aEmptyContainer, + final int aFluidAmount) { + return addGtFluid( + aName, + aLocalized, + aMaterial, + aState, + aTemperatureK, + aFullContainer, + aEmptyContainer, + aFluidAmount, + true); + } + + public static Fluid addGtFluid( + final String aName, + final String aLocalized, + final GT_Materials aMaterial, + final int aState, + final long aTemperatureK, + final ItemStack aFullContainer, + final ItemStack aEmptyContainer, + final int aFluidAmount, + final boolean aGenerateCell) { + Fluid g = addGTFluid( + aName, + "fluid.autogenerated", + aLocalized, + aMaterial != null ? aMaterial.mRGBa : new short[] {255, 255, 255, 0}, + aState, + aTemperatureK, + aFullContainer, + aEmptyContainer, + aFluidAmount, + aGenerateCell); + if (g != null) { + if (aMaterial != null) { + switch (aState) { + case 1: { + aMaterial.mFluid = (g); + break; + } + case 2: { + aMaterial.mGas = (g); + break; + } + case 3: { + aMaterial.mPlasma = (g); + break; + } + } + } + return g; + } + return null; + } + + public static Fluid addGTFluid( + final String aName, + final String aLocalized, + final short[] aRGBa, + final int aState, + final long aTemperatureK, + final ItemStack aFullContainer, + final ItemStack aEmptyContainer, + final int aFluidAmount, + final boolean aGenerateCell) { + return addGTFluid( + "molten." + aName, + "molten.autogenerated", + aLocalized, + aRGBa, + aState, + aTemperatureK, + aFullContainer, + aEmptyContainer, + aFluidAmount, + aGenerateCell); + } + + public static Fluid addGTFluidNonMolten( + final String aName, + final String aLocalized, + final short[] aRGBa, + final int aState, + final long aTemperatureK, + final ItemStack aFullContainer, + final ItemStack aEmptyContainer, + final int aFluidAmount, + final boolean aGenerateCell) { + return addGTFluid( + "fluid." + aName, + "fluid.autogenerated", + aLocalized, + aRGBa, + aState, + aTemperatureK, + aFullContainer, + aEmptyContainer, + aFluidAmount, + aGenerateCell); + } + + public static Fluid addGTFluidNoPrefix( + final String aName, + final String aLocalized, + final short[] aRGBa, + final int aState, + final long aTemperatureK, + final ItemStack aFullContainer, + final ItemStack aEmptyContainer, + final int aFluidAmount, + final boolean aGenerateCell) { + return addGTFluid( + aName, + "fluid.autogenerated", + aLocalized, + aRGBa, + aState, + aTemperatureK, + aFullContainer, + aEmptyContainer, + aFluidAmount, + aGenerateCell); + } + // Gass + public static Fluid addGtGas( + final String aName, + final String aLocalized, + final short[] aRGBa, + final int aState, + final long aTemperatureK, + final ItemStack aFullContainer, + final ItemStack aEmptyContainer, + final int aFluidAmount, + final boolean aGenerateCell) { + return addGTFluid( + aName, + "fluid.autogenerated", + aLocalized, + aRGBa, + aState, + aTemperatureK, + aFullContainer, + aEmptyContainer, + aFluidAmount, + aGenerateCell); + } + + public static Fluid addGTPlasma(final Material aMaterial) { + if (aMaterial.getLocalizedName().toLowerCase().contains("clay") + || (aMaterial.getComposites().size() > 1) + || aMaterial.getLocalizedName().toLowerCase().contains("wrought")) { + return null; + } + Logger.INFO("Generating a " + aMaterial.getLocalizedName() + " Plasma Cell"); + if (aMaterial.vComponentCount != 1) { + Logger.INFO("Compound made from: "); + for (final MaterialStack x : aMaterial.getComposites()) { + Logger.INFO(x.getStackMaterial().getLocalizedName()); + } + Logger.INFO("Material is a composite, not generating plasma."); + return null; + } + + ItemStack temp = null; + // Generate a Cell if we need to + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cellPlasma" + aMaterial.getUnlocalizedName(), 1) + == null) { + new BaseItemPlasmaCell(aMaterial); + temp = aMaterial.getPlasmaCell(1); + } else { + temp = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cellPlasma" + aMaterial.getUnlocalizedName(), 1); + } + if (temp != null) { + return addGTFluid( + "plasma." + + Utils.sanitizeString(aMaterial.getLocalizedName().toLowerCase()), + "plasma.autogenerated", + aMaterial.getLocalizedName() + " Plasma", + aMaterial.getRGBA(), + 3, + 10000, + temp, + ItemUtils.getEmptyCell(), + 1000, + false); + } + return null; + } + + public static Fluid addGTFluid( + String aName, + final String aTexture, + final String aLocalized, + final short[] aRGBa, + final int aState, + final long aTemperatureK, + ItemStack aFullContainer, + final ItemStack aEmptyContainer, + final int aFluidAmount, + final boolean aGenerateFilledCell) { + + String aNameOriginal = aName; + Logger.INFO("Generating Fluid for " + aName); + + aName = Utils.sanitizeString(aName.toLowerCase()); + + String aLocalName = (aLocalized == null) ? aName : aLocalized; + + Fluid rFluid; + Fluid gFluid = FluidRegistry.getFluid(aName); + FluidStack aCheck = FluidUtils.getWildcardFluidStack(aName.toLowerCase(), 1000); + boolean register = false; + if (aCheck != null) { + rFluid = aCheck.getFluid(); + } else if (gFluid != null) { + rFluid = gFluid; + } else { + rFluid = new FluidGT6(aName, aTexture, (aRGBa != null) ? aRGBa : Dyes._NULL.getRGBA()); + register = true; + } + + if (register) { + GT_LanguageManager.addStringLocalization(rFluid.getUnlocalizedName(), aLocalName); + if (FluidRegistry.registerFluid(rFluid)) { + switch (aState) { + case 0: { + rFluid.setGaseous(false); + rFluid.setViscosity(10000); + break; + } + case 1: + case 4: { + rFluid.setGaseous(false); + rFluid.setViscosity(1000); + break; + } + case 2: { + rFluid.setGaseous(true); + rFluid.setDensity(-100); + rFluid.setViscosity(200); + break; + } + case 3: { + rFluid.setGaseous(true); + rFluid.setDensity(-10000); + rFluid.setViscosity(10); + rFluid.setLuminosity(15); + break; + } + } + } + } + + String aNameNonMolten = aLocalName.contains("Molten") ? aLocalName.replace("Molten", "") : aLocalName; + + if (aFullContainer == null) { + ItemStack oreStack = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell" + aLocalName, 1); + aFullContainer = oreStack; + if (aFullContainer == null) { + oreStack = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell" + aNameOriginal, 1); + aFullContainer = oreStack; + if (aFullContainer == null) { + oreStack = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell" + aNameNonMolten, 1); + aFullContainer = oreStack; + if (aFullContainer != null) { + Logger.INFO("Found cell for " + aNameNonMolten); + } + } else { + Logger.INFO("Found cell for " + aNameOriginal); + } + } else { + Logger.INFO("Found cell for " + aLocalName); + } + } + + Item tempCell = null; + // Generate a Cell if we need to + if (aGenerateFilledCell && aFullContainer == null) { + String aMatName = aNameOriginal; + if (aMatName.contains("molten.")) { + aMatName = aMatName.replace("molten.", ""); + aMatName = aMatName.substring(0, 1).toUpperCase() + aMatName.substring(1); + } + if (aMatName.contains("fluid.")) { + aMatName = aMatName.replace("fluid.", ""); + aMatName = aMatName.substring(0, 1).toUpperCase() + aMatName.substring(1); + } + Logger.INFO("Generating cell for " + aMatName + ", " + aLocalName); + tempCell = new BaseItemComponent(aMatName, aLocalName, aRGBa); + aFullContainer = ItemUtils.getSimpleStack(tempCell); + } + + if ((rFluid.getTemperature() == new Fluid("test").getTemperature()) || (rFluid.getTemperature() <= 0)) { + rFluid.setTemperature((int) (aTemperatureK)); + } + if ((aFullContainer != null) + && (aEmptyContainer != null) + && !FluidContainerRegistry.registerFluidContainer( + new FluidStack(rFluid, aFluidAmount), aFullContainer, aEmptyContainer)) { + CORE.RA.addFluidCannerRecipe(CI.emptyCells(1), aFullContainer, new FluidStack(rFluid, aFluidAmount)); + } else { + // Utils.LOG_INFO("Failed creating recipes to fill/empty cells of "+aName+"."); + } + return rFluid; + } + + public static boolean valid(final Object aStack) { + return (aStack != null) + && (aStack instanceof ItemStack) + && (((ItemStack) aStack).getItem() != null) + && (((ItemStack) aStack).stackSize >= 0); + } + + public static boolean invalid(final Object aStack) { + return (aStack == null) + || !(aStack instanceof ItemStack) + || (((ItemStack) aStack).getItem() == null) + || (((ItemStack) aStack).stackSize < 0); + } + + public static boolean equal(final ItemStack aStack1, final ItemStack aStack2) { + return equal(aStack1, aStack2, false); + } + + public static boolean equal(final ItemStack aStack1, final ItemStack aStack2, final boolean aIgnoreNBT) { + return (aStack1 != null) && (aStack2 != null) && equal_(aStack1, aStack2, aIgnoreNBT); + } + + public static boolean equal_(final ItemStack aStack1, final ItemStack aStack2, final boolean aIgnoreNBT) { + return (aStack1.getItem() == aStack2.getItem()) + && (aIgnoreNBT + || ((aStack1.getTagCompound() == null == (aStack2.getTagCompound() == null)) + && ((aStack1.getTagCompound() == null) + || aStack1.getTagCompound().equals(aStack2.getTagCompound())))) + && ((meta(aStack1) == meta(aStack2)) || (meta(aStack1) == 32767) || (meta(aStack2) == 32767)); + } + + public static ItemStack copy(final Object... aStacks) { + for (final Object tStack : aStacks) { + if (valid(tStack)) { + return ((ItemStack) tStack).copy(); + } + } + return null; + } + + public static ItemStack copyMeta(final long aMetaData, final Object... aStacks) { + final ItemStack rStack = copy(aStacks); + if (invalid(rStack)) { + return null; + } + return meta(rStack, aMetaData); + } + + public static short meta(final ItemStack aStack) { + return (short) Items.feather.getDamage(aStack); + } + + public static ItemStack meta(final ItemStack aStack, final long aMeta) { + Items.feather.setDamage(aStack, (short) aMeta); + return aStack; + } + + public static ItemStack amount(final long aAmount, final Object... aStacks) { + final ItemStack rStack = copy(aStacks); + if (invalid(rStack)) { + return null; + } + rStack.stackSize = (int) aAmount; + return rStack; + } + + public static ItemStack container(final ItemStack aStack, final boolean aCheckIFluidContainerItems) { + if (invalid(aStack)) { + return null; + } + if (aStack.getItem().hasContainerItem(aStack)) { + return aStack.getItem().getContainerItem(aStack); + } + if (equal(aStack, ItemUtils.getEmptyCell(), true)) { + return null; + } + if (aCheckIFluidContainerItems + && (aStack.getItem() instanceof IFluidContainerItem) + && (((IFluidContainerItem) aStack.getItem()).getCapacity(aStack) > 0)) { + final ItemStack tStack = amount(1L, aStack); + ((IFluidContainerItem) aStack.getItem()).drain(tStack, Integer.MAX_VALUE, true); + if (!equal(aStack, tStack)) { + return tStack; + } + return null; + } + if (equal(aStack, ItemList.IC2_ForgeHammer.get(1)) || equal(aStack, ItemList.IC2_WireCutter.get(1))) { + return copyMeta(meta(aStack) + 1, aStack); + } + return null; + } + + public static ItemStack container( + final ItemStack aStack, final boolean aCheckIFluidContainerItems, final int aStacksize) { + return amount(aStacksize, container(aStack, aCheckIFluidContainerItems)); + } + + public static final Fluid generateFluid( + final String unlocalizedName, + final String localizedName, + final int MeltingPoint, + final short[] RGBA, + boolean aGenerateCell) { + FluidStack aFStack = (FluidUtils.getFluidStack("molten" + "." + unlocalizedName.toLowerCase(), 1)); + if (aFStack == null) { + Logger.WARNING("Generating our own fluid."); + /* ItemStack cell = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+unlocalizedName, 1); + if (cell == null){ + final Item temp = new BaseItemComponent(unlocalizedName, localizedName, RGBA); + cell = ItemUtils.getSimpleStack(temp); + }*/ + final Fluid gtFluid = FluidUtils.addGTFluid( + unlocalizedName, + "Molten " + localizedName, + RGBA, + 4, + MeltingPoint, + null, + ItemUtils.getEmptyCell(), + 1000, + aGenerateCell); + + return gtFluid; + } else { + Logger.INFO("FLUID GENERATION FAILED FOR " + localizedName + ", ALREADY EXISTS"); + return aFStack.getFluid(); + } + } + + public static final Fluid generateFluidNonMolten( + final String unlocalizedName, + final String localizedName, + final int MeltingPoint, + final short[] RGBA, + final boolean aGenerateCell) { + return generateFluidNonMolten(unlocalizedName, localizedName, MeltingPoint, RGBA, null, null, 0, aGenerateCell); + } + + public static final Fluid generateFluidNonMolten( + final String unlocalizedName, + final String localizedName, + final int MeltingPoint, + final short[] RGBA, + final ItemStack dustStack, + final ItemStack dustStack2) { + return generateFluidNonMolten( + unlocalizedName, localizedName, MeltingPoint, RGBA, dustStack, dustStack2, 144, true); + } + + public static final Fluid generateFluidNonMolten( + final String unlocalizedName, + final String localizedName, + final int MeltingPoint, + final short[] RGBA, + final ItemStack dustStack, + final ItemStack dustStack2, + final boolean aGenerateCell) { + return generateFluidNonMolten( + unlocalizedName, localizedName, MeltingPoint, RGBA, dustStack, dustStack2, 144, aGenerateCell); + } + + public static final Fluid generateFluidNonMolten( + final String unlocalizedName, + final String localizedName, + final int MeltingPoint, + final short[] RGBA, + ItemStack dustStack, + final ItemStack dustStack2, + final int amountPerItem, + final boolean aGenerateCell) { + if (dustStack == null) { + dustStack = + ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dust" + Utils.sanitizeString(localizedName), 1); + } + FluidStack aFStack = (FluidUtils.getFluidStack(unlocalizedName.toLowerCase(), 1)); + if (aFStack == null) { + Logger.WARNING("Generating our own fluid."); + + final Fluid gtFluid = FluidUtils.addGTFluidNonMolten( + unlocalizedName, + localizedName, + RGBA, + 4, + MeltingPoint, + null, + ItemUtils.getEmptyCell(), + 1000, + aGenerateCell); + + if (dustStack != null) { + CORE.RA.addFluidExtractionRecipe( + dustStack, // Input 2 + FluidUtils.getFluidStack(gtFluid, amountPerItem), // Fluid Output + 1 * 20, // Duration + 16 // Eu Tick + ); + } + if (dustStack2 != null) { + CORE.RA.addFluidExtractionRecipe( + dustStack2, // Input 2 + FluidUtils.getFluidStack(gtFluid, amountPerItem), // Fluid Output + 1 * 20, // Duration + 16 // Eu Tick + ); + } + + return gtFluid; + } else { + Logger.INFO("FLUID GENERATION FAILED FOR " + localizedName + ", ALREADY EXISTS"); + return aFStack.getFluid(); + } + } + + public static final Fluid generateFluidNoPrefix( + final String unlocalizedName, final String localizedName, final int MeltingPoint, final short[] RGBA) { + return generateFluidNoPrefix(unlocalizedName, localizedName, MeltingPoint, RGBA, true); + } + + public static final Fluid generateFluidNoPrefix( + final String unlocalizedName, + final String localizedName, + final int MeltingPoint, + final short[] RGBA, + final boolean aGenerateCell) { + Fluid gtFluid; + if (FluidUtils.getFluidStack(unlocalizedName.toLowerCase(), 1) == null) { + Logger.WARNING("Generating our own fluid."); + gtFluid = FluidUtils.addGTFluidNoPrefix( + unlocalizedName, + localizedName, + RGBA, + 4, + MeltingPoint, + null, + ItemUtils.getEmptyCell(), + 1000, + aGenerateCell); + } else { + gtFluid = FluidUtils.getFluidStack(unlocalizedName.toLowerCase(), 1).getFluid(); + } + // Generate a Cell if we need to + // if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+unlocalizedName, 1) == null){ + // new BaseItemCell(unlocalizedName, localizedName, RGBA, gtFluid); + // } + return gtFluid; + } + + public static final Fluid generateGas( + final String unlocalizedName, + final String localizedName, + final int MeltingPoint, + final short[] RGBA, + final boolean aGenerateCell) { + Fluid gtFluid; + if (FluidUtils.getFluidStack(unlocalizedName.toLowerCase(), 1) == null) { + Logger.WARNING("Generating our own gas."); + gtFluid = FluidUtils.addGtGas( + unlocalizedName, + localizedName, + RGBA, + 3, + MeltingPoint, + null, + ItemUtils.getEmptyCell(), + 1000, + aGenerateCell); + } else { + gtFluid = FluidUtils.getFluidStack(unlocalizedName.toLowerCase(), 1).getFluid(); + } + // Generate a Cell if we need to + /* if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+unlocalizedName, 1) == null){ + new BaseItemCell(unlocalizedName, localizedName, RGBA, gtFluid); + }*/ + return gtFluid; + } + + public static FluidStack getMobEssence(final int amount) { + return EnchantingUtils.getMobEssence(amount); + } + + public static FluidStack getLiquidXP(final int amount) { + return EnchantingUtils.getLiquidXP(amount); + } + + public static boolean doesFluidExist(String aFluidName) { + FluidStack aFStack1 = (FluidUtils.getFluidStack("molten" + "." + aFluidName.toLowerCase(), 1)); + FluidStack aFStack2 = (FluidUtils.getFluidStack("fluid" + "." + aFluidName.toLowerCase(), 1)); + FluidStack aFStack3 = (FluidUtils.getFluidStack(aFluidName.toLowerCase(), 1)); + FluidStack aFStack4 = (FluidUtils.getFluidStack(aFluidName, 1)); + FluidStack aFStack5 = (FluidUtils.getFluidStack("liquid_" + aFluidName.toLowerCase(), 1)); + FluidStack aFStack6 = (FluidUtils.getFluidStack("liquid" + "." + aFluidName.toLowerCase(), 1)); + return aFStack1 != null + || aFStack2 != null + || aFStack3 != null + || aFStack4 != null + || aFStack5 != null + || aFStack6 != null; + } + + public static FluidStack getWildcardFluidStack(String aFluidName, int amount) { + FluidStack aFStack1 = (FluidUtils.getFluidStack(aFluidName, amount)); + FluidStack aFStack2 = (FluidUtils.getFluidStack(aFluidName.toLowerCase(), amount)); + FluidStack aFStack3 = (FluidUtils.getFluidStack("molten" + "." + aFluidName.toLowerCase(), amount)); + FluidStack aFStack4 = (FluidUtils.getFluidStack("fluid" + "." + aFluidName.toLowerCase(), amount)); + FluidStack aFStack5 = (FluidUtils.getFluidStack("liquid_" + aFluidName.toLowerCase(), amount)); + FluidStack aFStack6 = (FluidUtils.getFluidStack("liquid" + "." + aFluidName.toLowerCase(), amount)); + if (aFStack1 != null) { + return aFStack1; + } + if (aFStack2 != null) { + return aFStack2; + } + if (aFStack3 != null) { + return aFStack3; + } + if (aFStack4 != null) { + return aFStack4; + } + if (aFStack5 != null) { + return aFStack5; + } + if (aFStack6 != null) { + return aFStack6; + } + return null; + } + + public static FluidStack getWildcardFluidStack(Materials aMaterial, int amount) { + FluidStack aFStack1 = aMaterial.getFluid(amount); + FluidStack aFStack2 = aMaterial.getGas(amount); + FluidStack aFStack3 = aMaterial.getMolten(amount); + FluidStack aFStack4 = aMaterial.getSolid(amount); + if (aFStack1 != null) { + return aFStack1; + } else if (aFStack2 != null) { + return aFStack2; + } else if (aFStack3 != null) { + return aFStack3; + } else if (aFStack4 != null) { + return aFStack4; + } else { + return null; + } + } + + public static FluidStack getAir(int aAmount) { + return FluidUtils.getFluidStack("air", aAmount); + } } diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/FoodUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/FoodUtils.java index 9f5d4f36ca..129548d1db 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/FoodUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/FoodUtils.java @@ -10,51 +10,51 @@ import net.minecraft.item.ItemStack; public class FoodUtils { - public static final Class IEdibleClass; - - static { - IEdibleClass = ReflectionUtils.getClass("squeek.applecore.api.food.IEdible"); - } - - public static boolean isFood(ItemStack food) { - - if (food == null) { - return false; - } - - Item item = food.getItem(); - - if(item == null) { - return false; - } - - EnumAction action = item.getItemUseAction(food); - - if(item instanceof ItemBlock || action == EnumAction.eat || action == EnumAction.drink) { - if(getUnmodifiedFoodValues(food) > 0) { - return true; - } - } - - return false; - } - - private static int getUnmodifiedFoodValues(ItemStack stack) { - - if (stack == null) { - return 0; - } - - Item item = stack.getItem(); - - if(item == null) { - return 0; - } - - if(IEdibleClass.isInstance(item) || item instanceof ItemFood || item == Items.cake) { - return 1; - } - - return 0; - } + public static final Class IEdibleClass; + + static { + IEdibleClass = ReflectionUtils.getClass("squeek.applecore.api.food.IEdible"); + } + + public static boolean isFood(ItemStack food) { + + if (food == null) { + return false; + } + + Item item = food.getItem(); + + if (item == null) { + return false; + } + + EnumAction action = item.getItemUseAction(food); + + if (item instanceof ItemBlock || action == EnumAction.eat || action == EnumAction.drink) { + if (getUnmodifiedFoodValues(food) > 0) { + return true; + } + } + + return false; + } + + private static int getUnmodifiedFoodValues(ItemStack stack) { + + if (stack == null) { + return 0; + } + + Item item = stack.getItem(); + + if (item == null) { + return 0; + } + + if (IEdibleClass.isInstance(item) || item instanceof ItemFood || item == Items.cake) { + return 1; + } + + return 0; + } } diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/HazmatUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/HazmatUtils.java index 0e2fff3f35..6c1442cb0d 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/HazmatUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/HazmatUtils.java @@ -2,10 +2,6 @@ package gtPlusPlus.core.util.minecraft; import static gregtech.api.GregTech_API.*; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.HashMap; - import cpw.mods.fml.common.eventhandler.SubscribeEvent; import gregtech.api.objects.GT_HashSet; import gregtech.api.objects.GT_ItemStack; @@ -21,6 +17,8 @@ import ic2.core.Ic2Items; import ic2.core.item.armor.ItemArmorHazmat; import ic2.core.item.armor.ItemArmorNanoSuit; import ic2.core.item.armor.ItemArmorQuantumSuit; +import java.lang.reflect.Field; +import java.util.HashMap; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -29,576 +27,567 @@ import net.minecraftforge.event.entity.player.ItemTooltipEvent; public class HazmatUtils { - public static final GT_HashSet sHazmatList = new GT_HashSet(); - - private static final HashMap> mToolTips = new HashMap>(); - - private static boolean mInit = false; - private static HazmatUtils mInstance; - - @SuppressWarnings("rawtypes") - public static void init() { - if (mInit) { - return; - } - //doInit(); Disabled, hazmat moved to gt5u - } - public static void doInit() { - - mInstance = new HazmatUtils(); - - sHazmatList.add(ItemUtils.getSimpleStack(Ic2Items.hazmatHelmet, 1)); - sHazmatList.add(ItemUtils.getSimpleStack(Ic2Items.hazmatChestplate, 1)); - sHazmatList.add(ItemUtils.getSimpleStack(Ic2Items.hazmatLeggings, 1)); - sHazmatList.add(ItemUtils.getSimpleStack(Ic2Items.hazmatBoots, 1)); - - // Make Nano a hazmat suit - // Make Quantum a hazmat suit - - - if (LoadedMods.IndustrialCraft2 || LoadedMods.IndustrialCraft2Classic) { - AutoMap aVanillaIC2Armour = new AutoMap(); - aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.nanoHelmet, 1)); - aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.nanoBodyarmor, 1)); - aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.nanoLeggings, 1)); - aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.nanoBoots, 1)); - aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.quantumHelmet, 1)); - aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.quantumBodyarmor, 1)); - aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.quantumLeggings, 1)); - aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.quantumBoots, 1)); - for (ItemStack aItem : aVanillaIC2Armour) { - addProtection(aItem); - } - Logger.INFO("[Hazmat] Registered IC2 Items as hazmat gear."); - } - - if (LoadedMods.isModLoaded("EMT")) { - AutoMap aItemFields = new AutoMap(); - Class aItemsEMT = ReflectionUtils.getClass("emt.init.EMTItems"); - aItemFields.add(ReflectionUtils.getField(aItemsEMT, "nanoThaumicHelmet")); - aItemFields.add(ReflectionUtils.getField(aItemsEMT, "nanoWing")); - aItemFields.add(ReflectionUtils.getField(aItemsEMT, "nanoBootsTraveller")); - aItemFields.add(ReflectionUtils.getField(aItemsEMT, "quantumThaumicHelmet")); - aItemFields.add(ReflectionUtils.getField(aItemsEMT, "quantumWing")); - aItemFields.add(ReflectionUtils.getField(aItemsEMT, "quantumArmor")); - aItemFields.add(ReflectionUtils.getField(aItemsEMT, "quantumBootsTraveller")); - AutoMap aEMT = new AutoMap(); - for (Field aItemField : aItemFields) { - Item aItemObject = null; - if (aItemField != null) { - try { - aItemObject = (Item) aItemField.get(null); - } - catch (Exception t) { - t.printStackTrace(); - } - } - if (aItemObject != null) { - aEMT.add(ItemUtils.getSimpleStack(aItemObject)); - } - else { - Logger.INFO("[Hazmat] Could not get "+aItemField.getName()+" from "+aItemsEMT.getName()); - } - } - Logger.INFO("[Hazmat] Registering "+aEMT.size()+" EMT Items as hazmat gear."); - for (ItemStack aItem : aEMT) { - addProtection(aItem); - } - Logger.INFO("[Hazmat] Registered EMT Items as hazmat gear."); - } - - if (LoadedMods.isModLoaded("DraconicEvolution")) { - AutoMap aItemFields = new AutoMap(); - Class aItemsDE = ReflectionUtils.getClass("com.brandon3055.draconicevolution.ModItems"); - - aItemFields.add(ReflectionUtils.getField(aItemsDE, "draconicHelm")); - aItemFields.add(ReflectionUtils.getField(aItemsDE, "draconicChest")); - aItemFields.add(ReflectionUtils.getField(aItemsDE, "draconicLeggs")); - aItemFields.add(ReflectionUtils.getField(aItemsDE, "draconicBoots")); - aItemFields.add(ReflectionUtils.getField(aItemsDE, "wyvernHelm")); - aItemFields.add(ReflectionUtils.getField(aItemsDE, "wyvernChest")); - aItemFields.add(ReflectionUtils.getField(aItemsDE, "wyvernLeggs")); - aItemFields.add(ReflectionUtils.getField(aItemsDE, "wyvernBoots")); - AutoMap aItemMap = new AutoMap(); - for (Field aItemField : aItemFields) { - Item aItemObject = null; - if (aItemField != null) { - try { - aItemObject = (Item) aItemField.get(null); - } - catch (Exception t) { - t.printStackTrace(); - } - } - if (aItemObject != null) { - aItemMap.add(ItemUtils.getSimpleStack(aItemObject)); - } - else { - Logger.INFO("[Hazmat] Could not get "+aItemField.getName()+" from "+aItemsDE.getName()); - } - } - Logger.INFO("[Hazmat] Registering "+aItemMap.size()+" Draconic Evolution Items as hazmat gear."); - for (ItemStack aItem : aItemMap) { - addProtection(aItem); - } - Logger.INFO("[Hazmat] Registered Draconic Evolution Items as hazmat gear."); - } - - if (LoadedMods.isModLoaded("TaintedMagic")) { - AutoMap aItemFields = new AutoMap(); - Class aItemsTaintedMagic = ReflectionUtils.getClass("taintedmagic.common.registry.ItemRegistry"); - - aItemFields.add(ReflectionUtils.getField(aItemsTaintedMagic, "ItemShadowFortressHelmet")); - aItemFields.add(ReflectionUtils.getField(aItemsTaintedMagic, "ItemShadowFortressChestplate")); - aItemFields.add(ReflectionUtils.getField(aItemsTaintedMagic, "ItemShadowFortressLeggings")); - aItemFields.add(ReflectionUtils.getField(aItemsTaintedMagic, "ItemVoidwalkerBoots")); - AutoMap aItemMap = new AutoMap(); - for (Field aItemField : aItemFields) { - Item aItemObject = null; - if (aItemField != null) { - try { - aItemObject = (Item) aItemField.get(null); - } - catch (Exception t) { - t.printStackTrace(); - } - } - if (aItemObject != null) { - aItemMap.add(ItemUtils.getSimpleStack(aItemObject)); - } - else { - Logger.INFO("[Hazmat] Could not get "+aItemField.getName()+" from "+aItemsTaintedMagic.getName()); - } - } - Logger.INFO("[Hazmat] Registering "+aItemMap.size()+" Tainted Magic Items as hazmat gear."); - for (ItemStack aItem : aItemMap) { - addProtection(aItem); - } - Logger.INFO("[Hazmat] Registered Tainted Magic Items as hazmat gear."); - } - - if (LoadedMods.isModLoaded("WitchingGadgets")) { - AutoMap aItemFields = new AutoMap(); - Class aItemsTaintedMagic = ReflectionUtils.getClass("witchinggadgets.common.WGContent"); - - aItemFields.add(ReflectionUtils.getField(aItemsTaintedMagic, "ItemPrimordialHelm")); - aItemFields.add(ReflectionUtils.getField(aItemsTaintedMagic, "ItemPrimordialChest")); - aItemFields.add(ReflectionUtils.getField(aItemsTaintedMagic, "ItemPrimordialLegs")); - aItemFields.add(ReflectionUtils.getField(aItemsTaintedMagic, "ItemPrimordialBoots")); - AutoMap aItemMap = new AutoMap(); - for (Field aItemField : aItemFields) { - Item aItemObject = null; - if (aItemField != null) { - try { - aItemObject = (Item) aItemField.get(null); - } - catch (Exception t) { - t.printStackTrace(); - } - } - if (aItemObject != null) { - aItemMap.add(ItemUtils.getSimpleStack(aItemObject)); - } - else { - Logger.INFO("[Hazmat] Could not get "+aItemField.getName()+" from "+aItemsTaintedMagic.getName()); - } - } - Logger.INFO("[Hazmat] Registering "+aItemMap.size()+" Witching Gadgets Items as hazmat gear."); - for (ItemStack aItem : aItemMap) { - addProtection(aItem); - } - Logger.INFO("[Hazmat] Registered Witching Gadgets Items as hazmat gear."); - } - - if (LoadedMods.isModLoaded("ThaumicTinkerer")) { - /* - AutoMap aItems = new AutoMap(); - Class aMainTT = ReflectionUtils.getClass("thaumic.tinkerer.common.ThaumicTinkerer"); - Class aItemRegistryTT = ReflectionUtils.getClass("thaumic.tinkerer.common.registry.TTRegistry"); - Field aRegistryInstance = ReflectionUtils.getField(aMainTT, "registry"); - Object aRegistry = ReflectionUtils.getFieldValue(aRegistryInstance); - Method aFuckingStupidMethodHandlingMethod = ReflectionUtils.getMethod(aItemRegistryTT, "getFirstItemFromClass", new Class[] {Class.class}); - Item aIchorHelm = (Item) ReflectionUtils.invokeNonBool(aRegistry, aFuckingStupidMethodHandlingMethod, new Object[] {ReflectionUtils.getClass("thaumic.tinkerer.common.item.kami.armor.ItemGemHelm")}); - Item aIchorChest = (Item) ReflectionUtils.invokeNonBool(aRegistry, aFuckingStupidMethodHandlingMethod, new Object[] {ReflectionUtils.getClass("thaumic.tinkerer.common.item.kami.armor.ItemGemChest")}); - Item aIchorLegs = (Item) ReflectionUtils.invokeNonBool(aRegistry, aFuckingStupidMethodHandlingMethod, new Object[] {ReflectionUtils.getClass("thaumic.tinkerer.common.item.kami.armor.ItemGemLegs")}); - Item aIchorBoots = (Item) ReflectionUtils.invokeNonBool(aRegistry, aFuckingStupidMethodHandlingMethod, new Object[] {ReflectionUtils.getClass("thaumic.tinkerer.common.item.kami.armor.ItemGemBoots")}); - aItems.add(aIchorHelm); - aItems.add(aIchorChest); - aItems.add(aIchorLegs); - aItems.add(aIchorBoots); - AutoMap aItemMap = new AutoMap(); - int aIndex = 0; - for (Item aItem : aItems) { - Item aItemObject = null; - if (aItem != null) { - aItemMap.add(ItemUtils.getSimpleStack(aItemObject)); - } - else { - Logger.INFO("[Hazmat] Could not get item "+aIndex+" from "+aItemRegistryTT.getName()); - } - aIndex++; - } - Logger.INFO("[Hazmat] Registering "+aItemMap.size()+" Thaumic Tinkerer Items as hazmat gear."); - for (ItemStack aItem : aItemMap) { - addProtection(aItem); - } - Logger.INFO("[Hazmat] Registered Thaumic Tinkerer Items as hazmat gear."); - */ - Logger.INFO("[Hazmat] Did not register Thaumic Tinkerer Items as hazmat gear."); - } - - if (LoadedMods.isModLoaded("GraviSuite")) { - AutoMap aItemFields = new AutoMap(); - Class aItemsGravisuite = ReflectionUtils.getClass("gravisuite.GraviSuite"); - aItemFields.add(ReflectionUtils.getField(aItemsGravisuite, "advNanoChestPlate")); - aItemFields.add(ReflectionUtils.getField(aItemsGravisuite, "graviChestPlate")); - AutoMap aGravisuite = new AutoMap(); - for (Field aItemField : aItemFields) { - Item aItemObject = ReflectionUtils.getFieldValue(aItemField); - if (aItemObject != null) { - aGravisuite.add(ItemUtils.getSimpleStack(aItemObject)); - } - } - Logger.INFO("[Hazmat] Registering "+aGravisuite.size()+" Gravisuit Items as hazmat gear."); - for (ItemStack aItem : aGravisuite) { - addProtection(aItem); - } - Logger.INFO("[Hazmat] Registered Gravisuit Items as hazmat gear."); - } - - if (LoadedMods.isModLoaded("AdvancedSolarPanel")) { - AutoMap aItemFields = new AutoMap(); - Class aItemsEMT = ReflectionUtils.getClass("advsolar.common.AdvancedSolarPanel"); - aItemFields.add(ReflectionUtils.getField(aItemsEMT, "advancedSolarHelmet")); - aItemFields.add(ReflectionUtils.getField(aItemsEMT, "hybridSolarHelmet")); - aItemFields.add(ReflectionUtils.getField(aItemsEMT, "ultimateSolarHelmet")); - AutoMap aASP = new AutoMap(); - for (Field aItemField : aItemFields) { - Item aItemObject = ReflectionUtils.getFieldValue(aItemField); - if (aItemObject != null) { - aASP.add(ItemUtils.getSimpleStack(aItemObject)); - } - } - Logger.INFO("[Hazmat] Registering "+aASP.size()+" Adv. Solar Items as hazmat gear."); - for (ItemStack aItem : aASP) { - addProtection(aItem); - } - Logger.INFO("[Hazmat] Registered Adv. Solar Items as hazmat gear."); - } - - Utils.registerEvent(mInstance); - Logger.INFO("[Hazmat] Registered Tooltip handler for hazmat gear."); - mInit = true; - - } - - private final static String mToolTipText = "Provides protection from:"; - - @SubscribeEvent - public void onItemTooltip(ItemTooltipEvent event) { - //Logger.INFO("Ticking Hazmat handler"); - if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { - - if (event.itemStack == null || isVanillaHazmatPiece(event.itemStack)) { - //Logger.INFO("[Hazmat] Invalid Itemstack or vanilla hazmat"); - return; - } else { - ItemStack aStackTemp = event.itemStack; - GT_ItemStack aStack = new GT_ItemStack(aStackTemp); - if (isNanoArmourPiece(aStackTemp) || isQuantumArmourPiece(aStackTemp)) { - event.toolTip.add(EnumChatFormatting.DARK_PURPLE+"Provides full hazmat protection."); - } - else { - //Logger.INFO("[Hazmat] Finding Tooltip Data"); - String[] aTooltips = getTooltips(aStack); - if (aTooltips == null || aTooltips.length == 0) { - //Logger.INFO("[Hazmat] No Info!"); - return; - } else { - //Logger.INFO("[Hazmat] Found Tooltips!"); - if (providesProtection(aStackTemp)) { - event.toolTip.add(EnumChatFormatting.LIGHT_PURPLE+"Provides full hazmat protection."); - } else { - event.toolTip.add(mToolTipText); - for (String r : aTooltips) { - event.toolTip.add(" - " + r); - } - } - } - } - } - } - } - - /** - * Static function to replace - * {@link #ic2.core.item.armor.ItemArmorHazmat.hasCompleteHazmat(EntityLivingBase)}. - * Because IC2 doesn't let us register things ourself, anything registered via - * GT/GT++ will return true. - * - * @param living - Entity Wearing Armour - * @return - Does {@link EntityLivingBase} have a full hazmat suit on? - */ - public static boolean hasCompleteHazmat(EntityLivingBase living) { - // Entity is Null, cannot have Hazmat. - if (living == null || living.isDead) { - return false; - } else { - - // Map All Player Armour slots - AutoMap aEquipment = new AutoMap(); - for (int i = 1; i < 5; ++i) { - ItemStack stack = living.getEquipmentInSlot(i); - - // Item is Null, cannot have full suit - if (stack == null) { - return false; - } else { - aEquipment.put(stack); - } - } - - // Compare Equipment to all items mapped for full hazmat. - for (ItemStack aSlotStack : aEquipment) { - if (!isHazmatPiece(aSlotStack)) { - //Logger.INFO("Found item which is not hazmat. "+ItemUtils.getItemName(aSlotStack)); - return false; - } - } - - // We are in some kind of full hazmat, huzzah! - //Logger.INFO("Has full hazmat."); - return true; - } - } - - /** - * Is this item vanilla IC2 hazmat? - * - * @param aArmour - The Armour to provide protection. - * @return - */ - public static boolean isVanillaHazmatPiece(ItemStack aArmour) { - return aArmour != null ? aArmour.getItem() instanceof ItemArmorHazmat : false; - } - - /** - * Is this item vanilla IC2 Nanosuit? - * - * @param aArmour - The Armour to provide protection. - * @return - */ - public static boolean isNanoArmourPiece(ItemStack aArmour) { - return aArmour != null ? aArmour.getItem() instanceof ItemArmorNanoSuit : false; - } - - /** - * Is this item vanilla IC2 Quantum? - * - * @param aArmour - The Armour to provide protection. - * @return - */ - public static boolean isQuantumArmourPiece(ItemStack aArmour) { - return aArmour != null ? aArmour.getItem() instanceof ItemArmorQuantumSuit : false; - } - - /** - * Is this item a registered piece of full hazmat? (Provides all 6 protections) - * - * @param aStack - The Armour to provide protection. - * @return - */ - public static boolean isHazmatPiece(ItemStack aStack) { - return isVanillaHazmatPiece(aStack) || providesProtection(aStack); - } - - /** - * Registers the {@link ItemStack} to all types of protection. Provides full - * hazmat protection. Frost, Fire, Bio, Gas, Radioaton & Electricity. - * - * @param aStack - The Armour to provide protection. - * @return - Did we register this ItemStack properly? - */ - public static boolean addProtection(ItemStack aVanStack) { - if (!ItemUtils.checkForInvalidItems(aVanStack)) { - Logger.INFO("=================Bad Hazmat Addition======================"); - Logger.INFO("Called from: "+ReflectionUtils.getMethodName(0)); - Logger.INFO(ReflectionUtils.getMethodName(1)); - Logger.INFO(ReflectionUtils.getMethodName(2)); - Logger.INFO(ReflectionUtils.getMethodName(3)); - Logger.INFO(ReflectionUtils.getMethodName(4)); - Logger.INFO(ReflectionUtils.getMethodName(5)); - Logger.INFO(ReflectionUtils.getMethodName(6)); - Logger.INFO("=========================================================="); - return false; - } - Logger.INFO("[Hazmat] Registering " + ItemUtils.getItemName(aVanStack) + " for full Hazmat protection."); - GT_ItemStack aStack = getGtStackFromVanilla(aVanStack); - AutoMap aAdded = new AutoMap(); - aAdded.put(addProtection_Frost(aStack)); - aAdded.put(addProtection_Fire(aStack)); - aAdded.put(addProtection_Biohazard(aStack)); - aAdded.put(addProtection_Gas(aStack)); - aAdded.put(addProtection_Radiation(aStack)); - aAdded.put(addProtection_Electricty(aStack)); - for (boolean b : aAdded) { - if (!b) { - return false; - } - } - Logger.INFO("[Hazmat] Protection added for all 6 damage types, registering to master Hazmat list."); - sHazmatList.add(aStack); - return true; - } - - public static boolean addProtection_Frost(GT_ItemStack aStack) { - registerTooltip(aStack, EnumChatFormatting.AQUA + "Frost"); - return addProtection_Generic(sFrostHazmatList, aStack); - } - - public static boolean addProtection_Fire(GT_ItemStack aStack) { - registerTooltip(aStack, EnumChatFormatting.DARK_RED + "Heat"); - return addProtection_Generic(sHeatHazmatList, aStack); - } - - public static boolean addProtection_Biohazard(GT_ItemStack aStack) { - registerTooltip(aStack, EnumChatFormatting.GREEN + "Biohazards"); - return addProtection_Generic(sBioHazmatList, aStack); - } - - public static boolean addProtection_Gas(GT_ItemStack aStack) { - registerTooltip(aStack, EnumChatFormatting.WHITE + "Gas"); - return addProtection_Generic(sGasHazmatList, aStack); - } - - public static boolean addProtection_Radiation(GT_ItemStack aStack) { - registerTooltip(aStack, EnumChatFormatting.DARK_GREEN + "Radiation"); - return addProtection_Generic(sRadioHazmatList, aStack); - } - - public static boolean addProtection_Electricty(GT_ItemStack aStack) { - registerTooltip(aStack, EnumChatFormatting.YELLOW + "Electricity"); - return addProtection_Generic(sElectroHazmatList, aStack); - } - - private static boolean addProtection_Generic(GT_HashSet aSet, GT_ItemStack aStack) { - int aMapSize = aSet.size(); - aSet.add(aStack); - return aMapSize < aSet.size(); - } - - /** - * Does this item provide hazmat protection? (Protection against Frost, Heat, - * Bio, Gas, Rads, Elec) An item may return false even if it protects against - * all six damage types. This is because it's not actually registered as hazmat - * correct. - * - * @param aStack - The item to check for protection - * @return - */ - public static boolean providesProtection(ItemStack aStack) { - return providesProtetion_Generic(sHazmatList, aStack); - } - - public static boolean providesProtetion_Frost(ItemStack aStack) { - return providesProtetion_Generic(sFrostHazmatList, aStack); - } - - public static boolean providesProtetion_Fire(ItemStack aStack) { - return providesProtetion_Generic(sHeatHazmatList, aStack); - } - - public static boolean providesProtetion_Biohazard(ItemStack aStack) { - return providesProtetion_Generic(sBioHazmatList, aStack); - } - - public static boolean providesProtetion_Gas(ItemStack aStack) { - return providesProtetion_Generic(sGasHazmatList, aStack); - } - - public static boolean providesProtetion_Radiation(ItemStack aStack) { - return providesProtetion_Generic(sRadioHazmatList, aStack); - } - - public static boolean providesProtetion_Electricity(ItemStack aStack) { - return providesProtetion_Generic(sElectroHazmatList, aStack); - } - - private static boolean providesProtetion_Generic(GT_HashSet aSet, ItemStack aStack) { - if (isVanillaHazmatPiece(aStack)) { - return true; - } - for (GT_ItemStack o : aSet) { - if (o != null && o.mItem != null && aStack != null && aStack.getItem() != null) { - if (GT_Utility.areStacksEqual(o.toStack(), aStack, true)) { - return true; - } - if (o.isStackEqual(aStack)){ - return true; - } - if (o.mItem == aStack.getItem() && EnergyUtils.EU.isElectricItem(aStack)) { - return true; - } - } - } - return false; - } - - private static String[] getTooltips(GT_ItemStack aStack) { - String aKey = convertGtItemstackToStringDataIgnoreDamage(aStack); - AutoMap aTempTooltipData = mToolTips.get(aKey); - if (aTempTooltipData == null || aTempTooltipData.isEmpty()) { - //Logger.INFO("[Hazmat] Item was not mapped for TTs - "+aKey); - return new String[] {}; - } else { - //Logger.INFO("[Hazmat] Item was mapped for TTs"); - //Collections.sort(aTempTooltipData); - //Logger.INFO("[Hazmat] Sorted TTs"); - - String[] mBuiltOutput = new String[aTempTooltipData.size()]; - int aIndex = 0; - for (String i : aTempTooltipData) { - mBuiltOutput[aIndex++] = i; - } - - return mBuiltOutput; - } - } - - private static void registerTooltip(GT_ItemStack aStack, String aTooltip) { - String aKey = convertGtItemstackToStringDataIgnoreDamage(aStack); - Logger.INFO("[Hazmat] Mapping " + aTooltip + " for " + aKey); - AutoMap aTempTooltipData = mToolTips.get(aKey); - if (aTempTooltipData == null) { - Logger.INFO("No data mapped yet, creating."); - aTempTooltipData = new AutoMap(); - mToolTips.put(aKey, aTempTooltipData); - } - aTempTooltipData.add(aTooltip); - } - - public static ItemStack getStackFromGtStack(GT_ItemStack aGtStack) { - return ItemUtils.simpleMetaStack(aGtStack.mItem, aGtStack.mMetaData, aGtStack.mStackSize); - } - - public static GT_ItemStack getGtStackFromVanilla(ItemStack aStack) { - return new GT_ItemStack(aStack); - } - - private static String convertGtItemstackToStringData(GT_ItemStack aStack) { - if (aStack == null) { - return "NULL"; - } else { - return aStack.mItem.getUnlocalizedName() + "." + aStack.mMetaData + "." + aStack.mStackSize; - } - } - - private static String convertGtItemstackToStringDataIgnoreDamage(GT_ItemStack aStack) { - if (aStack == null) { - return "NULL"; - } else { - return aStack.mItem.getUnlocalizedName() + "." + aStack.mStackSize; - } - } - + public static final GT_HashSet sHazmatList = new GT_HashSet(); + + private static final HashMap> mToolTips = new HashMap>(); + + private static boolean mInit = false; + private static HazmatUtils mInstance; + + @SuppressWarnings("rawtypes") + public static void init() { + if (mInit) { + return; + } + // doInit(); Disabled, hazmat moved to gt5u + } + + public static void doInit() { + + mInstance = new HazmatUtils(); + + sHazmatList.add(ItemUtils.getSimpleStack(Ic2Items.hazmatHelmet, 1)); + sHazmatList.add(ItemUtils.getSimpleStack(Ic2Items.hazmatChestplate, 1)); + sHazmatList.add(ItemUtils.getSimpleStack(Ic2Items.hazmatLeggings, 1)); + sHazmatList.add(ItemUtils.getSimpleStack(Ic2Items.hazmatBoots, 1)); + + // Make Nano a hazmat suit + // Make Quantum a hazmat suit + + if (LoadedMods.IndustrialCraft2 || LoadedMods.IndustrialCraft2Classic) { + AutoMap aVanillaIC2Armour = new AutoMap(); + aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.nanoHelmet, 1)); + aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.nanoBodyarmor, 1)); + aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.nanoLeggings, 1)); + aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.nanoBoots, 1)); + aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.quantumHelmet, 1)); + aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.quantumBodyarmor, 1)); + aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.quantumLeggings, 1)); + aVanillaIC2Armour.add(ItemUtils.getSimpleStack(Ic2Items.quantumBoots, 1)); + for (ItemStack aItem : aVanillaIC2Armour) { + addProtection(aItem); + } + Logger.INFO("[Hazmat] Registered IC2 Items as hazmat gear."); + } + + if (LoadedMods.isModLoaded("EMT")) { + AutoMap aItemFields = new AutoMap(); + Class aItemsEMT = ReflectionUtils.getClass("emt.init.EMTItems"); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "nanoThaumicHelmet")); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "nanoWing")); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "nanoBootsTraveller")); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "quantumThaumicHelmet")); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "quantumWing")); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "quantumArmor")); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "quantumBootsTraveller")); + AutoMap aEMT = new AutoMap(); + for (Field aItemField : aItemFields) { + Item aItemObject = null; + if (aItemField != null) { + try { + aItemObject = (Item) aItemField.get(null); + } catch (Exception t) { + t.printStackTrace(); + } + } + if (aItemObject != null) { + aEMT.add(ItemUtils.getSimpleStack(aItemObject)); + } else { + Logger.INFO("[Hazmat] Could not get " + aItemField.getName() + " from " + aItemsEMT.getName()); + } + } + Logger.INFO("[Hazmat] Registering " + aEMT.size() + " EMT Items as hazmat gear."); + for (ItemStack aItem : aEMT) { + addProtection(aItem); + } + Logger.INFO("[Hazmat] Registered EMT Items as hazmat gear."); + } + + if (LoadedMods.isModLoaded("DraconicEvolution")) { + AutoMap aItemFields = new AutoMap(); + Class aItemsDE = ReflectionUtils.getClass("com.brandon3055.draconicevolution.ModItems"); + + aItemFields.add(ReflectionUtils.getField(aItemsDE, "draconicHelm")); + aItemFields.add(ReflectionUtils.getField(aItemsDE, "draconicChest")); + aItemFields.add(ReflectionUtils.getField(aItemsDE, "draconicLeggs")); + aItemFields.add(ReflectionUtils.getField(aItemsDE, "draconicBoots")); + aItemFields.add(ReflectionUtils.getField(aItemsDE, "wyvernHelm")); + aItemFields.add(ReflectionUtils.getField(aItemsDE, "wyvernChest")); + aItemFields.add(ReflectionUtils.getField(aItemsDE, "wyvernLeggs")); + aItemFields.add(ReflectionUtils.getField(aItemsDE, "wyvernBoots")); + AutoMap aItemMap = new AutoMap(); + for (Field aItemField : aItemFields) { + Item aItemObject = null; + if (aItemField != null) { + try { + aItemObject = (Item) aItemField.get(null); + } catch (Exception t) { + t.printStackTrace(); + } + } + if (aItemObject != null) { + aItemMap.add(ItemUtils.getSimpleStack(aItemObject)); + } else { + Logger.INFO("[Hazmat] Could not get " + aItemField.getName() + " from " + aItemsDE.getName()); + } + } + Logger.INFO("[Hazmat] Registering " + aItemMap.size() + " Draconic Evolution Items as hazmat gear."); + for (ItemStack aItem : aItemMap) { + addProtection(aItem); + } + Logger.INFO("[Hazmat] Registered Draconic Evolution Items as hazmat gear."); + } + + if (LoadedMods.isModLoaded("TaintedMagic")) { + AutoMap aItemFields = new AutoMap(); + Class aItemsTaintedMagic = ReflectionUtils.getClass("taintedmagic.common.registry.ItemRegistry"); + + aItemFields.add(ReflectionUtils.getField(aItemsTaintedMagic, "ItemShadowFortressHelmet")); + aItemFields.add(ReflectionUtils.getField(aItemsTaintedMagic, "ItemShadowFortressChestplate")); + aItemFields.add(ReflectionUtils.getField(aItemsTaintedMagic, "ItemShadowFortressLeggings")); + aItemFields.add(ReflectionUtils.getField(aItemsTaintedMagic, "ItemVoidwalkerBoots")); + AutoMap aItemMap = new AutoMap(); + for (Field aItemField : aItemFields) { + Item aItemObject = null; + if (aItemField != null) { + try { + aItemObject = (Item) aItemField.get(null); + } catch (Exception t) { + t.printStackTrace(); + } + } + if (aItemObject != null) { + aItemMap.add(ItemUtils.getSimpleStack(aItemObject)); + } else { + Logger.INFO( + "[Hazmat] Could not get " + aItemField.getName() + " from " + aItemsTaintedMagic.getName()); + } + } + Logger.INFO("[Hazmat] Registering " + aItemMap.size() + " Tainted Magic Items as hazmat gear."); + for (ItemStack aItem : aItemMap) { + addProtection(aItem); + } + Logger.INFO("[Hazmat] Registered Tainted Magic Items as hazmat gear."); + } + + if (LoadedMods.isModLoaded("WitchingGadgets")) { + AutoMap aItemFields = new AutoMap(); + Class aItemsTaintedMagic = ReflectionUtils.getClass("witchinggadgets.common.WGContent"); + + aItemFields.add(ReflectionUtils.getField(aItemsTaintedMagic, "ItemPrimordialHelm")); + aItemFields.add(ReflectionUtils.getField(aItemsTaintedMagic, "ItemPrimordialChest")); + aItemFields.add(ReflectionUtils.getField(aItemsTaintedMagic, "ItemPrimordialLegs")); + aItemFields.add(ReflectionUtils.getField(aItemsTaintedMagic, "ItemPrimordialBoots")); + AutoMap aItemMap = new AutoMap(); + for (Field aItemField : aItemFields) { + Item aItemObject = null; + if (aItemField != null) { + try { + aItemObject = (Item) aItemField.get(null); + } catch (Exception t) { + t.printStackTrace(); + } + } + if (aItemObject != null) { + aItemMap.add(ItemUtils.getSimpleStack(aItemObject)); + } else { + Logger.INFO( + "[Hazmat] Could not get " + aItemField.getName() + " from " + aItemsTaintedMagic.getName()); + } + } + Logger.INFO("[Hazmat] Registering " + aItemMap.size() + " Witching Gadgets Items as hazmat gear."); + for (ItemStack aItem : aItemMap) { + addProtection(aItem); + } + Logger.INFO("[Hazmat] Registered Witching Gadgets Items as hazmat gear."); + } + + if (LoadedMods.isModLoaded("ThaumicTinkerer")) { + /* + AutoMap aItems = new AutoMap(); + Class aMainTT = ReflectionUtils.getClass("thaumic.tinkerer.common.ThaumicTinkerer"); + Class aItemRegistryTT = ReflectionUtils.getClass("thaumic.tinkerer.common.registry.TTRegistry"); + Field aRegistryInstance = ReflectionUtils.getField(aMainTT, "registry"); + Object aRegistry = ReflectionUtils.getFieldValue(aRegistryInstance); + Method aFuckingStupidMethodHandlingMethod = ReflectionUtils.getMethod(aItemRegistryTT, "getFirstItemFromClass", new Class[] {Class.class}); + Item aIchorHelm = (Item) ReflectionUtils.invokeNonBool(aRegistry, aFuckingStupidMethodHandlingMethod, new Object[] {ReflectionUtils.getClass("thaumic.tinkerer.common.item.kami.armor.ItemGemHelm")}); + Item aIchorChest = (Item) ReflectionUtils.invokeNonBool(aRegistry, aFuckingStupidMethodHandlingMethod, new Object[] {ReflectionUtils.getClass("thaumic.tinkerer.common.item.kami.armor.ItemGemChest")}); + Item aIchorLegs = (Item) ReflectionUtils.invokeNonBool(aRegistry, aFuckingStupidMethodHandlingMethod, new Object[] {ReflectionUtils.getClass("thaumic.tinkerer.common.item.kami.armor.ItemGemLegs")}); + Item aIchorBoots = (Item) ReflectionUtils.invokeNonBool(aRegistry, aFuckingStupidMethodHandlingMethod, new Object[] {ReflectionUtils.getClass("thaumic.tinkerer.common.item.kami.armor.ItemGemBoots")}); + aItems.add(aIchorHelm); + aItems.add(aIchorChest); + aItems.add(aIchorLegs); + aItems.add(aIchorBoots); + AutoMap aItemMap = new AutoMap(); + int aIndex = 0; + for (Item aItem : aItems) { + Item aItemObject = null; + if (aItem != null) { + aItemMap.add(ItemUtils.getSimpleStack(aItemObject)); + } + else { + Logger.INFO("[Hazmat] Could not get item "+aIndex+" from "+aItemRegistryTT.getName()); + } + aIndex++; + } + Logger.INFO("[Hazmat] Registering "+aItemMap.size()+" Thaumic Tinkerer Items as hazmat gear."); + for (ItemStack aItem : aItemMap) { + addProtection(aItem); + } + Logger.INFO("[Hazmat] Registered Thaumic Tinkerer Items as hazmat gear."); + */ + Logger.INFO("[Hazmat] Did not register Thaumic Tinkerer Items as hazmat gear."); + } + + if (LoadedMods.isModLoaded("GraviSuite")) { + AutoMap aItemFields = new AutoMap(); + Class aItemsGravisuite = ReflectionUtils.getClass("gravisuite.GraviSuite"); + aItemFields.add(ReflectionUtils.getField(aItemsGravisuite, "advNanoChestPlate")); + aItemFields.add(ReflectionUtils.getField(aItemsGravisuite, "graviChestPlate")); + AutoMap aGravisuite = new AutoMap(); + for (Field aItemField : aItemFields) { + Item aItemObject = ReflectionUtils.getFieldValue(aItemField); + if (aItemObject != null) { + aGravisuite.add(ItemUtils.getSimpleStack(aItemObject)); + } + } + Logger.INFO("[Hazmat] Registering " + aGravisuite.size() + " Gravisuit Items as hazmat gear."); + for (ItemStack aItem : aGravisuite) { + addProtection(aItem); + } + Logger.INFO("[Hazmat] Registered Gravisuit Items as hazmat gear."); + } + + if (LoadedMods.isModLoaded("AdvancedSolarPanel")) { + AutoMap aItemFields = new AutoMap(); + Class aItemsEMT = ReflectionUtils.getClass("advsolar.common.AdvancedSolarPanel"); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "advancedSolarHelmet")); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "hybridSolarHelmet")); + aItemFields.add(ReflectionUtils.getField(aItemsEMT, "ultimateSolarHelmet")); + AutoMap aASP = new AutoMap(); + for (Field aItemField : aItemFields) { + Item aItemObject = ReflectionUtils.getFieldValue(aItemField); + if (aItemObject != null) { + aASP.add(ItemUtils.getSimpleStack(aItemObject)); + } + } + Logger.INFO("[Hazmat] Registering " + aASP.size() + " Adv. Solar Items as hazmat gear."); + for (ItemStack aItem : aASP) { + addProtection(aItem); + } + Logger.INFO("[Hazmat] Registered Adv. Solar Items as hazmat gear."); + } + + Utils.registerEvent(mInstance); + Logger.INFO("[Hazmat] Registered Tooltip handler for hazmat gear."); + mInit = true; + } + + private static final String mToolTipText = "Provides protection from:"; + + @SubscribeEvent + public void onItemTooltip(ItemTooltipEvent event) { + // Logger.INFO("Ticking Hazmat handler"); + if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { + + if (event.itemStack == null || isVanillaHazmatPiece(event.itemStack)) { + // Logger.INFO("[Hazmat] Invalid Itemstack or vanilla hazmat"); + return; + } else { + ItemStack aStackTemp = event.itemStack; + GT_ItemStack aStack = new GT_ItemStack(aStackTemp); + if (isNanoArmourPiece(aStackTemp) || isQuantumArmourPiece(aStackTemp)) { + event.toolTip.add(EnumChatFormatting.DARK_PURPLE + "Provides full hazmat protection."); + } else { + // Logger.INFO("[Hazmat] Finding Tooltip Data"); + String[] aTooltips = getTooltips(aStack); + if (aTooltips == null || aTooltips.length == 0) { + // Logger.INFO("[Hazmat] No Info!"); + return; + } else { + // Logger.INFO("[Hazmat] Found Tooltips!"); + if (providesProtection(aStackTemp)) { + event.toolTip.add(EnumChatFormatting.LIGHT_PURPLE + "Provides full hazmat protection."); + } else { + event.toolTip.add(mToolTipText); + for (String r : aTooltips) { + event.toolTip.add(" - " + r); + } + } + } + } + } + } + } + + /** + * Static function to replace + * {@link #ic2.core.item.armor.ItemArmorHazmat.hasCompleteHazmat(EntityLivingBase)}. + * Because IC2 doesn't let us register things ourself, anything registered via + * GT/GT++ will return true. + * + * @param living - Entity Wearing Armour + * @return - Does {@link EntityLivingBase} have a full hazmat suit on? + */ + public static boolean hasCompleteHazmat(EntityLivingBase living) { + // Entity is Null, cannot have Hazmat. + if (living == null || living.isDead) { + return false; + } else { + + // Map All Player Armour slots + AutoMap aEquipment = new AutoMap(); + for (int i = 1; i < 5; ++i) { + ItemStack stack = living.getEquipmentInSlot(i); + + // Item is Null, cannot have full suit + if (stack == null) { + return false; + } else { + aEquipment.put(stack); + } + } + + // Compare Equipment to all items mapped for full hazmat. + for (ItemStack aSlotStack : aEquipment) { + if (!isHazmatPiece(aSlotStack)) { + // Logger.INFO("Found item which is not hazmat. "+ItemUtils.getItemName(aSlotStack)); + return false; + } + } + + // We are in some kind of full hazmat, huzzah! + // Logger.INFO("Has full hazmat."); + return true; + } + } + + /** + * Is this item vanilla IC2 hazmat? + * + * @param aArmour - The Armour to provide protection. + * @return + */ + public static boolean isVanillaHazmatPiece(ItemStack aArmour) { + return aArmour != null ? aArmour.getItem() instanceof ItemArmorHazmat : false; + } + + /** + * Is this item vanilla IC2 Nanosuit? + * + * @param aArmour - The Armour to provide protection. + * @return + */ + public static boolean isNanoArmourPiece(ItemStack aArmour) { + return aArmour != null ? aArmour.getItem() instanceof ItemArmorNanoSuit : false; + } + + /** + * Is this item vanilla IC2 Quantum? + * + * @param aArmour - The Armour to provide protection. + * @return + */ + public static boolean isQuantumArmourPiece(ItemStack aArmour) { + return aArmour != null ? aArmour.getItem() instanceof ItemArmorQuantumSuit : false; + } + + /** + * Is this item a registered piece of full hazmat? (Provides all 6 protections) + * + * @param aStack - The Armour to provide protection. + * @return + */ + public static boolean isHazmatPiece(ItemStack aStack) { + return isVanillaHazmatPiece(aStack) || providesProtection(aStack); + } + + /** + * Registers the {@link ItemStack} to all types of protection. Provides full + * hazmat protection. Frost, Fire, Bio, Gas, Radioaton & Electricity. + * + * @param aStack - The Armour to provide protection. + * @return - Did we register this ItemStack properly? + */ + public static boolean addProtection(ItemStack aVanStack) { + if (!ItemUtils.checkForInvalidItems(aVanStack)) { + Logger.INFO("=================Bad Hazmat Addition======================"); + Logger.INFO("Called from: " + ReflectionUtils.getMethodName(0)); + Logger.INFO(ReflectionUtils.getMethodName(1)); + Logger.INFO(ReflectionUtils.getMethodName(2)); + Logger.INFO(ReflectionUtils.getMethodName(3)); + Logger.INFO(ReflectionUtils.getMethodName(4)); + Logger.INFO(ReflectionUtils.getMethodName(5)); + Logger.INFO(ReflectionUtils.getMethodName(6)); + Logger.INFO("=========================================================="); + return false; + } + Logger.INFO("[Hazmat] Registering " + ItemUtils.getItemName(aVanStack) + " for full Hazmat protection."); + GT_ItemStack aStack = getGtStackFromVanilla(aVanStack); + AutoMap aAdded = new AutoMap(); + aAdded.put(addProtection_Frost(aStack)); + aAdded.put(addProtection_Fire(aStack)); + aAdded.put(addProtection_Biohazard(aStack)); + aAdded.put(addProtection_Gas(aStack)); + aAdded.put(addProtection_Radiation(aStack)); + aAdded.put(addProtection_Electricty(aStack)); + for (boolean b : aAdded) { + if (!b) { + return false; + } + } + Logger.INFO("[Hazmat] Protection added for all 6 damage types, registering to master Hazmat list."); + sHazmatList.add(aStack); + return true; + } + + public static boolean addProtection_Frost(GT_ItemStack aStack) { + registerTooltip(aStack, EnumChatFormatting.AQUA + "Frost"); + return addProtection_Generic(sFrostHazmatList, aStack); + } + + public static boolean addProtection_Fire(GT_ItemStack aStack) { + registerTooltip(aStack, EnumChatFormatting.DARK_RED + "Heat"); + return addProtection_Generic(sHeatHazmatList, aStack); + } + + public static boolean addProtection_Biohazard(GT_ItemStack aStack) { + registerTooltip(aStack, EnumChatFormatting.GREEN + "Biohazards"); + return addProtection_Generic(sBioHazmatList, aStack); + } + + public static boolean addProtection_Gas(GT_ItemStack aStack) { + registerTooltip(aStack, EnumChatFormatting.WHITE + "Gas"); + return addProtection_Generic(sGasHazmatList, aStack); + } + + public static boolean addProtection_Radiation(GT_ItemStack aStack) { + registerTooltip(aStack, EnumChatFormatting.DARK_GREEN + "Radiation"); + return addProtection_Generic(sRadioHazmatList, aStack); + } + + public static boolean addProtection_Electricty(GT_ItemStack aStack) { + registerTooltip(aStack, EnumChatFormatting.YELLOW + "Electricity"); + return addProtection_Generic(sElectroHazmatList, aStack); + } + + private static boolean addProtection_Generic(GT_HashSet aSet, GT_ItemStack aStack) { + int aMapSize = aSet.size(); + aSet.add(aStack); + return aMapSize < aSet.size(); + } + + /** + * Does this item provide hazmat protection? (Protection against Frost, Heat, + * Bio, Gas, Rads, Elec) An item may return false even if it protects against + * all six damage types. This is because it's not actually registered as hazmat + * correct. + * + * @param aStack - The item to check for protection + * @return + */ + public static boolean providesProtection(ItemStack aStack) { + return providesProtetion_Generic(sHazmatList, aStack); + } + + public static boolean providesProtetion_Frost(ItemStack aStack) { + return providesProtetion_Generic(sFrostHazmatList, aStack); + } + + public static boolean providesProtetion_Fire(ItemStack aStack) { + return providesProtetion_Generic(sHeatHazmatList, aStack); + } + + public static boolean providesProtetion_Biohazard(ItemStack aStack) { + return providesProtetion_Generic(sBioHazmatList, aStack); + } + + public static boolean providesProtetion_Gas(ItemStack aStack) { + return providesProtetion_Generic(sGasHazmatList, aStack); + } + + public static boolean providesProtetion_Radiation(ItemStack aStack) { + return providesProtetion_Generic(sRadioHazmatList, aStack); + } + + public static boolean providesProtetion_Electricity(ItemStack aStack) { + return providesProtetion_Generic(sElectroHazmatList, aStack); + } + + private static boolean providesProtetion_Generic(GT_HashSet aSet, ItemStack aStack) { + if (isVanillaHazmatPiece(aStack)) { + return true; + } + for (GT_ItemStack o : aSet) { + if (o != null && o.mItem != null && aStack != null && aStack.getItem() != null) { + if (GT_Utility.areStacksEqual(o.toStack(), aStack, true)) { + return true; + } + if (o.isStackEqual(aStack)) { + return true; + } + if (o.mItem == aStack.getItem() && EnergyUtils.EU.isElectricItem(aStack)) { + return true; + } + } + } + return false; + } + + private static String[] getTooltips(GT_ItemStack aStack) { + String aKey = convertGtItemstackToStringDataIgnoreDamage(aStack); + AutoMap aTempTooltipData = mToolTips.get(aKey); + if (aTempTooltipData == null || aTempTooltipData.isEmpty()) { + // Logger.INFO("[Hazmat] Item was not mapped for TTs - "+aKey); + return new String[] {}; + } else { + // Logger.INFO("[Hazmat] Item was mapped for TTs"); + // Collections.sort(aTempTooltipData); + // Logger.INFO("[Hazmat] Sorted TTs"); + + String[] mBuiltOutput = new String[aTempTooltipData.size()]; + int aIndex = 0; + for (String i : aTempTooltipData) { + mBuiltOutput[aIndex++] = i; + } + + return mBuiltOutput; + } + } + + private static void registerTooltip(GT_ItemStack aStack, String aTooltip) { + String aKey = convertGtItemstackToStringDataIgnoreDamage(aStack); + Logger.INFO("[Hazmat] Mapping " + aTooltip + " for " + aKey); + AutoMap aTempTooltipData = mToolTips.get(aKey); + if (aTempTooltipData == null) { + Logger.INFO("No data mapped yet, creating."); + aTempTooltipData = new AutoMap(); + mToolTips.put(aKey, aTempTooltipData); + } + aTempTooltipData.add(aTooltip); + } + + public static ItemStack getStackFromGtStack(GT_ItemStack aGtStack) { + return ItemUtils.simpleMetaStack(aGtStack.mItem, aGtStack.mMetaData, aGtStack.mStackSize); + } + + public static GT_ItemStack getGtStackFromVanilla(ItemStack aStack) { + return new GT_ItemStack(aStack); + } + + private static String convertGtItemstackToStringData(GT_ItemStack aStack) { + if (aStack == null) { + return "NULL"; + } else { + return aStack.mItem.getUnlocalizedName() + "." + aStack.mMetaData + "." + aStack.mStackSize; + } + } + + private static String convertGtItemstackToStringDataIgnoreDamage(GT_ItemStack aStack) { + if (aStack == null) { + return "NULL"; + } else { + return aStack.mItem.getUnlocalizedName() + "." + aStack.mStackSize; + } + } } diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/InventoryUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/InventoryUtils.java index fe67c88d69..8fc5b90b62 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/InventoryUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/InventoryUtils.java @@ -1,12 +1,10 @@ package gtPlusPlus.core.util.minecraft; -import java.util.Random; - import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.data.AutoMap; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy_RTG; +import java.util.Random; import net.minecraft.block.Block; import net.minecraft.entity.item.EntityItem; import net.minecraft.inventory.IInventory; @@ -16,73 +14,82 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class InventoryUtils { - - private final static Random mRandom = new Random(); - - public static void dropInventoryItems(World world, int x, int y, int z, Block block) { - TileEntity tileentity = world.getTileEntity(x, y, z); - if (tileentity != null && tileentity instanceof IInventory && ((IInventory) tileentity).getSizeInventory() > 0) { - - IInventory aTileInv = (IInventory) tileentity; - int aMinSlot = 0; - int aMaxSlot = aTileInv.getSizeInventory()-1; - - for (int i1 = aMinSlot; i1 < aMaxSlot; ++i1) { - ItemStack itemstack = aTileInv.getStackInSlot(i1); + private static final Random mRandom = new Random(); + + public static void dropInventoryItems(World world, int x, int y, int z, Block block) { + TileEntity tileentity = world.getTileEntity(x, y, z); + + if (tileentity != null + && tileentity instanceof IInventory + && ((IInventory) tileentity).getSizeInventory() > 0) { + + IInventory aTileInv = (IInventory) tileentity; + int aMinSlot = 0; + int aMaxSlot = aTileInv.getSizeInventory() - 1; - if (itemstack != null) { - float f = mRandom.nextFloat() * 0.8F + 0.1F; - float f1 = mRandom.nextFloat() * 0.8F + 0.1F; - EntityItem entityitem; + for (int i1 = aMinSlot; i1 < aMaxSlot; ++i1) { + ItemStack itemstack = aTileInv.getStackInSlot(i1); - for (float f2 = mRandom.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; world.spawnEntityInWorld(entityitem)) { - int j1 = mRandom.nextInt(21) + 10; + if (itemstack != null) { + float f = mRandom.nextFloat() * 0.8F + 0.1F; + float f1 = mRandom.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem; - if (j1 > itemstack.stackSize) { - j1 = itemstack.stackSize; - } + for (float f2 = mRandom.nextFloat() * 0.8F + 0.1F; + itemstack.stackSize > 0; + world.spawnEntityInWorld(entityitem)) { + int j1 = mRandom.nextInt(21) + 10; - itemstack.stackSize -= j1; - entityitem = new EntityItem(world, x + f, y + f1, z + f2, - new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); - float f3 = 0.05F; - entityitem.motionX = (float) mRandom.nextGaussian() * f3; - entityitem.motionY = (float) mRandom.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float) mRandom.nextGaussian() * f3; + if (j1 > itemstack.stackSize) { + j1 = itemstack.stackSize; + } - if (itemstack.hasTagCompound()) { - entityitem.getEntityItem() - .setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy()); - } - } - } - } + itemstack.stackSize -= j1; + entityitem = new EntityItem( + world, + x + f, + y + f1, + z + f2, + new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); + float f3 = 0.05F; + entityitem.motionX = (float) mRandom.nextGaussian() * f3; + entityitem.motionY = (float) mRandom.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float) mRandom.nextGaussian() * f3; - world.func_147453_f(x, y, z, block); - } + if (itemstack.hasTagCompound()) { + entityitem.getEntityItem().setTagCompound((NBTTagCompound) + itemstack.getTagCompound().copy()); + } + } + } + } - } + world.func_147453_f(x, y, z, block); + } + } - public static void sortInventoryItems(MetaTileEntity aTile) { - sortInventoryItems(aTile.getBaseMetaTileEntity()); - } + public static void sortInventoryItems(MetaTileEntity aTile) { + sortInventoryItems(aTile.getBaseMetaTileEntity()); + } - public static void sortInventoryItems(IGregTechTileEntity aBaseMetaTileEntity) { - IInventory mInv = aBaseMetaTileEntity.getIInventory(aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getZCoord()); - AutoMap aInvContents = new AutoMap(); - int aSize = mInv.getSizeInventory(); - for (int slot=0; slot aInvContents = new AutoMap(); + int aSize = mInv.getSizeInventory(); + for (int slot = 0; slot < aSize; slot++) { + aInvContents.put(mInv.getStackInSlot(slot)); + } + ItemStack[] mInventory = aInvContents.toArray(); + for (int i = 0; i < mInventory.length; i++) { + for (int j = i + 1; j < mInventory.length; j++) { + if (mInventory[j] != null + && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j]))) { + GT_Utility.moveStackFromSlotAToSlotB( + aBaseMetaTileEntity, aBaseMetaTileEntity, j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + } + } + } + } } diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/ItemUtils.java index 32d838b036..ad7bcdd063 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/ItemUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/ItemUtils.java @@ -1,10 +1,5 @@ package gtPlusPlus.core.util.minecraft; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier; import gregtech.api.enums.GT_Values; @@ -27,7 +22,6 @@ import gtPlusPlus.core.item.base.dusts.decimal.BaseItemDecidust; import gtPlusPlus.core.item.base.plates.BaseItemPlate_OLD; import gtPlusPlus.core.item.chemistry.AgriculturalChem; import gtPlusPlus.core.item.chemistry.GenericChem; -import gtPlusPlus.core.item.chemistry.RocketFuels; import gtPlusPlus.core.item.tool.staballoy.MultiPickaxeBase; import gtPlusPlus.core.item.tool.staballoy.MultiSpadeBase; import gtPlusPlus.core.lib.CORE; @@ -41,6 +35,10 @@ import gtPlusPlus.preloader.CORE_Preloader; import gtPlusPlus.xmod.gregtech.api.items.Gregtech_MetaTool; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_DustGeneration; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentData; @@ -58,1368 +56,1407 @@ import net.minecraftforge.oredict.OreDictionary; public class ItemUtils { - public static ItemStack getSimpleStack(final Item x) { - return getSimpleStack(x, 1); - } - - public static ItemStack getSimpleStack(final Block x) { - return simpleMetaStack(Item.getItemFromBlock(x), 0, 1); - } - - - public static ItemStack getSimpleStack(final Block x, int i) { - if (i == 0) { - return getSimpleStack(x, i, 1); - } - - return getSimpleStack(x, 0, i); - } - - public static ItemStack getSimpleStack(final Block x, int meta, int i) { - return simpleMetaStack(Item.getItemFromBlock(x), meta, i); - } - - public static ItemStack getSimpleStack(final Item x, final int i) { - try { - final ItemStack r = new ItemStack(x, i); - return r.copy(); - } catch (final Throwable e) { - return null; - } - } - - public static ItemStack getSimpleStack(final ItemStack x, final int i) { - try { - final ItemStack r = x.copy(); - r.stackSize = i; - return r; - } catch (final Throwable e) { - return null; - } - } - - public static final int WILDCARD_VALUE = Short.MAX_VALUE; - - public static ItemStack getWildcardStack(final Item x) { - final ItemStack y = new ItemStack(x, 1, WILDCARD_VALUE); - return y; - } - - public static ItemStack getWildcardStack(final ItemStack x) { - final ItemStack y = ItemUtils.simpleMetaStack(x, WILDCARD_VALUE, 1); - return y; - } - - public static ItemStack getIC2Cell(final String S) { - final ItemStack moreTemp = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell" + S, 1); - - if (moreTemp == null) { - final int cellID = 0; - final ItemStack temp = GT_ModHandler.getModItem("IC2", "itemCellEmpty", 1L, cellID); - return temp != null ? temp : null; - } - - return moreTemp; - } - - public static ItemStack getIC2Cell(final int meta) { - final ItemStack temp = GT_ModHandler.getModItem("IC2", "itemCellEmpty", 1L, meta); - return temp != null ? temp : null; - } - - public static ItemStack getEmptyCell() { - return getEmptyCell(1); - } - - public static ItemStack getEmptyCell(int i) { - if (ItemList.Cell_Empty.hasBeenSet()) { - return ItemList.Cell_Empty.get(i); - } - final ItemStack temp = GT_ModHandler.getModItem("IC2", "itemCellEmpty", i, 0); - return temp != null ? temp : null; - } - - public static void getItemForOreDict(final String FQRN, final String oreDictName, final String itemName, - final int meta) { - try { - Item em = null; - final Item em1 = getItemFromFQRN(FQRN); - // Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); - if (em1 != null) { - em = em1; - } - if (em != null) { - - final ItemStack metaStack = new ItemStack(em, 1, meta); - GT_OreDictUnificator.registerOre(oreDictName, metaStack); - - /* - * ItemStack itemStackWithMeta = new ItemStack(em,1,meta); - * GT_OreDictUnificator.registerOre(oreDictName, new - * ItemStack(itemStackWithMeta.getItem())); - */ - } - } catch (final NullPointerException e) { - Logger.ERROR(itemName + " not found. [NULL]"); - } - } - - public static void addItemToOreDictionary(ItemStack stack, final String oreDictName, boolean useWildcardMeta) { - if (useWildcardMeta) { - stack = ItemUtils.getWildcardStack(stack); - } - try { - OreDictionary.registerOre(oreDictName, stack); - } catch (final NullPointerException e) { - Logger.ERROR(ItemUtils.getItemName(stack) + " not registered. [NULL]"); - } - } - - public static void addItemToOreDictionary(final ItemStack stack, final String oreDictName) { - addItemToOreDictionary(stack, oreDictName, false); - } - - public static ItemStack getItemStackWithMeta(final boolean MOD, final String FQRN, final String itemName, - final int meta, final int itemstackSize) { - if (MOD) { - try { - Item em = null; - final Item em1 = getItemFromFQRN(FQRN); - // Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); - if (em1 != null) { - if (null == em) { - em = em1; - } - if (em != null) { - final ItemStack metaStack = new ItemStack(em, itemstackSize, meta); - return metaStack; - } - } - return null; - } catch (final NullPointerException e) { - Logger.ERROR(itemName + " not found. [NULL]"); - return null; - } - } - return null; - } - - public static ItemStack simpleMetaStack(final String FQRN, final int meta, final int itemstackSize) { - try { - Item em = null; - final Item em1 = getItemFromFQRN(FQRN); - // Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); - if (em1 != null) { - if (null == em) { - em = em1; - } - if (em != null) { - final ItemStack metaStack = new ItemStack(em, itemstackSize, meta); - return metaStack; - } - } - return null; - } catch (final NullPointerException e) { - Logger.ERROR(FQRN + " not found. [NULL]"); - return null; - } - } - - public static ItemStack simpleMetaStack(ItemStack simpleStack, int meta, int size) { - return simpleMetaStack(simpleStack.getItem(), meta, size); - } - - public static ItemStack simpleMetaStack(final Item item, int meta, int size) { - if (item == null) { - return null; - } - if (meta < 0 || meta > Short.MAX_VALUE) { - meta = 0; - } - if (size < 0 || size > 64) { - size = 1; - } - //Logger.INFO("Found Metastack: " + item.getUnlocalizedName() + ":" + meta); - //Logger.INFO(""+ReflectionUtils.getMethodName(0)); - //Logger.INFO(""+ReflectionUtils.getMethodName(1)); - //Logger.INFO(""+ReflectionUtils.getMethodName(2)); - //Logger.INFO(""+ReflectionUtils.getMethodName(3)); - //Logger.INFO(""+ReflectionUtils.getMethodName(4)); - final ItemStack metaStack = new ItemStack(item, size, meta); - return metaStack; - } - - public static ItemStack simpleMetaStack(final Block block, final int meta, final int size) { - return simpleMetaStack(Item.getItemFromBlock(block), meta, size); - } - - public static ItemStack getCorrectStacktype(final String fqrn, final int stackSize) { - final String oreDict = "ore:"; - ItemStack temp; - if (fqrn.toLowerCase().contains(oreDict.toLowerCase())) { - final String sanitizedName = fqrn.replace(oreDict, ""); - temp = ItemUtils.getItemStackFromFQRN(sanitizedName, stackSize); - return temp; - } - final String[] fqrnSplit = fqrn.split(":"); - String temp1; - String temp2; - temp1 = fqrnSplit[1]; - if (fqrnSplit.length < 3) { - temp2 = "0"; - } else { - temp2 = fqrnSplit[2]; - } - temp = ItemUtils.getItemStackWithMeta(LoadedMods.MiscUtils, fqrn, temp1, Integer.parseInt(temp2), stackSize); - return temp; - } - - public static ItemStack getCorrectStacktype(final Object item_Input, final int stackSize) { - if (item_Input instanceof String) { - return getItemStackOfAmountFromOreDictNoBroken((String) item_Input, stackSize); - } else if (item_Input instanceof ItemStack) { - return (ItemStack) item_Input; - } - return null; - } - - public static Item getItemFromFQRN(final String fqrn) // fqrn = fully qualified resource name - { - final String[] fqrnSplit = fqrn.split(":"); - return GameRegistry.findItem(fqrnSplit[0], fqrnSplit[1]); - } - - public static ItemStack getItemStackFromFQRN(final String fqrn, final int Size) // fqrn = fully qualified resource name - { - Logger.INFO("Trying to split string '"+fqrn+"'."); - final String[] fqrnSplit = fqrn.split(":"); - if (fqrnSplit.length < 2) { - return null; - } - else { - if (fqrnSplit.length == 2) { - Logger.INFO("Mod: "+fqrnSplit[0]+", Item: "+fqrnSplit[1]); - return GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size); - } - else if (fqrnSplit.length == 3 && fqrnSplit[2] != null && fqrnSplit[2].length() > 0) { - Logger.INFO("Mod: "+fqrnSplit[0]+", Item: "+fqrnSplit[1]+", Meta: "+fqrnSplit[2]); - ItemStack aStack = GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size); - int aMeta = Integer.parseInt(fqrnSplit[2]); - if (aStack != null && (aMeta >= 0 && aMeta <= Short.MAX_VALUE)){ - return ItemUtils.simpleMetaStack(aStack, aMeta, Size); - } - else { - Logger.INFO("Could not find instance of Item: "+fqrnSplit[1]); - - } - } - - } - return null; - } - - public static void generateSpawnEgg(final String entityModID, final String parSpawnName, final int colourEgg, - final int colourOverlay) { - final Item itemSpawnEgg = new BasicSpawnEgg(entityModID, parSpawnName, colourEgg, colourOverlay) - .setUnlocalizedName("spawn_egg_" + parSpawnName.toLowerCase()) - .setTextureName(CORE.MODID + ":spawn_egg"); - GameRegistry.registerItem(itemSpawnEgg, "spawnEgg" + parSpawnName); - } - - public static ItemStack[] validItemsForOreDict(final String oredictName) { - final List validNames = MaterialUtils.oreDictValuesForEntry(oredictName); - final ItemStack[] inputs = new ItemStack[validNames.size()]; - for (int i = 0; i < validNames.size(); i++) { - inputs[i] = (ItemStack) validNames.get(i); - } - return inputs; - } - - public static ItemStack getItemStackOfAmountFromOreDict(String oredictName, final int amount) { - String mTemp = oredictName; - - if (oredictName.contains("-") || oredictName.contains("_")) { - mTemp = Utils.sanitizeString(mTemp, new char[] {'-', '_'}); - } - else { - mTemp = Utils.sanitizeString(mTemp); - } - - - - if (oredictName.contains("rod")) { - String s = "stick"+oredictName.substring(3); - oredictName = s; - } - - // Banned Materials and replacements for GT5.8 compat. - - if (oredictName.toLowerCase().contains("ingotclay")) { - return getSimpleStack(Items.clay_ball, amount); - } - - if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - if (oredictName.toLowerCase().contains("rutile")) { - mTemp = oredictName.replace("Rutile", "Titanium"); - } - if (oredictName.toLowerCase().contains("vanadiumsteel")) { - mTemp = oredictName.replace("VanadiumSteel", "StainlessSteel"); - } - } - final ArrayList oreDictList = OreDictionary.getOres(mTemp); - if (!oreDictList.isEmpty()) { - final ItemStack returnValue = oreDictList.get(0).copy(); - returnValue.stackSize = amount; - return returnValue; - } - Logger.INFO("Failed to find `" + oredictName + "` in OD."); - return getErrorStack(amount, oredictName+" x"+amount); - //return getItemStackOfAmountFromOreDictNoBroken(mTemp, amount); - } - - public static ItemStack getItemStackOfAmountFromOreDictNoBroken(String oredictName, final int amount) { - if (CORE_Preloader.DEBUG_MODE) { - Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(1)); - Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(2)); - Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(3)); - Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(4)); - Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(5)); - } - - try { - - if (oredictName.contains("-") || oredictName.contains("_")) { - oredictName = Utils.sanitizeString(oredictName, new char[] {'-', '_'}); - } - else { - oredictName = Utils.sanitizeString(oredictName); - } - - // Adds a check to grab dusts using GT methodology if possible. - ItemStack returnValue = null; - if (oredictName.toLowerCase().contains("dust")) { - final String MaterialName = oredictName.toLowerCase().replace("dust", ""); - final Materials m = Materials.get(MaterialName); - if (m != null && m != Materials._NULL) { - returnValue = getGregtechDust(m, amount); - if (checkForInvalidItems(returnValue)) { - return returnValue; - } - } - } - if (returnValue == null) { - returnValue = getItemStackOfAmountFromOreDict(oredictName, amount); - if (ItemUtils.checkForInvalidItems(returnValue)) { - return returnValue.copy(); - } - } - - Logger.RECIPE(oredictName + " was not valid."); - return null; - } catch (final Throwable t) { - return null; - } - } - - public static ItemStack getGregtechDust(final Materials material, final int amount) { - final ItemStack returnValue = GT_OreDictUnificator.get(OrePrefixes.dust, material, 1L); - if (returnValue != null) { - if (ItemUtils.checkForInvalidItems(returnValue)) { - return returnValue.copy(); - } - } - Logger.WARNING(material + " was not valid."); - return null; - } - - // NullFormula - public static Item[] generateSpecialUseDusts(final String unlocalizedName, final String materialName, - final int Colour) { - return generateSpecialUseDusts(unlocalizedName, materialName, "NullFormula", Colour); - } - - public static Item[] generateSpecialUseDusts(final String unlocalizedName, final String materialName, - String mChemForm, final int Colour) { - final Item[] output = { - new BaseItemDustUnique("itemDust" + unlocalizedName, materialName, mChemForm, Colour, "Dust"), - new BaseItemDustUnique("itemDustSmall" + unlocalizedName, materialName, mChemForm, Colour, "Small"), - new BaseItemDustUnique("itemDustTiny" + unlocalizedName, materialName, mChemForm, Colour, "Tiny") }; - - //Generate Shaped/Shapeless Recipes - - final ItemStack normalDust = ItemUtils.getSimpleStack(output[0]); - final ItemStack smallDust = ItemUtils.getSimpleStack(output[1]); - final ItemStack tinyDust = ItemUtils.getSimpleStack(output[2]); - - CORE.RA.addpackagerRecipe(ItemList.Schematic_Dust.get(0), smallDust, tinyDust, normalDust); - - if (ItemUtils.checkForInvalidItems(tinyDust) && ItemUtils.checkForInvalidItems(normalDust)) { - if (RecipeUtils.addShapedRecipe( - tinyDust, tinyDust, tinyDust, - tinyDust, tinyDust, tinyDust, - tinyDust, tinyDust, tinyDust, - normalDust)){ - Logger.WARNING("9 Tiny dust to 1 Dust Recipe: "+materialName+" - Success"); - } - else { - Logger.WARNING("9 Tiny dust to 1 Dust Recipe: "+materialName+" - Failed"); - } - - if (RecipeUtils.addShapedRecipe( - normalDust, null, null, - null, null, null, - null, null, null, - ItemUtils.getSimpleStack(tinyDust, 9))){ - Logger.WARNING("9 Tiny dust from 1 Recipe: "+materialName+" - Success"); - } - else { - Logger.WARNING("9 Tiny dust from 1 Recipe: "+materialName+" - Failed"); - } - } - - if (ItemUtils.checkForInvalidItems(smallDust) && ItemUtils.checkForInvalidItems(normalDust)) { - if (RecipeUtils.addShapedRecipe( - smallDust, smallDust, null, - smallDust, smallDust, null, - null, null, null, - normalDust)){ - Logger.WARNING("4 Small dust to 1 Dust Recipe: "+materialName+" - Success"); - } - else { - Logger.WARNING("4 Small dust to 1 Dust Recipe: "+materialName+" - Failed"); - } - if (RecipeUtils.addShapedRecipe( - null, normalDust, null, - null, null, null, - null, null, null, - ItemUtils.getSimpleStack(smallDust, 4))){ - Logger.WARNING("4 Small dust from 1 Dust Recipe: "+materialName+" - Success"); - } - else { - Logger.WARNING("4 Small dust from 1 Dust Recipe: "+materialName+" - Failed"); - } - } - - return output; - } - - public static Item generateSpecialUsePlate(final String internalName, final String displayName, final short[] rgb, - final int radioactivity) { - return generateSpecialUsePlate(internalName, displayName, Utils.rgbtoHexValue(rgb[0], rgb[1], rgb[2]), - radioactivity); - } - - public static Item generateSpecialUsePlate(final String internalName, final String displayName, - final String mFormula, final short[] rgb, final int radioactivity) { - return generateSpecialUsePlate(internalName, displayName, mFormula, Utils.rgbtoHexValue(rgb[0], rgb[1], rgb[2]), - radioactivity); - } - - public static Item generateSpecialUsePlate(final String internalName, final String displayName, final int rgb, - final int radioactivity) { - return new BaseItemPlate_OLD(internalName, displayName, rgb, radioactivity); - } - - public static Item generateSpecialUsePlate(final String internalName, final String displayName, - final String mFormula, final int rgb, final int radioactivity) { - return new BaseItemPlate_OLD(internalName, displayName, mFormula, rgb, radioactivity); - } - - - public static Item[] generateSpecialUseDusts(final Material material, final boolean onlyLargeDust) { - return generateSpecialUseDusts(material, onlyLargeDust, false); - } - - public static Item[] generateSpecialUseDusts(final Material material, final boolean onlyLargeDust, final boolean disableExtraRecipes) { - final String materialName = material.getLocalizedName(); - final String unlocalizedName = Utils.sanitizeString(materialName); - final int Colour = material.getRgbAsHex(); - final String aChemForm = material.vChemicalFormula; - final boolean isChemFormvalid = (aChemForm != null && aChemForm.length() > 0); - Item[] output = null; - if (onlyLargeDust == false) { - output = new Item[] { new BaseItemDustUnique("itemDust" + unlocalizedName, materialName, isChemFormvalid ? aChemForm : "", Colour, "Dust"), - new BaseItemDustUnique("itemDustSmall" + unlocalizedName, materialName, isChemFormvalid ? aChemForm : "", Colour, "Small"), - new BaseItemDustUnique("itemDustTiny" + unlocalizedName, materialName, isChemFormvalid ? aChemForm : "", Colour, "Tiny") }; - } else { - output = new Item[] { new BaseItemDustUnique("itemDust" + unlocalizedName, materialName, Colour, "Dust") }; - } - - new RecipeGen_DustGeneration(material, disableExtraRecipes); - - return output; - } - - public static MultiPickaxeBase generateMultiPick(final boolean GT_Durability, final Materials material) { - final ToolMaterial customMaterial = Utils.generateToolMaterialFromGT(material); - final int enchantLevel = material.mEnchantmentToolsLevel; - final Object enchant = new Pair(material.mEnchantmentTools, enchantLevel); - return generateMultiPick(GT_Durability, customMaterial, material.mDefaultLocalName, material.mDurability, - material.mRGBa, enchant); - } - - public static MultiPickaxeBase generateMultiPick(final Material material) { - final ToolMaterial customMaterial = Utils.generateToolMaterial(material); - return generateMultiPick(true, customMaterial, material.getLocalizedName(), (int) material.vDurability, - material.getRGBA(), null); - } - - public static MultiPickaxeBase generateMultiPick(final boolean GT_Durability, final ToolMaterial customMaterial, - final String name, final int durability, final short[] rgba, final Object enchantment) { - Logger.WARNING("Generating a Multi-Pick out of " + name); - final short[] rgb = rgba; - int dur = customMaterial.getMaxUses(); - Logger.WARNING("Determined durability for " + name + " is " + dur); - if (GT_Durability) { - dur = durability * 100; - Logger.WARNING("Using gregtech durability value, " + name + " is now " + dur + "."); - } else if (dur <= 0) { - dur = durability; - Logger.WARNING("Determined durability too low, " + name + " is now " + dur - + " based on the GT material durability."); - } - if (dur <= 0) { - Logger.WARNING("Still too low, " + name + " will now go unused."); - return null; - } - - Object enchant; - if (enchantment != null) { - if (enchantment instanceof Pair) { - enchant = enchantment; - } - } else { - enchant = null; - } - - final MultiPickaxeBase MP_Redstone = new MultiPickaxeBase(name + " Multipick", (customMaterial), dur, - Utils.rgbtoHexValue(rgb[0], rgb[1], rgb[2]), enchantment); - - if (MP_Redstone.isValid) { - return MP_Redstone; - } - Logger.WARNING("Pickaxe was not valid."); - return null; - } - - public static MultiSpadeBase generateMultiShovel(final boolean GT_Durability, final Materials material) { - final ToolMaterial customMaterial = Utils.generateToolMaterialFromGT(material); - return generateMultiShovel(GT_Durability, customMaterial, material.mDefaultLocalName, material.mDurability, - material.mRGBa); - } - - public static MultiSpadeBase generateMultiShovel(final Material material) { - final ToolMaterial customMaterial = Utils.generateToolMaterial(material); - return generateMultiShovel(true, customMaterial, material.getLocalizedName(), (int) material.vDurability, - material.getRGBA()); - } - - public static MultiSpadeBase generateMultiShovel(final boolean GT_Durability, final ToolMaterial customMaterial, - final String name, final int durability, final short[] rgba) { - Logger.WARNING("Generating a Multi-Spade out of " + name); - final short[] rgb = rgba; - int dur = customMaterial.getMaxUses(); - Logger.WARNING("Determined durability for " + name + " is " + dur); - if (GT_Durability) { - dur = durability * 100; - Logger.WARNING("Using gregtech durability value, " + name + " is now " + dur + "."); - } else if (dur <= 0) { - dur = durability; - Logger.WARNING("Determined durability too low, " + name + " is now " + dur - + " based on the GT material durability."); - } - if (dur <= 0) { - Logger.WARNING("Still too low, " + name + " will now go unused."); - return null; - } - final MultiSpadeBase MP_Redstone = new MultiSpadeBase(name + " Multispade", (customMaterial), dur, - Utils.rgbtoHexValue(rgb[0], rgb[1], rgb[2])); - - if (MP_Redstone.isValid) { - return MP_Redstone; - } - return null; - } - - public static BaseItemDecidust generateDecidust(final Materials material) { - if (GT_OreDictUnificator.get(OrePrefixes.dust, material, 1L) != null) { - final Material placeholder = MaterialUtils.generateMaterialFromGtENUM(material); - if (placeholder != null) { - generateDecidust(placeholder); - } - } - return null; - } - - public static BaseItemDecidust generateDecidust(final Material material) { - if ((material.getDust(1) != null) && MaterialUtils.hasValidRGBA(material.getRGBA())) { - final BaseItemDecidust Decidust = new BaseItemDecidust(material); - return Decidust; - } - return null; - } - - public static BaseItemCentidust generateCentidust(final Materials material) { - if (GT_OreDictUnificator.get(OrePrefixes.dust, material, 1L) != null) { - final Material placeholder = MaterialUtils.generateMaterialFromGtENUM(material); - if (placeholder != null) { - generateCentidust(placeholder); - } - } - return null; - } - - public static BaseItemCentidust generateCentidust(final Material material) { - if ((material.getDust(1) != null) && MaterialUtils.hasValidRGBA(material.getRGBA())) { - final BaseItemCentidust Centidust = new BaseItemCentidust(material); - return Centidust; - } - return null; - } - - public static boolean isRadioactive(final String materialName) { - int sRadiation = 0; - if (materialName.toLowerCase().contains("uranium")) { - sRadiation = 2; - } else if (materialName.toLowerCase().contains("plutonium")) { - sRadiation = 4; - } else if (materialName.toLowerCase().contains("thorium")) { - sRadiation = 1; - } - if (sRadiation >= 1) { - return true; - } - return false; - } - - public static int getRadioactivityLevel(final String materialName) { - int sRadiation = 0; - if (materialName.toLowerCase().contains("uranium")) { - sRadiation = 2; - } else if (materialName.toLowerCase().contains("plutonium")) { - sRadiation = 4; - } else if (materialName.toLowerCase().contains("thorium")) { - sRadiation = 1; - } - return sRadiation; - } - - public static String getArrayStackNames(ArrayList aStack) { - Object aType = aStack.get(0); - if (aType instanceof FluidStack) { - FluidStack[] aItems = new FluidStack[aStack.size()]; - for (int i=0;i aStack) { - Object aType = aStack.get(0); - if (aType instanceof FluidStack) { - FluidStack[] aItems = new FluidStack[aStack.size()]; - for (int i=0;i 0 ? ", " : "") + alph.getDisplayName() + " x" + alph.stackSize; - aPos++; - } - } - return itemNames; - } - - public static String[] getArrayStackNamesAsArray(final ItemStack[] aStack) { - final String[] itemNames = aStack == null ? new String[] {} : new String[aStack.length]; - if (aStack != null){ - Logger.INFO(""+aStack.length); - } - - if (aStack == null || aStack.length < 1) { - return itemNames; - } - - int arpos = 0; - for (final ItemStack alph : aStack) { - if (alph == null) { - continue; - } - try { - itemNames[arpos] = alph.getDisplayName(); - arpos++; - } - catch (Throwable t) { - t.printStackTrace(); - } - } - return itemNames; - - } - - public static String getFluidArrayStackNames(final FluidStack[] aStack) { - String itemNames = "Fluid Array: "; - for (final FluidStack alph : aStack) { - final String temp = itemNames; - itemNames = temp + ", " + alph.getFluid().getName() + " x" + alph.amount; - } - return itemNames; - - } - - public static ItemStack getGregtechCircuit(final int Meta) { - return ItemUtils.getItemStackWithMeta(LoadedMods.Gregtech, "gregtech:gt.integrated_circuit", "Gregtech Circuit", - Meta, 0); - } - - public static ItemStack[] getBlockDrops(final ArrayList blockDrops) { - if (blockDrops == null) { - return null; - } - if (blockDrops.isEmpty()) { - return null; - } - final ItemStack[] outputs = new ItemStack[blockDrops.size()]; - short forCounter = 0; - for (final ItemStack I : blockDrops) { - outputs[forCounter++] = I; - } - return outputs; - } - - private static Map mModidCache = new HashMap(); - - private static String getModId(final Item item) { - if (mModidCache.containsKey(item)) { - return mModidCache.get(item); - } - String value = ""; - try { - final GameRegistry.UniqueIdentifier id = GameRegistry.findUniqueIdentifierFor(item); - if (id != null) { - final String modname = (id.modId == null ? id.name : id.modId); - value = ((id == null) || id.modId.equals("")) ? "minecraft" : modname; - } - } catch (final Throwable t) { - try { - final UniqueIdentifier t2 = GameRegistry.findUniqueIdentifierFor(Block.getBlockFromItem(item)); - if (t2 != null) { - final String modname = (t2.modId == null ? t2.name : t2.modId); - value = ((t2 == null) || t2.modId.equals("")) ? "minecraft" : modname; - } - } catch (final Throwable t3) { - t3.printStackTrace(); - value = "bad modid"; - } - } - if (!mModidCache.containsKey(item)) { - return mModidCache.put(item, value); - } - return value; - } - - public static String getModId(final ItemStack key) { - return getModId(key.getItem()); - } - - // Take 2 - GT/GT++ Dusts - public static ItemStack getGregtechDust(final String oredictName, final int amount) { - final ArrayList oreDictList = OreDictionary.getOres(oredictName); - if (!oreDictList.isEmpty()) { - ItemStack returnvalue; - for (int xrc = 0; xrc < oreDictList.size(); xrc++) { - final String modid = getModId(oreDictList.get(xrc).getItem()); - if (modid != null && (modid.equals("gregtech") || modid.equals(CORE.MODID))) { - returnvalue = oreDictList.get(xrc).copy(); - returnvalue.stackSize = amount; - return returnvalue; - } - } - } - return getNonTinkersDust(oredictName, amount); - } - - // Anything But Tinkers Dust - public static ItemStack getNonTinkersDust(final String oredictName, final int amount) { - final ArrayList oreDictList = OreDictionary.getOres(oredictName); - if (!oreDictList.isEmpty()) { - ItemStack returnvalue; - for (int xrc = 0; xrc < oreDictList.size(); xrc++) { - final String modid = getModId(oreDictList.get(xrc).getItem()); - if (modid != null && !modid.equals("tconstruct")) { - returnvalue = oreDictList.get(xrc).copy(); - returnvalue.stackSize = amount; - return returnvalue; - } - } - } - // If only Tinkers dust exists, bow down and just use it. - return getItemStackOfAmountFromOreDictNoBroken(oredictName, amount); - } - - @Deprecated - public static ItemStack getGregtechOreStack(OrePrefixes mPrefix, Materials mMat, int mAmount) { - - ItemStack aTemp = getOrePrefixStack(mPrefix, mMat, mAmount); - if (aTemp != null) { - return aTemp; - } - - String mName = MaterialUtils.getMaterialName(mMat); - - String mItemName = mPrefix.name() + mName; - // Utils.LOG_INFO("[Component Maker] Trying to get "+mItemName+"."); - ItemStack gregstack = ItemUtils.getItemStackOfAmountFromOreDictNoBroken(mItemName, mAmount); - if (gregstack == null) { - // Utils.LOG_INFO("[Component Maker] Failed to get "+mItemName+"."); - return null; - } - // Utils.LOG_INFO("[Component Maker] Found "+mItemName+"."); - return (gregstack); - } - - public static ItemStack getOrePrefixStack(OrePrefixes mPrefix, Material mMat, int mAmount) { - - String mName = Utils.sanitizeString(mMat.getLocalizedName()); - - String mItemName = mPrefix.name() + mName; - ItemStack gregstack = ItemUtils.getItemStackOfAmountFromOreDictNoBroken(mItemName, mAmount); - if (gregstack == null) { - return null; - } - return (gregstack); - } - - public static ItemStack getOrePrefixStack(OrePrefixes mPrefix, Materials mMat, int mAmount) { - if (mPrefix == OrePrefixes.rod) { - mPrefix = OrePrefixes.stick; - } - ItemStack aGtStack = GT_OreDictUnificator.get(mPrefix, mMat, mAmount); - if (aGtStack == null) { - Logger.INFO( - "Failed to find `" + mPrefix + MaterialUtils.getMaterialName(mMat) + "` in OD. [Prefix Search]"); - return getErrorStack(mAmount, (mPrefix.toString()+MaterialUtils.getMaterialName(mMat)+" x"+mAmount)); - } else { - return aGtStack; - } - } - - public static ItemStack getErrorStack(int mAmount) { - return getErrorStack(mAmount, null); - } - - public static ItemStack getErrorStack(int mAmount, String aName) { - ItemStack g = getSimpleStack(ModItems.AAA_Broken, 1); - if (aName != null) { - //NBTUtils.setString(g, "Lore", EnumChatFormatting.RED+aName); - NBTUtils.setBookTitle(g, EnumChatFormatting.RED+aName); - //NBTUtils.setBookTitle(g, EnumChatFormatting.YELLOW+"Maybe Alkalus should know about this"); - } - return g; - } - - public static ItemStack[] getStackOfAllOreDictGroup(String oredictname) { - final ArrayList oreDictList = OreDictionary.getOres(oredictname); - if (!oreDictList.isEmpty()) { - final ItemStack[] returnValues = new ItemStack[oreDictList.size()]; - for (int i = 0; i < oreDictList.size(); i++) { - if (oreDictList.get(i) != null) { - returnValues[i] = oreDictList.get(i); - } - } - return returnValues.length > 0 ? returnValues : null; - } else { - return null; - } - } - - public static boolean registerFuel(ItemStack aBurnable, int burn) { - return CORE.burnables.add(new Pair(burn, aBurnable)); - } - - public static String getLocalizedNameOfBlock(BlockPos pos) { - Block block = pos.world.getBlock(pos.xPos, pos.yPos, pos.zPos); - int metaData = pos.world.getBlockMetadata(pos.xPos, pos.yPos, pos.zPos); - return LangUtils.getLocalizedNameOfBlock(block, metaData); - } - - public static boolean checkForInvalidItems(ItemStack mInput) { - return checkForInvalidItems(new ItemStack[] { mInput }); - } - - public static boolean checkForInvalidItems(ItemStack[] mInput) { - return checkForInvalidItems(mInput, new ItemStack[] {}); - } - - /** - * - * @param mInputs - * @return {@link Boolean} - True if {@link ItemStack}[] only contains valid - * items. - */ - public static boolean checkForInvalidItems(ItemStack[] mInputs, ItemStack[] mOutputs) { - if (mInputs == null || mOutputs == null) { - return false; - } - - if (mInputs.length > 0) { - for (ItemStack stack : mInputs) { - if (stack != null) { - if (stack.getItem() != null) { - if (stack.getItem() == ModItems.AAA_Broken - || stack.getItem().getClass() == ModItems.AAA_Broken.getClass()) { - return false; - } else if (stack.getItem() == ModItems.ZZZ_Empty - || stack.getItem().getClass() == ModItems.ZZZ_Empty.getClass()) { - return false; - } else { - continue; - } - } else { - continue; - } - } else { - return false; - } - } - } - if (mOutputs.length > 0) { - for (ItemStack stack : mOutputs) { - if (stack != null) { - if (stack.getItem() != null) { - if (stack.getItem() == ModItems.AAA_Broken - || stack.getItem().getClass() == ModItems.AAA_Broken.getClass()) { - return false; - } else if (stack.getItem() == ModItems.ZZZ_Empty - || stack.getItem().getClass() == ModItems.ZZZ_Empty.getClass()) { - return false; - } else { - continue; - } - } else { - continue; - } - } else { - return false; - } - } - } - - return true; - } - - - public static IInventory organiseInventory(IInventory aInputInventory) { - ItemStack[] p = new ItemStack[aInputInventory.getSizeInventory()]; - for (int o = 0; o < aInputInventory.getSizeInventory(); o++) { - p[o] = aInputInventory.getStackInSlot(o); - } - //ItemStack[] g = organiseInventory(p); - - IInventory aTemp = aInputInventory; - for (int i = 0; i < p.length; ++i) { - for (int j = i + 1; j < p.length; ++j) { - if (p[j] != null && (p[i] == null - || GT_Utility.areStacksEqual(p[i], p[j]))) { - GT_Utility.moveStackFromSlotAToSlotB(aTemp, aTemp, j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); - } - } - } - - /* - for (int o = 0; o < aInputInventory.getSizeInventory(); o++) { - aTemp.setInventorySlotContents(o, g[o]); - }*/ - return aTemp; - } - - - public static ItemStack[] organiseInventory(ItemStack[] aInputs) { - - //Update Slots - int aInvSize = aInputs.length; - ItemStack[] newArray = new ItemStack[aInvSize]; - - - //Try merge stacks - for (int i = 0; i < aInvSize; i++) { - for (int i2 = 0; i2 < aInvSize; i2++) { - if (i != i2) { - ItemStack[] t1 = new ItemStack[] {aInputs[i], aInputs[i2]}; - if (t1[0] == null || t1[1] == null) { - continue; - } - else if (!GT_Utility.areStacksEqual(t1[0], t1[1])) { - continue; - } - //Try Merge - else { - - if (GT_Utility.areStacksEqual(t1[0], t1[1])) { - while ((t1[0].stackSize < 64 && t1[1].stackSize > 0)) { - t1[0].stackSize++; - t1[1].stackSize--; - if (t1[1].stackSize <= 0) { - t1[1] = null; - break; - } - if (t1[0].stackSize == 64) { - break; - } - } - newArray[i] = t1[1]; - newArray[i2] = t1[0]; - } - } - } - } - } - - ItemStack[] newArray2 = new ItemStack[aInvSize]; - - //Move nulls to end - int count2 = 0; - for (int i = 0; i < aInvSize; i++) - if (newArray[i] != null) - newArray2[count2++] = newArray[i]; - while (count2 < aInvSize) - newArray2[count2++] = null; - - return newArray2; - - - } - - public static String getFluidName(FluidStack aFluid) { - return aFluid != null ? aFluid.getFluid().getLocalizedName(aFluid) : "NULL"; - } - - public static String getFluidName(Fluid aFluid) { - return aFluid != null ? aFluid.getLocalizedName() : "NULL"; - } - - public static String getItemName(ItemStack aStack) { - if (aStack == null) { - return "ERROR - Empty Stack"; - } - String aDisplay = null; - try { - aDisplay = ("" + StatCollector - .translateToLocal(aStack.getItem().getUnlocalizedNameInefficiently(aStack) + ".name")) - .trim(); - if (aStack.hasTagCompound()) { - if (aStack.stackTagCompound != null && aStack.stackTagCompound.hasKey("display", 10)) { - NBTTagCompound nbttagcompound = aStack.stackTagCompound.getCompoundTag("display"); - - if (nbttagcompound.hasKey("Name", 8)) { - aDisplay = nbttagcompound.getString("Name"); - } - } - } - } catch (Throwable t) { - - } - if (aDisplay == null || aDisplay.length() <= 0) { - aDisplay = aStack.getUnlocalizedName() + ":" + aStack.getItemDamage(); - } else { - aDisplay += " | Meta: " + aStack.getItemDamage(); - } - return aDisplay; - } - - public static String getUnlocalizedItemName(ItemStack aStack) { - if (aStack == null) { - return "ERROR.Empty.Stack"; - } - String aDisplay = null; - try { - aDisplay = (aStack.getUnlocalizedName()).trim(); - } - catch (Throwable t) { - aDisplay = aStack.getItem().getUnlocalizedName(); - } - if (aDisplay == null || aDisplay.length() <= 0) { - aDisplay = aStack.getItem().getUnlocalizedNameInefficiently(aStack); - } - return aDisplay; - } - - public static boolean isItemGregtechTool(ItemStack aStack) { - if (aStack == null) { - return false; - } - final Item mItem = aStack.getItem(); - final Item aSkookum = ItemUtils.getItemFromFQRN("miscutils:gt.plusplus.metatool.01"); - final Class aSkookClass = aSkookum.getClass(); - if (aSkookClass.isInstance(mItem) || mItem instanceof GT_MetaGenerated_Tool_01 || mItem instanceof MetaGeneratedGregtechTools || mItem instanceof Gregtech_MetaTool || mItem == aSkookum) { - return true; - } - return false; - } - - public static boolean isToolWrench(ItemStack aWrench) { - if (isItemGregtechTool(aWrench) && (aWrench.getItemDamage() == 16 || aWrench.getItemDamage() == 120 || aWrench.getItemDamage() == 122 || aWrench.getItemDamage() == 124 || aWrench.getItemDamage() == 7734)) { - return true; - } - return false; - } - - public static boolean isToolMallet(ItemStack aMallet) { - if (isItemGregtechTool(aMallet) && (aMallet.getItemDamage() == 14)) { - return true; - } - return false; - } - - public static boolean isToolScrewdriver(ItemStack aScrewdriver) { - if (isItemGregtechTool(aScrewdriver) && (aScrewdriver.getItemDamage() == 22 || aScrewdriver.getItemDamage() == 150)) { - return true; - } - return false; - } - - public static boolean isToolCrowbar(ItemStack aCrowbar) { - if (isItemGregtechTool(aCrowbar) && (aCrowbar.getItemDamage() == 20)) { - return true; - } - return false; - } - - public static boolean isToolWirecutters(ItemStack aWirecutters) { - if (isItemGregtechTool(aWirecutters) && (aWirecutters.getItemDamage() == 26)) { - return true; - } - return false; - } - - public static boolean isToolHammer(ItemStack aHammer) { - if (isItemGregtechTool(aHammer) && (aHammer.getItemDamage() == 12 || aHammer.getItemDamage() == 7734)) { - return true; - } - return false; - } - - public static boolean isToolSolderingIron(ItemStack aSoldering) { - if (isItemGregtechTool(aSoldering) && (aSoldering.getItemDamage() == 160)) { - return true; - } - return false; - } - - public static ItemStack[] cleanItemStackArray(ItemStack[] input) { - int aArraySize = input.length; - ItemStack[] aOutput = new ItemStack[aArraySize]; - AutoMap aCleanedItems = new AutoMap(); - for (ItemStack checkStack : input) { - if (ItemUtils.checkForInvalidItems(checkStack)) { - aCleanedItems.put(checkStack); - } - } - for (int i=0;i= 1 && cap >= aAmount) { - ItemStack aDepStack = aStack.copy(); - aDepStack.stackSize = (MathUtils.balance((aDepStack.stackSize - 1), 0, 64)); - if (aDepStack.stackSize > 0) { - return aDepStack; - } - } - return getNullStack(); - } - - public static boolean isControlCircuit(ItemStack aStack) { - if (aStack != null) { - Item aItem = aStack.getItem(); - if (aItem == CI.getNumberedBioCircuit(0).getItem() || aItem == CI.getNumberedCircuit(0).getItem() || aItem == CI.getNumberedAdvancedCircuit(0).getItem()) { - return true; - } - } - return false; - } - - public static boolean isCatalyst(ItemStack aStack) { - if (GT_Utility.areStacksEqual(aStack, GenericChem.mBlueCatalyst, true)) { - return true; - } - if (GT_Utility.areStacksEqual(aStack, GenericChem.mBrownCatalyst, true)) { - return true; - } - if (GT_Utility.areStacksEqual(aStack, GenericChem.mOrangeCatalyst, true)) { - return true; - } - if (GT_Utility.areStacksEqual(aStack, GenericChem.mPurpleCatalyst, true)) { - return true; - } - if (GT_Utility.areStacksEqual(aStack, GenericChem.mRedCatalyst, true)) { - return true; - } - if (GT_Utility.areStacksEqual(aStack, GenericChem.mYellowCatalyst, true)) { - return true; - } - if (GT_Utility.areStacksEqual(aStack, GenericChem.mPinkCatalyst, true)) { - return true; - } - if (GT_Utility.areStacksEqual(aStack, GenericChem.mFormaldehydeCatalyst, true)) { - return true; - } - if (GT_Utility.areStacksEqual(aStack, GenericChem.mSolidAcidCatalyst, true)) { - return true; - } - if (GT_Utility.areStacksEqual(aStack, GenericChem.mInfiniteMutationCatalyst, true)) { - return true; - } - if (GT_Utility.areStacksEqual(aStack, AgriculturalChem.mGreenCatalyst, true)) { - return true; - } - return false; - } - - public static boolean isMillingBall(ItemStack aStack) { - if (GT_Utility.areStacksEqual(aStack, GenericChem.mMillingBallAlumina, true)) { - return true; - } - if (GT_Utility.areStacksEqual(aStack, GenericChem.mMillingBallSoapstone, true)) { - return true; - } - return false; - } - - public static String getLocalizedNameOfBlock(Block aBlock, int aMeta) { - return LangUtils.getLocalizedNameOfBlock(aBlock, aMeta); - } - - - - public static boolean doesItemListEntryExist(String string) { - ItemList[] aListValues = ItemList.class.getEnumConstants(); - for (ItemList aItem : aListValues) { - if (aItem != null) { - if (aItem.name().equals(string) || aItem.name().toLowerCase().equals(string.toLowerCase())) { - return true; - } - } - } - return false; - } - - public static ItemList getValueOfItemList(String string, ItemList aOther) { - ItemList[] aListValues = ItemList.class.getEnumConstants(); - for (ItemList aItem : aListValues) { - if (aItem != null) { - if (aItem.name().equals(string) || aItem.name().toLowerCase().equals(string.toLowerCase())) { - return aItem; - } - } - } - Logger.INFO("Tried to obtain '"+string+"' from the GT ItemList, however it does not exist."); - if (aOther != null) { - Logger.INFO("Using fallback option instead - "+aOther.name()); - } - return aOther; - } - - public static ItemStack getValueOfItemList(String string, int aAmount, ItemList aOther) { - return getValueOfItemList(string, aOther).get(aAmount); - } - - public static ItemStack getValueOfItemList(String string, int aAmount, ItemStack aOther) { - ItemList[] aListValues = ItemList.class.getEnumConstants(); - for (ItemList aItem : aListValues) { - if (aItem != null) { - if (aItem.name().equals(string) || aItem.name().toLowerCase().equals(string.toLowerCase())) { - return aItem.get(aAmount); - } - } - } - Logger.INFO("Tried to obtain '"+string+"' from the GT ItemList, however it does not exist."); - if (aOther != null) { - Logger.INFO("Using fallback option instead - "+ItemUtils.getItemName(aOther)); - } - return aOther; - } - - public static boolean areItemsEqual(ItemStack aStack1, ItemStack aStack2) { - return areItemsEqual(aStack1, aStack2, true); - } - - public static boolean areItemsEqual(ItemStack aStack1, ItemStack aStack2, boolean aIgnoreNBT) { - return GT_Utility.areStacksEqual(aStack1, aStack2, aIgnoreNBT); - } - + public static ItemStack getSimpleStack(final Item x) { + return getSimpleStack(x, 1); + } + + public static ItemStack getSimpleStack(final Block x) { + return simpleMetaStack(Item.getItemFromBlock(x), 0, 1); + } + + public static ItemStack getSimpleStack(final Block x, int i) { + if (i == 0) { + return getSimpleStack(x, i, 1); + } + + return getSimpleStack(x, 0, i); + } + + public static ItemStack getSimpleStack(final Block x, int meta, int i) { + return simpleMetaStack(Item.getItemFromBlock(x), meta, i); + } + + public static ItemStack getSimpleStack(final Item x, final int i) { + try { + final ItemStack r = new ItemStack(x, i); + return r.copy(); + } catch (final Throwable e) { + return null; + } + } + + public static ItemStack getSimpleStack(final ItemStack x, final int i) { + try { + final ItemStack r = x.copy(); + r.stackSize = i; + return r; + } catch (final Throwable e) { + return null; + } + } + + public static final int WILDCARD_VALUE = Short.MAX_VALUE; + + public static ItemStack getWildcardStack(final Item x) { + final ItemStack y = new ItemStack(x, 1, WILDCARD_VALUE); + return y; + } + + public static ItemStack getWildcardStack(final ItemStack x) { + final ItemStack y = ItemUtils.simpleMetaStack(x, WILDCARD_VALUE, 1); + return y; + } + + public static ItemStack getIC2Cell(final String S) { + final ItemStack moreTemp = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell" + S, 1); + + if (moreTemp == null) { + final int cellID = 0; + final ItemStack temp = GT_ModHandler.getModItem("IC2", "itemCellEmpty", 1L, cellID); + return temp != null ? temp : null; + } + + return moreTemp; + } + + public static ItemStack getIC2Cell(final int meta) { + final ItemStack temp = GT_ModHandler.getModItem("IC2", "itemCellEmpty", 1L, meta); + return temp != null ? temp : null; + } + + public static ItemStack getEmptyCell() { + return getEmptyCell(1); + } + + public static ItemStack getEmptyCell(int i) { + if (ItemList.Cell_Empty.hasBeenSet()) { + return ItemList.Cell_Empty.get(i); + } + final ItemStack temp = GT_ModHandler.getModItem("IC2", "itemCellEmpty", i, 0); + return temp != null ? temp : null; + } + + public static void getItemForOreDict( + final String FQRN, final String oreDictName, final String itemName, final int meta) { + try { + Item em = null; + final Item em1 = getItemFromFQRN(FQRN); + // Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); + if (em1 != null) { + em = em1; + } + if (em != null) { + + final ItemStack metaStack = new ItemStack(em, 1, meta); + GT_OreDictUnificator.registerOre(oreDictName, metaStack); + + /* + * ItemStack itemStackWithMeta = new ItemStack(em,1,meta); + * GT_OreDictUnificator.registerOre(oreDictName, new + * ItemStack(itemStackWithMeta.getItem())); + */ + } + } catch (final NullPointerException e) { + Logger.ERROR(itemName + " not found. [NULL]"); + } + } + + public static void addItemToOreDictionary(ItemStack stack, final String oreDictName, boolean useWildcardMeta) { + if (useWildcardMeta) { + stack = ItemUtils.getWildcardStack(stack); + } + try { + OreDictionary.registerOre(oreDictName, stack); + } catch (final NullPointerException e) { + Logger.ERROR(ItemUtils.getItemName(stack) + " not registered. [NULL]"); + } + } + + public static void addItemToOreDictionary(final ItemStack stack, final String oreDictName) { + addItemToOreDictionary(stack, oreDictName, false); + } + + public static ItemStack getItemStackWithMeta( + final boolean MOD, final String FQRN, final String itemName, final int meta, final int itemstackSize) { + if (MOD) { + try { + Item em = null; + final Item em1 = getItemFromFQRN(FQRN); + // Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); + if (em1 != null) { + if (null == em) { + em = em1; + } + if (em != null) { + final ItemStack metaStack = new ItemStack(em, itemstackSize, meta); + return metaStack; + } + } + return null; + } catch (final NullPointerException e) { + Logger.ERROR(itemName + " not found. [NULL]"); + return null; + } + } + return null; + } + + public static ItemStack simpleMetaStack(final String FQRN, final int meta, final int itemstackSize) { + try { + Item em = null; + final Item em1 = getItemFromFQRN(FQRN); + // Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); + if (em1 != null) { + if (null == em) { + em = em1; + } + if (em != null) { + final ItemStack metaStack = new ItemStack(em, itemstackSize, meta); + return metaStack; + } + } + return null; + } catch (final NullPointerException e) { + Logger.ERROR(FQRN + " not found. [NULL]"); + return null; + } + } + + public static ItemStack simpleMetaStack(ItemStack simpleStack, int meta, int size) { + return simpleMetaStack(simpleStack.getItem(), meta, size); + } + + public static ItemStack simpleMetaStack(final Item item, int meta, int size) { + if (item == null) { + return null; + } + if (meta < 0 || meta > Short.MAX_VALUE) { + meta = 0; + } + if (size < 0 || size > 64) { + size = 1; + } + // Logger.INFO("Found Metastack: " + item.getUnlocalizedName() + ":" + meta); + // Logger.INFO(""+ReflectionUtils.getMethodName(0)); + // Logger.INFO(""+ReflectionUtils.getMethodName(1)); + // Logger.INFO(""+ReflectionUtils.getMethodName(2)); + // Logger.INFO(""+ReflectionUtils.getMethodName(3)); + // Logger.INFO(""+ReflectionUtils.getMethodName(4)); + final ItemStack metaStack = new ItemStack(item, size, meta); + return metaStack; + } + + public static ItemStack simpleMetaStack(final Block block, final int meta, final int size) { + return simpleMetaStack(Item.getItemFromBlock(block), meta, size); + } + + public static ItemStack getCorrectStacktype(final String fqrn, final int stackSize) { + final String oreDict = "ore:"; + ItemStack temp; + if (fqrn.toLowerCase().contains(oreDict.toLowerCase())) { + final String sanitizedName = fqrn.replace(oreDict, ""); + temp = ItemUtils.getItemStackFromFQRN(sanitizedName, stackSize); + return temp; + } + final String[] fqrnSplit = fqrn.split(":"); + String temp1; + String temp2; + temp1 = fqrnSplit[1]; + if (fqrnSplit.length < 3) { + temp2 = "0"; + } else { + temp2 = fqrnSplit[2]; + } + temp = ItemUtils.getItemStackWithMeta(LoadedMods.MiscUtils, fqrn, temp1, Integer.parseInt(temp2), stackSize); + return temp; + } + + public static ItemStack getCorrectStacktype(final Object item_Input, final int stackSize) { + if (item_Input instanceof String) { + return getItemStackOfAmountFromOreDictNoBroken((String) item_Input, stackSize); + } else if (item_Input instanceof ItemStack) { + return (ItemStack) item_Input; + } + return null; + } + + public static Item getItemFromFQRN(final String fqrn) // fqrn = fully qualified resource name + { + final String[] fqrnSplit = fqrn.split(":"); + return GameRegistry.findItem(fqrnSplit[0], fqrnSplit[1]); + } + + public static ItemStack getItemStackFromFQRN( + final String fqrn, final int Size) // fqrn = fully qualified resource name + { + Logger.INFO("Trying to split string '" + fqrn + "'."); + final String[] fqrnSplit = fqrn.split(":"); + if (fqrnSplit.length < 2) { + return null; + } else { + if (fqrnSplit.length == 2) { + Logger.INFO("Mod: " + fqrnSplit[0] + ", Item: " + fqrnSplit[1]); + return GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size); + } else if (fqrnSplit.length == 3 && fqrnSplit[2] != null && fqrnSplit[2].length() > 0) { + Logger.INFO("Mod: " + fqrnSplit[0] + ", Item: " + fqrnSplit[1] + ", Meta: " + fqrnSplit[2]); + ItemStack aStack = GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size); + int aMeta = Integer.parseInt(fqrnSplit[2]); + if (aStack != null && (aMeta >= 0 && aMeta <= Short.MAX_VALUE)) { + return ItemUtils.simpleMetaStack(aStack, aMeta, Size); + } else { + Logger.INFO("Could not find instance of Item: " + fqrnSplit[1]); + } + } + } + return null; + } + + public static void generateSpawnEgg( + final String entityModID, final String parSpawnName, final int colourEgg, final int colourOverlay) { + final Item itemSpawnEgg = new BasicSpawnEgg(entityModID, parSpawnName, colourEgg, colourOverlay) + .setUnlocalizedName("spawn_egg_" + parSpawnName.toLowerCase()) + .setTextureName(CORE.MODID + ":spawn_egg"); + GameRegistry.registerItem(itemSpawnEgg, "spawnEgg" + parSpawnName); + } + + public static ItemStack[] validItemsForOreDict(final String oredictName) { + final List validNames = MaterialUtils.oreDictValuesForEntry(oredictName); + final ItemStack[] inputs = new ItemStack[validNames.size()]; + for (int i = 0; i < validNames.size(); i++) { + inputs[i] = (ItemStack) validNames.get(i); + } + return inputs; + } + + public static ItemStack getItemStackOfAmountFromOreDict(String oredictName, final int amount) { + String mTemp = oredictName; + + if (oredictName.contains("-") || oredictName.contains("_")) { + mTemp = Utils.sanitizeString(mTemp, new char[] {'-', '_'}); + } else { + mTemp = Utils.sanitizeString(mTemp); + } + + if (oredictName.contains("rod")) { + String s = "stick" + oredictName.substring(3); + oredictName = s; + } + + // Banned Materials and replacements for GT5.8 compat. + + if (oredictName.toLowerCase().contains("ingotclay")) { + return getSimpleStack(Items.clay_ball, amount); + } + + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + if (oredictName.toLowerCase().contains("rutile")) { + mTemp = oredictName.replace("Rutile", "Titanium"); + } + if (oredictName.toLowerCase().contains("vanadiumsteel")) { + mTemp = oredictName.replace("VanadiumSteel", "StainlessSteel"); + } + } + final ArrayList oreDictList = OreDictionary.getOres(mTemp); + if (!oreDictList.isEmpty()) { + final ItemStack returnValue = oreDictList.get(0).copy(); + returnValue.stackSize = amount; + return returnValue; + } + Logger.INFO("Failed to find `" + oredictName + "` in OD."); + return getErrorStack(amount, oredictName + " x" + amount); + // return getItemStackOfAmountFromOreDictNoBroken(mTemp, amount); + } + + public static ItemStack getItemStackOfAmountFromOreDictNoBroken(String oredictName, final int amount) { + if (CORE_Preloader.DEBUG_MODE) { + Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(1)); + Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(2)); + Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(3)); + Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(4)); + Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(5)); + } + + try { + + if (oredictName.contains("-") || oredictName.contains("_")) { + oredictName = Utils.sanitizeString(oredictName, new char[] {'-', '_'}); + } else { + oredictName = Utils.sanitizeString(oredictName); + } + + // Adds a check to grab dusts using GT methodology if possible. + ItemStack returnValue = null; + if (oredictName.toLowerCase().contains("dust")) { + final String MaterialName = oredictName.toLowerCase().replace("dust", ""); + final Materials m = Materials.get(MaterialName); + if (m != null && m != Materials._NULL) { + returnValue = getGregtechDust(m, amount); + if (checkForInvalidItems(returnValue)) { + return returnValue; + } + } + } + if (returnValue == null) { + returnValue = getItemStackOfAmountFromOreDict(oredictName, amount); + if (ItemUtils.checkForInvalidItems(returnValue)) { + return returnValue.copy(); + } + } + + Logger.RECIPE(oredictName + " was not valid."); + return null; + } catch (final Throwable t) { + return null; + } + } + + public static ItemStack getGregtechDust(final Materials material, final int amount) { + final ItemStack returnValue = GT_OreDictUnificator.get(OrePrefixes.dust, material, 1L); + if (returnValue != null) { + if (ItemUtils.checkForInvalidItems(returnValue)) { + return returnValue.copy(); + } + } + Logger.WARNING(material + " was not valid."); + return null; + } + + // NullFormula + public static Item[] generateSpecialUseDusts( + final String unlocalizedName, final String materialName, final int Colour) { + return generateSpecialUseDusts(unlocalizedName, materialName, "NullFormula", Colour); + } + + public static Item[] generateSpecialUseDusts( + final String unlocalizedName, final String materialName, String mChemForm, final int Colour) { + final Item[] output = { + new BaseItemDustUnique("itemDust" + unlocalizedName, materialName, mChemForm, Colour, "Dust"), + new BaseItemDustUnique("itemDustSmall" + unlocalizedName, materialName, mChemForm, Colour, "Small"), + new BaseItemDustUnique("itemDustTiny" + unlocalizedName, materialName, mChemForm, Colour, "Tiny") + }; + + // Generate Shaped/Shapeless Recipes + + final ItemStack normalDust = ItemUtils.getSimpleStack(output[0]); + final ItemStack smallDust = ItemUtils.getSimpleStack(output[1]); + final ItemStack tinyDust = ItemUtils.getSimpleStack(output[2]); + + CORE.RA.addpackagerRecipe(ItemList.Schematic_Dust.get(0), smallDust, tinyDust, normalDust); + + if (ItemUtils.checkForInvalidItems(tinyDust) && ItemUtils.checkForInvalidItems(normalDust)) { + if (RecipeUtils.addShapedRecipe( + tinyDust, + tinyDust, + tinyDust, + tinyDust, + tinyDust, + tinyDust, + tinyDust, + tinyDust, + tinyDust, + normalDust)) { + Logger.WARNING("9 Tiny dust to 1 Dust Recipe: " + materialName + " - Success"); + } else { + Logger.WARNING("9 Tiny dust to 1 Dust Recipe: " + materialName + " - Failed"); + } + + if (RecipeUtils.addShapedRecipe( + normalDust, + null, + null, + null, + null, + null, + null, + null, + null, + ItemUtils.getSimpleStack(tinyDust, 9))) { + Logger.WARNING("9 Tiny dust from 1 Recipe: " + materialName + " - Success"); + } else { + Logger.WARNING("9 Tiny dust from 1 Recipe: " + materialName + " - Failed"); + } + } + + if (ItemUtils.checkForInvalidItems(smallDust) && ItemUtils.checkForInvalidItems(normalDust)) { + if (RecipeUtils.addShapedRecipe( + smallDust, smallDust, null, smallDust, smallDust, null, null, null, null, normalDust)) { + Logger.WARNING("4 Small dust to 1 Dust Recipe: " + materialName + " - Success"); + } else { + Logger.WARNING("4 Small dust to 1 Dust Recipe: " + materialName + " - Failed"); + } + if (RecipeUtils.addShapedRecipe( + null, + normalDust, + null, + null, + null, + null, + null, + null, + null, + ItemUtils.getSimpleStack(smallDust, 4))) { + Logger.WARNING("4 Small dust from 1 Dust Recipe: " + materialName + " - Success"); + } else { + Logger.WARNING("4 Small dust from 1 Dust Recipe: " + materialName + " - Failed"); + } + } + + return output; + } + + public static Item generateSpecialUsePlate( + final String internalName, final String displayName, final short[] rgb, final int radioactivity) { + return generateSpecialUsePlate( + internalName, displayName, Utils.rgbtoHexValue(rgb[0], rgb[1], rgb[2]), radioactivity); + } + + public static Item generateSpecialUsePlate( + final String internalName, + final String displayName, + final String mFormula, + final short[] rgb, + final int radioactivity) { + return generateSpecialUsePlate( + internalName, displayName, mFormula, Utils.rgbtoHexValue(rgb[0], rgb[1], rgb[2]), radioactivity); + } + + public static Item generateSpecialUsePlate( + final String internalName, final String displayName, final int rgb, final int radioactivity) { + return new BaseItemPlate_OLD(internalName, displayName, rgb, radioactivity); + } + + public static Item generateSpecialUsePlate( + final String internalName, + final String displayName, + final String mFormula, + final int rgb, + final int radioactivity) { + return new BaseItemPlate_OLD(internalName, displayName, mFormula, rgb, radioactivity); + } + + public static Item[] generateSpecialUseDusts(final Material material, final boolean onlyLargeDust) { + return generateSpecialUseDusts(material, onlyLargeDust, false); + } + + public static Item[] generateSpecialUseDusts( + final Material material, final boolean onlyLargeDust, final boolean disableExtraRecipes) { + final String materialName = material.getLocalizedName(); + final String unlocalizedName = Utils.sanitizeString(materialName); + final int Colour = material.getRgbAsHex(); + final String aChemForm = material.vChemicalFormula; + final boolean isChemFormvalid = (aChemForm != null && aChemForm.length() > 0); + Item[] output = null; + if (onlyLargeDust == false) { + output = new Item[] { + new BaseItemDustUnique( + "itemDust" + unlocalizedName, materialName, isChemFormvalid ? aChemForm : "", Colour, "Dust"), + new BaseItemDustUnique( + "itemDustSmall" + unlocalizedName, + materialName, + isChemFormvalid ? aChemForm : "", + Colour, + "Small"), + new BaseItemDustUnique( + "itemDustTiny" + unlocalizedName, + materialName, + isChemFormvalid ? aChemForm : "", + Colour, + "Tiny") + }; + } else { + output = new Item[] {new BaseItemDustUnique("itemDust" + unlocalizedName, materialName, Colour, "Dust")}; + } + + new RecipeGen_DustGeneration(material, disableExtraRecipes); + + return output; + } + + public static MultiPickaxeBase generateMultiPick(final boolean GT_Durability, final Materials material) { + final ToolMaterial customMaterial = Utils.generateToolMaterialFromGT(material); + final int enchantLevel = material.mEnchantmentToolsLevel; + final Object enchant = new Pair(material.mEnchantmentTools, enchantLevel); + return generateMultiPick( + GT_Durability, + customMaterial, + material.mDefaultLocalName, + material.mDurability, + material.mRGBa, + enchant); + } + + public static MultiPickaxeBase generateMultiPick(final Material material) { + final ToolMaterial customMaterial = Utils.generateToolMaterial(material); + return generateMultiPick( + true, + customMaterial, + material.getLocalizedName(), + (int) material.vDurability, + material.getRGBA(), + null); + } + + public static MultiPickaxeBase generateMultiPick( + final boolean GT_Durability, + final ToolMaterial customMaterial, + final String name, + final int durability, + final short[] rgba, + final Object enchantment) { + Logger.WARNING("Generating a Multi-Pick out of " + name); + final short[] rgb = rgba; + int dur = customMaterial.getMaxUses(); + Logger.WARNING("Determined durability for " + name + " is " + dur); + if (GT_Durability) { + dur = durability * 100; + Logger.WARNING("Using gregtech durability value, " + name + " is now " + dur + "."); + } else if (dur <= 0) { + dur = durability; + Logger.WARNING("Determined durability too low, " + name + " is now " + dur + + " based on the GT material durability."); + } + if (dur <= 0) { + Logger.WARNING("Still too low, " + name + " will now go unused."); + return null; + } + + Object enchant; + if (enchantment != null) { + if (enchantment instanceof Pair) { + enchant = enchantment; + } + } else { + enchant = null; + } + + final MultiPickaxeBase MP_Redstone = new MultiPickaxeBase( + name + " Multipick", (customMaterial), dur, Utils.rgbtoHexValue(rgb[0], rgb[1], rgb[2]), enchantment); + + if (MP_Redstone.isValid) { + return MP_Redstone; + } + Logger.WARNING("Pickaxe was not valid."); + return null; + } + + public static MultiSpadeBase generateMultiShovel(final boolean GT_Durability, final Materials material) { + final ToolMaterial customMaterial = Utils.generateToolMaterialFromGT(material); + return generateMultiShovel( + GT_Durability, customMaterial, material.mDefaultLocalName, material.mDurability, material.mRGBa); + } + + public static MultiSpadeBase generateMultiShovel(final Material material) { + final ToolMaterial customMaterial = Utils.generateToolMaterial(material); + return generateMultiShovel( + true, customMaterial, material.getLocalizedName(), (int) material.vDurability, material.getRGBA()); + } + + public static MultiSpadeBase generateMultiShovel( + final boolean GT_Durability, + final ToolMaterial customMaterial, + final String name, + final int durability, + final short[] rgba) { + Logger.WARNING("Generating a Multi-Spade out of " + name); + final short[] rgb = rgba; + int dur = customMaterial.getMaxUses(); + Logger.WARNING("Determined durability for " + name + " is " + dur); + if (GT_Durability) { + dur = durability * 100; + Logger.WARNING("Using gregtech durability value, " + name + " is now " + dur + "."); + } else if (dur <= 0) { + dur = durability; + Logger.WARNING("Determined durability too low, " + name + " is now " + dur + + " based on the GT material durability."); + } + if (dur <= 0) { + Logger.WARNING("Still too low, " + name + " will now go unused."); + return null; + } + final MultiSpadeBase MP_Redstone = new MultiSpadeBase( + name + " Multispade", (customMaterial), dur, Utils.rgbtoHexValue(rgb[0], rgb[1], rgb[2])); + + if (MP_Redstone.isValid) { + return MP_Redstone; + } + return null; + } + + public static BaseItemDecidust generateDecidust(final Materials material) { + if (GT_OreDictUnificator.get(OrePrefixes.dust, material, 1L) != null) { + final Material placeholder = MaterialUtils.generateMaterialFromGtENUM(material); + if (placeholder != null) { + generateDecidust(placeholder); + } + } + return null; + } + + public static BaseItemDecidust generateDecidust(final Material material) { + if ((material.getDust(1) != null) && MaterialUtils.hasValidRGBA(material.getRGBA())) { + final BaseItemDecidust Decidust = new BaseItemDecidust(material); + return Decidust; + } + return null; + } + + public static BaseItemCentidust generateCentidust(final Materials material) { + if (GT_OreDictUnificator.get(OrePrefixes.dust, material, 1L) != null) { + final Material placeholder = MaterialUtils.generateMaterialFromGtENUM(material); + if (placeholder != null) { + generateCentidust(placeholder); + } + } + return null; + } + + public static BaseItemCentidust generateCentidust(final Material material) { + if ((material.getDust(1) != null) && MaterialUtils.hasValidRGBA(material.getRGBA())) { + final BaseItemCentidust Centidust = new BaseItemCentidust(material); + return Centidust; + } + return null; + } + + public static boolean isRadioactive(final String materialName) { + int sRadiation = 0; + if (materialName.toLowerCase().contains("uranium")) { + sRadiation = 2; + } else if (materialName.toLowerCase().contains("plutonium")) { + sRadiation = 4; + } else if (materialName.toLowerCase().contains("thorium")) { + sRadiation = 1; + } + if (sRadiation >= 1) { + return true; + } + return false; + } + + public static int getRadioactivityLevel(final String materialName) { + int sRadiation = 0; + if (materialName.toLowerCase().contains("uranium")) { + sRadiation = 2; + } else if (materialName.toLowerCase().contains("plutonium")) { + sRadiation = 4; + } else if (materialName.toLowerCase().contains("thorium")) { + sRadiation = 1; + } + return sRadiation; + } + + public static String getArrayStackNames(ArrayList aStack) { + Object aType = aStack.get(0); + if (aType instanceof FluidStack) { + FluidStack[] aItems = new FluidStack[aStack.size()]; + for (int i = 0; i < aItems.length; i++) { + aItems[i] = (FluidStack) aStack.get(i); + } + return getArrayStackNames(aItems); + } + if (aType instanceof ItemStack) { + ItemStack[] aItems = new ItemStack[aStack.size()]; + for (int i = 0; i < aItems.length; i++) { + aItems[i] = (ItemStack) aStack.get(i); + } + return getArrayStackNames(aItems); + } + return ""; + } + + public static String getArrayStackNames(final AutoMap aStack) { + Object aType = aStack.get(0); + if (aType instanceof FluidStack) { + FluidStack[] aItems = new FluidStack[aStack.size()]; + for (int i = 0; i < aItems.length; i++) { + aItems[i] = (FluidStack) aStack.get(i); + } + return getArrayStackNames(aItems); + } + if (aType instanceof ItemStack) { + ItemStack[] aItems = new ItemStack[aStack.size()]; + for (int i = 0; i < aItems.length; i++) { + aItems[i] = (ItemStack) aStack.get(i); + } + return getArrayStackNames(aItems); + } + return ""; + } + + public static String getArrayStackNames(final FluidStack[] aStack) { + String itemNames = "Fluid Array: "; + for (final FluidStack alph : aStack) { + if (alph != null) { + final String temp = itemNames; + itemNames = temp + ", " + alph.getLocalizedName() + " x" + alph.amount; + } else { + final String temp = itemNames; + itemNames = temp + ", " + "null" + " x" + "0"; + } + } + return itemNames; + } + + public static String getArrayStackNames(final ItemStack[] aStack) { + String itemNames = ""; + int aPos = 0; + for (final ItemStack alph : aStack) { + if (alph == null) { + continue; + } + if (alph != null) { + final String temp = itemNames; + itemNames = temp + (aPos > 0 ? ", " : "") + alph.getDisplayName() + " x" + alph.stackSize; + aPos++; + } + } + return itemNames; + } + + public static String[] getArrayStackNamesAsArray(final ItemStack[] aStack) { + final String[] itemNames = aStack == null ? new String[] {} : new String[aStack.length]; + if (aStack != null) { + Logger.INFO("" + aStack.length); + } + + if (aStack == null || aStack.length < 1) { + return itemNames; + } + + int arpos = 0; + for (final ItemStack alph : aStack) { + if (alph == null) { + continue; + } + try { + itemNames[arpos] = alph.getDisplayName(); + arpos++; + } catch (Throwable t) { + t.printStackTrace(); + } + } + return itemNames; + } + + public static String getFluidArrayStackNames(final FluidStack[] aStack) { + String itemNames = "Fluid Array: "; + for (final FluidStack alph : aStack) { + final String temp = itemNames; + itemNames = temp + ", " + alph.getFluid().getName() + " x" + alph.amount; + } + return itemNames; + } + + public static ItemStack getGregtechCircuit(final int Meta) { + return ItemUtils.getItemStackWithMeta( + LoadedMods.Gregtech, "gregtech:gt.integrated_circuit", "Gregtech Circuit", Meta, 0); + } + + public static ItemStack[] getBlockDrops(final ArrayList blockDrops) { + if (blockDrops == null) { + return null; + } + if (blockDrops.isEmpty()) { + return null; + } + final ItemStack[] outputs = new ItemStack[blockDrops.size()]; + short forCounter = 0; + for (final ItemStack I : blockDrops) { + outputs[forCounter++] = I; + } + return outputs; + } + + private static Map mModidCache = new HashMap(); + + private static String getModId(final Item item) { + if (mModidCache.containsKey(item)) { + return mModidCache.get(item); + } + String value = ""; + try { + final GameRegistry.UniqueIdentifier id = GameRegistry.findUniqueIdentifierFor(item); + if (id != null) { + final String modname = (id.modId == null ? id.name : id.modId); + value = ((id == null) || id.modId.equals("")) ? "minecraft" : modname; + } + } catch (final Throwable t) { + try { + final UniqueIdentifier t2 = GameRegistry.findUniqueIdentifierFor(Block.getBlockFromItem(item)); + if (t2 != null) { + final String modname = (t2.modId == null ? t2.name : t2.modId); + value = ((t2 == null) || t2.modId.equals("")) ? "minecraft" : modname; + } + } catch (final Throwable t3) { + t3.printStackTrace(); + value = "bad modid"; + } + } + if (!mModidCache.containsKey(item)) { + return mModidCache.put(item, value); + } + return value; + } + + public static String getModId(final ItemStack key) { + return getModId(key.getItem()); + } + + // Take 2 - GT/GT++ Dusts + public static ItemStack getGregtechDust(final String oredictName, final int amount) { + final ArrayList oreDictList = OreDictionary.getOres(oredictName); + if (!oreDictList.isEmpty()) { + ItemStack returnvalue; + for (int xrc = 0; xrc < oreDictList.size(); xrc++) { + final String modid = getModId(oreDictList.get(xrc).getItem()); + if (modid != null && (modid.equals("gregtech") || modid.equals(CORE.MODID))) { + returnvalue = oreDictList.get(xrc).copy(); + returnvalue.stackSize = amount; + return returnvalue; + } + } + } + return getNonTinkersDust(oredictName, amount); + } + + // Anything But Tinkers Dust + public static ItemStack getNonTinkersDust(final String oredictName, final int amount) { + final ArrayList oreDictList = OreDictionary.getOres(oredictName); + if (!oreDictList.isEmpty()) { + ItemStack returnvalue; + for (int xrc = 0; xrc < oreDictList.size(); xrc++) { + final String modid = getModId(oreDictList.get(xrc).getItem()); + if (modid != null && !modid.equals("tconstruct")) { + returnvalue = oreDictList.get(xrc).copy(); + returnvalue.stackSize = amount; + return returnvalue; + } + } + } + // If only Tinkers dust exists, bow down and just use it. + return getItemStackOfAmountFromOreDictNoBroken(oredictName, amount); + } + + @Deprecated + public static ItemStack getGregtechOreStack(OrePrefixes mPrefix, Materials mMat, int mAmount) { + + ItemStack aTemp = getOrePrefixStack(mPrefix, mMat, mAmount); + if (aTemp != null) { + return aTemp; + } + + String mName = MaterialUtils.getMaterialName(mMat); + + String mItemName = mPrefix.name() + mName; + // Utils.LOG_INFO("[Component Maker] Trying to get "+mItemName+"."); + ItemStack gregstack = ItemUtils.getItemStackOfAmountFromOreDictNoBroken(mItemName, mAmount); + if (gregstack == null) { + // Utils.LOG_INFO("[Component Maker] Failed to get "+mItemName+"."); + return null; + } + // Utils.LOG_INFO("[Component Maker] Found "+mItemName+"."); + return (gregstack); + } + + public static ItemStack getOrePrefixStack(OrePrefixes mPrefix, Material mMat, int mAmount) { + + String mName = Utils.sanitizeString(mMat.getLocalizedName()); + + String mItemName = mPrefix.name() + mName; + ItemStack gregstack = ItemUtils.getItemStackOfAmountFromOreDictNoBroken(mItemName, mAmount); + if (gregstack == null) { + return null; + } + return (gregstack); + } + + public static ItemStack getOrePrefixStack(OrePrefixes mPrefix, Materials mMat, int mAmount) { + if (mPrefix == OrePrefixes.rod) { + mPrefix = OrePrefixes.stick; + } + ItemStack aGtStack = GT_OreDictUnificator.get(mPrefix, mMat, mAmount); + if (aGtStack == null) { + Logger.INFO( + "Failed to find `" + mPrefix + MaterialUtils.getMaterialName(mMat) + "` in OD. [Prefix Search]"); + return getErrorStack(mAmount, (mPrefix.toString() + MaterialUtils.getMaterialName(mMat) + " x" + mAmount)); + } else { + return aGtStack; + } + } + + public static ItemStack getErrorStack(int mAmount) { + return getErrorStack(mAmount, null); + } + + public static ItemStack getErrorStack(int mAmount, String aName) { + ItemStack g = getSimpleStack(ModItems.AAA_Broken, 1); + if (aName != null) { + // NBTUtils.setString(g, "Lore", EnumChatFormatting.RED+aName); + NBTUtils.setBookTitle(g, EnumChatFormatting.RED + aName); + // NBTUtils.setBookTitle(g, EnumChatFormatting.YELLOW+"Maybe Alkalus should know about this"); + } + return g; + } + + public static ItemStack[] getStackOfAllOreDictGroup(String oredictname) { + final ArrayList oreDictList = OreDictionary.getOres(oredictname); + if (!oreDictList.isEmpty()) { + final ItemStack[] returnValues = new ItemStack[oreDictList.size()]; + for (int i = 0; i < oreDictList.size(); i++) { + if (oreDictList.get(i) != null) { + returnValues[i] = oreDictList.get(i); + } + } + return returnValues.length > 0 ? returnValues : null; + } else { + return null; + } + } + + public static boolean registerFuel(ItemStack aBurnable, int burn) { + return CORE.burnables.add(new Pair(burn, aBurnable)); + } + + public static String getLocalizedNameOfBlock(BlockPos pos) { + Block block = pos.world.getBlock(pos.xPos, pos.yPos, pos.zPos); + int metaData = pos.world.getBlockMetadata(pos.xPos, pos.yPos, pos.zPos); + return LangUtils.getLocalizedNameOfBlock(block, metaData); + } + + public static boolean checkForInvalidItems(ItemStack mInput) { + return checkForInvalidItems(new ItemStack[] {mInput}); + } + + public static boolean checkForInvalidItems(ItemStack[] mInput) { + return checkForInvalidItems(mInput, new ItemStack[] {}); + } + + /** + * + * @param mInputs + * @return {@link Boolean} - True if {@link ItemStack}[] only contains valid + * items. + */ + public static boolean checkForInvalidItems(ItemStack[] mInputs, ItemStack[] mOutputs) { + if (mInputs == null || mOutputs == null) { + return false; + } + + if (mInputs.length > 0) { + for (ItemStack stack : mInputs) { + if (stack != null) { + if (stack.getItem() != null) { + if (stack.getItem() == ModItems.AAA_Broken + || stack.getItem().getClass() == ModItems.AAA_Broken.getClass()) { + return false; + } else if (stack.getItem() == ModItems.ZZZ_Empty + || stack.getItem().getClass() == ModItems.ZZZ_Empty.getClass()) { + return false; + } else { + continue; + } + } else { + continue; + } + } else { + return false; + } + } + } + if (mOutputs.length > 0) { + for (ItemStack stack : mOutputs) { + if (stack != null) { + if (stack.getItem() != null) { + if (stack.getItem() == ModItems.AAA_Broken + || stack.getItem().getClass() == ModItems.AAA_Broken.getClass()) { + return false; + } else if (stack.getItem() == ModItems.ZZZ_Empty + || stack.getItem().getClass() == ModItems.ZZZ_Empty.getClass()) { + return false; + } else { + continue; + } + } else { + continue; + } + } else { + return false; + } + } + } + + return true; + } + + public static IInventory organiseInventory(IInventory aInputInventory) { + ItemStack[] p = new ItemStack[aInputInventory.getSizeInventory()]; + for (int o = 0; o < aInputInventory.getSizeInventory(); o++) { + p[o] = aInputInventory.getStackInSlot(o); + } + // ItemStack[] g = organiseInventory(p); + + IInventory aTemp = aInputInventory; + for (int i = 0; i < p.length; ++i) { + for (int j = i + 1; j < p.length; ++j) { + if (p[j] != null && (p[i] == null || GT_Utility.areStacksEqual(p[i], p[j]))) { + GT_Utility.moveStackFromSlotAToSlotB(aTemp, aTemp, j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + } + } + } + + /* + for (int o = 0; o < aInputInventory.getSizeInventory(); o++) { + aTemp.setInventorySlotContents(o, g[o]); + }*/ + return aTemp; + } + + public static ItemStack[] organiseInventory(ItemStack[] aInputs) { + + // Update Slots + int aInvSize = aInputs.length; + ItemStack[] newArray = new ItemStack[aInvSize]; + + // Try merge stacks + for (int i = 0; i < aInvSize; i++) { + for (int i2 = 0; i2 < aInvSize; i2++) { + if (i != i2) { + ItemStack[] t1 = new ItemStack[] {aInputs[i], aInputs[i2]}; + if (t1[0] == null || t1[1] == null) { + continue; + } else if (!GT_Utility.areStacksEqual(t1[0], t1[1])) { + continue; + } + // Try Merge + else { + + if (GT_Utility.areStacksEqual(t1[0], t1[1])) { + while ((t1[0].stackSize < 64 && t1[1].stackSize > 0)) { + t1[0].stackSize++; + t1[1].stackSize--; + if (t1[1].stackSize <= 0) { + t1[1] = null; + break; + } + if (t1[0].stackSize == 64) { + break; + } + } + newArray[i] = t1[1]; + newArray[i2] = t1[0]; + } + } + } + } + } + + ItemStack[] newArray2 = new ItemStack[aInvSize]; + + // Move nulls to end + int count2 = 0; + for (int i = 0; i < aInvSize; i++) if (newArray[i] != null) newArray2[count2++] = newArray[i]; + while (count2 < aInvSize) newArray2[count2++] = null; + + return newArray2; + } + + public static String getFluidName(FluidStack aFluid) { + return aFluid != null ? aFluid.getFluid().getLocalizedName(aFluid) : "NULL"; + } + + public static String getFluidName(Fluid aFluid) { + return aFluid != null ? aFluid.getLocalizedName() : "NULL"; + } + + public static String getItemName(ItemStack aStack) { + if (aStack == null) { + return "ERROR - Empty Stack"; + } + String aDisplay = null; + try { + aDisplay = ("" + + StatCollector.translateToLocal( + aStack.getItem().getUnlocalizedNameInefficiently(aStack) + ".name")) + .trim(); + if (aStack.hasTagCompound()) { + if (aStack.stackTagCompound != null && aStack.stackTagCompound.hasKey("display", 10)) { + NBTTagCompound nbttagcompound = aStack.stackTagCompound.getCompoundTag("display"); + + if (nbttagcompound.hasKey("Name", 8)) { + aDisplay = nbttagcompound.getString("Name"); + } + } + } + } catch (Throwable t) { + + } + if (aDisplay == null || aDisplay.length() <= 0) { + aDisplay = aStack.getUnlocalizedName() + ":" + aStack.getItemDamage(); + } else { + aDisplay += " | Meta: " + aStack.getItemDamage(); + } + return aDisplay; + } + + public static String getUnlocalizedItemName(ItemStack aStack) { + if (aStack == null) { + return "ERROR.Empty.Stack"; + } + String aDisplay = null; + try { + aDisplay = (aStack.getUnlocalizedName()).trim(); + } catch (Throwable t) { + aDisplay = aStack.getItem().getUnlocalizedName(); + } + if (aDisplay == null || aDisplay.length() <= 0) { + aDisplay = aStack.getItem().getUnlocalizedNameInefficiently(aStack); + } + return aDisplay; + } + + public static boolean isItemGregtechTool(ItemStack aStack) { + if (aStack == null) { + return false; + } + final Item mItem = aStack.getItem(); + final Item aSkookum = ItemUtils.getItemFromFQRN("miscutils:gt.plusplus.metatool.01"); + final Class aSkookClass = aSkookum.getClass(); + if (aSkookClass.isInstance(mItem) + || mItem instanceof GT_MetaGenerated_Tool_01 + || mItem instanceof MetaGeneratedGregtechTools + || mItem instanceof Gregtech_MetaTool + || mItem == aSkookum) { + return true; + } + return false; + } + + public static boolean isToolWrench(ItemStack aWrench) { + if (isItemGregtechTool(aWrench) + && (aWrench.getItemDamage() == 16 + || aWrench.getItemDamage() == 120 + || aWrench.getItemDamage() == 122 + || aWrench.getItemDamage() == 124 + || aWrench.getItemDamage() == 7734)) { + return true; + } + return false; + } + + public static boolean isToolMallet(ItemStack aMallet) { + if (isItemGregtechTool(aMallet) && (aMallet.getItemDamage() == 14)) { + return true; + } + return false; + } + + public static boolean isToolScrewdriver(ItemStack aScrewdriver) { + if (isItemGregtechTool(aScrewdriver) + && (aScrewdriver.getItemDamage() == 22 || aScrewdriver.getItemDamage() == 150)) { + return true; + } + return false; + } + + public static boolean isToolCrowbar(ItemStack aCrowbar) { + if (isItemGregtechTool(aCrowbar) && (aCrowbar.getItemDamage() == 20)) { + return true; + } + return false; + } + + public static boolean isToolWirecutters(ItemStack aWirecutters) { + if (isItemGregtechTool(aWirecutters) && (aWirecutters.getItemDamage() == 26)) { + return true; + } + return false; + } + + public static boolean isToolHammer(ItemStack aHammer) { + if (isItemGregtechTool(aHammer) && (aHammer.getItemDamage() == 12 || aHammer.getItemDamage() == 7734)) { + return true; + } + return false; + } + + public static boolean isToolSolderingIron(ItemStack aSoldering) { + if (isItemGregtechTool(aSoldering) && (aSoldering.getItemDamage() == 160)) { + return true; + } + return false; + } + + public static ItemStack[] cleanItemStackArray(ItemStack[] input) { + int aArraySize = input.length; + ItemStack[] aOutput = new ItemStack[aArraySize]; + AutoMap aCleanedItems = new AutoMap(); + for (ItemStack checkStack : input) { + if (ItemUtils.checkForInvalidItems(checkStack)) { + aCleanedItems.put(checkStack); + } + } + for (int i = 0; i < aArraySize; i++) { + ItemStack aMappedStack = aCleanedItems.get(i); + if (aMappedStack != null) { + aOutput[i] = aMappedStack; + } + } + return aOutput; + } + + public static ItemStack getEnchantedBook(Enchantment aEnch, int aLevel) { + return enchantItem(new ItemStack(Items.enchanted_book), aEnch, aLevel); + } + + public static ItemStack enchantItem(ItemStack aStack, Enchantment aEnch, int aLevel) { + Items.enchanted_book.addEnchantment(aStack, new EnchantmentData(aEnch, aLevel)); + return aStack; + } + + public static boolean doesOreDictHaveEntryFor(String string) { + return OreDictUtils.containsValidEntries(string); + } + + public static void hideItemFromNEI(ItemStack aItemToHide) { + codechicken.nei.api.API.hideItem(aItemToHide); + } + + public static ItemStack getNullStack() { + return GT_Values.NI; + } + + public static ItemStack depleteStack(ItemStack aStack) { + return depleteStack(aStack, 1); + } + + public static ItemStack depleteStack(ItemStack aStack, int aAmount) { + final int cap = aStack.stackSize; + if (cap >= 1 && cap >= aAmount) { + ItemStack aDepStack = aStack.copy(); + aDepStack.stackSize = (MathUtils.balance((aDepStack.stackSize - 1), 0, 64)); + if (aDepStack.stackSize > 0) { + return aDepStack; + } + } + return getNullStack(); + } + + public static boolean isControlCircuit(ItemStack aStack) { + if (aStack != null) { + Item aItem = aStack.getItem(); + if (aItem == CI.getNumberedBioCircuit(0).getItem() + || aItem == CI.getNumberedCircuit(0).getItem() + || aItem == CI.getNumberedAdvancedCircuit(0).getItem()) { + return true; + } + } + return false; + } + + public static boolean isCatalyst(ItemStack aStack) { + if (GT_Utility.areStacksEqual(aStack, GenericChem.mBlueCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mBrownCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mOrangeCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mPurpleCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mRedCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mYellowCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mPinkCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mFormaldehydeCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mSolidAcidCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mInfiniteMutationCatalyst, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, AgriculturalChem.mGreenCatalyst, true)) { + return true; + } + return false; + } + + public static boolean isMillingBall(ItemStack aStack) { + if (GT_Utility.areStacksEqual(aStack, GenericChem.mMillingBallAlumina, true)) { + return true; + } + if (GT_Utility.areStacksEqual(aStack, GenericChem.mMillingBallSoapstone, true)) { + return true; + } + return false; + } + + public static String getLocalizedNameOfBlock(Block aBlock, int aMeta) { + return LangUtils.getLocalizedNameOfBlock(aBlock, aMeta); + } + + public static boolean doesItemListEntryExist(String string) { + ItemList[] aListValues = ItemList.class.getEnumConstants(); + for (ItemList aItem : aListValues) { + if (aItem != null) { + if (aItem.name().equals(string) || aItem.name().toLowerCase().equals(string.toLowerCase())) { + return true; + } + } + } + return false; + } + + public static ItemList getValueOfItemList(String string, ItemList aOther) { + ItemList[] aListValues = ItemList.class.getEnumConstants(); + for (ItemList aItem : aListValues) { + if (aItem != null) { + if (aItem.name().equals(string) || aItem.name().toLowerCase().equals(string.toLowerCase())) { + return aItem; + } + } + } + Logger.INFO("Tried to obtain '" + string + "' from the GT ItemList, however it does not exist."); + if (aOther != null) { + Logger.INFO("Using fallback option instead - " + aOther.name()); + } + return aOther; + } + + public static ItemStack getValueOfItemList(String string, int aAmount, ItemList aOther) { + return getValueOfItemList(string, aOther).get(aAmount); + } + + public static ItemStack getValueOfItemList(String string, int aAmount, ItemStack aOther) { + ItemList[] aListValues = ItemList.class.getEnumConstants(); + for (ItemList aItem : aListValues) { + if (aItem != null) { + if (aItem.name().equals(string) || aItem.name().toLowerCase().equals(string.toLowerCase())) { + return aItem.get(aAmount); + } + } + } + Logger.INFO("Tried to obtain '" + string + "' from the GT ItemList, however it does not exist."); + if (aOther != null) { + Logger.INFO("Using fallback option instead - " + ItemUtils.getItemName(aOther)); + } + return aOther; + } + + public static boolean areItemsEqual(ItemStack aStack1, ItemStack aStack2) { + return areItemsEqual(aStack1, aStack2, true); + } + + public static boolean areItemsEqual(ItemStack aStack1, ItemStack aStack2, boolean aIgnoreNBT) { + return GT_Utility.areStacksEqual(aStack1, aStack2, aIgnoreNBT); + } } diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/LangUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/LangUtils.java index 0b24e962af..8517d129b2 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/LangUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/LangUtils.java @@ -1,14 +1,13 @@ package gtPlusPlus.core.util.minecraft; -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - import cpw.mods.fml.common.registry.LanguageRegistry; import gregtech.api.util.GT_LanguageManager; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -17,134 +16,129 @@ import net.minecraft.util.StatCollector; public class LangUtils { - - public static boolean rewriteEntryForLanguageRegistry(String aKey, String aNewValue){ - return rewriteEntryForLanguageRegistry("en_US", aKey, aNewValue); - } - - @SuppressWarnings("unchecked") - public static boolean rewriteEntryForLanguageRegistry(String aLang, String aKey, String aNewValue){ - LanguageRegistry aInstance = LanguageRegistry.instance(); - Field aModLanguageData = ReflectionUtils.getField(LanguageRegistry.class, "modLanguageData"); - if (aModLanguageData != null){ - Map aProps = new HashMap(); - Object aInstanceProps; - try { - aInstanceProps = aModLanguageData.get(aInstance); - if (aInstanceProps != null){ - aProps = (Map) aInstanceProps; - Properties aLangProps = aProps.get(aLang); - if (aLangProps != null){ - if (aLangProps.containsKey(aKey)) { - aLangProps.remove(aKey); - aLangProps.put(aKey, aNewValue); - } - else { - aLangProps.put(aKey, aNewValue); - } - aProps.remove(aLang); - aProps.put(aLang, aLangProps); - ReflectionUtils.setField(aInstance, aModLanguageData, aProps); - } - } - } - catch (IllegalArgumentException | IllegalAccessException e) { - - } - } - return false; - } - - public static String trans(String aNr, String aEnglish) { - return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_GTPP_" + aNr, aEnglish, false); - } - - - - /** - * Quick Block Name Lookup that is friendly to servers and locale. - */ - private static final Map mLocaleCache = new HashMap(); - - public static String getLocalizedNameOfBlock(Block aBlock, int aMeta) { - if (aBlock != null) { - return getLocalizedNameOfItemStack(ItemUtils.simpleMetaStack(aBlock, aMeta, 1)); - } - return "Bad Block Name"; - } - - public static String getLocalizedNameOfItem(Item aItem, int aMeta) { - if (aItem != null) { - return getLocalizedNameOfItemStack(ItemUtils.simpleMetaStack(aItem, aMeta, 1)); - } - return "Bad Item Name"; - } - - public static String getLocalizedNameOfItemStack(ItemStack aStack) { - String aUnlocalized; - if (aStack != null) { - aUnlocalized = ItemUtils.getUnlocalizedItemName(aStack)+"."+aStack.getItemDamage()+".name"; - if (aUnlocalized == null || aUnlocalized.length() <= 0) { - return "Bad Locale Data"; - } - String mCacheKey = aUnlocalized; - if (mLocaleCache.containsKey(mCacheKey)) { - // Recache the key if it's invalid. - if (mLocaleCache.get(mCacheKey).toLowerCase().contains(".name") || mLocaleCache.get(mCacheKey).toLowerCase().contains("|")) { - mLocaleCache.remove(mCacheKey); - String mNew; - try { - mNew = ("" + StatCollector - .translateToLocal(aStack.getItem().getUnlocalizedNameInefficiently(aStack) + ".name")) - .trim(); - if (aStack.hasTagCompound()) { - if (aStack.stackTagCompound != null && aStack.stackTagCompound.hasKey("display", 10)) { - NBTTagCompound nbttagcompound = aStack.stackTagCompound.getCompoundTag("display"); - - if (nbttagcompound.hasKey("Name", 8)) { - mNew = nbttagcompound.getString("Name"); - } - } - } - } catch (Throwable t) { - mNew = "ERROR - Empty Stack"; - } - Logger.INFO("Re-caching "+mNew+" into locale cache. Key: "+mCacheKey); - mLocaleCache.put(mCacheKey, mNew); - } - Logger.INFO("Returning Cached Value. Key: "+mCacheKey); - return mLocaleCache.get(mCacheKey); - } - else { - String unlocalizedName = aStack.getItem().getUnlocalizedName(aStack); - Logger.INFO("Cached New Value. UnlocalName: "+unlocalizedName); - String blockName = StatCollector.translateToLocal(unlocalizedName + ".name"); - Logger.INFO("Cached New Value. TranslatedName: "+unlocalizedName); - if (blockName.toLowerCase().contains(".name") || blockName.toLowerCase().contains("|")) { - try { - blockName = ("" + StatCollector - .translateToLocal(aStack.getItem().getUnlocalizedNameInefficiently(aStack) + ".name")) - .trim(); - if (aStack.hasTagCompound()) { - if (aStack.stackTagCompound != null && aStack.stackTagCompound.hasKey("display", 10)) { - NBTTagCompound nbttagcompound = aStack.stackTagCompound.getCompoundTag("display"); - if (nbttagcompound.hasKey("Name", 8)) { - blockName = nbttagcompound.getString("Name"); - } - } - } - } catch (Throwable t) { - blockName = "ERROR - Empty Stack"; - } - } - mLocaleCache.put(mCacheKey, blockName); - Logger.INFO("Cached New Value. Key: "+mCacheKey); - return blockName; - } - - } - return "Bad ItemStack Name"; - } - - + public static boolean rewriteEntryForLanguageRegistry(String aKey, String aNewValue) { + return rewriteEntryForLanguageRegistry("en_US", aKey, aNewValue); + } + + @SuppressWarnings("unchecked") + public static boolean rewriteEntryForLanguageRegistry(String aLang, String aKey, String aNewValue) { + LanguageRegistry aInstance = LanguageRegistry.instance(); + Field aModLanguageData = ReflectionUtils.getField(LanguageRegistry.class, "modLanguageData"); + if (aModLanguageData != null) { + Map aProps = new HashMap(); + Object aInstanceProps; + try { + aInstanceProps = aModLanguageData.get(aInstance); + if (aInstanceProps != null) { + aProps = (Map) aInstanceProps; + Properties aLangProps = aProps.get(aLang); + if (aLangProps != null) { + if (aLangProps.containsKey(aKey)) { + aLangProps.remove(aKey); + aLangProps.put(aKey, aNewValue); + } else { + aLangProps.put(aKey, aNewValue); + } + aProps.remove(aLang); + aProps.put(aLang, aLangProps); + ReflectionUtils.setField(aInstance, aModLanguageData, aProps); + } + } + } catch (IllegalArgumentException | IllegalAccessException e) { + + } + } + return false; + } + + public static String trans(String aNr, String aEnglish) { + return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_GTPP_" + aNr, aEnglish, false); + } + + /** + * Quick Block Name Lookup that is friendly to servers and locale. + */ + private static final Map mLocaleCache = new HashMap(); + + public static String getLocalizedNameOfBlock(Block aBlock, int aMeta) { + if (aBlock != null) { + return getLocalizedNameOfItemStack(ItemUtils.simpleMetaStack(aBlock, aMeta, 1)); + } + return "Bad Block Name"; + } + + public static String getLocalizedNameOfItem(Item aItem, int aMeta) { + if (aItem != null) { + return getLocalizedNameOfItemStack(ItemUtils.simpleMetaStack(aItem, aMeta, 1)); + } + return "Bad Item Name"; + } + + public static String getLocalizedNameOfItemStack(ItemStack aStack) { + String aUnlocalized; + if (aStack != null) { + aUnlocalized = ItemUtils.getUnlocalizedItemName(aStack) + "." + aStack.getItemDamage() + ".name"; + if (aUnlocalized == null || aUnlocalized.length() <= 0) { + return "Bad Locale Data"; + } + String mCacheKey = aUnlocalized; + if (mLocaleCache.containsKey(mCacheKey)) { + // Recache the key if it's invalid. + if (mLocaleCache.get(mCacheKey).toLowerCase().contains(".name") + || mLocaleCache.get(mCacheKey).toLowerCase().contains("|")) { + mLocaleCache.remove(mCacheKey); + String mNew; + try { + mNew = ("" + + StatCollector.translateToLocal( + aStack.getItem().getUnlocalizedNameInefficiently(aStack) + ".name")) + .trim(); + if (aStack.hasTagCompound()) { + if (aStack.stackTagCompound != null && aStack.stackTagCompound.hasKey("display", 10)) { + NBTTagCompound nbttagcompound = aStack.stackTagCompound.getCompoundTag("display"); + + if (nbttagcompound.hasKey("Name", 8)) { + mNew = nbttagcompound.getString("Name"); + } + } + } + } catch (Throwable t) { + mNew = "ERROR - Empty Stack"; + } + Logger.INFO("Re-caching " + mNew + " into locale cache. Key: " + mCacheKey); + mLocaleCache.put(mCacheKey, mNew); + } + Logger.INFO("Returning Cached Value. Key: " + mCacheKey); + return mLocaleCache.get(mCacheKey); + } else { + String unlocalizedName = aStack.getItem().getUnlocalizedName(aStack); + Logger.INFO("Cached New Value. UnlocalName: " + unlocalizedName); + String blockName = StatCollector.translateToLocal(unlocalizedName + ".name"); + Logger.INFO("Cached New Value. TranslatedName: " + unlocalizedName); + if (blockName.toLowerCase().contains(".name") + || blockName.toLowerCase().contains("|")) { + try { + blockName = ("" + + StatCollector.translateToLocal( + aStack.getItem().getUnlocalizedNameInefficiently(aStack) + ".name")) + .trim(); + if (aStack.hasTagCompound()) { + if (aStack.stackTagCompound != null && aStack.stackTagCompound.hasKey("display", 10)) { + NBTTagCompound nbttagcompound = aStack.stackTagCompound.getCompoundTag("display"); + if (nbttagcompound.hasKey("Name", 8)) { + blockName = nbttagcompound.getString("Name"); + } + } + } + } catch (Throwable t) { + blockName = "ERROR - Empty Stack"; + } + } + mLocaleCache.put(mCacheKey, blockName); + Logger.INFO("Cached New Value. Key: " + mCacheKey); + return blockName; + } + } + return "Bad ItemStack Name"; + } } diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/MaterialUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/MaterialUtils.java index 73ccfdf8a5..3d42bcda84 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/MaterialUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/MaterialUtils.java @@ -1,7 +1,5 @@ package gtPlusPlus.core.util.minecraft; -import java.util.*; - import gregtech.api.enums.*; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; @@ -19,502 +17,524 @@ import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.data.*; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import java.util.*; import net.minecraft.item.*; import net.minecraftforge.oredict.OreDictionary; public class MaterialUtils { - public static short firstID = 791; - - @SuppressWarnings({ "rawtypes", "unused" }) - private static Class[][] commonTypes = -{{Materials.class, int.class, TextureSet.class, float.class, int.class, - int.class, int.class, int.class, int.class, int.class, int.class, - String.class, int.class, int.class, int.class, int.class, boolean.class, - boolean.class, int.class, int.class, int.class, Dyes.class, int.class, - List.class , List.class}}; - - public static List oreDictValuesForEntry(final String oredictName){ - List oredictItemNames; - if(OreDictionary.doesOreNameExist(oredictName)){ - final List oredictItems = OreDictionary.getOres(oredictName); - oredictItemNames = oredictItems; - return oredictItemNames; - } - return null; - } - - private static Map mGeneratedMaterialMap = new HashMap(); - - public static Material generateMaterialFromGtENUM(final Materials material){ - return generateMaterialFromGtENUM(material, null, null); - } - - public static Material generateMaterialFromGtENUM(final Materials material, TextureSet aCustomTextures){ - return generateMaterialFromGtENUM(material, null, aCustomTextures); - } - - public static Material generateMaterialFromGtENUM(final Materials material, short[] customRGB){ - return generateMaterialFromGtENUM(material, customRGB, null); - } - - public static Material generateMaterialFromGtENUM(final Materials material, short[] customRGB, TextureSet aCustomTextures){ - String aMaterialKey = getMaterialName(material).toLowerCase(); - if (mGeneratedMaterialMap.containsKey(aMaterialKey)) { - return mGeneratedMaterialMap.get(aMaterialKey); - } - - try { - @SuppressWarnings("deprecation") - String name = material.name(); - final short[] rgba = (customRGB == null ? material.mRGBa : customRGB); - final int melting = material.mMeltingPoint; - final int boiling = material.mBlastFurnaceTemp; - final long protons = material.getProtons(); - final long neutrons = material.getNeutrons(); - final boolean blastFurnace = material.mBlastFurnaceRequired; - Integer radioactivity = 0; - if (material.isRadioactive()){ - ItemStack aDustStack = ItemUtils.getOrePrefixStack(OrePrefixes.dust, material, 1); - radioactivity = aDustStack != null ? GT_Utility.getRadioactivityLevel(aDustStack) : 0; - if (radioactivity == 0) { - long aProtons = material.getProtons(); - radioactivity = (int) Math.min(Math.max((aProtons / 30), 1), 9); - } - } - Logger.MATERIALS("[Debug] Calculated Radiation level to be "+radioactivity.intValue()+"."); - TextureSet iconSet = null; - if (aCustomTextures == null) { - if (material.isRadioactive()) { - iconSet = TextureSets.NUCLEAR.get(); - } - else { - iconSet = material.mIconSet; - } - } - else { - iconSet = aCustomTextures; - } - if (iconSet == null || iconSet.mSetName.toLowerCase().contains("fluid")) { - iconSet = TextureSet.SET_METALLIC; - } - Logger.MATERIALS("[Debug] Calculated Texture Set to be "+iconSet.mSetName+"."); - - - final int durability = material.mDurability; - boolean mGenerateCell = false; - boolean mGenerateFluid = true; - MaterialState materialState; - String chemicalFormula = StringUtils.subscript(Utils.sanitizeString(material.mChemicalFormula)); - final Element element = material.mElement; - - - //Weird Blacklist of Bad Chemical Strings - if (material.mElement == Element.Pb || material.mElement == Element.Na || material.mElement == Element.Ar){ - chemicalFormula = StringUtils.subscript(Utils.sanitizeString(material.mElement.name())); - } - - //Determine default state - Logger.MATERIALS("[Debug] Setting State of GT generated material. "+material.mDefaultLocalName); - if (material.getMolten(1) != null || material.getSolid(1) != null){ - materialState = MaterialState.SOLID; - Logger.MATERIALS("[Debug] Molten or Solid was not null."); - if (material.getMolten(1) == null && material.getSolid(1) != null){ - Logger.MATERIALS("[Debug] Molten is Null, Solid is not. Enabling cell generation."); - mGenerateCell = true; - } - else if (material.getMolten(1) != null && material.getSolid(1) == null){ - Logger.MATERIALS("[Debug] Molten is not Null, Solid is null. Not enabling cell generation."); - //mGenerateCell = true; - } - Logger.MATERIALS("[Debug] State set as solid."); - } - else if (material.getFluid(1) != null){ - Logger.MATERIALS("[Debug] State set as liquid."); - materialState = MaterialState.LIQUID; - } - else if (material.getGas(1) != null){ - Logger.MATERIALS("[Debug] State set as gas."); - materialState = MaterialState.GAS; - }/* - else if (material.getPlasma(1) != null){ - Logger.MATERIALS("[Debug] State set as plasma."); - materialState = MaterialState.PLASMA; - }*/ - else { - Logger.MATERIALS("[Debug] State set as solid. This material has no alternative states, so for safety we wont generate anything."); - materialState = MaterialState.SOLID; - mGenerateFluid = false; - } - - - if (name.toLowerCase().contains("infused")){ - final String tempname = name.substring(7, name.length()); - name = "Infused " + tempname; - } - if (hasValidRGBA(rgba) || (element == Element.H) || ((material == Materials.InfusedAir) || (material == Materials.InfusedFire) || (material == Materials.InfusedEarth) || (material == Materials.InfusedWater))){ - //ModItems.itemBaseDecidust = UtilsItems.generateDecidust(material); - //ModItems.itemBaseCentidust = UtilsItems.generateCentidust(material); - Material M = new Material(name, materialState,iconSet, durability, rgba, melting, boiling, protons, neutrons, blastFurnace, chemicalFormula, radioactivity, mGenerateCell, mGenerateFluid); - mGeneratedMaterialMap.put(aMaterialKey, M); - return M; - } - else { - Logger.DEBUG_MATERIALS("Failed to generate GT++ material instance for "+material.name() +" | Valid RGB? "+(hasValidRGBA(rgba))); - } - } - catch (Throwable t) { - Logger.DEBUG_MATERIALS("Failed to generate GT++ material instance for "+material.name()); - t.printStackTrace(); - } - return null; - - } - - public static Material generateQuickMaterial(final String materialName, final MaterialState defaultState, final short[] colour, final int sRadioactivity) { - String aMaterialKey = materialName.toLowerCase(); - if (mGeneratedMaterialMap.containsKey(aMaterialKey)) { - return mGeneratedMaterialMap.get(aMaterialKey); - } - - final Material temp = new Material( - materialName, - defaultState, - colour, - 1000, //melting - 3000, //boiling - 50, //Protons - 50, //Neutrons - false, - "", - sRadioactivity); - mGeneratedMaterialMap.put(aMaterialKey, temp); - return temp; - } - - public static boolean hasValidRGBA(final short[] rgba){ - if (rgba == null || rgba.length < 3 || rgba.length > 4){ - return false; - } - return true; - } - - public static int getTierOfMaterial(final double aMeltingPoint){ - - return aMeltingPoint < 1000 ? 0 : (MathUtils.roundToClosestInt(aMeltingPoint/1000f)); - - - /*if ((aMeltingPoint >= 0) && (aMeltingPoint <= 1000)){ - return 1; - } - else if((aMeltingPoint >= 1001) && (aMeltingPoint <= 2000)){ - return 2; - } - else if((aMeltingPoint >= 2001) && (aMeltingPoint <= 3000)){ - return 3; - } - else if((aMeltingPoint >= 3001) && (aMeltingPoint <= 4000)){ - return 4; - } - else if((aMeltingPoint >= 4001) && (aMeltingPoint <= 5000)){ - return 5; - } - else if((aMeltingPoint >= 5001) && (aMeltingPoint <= 6000)){ - return 6; - } - else if((aMeltingPoint >= 6001) && (aMeltingPoint <= 7000)){ - return 7; - } - else if((aMeltingPoint >= 7001) && (aMeltingPoint <= 8000)){ - return 8; - } - else if((aMeltingPoint >= 8001) && (aMeltingPoint <= 9000)){ - return 9; - } - else if((aMeltingPoint >= 9001) && (aMeltingPoint <= 9999)){ - return 10; - } - else { - return 0; - }*/ - } - - public static int getVoltageForTier(int aTier) { - //aTier += 1; - Probably some logic to this, idk. - - switch(aTier){ - case 0: - return 16; - case 1: - return 30; - case 2: - return 120; - case 3: - return 480; - case 4: - return 1920; - case 5: - return 7680; - case 6: - return 30720; - case 7: - return 122880; - case 8: - return 491520; - case 9: - return 1966080; - case 10: - return 7864320; - case 11: - return 31457280; - case 12: - return 125829120; - case 13: - return 503316480; - case 14: - return 2013265920; - default: - return Integer.MAX_VALUE; - } - - /*else { - int newTier = aTier - 1; - return (int) ((4*(Math.pow(4, newTier)))*7.5); - }*/ - } - - private static Materials getMaterialByName(String materialName) { - - if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - return (Materials) EnumUtils.getValue(gregtech.api.enums.Materials.class, materialName, false); - } - else { - for (Materials m : Materials.values()) { - if (MaterialUtils.getMaterialName(m).toLowerCase().equals(materialName.toLowerCase())) { - return m; - } - } - return null; - } - } - - @SuppressWarnings("deprecation") - public static String getMaterialName(Materials mat){ - - String mName = null; - - try { - mName = (String) ReflectionUtils.getField(Materials.class, "mDefaultLocalName").get(mat); - if (mName == null) { - mName = (String) ReflectionUtils.getField(Materials.class, "mName").get(mat); - } - } - catch (IllegalArgumentException | IllegalAccessException e) { - } - - - if (mName == null || mName.equals("")){ - mName = mat.name(); - } - return mName; - } - - public static TextureSet getMostCommonTextureSet(List list) { - TypeCounter aCounter = new TypeCounter(TextureSet.class); - for (Material m : list) { - TextureSet t = m.getTextureSet(); - if (t == null) { - t = Materials.Gold.mIconSet; - } - if (t != null) { - aCounter.add(t, t.mSetName); - } - } - return aCounter.getResults(); - /*Optional r = list.stream().map(Material::getTextureSet).collect(Collectors.groupingBy(Function.identity(), Collectors.counting())).entrySet().stream().max(Map.Entry.comparingByValue()).map(Map.Entry::getKey); - TextureSet o = (r != null && r.isPresent() && r.get() != null) ? r.get() : null; - return o;*/ - } - - - - public static Materials getMaterial(String aMaterialName, String aFallbackMaterialName) { - Materials g = getMaterial(aMaterialName); - if (g == null) { - g = getMaterial(aFallbackMaterialName); - } - if (g == null) { - Logger.INFO("Failed finding material '"+aMaterialName+"' & fallback '"+aFallbackMaterialName+"', returning _NULL."); - CORE.crash(); - //g = Materials._NULL; - } - return g; - } - - public static Materials getMaterial(String aMaterialName) { - Materials m = gtPlusPlus.xmod.gregtech.common.StaticFields59.getMaterial(aMaterialName); - if (m == null) { - m = getMaterialByName(aMaterialName); - } - if (m == null) { - Logger.INFO("Failed finding material '"+aMaterialName+"', returning _NULL."); - m = Materials._NULL; - } - return m; - } - - public static AutoMap getCompoundMaterialsRecursively(Material aMat){ - return getCompoundMaterialsRecursively_Speiger(aMat); - /* - AutoMap aDataSet = new AutoMap(); - final int HARD_LIMIT = 1000; - int mLoopCounter = 0; - if (aMat.getComposites().size() > 0) { - try { - List xList = Lists.newLinkedList(); - for (MaterialStack kj : aMat.getComposites()) { - xList.add(kj.getStackMaterial()); - } - if (xList.isEmpty()) { - aDataSet.put(aMat); - return aDataSet; - } - ListIterator listIterator = xList.listIterator(); - while(listIterator.hasNext()){ - Material e = listIterator.next(); - listIterator.remove(); - if (mLoopCounter > HARD_LIMIT) { - break; - } - - if (e.getComposites().isEmpty()) { - aDataSet.put(e); - } - else { - for (MaterialStack x : e.getComposites()) { - listIterator.add(x.getStackMaterial()); - } - } - mLoopCounter++; - - - }} - catch (Throwable t) { - aDataSet.put(aMat); - t.printStackTrace(); - } - } - if (aDataSet.isEmpty()) { - aDataSet.put(aMat); - return aDataSet; - } - return aDataSet; - */} - - public static AutoMap getCompoundMaterialsRecursively_Speiger(Material toSearch) { - AutoMap resultList = new AutoMap(); - if (toSearch.getComposites().isEmpty()) { - resultList.put(toSearch); - return resultList; - } - final int HARD_LIMIT = 1000; - - // Could be a Deque but i dont use the interface - // enough to use it as default. - LinkedList toCheck = new LinkedList(); - - toCheck.add(toSearch); - int processed = 0; - while (toCheck.size() > 0 && processed < HARD_LIMIT) { - Material current = toCheck.remove(); - if (current.getComposites().isEmpty()) { - resultList.put(current); - } else { - for (MaterialStack entry : current.getComposites()) { - toCheck.add(entry.getStackMaterial()); - } - } - processed++; - } - return resultList; - } - - public static void generateComponentAndAssignToAMaterial(ComponentTypes aType, Material aMaterial) { - generateComponentAndAssignToAMaterial(aType, aMaterial, true); - } - - public static void generateComponentAndAssignToAMaterial(ComponentTypes aType, Material aMaterial, boolean generateRecipes) { - Item aGC; - if (aType == ComponentTypes.PLATEHEAVY) { - aGC = new BaseItemPlateHeavy(aMaterial); - } - else if (aType == ComponentTypes.FINEWIRE) { - aGC = new BaseItemFineWire(aMaterial); - } - else if (aType == ComponentTypes.FOIL) { - aGC = new BaseItemFoil(aMaterial); - } - else { - aGC = new BaseItemComponent(aMaterial, aType); - } - if (aGC != null) { - String aFormattedLangName = aType.getName(); - - if (!aFormattedLangName.startsWith(" ")) { - if (aFormattedLangName.contains("@")) { - String[] aSplit = aFormattedLangName.split("@"); - aFormattedLangName = aSplit[0] + " " + aMaterial.getLocalizedName() + " " + aSplit[1]; - } - } - - if (aFormattedLangName.equals(aType.getName())) { - aFormattedLangName = aMaterial.getLocalizedName() + aFormattedLangName; - - } - - - - Logger.MATERIALS("[Lang] "+aGC.getUnlocalizedName()+".name="+aFormattedLangName); - aMaterial.registerComponentForMaterial(aType, ItemUtils.getSimpleStack(aGC)); - } - } - - - - - - - - - public static void generateSpecialDustAndAssignToAMaterial(Material aMaterial) { - generateSpecialDustAndAssignToAMaterial(aMaterial, true); - } - - public static void generateSpecialDustAndAssignToAMaterial(Material aMaterial, boolean generateMixerRecipes) { - Item[] aDusts = ItemUtils.generateSpecialUseDusts(aMaterial, false, Utils.invertBoolean(generateMixerRecipes)); - if (aDusts != null && aDusts.length > 0) { - aMaterial.registerComponentForMaterial(OrePrefixes.dust, ItemUtils.getSimpleStack(aDusts[0])); - aMaterial.registerComponentForMaterial(OrePrefixes.dustSmall, ItemUtils.getSimpleStack(aDusts[1])); - aMaterial.registerComponentForMaterial(OrePrefixes.dustTiny, ItemUtils.getSimpleStack(aDusts[2])); - } - - } - - public static boolean doesMaterialExist(String aMatName) { - for (Materials m : Materials.values()) { - if (m.name().toLowerCase().equals(aMatName.toLowerCase())) { - return true; - } - } - return false; - } - - public static boolean isNullGregtechMaterial(Materials aGregtechMaterial) { - if (aGregtechMaterial == Materials._NULL || aGregtechMaterial.equals(Materials._NULL) || aGregtechMaterial.name().equals(Materials._NULL.name())) { - return true; - } - return false; - } - - -} \ No newline at end of file + public static short firstID = 791; + + @SuppressWarnings({"rawtypes", "unused"}) + private static Class[][] commonTypes = { + { + Materials.class, + int.class, + TextureSet.class, + float.class, + int.class, + int.class, + int.class, + int.class, + int.class, + int.class, + int.class, + String.class, + int.class, + int.class, + int.class, + int.class, + boolean.class, + boolean.class, + int.class, + int.class, + int.class, + Dyes.class, + int.class, + List.class, + List.class + } + }; + + public static List oreDictValuesForEntry(final String oredictName) { + List oredictItemNames; + if (OreDictionary.doesOreNameExist(oredictName)) { + final List oredictItems = OreDictionary.getOres(oredictName); + oredictItemNames = oredictItems; + return oredictItemNames; + } + return null; + } + + private static Map mGeneratedMaterialMap = new HashMap(); + + public static Material generateMaterialFromGtENUM(final Materials material) { + return generateMaterialFromGtENUM(material, null, null); + } + + public static Material generateMaterialFromGtENUM(final Materials material, TextureSet aCustomTextures) { + return generateMaterialFromGtENUM(material, null, aCustomTextures); + } + + public static Material generateMaterialFromGtENUM(final Materials material, short[] customRGB) { + return generateMaterialFromGtENUM(material, customRGB, null); + } + + public static Material generateMaterialFromGtENUM( + final Materials material, short[] customRGB, TextureSet aCustomTextures) { + String aMaterialKey = getMaterialName(material).toLowerCase(); + if (mGeneratedMaterialMap.containsKey(aMaterialKey)) { + return mGeneratedMaterialMap.get(aMaterialKey); + } + + try { + @SuppressWarnings("deprecation") + String name = material.name(); + final short[] rgba = (customRGB == null ? material.mRGBa : customRGB); + final int melting = material.mMeltingPoint; + final int boiling = material.mBlastFurnaceTemp; + final long protons = material.getProtons(); + final long neutrons = material.getNeutrons(); + final boolean blastFurnace = material.mBlastFurnaceRequired; + Integer radioactivity = 0; + if (material.isRadioactive()) { + ItemStack aDustStack = ItemUtils.getOrePrefixStack(OrePrefixes.dust, material, 1); + radioactivity = aDustStack != null ? GT_Utility.getRadioactivityLevel(aDustStack) : 0; + if (radioactivity == 0) { + long aProtons = material.getProtons(); + radioactivity = (int) Math.min(Math.max((aProtons / 30), 1), 9); + } + } + Logger.MATERIALS("[Debug] Calculated Radiation level to be " + radioactivity.intValue() + "."); + TextureSet iconSet = null; + if (aCustomTextures == null) { + if (material.isRadioactive()) { + iconSet = TextureSets.NUCLEAR.get(); + } else { + iconSet = material.mIconSet; + } + } else { + iconSet = aCustomTextures; + } + if (iconSet == null || iconSet.mSetName.toLowerCase().contains("fluid")) { + iconSet = TextureSet.SET_METALLIC; + } + Logger.MATERIALS("[Debug] Calculated Texture Set to be " + iconSet.mSetName + "."); + + final int durability = material.mDurability; + boolean mGenerateCell = false; + boolean mGenerateFluid = true; + MaterialState materialState; + String chemicalFormula = StringUtils.subscript(Utils.sanitizeString(material.mChemicalFormula)); + final Element element = material.mElement; + + // Weird Blacklist of Bad Chemical Strings + if (material.mElement == Element.Pb || material.mElement == Element.Na || material.mElement == Element.Ar) { + chemicalFormula = StringUtils.subscript(Utils.sanitizeString(material.mElement.name())); + } + + // Determine default state + Logger.MATERIALS("[Debug] Setting State of GT generated material. " + material.mDefaultLocalName); + if (material.getMolten(1) != null || material.getSolid(1) != null) { + materialState = MaterialState.SOLID; + Logger.MATERIALS("[Debug] Molten or Solid was not null."); + if (material.getMolten(1) == null && material.getSolid(1) != null) { + Logger.MATERIALS("[Debug] Molten is Null, Solid is not. Enabling cell generation."); + mGenerateCell = true; + } else if (material.getMolten(1) != null && material.getSolid(1) == null) { + Logger.MATERIALS("[Debug] Molten is not Null, Solid is null. Not enabling cell generation."); + // mGenerateCell = true; + } + Logger.MATERIALS("[Debug] State set as solid."); + } else if (material.getFluid(1) != null) { + Logger.MATERIALS("[Debug] State set as liquid."); + materialState = MaterialState.LIQUID; + } else if (material.getGas(1) != null) { + Logger.MATERIALS("[Debug] State set as gas."); + materialState = MaterialState.GAS; + } /* + else if (material.getPlasma(1) != null){ + Logger.MATERIALS("[Debug] State set as plasma."); + materialState = MaterialState.PLASMA; + }*/ else { + Logger.MATERIALS( + "[Debug] State set as solid. This material has no alternative states, so for safety we wont generate anything."); + materialState = MaterialState.SOLID; + mGenerateFluid = false; + } + + if (name.toLowerCase().contains("infused")) { + final String tempname = name.substring(7, name.length()); + name = "Infused " + tempname; + } + if (hasValidRGBA(rgba) + || (element == Element.H) + || ((material == Materials.InfusedAir) + || (material == Materials.InfusedFire) + || (material == Materials.InfusedEarth) + || (material == Materials.InfusedWater))) { + // ModItems.itemBaseDecidust = UtilsItems.generateDecidust(material); + // ModItems.itemBaseCentidust = UtilsItems.generateCentidust(material); + Material M = new Material( + name, + materialState, + iconSet, + durability, + rgba, + melting, + boiling, + protons, + neutrons, + blastFurnace, + chemicalFormula, + radioactivity, + mGenerateCell, + mGenerateFluid); + mGeneratedMaterialMap.put(aMaterialKey, M); + return M; + } else { + Logger.DEBUG_MATERIALS("Failed to generate GT++ material instance for " + material.name() + + " | Valid RGB? " + (hasValidRGBA(rgba))); + } + } catch (Throwable t) { + Logger.DEBUG_MATERIALS("Failed to generate GT++ material instance for " + material.name()); + t.printStackTrace(); + } + return null; + } + + public static Material generateQuickMaterial( + final String materialName, + final MaterialState defaultState, + final short[] colour, + final int sRadioactivity) { + String aMaterialKey = materialName.toLowerCase(); + if (mGeneratedMaterialMap.containsKey(aMaterialKey)) { + return mGeneratedMaterialMap.get(aMaterialKey); + } + + final Material temp = new Material( + materialName, + defaultState, + colour, + 1000, // melting + 3000, // boiling + 50, // Protons + 50, // Neutrons + false, + "", + sRadioactivity); + mGeneratedMaterialMap.put(aMaterialKey, temp); + return temp; + } + + public static boolean hasValidRGBA(final short[] rgba) { + if (rgba == null || rgba.length < 3 || rgba.length > 4) { + return false; + } + return true; + } + + public static int getTierOfMaterial(final double aMeltingPoint) { + + return aMeltingPoint < 1000 ? 0 : (MathUtils.roundToClosestInt(aMeltingPoint / 1000f)); + + /*if ((aMeltingPoint >= 0) && (aMeltingPoint <= 1000)){ + return 1; + } + else if((aMeltingPoint >= 1001) && (aMeltingPoint <= 2000)){ + return 2; + } + else if((aMeltingPoint >= 2001) && (aMeltingPoint <= 3000)){ + return 3; + } + else if((aMeltingPoint >= 3001) && (aMeltingPoint <= 4000)){ + return 4; + } + else if((aMeltingPoint >= 4001) && (aMeltingPoint <= 5000)){ + return 5; + } + else if((aMeltingPoint >= 5001) && (aMeltingPoint <= 6000)){ + return 6; + } + else if((aMeltingPoint >= 6001) && (aMeltingPoint <= 7000)){ + return 7; + } + else if((aMeltingPoint >= 7001) && (aMeltingPoint <= 8000)){ + return 8; + } + else if((aMeltingPoint >= 8001) && (aMeltingPoint <= 9000)){ + return 9; + } + else if((aMeltingPoint >= 9001) && (aMeltingPoint <= 9999)){ + return 10; + } + else { + return 0; + }*/ + } + + public static int getVoltageForTier(int aTier) { + // aTier += 1; - Probably some logic to this, idk. + + switch (aTier) { + case 0: + return 16; + case 1: + return 30; + case 2: + return 120; + case 3: + return 480; + case 4: + return 1920; + case 5: + return 7680; + case 6: + return 30720; + case 7: + return 122880; + case 8: + return 491520; + case 9: + return 1966080; + case 10: + return 7864320; + case 11: + return 31457280; + case 12: + return 125829120; + case 13: + return 503316480; + case 14: + return 2013265920; + default: + return Integer.MAX_VALUE; + } + + /*else { + int newTier = aTier - 1; + return (int) ((4*(Math.pow(4, newTier)))*7.5); + }*/ + } + + private static Materials getMaterialByName(String materialName) { + + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + return (Materials) EnumUtils.getValue(gregtech.api.enums.Materials.class, materialName, false); + } else { + for (Materials m : Materials.values()) { + if (MaterialUtils.getMaterialName(m).toLowerCase().equals(materialName.toLowerCase())) { + return m; + } + } + return null; + } + } + + @SuppressWarnings("deprecation") + public static String getMaterialName(Materials mat) { + + String mName = null; + + try { + mName = (String) ReflectionUtils.getField(Materials.class, "mDefaultLocalName") + .get(mat); + if (mName == null) { + mName = (String) + ReflectionUtils.getField(Materials.class, "mName").get(mat); + } + } catch (IllegalArgumentException | IllegalAccessException e) { + } + + if (mName == null || mName.equals("")) { + mName = mat.name(); + } + return mName; + } + + public static TextureSet getMostCommonTextureSet(List list) { + TypeCounter aCounter = new TypeCounter(TextureSet.class); + for (Material m : list) { + TextureSet t = m.getTextureSet(); + if (t == null) { + t = Materials.Gold.mIconSet; + } + if (t != null) { + aCounter.add(t, t.mSetName); + } + } + return aCounter.getResults(); + /*Optional r = list.stream().map(Material::getTextureSet).collect(Collectors.groupingBy(Function.identity(), Collectors.counting())).entrySet().stream().max(Map.Entry.comparingByValue()).map(Map.Entry::getKey); + TextureSet o = (r != null && r.isPresent() && r.get() != null) ? r.get() : null; + return o;*/ + } + + public static Materials getMaterial(String aMaterialName, String aFallbackMaterialName) { + Materials g = getMaterial(aMaterialName); + if (g == null) { + g = getMaterial(aFallbackMaterialName); + } + if (g == null) { + Logger.INFO("Failed finding material '" + aMaterialName + "' & fallback '" + aFallbackMaterialName + + "', returning _NULL."); + CORE.crash(); + // g = Materials._NULL; + } + return g; + } + + public static Materials getMaterial(String aMaterialName) { + Materials m = gtPlusPlus.xmod.gregtech.common.StaticFields59.getMaterial(aMaterialName); + if (m == null) { + m = getMaterialByName(aMaterialName); + } + if (m == null) { + Logger.INFO("Failed finding material '" + aMaterialName + "', returning _NULL."); + m = Materials._NULL; + } + return m; + } + + public static AutoMap getCompoundMaterialsRecursively(Material aMat) { + return getCompoundMaterialsRecursively_Speiger(aMat); + /* + AutoMap aDataSet = new AutoMap(); + final int HARD_LIMIT = 1000; + int mLoopCounter = 0; + if (aMat.getComposites().size() > 0) { + try { + List xList = Lists.newLinkedList(); + for (MaterialStack kj : aMat.getComposites()) { + xList.add(kj.getStackMaterial()); + } + if (xList.isEmpty()) { + aDataSet.put(aMat); + return aDataSet; + } + ListIterator listIterator = xList.listIterator(); + while(listIterator.hasNext()){ + Material e = listIterator.next(); + listIterator.remove(); + if (mLoopCounter > HARD_LIMIT) { + break; + } + + if (e.getComposites().isEmpty()) { + aDataSet.put(e); + } + else { + for (MaterialStack x : e.getComposites()) { + listIterator.add(x.getStackMaterial()); + } + } + mLoopCounter++; + + + }} + catch (Throwable t) { + aDataSet.put(aMat); + t.printStackTrace(); + } + } + if (aDataSet.isEmpty()) { + aDataSet.put(aMat); + return aDataSet; + } + return aDataSet; + */ } + + public static AutoMap getCompoundMaterialsRecursively_Speiger(Material toSearch) { + AutoMap resultList = new AutoMap(); + if (toSearch.getComposites().isEmpty()) { + resultList.put(toSearch); + return resultList; + } + final int HARD_LIMIT = 1000; + + // Could be a Deque but i dont use the interface + // enough to use it as default. + LinkedList toCheck = new LinkedList(); + + toCheck.add(toSearch); + int processed = 0; + while (toCheck.size() > 0 && processed < HARD_LIMIT) { + Material current = toCheck.remove(); + if (current.getComposites().isEmpty()) { + resultList.put(current); + } else { + for (MaterialStack entry : current.getComposites()) { + toCheck.add(entry.getStackMaterial()); + } + } + processed++; + } + return resultList; + } + + public static void generateComponentAndAssignToAMaterial(ComponentTypes aType, Material aMaterial) { + generateComponentAndAssignToAMaterial(aType, aMaterial, true); + } + + public static void generateComponentAndAssignToAMaterial( + ComponentTypes aType, Material aMaterial, boolean generateRecipes) { + Item aGC; + if (aType == ComponentTypes.PLATEHEAVY) { + aGC = new BaseItemPlateHeavy(aMaterial); + } else if (aType == ComponentTypes.FINEWIRE) { + aGC = new BaseItemFineWire(aMaterial); + } else if (aType == ComponentTypes.FOIL) { + aGC = new BaseItemFoil(aMaterial); + } else { + aGC = new BaseItemComponent(aMaterial, aType); + } + if (aGC != null) { + String aFormattedLangName = aType.getName(); + + if (!aFormattedLangName.startsWith(" ")) { + if (aFormattedLangName.contains("@")) { + String[] aSplit = aFormattedLangName.split("@"); + aFormattedLangName = aSplit[0] + " " + aMaterial.getLocalizedName() + " " + aSplit[1]; + } + } + + if (aFormattedLangName.equals(aType.getName())) { + aFormattedLangName = aMaterial.getLocalizedName() + aFormattedLangName; + } + + Logger.MATERIALS("[Lang] " + aGC.getUnlocalizedName() + ".name=" + aFormattedLangName); + aMaterial.registerComponentForMaterial(aType, ItemUtils.getSimpleStack(aGC)); + } + } + + public static void generateSpecialDustAndAssignToAMaterial(Material aMaterial) { + generateSpecialDustAndAssignToAMaterial(aMaterial, true); + } + + public static void generateSpecialDustAndAssignToAMaterial(Material aMaterial, boolean generateMixerRecipes) { + Item[] aDusts = ItemUtils.generateSpecialUseDusts(aMaterial, false, Utils.invertBoolean(generateMixerRecipes)); + if (aDusts != null && aDusts.length > 0) { + aMaterial.registerComponentForMaterial(OrePrefixes.dust, ItemUtils.getSimpleStack(aDusts[0])); + aMaterial.registerComponentForMaterial(OrePrefixes.dustSmall, ItemUtils.getSimpleStack(aDusts[1])); + aMaterial.registerComponentForMaterial(OrePrefixes.dustTiny, ItemUtils.getSimpleStack(aDusts[2])); + } + } + + public static boolean doesMaterialExist(String aMatName) { + for (Materials m : Materials.values()) { + if (m.name().toLowerCase().equals(aMatName.toLowerCase())) { + return true; + } + } + return false; + } + + public static boolean isNullGregtechMaterial(Materials aGregtechMaterial) { + if (aGregtechMaterial == Materials._NULL + || aGregtechMaterial.equals(Materials._NULL) + || aGregtechMaterial.name().equals(Materials._NULL.name())) { + return true; + } + return false; + } +} diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/MiningUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/MiningUtils.java index 080b5665a3..cdfe1e5076 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/MiningUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/MiningUtils.java @@ -1,265 +1,266 @@ package gtPlusPlus.core.util.minecraft; +import gregtech.common.GT_Worldgen_GT_Ore_Layer; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import java.util.HashMap; - import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.world.World; -import gregtech.common.GT_Worldgen_GT_Ore_Layer; +public class MiningUtils { -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.data.AutoMap; -import gtPlusPlus.core.util.reflect.ReflectionUtils; + public static Boolean canPickaxeBlock(final Block currentBlock, final World currentWorld) { + String correctTool = ""; + if (!currentWorld.isRemote) { + try { + correctTool = currentBlock.getHarvestTool(0); + // Utils.LOG_WARNING(correctTool); + if (correctTool.equals("pickaxe")) { + return true; + } + } catch (final NullPointerException e) { + return false; + } + } + return false; + } -public class MiningUtils { + private static void removeBlockAndDropAsItem(final World world, final int X, final int Y, final int Z) { + try { + final Block block = world.getBlock(X, Y, Z); + if (canPickaxeBlock(block, world)) { + if ((block != Blocks.bedrock) + && (block.getBlockHardness(world, X, Y, Z) != -1) + && (block.getBlockHardness(world, X, Y, Z) <= 100) + && (block != Blocks.water) + && (block != Blocks.lava)) { + block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0); + world.setBlockToAir(X, Y, Z); + + } else { + Logger.WARNING("Incorrect Tool for mining this block."); + } + } + } catch (final NullPointerException e) { + + } + } + + public static boolean getBlockType(final Block block, final World world, final int[] xyz, final int miningLevel) { + final String LIQUID = "liquid"; + final String BLOCK = "block"; + final String ORE = "ore"; + final String AIR = "air"; + String blockClass = ""; + + if (world.isRemote) { + return false; + } + + if (block == Blocks.end_stone) { + return true; + } + if (block == Blocks.stone) { + return true; + } + if (block == Blocks.sandstone) { + return true; + } + if (block == Blocks.netherrack) { + return true; + } + if (block == Blocks.nether_brick) { + return true; + } + if (block == Blocks.nether_brick_stairs) { + return true; + } + if (block == Blocks.nether_brick_fence) { + return true; + } + if (block == Blocks.glowstone) { + return true; + } + + try { + blockClass = block.getClass().toString().toLowerCase(); + Logger.WARNING(blockClass); + if (blockClass.toLowerCase().contains(LIQUID)) { + Logger.WARNING(block.toString() + " is a Liquid."); + return false; + } else if (blockClass.toLowerCase().contains(ORE)) { + Logger.WARNING(block.toString() + " is an Ore."); + return true; + } else if (block.getHarvestLevel(world.getBlockMetadata(xyz[0], xyz[1], xyz[2])) >= miningLevel) { + Logger.WARNING(block.toString() + " is minable."); + return true; + } else if (blockClass.toLowerCase().contains(AIR)) { + Logger.WARNING(block.toString() + " is Air."); + return false; + } else if (blockClass.toLowerCase().contains(BLOCK)) { + Logger.WARNING(block.toString() + " is a block of some kind."); + return false; + } else { + Logger.WARNING(block.toString() + " is mystery."); + return false; + } + } catch (final NullPointerException e) { + return false; + } + } + + public static int mMoonID = -99; + public static int mMarsID = -99; + public static int mCometsID = -99; - public static Boolean canPickaxeBlock(final Block currentBlock, final World currentWorld){ - String correctTool = ""; - if (!currentWorld.isRemote){ - try { - correctTool = currentBlock.getHarvestTool(0); - //Utils.LOG_WARNING(correctTool); - if (correctTool.equals("pickaxe")){ - return true;} - } catch (final NullPointerException e){ - return false;} - } - return false; - } + public static AutoMap getOresForDim(int dim) { + if (dim == -1) { + return Ores_Nether; + } else if (dim == 1) { + return Ores_End; + } else if (dim == mMoonID) { + return Ores_Moon; + } else if (dim == mMarsID) { + return Ores_Mars; + } else if (dim == mCometsID) { + return Ores_Comets; + } else { + return Ores_Overworld; + } + } - private static void removeBlockAndDropAsItem(final World world, final int X, final int Y, final int Z){ - try { - final Block block = world.getBlock(X, Y, Z); - if (canPickaxeBlock(block, world)){ - if((block != Blocks.bedrock) && (block.getBlockHardness(world, X, Y, Z) != -1) && (block.getBlockHardness(world, X, Y, Z) <= 100) && (block != Blocks.water) && (block != Blocks.lava)){ - block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0); - world.setBlockToAir(X, Y, Z); + public static void iterateAllOreTypes() { + HashMap M = new HashMap(); + String aTextWorldGen = null; + if (MiningUtils.findAndMapOreTypesFromGT()) { + int mapKey = 0; + for (AutoMap g : MiningUtils.mOreMaps) { + for (GT_Worldgen_GT_Ore_Layer h : g) { - } - else { - Logger.WARNING("Incorrect Tool for mining this block."); - } - } - } catch (final NullPointerException e){ + try { + aTextWorldGen = + (String) ReflectionUtils.getField(GT_Worldgen_GT_Ore_Layer.class, "aTextWorldgen") + .get(h); + } catch (IllegalArgumentException | IllegalAccessException e) { + aTextWorldGen = h.mWorldGenName; + } - } - } + // if (M.containsKey(h.aTextWorldgen + h.mWorldGenName)) { + M.put(aTextWorldGen + h.mWorldGenName, mapKey); + Logger.INFO("Found Vein type: " + aTextWorldGen + h.mWorldGenName + " in map with key: " + mapKey); + // } + } + mapKey++; + } + } + } - public static boolean getBlockType(final Block block, final World world, final int[] xyz, final int miningLevel){ - final String LIQUID = "liquid"; - final String BLOCK = "block"; - final String ORE = "ore"; - final String AIR = "air"; - String blockClass = ""; + public static AutoMap[] mOreMaps = new AutoMap[7]; + private static AutoMap Ores_Overworld = new AutoMap(); + private static AutoMap Ores_Nether = new AutoMap(); + private static AutoMap Ores_End = new AutoMap(); + private static AutoMap Ores_Moon = new AutoMap(); + private static AutoMap Ores_Mars = new AutoMap(); + private static AutoMap Ores_Comets = new AutoMap(); + private static AutoMap Ores_Misc = new AutoMap(); - if (world.isRemote){ - return false; - } + public static boolean findAndMapOreTypesFromGT() { + // Gets Moon ID - if (block == Blocks.end_stone) { - return true; - } - if (block == Blocks.stone) { - return true; - } - if (block == Blocks.sandstone) { - return true; - } - if (block == Blocks.netherrack) { - return true; - } - if (block == Blocks.nether_brick) { - return true; - } - if (block == Blocks.nether_brick_stairs) { - return true; - } - if (block == Blocks.nether_brick_fence) { - return true; - } - if (block == Blocks.glowstone) { - return true; - } + boolean aEndAsteroids; + try { + if (ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.util.ConfigManagerCore") != null + && mMoonID == -99) { + mMoonID = ReflectionUtils.getField( + ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.util.ConfigManagerCore"), + "idDimensionMoon") + .getInt(null); + } + } catch (IllegalArgumentException | IllegalAccessException e) { + } + // Gets Mars ID + try { + if (ReflectionUtils.getClass("micdoodle8.mods.galacticraft.planets.mars.ConfigManagerMars") != null + && mMarsID == -99) { + mMarsID = ReflectionUtils.getField( + ReflectionUtils.getClass("micdoodle8.mods.galacticraft.planets.mars.ConfigManagerMars"), + "dimensionIDMars") + .getInt(null); + } + } catch (IllegalArgumentException | IllegalAccessException e) { + } + // Get Comets ID + try { + if (ReflectionUtils.getClass("micdoodle8.mods.galacticraft.planets.asteroids.ConfigManagerAsteroids") + != null + && mCometsID == -99) { + mCometsID = ReflectionUtils.getField( + ReflectionUtils.getClass( + "micdoodle8.mods.galacticraft.planets.asteroids.ConfigManagerAsteroids"), + "dimensionIDAsteroids") + .getInt(null); + } + } catch (IllegalArgumentException | IllegalAccessException e) { + } - try { - blockClass = block.getClass().toString().toLowerCase(); - Logger.WARNING(blockClass); - if (blockClass.toLowerCase().contains(LIQUID)){ - Logger.WARNING(block.toString()+" is a Liquid."); - return false; - } - else if (blockClass.toLowerCase().contains(ORE)){ - Logger.WARNING(block.toString()+" is an Ore."); - return true; - } - else if (block.getHarvestLevel(world.getBlockMetadata(xyz[0], xyz[1], xyz[2])) >= miningLevel){ - Logger.WARNING(block.toString()+" is minable."); - return true; - } - else if (blockClass.toLowerCase().contains(AIR)){ - Logger.WARNING(block.toString()+" is Air."); - return false; - } - else if (blockClass.toLowerCase().contains(BLOCK)){ - Logger.WARNING(block.toString()+" is a block of some kind."); - return false; - } - else { - Logger.WARNING(block.toString()+" is mystery."); - return false; - } - } - catch(final NullPointerException e){ - return false; - } - } + // Clear Cache + Ores_Overworld.clear(); + Ores_Nether.clear(); + Ores_End.clear(); + Ores_Misc.clear(); - public static int mMoonID =-99; - public static int mMarsID = -99; - public static int mCometsID = -99; - public static AutoMap getOresForDim(int dim) { - if (dim == -1) { - return Ores_Nether; - } - else if (dim == 1) { - return Ores_End; - } - else if (dim == mMoonID) { - return Ores_Moon; - } - else if (dim == mMarsID) { - return Ores_Mars; - } - else if (dim == mCometsID) { - return Ores_Comets; - } - else { - return Ores_Overworld; - } - - } - - public static void iterateAllOreTypes() { - HashMap M = new HashMap(); - String aTextWorldGen = null; - if (MiningUtils.findAndMapOreTypesFromGT()) { - int mapKey = 0; - for (AutoMap g : MiningUtils.mOreMaps) { - for (GT_Worldgen_GT_Ore_Layer h : g) { - - try { - aTextWorldGen = (String) ReflectionUtils.getField(GT_Worldgen_GT_Ore_Layer.class, "aTextWorldgen").get(h); - } catch (IllegalArgumentException | IllegalAccessException e) { - aTextWorldGen = h.mWorldGenName; - } - - //if (M.containsKey(h.aTextWorldgen + h.mWorldGenName)) { - M.put(aTextWorldGen + h.mWorldGenName, mapKey); - Logger.INFO("Found Vein type: " + aTextWorldGen + h.mWorldGenName + " in map with key: "+mapKey); - //} - } - mapKey++; - } - } - } - - public static AutoMap[] mOreMaps = new AutoMap[7]; - private static AutoMap Ores_Overworld = new AutoMap(); - private static AutoMap Ores_Nether = new AutoMap(); - private static AutoMap Ores_End = new AutoMap(); - private static AutoMap Ores_Moon = new AutoMap(); - private static AutoMap Ores_Mars = new AutoMap(); - private static AutoMap Ores_Comets = new AutoMap(); - private static AutoMap Ores_Misc = new AutoMap(); - - public static boolean findAndMapOreTypesFromGT() { - //Gets Moon ID - - boolean aEndAsteroids; - try { - if (ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.util.ConfigManagerCore") != null && mMoonID == -99) { - mMoonID = ReflectionUtils.getField(ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.util.ConfigManagerCore"), "idDimensionMoon").getInt(null); - } - } - catch (IllegalArgumentException | IllegalAccessException e) {} - - //Gets Mars ID - try { - if (ReflectionUtils.getClass("micdoodle8.mods.galacticraft.planets.mars.ConfigManagerMars") != null && mMarsID == -99) { - mMarsID = ReflectionUtils.getField(ReflectionUtils.getClass("micdoodle8.mods.galacticraft.planets.mars.ConfigManagerMars"), "dimensionIDMars").getInt(null); - } - } - catch (IllegalArgumentException | IllegalAccessException e) {} - - //Get Comets ID - try { - if (ReflectionUtils.getClass("micdoodle8.mods.galacticraft.planets.asteroids.ConfigManagerAsteroids") != null && mCometsID == -99) { - mCometsID = ReflectionUtils.getField(ReflectionUtils.getClass("micdoodle8.mods.galacticraft.planets.asteroids.ConfigManagerAsteroids"), "dimensionIDAsteroids").getInt(null); - } - } - catch (IllegalArgumentException | IllegalAccessException e) {} + for (GT_Worldgen_GT_Ore_Layer x : GT_Worldgen_GT_Ore_Layer.sList) { + if (x.mEnabled) { - //Clear Cache - Ores_Overworld.clear(); - Ores_Nether.clear(); - Ores_End.clear(); - Ores_Misc.clear(); - - for (GT_Worldgen_GT_Ore_Layer x : GT_Worldgen_GT_Ore_Layer.sList) { - if (x.mEnabled) { - + try { + aEndAsteroids = ReflectionUtils.getField(GT_Worldgen_GT_Ore_Layer.class, "mEndAsteroid") + .getBoolean(x); + } catch (IllegalArgumentException | IllegalAccessException e) { + aEndAsteroids = false; + } - try { - aEndAsteroids = ReflectionUtils.getField(GT_Worldgen_GT_Ore_Layer.class, "mEndAsteroid").getBoolean(x); - } - catch (IllegalArgumentException | IllegalAccessException e) { - aEndAsteroids = false; - } - - if (x.mOverworld) { - Ores_Overworld.put(x); - } - if (x.mNether) { - Ores_Nether.put(x); - } - if (x.mEnd || aEndAsteroids) { - Ores_End.put(x); - } - if (x.mOverworld || x.mNether || (x.mEnd || aEndAsteroids)) { - continue; - } - /*if (x.mMoon) { - Ores_Moon.put(x); - continue; - } - if (x.mMars) { - Ores_Mars.put(x); - continue; - } - if (x.mAsteroid) { - Ores_Comets.put(x); - continue; - }*/ - Ores_Misc.put(x); - continue; - } - else { - Ores_Comets.put(x); - } - } - - - mOreMaps[0] = Ores_Overworld; - mOreMaps[1] = Ores_Nether; - mOreMaps[2] = Ores_End; - mOreMaps[3] = Ores_Moon; - mOreMaps[4] = Ores_Mars; - mOreMaps[5] = Ores_Comets; - mOreMaps[6] = Ores_Misc; - return true; - } + if (x.mOverworld) { + Ores_Overworld.put(x); + } + if (x.mNether) { + Ores_Nether.put(x); + } + if (x.mEnd || aEndAsteroids) { + Ores_End.put(x); + } + if (x.mOverworld || x.mNether || (x.mEnd || aEndAsteroids)) { + continue; + } + /*if (x.mMoon) { + Ores_Moon.put(x); + continue; + } + if (x.mMars) { + Ores_Mars.put(x); + continue; + } + if (x.mAsteroid) { + Ores_Comets.put(x); + continue; + }*/ + Ores_Misc.put(x); + continue; + } else { + Ores_Comets.put(x); + } + } + mOreMaps[0] = Ores_Overworld; + mOreMaps[1] = Ores_Nether; + mOreMaps[2] = Ores_End; + mOreMaps[3] = Ores_Moon; + mOreMaps[4] = Ores_Mars; + mOreMaps[5] = Ores_Comets; + mOreMaps[6] = Ores_Misc; + return true; + } } diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/ModularArmourUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/ModularArmourUtils.java index e3ffb5c410..c4eb8cff64 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/ModularArmourUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/ModularArmourUtils.java @@ -1,161 +1,162 @@ package gtPlusPlus.core.util.minecraft; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -import gregtech.api.util.GT_Utility; - import baubles.api.BaubleType; +import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.Pair; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; public class ModularArmourUtils { - public static ItemStack addComponent(ItemStack tArmour, ItemStack[] tComponents) { - if (tArmour != null) { - ItemStack rArmour = NBTUtils.writeItemsToGtCraftingComponents(tArmour, tComponents, true); - if (rArmour != null) { - - } - } - return null; - } - - public static enum Modifiers { - BOOST_HP("skill.hpboost"), BOOST_DEF("skill.defenceboost"), BOOST_SPEED("skill.speedboost"), BOOST_MINING( - "skill.miningboost"), BOOST_DAMAGE("skill.damageboost"), BOOST_HOLY("skill.holyboost"); - private String MODIFIER_NAME; - - private Modifiers(final String mModifier) { - this.MODIFIER_NAME = mModifier; - } - - public String getModifier() { - return this.MODIFIER_NAME; - } - - public boolean isValidLevel(int i) { - if (i >= 0 && i <= 100) { - return true; - } - return false; - } - } - - public static enum BT { - TYPE_AMULET(BaubleType.AMULET, 0), TYPE_RING(BaubleType.RING, 1), TYPE_BELT(BaubleType.BELT, 2); - private final BaubleType mType; - private final int mID; - private final String mBaubleType; - - private BT(final BaubleType tType, int tID) { - this.mType = tType; - this.mID = tID; - this.mBaubleType = tType.name().toLowerCase(); - } - - public BaubleType getType() { - return this.mType; - } - - public BT getThis() { - return this; - } - - public BaubleType getBaubleByID(int tID) { - if (tID == 0) { - return BaubleType.AMULET; - } else if (tID == 1) { - return BaubleType.RING; - } else if (tID == 2) { - return BaubleType.BELT; - } else { - return BaubleType.RING; - } - } - - public int getID() { - return this.mID; - } - - public String getTypeAsString() { - return this.mBaubleType; - } - } - - public static void setModifierLevel(ItemStack aStack, Pair mPair) { - setModifierLevel(aStack, mPair.getKey(), mPair.getValue().intValue()); - } - - public static void setModifierLevel(ItemStack aStack, Modifiers aMod, Integer aInt) { - setModifierLevel(aStack, aMod, aInt.intValue()); - } - - public static void setModifierLevel(ItemStack aStack, Modifiers aMod, int aInt) { - - int mCurrentLevel = getModifierLevel(aStack, aMod); - int mNewTotalLevel = mCurrentLevel + aInt; - - NBTTagCompound tNBT = NBTUtils.getNBT(aStack); - if (aMod.isValidLevel(mNewTotalLevel)) { - tNBT.setInteger(aMod.getModifier(), mNewTotalLevel); - GT_Utility.ItemNBT.setNBT(aStack, tNBT); - } else { - if (getModifierLevel(aStack, aMod) > 100) { - setModifierLevel(aStack, aMod, 100); - } - } - } - - public static int getModifierLevel(ItemStack aStack, Pair newPair) { - return getModifierLevel(aStack, newPair.getKey()); - } - - public static int getModifierLevel(ItemStack aStack, Modifiers aMod) { - NBTTagCompound tNBT = NBTUtils.getNBT(aStack); - return tNBT.getInteger(aMod.getModifier()); - } - - public static void setBaubleType(ItemStack aStack, BT aMod) { - Logger.INFO("Changing bauble type."); - NBTTagCompound tNBT = NBTUtils.getNBT(aStack); - if (aMod != null) { - tNBT.setInteger("mBaubleType", aMod.getID()); - GT_Utility.ItemNBT.setNBT(aStack, tNBT); - } - } - - public static int getBaubleTypeID(ItemStack aStack) { - NBTTagCompound tNBT = NBTUtils.getNBT(aStack); - return tNBT.getInteger("mBaubleType"); - } - - public static BaubleType getBaubleType(ItemStack aStack) { - NBTTagCompound tNBT = NBTUtils.getNBT(aStack); - return getBaubleByID(tNBT.getInteger("mBaubleType")); - } - - public static BaubleType getBaubleByID(int tID) { - if (tID == 0) { - return BaubleType.AMULET; - } else if (tID == 1) { - return BaubleType.RING; - } else if (tID == 2) { - return BaubleType.BELT; - } else { - return BaubleType.RING; - } - } - - public static ItemStack setDefaultStats(ItemStack aStack) { - ItemStack tempStack = aStack; - setModifierLevel(tempStack, Modifiers.BOOST_DAMAGE, 0); - setModifierLevel(tempStack, Modifiers.BOOST_DEF, 0); - setModifierLevel(tempStack, Modifiers.BOOST_HOLY, 0); - setModifierLevel(tempStack, Modifiers.BOOST_HP, 0); - setModifierLevel(tempStack, Modifiers.BOOST_MINING, 0); - setModifierLevel(tempStack, Modifiers.BOOST_SPEED, 0); - return tempStack; - } - + public static ItemStack addComponent(ItemStack tArmour, ItemStack[] tComponents) { + if (tArmour != null) { + ItemStack rArmour = NBTUtils.writeItemsToGtCraftingComponents(tArmour, tComponents, true); + if (rArmour != null) {} + } + return null; + } + + public static enum Modifiers { + BOOST_HP("skill.hpboost"), + BOOST_DEF("skill.defenceboost"), + BOOST_SPEED("skill.speedboost"), + BOOST_MINING("skill.miningboost"), + BOOST_DAMAGE("skill.damageboost"), + BOOST_HOLY("skill.holyboost"); + private String MODIFIER_NAME; + + private Modifiers(final String mModifier) { + this.MODIFIER_NAME = mModifier; + } + + public String getModifier() { + return this.MODIFIER_NAME; + } + + public boolean isValidLevel(int i) { + if (i >= 0 && i <= 100) { + return true; + } + return false; + } + } + + public static enum BT { + TYPE_AMULET(BaubleType.AMULET, 0), + TYPE_RING(BaubleType.RING, 1), + TYPE_BELT(BaubleType.BELT, 2); + private final BaubleType mType; + private final int mID; + private final String mBaubleType; + + private BT(final BaubleType tType, int tID) { + this.mType = tType; + this.mID = tID; + this.mBaubleType = tType.name().toLowerCase(); + } + + public BaubleType getType() { + return this.mType; + } + + public BT getThis() { + return this; + } + + public BaubleType getBaubleByID(int tID) { + if (tID == 0) { + return BaubleType.AMULET; + } else if (tID == 1) { + return BaubleType.RING; + } else if (tID == 2) { + return BaubleType.BELT; + } else { + return BaubleType.RING; + } + } + + public int getID() { + return this.mID; + } + + public String getTypeAsString() { + return this.mBaubleType; + } + } + + public static void setModifierLevel(ItemStack aStack, Pair mPair) { + setModifierLevel(aStack, mPair.getKey(), mPair.getValue().intValue()); + } + + public static void setModifierLevel(ItemStack aStack, Modifiers aMod, Integer aInt) { + setModifierLevel(aStack, aMod, aInt.intValue()); + } + + public static void setModifierLevel(ItemStack aStack, Modifiers aMod, int aInt) { + + int mCurrentLevel = getModifierLevel(aStack, aMod); + int mNewTotalLevel = mCurrentLevel + aInt; + + NBTTagCompound tNBT = NBTUtils.getNBT(aStack); + if (aMod.isValidLevel(mNewTotalLevel)) { + tNBT.setInteger(aMod.getModifier(), mNewTotalLevel); + GT_Utility.ItemNBT.setNBT(aStack, tNBT); + } else { + if (getModifierLevel(aStack, aMod) > 100) { + setModifierLevel(aStack, aMod, 100); + } + } + } + + public static int getModifierLevel(ItemStack aStack, Pair newPair) { + return getModifierLevel(aStack, newPair.getKey()); + } + + public static int getModifierLevel(ItemStack aStack, Modifiers aMod) { + NBTTagCompound tNBT = NBTUtils.getNBT(aStack); + return tNBT.getInteger(aMod.getModifier()); + } + + public static void setBaubleType(ItemStack aStack, BT aMod) { + Logger.INFO("Changing bauble type."); + NBTTagCompound tNBT = NBTUtils.getNBT(aStack); + if (aMod != null) { + tNBT.setInteger("mBaubleType", aMod.getID()); + GT_Utility.ItemNBT.setNBT(aStack, tNBT); + } + } + + public static int getBaubleTypeID(ItemStack aStack) { + NBTTagCompound tNBT = NBTUtils.getNBT(aStack); + return tNBT.getInteger("mBaubleType"); + } + + public static BaubleType getBaubleType(ItemStack aStack) { + NBTTagCompound tNBT = NBTUtils.getNBT(aStack); + return getBaubleByID(tNBT.getInteger("mBaubleType")); + } + + public static BaubleType getBaubleByID(int tID) { + if (tID == 0) { + return BaubleType.AMULET; + } else if (tID == 1) { + return BaubleType.RING; + } else if (tID == 2) { + return BaubleType.BELT; + } else { + return BaubleType.RING; + } + } + + public static ItemStack setDefaultStats(ItemStack aStack) { + ItemStack tempStack = aStack; + setModifierLevel(tempStack, Modifiers.BOOST_DAMAGE, 0); + setModifierLevel(tempStack, Modifiers.BOOST_DEF, 0); + setModifierLevel(tempStack, Modifiers.BOOST_HOLY, 0); + setModifierLevel(tempStack, Modifiers.BOOST_HP, 0); + setModifierLevel(tempStack, Modifiers.BOOST_MINING, 0); + setModifierLevel(tempStack, Modifiers.BOOST_SPEED, 0); + return tempStack; + } } diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/NBTUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/NBTUtils.java index 7ed4d887cc..c235cd0e0b 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/NBTUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/NBTUtils.java @@ -2,579 +2,575 @@ package gtPlusPlus.core.util.minecraft; import static gtPlusPlus.core.item.ModItems.ZZZ_Empty; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import java.util.HashMap; import java.util.Map; - import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -import gregtech.api.items.GT_MetaGenerated_Tool; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Utility; - -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.util.reflect.ReflectionUtils; - public class NBTUtils { - public static NBTTagCompound getNBT(ItemStack aStack) { - NBTTagCompound rNBT = aStack.getTagCompound(); - return ((rNBT == null) ? new NBTTagCompound() : rNBT); - } - - public static void setBookTitle(ItemStack aStack, String aTitle) { - NBTTagCompound tNBT = getNBT(aStack); - tNBT.setString("title", aTitle); - GT_Utility.ItemNBT.setNBT(aStack, tNBT); - } - - public static String getBookTitle(ItemStack aStack) { - NBTTagCompound tNBT = getNBT(aStack); - return tNBT.getString("title"); - } - - public static ItemStack[] readItemsFromNBT(ItemStack itemstack) { - NBTTagCompound tNBT = getNBT(itemstack); - final NBTTagList list = tNBT.getTagList("Items", 10); - ItemStack inventory[] = new ItemStack[list.tagCount()]; - for (int i = 0; i < list.tagCount(); i++) { - final NBTTagCompound data = list.getCompoundTagAt(i); - final int slot = data.getInteger("Slot"); - if ((slot >= 0) && (slot < list.tagCount())) { - if (ItemStack.loadItemStackFromNBT(data) == ItemUtils.getSimpleStack(ZZZ_Empty)) { - inventory[slot] = null; - } else { - inventory[slot] = ItemStack.loadItemStackFromNBT(data); - } - - } - } - return inventory; - } - - public static ItemStack[] readItemsFromNBT(ItemStack itemstack, String customkey) { - NBTTagCompound tNBT = getNBT(itemstack); - final NBTTagList list = tNBT.getTagList(customkey, 10); - ItemStack inventory[] = new ItemStack[list.tagCount()]; - for (int i = 0; i < list.tagCount(); i++) { - final NBTTagCompound data = list.getCompoundTagAt(i); - final int slot = data.getInteger("Slot"); - if ((slot >= 0) && (slot < list.tagCount())) { - if (ItemStack.loadItemStackFromNBT(data) == ItemUtils.getSimpleStack(ZZZ_Empty)) { - inventory[slot] = null; - } else { - inventory[slot] = ItemStack.loadItemStackFromNBT(data); - } - - } - } - return inventory; - } - - public static ItemStack writeItemsToNBT(ItemStack itemstack, ItemStack[] stored) { - NBTTagCompound tNBT = getNBT(itemstack); - final NBTTagList list = new NBTTagList(); - for (int i = 0; i < stored.length; i++) { - final ItemStack stack = stored[i]; - if (stack != null) { - final NBTTagCompound data = new NBTTagCompound(); - stack.writeToNBT(data); - data.setInteger("Slot", i); - list.appendTag(data); - } else { - final NBTTagCompound data = new NBTTagCompound(); - ItemStack nullstack = ItemUtils.getSimpleStack(ZZZ_Empty); - nullstack.writeToNBT(data); - data.setInteger("Slot", i); - list.appendTag(data); - } - } - tNBT.setTag("Items", list); - itemstack.setTagCompound(tNBT); - return itemstack; - } - - public static ItemStack writeItemsToNBT(ItemStack itemstack, ItemStack[] stored, String customkey) { - NBTTagCompound tNBT = getNBT(itemstack); - final NBTTagList list = new NBTTagList(); - for (int i = 0; i < stored.length; i++) { - final ItemStack stack = stored[i]; - if (stack != null) { - final NBTTagCompound data = new NBTTagCompound(); - stack.writeToNBT(data); - data.setInteger("Slot", i); - list.appendTag(data); - } - } - tNBT.setTag(customkey, list); - itemstack.setTagCompound(tNBT); - return itemstack; - } - - public static ItemStack writeItemsToGtCraftingComponents(ItemStack rStack, ItemStack[] input, boolean copyTags) { - try { - ItemStack stored[] = new ItemStack[9]; - if (input.length != 9) { - for (int e=0;e mInternalMap = ReflectionUtils.getField(aNBT, "tagMap"); - if (mInternalMap != null) { - for (Map.Entry e : mInternalMap.entrySet()) { - Logger.INFO("Key: " + e.getKey().toString() + " | Value: " + e.getValue()); - } - return true; - } else { - Logger.INFO("Data map reflected from NBTTagCompound was not valid."); - return false; - } - } - } - } catch (Throwable t) {} - return false; - } - - // Botania soulbind handling - public static boolean setBotanicaSoulboundOwner(ItemStack aStack, String aName) { - final String TAG_SOULBIND = "soulbind"; - NBTTagCompound tNBT = getNBT(aStack); - tNBT.setString(TAG_SOULBIND, aName); - GT_Utility.ItemNBT.setNBT(aStack, tNBT); - if (NBTUtils.doesStringExist(aStack, TAG_SOULBIND)) { - return true; - } else { - return false; - } - } - - public static String getBotanicaSoulboundOwner(ItemStack aStack) { - final String TAG_SOULBIND = "soulbind"; - NBTTagCompound tNBT = getNBT(aStack); - return tNBT.getString(TAG_SOULBIND); - } - - public static boolean hasKey(ItemStack stack, String key) { - final NBTTagCompound itemData = getNBT(stack); - if (itemData.hasKey(key)) { - return true; - } - return false; - } - - public static boolean createIntegerTagCompound(ItemStack rStack, String tagName, String keyName, int keyValue) { - final NBTTagCompound tagMain = getNBT(rStack); - final NBTTagCompound tagNBT = new NBTTagCompound(); - tagNBT.setInteger(keyName, keyValue); - tagMain.setTag(tagName, tagNBT); - rStack.setTagCompound(tagMain); - return true; - } - - public static boolean createLongTagCompound(ItemStack rStack, String tagName, String keyName, long keyValue) { - final NBTTagCompound tagMain = getNBT(rStack); - final NBTTagCompound tagNBT = new NBTTagCompound(); - tagNBT.setLong(keyName, keyValue); - tagMain.setTag(tagName, tagNBT); - rStack.setTagCompound(tagMain); - return true; - } - - public static boolean createStringTagCompound(ItemStack rStack, String tagName, String keyName, String keyValue) { - final NBTTagCompound tagMain = getNBT(rStack); - final NBTTagCompound tagNBT = new NBTTagCompound(); - tagNBT.setString(keyName, keyValue); - tagMain.setTag(tagName, tagNBT); - rStack.setTagCompound(tagMain); - return true; - } - - public static boolean createFloatTagCompound(ItemStack rStack, String tagName, String keyName, float keyValue) { - final NBTTagCompound tagMain = getNBT(rStack); - final NBTTagCompound tagNBT = new NBTTagCompound(); - tagNBT.setFloat(keyName, keyValue); - tagMain.setTag(tagName, tagNBT); - rStack.setTagCompound(tagMain); - return true; - } - - public static boolean createDoubleTagCompound(ItemStack rStack, String tagName, String keyName, double keyValue) { - final NBTTagCompound tagMain = getNBT(rStack); - final NBTTagCompound tagNBT = new NBTTagCompound(); - tagNBT.setDouble(keyName, keyValue); - tagMain.setTag(tagName, tagNBT); - rStack.setTagCompound(tagMain); - return true; - } - - public static boolean createBooleanTagCompound(ItemStack rStack, String tagName, String keyName, boolean keyValue) { - final NBTTagCompound tagMain = getNBT(rStack); - final NBTTagCompound tagNBT = new NBTTagCompound(); - tagNBT.setBoolean(keyName, keyValue); - tagMain.setTag(tagName, tagNBT); - rStack.setTagCompound(tagMain); - return true; - } - - public static boolean createTagCompound(ItemStack rStack, String tagName, NBTTagCompound keyValue) { - final NBTTagCompound tagMain = getNBT(rStack); - NBTTagCompound tagNBT = keyValue; - tagMain.setTag(tagName, tagNBT); - rStack.setTagCompound(tagMain); - return true; - } - - public static int getIntegerTagCompound(ItemStack aStack, String tagName, String keyName) { - NBTTagCompound aNBT = getNBT(aStack); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag(tagName); - if (aNBT != null) { - return aNBT.getInteger(keyName); - } - } - return 0; - } - - public static long getLongTagCompound(ItemStack aStack, String tagName, String keyName) { - NBTTagCompound aNBT = getNBT(aStack); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag(tagName); - if (aNBT != null) { - return aNBT.getLong(keyName); - } - } - return 0L; - } - - public static String getStringTagCompound(ItemStack aStack, String tagName, String keyName) { - NBTTagCompound aNBT = getNBT(aStack); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag(tagName); - if (aNBT != null) { - return aNBT.getString(keyName); - } - } - return null; - } - - public static float getFloatTagCompound(ItemStack aStack, String tagName, String keyName) { - NBTTagCompound aNBT = getNBT(aStack); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag(tagName); - if (aNBT != null) { - return aNBT.getFloat(keyName); - } - } - return 0; - } - - public static double getDoubleTagCompound(ItemStack aStack, String tagName, String keyName) { - NBTTagCompound aNBT = getNBT(aStack); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag(tagName); - if (aNBT != null) { - return aNBT.getDouble(keyName); - } - } - return 0; - } - - public static boolean getBooleanTagCompound(ItemStack aStack, String tagName, String keyName) { - NBTTagCompound aNBT = getNBT(aStack); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag(tagName); - if (aNBT != null) { - return aNBT.getBoolean(keyName); - } - } - return false; - } - - public static NBTTagCompound getTagCompound(ItemStack aStack, String tagName) { - NBTTagCompound aNBT = getNBT(aStack); - if (aNBT != null && hasKey(aStack, tagName)) { - aNBT = aNBT.getCompoundTag(tagName); - if (aNBT != null) { - return aNBT; - } - } - return null; - } - - public static boolean hasKeyInTagCompound(ItemStack stack, String tag, String key) { - NBTTagCompound aNBT = stack.getTagCompound(); - if (aNBT != null) { - aNBT = aNBT.getCompoundTag(tag); - if (aNBT.hasKey(key)) { - return true; - } - } - return false; - } - - public static Map getTagMap(NBTTagCompound aNBT) { - Map tagMap = new HashMap(); - if (!aNBT.hasNoTags()) { - Map mInternalMap = ReflectionUtils.getField(aNBT, "tagMap"); - if (mInternalMap != null && !mInternalMap.isEmpty()) { - tagMap.putAll(mInternalMap); - } - } - return tagMap; - } - - public static boolean isTagString(NBTTagCompound aNBT, String aTagName) { - Map aTagMap = getTagMap(aNBT); - if (aTagMap != null && !aTagMap.isEmpty()) { - for (Map.Entry e : aTagMap.entrySet()) { - if (e.getKey().equals(aTagName)) { - Object aValue = e.getValue(); - if (aValue instanceof String) { - return true; - } - } - } - } - return false; - } - - public static boolean isTagInteger(NBTTagCompound aNBT, String aTagName) { - Map aTagMap = getTagMap(aNBT); - if (aTagMap != null && !aTagMap.isEmpty()) { - for (Map.Entry e : aTagMap.entrySet()) { - if (e.getKey().equals(aTagName)) { - Object aValue = e.getValue(); - if (int.class.isInstance(aValue) || aValue instanceof Integer) { - return true; - } - } - } - } - return false; - } - - public static boolean isTagLong(NBTTagCompound aNBT, String aTagName) { - Map aTagMap = getTagMap(aNBT); - if (aTagMap != null && !aTagMap.isEmpty()) { - for (Map.Entry e : aTagMap.entrySet()) { - if (e.getKey().equals(aTagName)) { - Object aValue = e.getValue(); - if (long.class.isInstance(aValue) || aValue instanceof Long) { - return true; - } - } - } - } - return false; - } - - public static boolean isTagFloat(NBTTagCompound aNBT, String aTagName) { - Map aTagMap = getTagMap(aNBT); - if (aTagMap != null && !aTagMap.isEmpty()) { - for (Map.Entry e : aTagMap.entrySet()) { - if (e.getKey().equals(aTagName)) { - Object aValue = e.getValue(); - if (float.class.isInstance(aValue) || aValue instanceof Float) { - return true; - } - } - } - } - return false; - } - - public static boolean isTagDouble(NBTTagCompound aNBT, String aTagName) { - Map aTagMap = getTagMap(aNBT); - if (aTagMap != null && !aTagMap.isEmpty()) { - for (Map.Entry e : aTagMap.entrySet()) { - if (e.getKey().equals(aTagName)) { - Object aValue = e.getValue(); - if (double.class.isInstance(aValue) || aValue instanceof Double) { - return true; - } - } - } - } - return false; - } - - public static boolean isTagBoolean(NBTTagCompound aNBT, String aTagName) { - Map aTagMap = getTagMap(aNBT); - if (aTagMap != null && !aTagMap.isEmpty()) { - for (Map.Entry e : aTagMap.entrySet()) { - if (e.getKey().equals(aTagName)) { - Object aValue = e.getValue(); - if (boolean.class.isInstance(aValue) || aValue instanceof Boolean) { - return true; - } - } - } - } - return false; - } - - public static boolean tryCloneTagCompoundDataIntoSubTag(ItemStack aStack, NBTTagCompound aTagCompound) { - try { - NBTTagCompound aNBT = aTagCompound; - if (aNBT != null) { - if (!aNBT.hasNoTags()) { - Map mInternalMap = ReflectionUtils.getField(aNBT, "tagMap"); - if (mInternalMap != null) { - for (Map.Entry e : mInternalMap.entrySet()) { - Logger.INFO("Key: " + e.getKey().toString() + " | Value: " + e.getValue().toString()); - if (e.getValue().getClass() == String.class){ - createStringTagCompound(aStack, "mEntityTag", (String) e.getKey(), (String) e.getValue()); - } - else if (e.getValue().getClass() == Boolean.class || e.getValue().getClass() == boolean.class){ - createBooleanTagCompound(aStack, "mEntityTag", (String) e.getKey(), (Boolean) e.getValue()); - } - else if (e.getValue().getClass() == Integer.class || e.getValue().getClass() == int.class){ - createIntegerTagCompound(aStack, "mEntityTag", (String) e.getKey(), (Integer) e.getValue()); - } - else if (e.getValue().getClass() == Double.class || e.getValue().getClass() == double.class){ - createDoubleTagCompound(aStack, "mEntityTag", (String) e.getKey(), (Double) e.getValue()); - } - else if (e.getValue().getClass() == Long.class || e.getValue().getClass() == long.class){ - createLongTagCompound(aStack, "mEntityTag", (String) e.getKey(), (Long) e.getValue()); - } - else if (e.getValue().getClass() == Float.class || e.getValue().getClass() == float.class){ - createFloatTagCompound(aStack, "mEntityTag", (String) e.getKey(), (Float) e.getValue()); - } - else { - - - } - - } - return true; - } - } - } - return false; - } catch (Throwable t) { - return false; - } - } - - public static NBTTagCompound getEntityCustomData(Entity aEntity){ - return ReflectionUtils.getField(aEntity, "customEntityData"); - } - - public static boolean setEntityCustomData(Entity aEntity, NBTTagCompound aTag){ - return ReflectionUtils.setField(aEntity, "customEntityData", aTag); - } - - public static boolean hasTagCompound(ItemStack aStack) { - return aStack.hasTagCompound(); - } - - public static void createEmptyTagCompound(ItemStack aStack) { - if (!hasTagCompound(aStack)) { - NBTTagCompound aTag = new NBTTagCompound(); - aStack.setTagCompound(aTag); - } - } - + public static NBTTagCompound getNBT(ItemStack aStack) { + NBTTagCompound rNBT = aStack.getTagCompound(); + return ((rNBT == null) ? new NBTTagCompound() : rNBT); + } + + public static void setBookTitle(ItemStack aStack, String aTitle) { + NBTTagCompound tNBT = getNBT(aStack); + tNBT.setString("title", aTitle); + GT_Utility.ItemNBT.setNBT(aStack, tNBT); + } + + public static String getBookTitle(ItemStack aStack) { + NBTTagCompound tNBT = getNBT(aStack); + return tNBT.getString("title"); + } + + public static ItemStack[] readItemsFromNBT(ItemStack itemstack) { + NBTTagCompound tNBT = getNBT(itemstack); + final NBTTagList list = tNBT.getTagList("Items", 10); + ItemStack inventory[] = new ItemStack[list.tagCount()]; + for (int i = 0; i < list.tagCount(); i++) { + final NBTTagCompound data = list.getCompoundTagAt(i); + final int slot = data.getInteger("Slot"); + if ((slot >= 0) && (slot < list.tagCount())) { + if (ItemStack.loadItemStackFromNBT(data) == ItemUtils.getSimpleStack(ZZZ_Empty)) { + inventory[slot] = null; + } else { + inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + return inventory; + } + + public static ItemStack[] readItemsFromNBT(ItemStack itemstack, String customkey) { + NBTTagCompound tNBT = getNBT(itemstack); + final NBTTagList list = tNBT.getTagList(customkey, 10); + ItemStack inventory[] = new ItemStack[list.tagCount()]; + for (int i = 0; i < list.tagCount(); i++) { + final NBTTagCompound data = list.getCompoundTagAt(i); + final int slot = data.getInteger("Slot"); + if ((slot >= 0) && (slot < list.tagCount())) { + if (ItemStack.loadItemStackFromNBT(data) == ItemUtils.getSimpleStack(ZZZ_Empty)) { + inventory[slot] = null; + } else { + inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + return inventory; + } + + public static ItemStack writeItemsToNBT(ItemStack itemstack, ItemStack[] stored) { + NBTTagCompound tNBT = getNBT(itemstack); + final NBTTagList list = new NBTTagList(); + for (int i = 0; i < stored.length; i++) { + final ItemStack stack = stored[i]; + if (stack != null) { + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } else { + final NBTTagCompound data = new NBTTagCompound(); + ItemStack nullstack = ItemUtils.getSimpleStack(ZZZ_Empty); + nullstack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + tNBT.setTag("Items", list); + itemstack.setTagCompound(tNBT); + return itemstack; + } + + public static ItemStack writeItemsToNBT(ItemStack itemstack, ItemStack[] stored, String customkey) { + NBTTagCompound tNBT = getNBT(itemstack); + final NBTTagList list = new NBTTagList(); + for (int i = 0; i < stored.length; i++) { + final ItemStack stack = stored[i]; + if (stack != null) { + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + tNBT.setTag(customkey, list); + itemstack.setTagCompound(tNBT); + return itemstack; + } + + public static ItemStack writeItemsToGtCraftingComponents(ItemStack rStack, ItemStack[] input, boolean copyTags) { + try { + ItemStack stored[] = new ItemStack[9]; + if (input.length != 9) { + for (int e = 0; e < input.length; e++) { + if (input[e] != null) stored[e] = input[e]; + } + } + + if (copyTags) { + for (int i = 0; i < stored.length; i++) { + if (stored[i] != null && stored[i].hasTagCompound()) { + rStack.setTagCompound( + (NBTTagCompound) stored[i].getTagCompound().copy()); + break; + } + } + } + + NBTTagCompound rNBT = rStack.getTagCompound(), tNBT = new NBTTagCompound(); + if (rNBT == null) rNBT = new NBTTagCompound(); + for (int i = 0; i < 9; i++) { + ItemStack tStack = stored[i]; + if (tStack != null + && GT_Utility.getContainerItem(tStack, true) == null + && !(tStack.getItem() instanceof GT_MetaGenerated_Tool)) { + tStack = GT_Utility.copyAmount(1, tStack); + if (GT_Utility.isStackValid(tStack)) { + GT_ModHandler.dischargeElectricItem( + tStack, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false, true); + tNBT.setTag("Ingredient." + i, tStack.writeToNBT(new NBTTagCompound())); + } + } + } + rNBT.setTag("GT.CraftingComponents", tNBT); + rStack.setTagCompound(rNBT); + } catch (Throwable t) { + t.printStackTrace(); + } + return rStack; + } + + public static void setBoolean(ItemStack aStack, String aTag, boolean aBoolean) { + NBTTagCompound tNBT = getNBT(aStack); + tNBT.setBoolean(aTag, aBoolean); + GT_Utility.ItemNBT.setNBT(aStack, tNBT); + } + + public static boolean getBoolean(ItemStack aStack, String aTag) { + NBTTagCompound tNBT = getNBT(aStack); + return tNBT.getBoolean(aTag); + } + + public static void setInteger(ItemStack aStack, String aTag, int aInt) { + NBTTagCompound tNBT = getNBT(aStack); + tNBT.setInteger(aTag, aInt); + GT_Utility.ItemNBT.setNBT(aStack, tNBT); + } + + public static int getInteger(ItemStack aStack, String aTag) { + NBTTagCompound tNBT = getNBT(aStack); + return tNBT.getInteger(aTag); + } + + public static void setLong(ItemStack aStack, String aTag, long aInt) { + NBTTagCompound tNBT = getNBT(aStack); + tNBT.setLong(aTag, aInt); + GT_Utility.ItemNBT.setNBT(aStack, tNBT); + } + + public static long getLong(ItemStack aStack, String aTag) { + NBTTagCompound tNBT = getNBT(aStack); + return tNBT.getLong(aTag); + } + + public static void setFloat(ItemStack aStack, String aTag, float aInt) { + NBTTagCompound tNBT = getNBT(aStack); + tNBT.setFloat(aTag, aInt); + GT_Utility.ItemNBT.setNBT(aStack, tNBT); + } + + public static float getFloat(ItemStack aStack, String aTag) { + NBTTagCompound tNBT = getNBT(aStack); + return tNBT.getFloat(aTag); + } + + public static void setString(ItemStack aStack, String aTag, String aString) { + NBTTagCompound tNBT = getNBT(aStack); + tNBT.setString(aTag, aString); + GT_Utility.ItemNBT.setNBT(aStack, tNBT); + } + + public static String getString(ItemStack aStack, String aTag) { + NBTTagCompound tNBT = getNBT(aStack); + return tNBT.getString(aTag); + } + + public static boolean doesStringExist(ItemStack aStack, String aTag) { + NBTTagCompound tNBT = getNBT(aStack); + return tNBT.hasKey(aTag); + } + + public static boolean tryIterateNBTData(ItemStack aStack) { + try { + NBTTagCompound aNBT = NBTUtils.getNBT(aStack); + if (aNBT != null) { + if (!aNBT.hasNoTags()) { + Map mInternalMap = ReflectionUtils.getField(aNBT, "tagMap"); + if (mInternalMap != null) { + for (Map.Entry e : mInternalMap.entrySet()) { + Logger.INFO("Key: " + e.getKey().toString() + " | Value: " + e.getValue()); + } + return true; + } else { + Logger.INFO("Data map reflected from NBTTagCompound was not valid."); + return false; + } + } + } + } catch (Throwable t) { + } + return false; + } + + // Botania soulbind handling + public static boolean setBotanicaSoulboundOwner(ItemStack aStack, String aName) { + final String TAG_SOULBIND = "soulbind"; + NBTTagCompound tNBT = getNBT(aStack); + tNBT.setString(TAG_SOULBIND, aName); + GT_Utility.ItemNBT.setNBT(aStack, tNBT); + if (NBTUtils.doesStringExist(aStack, TAG_SOULBIND)) { + return true; + } else { + return false; + } + } + + public static String getBotanicaSoulboundOwner(ItemStack aStack) { + final String TAG_SOULBIND = "soulbind"; + NBTTagCompound tNBT = getNBT(aStack); + return tNBT.getString(TAG_SOULBIND); + } + + public static boolean hasKey(ItemStack stack, String key) { + final NBTTagCompound itemData = getNBT(stack); + if (itemData.hasKey(key)) { + return true; + } + return false; + } + + public static boolean createIntegerTagCompound(ItemStack rStack, String tagName, String keyName, int keyValue) { + final NBTTagCompound tagMain = getNBT(rStack); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setInteger(keyName, keyValue); + tagMain.setTag(tagName, tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public static boolean createLongTagCompound(ItemStack rStack, String tagName, String keyName, long keyValue) { + final NBTTagCompound tagMain = getNBT(rStack); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setLong(keyName, keyValue); + tagMain.setTag(tagName, tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public static boolean createStringTagCompound(ItemStack rStack, String tagName, String keyName, String keyValue) { + final NBTTagCompound tagMain = getNBT(rStack); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setString(keyName, keyValue); + tagMain.setTag(tagName, tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public static boolean createFloatTagCompound(ItemStack rStack, String tagName, String keyName, float keyValue) { + final NBTTagCompound tagMain = getNBT(rStack); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setFloat(keyName, keyValue); + tagMain.setTag(tagName, tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public static boolean createDoubleTagCompound(ItemStack rStack, String tagName, String keyName, double keyValue) { + final NBTTagCompound tagMain = getNBT(rStack); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setDouble(keyName, keyValue); + tagMain.setTag(tagName, tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public static boolean createBooleanTagCompound(ItemStack rStack, String tagName, String keyName, boolean keyValue) { + final NBTTagCompound tagMain = getNBT(rStack); + final NBTTagCompound tagNBT = new NBTTagCompound(); + tagNBT.setBoolean(keyName, keyValue); + tagMain.setTag(tagName, tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public static boolean createTagCompound(ItemStack rStack, String tagName, NBTTagCompound keyValue) { + final NBTTagCompound tagMain = getNBT(rStack); + NBTTagCompound tagNBT = keyValue; + tagMain.setTag(tagName, tagNBT); + rStack.setTagCompound(tagMain); + return true; + } + + public static int getIntegerTagCompound(ItemStack aStack, String tagName, String keyName) { + NBTTagCompound aNBT = getNBT(aStack); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag(tagName); + if (aNBT != null) { + return aNBT.getInteger(keyName); + } + } + return 0; + } + + public static long getLongTagCompound(ItemStack aStack, String tagName, String keyName) { + NBTTagCompound aNBT = getNBT(aStack); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag(tagName); + if (aNBT != null) { + return aNBT.getLong(keyName); + } + } + return 0L; + } + + public static String getStringTagCompound(ItemStack aStack, String tagName, String keyName) { + NBTTagCompound aNBT = getNBT(aStack); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag(tagName); + if (aNBT != null) { + return aNBT.getString(keyName); + } + } + return null; + } + + public static float getFloatTagCompound(ItemStack aStack, String tagName, String keyName) { + NBTTagCompound aNBT = getNBT(aStack); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag(tagName); + if (aNBT != null) { + return aNBT.getFloat(keyName); + } + } + return 0; + } + + public static double getDoubleTagCompound(ItemStack aStack, String tagName, String keyName) { + NBTTagCompound aNBT = getNBT(aStack); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag(tagName); + if (aNBT != null) { + return aNBT.getDouble(keyName); + } + } + return 0; + } + + public static boolean getBooleanTagCompound(ItemStack aStack, String tagName, String keyName) { + NBTTagCompound aNBT = getNBT(aStack); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag(tagName); + if (aNBT != null) { + return aNBT.getBoolean(keyName); + } + } + return false; + } + + public static NBTTagCompound getTagCompound(ItemStack aStack, String tagName) { + NBTTagCompound aNBT = getNBT(aStack); + if (aNBT != null && hasKey(aStack, tagName)) { + aNBT = aNBT.getCompoundTag(tagName); + if (aNBT != null) { + return aNBT; + } + } + return null; + } + + public static boolean hasKeyInTagCompound(ItemStack stack, String tag, String key) { + NBTTagCompound aNBT = stack.getTagCompound(); + if (aNBT != null) { + aNBT = aNBT.getCompoundTag(tag); + if (aNBT.hasKey(key)) { + return true; + } + } + return false; + } + + public static Map getTagMap(NBTTagCompound aNBT) { + Map tagMap = new HashMap(); + if (!aNBT.hasNoTags()) { + Map mInternalMap = ReflectionUtils.getField(aNBT, "tagMap"); + if (mInternalMap != null && !mInternalMap.isEmpty()) { + tagMap.putAll(mInternalMap); + } + } + return tagMap; + } + + public static boolean isTagString(NBTTagCompound aNBT, String aTagName) { + Map aTagMap = getTagMap(aNBT); + if (aTagMap != null && !aTagMap.isEmpty()) { + for (Map.Entry e : aTagMap.entrySet()) { + if (e.getKey().equals(aTagName)) { + Object aValue = e.getValue(); + if (aValue instanceof String) { + return true; + } + } + } + } + return false; + } + + public static boolean isTagInteger(NBTTagCompound aNBT, String aTagName) { + Map aTagMap = getTagMap(aNBT); + if (aTagMap != null && !aTagMap.isEmpty()) { + for (Map.Entry e : aTagMap.entrySet()) { + if (e.getKey().equals(aTagName)) { + Object aValue = e.getValue(); + if (int.class.isInstance(aValue) || aValue instanceof Integer) { + return true; + } + } + } + } + return false; + } + + public static boolean isTagLong(NBTTagCompound aNBT, String aTagName) { + Map aTagMap = getTagMap(aNBT); + if (aTagMap != null && !aTagMap.isEmpty()) { + for (Map.Entry e : aTagMap.entrySet()) { + if (e.getKey().equals(aTagName)) { + Object aValue = e.getValue(); + if (long.class.isInstance(aValue) || aValue instanceof Long) { + return true; + } + } + } + } + return false; + } + + public static boolean isTagFloat(NBTTagCompound aNBT, String aTagName) { + Map aTagMap = getTagMap(aNBT); + if (aTagMap != null && !aTagMap.isEmpty()) { + for (Map.Entry e : aTagMap.entrySet()) { + if (e.getKey().equals(aTagName)) { + Object aValue = e.getValue(); + if (float.class.isInstance(aValue) || aValue instanceof Float) { + return true; + } + } + } + } + return false; + } + + public static boolean isTagDouble(NBTTagCompound aNBT, String aTagName) { + Map aTagMap = getTagMap(aNBT); + if (aTagMap != null && !aTagMap.isEmpty()) { + for (Map.Entry e : aTagMap.entrySet()) { + if (e.getKey().equals(aTagName)) { + Object aValue = e.getValue(); + if (double.class.isInstance(aValue) || aValue instanceof Double) { + return true; + } + } + } + } + return false; + } + + public static boolean isTagBoolean(NBTTagCompound aNBT, String aTagName) { + Map aTagMap = getTagMap(aNBT); + if (aTagMap != null && !aTagMap.isEmpty()) { + for (Map.Entry e : aTagMap.entrySet()) { + if (e.getKey().equals(aTagName)) { + Object aValue = e.getValue(); + if (boolean.class.isInstance(aValue) || aValue instanceof Boolean) { + return true; + } + } + } + } + return false; + } + + public static boolean tryCloneTagCompoundDataIntoSubTag(ItemStack aStack, NBTTagCompound aTagCompound) { + try { + NBTTagCompound aNBT = aTagCompound; + if (aNBT != null) { + if (!aNBT.hasNoTags()) { + Map mInternalMap = ReflectionUtils.getField(aNBT, "tagMap"); + if (mInternalMap != null) { + for (Map.Entry e : mInternalMap.entrySet()) { + Logger.INFO("Key: " + e.getKey().toString() + " | Value: " + + e.getValue().toString()); + if (e.getValue().getClass() == String.class) { + createStringTagCompound( + aStack, "mEntityTag", (String) e.getKey(), (String) e.getValue()); + } else if (e.getValue().getClass() == Boolean.class + || e.getValue().getClass() == boolean.class) { + createBooleanTagCompound( + aStack, "mEntityTag", (String) e.getKey(), (Boolean) e.getValue()); + } else if (e.getValue().getClass() == Integer.class + || e.getValue().getClass() == int.class) { + createIntegerTagCompound( + aStack, "mEntityTag", (String) e.getKey(), (Integer) e.getValue()); + } else if (e.getValue().getClass() == Double.class + || e.getValue().getClass() == double.class) { + createDoubleTagCompound( + aStack, "mEntityTag", (String) e.getKey(), (Double) e.getValue()); + } else if (e.getValue().getClass() == Long.class + || e.getValue().getClass() == long.class) { + createLongTagCompound(aStack, "mEntityTag", (String) e.getKey(), (Long) e.getValue()); + } else if (e.getValue().getClass() == Float.class + || e.getValue().getClass() == float.class) { + createFloatTagCompound(aStack, "mEntityTag", (String) e.getKey(), (Float) e.getValue()); + } else { + + } + } + return true; + } + } + } + return false; + } catch (Throwable t) { + return false; + } + } + + public static NBTTagCompound getEntityCustomData(Entity aEntity) { + return ReflectionUtils.getField(aEntity, "customEntityData"); + } + + public static boolean setEntityCustomData(Entity aEntity, NBTTagCompound aTag) { + return ReflectionUtils.setField(aEntity, "customEntityData", aTag); + } + + public static boolean hasTagCompound(ItemStack aStack) { + return aStack.hasTagCompound(); + } + + public static void createEmptyTagCompound(ItemStack aStack) { + if (!hasTagCompound(aStack)) { + NBTTagCompound aTag = new NBTTagCompound(); + aStack.setTagCompound(aTag); + } + } } diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/OreDictUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/OreDictUtils.java index 324d39b863..359b336889 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/OreDictUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/OreDictUtils.java @@ -1,25 +1,22 @@ package gtPlusPlus.core.util.minecraft; import java.util.List; - import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; public class OreDictUtils { - public static boolean containsValidEntries(String aOreName) { - boolean a = OreDictionary.doesOreNameExist(aOreName); - List b = OreDictionary.getOres(aOreName, false); - - if (!a) { - return false; - } - else { - if (b == null || b.isEmpty()) { - return false; - } - } - return true; - } - + public static boolean containsValidEntries(String aOreName) { + boolean a = OreDictionary.doesOreNameExist(aOreName); + List b = OreDictionary.getOres(aOreName, false); + + if (!a) { + return false; + } else { + if (b == null || b.isEmpty()) { + return false; + } + } + return true; + } } diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/PlayerUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/PlayerUtils.java index f2be723726..038672c259 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/PlayerUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/PlayerUtils.java @@ -1,11 +1,10 @@ package gtPlusPlus.core.util.minecraft; -import java.util.*; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import java.util.*; import net.minecraft.client.Minecraft; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -20,246 +19,257 @@ import net.minecraftforge.common.util.FakePlayer; public class PlayerUtils { - public static final Map mCachedFakePlayers = new WeakHashMap(); - private static final Class mThaumcraftFakePlayer; - - static { - if (ReflectionUtils.doesClassExist("thaumcraft.common.lib.FakeThaumcraftPlayer")) { - mThaumcraftFakePlayer = ReflectionUtils.getClass("thaumcraft.common.lib.FakeThaumcraftPlayer"); - } - else { - mThaumcraftFakePlayer = null; - } - } + public static final Map mCachedFakePlayers = new WeakHashMap(); + private static final Class mThaumcraftFakePlayer; + + static { + if (ReflectionUtils.doesClassExist("thaumcraft.common.lib.FakeThaumcraftPlayer")) { + mThaumcraftFakePlayer = ReflectionUtils.getClass("thaumcraft.common.lib.FakeThaumcraftPlayer"); + } else { + mThaumcraftFakePlayer = null; + } + } + + public static void messagePlayer(final EntityPlayer P, final String S) { + gregtech.api.util.GT_Utility.sendChatToPlayer(P, S); + } + + public static void messagePlayer(final EntityPlayer P, final IChatComponent S) { + P.addChatComponentMessage(S); + } + + public static EntityPlayer getPlayer(final String name) { + try { + final List i = new ArrayList<>(); + final Iterator iterator = MinecraftServer.getServer() + .getConfigurationManager() + .playerEntityList + .iterator(); + while (iterator.hasNext()) { + i.add((iterator.next())); + } + for (final EntityPlayer temp : i) { + if (temp.getDisplayName().toLowerCase().equals(name.toLowerCase())) { + return temp; + } + } + } catch (final Throwable e) { + } + return null; + } + + public static EntityPlayer getPlayerOnServerFromUUID(final UUID parUUID) { + if (parUUID == null) { + return null; + } + final List allPlayers = MinecraftServer.getServer().getConfigurationManager().playerEntityList; + for (final EntityPlayerMP player : allPlayers) { + if (player.getUniqueID().equals(parUUID)) { + return player; + } + } + return null; + } + + // Not Clientside + public static EntityPlayer getPlayerInWorld(final World world, final String Name) { + final List i = world.playerEntities; + final Minecraft mc = Minecraft.getMinecraft(); + try { + for (final EntityPlayer temp : i) { + if (temp.getDisplayName().toLowerCase().equals(Name.toLowerCase())) { + return temp; + } + } + } catch (final NullPointerException e) { + } + return null; + } + + public static boolean isPlayerOP(final EntityPlayer player) { + if (player.canCommandSenderUseCommand(2, "")) { + return true; + } + return false; + } - public static void messagePlayer(final EntityPlayer P, final String S){ - gregtech.api.util.GT_Utility.sendChatToPlayer(P, S); - } - - public static void messagePlayer(final EntityPlayer P, final IChatComponent S){ - P.addChatComponentMessage(S); - } + // Not Clientside + public static ItemStack getItemStackInPlayersHand(final World world, final String Name) { + final EntityPlayer thePlayer = getPlayer(Name); + ItemStack heldItem = null; + try { + heldItem = thePlayer.getHeldItem(); + } catch (final NullPointerException e) { + return null; + } + if (heldItem != null) { + return heldItem; + } + return null; + } - public static EntityPlayer getPlayer(final String name){ - try{ - final List i = new ArrayList<>(); - final Iterator iterator = MinecraftServer.getServer().getConfigurationManager().playerEntityList.iterator(); - while (iterator.hasNext()) { - i.add((iterator.next())); - } - for (final EntityPlayer temp : i) { - if (temp.getDisplayName().toLowerCase().equals(name.toLowerCase())){ - return temp; - } - } - } - catch(final Throwable e){} - return null; - } + @SideOnly(Side.CLIENT) + public static ItemStack getItemStackInPlayersHand() { + final Minecraft mc = Minecraft.getMinecraft(); + ItemStack heldItem = null; + try { + heldItem = mc.thePlayer.getHeldItem(); + } catch (final NullPointerException e) { + return null; + } + if (heldItem != null) { + return heldItem; + } + return null; + } - public static EntityPlayer getPlayerOnServerFromUUID(final UUID parUUID){ - if (parUUID == null) - { - return null; - } - final List allPlayers = MinecraftServer.getServer().getConfigurationManager().playerEntityList; - for (final EntityPlayerMP player : allPlayers) - { - if (player.getUniqueID().equals(parUUID)) - { - return player; - } - } - return null; - } + public static ItemStack getItemStackInPlayersHand(final EntityPlayer player) { + ItemStack heldItem = null; + try { + heldItem = player.getHeldItem(); + } catch (final NullPointerException e) { + e.printStackTrace(); + return null; + } + if (heldItem != null) { + return heldItem; + } else { + if (Utils.isClient()) { + heldItem = player.getItemInUse(); + } else { + heldItem = player.getCurrentEquippedItem(); + } + } + return heldItem; + } - //Not Clientside - public static EntityPlayer getPlayerInWorld(final World world, final String Name){ - final List i = world.playerEntities; - final Minecraft mc = Minecraft.getMinecraft(); - try{ - for (final EntityPlayer temp : i) { - if (temp.getDisplayName().toLowerCase().equals(Name.toLowerCase())){ - return temp; - } - } - } - catch(final NullPointerException e){} - return null; - } + @SideOnly(Side.CLIENT) + public static Item getItemInPlayersHandClient() { + final Minecraft mc = Minecraft.getMinecraft(); + Item heldItem = null; - public static boolean isPlayerOP(final EntityPlayer player){ - if (player.canCommandSenderUseCommand(2, "")){ - return true; - } - return false; - } + try { + heldItem = mc.thePlayer.getHeldItem().getItem(); + } catch (final NullPointerException e) { + return null; + } - //Not Clientside - public static ItemStack getItemStackInPlayersHand(final World world, final String Name){ - final EntityPlayer thePlayer = getPlayer(Name); - ItemStack heldItem = null; - try{heldItem = thePlayer.getHeldItem(); - }catch(final NullPointerException e){return null;} - if (heldItem != null){ - return heldItem; - } - return null; - } + if (heldItem != null) { + return heldItem; + } - @SideOnly(Side.CLIENT) - public static ItemStack getItemStackInPlayersHand(){ - final Minecraft mc = Minecraft.getMinecraft(); - ItemStack heldItem = null; - try{heldItem = mc.thePlayer.getHeldItem(); - }catch(final NullPointerException e){return null;} - if (heldItem != null){ - return heldItem; - } - return null; - } + return null; + } - public static ItemStack getItemStackInPlayersHand(final EntityPlayer player){ - ItemStack heldItem = null; - try{ - heldItem = player.getHeldItem(); - } - catch(final NullPointerException e){ - e.printStackTrace(); - return null; - } - if (heldItem != null){ - return heldItem; - } - else { - if (Utils.isClient()) { - heldItem = player.getItemInUse(); - } - else { - heldItem = player.getCurrentEquippedItem(); - } - } - return heldItem; - } + public static Item getItemInPlayersHand(final EntityPlayer player) { + Item heldItem = null; + try { + heldItem = player.getHeldItem().getItem(); + } catch (final NullPointerException e) { + return null; + } - @SideOnly(Side.CLIENT) - public static Item getItemInPlayersHandClient(){ - final Minecraft mc = Minecraft.getMinecraft(); - Item heldItem = null; + if (heldItem != null) { + return heldItem; + } + return null; + } - try{heldItem = mc.thePlayer.getHeldItem().getItem(); - }catch(final NullPointerException e){return null;} + public static final EntityPlayer getPlayerEntityByName(final String aPlayerName) { + final EntityPlayer player = PlayerUtils.getPlayer(aPlayerName); + if (player != null) { + return player; + } + return null; + } - if (heldItem != null){ - return heldItem; - } + public static final UUID getPlayersUUIDByName(final String aPlayerName) { + final EntityPlayer player = PlayerUtils.getPlayer(aPlayerName); + if (player != null) { + return player.getUniqueID(); + } + return null; + } - return null; - } + @SideOnly(Side.CLIENT) + public static final boolean isPlayerAlkalus() { + if (Utils.isServer()) { + return false; + } + return isPlayerAlkalus(Minecraft.getMinecraft().thePlayer); + } - public static Item getItemInPlayersHand(final EntityPlayer player){ - Item heldItem = null; - try{ - heldItem = player.getHeldItem().getItem(); - }catch(final NullPointerException e){return null;} + public static final boolean isPlayerAlkalus(EntityPlayer player) { + if (player != null) { + if (player.getDisplayName().toLowerCase().equals("draknyte1") + || player.getDisplayName().toLowerCase().equals("alkalus")) { + return true; + } + } + return false; + } - if (heldItem != null){ - return heldItem; - } - return null; - } + public static void messageAllPlayers(String string) { + Utils.sendServerMessage(string); + } - public final static EntityPlayer getPlayerEntityByName(final String aPlayerName){ - final EntityPlayer player = PlayerUtils.getPlayer(aPlayerName); - if (player != null){ - return player; - } - return null; - } + public static boolean isCreative(EntityPlayer aPlayer) { + return aPlayer.capabilities.isCreativeMode; + } - public final static UUID getPlayersUUIDByName(final String aPlayerName){ - final EntityPlayer player = PlayerUtils.getPlayer(aPlayerName); - if (player != null){ - return player.getUniqueID(); - } - return null; - } - - @SideOnly(Side.CLIENT) - public static final boolean isPlayerAlkalus(){ - if (Utils.isServer()){ - return false; - } - return isPlayerAlkalus(Minecraft.getMinecraft().thePlayer); - } - - public static final boolean isPlayerAlkalus(EntityPlayer player){ - if (player != null){ - if (player.getDisplayName().toLowerCase().equals("draknyte1") || player.getDisplayName().toLowerCase().equals("alkalus")){ - return true; - } - } - return false; - } + public static boolean canTakeDamage(EntityPlayer aPlayer) { + return !aPlayer.capabilities.disableDamage; + } - public static void messageAllPlayers(String string) { - Utils.sendServerMessage(string); - } + public static void cacheFakePlayer(EntityPlayer aPlayer) { + ChunkCoordinates aChunkLocation = aPlayer.getPlayerCoordinates(); + // Cache Fake Player + if (aPlayer instanceof FakePlayer + || (mThaumcraftFakePlayer != null && mThaumcraftFakePlayer.isInstance(aPlayer)) + || (aPlayer.getCommandSenderName() == null + || aPlayer.getCommandSenderName().length() <= 0) + || (aPlayer.isEntityInvulnerable() + && !aPlayer.canCommandSenderUseCommand(0, "") + && (aChunkLocation == null) + || (aChunkLocation.posX == 0 && aChunkLocation.posY == 0 && aChunkLocation.posZ == 0))) { + mCachedFakePlayers.put(aPlayer.getUniqueID().toString(), aPlayer); + } + } - public static boolean isCreative(EntityPlayer aPlayer) { - return aPlayer.capabilities.isCreativeMode; - } - - public static boolean canTakeDamage(EntityPlayer aPlayer) { - return !aPlayer.capabilities.disableDamage; - } - - public static void cacheFakePlayer(EntityPlayer aPlayer) { - ChunkCoordinates aChunkLocation = aPlayer.getPlayerCoordinates(); - // Cache Fake Player - if (aPlayer instanceof FakePlayer || (mThaumcraftFakePlayer != null && mThaumcraftFakePlayer.isInstance(aPlayer)) - || (aPlayer.getCommandSenderName() == null - || aPlayer.getCommandSenderName().length() <= 0) - || (aPlayer.isEntityInvulnerable() && !aPlayer.canCommandSenderUseCommand(0, "") - && (aChunkLocation == null) || (aChunkLocation.posX == 0 && aChunkLocation.posY == 0 - && aChunkLocation.posZ == 0))) { - mCachedFakePlayers.put(aPlayer.getUniqueID().toString(), aPlayer); - } - } - - public static boolean isCachedFakePlayer(String aUUID) { - return mCachedFakePlayers.containsKey(aUUID); - } - - public static boolean isRealPlayer(EntityLivingBase aEntity) { - if (aEntity instanceof EntityPlayer) { - EntityPlayer p = (EntityPlayer) aEntity; - ChunkCoordinates aChunkLocation = p.getPlayerCoordinates(); - if (p instanceof FakePlayer) { - cacheFakePlayer(p); - return false; - } - if (mThaumcraftFakePlayer != null && mThaumcraftFakePlayer.isInstance(p) ) { - cacheFakePlayer(p); - return false; - } - if (p.getCommandSenderName() == null) { - cacheFakePlayer(p); - return false; - } - if (p.getCommandSenderName().length() <= 0) { - cacheFakePlayer(p); - return false; - } - if (p.isEntityInvulnerable() && !p.canCommandSenderUseCommand(0, "") && (aChunkLocation.posX == 0 && aChunkLocation.posY == 0 && aChunkLocation.posZ == 0)) { - cacheFakePlayer(p); - return false; - } - if (!isCachedFakePlayer(p.getUniqueID().toString())) { - return true; - } - } - return false; - } + public static boolean isCachedFakePlayer(String aUUID) { + return mCachedFakePlayers.containsKey(aUUID); + } + public static boolean isRealPlayer(EntityLivingBase aEntity) { + if (aEntity instanceof EntityPlayer) { + EntityPlayer p = (EntityPlayer) aEntity; + ChunkCoordinates aChunkLocation = p.getPlayerCoordinates(); + if (p instanceof FakePlayer) { + cacheFakePlayer(p); + return false; + } + if (mThaumcraftFakePlayer != null && mThaumcraftFakePlayer.isInstance(p)) { + cacheFakePlayer(p); + return false; + } + if (p.getCommandSenderName() == null) { + cacheFakePlayer(p); + return false; + } + if (p.getCommandSenderName().length() <= 0) { + cacheFakePlayer(p); + return false; + } + if (p.isEntityInvulnerable() + && !p.canCommandSenderUseCommand(0, "") + && (aChunkLocation.posX == 0 && aChunkLocation.posY == 0 && aChunkLocation.posZ == 0)) { + cacheFakePlayer(p); + return false; + } + if (!isCachedFakePlayer(p.getUniqueID().toString())) { + return true; + } + } + return false; + } } diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/RecipeUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/RecipeUtils.java index 595635d411..ba55ce262a 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/RecipeUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/RecipeUtils.java @@ -1,10 +1,5 @@ package gtPlusPlus.core.util.minecraft; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; - import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.enums.Materials; import gregtech.api.objects.ItemData; @@ -24,6 +19,10 @@ import gtPlusPlus.core.handler.Recipes.RegistrationHandler; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.data.ArrayUtils; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -35,580 +34,659 @@ import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; public class RecipeUtils { -public static int mInvalidID = 1; - public static boolean recipeBuilder(final Object slot_1, final Object slot_2, final Object slot_3, final Object slot_4, final Object slot_5, final Object slot_6, final Object slot_7, final Object slot_8, final Object slot_9, ItemStack resultItem){ - - //Old Debug Code, useful for finding recipes loading too early. - /*if (gtPlusPlus.GTplusplus.CURRENT_LOAD_PHASE != GTplusplus.INIT_PHASE.POST_INIT) { - Logger.RECIPE(ReflectionUtils.getMethodName(1)); - Logger.RECIPE(ReflectionUtils.getMethodName(2)); - Logger.RECIPE(ReflectionUtils.getMethodName(3)); - Logger.RECIPE(ReflectionUtils.getMethodName(4)); - Logger.RECIPE(ReflectionUtils.getMethodName(5)); - Logger.RECIPE(ReflectionUtils.getMethodName(6)); - Logger.RECIPE(ReflectionUtils.getMethodName(7)); - Logger.RECIPE(ReflectionUtils.getMethodName(8)); - Logger.RECIPE(ReflectionUtils.getMethodName(9)); - FMLCommonHandler.instance().exitJava(1, true); - }*/ - - if (resultItem == null){ - Logger.RECIPE("[Fix] Found a recipe with an invalid output, yet had a valid inputs. Using Dummy output so recipe can be found.."); - resultItem = ItemUtils.getItemStackOfAmountFromOreDict("givemeabrokenitem", 1); - resultItem.setItemDamage(mInvalidID++); - RegistrationHandler.recipesFailed++; - //return false; - } - else if ((slot_1 == null) && (slot_2 == null) && (slot_3 == null) && - (slot_4 == null) && (slot_5 == null) && (slot_6 == null) && - (slot_7 == null) && (slot_8 == null) && (slot_9 == null)){ - Logger.RECIPE("[Fix] Found a recipe with 0 inputs, yet had a valid output."); - Logger.RECIPE("[Fix] Error found while adding a recipe for: "+resultItem != null ? resultItem.getDisplayName() : "Bad Output Item"+" | Please report this issue on Github."); - RegistrationHandler.recipesFailed++; - return false; - } - - Object[] o = new Object[] {slot_1, slot_2, slot_3, slot_4, slot_5, slot_6, slot_7, slot_8, slot_9}; - - try { - int size = COMPAT_HANDLER.mRecipesToGenerate.size(); - COMPAT_HANDLER.mRecipesToGenerate.put(new InternalRecipeObject(o, resultItem, false)); - //Utils.LOG_WARNING("Success! Added a recipe for "+resultItem.getDisplayName()); - if (COMPAT_HANDLER.mRecipesToGenerate.size() > size) { - if (!COMPAT_HANDLER.areInitItemsLoaded){ - RegistrationHandler.recipesSuccess++; - } - else { - LateRegistrationHandler.recipesSuccess++; - } - return true; - } - return false; - } - catch(RuntimeException k){ - //k.getMessage(); - //k.getClass(); - //k.printStackTrace(); - //k.getLocalizedMessage(); - Logger.RECIPE("[Fix] Invalid Recipe detected for: "+resultItem != null ? resultItem.getUnlocalizedName() : "INVALID OUTPUT ITEM"); - if (!COMPAT_HANDLER.areInitItemsLoaded){ - RegistrationHandler.recipesFailed++; - } - else { - LateRegistrationHandler.recipesFailed++; - } - return false; - } - } - - public static void shapelessBuilder(final ItemStack Output, final Object slot_1, final Object slot_2, final Object slot_3, final Object slot_4, final Object slot_5, final Object slot_6, final Object slot_7, final Object slot_8, final Object slot_9){ - //Item output_ITEM = Output.getItem(); - - final ArrayList validSlots = new ArrayList<>(); - - Logger.WARNING("Trying to add a recipe for "+Output.toString()); - String a,b,c,d,e,f,g,h,i; - if (slot_1 == null){ a = " ";} else { a = "1";validSlots.add('1');validSlots.add(slot_1);} - Logger.WARNING(a); - if (slot_2 == null){ b = " ";} else { b = "2";validSlots.add('2');validSlots.add(slot_2);} - Logger.WARNING(b); - if (slot_3 == null){ c = " ";} else { c = "3";validSlots.add('3');validSlots.add(slot_3);} - Logger.WARNING(c); - if (slot_4 == null){ d = " ";} else { d = "4";validSlots.add('4');validSlots.add(slot_4);} - Logger.WARNING(d); - if (slot_5 == null){ e = " ";} else { e = "5";validSlots.add('5');validSlots.add(slot_5);} - Logger.WARNING(e); - if (slot_6 == null){ f = " ";} else { f = "6";validSlots.add('6');validSlots.add(slot_6);} - Logger.WARNING(f); - if (slot_7 == null){ g = " ";} else { g = "7";validSlots.add('7');validSlots.add(slot_7);} - Logger.WARNING(g); - if (slot_8 == null){ h = " ";} else { h = "8";validSlots.add('8');validSlots.add(slot_8);} - Logger.WARNING(h); - if (slot_9 == null){ i = " ";} else { i = "9";validSlots.add('9');validSlots.add(slot_9);} - Logger.WARNING(i); - - - Logger.ERROR("_______"); - Logger.ERROR("|"+a+"|"+b+"|"+c+"|"); - Logger.ERROR("_______"); - Logger.ERROR("|"+d+"|"+e+"|"+f+"|"); - Logger.ERROR("_______"); - Logger.ERROR("|"+g+"|"+h+"|"+i+"|"); - Logger.ERROR("_______"); - - validSlots.add(0, a); - validSlots.add(1, b); - validSlots.add(2, c); - validSlots.add(3, d); - validSlots.add(4, e); - validSlots.add(5, f); - validSlots.add(6, g); - validSlots.add(7, h); - validSlots.add(8, i); - - try { - //GameRegistry.addRecipe(new ShapelessOreRecipe(Output, outputAmount), (Object[]) validSlots.toArray()); - GameRegistry.addRecipe(new ShapelessOreRecipe(Output, validSlots.toArray())); - //GameRegistry.addShapelessRecipe(new ItemStack(output_ITEM, 1), new Object[] {slot_1, slot_2}); - Logger.RECIPE("Success! Added a recipe for "+Output.getDisplayName()); - RegistrationHandler.recipesSuccess++; - } - catch(final RuntimeException k){ - k.getMessage(); - k.getClass(); - k.printStackTrace(); - k.getLocalizedMessage(); - Logger.RECIPE("[Fix] Invalid Recipe detected for: "+Output.getUnlocalizedName()); - RegistrationHandler.recipesFailed++; - } - - - //GameRegistry.addShapelessRecipe(new ItemStack(output_ITEM, 1), new Object[] {slot_1, slot_2}); - } - - public static void recipeBuilder(final Object[] array, final ItemStack outPut) { - Logger.SPECIFIC_WARNING("object Array - recipeBuilder", "Attempting to build a recipe using an object array as an input, splitting it, then running the normal recipeBuilder() method.", 396); - Object a=null; - Object b=null; - Object c=null; - Object d=null; - Object e=null; - Object f=null; - Object g=null; - Object h=null; - Object i=null; - for(int z =0; z <= array.length; z++){ - array[z].toString(); - switch(z) - { - case 0: - a = array[z]; - break; - case 1: - b = array[z]; - break; - case 2: - c = array[z]; - break; - case 3: - d = array[z]; - break; - case 4: - e = array[z]; - break; - case 5: - f = array[z]; - break; - case 6: - g = array[z]; - break; - case 7: - h = array[z]; - break; - case 8: - i = array[z]; - break; - default: - break; - } - recipeBuilder(a, b, c, d, e, f, g, h, i, outPut); - } - } - - public static boolean removeCraftingRecipe(Object x){ - if (null == x){return false;} - if (x instanceof String){ - final Item R = ItemUtils.getItemFromFQRN((String) x); - if (R != null){ - x = R; - } - else { - return false; - } - } - if ((x instanceof Item) || (x instanceof ItemStack)){ - if (x instanceof Item){ - final ItemStack r = new ItemStack((Item) x); - Logger.RECIPE("Removing Recipe for "+r.getUnlocalizedName()); - } - else { - Logger.RECIPE("Removing Recipe for "+((ItemStack) x).getUnlocalizedName()); - } - if (x instanceof ItemStack){ - final Item r = ((ItemStack) x).getItem(); - if (null != r){ - x = r; - } - else { - Logger.RECIPE("Recipe removal failed - Tell Alkalus."); - return false; - } - } - if (RecipeUtils.attemptRecipeRemoval((Item) x)){ - Logger.RECIPE("Recipe removal successful"); - return true; - } - Logger.RECIPE("Recipe removal failed - Tell Alkalus."); - return false; - } - return false; - } - - private static boolean attemptRecipeRemoval(final Item I){ - Logger.RECIPE("Create list of recipes."); - final List recipes = CraftingManager.getInstance().getRecipeList(); - final Iterator items = recipes.iterator(); - Logger.RECIPE("Begin list iteration."); - while (items.hasNext()) { - final ItemStack is = items.next().getRecipeOutput(); - if ((is != null) && (is.getItem() == I)){ - items.remove(); - Logger.RECIPE("Remove a recipe with "+I.getUnlocalizedName()+" as output."); - continue; - } - } - Logger.RECIPE("All recipes should be gone?"); - if (!items.hasNext()){ - Logger.RECIPE("We iterated once, let's try again to double check."); - final Iterator items2 = recipes.iterator(); - while (items2.hasNext()) { - final ItemStack is = items2.next().getRecipeOutput(); - if ((is != null) && (is.getItem() == I)){ - items.remove(); - Logger.RECIPE("REMOVING MISSED RECIPE - RECHECK CONSTRUCTORS"); - return true; - } - } - Logger.RECIPE("Should be all gone now after double checking, so return true."); - return true; - } - Logger.RECIPE("Return false, because something went wrong."); - return false; - } - - - - public static boolean addShapedGregtechRecipeForTypes( - final Object InputItem1, final Object InputItem2, final Object InputItem3, - final Object InputItem4, final Object InputItem5, final Object InputItem6, - final Object InputItem7, final Object InputItem8, final Object InputItem9, - final ItemStack OutputItem){ - - int using = 0, recipeSlotCurrent = 0; - boolean[] hasMultiStack = new boolean[9]; - boolean inUse[] = {false, false, false}; - ItemStack array[][] = new ItemStack[3][9]; - - Object[] inputs = { - InputItem1, InputItem2, InputItem3, - InputItem4, InputItem5, InputItem6, - InputItem7, InputItem8, InputItem9}; - - for (Object o : inputs){ - if (o.getClass().isArray()){ - if (inUse[using] == false){ - inUse[using] = true; - array[using] = (ItemStack[]) o; - hasMultiStack[recipeSlotCurrent] = true; - using++; - } - } - else { - hasMultiStack[recipeSlotCurrent] = false; - } - recipeSlotCurrent++; - } - - int using2 = 0; - for (boolean t : inUse){ - - if (t){ - if (array[using2] != null){ - //addShapedGregtechRecipe - } - } - using2++; - } - - - return false; - } - - - - public static boolean addShapedGregtechRecipe( - final Object InputItem1, final Object InputItem2, final Object InputItem3, - final Object InputItem4, final Object InputItem5, final Object InputItem6, - final Object InputItem7, final Object InputItem8, final Object InputItem9, - final ItemStack OutputItem){ - - Object[] o = { - InputItem1, InputItem2, InputItem3, - InputItem4, InputItem5, InputItem6, - InputItem7, InputItem8, InputItem9 - }; - - - if (gtPlusPlus.GTplusplus.CURRENT_LOAD_PHASE != GTplusplus.INIT_PHASE.POST_INIT) { - CORE.crash("Load Phase "+gtPlusPlus.GTplusplus.CURRENT_LOAD_PHASE+" should be "+GTplusplus.INIT_PHASE.POST_INIT+". Unable to register recipe."); - } - - - int size = COMPAT_HANDLER.mGtRecipesToGenerate.size(); - COMPAT_HANDLER.mGtRecipesToGenerate.put(new InternalRecipeObject(o, OutputItem, true)); - - if (COMPAT_HANDLER.mGtRecipesToGenerate.size() > size) { - if (!COMPAT_HANDLER.areInitItemsLoaded){ - RegistrationHandler.recipesSuccess++; - } - else { - LateRegistrationHandler.recipesSuccess++; - } - return true; - } - return false; - - } - - public static boolean addShapedGregtechRecipe(final Object[] inputs, ItemStack output){ - - if (inputs.length != 9){ - Logger.RECIPE("[Fix] Input array for "+output.getDisplayName()+" does not equal 9. "+inputs.length+" is the actual size."); - RegistrationHandler.recipesFailed++; - return false; - } - - for (int x=0;x<9;x++){ - if (inputs[x] == null){ - inputs[x] = " "; - Logger.WARNING("Input slot "+x+" changed from NULL to a blank space."); - } - else if (!(inputs[x] instanceof ItemStack) && !(inputs[x] instanceof String) && !(inputs[x] instanceof Item)){ - if (output != null){ - Logger.RECIPE("[Fix] Invalid Item inserted into inputArray. Item:"+output.getDisplayName()+" has a bad recipe. Please report to Alkalus."); - RegistrationHandler.recipesFailed++; - return false; - } - else { - Logger.RECIPE("[Fix] Output is Null for a recipe. Report to Alkalus."); - output = ItemUtils.getItemStackOfAmountFromOreDict("sadibasdkjnad", 1); - RegistrationHandler.recipesFailed++; - } - } - } - - int size = COMPAT_HANDLER.mGtRecipesToGenerate.size(); - COMPAT_HANDLER.mGtRecipesToGenerate.put(new InternalRecipeObject(inputs, output, true)); - - if (COMPAT_HANDLER.mGtRecipesToGenerate.size() > size) { - if (!COMPAT_HANDLER.areInitItemsLoaded){ - RegistrationHandler.recipesSuccess++; - } - else { - LateRegistrationHandler.recipesSuccess++; - } - return true; - } - return false; - } - - public static boolean addShapelessGregtechRecipe( - final Object InputItem1, final Object InputItem2, final Object InputItem3, - final Object InputItem4, final Object InputItem5, final Object InputItem6, - final Object InputItem7, final Object InputItem8, final Object InputItem9, - final ItemStack OutputItem){ - - Object[] inputItems = { - InputItem1, InputItem2, InputItem3, - InputItem4, InputItem5, InputItem6, - InputItem7, InputItem8, InputItem9 - }; - return addShapelessGregtechRecipe(inputItems, OutputItem); - } - - public static boolean addShapelessGregtechRecipe(final Object[] inputItems, final ItemStack OutputItem){ - //Catch Invalid Recipes - if (inputItems.length > 9 || inputItems.length < 1){ - if (OutputItem != null){ - Logger.RECIPE("[Fix] Invalid input array for shapeless recipe, which should output "+OutputItem.getDisplayName()); - } - return false; - } - //let gregtech handle shapeless recipes. - if (GT_ModHandler.addShapelessCraftingRecipe(OutputItem, inputItems)){ - return true; - } - return false; - } - - public static ItemStack getItemStackFromOreDict(final String oredictName){ - final ArrayList oreDictList = OreDictionary.getOres(oredictName); - return oreDictList.get(0); - } - - public static boolean buildShapelessRecipe(final ItemStack output, final Object[] input){ - return ShapelessUtils.addShapelessRecipe(output, input); - } - - public static boolean generateMortarRecipe(ItemStack aStack, ItemStack aOutput) { - return RecipeUtils.addShapedGregtechRecipe( - aStack, null, null, - CI.craftingToolMortar, null, null, - null, null, null, - aOutput); - } - - public static boolean doesGregtechRecipeHaveEqualCells(GT_Recipe x) { - if (x.mInputs.length == 0 && x.mOutputs.length == 0) { - return true; - } - - final int tInputAmount = GT_ModHandler.getCapsuleCellContainerCountMultipliedWithStackSize(x.mInputs); - final int tOutputAmount = GT_ModHandler.getCapsuleCellContainerCountMultipliedWithStackSize(x.mOutputs); - - if (tInputAmount < tOutputAmount) { - if (!Materials.Tin.contains(x.mInputs)) { - return false; - } - else { - return true; - } - } - else if (tInputAmount > tOutputAmount && !Materials.Tin.contains(x.mOutputs)) { - return false; - } - else { - return true; - } - } - - public static String[] getRecipeInfo(GT_Recipe m) { - if (m == null) { - return new String[] {}; - } - AutoMap result = new AutoMap(); - result.put(m.toString()); - result.put("Input "+ItemUtils.getArrayStackNames(m.mInputs)); - result.put("Output "+ItemUtils.getArrayStackNames(m.mOutputs)); - result.put("Input "+ItemUtils.getArrayStackNames(m.mFluidInputs)); - result.put("Output "+ItemUtils.getArrayStackNames(m.mFluidOutputs)); - result.put("Can be buffered? "+m.mCanBeBuffered); - result.put("Duration: "+m.mDuration); - result.put("EU/t: "+m.mEUt); - result.put("Is Hidden? "+m.mHidden); - result.put("Is Enabled? "+m.mEnabled); - result.put("Special Value: "+m.mSpecialValue); - result.put("====================================="); - String s[] = result.toArray(); - return s; - } - - - public static class InternalRecipeObject implements RunnableWithInfo { - final ItemStack mOutput; - final ShapedOreRecipe mRecipe; - public final boolean isValid; - - public InternalRecipeObject(Object[] aInputs, ItemStack aOutput, boolean gtRecipe) { - Logger.RECIPE("==================================="); - mOutput = aOutput != null ? aOutput.copy() : null; - Object[] aFiltered = new Object[9]; - int aValid = 0; - for (Object o : aInputs) { - if (o instanceof ItemStack) { - aFiltered[aValid++] = o; - } - else if (o instanceof Item) { - aFiltered[aValid++] = ItemUtils.getSimpleStack((Item) o); - } - else if (o instanceof Block) { - aFiltered[aValid++] = ItemUtils.getSimpleStack((Block) o); - } - else if (o instanceof String) { - aFiltered[aValid++] = o; - } - else if (o == null) { - aFiltered[aValid++] = null; - } - else { - Logger.RECIPE("Cleaned a "+o.getClass().getSimpleName()+" from recipe input."); - } - } - - int validCounter = 0, invalidCounter = 0; - for (Object p : aFiltered) { - if (p instanceof ItemStack) { - validCounter++; - } - else if (p instanceof Item) { - validCounter++; - } - else if (p instanceof Block) { - validCounter++; - } - else if (p instanceof String) { - validCounter++; - } - else if (p == null) { - validCounter++; - } - else { - invalidCounter++; - } - } - - Logger.RECIPE("Using "+validCounter+" valid inputs and "+invalidCounter+" invalid inputs."); - ShapedRecipe r = new ShapedRecipe(aFiltered, mOutput); - if (r != null && r.mRecipe != null) { - isValid = true; - } - else { - isValid = false; - } - mRecipe = r != null ? r.mRecipe : null; - } - - @Override - public void run() { - if (this.isValid) { - GameRegistry.addRecipe(mRecipe); - } - else { - Logger.RECIPE("[Fix] Invalid shapped recipe outputting "+mOutput != null ? mOutput.getDisplayName() : "Bad Output Item"); - } - } - - @Override - public String getInfoData() { - if (mOutput != null && mOutput instanceof ItemStack) { - return ((ItemStack) mOutput).getDisplayName(); - } - return ""; - } - - } - - - public static boolean removeGtRecipe(GT_Recipe aRecipeToRemove, GT_Recipe_Map aRecipeMap) { - if (aRecipeMap.mRecipeList.contains(aRecipeToRemove)) { - return aRecipeMap.mRecipeList.remove(aRecipeToRemove); - } - return false; - } - - public static boolean addGtRecipe(GT_Recipe aRecipeToAdd, GT_Recipe_Map aRecipeMap) { + public static int mInvalidID = 1; + + public static boolean recipeBuilder( + final Object slot_1, + final Object slot_2, + final Object slot_3, + final Object slot_4, + final Object slot_5, + final Object slot_6, + final Object slot_7, + final Object slot_8, + final Object slot_9, + ItemStack resultItem) { + + // Old Debug Code, useful for finding recipes loading too early. + /*if (gtPlusPlus.GTplusplus.CURRENT_LOAD_PHASE != GTplusplus.INIT_PHASE.POST_INIT) { + Logger.RECIPE(ReflectionUtils.getMethodName(1)); + Logger.RECIPE(ReflectionUtils.getMethodName(2)); + Logger.RECIPE(ReflectionUtils.getMethodName(3)); + Logger.RECIPE(ReflectionUtils.getMethodName(4)); + Logger.RECIPE(ReflectionUtils.getMethodName(5)); + Logger.RECIPE(ReflectionUtils.getMethodName(6)); + Logger.RECIPE(ReflectionUtils.getMethodName(7)); + Logger.RECIPE(ReflectionUtils.getMethodName(8)); + Logger.RECIPE(ReflectionUtils.getMethodName(9)); + FMLCommonHandler.instance().exitJava(1, true); + }*/ + + if (resultItem == null) { + Logger.RECIPE( + "[Fix] Found a recipe with an invalid output, yet had a valid inputs. Using Dummy output so recipe can be found.."); + resultItem = ItemUtils.getItemStackOfAmountFromOreDict("givemeabrokenitem", 1); + resultItem.setItemDamage(mInvalidID++); + RegistrationHandler.recipesFailed++; + // return false; + } else if ((slot_1 == null) + && (slot_2 == null) + && (slot_3 == null) + && (slot_4 == null) + && (slot_5 == null) + && (slot_6 == null) + && (slot_7 == null) + && (slot_8 == null) + && (slot_9 == null)) { + Logger.RECIPE("[Fix] Found a recipe with 0 inputs, yet had a valid output."); + Logger.RECIPE( + "[Fix] Error found while adding a recipe for: " + resultItem != null + ? resultItem.getDisplayName() + : "Bad Output Item" + " | Please report this issue on Github."); + RegistrationHandler.recipesFailed++; + return false; + } + + Object[] o = new Object[] {slot_1, slot_2, slot_3, slot_4, slot_5, slot_6, slot_7, slot_8, slot_9}; + + try { + int size = COMPAT_HANDLER.mRecipesToGenerate.size(); + COMPAT_HANDLER.mRecipesToGenerate.put(new InternalRecipeObject(o, resultItem, false)); + // Utils.LOG_WARNING("Success! Added a recipe for "+resultItem.getDisplayName()); + if (COMPAT_HANDLER.mRecipesToGenerate.size() > size) { + if (!COMPAT_HANDLER.areInitItemsLoaded) { + RegistrationHandler.recipesSuccess++; + } else { + LateRegistrationHandler.recipesSuccess++; + } + return true; + } + return false; + } catch (RuntimeException k) { + // k.getMessage(); + // k.getClass(); + // k.printStackTrace(); + // k.getLocalizedMessage(); + Logger.RECIPE( + "[Fix] Invalid Recipe detected for: " + resultItem != null + ? resultItem.getUnlocalizedName() + : "INVALID OUTPUT ITEM"); + if (!COMPAT_HANDLER.areInitItemsLoaded) { + RegistrationHandler.recipesFailed++; + } else { + LateRegistrationHandler.recipesFailed++; + } + return false; + } + } + + public static void shapelessBuilder( + final ItemStack Output, + final Object slot_1, + final Object slot_2, + final Object slot_3, + final Object slot_4, + final Object slot_5, + final Object slot_6, + final Object slot_7, + final Object slot_8, + final Object slot_9) { + // Item output_ITEM = Output.getItem(); + + final ArrayList validSlots = new ArrayList<>(); + + Logger.WARNING("Trying to add a recipe for " + Output.toString()); + String a, b, c, d, e, f, g, h, i; + if (slot_1 == null) { + a = " "; + } else { + a = "1"; + validSlots.add('1'); + validSlots.add(slot_1); + } + Logger.WARNING(a); + if (slot_2 == null) { + b = " "; + } else { + b = "2"; + validSlots.add('2'); + validSlots.add(slot_2); + } + Logger.WARNING(b); + if (slot_3 == null) { + c = " "; + } else { + c = "3"; + validSlots.add('3'); + validSlots.add(slot_3); + } + Logger.WARNING(c); + if (slot_4 == null) { + d = " "; + } else { + d = "4"; + validSlots.add('4'); + validSlots.add(slot_4); + } + Logger.WARNING(d); + if (slot_5 == null) { + e = " "; + } else { + e = "5"; + validSlots.add('5'); + validSlots.add(slot_5); + } + Logger.WARNING(e); + if (slot_6 == null) { + f = " "; + } else { + f = "6"; + validSlots.add('6'); + validSlots.add(slot_6); + } + Logger.WARNING(f); + if (slot_7 == null) { + g = " "; + } else { + g = "7"; + validSlots.add('7'); + validSlots.add(slot_7); + } + Logger.WARNING(g); + if (slot_8 == null) { + h = " "; + } else { + h = "8"; + validSlots.add('8'); + validSlots.add(slot_8); + } + Logger.WARNING(h); + if (slot_9 == null) { + i = " "; + } else { + i = "9"; + validSlots.add('9'); + validSlots.add(slot_9); + } + Logger.WARNING(i); + + Logger.ERROR("_______"); + Logger.ERROR("|" + a + "|" + b + "|" + c + "|"); + Logger.ERROR("_______"); + Logger.ERROR("|" + d + "|" + e + "|" + f + "|"); + Logger.ERROR("_______"); + Logger.ERROR("|" + g + "|" + h + "|" + i + "|"); + Logger.ERROR("_______"); + + validSlots.add(0, a); + validSlots.add(1, b); + validSlots.add(2, c); + validSlots.add(3, d); + validSlots.add(4, e); + validSlots.add(5, f); + validSlots.add(6, g); + validSlots.add(7, h); + validSlots.add(8, i); + + try { + // GameRegistry.addRecipe(new ShapelessOreRecipe(Output, outputAmount), (Object[]) validSlots.toArray()); + GameRegistry.addRecipe(new ShapelessOreRecipe(Output, validSlots.toArray())); + // GameRegistry.addShapelessRecipe(new ItemStack(output_ITEM, 1), new Object[] {slot_1, slot_2}); + Logger.RECIPE("Success! Added a recipe for " + Output.getDisplayName()); + RegistrationHandler.recipesSuccess++; + } catch (final RuntimeException k) { + k.getMessage(); + k.getClass(); + k.printStackTrace(); + k.getLocalizedMessage(); + Logger.RECIPE("[Fix] Invalid Recipe detected for: " + Output.getUnlocalizedName()); + RegistrationHandler.recipesFailed++; + } + + // GameRegistry.addShapelessRecipe(new ItemStack(output_ITEM, 1), new Object[] {slot_1, slot_2}); + } + + public static void recipeBuilder(final Object[] array, final ItemStack outPut) { + Logger.SPECIFIC_WARNING( + "object Array - recipeBuilder", + "Attempting to build a recipe using an object array as an input, splitting it, then running the normal recipeBuilder() method.", + 396); + Object a = null; + Object b = null; + Object c = null; + Object d = null; + Object e = null; + Object f = null; + Object g = null; + Object h = null; + Object i = null; + for (int z = 0; z <= array.length; z++) { + array[z].toString(); + switch (z) { + case 0: + a = array[z]; + break; + case 1: + b = array[z]; + break; + case 2: + c = array[z]; + break; + case 3: + d = array[z]; + break; + case 4: + e = array[z]; + break; + case 5: + f = array[z]; + break; + case 6: + g = array[z]; + break; + case 7: + h = array[z]; + break; + case 8: + i = array[z]; + break; + default: + break; + } + recipeBuilder(a, b, c, d, e, f, g, h, i, outPut); + } + } + + public static boolean removeCraftingRecipe(Object x) { + if (null == x) { + return false; + } + if (x instanceof String) { + final Item R = ItemUtils.getItemFromFQRN((String) x); + if (R != null) { + x = R; + } else { + return false; + } + } + if ((x instanceof Item) || (x instanceof ItemStack)) { + if (x instanceof Item) { + final ItemStack r = new ItemStack((Item) x); + Logger.RECIPE("Removing Recipe for " + r.getUnlocalizedName()); + } else { + Logger.RECIPE("Removing Recipe for " + ((ItemStack) x).getUnlocalizedName()); + } + if (x instanceof ItemStack) { + final Item r = ((ItemStack) x).getItem(); + if (null != r) { + x = r; + } else { + Logger.RECIPE("Recipe removal failed - Tell Alkalus."); + return false; + } + } + if (RecipeUtils.attemptRecipeRemoval((Item) x)) { + Logger.RECIPE("Recipe removal successful"); + return true; + } + Logger.RECIPE("Recipe removal failed - Tell Alkalus."); + return false; + } + return false; + } + + private static boolean attemptRecipeRemoval(final Item I) { + Logger.RECIPE("Create list of recipes."); + final List recipes = CraftingManager.getInstance().getRecipeList(); + final Iterator items = recipes.iterator(); + Logger.RECIPE("Begin list iteration."); + while (items.hasNext()) { + final ItemStack is = items.next().getRecipeOutput(); + if ((is != null) && (is.getItem() == I)) { + items.remove(); + Logger.RECIPE("Remove a recipe with " + I.getUnlocalizedName() + " as output."); + continue; + } + } + Logger.RECIPE("All recipes should be gone?"); + if (!items.hasNext()) { + Logger.RECIPE("We iterated once, let's try again to double check."); + final Iterator items2 = recipes.iterator(); + while (items2.hasNext()) { + final ItemStack is = items2.next().getRecipeOutput(); + if ((is != null) && (is.getItem() == I)) { + items.remove(); + Logger.RECIPE("REMOVING MISSED RECIPE - RECHECK CONSTRUCTORS"); + return true; + } + } + Logger.RECIPE("Should be all gone now after double checking, so return true."); + return true; + } + Logger.RECIPE("Return false, because something went wrong."); + return false; + } + + public static boolean addShapedGregtechRecipeForTypes( + final Object InputItem1, + final Object InputItem2, + final Object InputItem3, + final Object InputItem4, + final Object InputItem5, + final Object InputItem6, + final Object InputItem7, + final Object InputItem8, + final Object InputItem9, + final ItemStack OutputItem) { + + int using = 0, recipeSlotCurrent = 0; + boolean[] hasMultiStack = new boolean[9]; + boolean inUse[] = {false, false, false}; + ItemStack array[][] = new ItemStack[3][9]; + + Object[] inputs = { + InputItem1, InputItem2, InputItem3, + InputItem4, InputItem5, InputItem6, + InputItem7, InputItem8, InputItem9 + }; + + for (Object o : inputs) { + if (o.getClass().isArray()) { + if (inUse[using] == false) { + inUse[using] = true; + array[using] = (ItemStack[]) o; + hasMultiStack[recipeSlotCurrent] = true; + using++; + } + } else { + hasMultiStack[recipeSlotCurrent] = false; + } + recipeSlotCurrent++; + } + + int using2 = 0; + for (boolean t : inUse) { + + if (t) { + if (array[using2] != null) { + // addShapedGregtechRecipe + } + } + using2++; + } + + return false; + } + + public static boolean addShapedGregtechRecipe( + final Object InputItem1, + final Object InputItem2, + final Object InputItem3, + final Object InputItem4, + final Object InputItem5, + final Object InputItem6, + final Object InputItem7, + final Object InputItem8, + final Object InputItem9, + final ItemStack OutputItem) { + + Object[] o = { + InputItem1, InputItem2, InputItem3, + InputItem4, InputItem5, InputItem6, + InputItem7, InputItem8, InputItem9 + }; + + if (gtPlusPlus.GTplusplus.CURRENT_LOAD_PHASE != GTplusplus.INIT_PHASE.POST_INIT) { + CORE.crash("Load Phase " + gtPlusPlus.GTplusplus.CURRENT_LOAD_PHASE + " should be " + + GTplusplus.INIT_PHASE.POST_INIT + ". Unable to register recipe."); + } + + int size = COMPAT_HANDLER.mGtRecipesToGenerate.size(); + COMPAT_HANDLER.mGtRecipesToGenerate.put(new InternalRecipeObject(o, OutputItem, true)); + + if (COMPAT_HANDLER.mGtRecipesToGenerate.size() > size) { + if (!COMPAT_HANDLER.areInitItemsLoaded) { + RegistrationHandler.recipesSuccess++; + } else { + LateRegistrationHandler.recipesSuccess++; + } + return true; + } + return false; + } + + public static boolean addShapedGregtechRecipe(final Object[] inputs, ItemStack output) { + + if (inputs.length != 9) { + Logger.RECIPE("[Fix] Input array for " + output.getDisplayName() + " does not equal 9. " + inputs.length + + " is the actual size."); + RegistrationHandler.recipesFailed++; + return false; + } + + for (int x = 0; x < 9; x++) { + if (inputs[x] == null) { + inputs[x] = " "; + Logger.WARNING("Input slot " + x + " changed from NULL to a blank space."); + } else if (!(inputs[x] instanceof ItemStack) + && !(inputs[x] instanceof String) + && !(inputs[x] instanceof Item)) { + if (output != null) { + Logger.RECIPE("[Fix] Invalid Item inserted into inputArray. Item:" + output.getDisplayName() + + " has a bad recipe. Please report to Alkalus."); + RegistrationHandler.recipesFailed++; + return false; + } else { + Logger.RECIPE("[Fix] Output is Null for a recipe. Report to Alkalus."); + output = ItemUtils.getItemStackOfAmountFromOreDict("sadibasdkjnad", 1); + RegistrationHandler.recipesFailed++; + } + } + } + + int size = COMPAT_HANDLER.mGtRecipesToGenerate.size(); + COMPAT_HANDLER.mGtRecipesToGenerate.put(new InternalRecipeObject(inputs, output, true)); + + if (COMPAT_HANDLER.mGtRecipesToGenerate.size() > size) { + if (!COMPAT_HANDLER.areInitItemsLoaded) { + RegistrationHandler.recipesSuccess++; + } else { + LateRegistrationHandler.recipesSuccess++; + } + return true; + } + return false; + } + + public static boolean addShapelessGregtechRecipe( + final Object InputItem1, + final Object InputItem2, + final Object InputItem3, + final Object InputItem4, + final Object InputItem5, + final Object InputItem6, + final Object InputItem7, + final Object InputItem8, + final Object InputItem9, + final ItemStack OutputItem) { + + Object[] inputItems = { + InputItem1, InputItem2, InputItem3, + InputItem4, InputItem5, InputItem6, + InputItem7, InputItem8, InputItem9 + }; + return addShapelessGregtechRecipe(inputItems, OutputItem); + } + + public static boolean addShapelessGregtechRecipe(final Object[] inputItems, final ItemStack OutputItem) { + // Catch Invalid Recipes + if (inputItems.length > 9 || inputItems.length < 1) { + if (OutputItem != null) { + Logger.RECIPE("[Fix] Invalid input array for shapeless recipe, which should output " + + OutputItem.getDisplayName()); + } + return false; + } + // let gregtech handle shapeless recipes. + if (GT_ModHandler.addShapelessCraftingRecipe(OutputItem, inputItems)) { + return true; + } + return false; + } + + public static ItemStack getItemStackFromOreDict(final String oredictName) { + final ArrayList oreDictList = OreDictionary.getOres(oredictName); + return oreDictList.get(0); + } + + public static boolean buildShapelessRecipe(final ItemStack output, final Object[] input) { + return ShapelessUtils.addShapelessRecipe(output, input); + } + + public static boolean generateMortarRecipe(ItemStack aStack, ItemStack aOutput) { + return RecipeUtils.addShapedGregtechRecipe( + aStack, null, null, CI.craftingToolMortar, null, null, null, null, null, aOutput); + } + + public static boolean doesGregtechRecipeHaveEqualCells(GT_Recipe x) { + if (x.mInputs.length == 0 && x.mOutputs.length == 0) { + return true; + } + + final int tInputAmount = GT_ModHandler.getCapsuleCellContainerCountMultipliedWithStackSize(x.mInputs); + final int tOutputAmount = GT_ModHandler.getCapsuleCellContainerCountMultipliedWithStackSize(x.mOutputs); + + if (tInputAmount < tOutputAmount) { + if (!Materials.Tin.contains(x.mInputs)) { + return false; + } else { + return true; + } + } else if (tInputAmount > tOutputAmount && !Materials.Tin.contains(x.mOutputs)) { + return false; + } else { + return true; + } + } + + public static String[] getRecipeInfo(GT_Recipe m) { + if (m == null) { + return new String[] {}; + } + AutoMap result = new AutoMap(); + result.put(m.toString()); + result.put("Input " + ItemUtils.getArrayStackNames(m.mInputs)); + result.put("Output " + ItemUtils.getArrayStackNames(m.mOutputs)); + result.put("Input " + ItemUtils.getArrayStackNames(m.mFluidInputs)); + result.put("Output " + ItemUtils.getArrayStackNames(m.mFluidOutputs)); + result.put("Can be buffered? " + m.mCanBeBuffered); + result.put("Duration: " + m.mDuration); + result.put("EU/t: " + m.mEUt); + result.put("Is Hidden? " + m.mHidden); + result.put("Is Enabled? " + m.mEnabled); + result.put("Special Value: " + m.mSpecialValue); + result.put("====================================="); + String s[] = result.toArray(); + return s; + } + + public static class InternalRecipeObject implements RunnableWithInfo { + final ItemStack mOutput; + final ShapedOreRecipe mRecipe; + public final boolean isValid; + + public InternalRecipeObject(Object[] aInputs, ItemStack aOutput, boolean gtRecipe) { + Logger.RECIPE("==================================="); + mOutput = aOutput != null ? aOutput.copy() : null; + Object[] aFiltered = new Object[9]; + int aValid = 0; + for (Object o : aInputs) { + if (o instanceof ItemStack) { + aFiltered[aValid++] = o; + } else if (o instanceof Item) { + aFiltered[aValid++] = ItemUtils.getSimpleStack((Item) o); + } else if (o instanceof Block) { + aFiltered[aValid++] = ItemUtils.getSimpleStack((Block) o); + } else if (o instanceof String) { + aFiltered[aValid++] = o; + } else if (o == null) { + aFiltered[aValid++] = null; + } else { + Logger.RECIPE("Cleaned a " + o.getClass().getSimpleName() + " from recipe input."); + } + } + + int validCounter = 0, invalidCounter = 0; + for (Object p : aFiltered) { + if (p instanceof ItemStack) { + validCounter++; + } else if (p instanceof Item) { + validCounter++; + } else if (p instanceof Block) { + validCounter++; + } else if (p instanceof String) { + validCounter++; + } else if (p == null) { + validCounter++; + } else { + invalidCounter++; + } + } + + Logger.RECIPE("Using " + validCounter + " valid inputs and " + invalidCounter + " invalid inputs."); + ShapedRecipe r = new ShapedRecipe(aFiltered, mOutput); + if (r != null && r.mRecipe != null) { + isValid = true; + } else { + isValid = false; + } + mRecipe = r != null ? r.mRecipe : null; + } + + @Override + public void run() { + if (this.isValid) { + GameRegistry.addRecipe(mRecipe); + } else { + Logger.RECIPE( + "[Fix] Invalid shapped recipe outputting " + mOutput != null + ? mOutput.getDisplayName() + : "Bad Output Item"); + } + } + + @Override + public String getInfoData() { + if (mOutput != null && mOutput instanceof ItemStack) { + return ((ItemStack) mOutput).getDisplayName(); + } + return ""; + } + } + + public static boolean removeGtRecipe(GT_Recipe aRecipeToRemove, GT_Recipe_Map aRecipeMap) { + if (aRecipeMap.mRecipeList.contains(aRecipeToRemove)) { + return aRecipeMap.mRecipeList.remove(aRecipeToRemove); + } + return false; + } + + public static boolean addGtRecipe(GT_Recipe aRecipeToAdd, GT_Recipe_Map aRecipeMap) { if (!aRecipeMap.mRecipeList.contains(aRecipeToAdd)) { return aRecipeMap.mRecipeList.add(aRecipeToAdd); } - return false; - } - + return false; + } + public static boolean removeRecipeByOutput(ItemStack aOutput) { return removeRecipeByOutput(aOutput, true, false, false); } - public static boolean removeRecipeByOutput(ItemStack aOutput, boolean aIgnoreNBT, - boolean aNotRemoveShapelessRecipes, boolean aOnlyRemoveNativeHandlers) { + public static boolean removeRecipeByOutput( + ItemStack aOutput, + boolean aIgnoreNBT, + boolean aNotRemoveShapelessRecipes, + boolean aOnlyRemoveNativeHandlers) { if (aOutput == null) { return false; } else { @@ -622,10 +700,12 @@ public static int mInvalidID = 1; if (!aNotRemoveShapelessRecipes || !(tRecipe instanceof ShapelessRecipes) && !(tRecipe instanceof ShapelessOreRecipe)) { if (aOnlyRemoveNativeHandlers) { - if (!gregtech.api.util.GT_ModHandler.sNativeRecipeClasses.contains(tRecipe.getClass().getName())) { + if (!gregtech.api.util.GT_ModHandler.sNativeRecipeClasses.contains( + tRecipe.getClass().getName())) { continue; } - } else if (gregtech.api.util.GT_ModHandler.sSpecialRecipeClasses.contains(tRecipe.getClass().getName())) { + } else if (gregtech.api.util.GT_ModHandler.sSpecialRecipeClasses.contains( + tRecipe.getClass().getName())) { continue; } @@ -642,162 +722,162 @@ public static int mInvalidID = 1; } } + public static void addSmeltingRecipe(ItemStack aStackInput, ItemStack aStackOutput) { + addSmeltingRecipe(aStackInput, aStackOutput, 0f); + } + + public static void addSmeltingRecipe(ItemStack aStackInput, ItemStack aStackOutput, float aXpGained) { + + GameRegistry.addSmelting(aStackInput, aStackOutput, aXpGained); + } + + public static boolean addShapedRecipe( + Object Input_1, + Object Input_2, + Object Input_3, + Object Input_4, + Object Input_5, + Object Input_6, + Object Input_7, + Object Input_8, + Object Input_9, + ItemStack aOutputStack) { + return addShapedRecipe( + new Object[] {Input_1, Input_2, Input_3, Input_4, Input_5, Input_6, Input_7, Input_8, Input_9}, + aOutputStack); + } + + private static boolean addShapedRecipe(Object[] Inputs, ItemStack aOutputStack) { + Object[] Slots = new Object[9]; + + String aFullString = ""; + String aFullStringExpanded = "abcdefghi"; + + for (int i = 0; i < 9; i++) { + Object o = Inputs[i]; + + if (o instanceof ItemStack) { + Slots[i] = ItemUtils.getSimpleStack((ItemStack) o, 1); + aFullString += aFullStringExpanded.charAt(i); + } else if (o instanceof Item) { + Slots[i] = ItemUtils.getSimpleStack((Item) o, 1); + aFullString += aFullStringExpanded.charAt(i); + } else if (o instanceof Block) { + Slots[i] = ItemUtils.getSimpleStack((Block) o, 1); + aFullString += aFullStringExpanded.charAt(i); + } else if (o instanceof String) { + Slots[i] = o; + aFullString += aFullStringExpanded.charAt(i); + } else if (o instanceof ItemData) { + ItemData aData = (ItemData) o; + ItemStack aStackFromGT = ItemUtils.getOrePrefixStack(aData.mPrefix, aData.mMaterial.mMaterial, 1); + Slots[i] = aStackFromGT; + aFullString += aFullStringExpanded.charAt(i); + } else if (o == null) { + Slots[i] = null; + aFullString += " "; + } else { + Slots[i] = null; + Logger.INFO("Cleaned a " + o.getClass().getSimpleName() + " from recipe input."); + Logger.INFO("ERROR"); + CORE.crash("Bad Shaped Recipe."); + } + } + Logger.RECIPE("Using String: " + aFullString); + + String aRow1 = aFullString.substring(0, 3); + String aRow2 = aFullString.substring(3, 6); + String aRow3 = aFullString.substring(6, 9); + Logger.RECIPE("" + aRow1); + Logger.RECIPE("" + aRow2); + Logger.RECIPE("" + aRow3); + + String[] aStringData = new String[] {aRow1, aRow2, aRow3}; + Object[] aDataObject = new Object[19]; + aDataObject[0] = aStringData; + int aIndex = 0; + + for (int u = 1; u < 20; u += 2) { + if (aIndex == 9) { + break; + } + if (aFullString.charAt(aIndex) != (' ')) { + aDataObject[u] = aFullString.charAt(aIndex); + aDataObject[u + 1] = Slots[aIndex]; + Logger.INFO("(" + aIndex + ") " + aFullString.charAt(aIndex) + " | " + + (Slots[aIndex] instanceof ItemStack + ? ItemUtils.getItemName((ItemStack) Slots[aIndex]) + : Slots[aIndex] instanceof String ? (String) Slots[aIndex] : "Unknown")); + } + aIndex++; + } + + Logger.RECIPE("Data Size: " + aDataObject.length); + aDataObject = ArrayUtils.removeNulls(aDataObject); + Logger.RECIPE("Clean Size: " + aDataObject.length); + Logger.RECIPE("ArrayData: " + Arrays.toString(aDataObject)); + + ShapedOreRecipe aRecipe = new ShapedOreRecipe(aOutputStack, aDataObject); + + /*ShapedOreRecipe aRecipe = new ShapedOreRecipe(aOutputStack, + aStringData, + 'a', Slots[0], + 'b', Slots[1], + 'c', Slots[2], + 'd', Slots[3], + 'e', Slots[4], + 'f', Slots[5], + 'g', Slots[6], + 'h', Slots[7], + 'i', Slots[8]);*/ + + int size = COMPAT_HANDLER.mRecipesToGenerate.size(); + COMPAT_HANDLER.mRecipesToGenerate.put(new InternalRecipeObject2(aRecipe)); + if (COMPAT_HANDLER.mRecipesToGenerate.size() > size) { + if (!COMPAT_HANDLER.areInitItemsLoaded) { + RegistrationHandler.recipesSuccess++; + } else { + LateRegistrationHandler.recipesSuccess++; + } + return true; + } + return false; + } + + public static class InternalRecipeObject2 implements RunnableWithInfo { + + final ItemStack mOutput; + final ShapedOreRecipe mRecipe; + final boolean isValid; - public static void addSmeltingRecipe(ItemStack aStackInput, ItemStack aStackOutput) { - addSmeltingRecipe(aStackInput, aStackOutput, 0f); - } - - public static void addSmeltingRecipe(ItemStack aStackInput, ItemStack aStackOutput, float aXpGained) { - - GameRegistry.addSmelting(aStackInput, aStackOutput, aXpGained); - - } - - public static boolean addShapedRecipe( - Object Input_1, Object Input_2, Object Input_3, - Object Input_4, Object Input_5, Object Input_6, - Object Input_7, Object Input_8, Object Input_9, - ItemStack aOutputStack) { - return addShapedRecipe(new Object[] {Input_1, Input_2, Input_3, Input_4, Input_5, Input_6, Input_7, Input_8, Input_9}, aOutputStack); - } - - private static boolean addShapedRecipe(Object[] Inputs, ItemStack aOutputStack) { - Object[] Slots = new Object[9]; - - String aFullString = ""; - String aFullStringExpanded = "abcdefghi"; - - for (int i=0; i<9; i++) { - Object o = Inputs[i]; - - if (o instanceof ItemStack) { - Slots[i] = ItemUtils.getSimpleStack((ItemStack) o, 1); - aFullString += aFullStringExpanded.charAt(i); - } - else if (o instanceof Item) { - Slots[i] = ItemUtils.getSimpleStack((Item) o, 1); - aFullString += aFullStringExpanded.charAt(i); - } - else if (o instanceof Block) { - Slots[i] = ItemUtils.getSimpleStack((Block) o, 1); - aFullString += aFullStringExpanded.charAt(i); - } - else if (o instanceof String) { - Slots[i] = o; - aFullString += aFullStringExpanded.charAt(i); - } - else if (o instanceof ItemData) { - ItemData aData = (ItemData) o; - ItemStack aStackFromGT = ItemUtils.getOrePrefixStack(aData.mPrefix, aData.mMaterial.mMaterial, 1); - Slots[i] = aStackFromGT; - aFullString += aFullStringExpanded.charAt(i); - } - else if (o == null) { - Slots[i] = null; - aFullString += " "; - } - else { - Slots[i] = null; - Logger.INFO("Cleaned a "+o.getClass().getSimpleName()+" from recipe input."); - Logger.INFO("ERROR"); - CORE.crash("Bad Shaped Recipe."); - } - } - Logger.RECIPE("Using String: "+aFullString); - - String aRow1 = aFullString.substring(0, 3); - String aRow2 = aFullString.substring(3, 6); - String aRow3 = aFullString.substring(6, 9); - Logger.RECIPE(""+aRow1); - Logger.RECIPE(""+aRow2); - Logger.RECIPE(""+aRow3); - - String[] aStringData = new String[] {aRow1, aRow2, aRow3}; - Object[] aDataObject = new Object[19]; - aDataObject[0] = aStringData; - int aIndex = 0; - - - for (int u=1;u<20;u+=2) { - if (aIndex == 9) { - break; - } - if (aFullString.charAt(aIndex) != (' ')) { - aDataObject[u] = aFullString.charAt(aIndex); - aDataObject[u+1] = Slots[aIndex]; - Logger.INFO("("+aIndex+") "+aFullString.charAt(aIndex)+" | "+ (Slots[aIndex] instanceof ItemStack ? ItemUtils.getItemName((ItemStack) Slots[aIndex]) : Slots[aIndex] instanceof String ? (String) Slots[aIndex] : "Unknown")); - } - aIndex++; - } - - Logger.RECIPE("Data Size: "+aDataObject.length); - aDataObject = ArrayUtils.removeNulls(aDataObject); - Logger.RECIPE("Clean Size: "+aDataObject.length); - Logger.RECIPE("ArrayData: "+Arrays.toString(aDataObject)); - - ShapedOreRecipe aRecipe = new ShapedOreRecipe(aOutputStack, aDataObject); - - /*ShapedOreRecipe aRecipe = new ShapedOreRecipe(aOutputStack, - aStringData, - 'a', Slots[0], - 'b', Slots[1], - 'c', Slots[2], - 'd', Slots[3], - 'e', Slots[4], - 'f', Slots[5], - 'g', Slots[6], - 'h', Slots[7], - 'i', Slots[8]);*/ - - int size = COMPAT_HANDLER.mRecipesToGenerate.size(); - COMPAT_HANDLER.mRecipesToGenerate.put(new InternalRecipeObject2(aRecipe)); - if (COMPAT_HANDLER.mRecipesToGenerate.size() > size) { - if (!COMPAT_HANDLER.areInitItemsLoaded){ - RegistrationHandler.recipesSuccess++; - } - else { - LateRegistrationHandler.recipesSuccess++; - } - return true; - } - return false; - } - public static class InternalRecipeObject2 implements RunnableWithInfo { - - final ItemStack mOutput; - final ShapedOreRecipe mRecipe; - final boolean isValid; - - public InternalRecipeObject2(ShapedOreRecipe aRecipe) { - mRecipe = aRecipe; - mOutput = aRecipe.getRecipeOutput(); - if (mOutput != null) { - this.isValid = true; - } - else { - this.isValid = false; - } - } - - @Override - public void run() { - if (this.isValid) { - GameRegistry.addRecipe(mRecipe); - } - else { - Logger.INFO("[Fix] Invalid shapped recipe outputting "+mOutput != null ? mOutput.getDisplayName() : "Bad Output Item"); - } - } - - @Override - public String getInfoData() { - if (mOutput != null && mOutput instanceof ItemStack) { - return ((ItemStack) mOutput).getDisplayName(); - } - return ""; - } - - } + public InternalRecipeObject2(ShapedOreRecipe aRecipe) { + mRecipe = aRecipe; + mOutput = aRecipe.getRecipeOutput(); + if (mOutput != null) { + this.isValid = true; + } else { + this.isValid = false; + } + } + @Override + public void run() { + if (this.isValid) { + GameRegistry.addRecipe(mRecipe); + } else { + Logger.INFO( + "[Fix] Invalid shapped recipe outputting " + mOutput != null + ? mOutput.getDisplayName() + : "Bad Output Item"); + } + } + @Override + public String getInfoData() { + if (mOutput != null && mOutput instanceof ItemStack) { + return ((ItemStack) mOutput).getDisplayName(); + } + return ""; + } + } } diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/ShapelessUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/ShapelessUtils.java index 3caa9d4e4f..5994bf5f67 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/ShapelessUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/ShapelessUtils.java @@ -1,56 +1,40 @@ package gtPlusPlus.core.util.minecraft; +import gtPlusPlus.api.objects.Logger; import java.util.ArrayList; - import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.ShapelessRecipes; -import gtPlusPlus.api.objects.Logger; - public class ShapelessUtils { - - public static boolean addShapelessRecipe(final ItemStack output, final Object ... params) - { - final ArrayList arraylist = new ArrayList<>(); - final Object[] aobject = params; - final int i = params.length; - - for (int j = 0; j < i; ++j) - { - final Object object1 = aobject[j]; - - if (object1 instanceof ItemStack) - { - arraylist.add(((ItemStack)object1).copy()); - } - else if (object1 instanceof Item) - { - arraylist.add(new ItemStack((Item)object1)); - } - else - { - if ((object1 == null)) - { - Logger.INFO(("Invalid shapeless input, ignoring!")); - } - else if (!(object1 instanceof Block) && (object1 != null)) - { - Logger.INFO(("Invalid shapeless recipe!")); - return false; - } - else { - arraylist.add(new ItemStack((Block)object1)); - } - } - } - CraftingManager.getInstance().getRecipeList().add(new ShapelessRecipes(output, arraylist)); - //CraftingManager.getInstance().addShapelessRecipe(output, arraylist); - return true; - } - - + public static boolean addShapelessRecipe(final ItemStack output, final Object... params) { + final ArrayList arraylist = new ArrayList<>(); + final Object[] aobject = params; + final int i = params.length; + + for (int j = 0; j < i; ++j) { + final Object object1 = aobject[j]; + + if (object1 instanceof ItemStack) { + arraylist.add(((ItemStack) object1).copy()); + } else if (object1 instanceof Item) { + arraylist.add(new ItemStack((Item) object1)); + } else { + if ((object1 == null)) { + Logger.INFO(("Invalid shapeless input, ignoring!")); + } else if (!(object1 instanceof Block) && (object1 != null)) { + Logger.INFO(("Invalid shapeless recipe!")); + return false; + } else { + arraylist.add(new ItemStack((Block) object1)); + } + } + } + CraftingManager.getInstance().getRecipeList().add(new ShapelessRecipes(output, arraylist)); + // CraftingManager.getInstance().addShapelessRecipe(output, arraylist); + return true; + } } diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java index 242a63c712..33ef1b89e3 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java @@ -2,8 +2,6 @@ package gtPlusPlus.core.util.minecraft.gregtech; import static gtPlusPlus.core.lib.CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK; -import org.apache.commons.lang3.ArrayUtils; - import gregtech.GT_Mod; import gregtech.api.enums.OrePrefixes; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -20,172 +18,162 @@ import gtPlusPlus.core.util.minecraft.ItemUtils; import net.minecraft.item.ItemStack; import net.minecraft.world.chunk.Chunk; import net.minecraftforge.fluids.FluidStack; +import org.apache.commons.lang3.ArrayUtils; public class PollutionUtils { - private static boolean mIsPollutionEnabled = true; - - public static AutoMap mPollutionFluidStacks = new AutoMap(); - - static { - if (MAIN_GREGTECH_5U_EXPERIMENTAL_FORK || CORE.GTNH) { - mIsPollutionEnabled = mPollution(); - } else { - mIsPollutionEnabled = false; - } - } - - public static boolean isPollutionEnabled() { - return mIsPollutionEnabled; - } - - private static boolean mPollution() { - return GT_Mod.gregtechproxy.mPollution; - } - - public static boolean addPollution(IGregTechTileEntity te, int pollutionValue) { - if (mIsPollutionEnabled) { - GT_Pollution.addPollution(te, pollutionValue); - return true; - } - return false; - } - - public static boolean addPollution(IHasWorldObjectAndCoords aTileOfSomeSort, int pollutionValue) { - if (mIsPollutionEnabled) { - IHasWorldObjectAndCoords j = (IHasWorldObjectAndCoords) aTileOfSomeSort; - Chunk c = j.getWorld().getChunkFromBlockCoords(j.getXCoord(), j.getZCoord()); - return addPollution(c, pollutionValue); - } - return false; - } - - public static boolean addPollution(Chunk aChunk, int pollutionValue) { - if (mIsPollutionEnabled) { - GT_Pollution.addPollution(aChunk, pollutionValue); - return true; - } - return false; - } - - public static boolean removePollution(IGregTechTileEntity te, int pollutionValue) { - return addPollution(te, -pollutionValue); - } - - public static boolean removePollution(IHasWorldObjectAndCoords aTileOfSomeSort, int pollutionValue) { - return addPollution(aTileOfSomeSort, -pollutionValue); - } - - public static boolean removePollution(Chunk aChunk, int pollutionValue) { - return addPollution(aChunk, -pollutionValue); - } - - public static boolean nullifyPollution(IGregTechTileEntity te) { - if (te == null) { - return false; - } - return nullifyPollution((IHasWorldObjectAndCoords) te); - } - - public static boolean nullifyPollution(IHasWorldObjectAndCoords aTileOfSomeSort) { - if (aTileOfSomeSort == null) { - return false; - } - IHasWorldObjectAndCoords j = (IHasWorldObjectAndCoords) aTileOfSomeSort; - Chunk c = j.getWorld().getChunkFromBlockCoords(j.getXCoord(), j.getZCoord()); - return nullifyPollution(c); - } - - public static boolean nullifyPollution(Chunk aChunk) { - if (mIsPollutionEnabled) { - if (aChunk == null) { - return false; - } - int getCurrentPollution = getPollution(aChunk); - if (getCurrentPollution <= 0) { - return false; - } - else { - return removePollution(aChunk, getCurrentPollution); - } - } - return false; - } - - public static int getPollution(IGregTechTileEntity te) { - return GT_Pollution.getPollution(te); - } - - public static int getPollution(Chunk te) { - return GT_Pollution.getPollution(te); - } - - public static boolean setPollutionFluids() { - if (mPollutionFluidStacks.isEmpty()) { - FluidStack CD, CM, SD; - CD = FluidUtils.getFluidStack("carbondioxide", 1000); - CM = FluidUtils.getFluidStack("carbonmonoxide", 1000); - SD = FluidUtils.getFluidStack("sulfurdioxide", 1000); - if (PollutionUtils.mPollutionFluidStacks.size() == 0) { - if (CD != null) { - Logger.INFO("[PollutionCompat] Found carbon dioxide fluid, registering it."); - PollutionUtils.mPollutionFluidStacks.put(CD); - MISC_MATERIALS.CARBON_DIOXIDE.registerComponentForMaterial(CD); - ItemStack cellCD = ItemUtils.getItemStackOfAmountFromOreDict("cellCarbonDioxide", 1); - if (ItemUtils.checkForInvalidItems(cellCD)) { - Logger.INFO("[PollutionCompat] Found carbon dioxide cell, registering component."); - MISC_MATERIALS.CARBON_DIOXIDE.registerComponentForMaterial(OrePrefixes.cell, cellCD); - } - else { - Logger.INFO("[PollutionCompat] Did not find carbon dioxide cell, registering new component."); - new BaseItemCell(MISC_MATERIALS.CARBON_DIOXIDE); - } - } - else { - MaterialGenerator.generate(MISC_MATERIALS.CARBON_DIOXIDE, false, false); - } - - if (CM != null) { - Logger.INFO("[PollutionCompat] Found carbon monoxide fluid, registering it."); - PollutionUtils.mPollutionFluidStacks.put(CM); - MISC_MATERIALS.CARBON_MONOXIDE.registerComponentForMaterial(CM); - ItemStack cellCD = ItemUtils.getItemStackOfAmountFromOreDict("cellCarbonMonoxide", 1); - if (ItemUtils.checkForInvalidItems(cellCD)) { - Logger.INFO("[PollutionCompat] Found carbon monoxide cell, registering component."); - MISC_MATERIALS.CARBON_MONOXIDE.registerComponentForMaterial(OrePrefixes.cell, cellCD); - } - else { - Logger.INFO("[PollutionCompat] Did not find carbon monoxide cell, registering new component."); - new BaseItemCell(MISC_MATERIALS.CARBON_MONOXIDE); - } - } - else { - MaterialGenerator.generate(MISC_MATERIALS.CARBON_MONOXIDE, false, false); - } - - if (SD != null) { - Logger.INFO("[PollutionCompat] Found sulfur dioxide fluid, registering it."); - PollutionUtils.mPollutionFluidStacks.put(SD); - } - } - if (PollutionUtils.mPollutionFluidStacks.size() > 0) { - return true; - } - return false; - } - else { - if (mPollutionFluidStacks.size() != 3) { - Logger.INFO("Unable to detect all 3 pollution fluids. Found: "); - Logger.INFO(ArrayUtils.toString(mPollutionFluidStacks)); - return false; - } - else { - return true; - } - } - - - - } - + private static boolean mIsPollutionEnabled = true; + + public static AutoMap mPollutionFluidStacks = new AutoMap(); + + static { + if (MAIN_GREGTECH_5U_EXPERIMENTAL_FORK || CORE.GTNH) { + mIsPollutionEnabled = mPollution(); + } else { + mIsPollutionEnabled = false; + } + } + + public static boolean isPollutionEnabled() { + return mIsPollutionEnabled; + } + + private static boolean mPollution() { + return GT_Mod.gregtechproxy.mPollution; + } + + public static boolean addPollution(IGregTechTileEntity te, int pollutionValue) { + if (mIsPollutionEnabled) { + GT_Pollution.addPollution(te, pollutionValue); + return true; + } + return false; + } + + public static boolean addPollution(IHasWorldObjectAndCoords aTileOfSomeSort, int pollutionValue) { + if (mIsPollutionEnabled) { + IHasWorldObjectAndCoords j = (IHasWorldObjectAndCoords) aTileOfSomeSort; + Chunk c = j.getWorld().getChunkFromBlockCoords(j.getXCoord(), j.getZCoord()); + return addPollution(c, pollutionValue); + } + return false; + } + + public static boolean addPollution(Chunk aChunk, int pollutionValue) { + if (mIsPollutionEnabled) { + GT_Pollution.addPollution(aChunk, pollutionValue); + return true; + } + return false; + } + + public static boolean removePollution(IGregTechTileEntity te, int pollutionValue) { + return addPollution(te, -pollutionValue); + } + + public static boolean removePollution(IHasWorldObjectAndCoords aTileOfSomeSort, int pollutionValue) { + return addPollution(aTileOfSomeSort, -pollutionValue); + } + + public static boolean removePollution(Chunk aChunk, int pollutionValue) { + return addPollution(aChunk, -pollutionValue); + } + + public static boolean nullifyPollution(IGregTechTileEntity te) { + if (te == null) { + return false; + } + return nullifyPollution((IHasWorldObjectAndCoords) te); + } + + public static boolean nullifyPollution(IHasWorldObjectAndCoords aTileOfSomeSort) { + if (aTileOfSomeSort == null) { + return false; + } + IHasWorldObjectAndCoords j = (IHasWorldObjectAndCoords) aTileOfSomeSort; + Chunk c = j.getWorld().getChunkFromBlockCoords(j.getXCoord(), j.getZCoord()); + return nullifyPollution(c); + } + + public static boolean nullifyPollution(Chunk aChunk) { + if (mIsPollutionEnabled) { + if (aChunk == null) { + return false; + } + int getCurrentPollution = getPollution(aChunk); + if (getCurrentPollution <= 0) { + return false; + } else { + return removePollution(aChunk, getCurrentPollution); + } + } + return false; + } + + public static int getPollution(IGregTechTileEntity te) { + return GT_Pollution.getPollution(te); + } + + public static int getPollution(Chunk te) { + return GT_Pollution.getPollution(te); + } + + public static boolean setPollutionFluids() { + if (mPollutionFluidStacks.isEmpty()) { + FluidStack CD, CM, SD; + CD = FluidUtils.getFluidStack("carbondioxide", 1000); + CM = FluidUtils.getFluidStack("carbonmonoxide", 1000); + SD = FluidUtils.getFluidStack("sulfurdioxide", 1000); + if (PollutionUtils.mPollutionFluidStacks.size() == 0) { + if (CD != null) { + Logger.INFO("[PollutionCompat] Found carbon dioxide fluid, registering it."); + PollutionUtils.mPollutionFluidStacks.put(CD); + MISC_MATERIALS.CARBON_DIOXIDE.registerComponentForMaterial(CD); + ItemStack cellCD = ItemUtils.getItemStackOfAmountFromOreDict("cellCarbonDioxide", 1); + if (ItemUtils.checkForInvalidItems(cellCD)) { + Logger.INFO("[PollutionCompat] Found carbon dioxide cell, registering component."); + MISC_MATERIALS.CARBON_DIOXIDE.registerComponentForMaterial(OrePrefixes.cell, cellCD); + } else { + Logger.INFO("[PollutionCompat] Did not find carbon dioxide cell, registering new component."); + new BaseItemCell(MISC_MATERIALS.CARBON_DIOXIDE); + } + } else { + MaterialGenerator.generate(MISC_MATERIALS.CARBON_DIOXIDE, false, false); + } + + if (CM != null) { + Logger.INFO("[PollutionCompat] Found carbon monoxide fluid, registering it."); + PollutionUtils.mPollutionFluidStacks.put(CM); + MISC_MATERIALS.CARBON_MONOXIDE.registerComponentForMaterial(CM); + ItemStack cellCD = ItemUtils.getItemStackOfAmountFromOreDict("cellCarbonMonoxide", 1); + if (ItemUtils.checkForInvalidItems(cellCD)) { + Logger.INFO("[PollutionCompat] Found carbon monoxide cell, registering component."); + MISC_MATERIALS.CARBON_MONOXIDE.registerComponentForMaterial(OrePrefixes.cell, cellCD); + } else { + Logger.INFO("[PollutionCompat] Did not find carbon monoxide cell, registering new component."); + new BaseItemCell(MISC_MATERIALS.CARBON_MONOXIDE); + } + } else { + MaterialGenerator.generate(MISC_MATERIALS.CARBON_MONOXIDE, false, false); + } + + if (SD != null) { + Logger.INFO("[PollutionCompat] Found sulfur dioxide fluid, registering it."); + PollutionUtils.mPollutionFluidStacks.put(SD); + } + } + if (PollutionUtils.mPollutionFluidStacks.size() > 0) { + return true; + } + return false; + } else { + if (mPollutionFluidStacks.size() != 3) { + Logger.INFO("Unable to detect all 3 pollution fluids. Found: "); + Logger.INFO(ArrayUtils.toString(mPollutionFluidStacks)); + return false; + } else { + return true; + } + } + } } diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/gregtech/material/MaterialBuilder.java b/src/main/java/gtPlusPlus/core/util/minecraft/gregtech/material/MaterialBuilder.java index 44c0f66732..1b35ead9f1 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/gregtech/material/MaterialBuilder.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/gregtech/material/MaterialBuilder.java @@ -1,244 +1,244 @@ package gtPlusPlus.core.util.minecraft.gregtech.material; public class MaterialBuilder { - /*public static final int DIESEL = 0, GAS = 1, THERMAL = 2, SEMIFLUID = 3, PLASMA = 4, MAGIC = 5; - - private int metaItemSubID; - private TextureSet iconSet; - private float toolSpeed = 1.0f; - private int durability = 0; - private int toolQuality = 0; - private int types = 0; - private int r = 255, g = 255, b = 255, a = 0; - private String name; - private String defaultLocalName; - private int fuelType = 0; - private int fuelPower = 0; - private int meltingPoint = 0; - private int blastFurnaceTemp = 0; - private boolean blastFurnaceRequired = false; - private boolean transparent = false; - private int oreValue = 1; - private int densityMultiplier = 1; - private int densityDivider = 1; - private Dyes color = Dyes._NULL; - private int extraData = 0; - private List materialList = new ArrayList(); - private List aspects = new ArrayList(); - private boolean canBeCracked = false; - private int liquidTemperature = 300; - private int gasTemperature = 300; - - public MaterialBuilder(int metaItemSubID, TextureSet iconSet, String defaultLocalName) { - this.metaItemSubID = metaItemSubID; - this.iconSet = iconSet; - this.name = defaultLocalName.replace(" ", "").replace("-", ""); - this.defaultLocalName = defaultLocalName; - } - - public Materials constructMaterial() { - return new Materials( - metaItemSubID, iconSet, toolSpeed, durability, toolQuality, types, r, g, b, a, name, defaultLocalName, fuelType, fuelPower, meltingPoint, blastFurnaceTemp, - blastFurnaceRequired, transparent, oreValue, densityMultiplier, densityDivider, color, extraData, materialList, aspects); - - } - - public MaterialBuilder setName(String name){ - this.name = name; - return this; - } - - public MaterialBuilder setTypes(int types){ - this.types = types; - return this; - } - - public MaterialBuilder addDustItems(){ - types = types | 1; - return this; - } - - public MaterialBuilder addMetalItems(){ - types = types | 2; - return this; - } - - public MaterialBuilder addGemItems(){ - types = types | 4; - return this; - } - - public MaterialBuilder addOreItems(){ - types = types | 8; - return this; - } - - public MaterialBuilder addCell(){ - types = types | 16; - return this; - } - - public MaterialBuilder addPlasma(){ - types = types | 32; - return this; - } - - public MaterialBuilder addToolHeadItems(){ - types = types | 64; - return this; - } - - public MaterialBuilder addGearItems(){ - types = types | 128; - return this; - } - - public MaterialBuilder addFluid(){ - return this; - } - - public MaterialBuilder addGas(){ - return this; - } - - - public MaterialBuilder setRGBA(int r, int g, int b, int a){ - this.r = r; - this.g = g; - this.b = b; - this.a = a; - return this; - } - - public MaterialBuilder setRGB(int r, int g, int b){ - this.r = r; - this.g = g; - this.b = b; - return this; - } - - public MaterialBuilder setTransparent(boolean transparent){ - this.transparent = transparent; - return this; - } - - public MaterialBuilder setColor(Dyes color){ - this.color = color; - return this; - } - - - public MaterialBuilder setToolSpeed(float toolSpeed) { - this.toolSpeed = toolSpeed; - return this; - } - - public MaterialBuilder setDurability(int durability) { - this.durability = durability; - return this; - } - - public MaterialBuilder setToolQuality(int toolQuality) { - this.toolQuality = toolQuality; - return this; - } - - - public MaterialBuilder setFuelType(int fuelType) { - this.fuelType = fuelType; - return this; - } - - public MaterialBuilder setFuelPower(int fuelPower) { - this.fuelPower = fuelPower; - return this; - } - - public MaterialBuilder setMeltingPoint(int meltingPoint) { - this.meltingPoint = meltingPoint; - return this; - } - - public MaterialBuilder setBlastFurnaceTemp(int blastFurnaceTemp) { - this.blastFurnaceTemp = blastFurnaceTemp; - return this; - } - - public MaterialBuilder setBlastFurnaceRequired(boolean blastFurnaceRequired) { - this.blastFurnaceRequired = blastFurnaceRequired; - return this; - } - - public MaterialBuilder setOreValue(int oreValue) { - this.oreValue = oreValue; - return this; - } - - public MaterialBuilder setDensityMultiplier(int densityMultiplier) { - this.densityMultiplier = densityMultiplier; - return this; - } - - public MaterialBuilder setDensityDivider(int densityDivider) { - this.densityDivider = densityDivider; - return this; - } - - public MaterialBuilder setExtraData(int extraData) { - this.extraData = extraData; - return this; - } - - public MaterialBuilder addElectrolyzerRecipe(){ - extraData = extraData | 1; - return this; - } - - public MaterialBuilder addCentrifugeRecipe(){ - extraData = extraData | 2; - return this; - } - - public MaterialBuilder setMaterialList(List materialList) { - this.materialList = materialList; - return this; - } - - public MaterialBuilder setMaterialList(MaterialStack ... materials) { - this.materialList = Arrays.asList(materials); - return this; - } - - public MaterialBuilder setAspects(List aspects) { - this.aspects = aspects; - return this; - } - - public int getLiquidTemperature() { - return liquidTemperature; - } - - public MaterialBuilder setLiquidTemperature(int liquidTemperature) { - this.liquidTemperature = liquidTemperature; - return this; - } - - public int getGasTemperature() { - return gasTemperature; - } - - public MaterialBuilder setGasTemperature(int gasTemperature) { - this.gasTemperature = gasTemperature; - return this; - } - - public boolean canBeCracked() { - return canBeCracked; - } - - public MaterialBuilder setCanBeCracked(boolean canBeCracked) { - this.canBeCracked = canBeCracked; - return this; - } -*/ -} \ No newline at end of file + /*public static final int DIESEL = 0, GAS = 1, THERMAL = 2, SEMIFLUID = 3, PLASMA = 4, MAGIC = 5; + + private int metaItemSubID; + private TextureSet iconSet; + private float toolSpeed = 1.0f; + private int durability = 0; + private int toolQuality = 0; + private int types = 0; + private int r = 255, g = 255, b = 255, a = 0; + private String name; + private String defaultLocalName; + private int fuelType = 0; + private int fuelPower = 0; + private int meltingPoint = 0; + private int blastFurnaceTemp = 0; + private boolean blastFurnaceRequired = false; + private boolean transparent = false; + private int oreValue = 1; + private int densityMultiplier = 1; + private int densityDivider = 1; + private Dyes color = Dyes._NULL; + private int extraData = 0; + private List materialList = new ArrayList(); + private List aspects = new ArrayList(); + private boolean canBeCracked = false; + private int liquidTemperature = 300; + private int gasTemperature = 300; + + public MaterialBuilder(int metaItemSubID, TextureSet iconSet, String defaultLocalName) { + this.metaItemSubID = metaItemSubID; + this.iconSet = iconSet; + this.name = defaultLocalName.replace(" ", "").replace("-", ""); + this.defaultLocalName = defaultLocalName; + } + + public Materials constructMaterial() { + return new Materials( + metaItemSubID, iconSet, toolSpeed, durability, toolQuality, types, r, g, b, a, name, defaultLocalName, fuelType, fuelPower, meltingPoint, blastFurnaceTemp, + blastFurnaceRequired, transparent, oreValue, densityMultiplier, densityDivider, color, extraData, materialList, aspects); + + } + + public MaterialBuilder setName(String name){ + this.name = name; + return this; + } + + public MaterialBuilder setTypes(int types){ + this.types = types; + return this; + } + + public MaterialBuilder addDustItems(){ + types = types | 1; + return this; + } + + public MaterialBuilder addMetalItems(){ + types = types | 2; + return this; + } + + public MaterialBuilder addGemItems(){ + types = types | 4; + return this; + } + + public MaterialBuilder addOreItems(){ + types = types | 8; + return this; + } + + public MaterialBuilder addCell(){ + types = types | 16; + return this; + } + + public MaterialBuilder addPlasma(){ + types = types | 32; + return this; + } + + public MaterialBuilder addToolHeadItems(){ + types = types | 64; + return this; + } + + public MaterialBuilder addGearItems(){ + types = types | 128; + return this; + } + + public MaterialBuilder addFluid(){ + return this; + } + + public MaterialBuilder addGas(){ + return this; + } + + + public MaterialBuilder setRGBA(int r, int g, int b, int a){ + this.r = r; + this.g = g; + this.b = b; + this.a = a; + return this; + } + + public MaterialBuilder setRGB(int r, int g, int b){ + this.r = r; + this.g = g; + this.b = b; + return this; + } + + public MaterialBuilder setTransparent(boolean transparent){ + this.transparent = transparent; + return this; + } + + public MaterialBuilder setColor(Dyes color){ + this.color = color; + return this; + } + + + public MaterialBuilder setToolSpeed(float toolSpeed) { + this.toolSpeed = toolSpeed; + return this; + } + + public MaterialBuilder setDurability(int durability) { + this.durability = durability; + return this; + } + + public MaterialBuilder setToolQuality(int toolQuality) { + this.toolQuality = toolQuality; + return this; + } + + + public MaterialBuilder setFuelType(int fuelType) { + this.fuelType = fuelType; + return this; + } + + public MaterialBuilder setFuelPower(int fuelPower) { + this.fuelPower = fuelPower; + return this; + } + + public MaterialBuilder setMeltingPoint(int meltingPoint) { + this.meltingPoint = meltingPoint; + return this; + } + + public MaterialBuilder setBlastFurnaceTemp(int blastFurnaceTemp) { + this.blastFurnaceTemp = blastFurnaceTemp; + return this; + } + + public MaterialBuilder setBlastFurnaceRequired(boolean blastFurnaceRequired) { + this.blastFurnaceRequired = blastFurnaceRequired; + return this; + } + + public MaterialBuilder setOreValue(int oreValue) { + this.oreValue = oreValue; + return this; + } + + public MaterialBuilder setDensityMultiplier(int densityMultiplier) { + this.densityMultiplier = densityMultiplier; + return this; + } + + public MaterialBuilder setDensityDivider(int densityDivider) { + this.densityDivider = densityDivider; + return this; + } + + public MaterialBuilder setExtraData(int extraData) { + this.extraData = extraData; + return this; + } + + public MaterialBuilder addElectrolyzerRecipe(){ + extraData = extraData | 1; + return this; + } + + public MaterialBuilder addCentrifugeRecipe(){ + extraData = extraData | 2; + return this; + } + + public MaterialBuilder setMaterialList(List materialList) { + this.materialList = materialList; + return this; + } + + public MaterialBuilder setMaterialList(MaterialStack ... materials) { + this.materialList = Arrays.asList(materials); + return this; + } + + public MaterialBuilder setAspects(List aspects) { + this.aspects = aspects; + return this; + } + + public int getLiquidTemperature() { + return liquidTemperature; + } + + public MaterialBuilder setLiquidTemperature(int liquidTemperature) { + this.liquidTemperature = liquidTemperature; + return this; + } + + public int getGasTemperature() { + return gasTemperature; + } + + public MaterialBuilder setGasTemperature(int gasTemperature) { + this.gasTemperature = gasTemperature; + return this; + } + + public boolean canBeCracked() { + return canBeCracked; + } + + public MaterialBuilder setCanBeCracked(boolean canBeCracked) { + this.canBeCracked = canBeCracked; + return this; + } + */ +} diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/gregtech/recipehandlers/GregtechRecipe.java b/src/main/java/gtPlusPlus/core/util/minecraft/gregtech/recipehandlers/GregtechRecipe.java index 635239bbfc..cbd92c3f4e 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/gregtech/recipehandlers/GregtechRecipe.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/gregtech/recipehandlers/GregtechRecipe.java @@ -1,3 +1,3 @@ package gtPlusPlus.core.util.minecraft.gregtech.recipehandlers; -public final class GregtechRecipe {} \ No newline at end of file +public final class GregtechRecipe {} diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/network/CustomPacket.java b/src/main/java/gtPlusPlus/core/util/minecraft/network/CustomPacket.java index def836eac9..6a7a33bd8e 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/network/CustomPacket.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/network/CustomPacket.java @@ -9,31 +9,31 @@ import java.io.IOException; import mods.railcraft.common.util.misc.Game; public abstract class CustomPacket { - public static final String CHANNEL_NAME = "GTPP"; + public static final String CHANNEL_NAME = "GTPP"; - public enum PacketType { + public enum PacketType { TILE_ENTITY, - } - - public FMLProxyPacket getPacket() { - ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - DataOutputStream data = new DataOutputStream(bytes); - try { - data.writeByte(this.getID()); - this.writeData(data); - } catch (IOException var4) { - Game.logThrowable("Error constructing packet: {0}", var4, new Object[]{this.getClass()}); - } - return new FMLProxyPacket(Unpooled.wrappedBuffer(bytes.toByteArray()), "GTPP"); - } - - public abstract void writeData(DataOutputStream var1) throws IOException; - - public abstract void readData(DataInputStream var1) throws IOException; - - public abstract int getID(); - - public String toString() { - return this.getClass().getSimpleName(); - } -} \ No newline at end of file + } + + public FMLProxyPacket getPacket() { + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + DataOutputStream data = new DataOutputStream(bytes); + try { + data.writeByte(this.getID()); + this.writeData(data); + } catch (IOException var4) { + Game.logThrowable("Error constructing packet: {0}", var4, new Object[] {this.getClass()}); + } + return new FMLProxyPacket(Unpooled.wrappedBuffer(bytes.toByteArray()), "GTPP"); + } + + public abstract void writeData(DataOutputStream var1) throws IOException; + + public abstract void readData(DataInputStream var1) throws IOException; + + public abstract int getID(); + + public String toString() { + return this.getClass().getSimpleName(); + } +} diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/network/PacketBuilder.java b/src/main/java/gtPlusPlus/core/util/minecraft/network/PacketBuilder.java index edbc6aaf83..30e981b1a0 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/network/PacketBuilder.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/network/PacketBuilder.java @@ -4,22 +4,21 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.world.WorldServer; public class PacketBuilder { - - private static PacketBuilder instance; - public static PacketBuilder instance() { - if (instance == null) { - instance = new PacketBuilder(); - } - return instance; - } + private static PacketBuilder instance; - public void sendTileEntityPacket(IGregTechTileEntity tile) { - if (tile.getWorld() instanceof WorldServer) { - WorldServer world = (WorldServer) tile.getWorld(); - PacketTileEntity pkt = new PacketTileEntity(tile); - PacketDispatcher.sendToWatchers(pkt, world, tile.getXCoord(), tile.getZCoord()); - } - } - -} \ No newline at end of file + public static PacketBuilder instance() { + if (instance == null) { + instance = new PacketBuilder(); + } + return instance; + } + + public void sendTileEntityPacket(IGregTechTileEntity tile) { + if (tile.getWorld() instanceof WorldServer) { + WorldServer world = (WorldServer) tile.getWorld(); + PacketTileEntity pkt = new PacketTileEntity(tile); + PacketDispatcher.sendToWatchers(pkt, world, tile.getXCoord(), tile.getZCoord()); + } + } +} diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/network/PacketDispatcher.java b/src/main/java/gtPlusPlus/core/util/minecraft/network/PacketDispatcher.java index f61a6f2b6c..4b6fc5aa85 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/network/PacketDispatcher.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/network/PacketDispatcher.java @@ -4,7 +4,6 @@ import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import cpw.mods.fml.relauncher.ReflectionHelper; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.preloader.DevHelper; - import java.lang.reflect.Method; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.network.Packet; @@ -13,76 +12,78 @@ import net.minecraft.world.WorldServer; @SuppressWarnings("unchecked") public class PacketDispatcher { - private static final Class playerInstanceClass; - private static final Method getOrCreateChunkWatcher; - private static final Method sendToAllPlayersWatchingChunk; + private static final Class playerInstanceClass; + private static final Method getOrCreateChunkWatcher; + private static final Method sendToAllPlayersWatchingChunk; - public static void sendToServer(CustomPacket packet) { - PacketHandler.INSTANCE.channel.sendToServer(packet.getPacket()); - } + public static void sendToServer(CustomPacket packet) { + PacketHandler.INSTANCE.channel.sendToServer(packet.getPacket()); + } - public static void sendToPlayer(CustomPacket packet, EntityPlayerMP player) { - PacketHandler.INSTANCE.channel.sendTo(packet.getPacket(), player); - } + public static void sendToPlayer(CustomPacket packet, EntityPlayerMP player) { + PacketHandler.INSTANCE.channel.sendTo(packet.getPacket(), player); + } - public static void sendToAll(CustomPacket packet) { - PacketHandler.INSTANCE.channel.sendToAll(packet.getPacket()); - } + public static void sendToAll(CustomPacket packet) { + PacketHandler.INSTANCE.channel.sendToAll(packet.getPacket()); + } - public static void sendToAllAround(CustomPacket packet, TargetPoint zone) { - PacketHandler.INSTANCE.channel.sendToAllAround(packet.getPacket(), zone); - } + public static void sendToAllAround(CustomPacket packet, TargetPoint zone) { + PacketHandler.INSTANCE.channel.sendToAllAround(packet.getPacket(), zone); + } - public static void sendToDimension(CustomPacket packet, int dimensionId) { - PacketHandler.INSTANCE.channel.sendToDimension(packet.getPacket(), dimensionId); - } + public static void sendToDimension(CustomPacket packet, int dimensionId) { + PacketHandler.INSTANCE.channel.sendToDimension(packet.getPacket(), dimensionId); + } - public static void sendToWatchers(CustomPacket packet, WorldServer world, int worldX, int worldZ) { - try { - Object playerInstance = getOrCreateChunkWatcher.invoke(world.getPlayerManager(), worldX >> 4, worldZ >> 4, - false); - if (playerInstance != null) { - sendToAllPlayersWatchingChunk.invoke(playerInstance, packet.getPacket()); - } + public static void sendToWatchers(CustomPacket packet, WorldServer world, int worldX, int worldZ) { + try { + Object playerInstance = + getOrCreateChunkWatcher.invoke(world.getPlayerManager(), worldX >> 4, worldZ >> 4, false); + if (playerInstance != null) { + sendToAllPlayersWatchingChunk.invoke(playerInstance, packet.getPacket()); + } - } catch (Exception var5) { - Logger.ERROR("Reflection Failure in PacketDispatcher.sendToWatchers() {0} {1}" + 20 + var5 + - new Object[]{getOrCreateChunkWatcher.getName() + sendToAllPlayersWatchingChunk.getName()}); - throw new RuntimeException(var5); - } - } + } catch (Exception var5) { + Logger.ERROR("Reflection Failure in PacketDispatcher.sendToWatchers() {0} {1}" + 20 + var5 + + new Object[] {getOrCreateChunkWatcher.getName() + sendToAllPlayersWatchingChunk.getName()}); + throw new RuntimeException(var5); + } + } - static { - try { - playerInstanceClass = PlayerManager.class.getDeclaredClasses()[0]; + static { + try { + playerInstanceClass = PlayerManager.class.getDeclaredClasses()[0]; - Method a, b; - - try { - a = DevHelper.getForgeMethod(PlayerManager.class, "getOrCreateChunkWatcher", int.class, int.class, boolean.class); - } - catch (Throwable t) { - a = ReflectionHelper.findMethod(playerInstanceClass, (Object) null, - new String[]{"func_72690_a", "getOrCreateChunkWatcher"}, - new Class[]{Integer.TYPE, Integer.TYPE, Boolean.TYPE}); - } - try { - b = DevHelper.getForgeMethod(PlayerManager.class, "sendToAllPlayersWatchingChunk", Packet.class); - } - catch (Throwable t) { - b = ReflectionHelper.findMethod(playerInstanceClass, (Object) null, - new String[]{"func_151251_a", "sendToAllPlayersWatchingChunk"}, - new Class[]{Packet.class}); - } + Method a, b; + try { + a = DevHelper.getForgeMethod( + PlayerManager.class, "getOrCreateChunkWatcher", int.class, int.class, boolean.class); + } catch (Throwable t) { + a = ReflectionHelper.findMethod( + playerInstanceClass, + (Object) null, + new String[] {"func_72690_a", "getOrCreateChunkWatcher"}, + new Class[] {Integer.TYPE, Integer.TYPE, Boolean.TYPE}); + } + try { + b = DevHelper.getForgeMethod(PlayerManager.class, "sendToAllPlayersWatchingChunk", Packet.class); + } catch (Throwable t) { + b = ReflectionHelper.findMethod( + playerInstanceClass, + (Object) null, + new String[] {"func_151251_a", "sendToAllPlayersWatchingChunk"}, + new Class[] {Packet.class}); + } - getOrCreateChunkWatcher = a; - sendToAllPlayersWatchingChunk = b; - getOrCreateChunkWatcher.setAccessible(true); - sendToAllPlayersWatchingChunk.setAccessible(true); - } catch (Exception var1) { - Logger.ERROR("Reflection Failure in PacketDispatcher initalization {0} {1}" + var1); - throw new RuntimeException(var1); - } - } -} \ No newline at end of file + getOrCreateChunkWatcher = a; + sendToAllPlayersWatchingChunk = b; + getOrCreateChunkWatcher.setAccessible(true); + sendToAllPlayersWatchingChunk.setAccessible(true); + } catch (Exception var1) { + Logger.ERROR("Reflection Failure in PacketDispatcher initalization {0} {1}" + var1); + throw new RuntimeException(var1); + } + } +} diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/network/PacketHandler.java b/src/main/java/gtPlusPlus/core/util/minecraft/network/PacketHandler.java index 158f9f9483..bd7e1fbcb8 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/network/PacketHandler.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/network/PacketHandler.java @@ -2,11 +2,11 @@ package gtPlusPlus.core.util.minecraft.network; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.network.FMLEventChannel; +import cpw.mods.fml.common.network.FMLNetworkEvent.ClientCustomPacketEvent; +import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent; import cpw.mods.fml.common.network.NetworkRegistry; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.minecraft.network.CustomPacket.PacketType; -import cpw.mods.fml.common.network.FMLNetworkEvent.ClientCustomPacketEvent; -import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent; import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.IOException; @@ -15,57 +15,55 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.network.NetHandlerPlayServer; public class PacketHandler { - public static final PacketHandler INSTANCE = new PacketHandler(); - private static final PacketType[] packetTypes = PacketType.values(); - final FMLEventChannel channel; + public static final PacketHandler INSTANCE = new PacketHandler(); + private static final PacketType[] packetTypes = PacketType.values(); + final FMLEventChannel channel; - private PacketHandler() { - this.channel = NetworkRegistry.INSTANCE.newEventDrivenChannel("GTPP"); - this.channel.register(this); - } + private PacketHandler() { + this.channel = NetworkRegistry.INSTANCE.newEventDrivenChannel("GTPP"); + this.channel.register(this); + } - public static void init() { - } + public static void init() {} - @SubscribeEvent - public void onPacket(ServerCustomPacketEvent event) { - byte[] data = new byte[event.packet.payload().readableBytes()]; - event.packet.payload().readBytes(data); - this.onPacketData(data, ((NetHandlerPlayServer) event.handler).playerEntity); - } + @SubscribeEvent + public void onPacket(ServerCustomPacketEvent event) { + byte[] data = new byte[event.packet.payload().readableBytes()]; + event.packet.payload().readBytes(data); + this.onPacketData(data, ((NetHandlerPlayServer) event.handler).playerEntity); + } - @SubscribeEvent - public void onPacket(ClientCustomPacketEvent event) { - byte[] data = new byte[event.packet.payload().readableBytes()]; - event.packet.payload().readBytes(data); - this.onPacketData(data, (EntityPlayerMP) null); - } + @SubscribeEvent + public void onPacket(ClientCustomPacketEvent event) { + byte[] data = new byte[event.packet.payload().readableBytes()]; + event.packet.payload().readBytes(data); + this.onPacketData(data, (EntityPlayerMP) null); + } - public void onPacketData(byte[] bData, EntityPlayerMP player) { - DataInputStream data = new DataInputStream(new ByteArrayInputStream(bData)); + public void onPacketData(byte[] bData, EntityPlayerMP player) { + DataInputStream data = new DataInputStream(new ByteArrayInputStream(bData)); - try { - byte packetID = data.readByte(); - if (packetID < 0) { - return; - } - PacketType type = packetTypes[packetID]; - Object pkt; - - switch(type.ordinal()) { - case 0: - pkt = new PacketTileEntity(); - break; - default: - return; - } + try { + byte packetID = data.readByte(); + if (packetID < 0) { + return; + } + PacketType type = packetTypes[packetID]; + Object pkt; - if (pkt != null) { - ((CustomPacket)pkt).readData(data); - } - } catch (IOException var7) { - Logger.ERROR("Exception in PacketHandler.onPacketData: {0}"+ var7 + new Object[]{Arrays.toString(bData)}); - } + switch (type.ordinal()) { + case 0: + pkt = new PacketTileEntity(); + break; + default: + return; + } - } -} \ No newline at end of file + if (pkt != null) { + ((CustomPacket) pkt).readData(data); + } + } catch (IOException var7) { + Logger.ERROR("Exception in PacketHandler.onPacketData: {0}" + var7 + new Object[] {Arrays.toString(bData)}); + } + } +} diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/network/PacketTileEntity.java b/src/main/java/gtPlusPlus/core/util/minecraft/network/PacketTileEntity.java index d59bee3c27..265d78a7f4 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/network/PacketTileEntity.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/network/PacketTileEntity.java @@ -5,7 +5,6 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gtPlusPlus.api.interfaces.IGregtechPacketEntity; - import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -15,65 +14,64 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class PacketTileEntity extends CustomPacket { - private IGregTechTileEntity tile; - private IGregtechPacketEntity ptile; + private IGregTechTileEntity tile; + private IGregtechPacketEntity ptile; - public PacketTileEntity() { - } + public PacketTileEntity() {} - public PacketTileEntity(IGregTechTileEntity tile) { - this.tile = tile; - if (tile instanceof IGregtechPacketEntity) { - ptile = (IGregtechPacketEntity) tile; - } - } + public PacketTileEntity(IGregTechTileEntity tile) { + this.tile = tile; + if (tile instanceof IGregtechPacketEntity) { + ptile = (IGregtechPacketEntity) tile; + } + } - public void writeData(DataOutputStream data) throws IOException { - if (ptile != null) { - data.writeInt(this.tile.getXCoord()); - data.writeInt(this.tile.getYCoord()); - data.writeInt(this.tile.getZCoord()); - data.writeShort(this.tile.getMetaTileID()); - this.ptile.writePacketData(data); - } - } + public void writeData(DataOutputStream data) throws IOException { + if (ptile != null) { + data.writeInt(this.tile.getXCoord()); + data.writeInt(this.tile.getYCoord()); + data.writeInt(this.tile.getZCoord()); + data.writeShort(this.tile.getMetaTileID()); + this.ptile.writePacketData(data); + } + } - @SideOnly(Side.CLIENT) - public void readData(DataInputStream data) throws IOException { - Minecraft mc = FMLClientHandler.instance().getClient(); - World world = mc != null ? mc.theWorld : null; - if (world != null) { - int x = data.readInt(); - int y = data.readInt(); - int z = data.readInt(); - short id = data.readShort(); - if (id >= 0 && y >= 0 && world.blockExists(x, y, z)) { - TileEntity te = world.getTileEntity(x, y, z); - if (te instanceof IGregTechTileEntity) { - this.tile = (IGregTechTileEntity) te; - if (this.tile.getMetaTileID() != id) { - this.tile = null; - } - } else { - this.tile = null; - } - if (this.tile != null) { - if (tile instanceof IGregtechPacketEntity) { - ptile = (IGregtechPacketEntity) tile; - try { - this.ptile.readPacketData(data); - } catch (IOException var10) { - throw var10; - } catch (RuntimeException var11) { - Game.logThrowable("Exception in PacketTileEntity.readData:", var11, new Object[0]); - } - } - } - } - } - } + @SideOnly(Side.CLIENT) + public void readData(DataInputStream data) throws IOException { + Minecraft mc = FMLClientHandler.instance().getClient(); + World world = mc != null ? mc.theWorld : null; + if (world != null) { + int x = data.readInt(); + int y = data.readInt(); + int z = data.readInt(); + short id = data.readShort(); + if (id >= 0 && y >= 0 && world.blockExists(x, y, z)) { + TileEntity te = world.getTileEntity(x, y, z); + if (te instanceof IGregTechTileEntity) { + this.tile = (IGregTechTileEntity) te; + if (this.tile.getMetaTileID() != id) { + this.tile = null; + } + } else { + this.tile = null; + } + if (this.tile != null) { + if (tile instanceof IGregtechPacketEntity) { + ptile = (IGregtechPacketEntity) tile; + try { + this.ptile.readPacketData(data); + } catch (IOException var10) { + throw var10; + } catch (RuntimeException var11) { + Game.logThrowable("Exception in PacketTileEntity.readData:", var11, new Object[0]); + } + } + } + } + } + } - public int getID() { - return 0; - } -} \ No newline at end of file + public int getID() { + return 0; + } +} diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/particles/BlockBreakParticles.java b/src/main/java/gtPlusPlus/core/util/minecraft/particles/BlockBreakParticles.java index 9046a57120..f848ea49be 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/particles/BlockBreakParticles.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/particles/BlockBreakParticles.java @@ -1,18 +1,16 @@ package gtPlusPlus.core.util.minecraft.particles; +import gtPlusPlus.xmod.forestry.HANDLER_FR; import net.minecraft.block.Block; import net.minecraft.world.World; -import gtPlusPlus.xmod.forestry.HANDLER_FR; - public class BlockBreakParticles { - public BlockBreakParticles(final World world, final int x, final int y, final int z, final Block block){ - try { - HANDLER_FR.createBlockBreakParticles(world, x, y, z, block); - } catch (final Throwable T){ - - } - } + public BlockBreakParticles(final World world, final int x, final int y, final int z, final Block block) { + try { + HANDLER_FR.createBlockBreakParticles(world, x, y, z, block); + } catch (final Throwable T) { + } + } } diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/particles/EntityParticleFXMysterious.java b/src/main/java/gtPlusPlus/core/util/minecraft/particles/EntityParticleFXMysterious.java index d996cf705a..6c21e8addf 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/particles/EntityParticleFXMysterious.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/particles/EntityParticleFXMysterious.java @@ -3,15 +3,18 @@ package gtPlusPlus.core.util.minecraft.particles; import net.minecraft.client.particle.EntityAuraFX; import net.minecraft.world.World; -public class EntityParticleFXMysterious extends EntityAuraFX -{ - public EntityParticleFXMysterious(final World parWorld, - final double parX, final double parY, final double parZ, - final double parMotionX, final double parMotionY, final double parMotionZ) - { - super(parWorld, parX, parY, parZ, parMotionX, parMotionY, parMotionZ); - this.setParticleTextureIndex(82); // same as happy villager - this.particleScale = 2.0F; - this.setRBGColorF(0x88, 0x00, 0x88); - } +public class EntityParticleFXMysterious extends EntityAuraFX { + public EntityParticleFXMysterious( + final World parWorld, + final double parX, + final double parY, + final double parZ, + final double parMotionX, + final double parMotionY, + final double parMotionZ) { + super(parWorld, parX, parY, parZ, parMotionX, parMotionY, parMotionZ); + this.setParticleTextureIndex(82); // same as happy villager + this.particleScale = 2.0F; + this.setRBGColorF(0x88, 0x00, 0x88); + } } diff --git a/src/main/java/gtPlusPlus/core/util/player/PlayerCache.java b/src/main/java/gtPlusPlus/core/util/player/PlayerCache.java index 753124dcd7..7159345d86 100644 --- a/src/main/java/gtPlusPlus/core/util/player/PlayerCache.java +++ b/src/main/java/gtPlusPlus/core/util/player/PlayerCache.java @@ -1,160 +1,149 @@ package gtPlusPlus.core.util.player; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; import java.io.*; import java.util.*; - import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.server.MinecraftServer; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; - public class PlayerCache { - private static final File cache = new File("PlayerCache.dat"); - - public static final void initCache() { - if (CORE.PlayerCache == null){ - try { - - if (cache != null){ - CORE.PlayerCache = PlayerCache.readPropertiesFileAsMap(); - Logger.INFO("Loaded PlayerCache.dat"); - } - - - } catch (final Exception e) { - Logger.INFO("Failed to initialise PlayerCache.dat"); - PlayerCache.createPropertiesFile("PLAYER_", "DATA"); - //e.printStackTrace(); - } - } - } - - public static void createPropertiesFile(final String playerName, final String playerUUIDasString) { - try { - final Properties props = new Properties(); - props.setProperty(playerName+" ", playerUUIDasString); - final OutputStream out = new FileOutputStream(cache); - props.store(out, "Player Cache."); - Logger.INFO("PlayerCache.dat created for future use."); - out.close(); - } - catch (final Exception e ) { - e.printStackTrace(); - } - } - - public static void appendParamChanges(final String playerName, final String playerUUIDasString) { - final HashMap playerInfo = new HashMap<>(); - playerInfo.put(playerName, UUID.fromString(playerUUIDasString)); - - /*try { - Utils.LOG_INFO("Attempting to load "+cache.getName()); - properties.load(new FileInputStream(cache)); - if (properties == null || properties.equals(null)){ - Utils.LOG_INFO("Please wait."); - } - else { - Utils.LOG_INFO("Loaded PlayerCache.dat"); - properties.setProperty(playerName+"_", playerUUIDasString); - FileOutputStream fr=new FileOutputStream(cache); - properties.store(fr, "Player Cache."); - fr.close(); - } - - } */ - - try - { - final FileOutputStream fos = new FileOutputStream("PlayerCache.dat"); - final ObjectOutputStream oos = new ObjectOutputStream(fos); - oos.writeObject(playerInfo); - oos.close(); - fos.close(); - Logger.INFO("Serialized Player data saved in PlayerCache.dat"); - } - - catch (final IOException e) { - Logger.INFO("No PlayerCache file found, creating one."); - createPropertiesFile(playerName, playerUUIDasString); - } - } - - /** - * Reads a "properties" file, and returns it as a Map - * (a collection of key/value pairs). - * - * Credit due to Alvin Alexander - http://alvinalexander.com/java/java-properties-file-map-example?nocache=1#comment-8215 - * Changed slightly as the filename and delimiter are constant in my case. - * - * @param filename The properties filename to read. - * @param delimiter The string (or character) that separates the key - * from the value in the properties file. - * @return The Map that contains the key/value pairs. - * @throws Exception - */ - @Deprecated - public static Map readPropertiesFileAsMapOld() throws Exception { - final String delimiter = "="; - @SuppressWarnings({ "rawtypes", "unchecked" }) - final - Map map = new HashMap<>(); - final BufferedReader reader = new BufferedReader(new FileReader(cache)); - String line; - while ((line = reader.readLine()) != null) - { - if (line.trim().length()==0) { - continue; - } - if (line.charAt(0)=='#') { - continue; - } - // assumption here is that proper lines are like "String : http://xxx.yyy.zzz/foo/bar", - // and the ":" is the delimiter - final int delimPosition = line.indexOf(delimiter); - final String key = line.substring(0, delimPosition-1).trim(); - final String value = line.substring(delimPosition+1).trim(); - map.put(key, value); - } - reader.close(); - CORE.PlayerCache = map; - return map; - } - - public static HashMap readPropertiesFileAsMap() { - HashMap map = null; - try - { - final FileInputStream fis = new FileInputStream(cache); - final ObjectInputStream ois = new ObjectInputStream(fis); - map = (HashMap) ois.readObject(); - ois.close(); - fis.close(); - }catch(final IOException ioe) - { - ioe.printStackTrace(); - return null; - }catch(final ClassNotFoundException c) - { - Logger.INFO("Class not found"); - c.printStackTrace(); - return null; - } - Logger.WARNING("Deserialized PlayerCache.."); - return map; - } - - public static String lookupPlayerByUUID(final UUID UUID){ - if (UUID == null) { - return null; - } - final List allPlayers = MinecraftServer.getServer().getConfigurationManager().playerEntityList; - for (final EntityPlayerMP player : allPlayers) { - if (player.getUniqueID().equals(UUID)) { - return player.getDisplayName(); - } - } - return "Offline Player."; - } + private static final File cache = new File("PlayerCache.dat"); + + public static final void initCache() { + if (CORE.PlayerCache == null) { + try { + + if (cache != null) { + CORE.PlayerCache = PlayerCache.readPropertiesFileAsMap(); + Logger.INFO("Loaded PlayerCache.dat"); + } + + } catch (final Exception e) { + Logger.INFO("Failed to initialise PlayerCache.dat"); + PlayerCache.createPropertiesFile("PLAYER_", "DATA"); + // e.printStackTrace(); + } + } + } + + public static void createPropertiesFile(final String playerName, final String playerUUIDasString) { + try { + final Properties props = new Properties(); + props.setProperty(playerName + " ", playerUUIDasString); + final OutputStream out = new FileOutputStream(cache); + props.store(out, "Player Cache."); + Logger.INFO("PlayerCache.dat created for future use."); + out.close(); + } catch (final Exception e) { + e.printStackTrace(); + } + } + + public static void appendParamChanges(final String playerName, final String playerUUIDasString) { + final HashMap playerInfo = new HashMap<>(); + playerInfo.put(playerName, UUID.fromString(playerUUIDasString)); + + /*try { + Utils.LOG_INFO("Attempting to load "+cache.getName()); + properties.load(new FileInputStream(cache)); + if (properties == null || properties.equals(null)){ + Utils.LOG_INFO("Please wait."); + } + else { + Utils.LOG_INFO("Loaded PlayerCache.dat"); + properties.setProperty(playerName+"_", playerUUIDasString); + FileOutputStream fr=new FileOutputStream(cache); + properties.store(fr, "Player Cache."); + fr.close(); + } + + } */ + + try { + final FileOutputStream fos = new FileOutputStream("PlayerCache.dat"); + final ObjectOutputStream oos = new ObjectOutputStream(fos); + oos.writeObject(playerInfo); + oos.close(); + fos.close(); + Logger.INFO("Serialized Player data saved in PlayerCache.dat"); + } catch (final IOException e) { + Logger.INFO("No PlayerCache file found, creating one."); + createPropertiesFile(playerName, playerUUIDasString); + } + } + + /** + * Reads a "properties" file, and returns it as a Map + * (a collection of key/value pairs). + * + * Credit due to Alvin Alexander - http://alvinalexander.com/java/java-properties-file-map-example?nocache=1#comment-8215 + * Changed slightly as the filename and delimiter are constant in my case. + * + * @param filename The properties filename to read. + * @param delimiter The string (or character) that separates the key + * from the value in the properties file. + * @return The Map that contains the key/value pairs. + * @throws Exception + */ + @Deprecated + public static Map readPropertiesFileAsMapOld() throws Exception { + final String delimiter = "="; + @SuppressWarnings({"rawtypes", "unchecked"}) + final Map map = new HashMap<>(); + final BufferedReader reader = new BufferedReader(new FileReader(cache)); + String line; + while ((line = reader.readLine()) != null) { + if (line.trim().length() == 0) { + continue; + } + if (line.charAt(0) == '#') { + continue; + } + // assumption here is that proper lines are like "String : http://xxx.yyy.zzz/foo/bar", + // and the ":" is the delimiter + final int delimPosition = line.indexOf(delimiter); + final String key = line.substring(0, delimPosition - 1).trim(); + final String value = line.substring(delimPosition + 1).trim(); + map.put(key, value); + } + reader.close(); + CORE.PlayerCache = map; + return map; + } + + public static HashMap readPropertiesFileAsMap() { + HashMap map = null; + try { + final FileInputStream fis = new FileInputStream(cache); + final ObjectInputStream ois = new ObjectInputStream(fis); + map = (HashMap) ois.readObject(); + ois.close(); + fis.close(); + } catch (final IOException ioe) { + ioe.printStackTrace(); + return null; + } catch (final ClassNotFoundException c) { + Logger.INFO("Class not found"); + c.printStackTrace(); + return null; + } + Logger.WARNING("Deserialized PlayerCache.."); + return map; + } + + public static String lookupPlayerByUUID(final UUID UUID) { + if (UUID == null) { + return null; + } + final List allPlayers = MinecraftServer.getServer().getConfigurationManager().playerEntityList; + for (final EntityPlayerMP player : allPlayers) { + if (player.getUniqueID().equals(UUID)) { + return player.getDisplayName(); + } + } + return "Offline Player."; + } } diff --git a/src/main/java/gtPlusPlus/core/util/reflect/AddGregtechRecipe.java b/src/main/java/gtPlusPlus/core/util/reflect/AddGregtechRecipe.java index fc8e84cb61..10b689f044 100644 --- a/src/main/java/gtPlusPlus/core/util/reflect/AddGregtechRecipe.java +++ b/src/main/java/gtPlusPlus/core/util/reflect/AddGregtechRecipe.java @@ -1,8 +1,5 @@ package gtPlusPlus.core.util.reflect; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - import gregtech.api.enums.GT_Values; import gregtech.api.interfaces.internal.IGT_RecipeAdder; import gregtech.api.util.GT_Recipe; @@ -10,282 +7,271 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; public final class AddGregtechRecipe { - - + public static boolean importPyroRecipe(GT_Recipe aRecipe) { - + int aModifiedTime = (int) (aRecipe.mDuration * 0.8); - - if (aRecipe.mInputs == null || aRecipe.mFluidInputs == null || aRecipe.mFluidOutputs == null || aRecipe.mOutputs == null) { - return false; - } - if (aRecipe.mInputs.length > 2 || aRecipe.mFluidInputs.length > 1 || aRecipe.mFluidOutputs.length > 1 || aRecipe.mOutputs.length > 9) { + + if (aRecipe.mInputs == null + || aRecipe.mFluidInputs == null + || aRecipe.mFluidOutputs == null + || aRecipe.mOutputs == null) { return false; } - else if (aRecipe.mInputs.length <= 0) { + if (aRecipe.mInputs.length > 2 + || aRecipe.mFluidInputs.length > 1 + || aRecipe.mFluidOutputs.length > 1 + || aRecipe.mOutputs.length > 9) { + return false; + } else if (aRecipe.mInputs.length <= 0) { return false; } - + int aCircuitNumber = -1; Item aCircuit = CI.getNumberedCircuit(1).getItem(); boolean hasCircuit = false; - + for (ItemStack a : aRecipe.mInputs) { if (a != null && a.getItem() == aCircuit) { - hasCircuit = true; - aCircuitNumber = a.getItemDamage(); - break; + hasCircuit = true; + aCircuitNumber = a.getItemDamage(); + break; } } - + ItemStack aInputItem = null; if (!hasCircuit || aCircuitNumber < 1) { - return false; + return false; } - + for (ItemStack a : aRecipe.mInputs) { if (a != null && a.getItem() != aCircuit) { - aInputItem = a; - break; + aInputItem = a; + break; } } - + return CORE.RA.addCokeOvenRecipe( - aCircuitNumber, - aInputItem, - aRecipe.mFluidInputs, - aRecipe.mFluidOutputs, - aRecipe.mOutputs, - aModifiedTime, - aRecipe.mEUt); - + aCircuitNumber, + aInputItem, + aRecipe.mFluidInputs, + aRecipe.mFluidOutputs, + aRecipe.mOutputs, + aModifiedTime, + aRecipe.mEUt); } - - - public static boolean addCokeAndPyrolyseRecipes( - ItemStack input1, int circuitNumber, - FluidStack inputFluid1, - ItemStack output1, - FluidStack outputFluid1, - int timeInSeconds, - int euTick - ){ - //Seconds Conversion - int TIME = timeInSeconds*20; - int TIMEPYRO = TIME+(TIME/5); - CORE.RA.addCokeOvenRecipe( - input1, - ItemUtils.getGregtechCircuit(circuitNumber), - inputFluid1, - outputFluid1, - output1, - TIME, - euTick); - PyrolyseOven( - input1, - inputFluid1, - circuitNumber, - output1, - outputFluid1, - TIMEPYRO, - euTick); - - - return false; - } - - + public static boolean addCokeAndPyrolyseRecipes( + ItemStack input1, + int circuitNumber, + FluidStack inputFluid1, + ItemStack output1, + FluidStack outputFluid1, + int timeInSeconds, + int euTick) { + // Seconds Conversion + int TIME = timeInSeconds * 20; + int TIMEPYRO = TIME + (TIME / 5); + CORE.RA.addCokeOvenRecipe( + input1, ItemUtils.getGregtechCircuit(circuitNumber), inputFluid1, outputFluid1, output1, TIME, euTick); + PyrolyseOven(input1, inputFluid1, circuitNumber, output1, outputFluid1, TIMEPYRO, euTick); - public static boolean PyrolyseOven(final ItemStack p0, final FluidStack p1, final int p2, final ItemStack p3, - final FluidStack p4, final int p5, final int p6){ - - try { - IGT_RecipeAdder IGT_RecipeAdder = GT_Values.RA; - if (IGT_RecipeAdder != null){ - Class classRA = IGT_RecipeAdder.getClass(); - Method addRecipe = classRA.getMethod("addPyrolyseRecipe", ItemStack.class, FluidStack.class, int.class, ItemStack.class, FluidStack.class, int.class, int.class); - if (addRecipe != null){ - return (boolean) addRecipe.invoke(IGT_RecipeAdder, p0, p1, p2, p3, p4, p5, p6); - } - } - } - catch (SecurityException | NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - return false; - } - return false; - } - - - - public static boolean addAssemblylineRecipe( - ItemStack aResearchItem, - int aResearchTime, - ItemStack[] aInputs, - FluidStack[] aFluidInputs, - ItemStack aOutput, - int aDuration, int aEUt){ - /* - try { - IGT_RecipeAdder IGT_RecipeAdder = GT_Values.RA; - if (IGT_RecipeAdder != null){ - Class classRA = IGT_RecipeAdder.getClass(); - - for(Method current : classRA.getDeclaredMethods()){ - //Utils.LOG_INFO("-----------------------------------------------"); - ////Utils.LOG_INFO("Found method: "+current.getName()); - //Utils.LOG_INFO("With Parameters: "); - //Utils.LOG_INFO("==============================================="); - for (Class P : current.getParameterTypes()){ - //Utils.LOG_INFO(""+P.getName()); - //Utils.LOG_INFO(""+P.getClass().getName()); - } - //Utils.LOG_INFO("==============================================="); - } - - try { - Method testRA = GT_Values.RA.getClass().getMethod("addAssemblylineRecipe", GT_Values.RA.getClass(), aResearchItem.getClass(), int.class, aInputs.getClass(), aFluidInputs.getClass(), aOutput.getClass(), int.class, int.class); - testRA.invoke(aResearchItem, aResearchTime, aInputs, aFluidInputs, aOutput, aDuration, aEUt); - } - catch (Throwable masndj){ - masndj.printStackTrace(); - } - + return false; + } - Method addRecipe = classRA.getDeclaredMethod( - "addAssemblylineRecipe", - ItemStack.class, - int.class, - ItemStack.class, - FluidStack.class, - ItemStack.class, - int.class, - int.class); - if (addRecipe != null){ - return (boolean) addRecipe.invoke(aResearchItem, aResearchTime, aInputs, aFluidInputs, aOutput, aDuration, aEUt); - } - } - } - catch (SecurityException | NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - Utils.LOG_INFO("[Assembly Line] - Failed to add recipe, due to GT not being .09 branch. Research: "+aResearchItem.getDisplayName()+" | Result: "+aOutput.getDisplayName()); - e.printStackTrace(); - return false; - } - Utils.LOG_INFO("[Assembly Line] - Failed to add recipe. Research: "+aResearchItem.getDisplayName()+" | Result: "+aOutput.getDisplayName()); - */return false; - } + public static boolean PyrolyseOven( + final ItemStack p0, + final FluidStack p1, + final int p2, + final ItemStack p3, + final FluidStack p4, + final int p5, + final int p6) { - public static boolean addCircuitAssemblerRecipe( - ItemStack[] aInputs, - FluidStack aFluidInput, - ItemStack aOutput, - int aDuration, - int aEUt) { - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ - try { - IGT_RecipeAdder IGT_RecipeAdder = GT_Values.RA; - if (IGT_RecipeAdder != null){ - Class classRA = IGT_RecipeAdder.getClass(); - Method addRecipe = classRA.getMethod( - "addCircuitAssemblerRecipe", - ItemStack.class, - FluidStack.class, - ItemStack.class, - int.class, - int.class); - if (addRecipe != null){ - if (aFluidInput.isFluidEqual(FluidUtils.getFluidStack("molten.tin", 1))){ - boolean[] didAdd = new boolean[3]; - FluidStack moltenMetal = FluidUtils.getFluidStack("molten.tin", 144); - //Tin - didAdd[0] = (boolean) addRecipe.invoke( - IGT_RecipeAdder, - aInputs, - moltenMetal, - aOutput, - aDuration, - aEUt); - moltenMetal = FluidUtils.getFluidStack("molten.lead", 144); - //Lead - didAdd[1] = (boolean) addRecipe.invoke( - IGT_RecipeAdder, - aInputs, - moltenMetal, - aOutput, - aDuration, - aEUt); - moltenMetal = FluidUtils.getFluidStack("molten.solderingalloy", 144/2); - //Soldering Alloy - didAdd[2] = (boolean) addRecipe.invoke( - IGT_RecipeAdder, - aInputs, - moltenMetal, - aOutput, - aDuration, - aEUt); + try { + IGT_RecipeAdder IGT_RecipeAdder = GT_Values.RA; + if (IGT_RecipeAdder != null) { + Class classRA = IGT_RecipeAdder.getClass(); + Method addRecipe = classRA.getMethod( + "addPyrolyseRecipe", + ItemStack.class, + FluidStack.class, + int.class, + ItemStack.class, + FluidStack.class, + int.class, + int.class); + if (addRecipe != null) { + return (boolean) addRecipe.invoke(IGT_RecipeAdder, p0, p1, p2, p3, p4, p5, p6); + } + } + } catch (SecurityException + | NoSuchMethodException + | IllegalAccessException + | IllegalArgumentException + | InvocationTargetException e) { + return false; + } + return false; + } - if (didAdd[0] && didAdd[1] && didAdd[2]){ - return true; - } - else { - return false; - } - } - else { - return (boolean) addRecipe.invoke( - IGT_RecipeAdder, - aInputs, - aFluidInput, - aOutput, - aDuration, - aEUt); - } - } - } - } - catch (SecurityException | NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - return false; - } - } - return false; - } + public static boolean addAssemblylineRecipe( + ItemStack aResearchItem, + int aResearchTime, + ItemStack[] aInputs, + FluidStack[] aFluidInputs, + ItemStack aOutput, + int aDuration, + int aEUt) { + /* + try { + IGT_RecipeAdder IGT_RecipeAdder = GT_Values.RA; + if (IGT_RecipeAdder != null){ + Class classRA = IGT_RecipeAdder.getClass(); + for(Method current : classRA.getDeclaredMethods()){ + //Utils.LOG_INFO("-----------------------------------------------"); + ////Utils.LOG_INFO("Found method: "+current.getName()); + //Utils.LOG_INFO("With Parameters: "); + //Utils.LOG_INFO("==============================================="); + for (Class P : current.getParameterTypes()){ + //Utils.LOG_INFO(""+P.getName()); + //Utils.LOG_INFO(""+P.getClass().getName()); + } + //Utils.LOG_INFO("==============================================="); + } - public static boolean addChemicalRecipeForBasicMachineOnly(final ItemStack p0, final ItemStack p1, final FluidStack p2, final FluidStack p3, final ItemStack p4, final ItemStack p5, final int p6, final int p7){ + try { + Method testRA = GT_Values.RA.getClass().getMethod("addAssemblylineRecipe", GT_Values.RA.getClass(), aResearchItem.getClass(), int.class, aInputs.getClass(), aFluidInputs.getClass(), aOutput.getClass(), int.class, int.class); + testRA.invoke(aResearchItem, aResearchTime, aInputs, aFluidInputs, aOutput, aDuration, aEUt); + } + catch (Throwable masndj){ + masndj.printStackTrace(); + } - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - try { - IGT_RecipeAdder IGT_RecipeAdder = GT_Values.RA; - if (IGT_RecipeAdder != null){ - Class classRA = IGT_RecipeAdder.getClass(); - //final ItemStack p0, final ItemStack p1, final FluidStack p2, final FluidStack p3, final ItemStack p4, final ItemStack p5, final int p6, final int p7 - Method addRecipe = classRA.getMethod("addChemicalRecipeForBasicMachineOnly", ItemStack.class, ItemStack.class, FluidStack.class, FluidStack.class, ItemStack.class, ItemStack.class, int.class, int.class); - if (addRecipe != null){ - return (boolean) addRecipe.invoke(IGT_RecipeAdder, p0, p1, p2, p3, p4, p5, p6, p7); - } - } - } - catch (SecurityException | NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - } - } + Method addRecipe = classRA.getDeclaredMethod( + "addAssemblylineRecipe", + ItemStack.class, + int.class, + ItemStack.class, + FluidStack.class, + ItemStack.class, + int.class, + int.class); + if (addRecipe != null){ + return (boolean) addRecipe.invoke(aResearchItem, aResearchTime, aInputs, aFluidInputs, aOutput, aDuration, aEUt); + } + } + } + catch (SecurityException | NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + Utils.LOG_INFO("[Assembly Line] - Failed to add recipe, due to GT not being .09 branch. Research: "+aResearchItem.getDisplayName()+" | Result: "+aOutput.getDisplayName()); + e.printStackTrace(); + return false; + } + Utils.LOG_INFO("[Assembly Line] - Failed to add recipe. Research: "+aResearchItem.getDisplayName()+" | Result: "+aOutput.getDisplayName()); + */ return false; + } - return GT_Values.RA.addChemicalRecipe( - p0, - p1, - p2, - p3, - p4, - p6); + public static boolean addCircuitAssemblerRecipe( + ItemStack[] aInputs, FluidStack aFluidInput, ItemStack aOutput, int aDuration, int aEUt) { + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + try { + IGT_RecipeAdder IGT_RecipeAdder = GT_Values.RA; + if (IGT_RecipeAdder != null) { + Class classRA = IGT_RecipeAdder.getClass(); + Method addRecipe = classRA.getMethod( + "addCircuitAssemblerRecipe", + ItemStack.class, + FluidStack.class, + ItemStack.class, + int.class, + int.class); + if (addRecipe != null) { + if (aFluidInput.isFluidEqual(FluidUtils.getFluidStack("molten.tin", 1))) { + boolean[] didAdd = new boolean[3]; + FluidStack moltenMetal = FluidUtils.getFluidStack("molten.tin", 144); + // Tin + didAdd[0] = (boolean) + addRecipe.invoke(IGT_RecipeAdder, aInputs, moltenMetal, aOutput, aDuration, aEUt); + moltenMetal = FluidUtils.getFluidStack("molten.lead", 144); + // Lead + didAdd[1] = (boolean) + addRecipe.invoke(IGT_RecipeAdder, aInputs, moltenMetal, aOutput, aDuration, aEUt); + moltenMetal = FluidUtils.getFluidStack("molten.solderingalloy", 144 / 2); + // Soldering Alloy + didAdd[2] = (boolean) + addRecipe.invoke(IGT_RecipeAdder, aInputs, moltenMetal, aOutput, aDuration, aEUt); - } + if (didAdd[0] && didAdd[1] && didAdd[2]) { + return true; + } else { + return false; + } + } else { + return (boolean) + addRecipe.invoke(IGT_RecipeAdder, aInputs, aFluidInput, aOutput, aDuration, aEUt); + } + } + } + } catch (SecurityException + | NoSuchMethodException + | IllegalAccessException + | IllegalArgumentException + | InvocationTargetException e) { + return false; + } + } + return false; + } + public static boolean addChemicalRecipeForBasicMachineOnly( + final ItemStack p0, + final ItemStack p1, + final FluidStack p2, + final FluidStack p3, + final ItemStack p4, + final ItemStack p5, + final int p6, + final int p7) { + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + try { + IGT_RecipeAdder IGT_RecipeAdder = GT_Values.RA; + if (IGT_RecipeAdder != null) { + Class classRA = IGT_RecipeAdder.getClass(); + // final ItemStack p0, final ItemStack p1, final FluidStack p2, final FluidStack p3, final ItemStack + // p4, final ItemStack p5, final int p6, final int p7 + Method addRecipe = classRA.getMethod( + "addChemicalRecipeForBasicMachineOnly", + ItemStack.class, + ItemStack.class, + FluidStack.class, + FluidStack.class, + ItemStack.class, + ItemStack.class, + int.class, + int.class); + if (addRecipe != null) { + return (boolean) addRecipe.invoke(IGT_RecipeAdder, p0, p1, p2, p3, p4, p5, p6, p7); + } + } + } catch (SecurityException + | NoSuchMethodException + | IllegalAccessException + | IllegalArgumentException + | InvocationTargetException e) { + } + } -} \ No newline at end of file + return GT_Values.RA.addChemicalRecipe(p0, p1, p2, p3, p4, p6); + } +} diff --git a/src/main/java/gtPlusPlus/core/util/reflect/ProxyFinder.java b/src/main/java/gtPlusPlus/core/util/reflect/ProxyFinder.java index aaa9b2fae7..6c3be2e6df 100644 --- a/src/main/java/gtPlusPlus/core/util/reflect/ProxyFinder.java +++ b/src/main/java/gtPlusPlus/core/util/reflect/ProxyFinder.java @@ -1,55 +1,53 @@ package gtPlusPlus.core.util.reflect; -import java.lang.reflect.Field; - import cpw.mods.fml.common.SidedProxy; +import java.lang.reflect.Field; public class ProxyFinder { - public static Object getServerProxy(final Object modInstance) throws ReflectiveOperationException { - for(final Field field : modInstance.getClass().getDeclaredFields()) { - if(field.isAnnotationPresent(SidedProxy.class)) { - final SidedProxy sidedProxy = field.getAnnotation(SidedProxy.class); - final Object fieldValue = field.get(modInstance); - try { - final Class serverSideClass = ReflectionUtils.getClass(sidedProxy.serverSide()); - if(serverSideClass.isAssignableFrom(fieldValue.getClass())) { - final Object serverProxy = serverSideClass.cast(fieldValue); - //do what you want with server proxy instance - return serverProxy; - } + public static Object getServerProxy(final Object modInstance) throws ReflectiveOperationException { + for (final Field field : modInstance.getClass().getDeclaredFields()) { + if (field.isAnnotationPresent(SidedProxy.class)) { + final SidedProxy sidedProxy = field.getAnnotation(SidedProxy.class); + final Object fieldValue = field.get(modInstance); + try { + final Class serverSideClass = ReflectionUtils.getClass(sidedProxy.serverSide()); + if (serverSideClass.isAssignableFrom(fieldValue.getClass())) { + final Object serverProxy = serverSideClass.cast(fieldValue); + // do what you want with server proxy instance + return serverProxy; + } - } catch (final NoClassDefFoundError err) { - //its client side - return null; - } - break; - } - } - return null; - } - - public static Object getClientProxy(final Object modInstance) throws ReflectiveOperationException { - for(final Field field : modInstance.getClass().getDeclaredFields()) { - if(field.isAnnotationPresent(SidedProxy.class)) { - final SidedProxy sidedProxy = field.getAnnotation(SidedProxy.class); - final Object fieldValue = field.get(modInstance); - try { - final Class clientSideClass = ReflectionUtils.getClass(sidedProxy.clientSide()); - if(clientSideClass.isAssignableFrom(fieldValue.getClass())) { - final Object clientProxy = clientSideClass.cast(fieldValue); - //do what you want with client proxy instance - return clientProxy; - } + } catch (final NoClassDefFoundError err) { + // its client side + return null; + } + break; + } + } + return null; + } - } catch (final NoClassDefFoundError err) { - //its server side - return null; - } - break; - } - } - return null; - } + public static Object getClientProxy(final Object modInstance) throws ReflectiveOperationException { + for (final Field field : modInstance.getClass().getDeclaredFields()) { + if (field.isAnnotationPresent(SidedProxy.class)) { + final SidedProxy sidedProxy = field.getAnnotation(SidedProxy.class); + final Object fieldValue = field.get(modInstance); + try { + final Class clientSideClass = ReflectionUtils.getClass(sidedProxy.clientSide()); + if (clientSideClass.isAssignableFrom(fieldValue.getClass())) { + final Object clientProxy = clientSideClass.cast(fieldValue); + // do what you want with client proxy instance + return clientProxy; + } -} \ No newline at end of file + } catch (final NoClassDefFoundError err) { + // its server side + return null; + } + break; + } + } + return null; + } +} diff --git a/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index 112c4f1f02..c493ce1aa9 100644 --- a/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -1,5 +1,8 @@ package gtPlusPlus.core.util.reflect; +import com.google.common.reflect.ClassPath; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.data.StringUtils; import java.io.IOException; import java.lang.reflect.Constructor; import java.lang.reflect.Field; @@ -15,1115 +18,1070 @@ import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; - import org.apache.commons.lang3.ArrayUtils; -import com.google.common.reflect.ClassPath; - -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.util.data.StringUtils; - public class ReflectionUtils { - public static Map> mCachedClasses = new LinkedHashMap>(); - public static Map mCachedMethods = new LinkedHashMap(); - public static Map mCachedFields = new LinkedHashMap(); - public static Map mCachedConstructors = new LinkedHashMap(); - - private static class CachedConstructor { - - private final Constructor METHOD; - - public CachedConstructor(Constructor aCons) { - METHOD = aCons; - } - - public Constructor get() { - return METHOD; - } - - } - - private static class CachedMethod { - - private final boolean STATIC; - private final Method METHOD; - - public CachedMethod(Method aMethod, boolean isStatic) { - METHOD = aMethod; - STATIC = isStatic; - } - - public Method get() { - return METHOD; - } - - public boolean type() { - return STATIC; - } - - } - - private static class CachedField { - - private final boolean STATIC; - private final Field FIELD; - - public CachedField(Field aField, boolean isStatic) { - FIELD = aField; - STATIC = isStatic; - } - - public Field get() { - return FIELD; - } - - public boolean type() { - return STATIC; - } - - } - - private static boolean cacheClass(Class aClass) { - if (aClass == null) { - return false; - } - Class y = mCachedClasses.get(aClass.getCanonicalName()); - if (y == null) { - mCachedClasses.put(aClass.getCanonicalName(), aClass); - return true; - } - return false; - } - - private static boolean cacheMethod(Class aClass, Method aMethod) { - if (aMethod == null) { - return false; - } - boolean isStatic = Modifier.isStatic(aMethod.getModifiers()); - CachedMethod y = mCachedMethods.get(aClass.getName()+"."+aMethod.getName()+"."+ArrayUtils.toString(aMethod.getParameterTypes())); - if (y == null) { - mCachedMethods.put(aClass.getName()+"."+aMethod.getName()+"."+ArrayUtils.toString(aMethod.getParameterTypes()), new CachedMethod(aMethod, isStatic)); - return true; - } - return false; - } - - private static boolean cacheField(Class aClass, Field aField) { - if (aField == null) { - return false; - } - boolean isStatic = Modifier.isStatic(aField.getModifiers()); - CachedField y = mCachedFields.get(aClass.getName()+"."+aField.getName()); - if (y == null) { - mCachedFields.put(aClass.getName()+"."+aField.getName(), new CachedField(aField, isStatic)); - return true; - } - return false; - } - - private static boolean cacheConstructor(Class aClass, Constructor aConstructor) { - if (aConstructor == null) { - return false; - } - CachedConstructor y = mCachedConstructors.get(aClass.getName()+"."+ArrayUtils.toString(aConstructor.getParameterTypes())); - if (y == null) { - mCachedConstructors.put(aClass.getName()+"."+ArrayUtils.toString(aConstructor.getParameterTypes()), new CachedConstructor(aConstructor)); - return true; - } - return false; - } - - - /** - * Returns a cached {@link Constructor} object. - * @param aClass - Class containing the Constructor. - * @param aTypes - Varags Class Types for objects constructor. - * @return - Valid, non-final, {@link Method} object, or {@link null}. - */ - public static Constructor getConstructor(Class aClass, Class... aTypes) { - if (aClass == null || aTypes == null) { - return null; - } - - String aMethodKey = ArrayUtils.toString(aTypes); - //Logger.REFLECTION("Looking up method in cache: "+(aClass.getName()+"."+aMethodName + "." + aMethodKey)); - CachedConstructor y = mCachedConstructors.get(aClass.getName() + "." + aMethodKey); - if (y == null) { - Constructor u = getConstructor_Internal(aClass, aTypes); - if (u != null) { - Logger.REFLECTION("Caching Constructor: "+aClass.getName() + "." + aMethodKey); - cacheConstructor(aClass, u); - return u; - } else { - return null; - } - } else { - return y.get(); - } - } - - - - - /** - * Returns a cached {@link Class} object. - * @param aClassCanonicalName - The canonical name of the underlying class. - * @return - Valid, {@link Class} object, or {@link null}. - */ - public static Class getClass(String aClassCanonicalName) { - if (aClassCanonicalName == null || aClassCanonicalName.length() <= 0) { - return null; - } - Class y = mCachedClasses.get(aClassCanonicalName); - if (y == null) { - y = getClass_Internal(aClassCanonicalName); - if (y != null) { - Logger.REFLECTION("Caching Class: "+aClassCanonicalName); - cacheClass(y); - } - } - return y; - } - - - - /** - * Returns a cached {@link Method} object. Wraps {@link #getMethod(Class, String, Class...)}. - * @param aObject - Object containing the Method. - * @param aMethodName - Method's name in {@link String} form. - * @param aTypes - Class Array of Types for {@link Method}'s constructor. - * @return - Valid, non-final, {@link Method} object, or {@link null}. - */ - public static Method getMethod(Object aObject, String aMethodName, Class[] aTypes) { - return getMethod(aObject.getClass(), aMethodName, aTypes); - } - - - /** - * Returns a cached {@link Method} object. - * @param aClass - Class containing the Method. - * @param aMethodName - Method's name in {@link String} form. - * @param aTypes - Varags Class Types for {@link Method}'s constructor. - * @return - Valid, non-final, {@link Method} object, or {@link null}. - */ - public static Method getMethod(Class aClass, String aMethodName, Class... aTypes) { - if (aClass == null || aMethodName == null || aMethodName.length() <= 0) { - return null; - } - String aMethodKey = ArrayUtils.toString(aTypes); - //Logger.REFLECTION("Looking up method in cache: "+(aClass.getName()+"."+aMethodName + "." + aMethodKey)); - CachedMethod y = mCachedMethods.get(aClass.getName()+"."+aMethodName + "." + aMethodKey); - if (y == null) { - Method u = getMethod_Internal(aClass, aMethodName, aTypes); - if (u != null) { - Logger.REFLECTION("Caching Method: "+aMethodName + "." + aMethodKey); - cacheMethod(aClass, u); - return u; - } else { - return null; - } - } else { - return y.get(); - } - } - - public static boolean isStaticMethod(Class aClass, String aMethodName, Class... aTypes) { - return isStaticMethod(ReflectionUtils.getMethod(aClass, aMethodName, aTypes)); - } - - public static boolean isStaticMethod(Method aMethod) { - if (aMethod != null && Modifier.isStatic(aMethod.getModifiers())) { - return true; - } - return false; - } - - - - /** - * Returns a cached {@link Field} object. - * @param aClass - Class containing the Method. - * @param aFieldName - Field name in {@link String} form. - * @return - Valid, non-final, {@link Field} object, or {@link null}. - */ - public static Field getField(final Class aClass, final String aFieldName) { - if (aClass == null || aFieldName == null || aFieldName.length() <= 0) { - return null; - } - CachedField y = mCachedFields.get(aClass.getName()+"."+aFieldName); - if (y == null) { - Field u; - try { - u = getField_Internal(aClass, aFieldName); - if (u != null) { - Logger.REFLECTION("Caching Field '"+aFieldName+"' from "+aClass.getName()); - cacheField(aClass, u); - return u; - } - } catch (NoSuchFieldException e) { - } - return null; - - } else { - return y.get(); - } - } - - public static Field[] getAllFields(final Class aClass) { - if (aClass == null) { - return null; - } - Field[] aFields = aClass.getDeclaredFields(); - for (Field f : aFields) { - CachedField y = mCachedFields.get(aClass.getName()+"."+f.getName()); - if (y == null) { - makeFieldAccessible(f); - cacheField(aClass, f); - } - } - return aFields; - } - - /** - * Returns a cached {@link Field} object. - * @param aInstance - {@link Object} to get the field instance from. - * @param aFieldName - Field name in {@link String} form. - * @return - Valid, non-final, {@link Field} object, or {@link null}. - */ - public static T getField(final Object aInstance, final String aFieldName) { - try { - return (T) getField(aInstance.getClass(), aFieldName).get(aInstance); - } catch (IllegalArgumentException | IllegalAccessException e) { - return null; - } - } - - - - - /* - * Utility Functions - */ - - public static boolean doesClassExist(final String classname) { - return isClassPresent(classname); - } - - - /** - * Returns the class of the objects type parameter - * @param o - Object to examine paramters on - * @return - a Class or null - */ - public static Class getTypeOfGenericObject(Object o) { - Class aTypeParam = findSuperClassParameterType(o, o.getClass(), 0); - if (aTypeParam == null) { - aTypeParam = findSubClassParameterType(o, o.getClass(), 0); - } - return aTypeParam; - } - - public static void makeFieldAccessible(final Field field) { - if (!Modifier.isPublic(field.getModifiers()) || - !Modifier.isPublic(field.getDeclaringClass().getModifiers())) - { - field.setAccessible(true); - } - } - - public static void makeMethodAccessible(final Method field) { - if (!Modifier.isPublic(field.getModifiers()) || - !Modifier.isPublic(field.getDeclaringClass().getModifiers())) - { - field.setAccessible(true); - } - } - - /** - * Get the method name for a depth in call stack.
- * Utility function - * @param depth depth in the call stack (0 means current method, 1 means call method, ...) - * @return Method name - */ - public static String getMethodName(final int depth) { - final StackTraceElement[] ste = new Throwable().getStackTrace(); - //System. out.println(ste[ste.length-depth].getClassName()+"#"+ste[ste.length-depth].getMethodName()); - if (ste.length < depth) { - return "No valid stack."; - } - return ste[depth+1].getMethodName(); - } - - - /** - * - * @param aPackageName - The full {@link Package} name in {@link String} form. - * @return - {@link Boolean} object. True if loaded > 0 classes. - */ - public static boolean dynamicallyLoadClassesInPackage(String aPackageName) { - ClassLoader classLoader = ReflectionUtils.class.getClassLoader(); - int loaded = 0; - try { - ClassPath path = ClassPath.from(classLoader); - for (ClassPath.ClassInfo info : path.getTopLevelClassesRecursive(aPackageName)) { - Class clazz = Class.forName(info.getName(), true, classLoader); - if (clazz != null) { - loaded++; - Logger.INFO("Found "+clazz.getCanonicalName()+". ["+loaded+"]"); - } - } - } catch (ClassNotFoundException | IOException e) { - - } - - return loaded > 0; - } - - public static void loadClass(String aClassName) { - try { - Class.forName(aClassName, true, ReflectionUtils.class.getClassLoader()); - } - catch (ClassNotFoundException e) { - e.printStackTrace(); - } - } - - - - public static boolean setField(final Object object, final String fieldName, final Object fieldValue) { - Class clazz; - if (object instanceof Class) { - clazz = (Class) object; - } - else { - clazz = object.getClass(); - } - while (clazz != null) { - try { - final Field field = getField(clazz, fieldName); - if (field != null) { - setFieldValue_Internal(object, field, fieldValue); - return true; - } - } catch (final NoSuchFieldException e) { - Logger.REFLECTION("setField("+object.toString()+", "+fieldName+") failed."); - clazz = clazz.getSuperclass(); - } catch (final Exception e) { - Logger.REFLECTION("setField("+object.toString()+", "+fieldName+") failed."); - throw new IllegalStateException(e); - } - } - return false; - - - } - - public static boolean setField(final Object object, final Field field, final Object fieldValue) { - if (field == null) return false; - Class clazz; - if (object instanceof Class) { - clazz = (Class) object; - } - else { - clazz = object.getClass(); - } - while (clazz != null) { - try { - final Field field2 = getField(clazz, field.getName()); - if (field2 != null) { - setFieldValue_Internal(object, field, fieldValue); - return true; - } - } catch (final NoSuchFieldException e) { - Logger.REFLECTION("setField("+object.toString()+", "+field.getName()+") failed."); - clazz = clazz.getSuperclass(); - } catch (final Exception e) { - Logger.REFLECTION("setField("+object.toString()+", "+field.getName()+") failed."); - throw new IllegalStateException(e); - } - } - return false; - } - - - /** - * Allows to change the state of an immutable instance. Huh?!? - */ - public static void setFinalFieldValue(Class clazz, String fieldName, Object newValue) { - Field nameField = getField(clazz, fieldName); - try { - setFieldValue_Internal(clazz, nameField, newValue); - } - catch (Throwable t) { - t.printStackTrace(); - } - } - - /** - * Allows to change the state of an immutable instance. Huh?!? - */ - public static void setFinalFieldValue(Class clazz, Field field, Object newValue) { - try { - setFieldValue_Internal(clazz, field, newValue); - } - catch (Throwable t) { - t.printStackTrace(); - } - } - - @Deprecated - public static void setFinalStatic(Field field, Object newValue) throws Exception { - field.setAccessible(true); - Field modifiersField = Field.class.getDeclaredField("modifiers"); - modifiersField.setAccessible(true); - modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); - field.set(null, newValue); - } - - - public static void setByte(Object clazz, String fieldName, byte newValue) throws Exception { - Field nameField = getField(clazz.getClass(), fieldName); - nameField.setAccessible(true); - int modifiers = nameField.getModifiers(); - Field modifierField = nameField.getClass().getDeclaredField("modifiers"); - modifiers = modifiers & ~Modifier.FINAL; - modifierField.setAccessible(true); - modifierField.setInt(nameField, modifiers); - //Utils.LOG_INFO("O-"+(byte) nameField.get(clazz) + " | "+newValue); - nameField.setByte(clazz, newValue); - //Utils.LOG_INFO("N-"+(byte) nameField.get(clazz)); - - /*final Field fieldA = getField(clazz.getClass(), fieldName); - fieldA.setAccessible(true); - fieldA.setByte(clazz, newValue);*/ - - } - - public static boolean invoke(Object objectInstance, String methodName, Class[] parameters, Object[] values){ - if (objectInstance == null || methodName == null || parameters == null || values == null){ - return false; - } - Class mLocalClass = (objectInstance instanceof Class ? (Class) objectInstance : objectInstance.getClass()); - Logger.REFLECTION("Trying to invoke "+methodName+" on an instance of "+mLocalClass.getCanonicalName()+"."); - try { - Method mInvokingMethod = mLocalClass.getDeclaredMethod(methodName, parameters); - if (mInvokingMethod != null){ - return invoke(objectInstance, mInvokingMethod, values); - } - } - catch (NoSuchMethodException | SecurityException | IllegalArgumentException e) { - Logger.REFLECTION("Failed to Dynamically invoke "+methodName+" on an object of type: "+mLocalClass.getName()); - } - - Logger.REFLECTION("Invoke failed or did something wrong."); - return false; - } - - public static boolean invoke(Object objectInstance, Method method, Object[] values){ - if (method == null || values == null || (!ReflectionUtils.isStaticMethod(method) && objectInstance == null)){ - //Logger.REFLECTION("Null value when trying to Dynamically invoke "+methodName+" on an object of type: "+objectInstance.getClass().getName()); - return false; - } - String methodName = method.getName(); - String classname = objectInstance != null ? objectInstance.getClass().getCanonicalName() : method.getDeclaringClass().getCanonicalName(); - Logger.REFLECTION("Trying to invoke "+methodName+" on an instance of "+classname+"."); - try { - Method mInvokingMethod = method; - if (mInvokingMethod != null){ - Logger.REFLECTION(methodName+" was not null."); - if ((boolean) mInvokingMethod.invoke(objectInstance, values)){ - Logger.REFLECTION("Successfully invoked "+methodName+"."); - return true; - } - else { - Logger.REFLECTION("Invocation failed for "+methodName+"."); - } - } - } - catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - Logger.REFLECTION("Failed to Dynamically invoke "+methodName+" on an object of type: "+classname); - } - Logger.REFLECTION("Invoke failed or did something wrong."); - return false; - } - - public static boolean invokeVoid(Object objectInstance, Method method, Object[] values){ - if (method == null || values == null || (!ReflectionUtils.isStaticMethod(method) && objectInstance == null)){ - //Logger.REFLECTION("Null value when trying to Dynamically invoke "+methodName+" on an object of type: "+objectInstance.getClass().getName()); - return false; - } - String methodName = method.getName(); - String classname = objectInstance != null ? objectInstance.getClass().getCanonicalName() : method.getDeclaringClass().getCanonicalName(); - Logger.REFLECTION("Trying to invoke "+methodName+" on an instance of "+classname+"."); - try { - Method mInvokingMethod = method; - if (mInvokingMethod != null){ - Logger.REFLECTION(methodName+" was not null."); - mInvokingMethod.invoke(objectInstance, values); - Logger.REFLECTION("Successfully invoked "+methodName+"."); - return true; - } - } - catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - Logger.REFLECTION("Failed to Dynamically invoke "+methodName+" on an object of type: "+classname); - } - Logger.REFLECTION("Invoke failed or did something wrong."); - return false; - } - - public static boolean invokeVoid(Object objectInstance, String methodName, Class[] parameters, Object[] values){ - if (objectInstance == null || methodName == null || parameters == null || values == null){ - return false; - } - Class mLocalClass = (objectInstance instanceof Class ? (Class) objectInstance : objectInstance.getClass()); - Logger.REFLECTION("Trying to invoke "+methodName+" on an instance of "+mLocalClass.getCanonicalName()+"."); - try { - Method mInvokingMethod = mLocalClass.getDeclaredMethod(methodName, parameters); - if (mInvokingMethod != null){ - Logger.REFLECTION(methodName+" was not null."); - mInvokingMethod.invoke(objectInstance, values); - Logger.REFLECTION("Successfully invoked "+methodName+"."); - return true; - } - else { - Logger.REFLECTION(methodName+" is null."); - } - } - catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - Logger.REFLECTION("Failed to Dynamically invoke "+methodName+" on an object of type: "+mLocalClass.getName()); - } - - Logger.REFLECTION("Invoke failed or did something wrong."); - return false; - } - - - public static Object invokeNonBool(Object objectInstance, Method method, Object[] values){ - if ((!ReflectionUtils.isStaticMethod(method) && objectInstance == null) || method == null || values == null){ - return false; - } - String methodName = method.getName(); - String classname = objectInstance != null ? objectInstance.getClass().getCanonicalName() : method.getDeclaringClass().getCanonicalName(); - Logger.REFLECTION("Trying to invoke "+methodName+" on an instance of "+classname+"."); - try { - return method.invoke(objectInstance, values); - } - catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - Logger.REFLECTION("Failed to Dynamically invoke "+methodName+" on an object of type: "+classname); - } - - Logger.REFLECTION("Invoke failed or did something wrong."); - return null; - } - - public static Object invokeNonBool(Object objectInstance, String methodName, Class[] parameters, Object[] values){ - if (objectInstance == null || methodName == null || parameters == null || values == null){ - return false; - } - Class mLocalClass = (objectInstance instanceof Class ? (Class) objectInstance : objectInstance.getClass()); - Logger.REFLECTION("Trying to invoke "+methodName+" on an instance of "+mLocalClass.getCanonicalName()+"."); - try { - Method mInvokingMethod = mLocalClass.getDeclaredMethod(methodName, parameters); - if (mInvokingMethod != null){ - Logger.REFLECTION(methodName+" was not null."); - return mInvokingMethod.invoke(objectInstance, values); - } - else { - Logger.REFLECTION(methodName+" is null."); - } - } - catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - Logger.REFLECTION("Failed to Dynamically invoke "+methodName+" on an object of type: "+mLocalClass.getName()); - } - - Logger.REFLECTION("Invoke failed or did something wrong."); - return null; - } - - - - - - - - - - - - - - - - - - - - - - /* - * Internal Magic that probably should not get exposed. - */ - - - - - - - - - - /* - * - * Below Code block is used for determining generic types associated with type - * - */ - - - //https://xebia.com/blog/acessing-generic-types-at-runtime-in-java/ - //https://www.javacodegeeks.com/2013/12/advanced-java-generics-retreiving-generic-type-arguments.html - public static Class findSuperClassParameterType(Object instance, Class classOfInterest, int parameterIndex) { - Class subClass = instance.getClass(); - while (classOfInterest != subClass.getSuperclass()) { - // instance.getClass() is no subclass of classOfInterest or instance is a direct instance of classOfInterest - subClass = subClass.getSuperclass(); - if (subClass == null) { - return null; - } - } - ParameterizedType parameterizedType = (ParameterizedType) subClass.getGenericSuperclass(); - Class aReturn; - aReturn = (Class) parameterizedType.getActualTypeArguments()[parameterIndex]; - return aReturn; - } - - public static Class findSubClassParameterType(Object instance, Class classOfInterest, int parameterIndex) { - Map typeMap = new HashMap(); - Class instanceClass = instance.getClass(); - while (classOfInterest != instanceClass.getSuperclass()) { - extractTypeArguments(typeMap, instanceClass); - instanceClass = instanceClass.getSuperclass(); - if (instanceClass == null) { - return null; - } - } - - ParameterizedType parameterizedType = (ParameterizedType) instanceClass.getGenericSuperclass(); - Type actualType = parameterizedType.getActualTypeArguments()[parameterIndex]; - if (typeMap.containsKey(actualType)) { - actualType = typeMap.get(actualType); - } - if (actualType instanceof Class) { - return (Class) actualType; - } else if (actualType instanceof TypeVariable) { - return browseNestedTypes(instance, (TypeVariable) actualType); - } else { - return null; - } - } - - private static void extractTypeArguments(Map typeMap, Class clazz) { - Type genericSuperclass = clazz.getGenericSuperclass(); - if (!(genericSuperclass instanceof ParameterizedType)) { - return; - } - - ParameterizedType parameterizedType = (ParameterizedType) genericSuperclass; - Type[] typeParameter = ((Class) parameterizedType.getRawType()).getTypeParameters(); - Type[] actualTypeArgument = parameterizedType.getActualTypeArguments(); - for (int i = 0; i < typeParameter.length; i++) { - if(typeMap.containsKey(actualTypeArgument[i])) { - actualTypeArgument[i] = typeMap.get(actualTypeArgument[i]); - } - typeMap.put(typeParameter[i], actualTypeArgument[i]); - } - } - - private static Class browseNestedTypes(Object instance, TypeVariable actualType) { - Class instanceClass = instance.getClass(); - List> nestedOuterTypes = new LinkedList>(); - for (Class enclosingClass = instanceClass - .getEnclosingClass(); enclosingClass != null; enclosingClass = enclosingClass.getEnclosingClass()) { - try { - Field this$0 = instanceClass.getDeclaredField("this$0"); - Object outerInstance = this$0.get(instance); - Class outerClass = outerInstance.getClass(); - nestedOuterTypes.add(outerClass); - Map outerTypeMap = new HashMap(); - extractTypeArguments(outerTypeMap, outerClass); - for (Map.Entry entry : outerTypeMap.entrySet()) { - if (!(entry.getKey() instanceof TypeVariable)) { - continue; - } - TypeVariable foundType = (TypeVariable) entry.getKey(); - if (foundType.getName().equals(actualType.getName()) - && isInnerClass(foundType.getGenericDeclaration(), actualType.getGenericDeclaration())) { - if (entry.getValue() instanceof Class) { - return (Class) entry.getValue(); - } - actualType = (TypeVariable) entry.getValue(); - } - } - } catch (NoSuchFieldException | IllegalAccessException e) { - - } - - } - return null; - } - - private static boolean isInnerClass(GenericDeclaration outerDeclaration, GenericDeclaration innerDeclaration) { - if (!(outerDeclaration instanceof Class) || !(innerDeclaration instanceof Class)) { - return false; - } - Class outerClass = (Class) outerDeclaration; - Class innerClass = (Class) innerDeclaration; - while ((innerClass = innerClass.getEnclosingClass()) != null) { - if (innerClass == outerClass) { - return true; - } - } - return false; - } - - - /* - * - * End of Generics Block - * - */ - - - - private static Field getField_Internal(final Class clazz, final String fieldName) throws NoSuchFieldException { - try { - Logger.REFLECTION("Field: Internal Lookup: "+fieldName); - Field k = clazz.getDeclaredField(fieldName); - makeFieldAccessible(k); - //Logger.REFLECTION("Got Field from Class. "+fieldName+" did exist within "+clazz.getCanonicalName()+"."); - return k; - } catch (final NoSuchFieldException e) { - Logger.REFLECTION("Field: Internal Lookup Failed: "+fieldName); - final Class superClass = clazz.getSuperclass(); - if (superClass == null) { - Logger.REFLECTION("Unable to find field '"+fieldName+"'"); - //Logger.REFLECTION("Failed to get Field from Class. "+fieldName+" does not existing within "+clazz.getCanonicalName()+"."); - throw e; - } - Logger.REFLECTION("Method: Recursion Lookup: "+fieldName+" - Checking in "+superClass.getName()); - //Logger.REFLECTION("Failed to get Field from Class. "+fieldName+" does not existing within "+clazz.getCanonicalName()+". Trying super class."); - return getField_Internal(superClass, fieldName); - } - } - - /** - * if (isPresent("com.optionaldependency.DependencyClass")) || - * This block will never execute when the dependency is not present. There is - * therefore no more risk of code throwing NoClassDefFoundException. - */ - private static boolean isClassPresent(final String className) { - try { - Class.forName(className); - return true; - } catch (final Throwable ex) { - // Class or one of its dependencies is not present... - return false; - } - } - - @Deprecated - public static Method getMethodViaReflection(final Class lookupClass, final String methodName, - final boolean invoke) throws Exception { - final Class lookup = lookupClass.getClass(); - final Method m = lookup.getDeclaredMethod(methodName); - m.setAccessible(true);// Abracadabra - if (invoke) { - m.invoke(lookup);// now its OK - } - return m; - } - - private static Method getMethod_Internal(Class aClass, String aMethodName, Class... aTypes) { - Method m = null; - try { - Logger.REFLECTION("Method: Internal Lookup: "+aMethodName); - m = aClass.getDeclaredMethod(aMethodName, aTypes); - if (m != null) { - m.setAccessible(true); - int modifiers = m.getModifiers(); - Field modifierField = m.getClass().getDeclaredField("modifiers"); - modifiers = modifiers & ~Modifier.FINAL; - modifierField.setAccessible(true); - modifierField.setInt(m, modifiers); - } - } - catch (Throwable t) { - Logger.REFLECTION("Method: Internal Lookup Failed: "+aMethodName); - try { - m = getMethodRecursively(aClass, aMethodName); - } catch (NoSuchMethodException e) { - Logger.REFLECTION("Unable to find method '"+aMethodName+"'"); - e.printStackTrace(); - dumpClassInfo(aClass); - } - } - return m; - } - - private static Constructor getConstructor_Internal(Class aClass, Class... aTypes) { - Constructor c = null; - try { - Logger.REFLECTION("Constructor: Internal Lookup: "+aClass.getName()); - c = aClass.getDeclaredConstructor(aTypes); - if (c != null) { - c.setAccessible(true); - int modifiers = c.getModifiers(); - Field modifierField = c.getClass().getDeclaredField("modifiers"); - modifiers = modifiers & ~Modifier.FINAL; - modifierField.setAccessible(true); - modifierField.setInt(c, modifiers); - } - } - catch (Throwable t) { - Logger.REFLECTION("Constructor: Internal Lookup Failed: "+aClass.getName()); - try { - c = getConstructorRecursively(aClass, aTypes); - } catch (Exception e) { - Logger.REFLECTION("Unable to find method '"+aClass.getName()+"'"); - e.printStackTrace(); - dumpClassInfo(aClass); - } - } - return c; - } - - private static Constructor getConstructorRecursively(Class aClass, Class... aTypes) throws Exception { - try { - Logger.REFLECTION("Constructor: Recursion Lookup: "+aClass.getName()); - Constructor c = aClass.getConstructor(aTypes); - if (c != null) { - c.setAccessible(true); - int modifiers = c.getModifiers(); - Field modifierField = c.getClass().getDeclaredField("modifiers"); - modifiers = modifiers & ~Modifier.FINAL; - modifierField.setAccessible(true); - modifierField.setInt(c, modifiers); - } - return c; - } catch (final NoSuchMethodException | IllegalArgumentException | IllegalAccessException e) { - final Class superClass = aClass.getSuperclass(); - if (superClass == null || superClass == Object.class) { - throw e; - } - return getConstructor_Internal(superClass, aTypes); - } - } - - private static Method getMethodRecursively(final Class clazz, final String aMethodName) throws NoSuchMethodException { - try { - Logger.REFLECTION("Method: Recursion Lookup: "+aMethodName); - Method k = clazz.getDeclaredMethod(aMethodName); - makeMethodAccessible(k); - return k; - } catch (final NoSuchMethodException e) { - final Class superClass = clazz.getSuperclass(); - if (superClass == null || superClass == Object.class) { - throw e; - } - return getMethod_Internal(superClass, aMethodName); - } - } - - private static void dumpClassInfo(Class aClass) { - Logger.INFO("We ran into an error processing reflection in "+aClass.getName()+", dumping all data for debugging."); - // Get the methods - Method[] methods = aClass.getDeclaredMethods(); - Field[] fields = aClass.getDeclaredFields(); - Constructor[] consts = aClass.getDeclaredConstructors(); - - Logger.INFO("Dumping all Methods."); - for (Method method : methods) { - System.out.println(method.getName()+" | "+StringUtils.getDataStringFromArray(method.getParameterTypes())); - } - Logger.INFO("Dumping all Fields."); - for (Field f : fields) { - System.out.println(f.getName()); - } - Logger.INFO("Dumping all Constructors."); - for (Constructor c : consts) { - System.out.println(c.getName()+" | "+c.getParameterCount()+" | "+StringUtils.getDataStringFromArray(c.getParameterTypes())); - } - } - - private static Class getNonPublicClass(final String className) { - Class c = null; - try { - c = Class.forName(className); - } catch (final ClassNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - // full package name --------^^^^^^^^^^ - // or simpler without Class.forName: - // Class c = package1.A.class; - - if (null != c) { - // In our case we need to use - Constructor constructor = null; - try { - constructor = c.getDeclaredConstructor(); - } catch (NoSuchMethodException | SecurityException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - // note: getConstructor() can return only public constructors - // so we needed to search for any Declared constructor - - // now we need to make this constructor accessible - if (null != constructor) { - constructor.setAccessible(true);// ABRACADABRA! - - try { - final Object o = constructor.newInstance(); - return (Class) o; - } catch (InstantiationException | IllegalAccessException | IllegalArgumentException - | InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - } - return null; - } - - private static Class getClass_Internal(String string) { - Class aClass = null; - if (ReflectionUtils.doesClassExist(string)) { - try { - aClass = Class.forName(string); - } - catch (ClassNotFoundException e) { - aClass = getNonPublicClass(string); - } - } - - if (aClass == null) { - String aClassName = ""; - Logger.REFLECTION("Splitting "+string+" to try look for hidden classes."); - String[] aData = string.split("\\."); - Logger.REFLECTION("Obtained "+aData.length+" pieces."); - for (int i=0;i<(aData.length-1);i++) { - aClassName += (i > 0) ? "."+aData[i] : ""+aData[i]; - Logger.REFLECTION("Building: "+aClassName); - } - if (aClassName != null && aClassName.length() > 0) { - Logger.REFLECTION("Trying to search '"+aClassName+"' for inner classes."); - Class clazz = ReflectionUtils.getClass(aClassName); - if (clazz != null) { - Class[] y = clazz.getDeclaredClasses(); - if (y == null || y.length <= 0) { - Logger.REFLECTION("No hidden inner classes found."); - return null; - } - else { - boolean found = false; - for (Class h : y) { - Logger.REFLECTION("Found hidden inner class: "+h.getCanonicalName()); - if (h.getSimpleName().toLowerCase().equals(aData[aData.length-1].toLowerCase())) { - Logger.REFLECTION("Found correct class. ["+aData[aData.length-1]+"] Caching at correct location: "+string); - Logger.REFLECTION("Found at location: "+h.getCanonicalName()); - ReflectionUtils.mCachedClasses.put(string, h); - aClass = h; - found = true; - break; - } - } - if (!found) { - return null; - } - } - } - else { - return null; - } - } - else { - return null; - } - } - return aClass; - } - - /** - * - * Set the value of a field reflectively. - */ - private static void setFieldValue_Internal(Object owner, Field field, Object value) throws Exception { - makeModifiable(field); - field.set(owner, value); - } - - /** - * Force the field to be modifiable and accessible. - */ - private static void makeModifiable(Field nameField) throws Exception { - nameField.setAccessible(true); - Field modifiers = getField(Field.class, "modifiers"); - modifiers.setAccessible(true); - modifiers.setInt(nameField, nameField.getModifiers() & ~Modifier.FINAL); - } - - - public static boolean doesFieldExist(String clazz, String string) { - return doesFieldExist(ReflectionUtils.getClass(clazz), string); - } - - public static boolean doesFieldExist(Class clazz, String string) { - if (clazz != null) { - if (ReflectionUtils.getField(clazz, string) != null) { - return true; - } - } - return false; - } - - public static T getFieldValue(Field field) { - return getFieldValue(field, null); - } - - public static T getFieldValue(Field field, Object instance) { - try { - return (T) field.get(instance); - } catch (IllegalArgumentException | IllegalAccessException e) { - } - return null; - } - - public static T createNewInstanceFromConstructor(Constructor aConstructor, Object[] aArgs) { - T aInstance; - try { - aInstance = (T) aConstructor.newInstance(aArgs); - if (aInstance != null) { - return aInstance; - } - } - catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - e.printStackTrace(); - } - return null; - } - - public static Enum getEnum(Class sgtbees, String name) { - if (sgtbees.isEnum()) { - Object[] aValues = sgtbees.getEnumConstants(); - for (Object o : aValues) { - if (o.toString().toLowerCase().equals(name.toLowerCase())) { - return (Enum) o; - } - } - } - return null; - } - - + public static Map> mCachedClasses = new LinkedHashMap>(); + public static Map mCachedMethods = new LinkedHashMap(); + public static Map mCachedFields = new LinkedHashMap(); + public static Map mCachedConstructors = new LinkedHashMap(); + + private static class CachedConstructor { + + private final Constructor METHOD; + + public CachedConstructor(Constructor aCons) { + METHOD = aCons; + } + + public Constructor get() { + return METHOD; + } + } + + private static class CachedMethod { + + private final boolean STATIC; + private final Method METHOD; + + public CachedMethod(Method aMethod, boolean isStatic) { + METHOD = aMethod; + STATIC = isStatic; + } + + public Method get() { + return METHOD; + } + + public boolean type() { + return STATIC; + } + } + + private static class CachedField { + + private final boolean STATIC; + private final Field FIELD; + + public CachedField(Field aField, boolean isStatic) { + FIELD = aField; + STATIC = isStatic; + } + + public Field get() { + return FIELD; + } + + public boolean type() { + return STATIC; + } + } + + private static boolean cacheClass(Class aClass) { + if (aClass == null) { + return false; + } + Class y = mCachedClasses.get(aClass.getCanonicalName()); + if (y == null) { + mCachedClasses.put(aClass.getCanonicalName(), aClass); + return true; + } + return false; + } + + private static boolean cacheMethod(Class aClass, Method aMethod) { + if (aMethod == null) { + return false; + } + boolean isStatic = Modifier.isStatic(aMethod.getModifiers()); + CachedMethod y = mCachedMethods.get( + aClass.getName() + "." + aMethod.getName() + "." + ArrayUtils.toString(aMethod.getParameterTypes())); + if (y == null) { + mCachedMethods.put( + aClass.getName() + "." + aMethod.getName() + "." + ArrayUtils.toString(aMethod.getParameterTypes()), + new CachedMethod(aMethod, isStatic)); + return true; + } + return false; + } + + private static boolean cacheField(Class aClass, Field aField) { + if (aField == null) { + return false; + } + boolean isStatic = Modifier.isStatic(aField.getModifiers()); + CachedField y = mCachedFields.get(aClass.getName() + "." + aField.getName()); + if (y == null) { + mCachedFields.put(aClass.getName() + "." + aField.getName(), new CachedField(aField, isStatic)); + return true; + } + return false; + } + + private static boolean cacheConstructor(Class aClass, Constructor aConstructor) { + if (aConstructor == null) { + return false; + } + CachedConstructor y = + mCachedConstructors.get(aClass.getName() + "." + ArrayUtils.toString(aConstructor.getParameterTypes())); + if (y == null) { + mCachedConstructors.put( + aClass.getName() + "." + ArrayUtils.toString(aConstructor.getParameterTypes()), + new CachedConstructor(aConstructor)); + return true; + } + return false; + } + + /** + * Returns a cached {@link Constructor} object. + * @param aClass - Class containing the Constructor. + * @param aTypes - Varags Class Types for objects constructor. + * @return - Valid, non-final, {@link Method} object, or {@link null}. + */ + public static Constructor getConstructor(Class aClass, Class... aTypes) { + if (aClass == null || aTypes == null) { + return null; + } + + String aMethodKey = ArrayUtils.toString(aTypes); + // Logger.REFLECTION("Looking up method in cache: "+(aClass.getName()+"."+aMethodName + "." + aMethodKey)); + CachedConstructor y = mCachedConstructors.get(aClass.getName() + "." + aMethodKey); + if (y == null) { + Constructor u = getConstructor_Internal(aClass, aTypes); + if (u != null) { + Logger.REFLECTION("Caching Constructor: " + aClass.getName() + "." + aMethodKey); + cacheConstructor(aClass, u); + return u; + } else { + return null; + } + } else { + return y.get(); + } + } + + /** + * Returns a cached {@link Class} object. + * @param aClassCanonicalName - The canonical name of the underlying class. + * @return - Valid, {@link Class} object, or {@link null}. + */ + public static Class getClass(String aClassCanonicalName) { + if (aClassCanonicalName == null || aClassCanonicalName.length() <= 0) { + return null; + } + Class y = mCachedClasses.get(aClassCanonicalName); + if (y == null) { + y = getClass_Internal(aClassCanonicalName); + if (y != null) { + Logger.REFLECTION("Caching Class: " + aClassCanonicalName); + cacheClass(y); + } + } + return y; + } + + /** + * Returns a cached {@link Method} object. Wraps {@link #getMethod(Class, String, Class...)}. + * @param aObject - Object containing the Method. + * @param aMethodName - Method's name in {@link String} form. + * @param aTypes - Class Array of Types for {@link Method}'s constructor. + * @return - Valid, non-final, {@link Method} object, or {@link null}. + */ + public static Method getMethod(Object aObject, String aMethodName, Class[] aTypes) { + return getMethod(aObject.getClass(), aMethodName, aTypes); + } + + /** + * Returns a cached {@link Method} object. + * @param aClass - Class containing the Method. + * @param aMethodName - Method's name in {@link String} form. + * @param aTypes - Varags Class Types for {@link Method}'s constructor. + * @return - Valid, non-final, {@link Method} object, or {@link null}. + */ + public static Method getMethod(Class aClass, String aMethodName, Class... aTypes) { + if (aClass == null || aMethodName == null || aMethodName.length() <= 0) { + return null; + } + String aMethodKey = ArrayUtils.toString(aTypes); + // Logger.REFLECTION("Looking up method in cache: "+(aClass.getName()+"."+aMethodName + "." + aMethodKey)); + CachedMethod y = mCachedMethods.get(aClass.getName() + "." + aMethodName + "." + aMethodKey); + if (y == null) { + Method u = getMethod_Internal(aClass, aMethodName, aTypes); + if (u != null) { + Logger.REFLECTION("Caching Method: " + aMethodName + "." + aMethodKey); + cacheMethod(aClass, u); + return u; + } else { + return null; + } + } else { + return y.get(); + } + } + + public static boolean isStaticMethod(Class aClass, String aMethodName, Class... aTypes) { + return isStaticMethod(ReflectionUtils.getMethod(aClass, aMethodName, aTypes)); + } + + public static boolean isStaticMethod(Method aMethod) { + if (aMethod != null && Modifier.isStatic(aMethod.getModifiers())) { + return true; + } + return false; + } + + /** + * Returns a cached {@link Field} object. + * @param aClass - Class containing the Method. + * @param aFieldName - Field name in {@link String} form. + * @return - Valid, non-final, {@link Field} object, or {@link null}. + */ + public static Field getField(final Class aClass, final String aFieldName) { + if (aClass == null || aFieldName == null || aFieldName.length() <= 0) { + return null; + } + CachedField y = mCachedFields.get(aClass.getName() + "." + aFieldName); + if (y == null) { + Field u; + try { + u = getField_Internal(aClass, aFieldName); + if (u != null) { + Logger.REFLECTION("Caching Field '" + aFieldName + "' from " + aClass.getName()); + cacheField(aClass, u); + return u; + } + } catch (NoSuchFieldException e) { + } + return null; + + } else { + return y.get(); + } + } + + public static Field[] getAllFields(final Class aClass) { + if (aClass == null) { + return null; + } + Field[] aFields = aClass.getDeclaredFields(); + for (Field f : aFields) { + CachedField y = mCachedFields.get(aClass.getName() + "." + f.getName()); + if (y == null) { + makeFieldAccessible(f); + cacheField(aClass, f); + } + } + return aFields; + } + + /** + * Returns a cached {@link Field} object. + * @param aInstance - {@link Object} to get the field instance from. + * @param aFieldName - Field name in {@link String} form. + * @return - Valid, non-final, {@link Field} object, or {@link null}. + */ + public static T getField(final Object aInstance, final String aFieldName) { + try { + return (T) getField(aInstance.getClass(), aFieldName).get(aInstance); + } catch (IllegalArgumentException | IllegalAccessException e) { + return null; + } + } + + /* + * Utility Functions + */ + + public static boolean doesClassExist(final String classname) { + return isClassPresent(classname); + } + + /** + * Returns the class of the objects type parameter + * @param o - Object to examine paramters on + * @return - a Class or null + */ + public static Class getTypeOfGenericObject(Object o) { + Class aTypeParam = findSuperClassParameterType(o, o.getClass(), 0); + if (aTypeParam == null) { + aTypeParam = findSubClassParameterType(o, o.getClass(), 0); + } + return aTypeParam; + } + + public static void makeFieldAccessible(final Field field) { + if (!Modifier.isPublic(field.getModifiers()) + || !Modifier.isPublic(field.getDeclaringClass().getModifiers())) { + field.setAccessible(true); + } + } + + public static void makeMethodAccessible(final Method field) { + if (!Modifier.isPublic(field.getModifiers()) + || !Modifier.isPublic(field.getDeclaringClass().getModifiers())) { + field.setAccessible(true); + } + } + + /** + * Get the method name for a depth in call stack.
+ * Utility function + * @param depth depth in the call stack (0 means current method, 1 means call method, ...) + * @return Method name + */ + public static String getMethodName(final int depth) { + final StackTraceElement[] ste = new Throwable().getStackTrace(); + // System. out.println(ste[ste.length-depth].getClassName()+"#"+ste[ste.length-depth].getMethodName()); + if (ste.length < depth) { + return "No valid stack."; + } + return ste[depth + 1].getMethodName(); + } + + /** + * + * @param aPackageName - The full {@link Package} name in {@link String} form. + * @return - {@link Boolean} object. True if loaded > 0 classes. + */ + public static boolean dynamicallyLoadClassesInPackage(String aPackageName) { + ClassLoader classLoader = ReflectionUtils.class.getClassLoader(); + int loaded = 0; + try { + ClassPath path = ClassPath.from(classLoader); + for (ClassPath.ClassInfo info : path.getTopLevelClassesRecursive(aPackageName)) { + Class clazz = Class.forName(info.getName(), true, classLoader); + if (clazz != null) { + loaded++; + Logger.INFO("Found " + clazz.getCanonicalName() + ". [" + loaded + "]"); + } + } + } catch (ClassNotFoundException | IOException e) { + + } + + return loaded > 0; + } + + public static void loadClass(String aClassName) { + try { + Class.forName(aClassName, true, ReflectionUtils.class.getClassLoader()); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + } + + public static boolean setField(final Object object, final String fieldName, final Object fieldValue) { + Class clazz; + if (object instanceof Class) { + clazz = (Class) object; + } else { + clazz = object.getClass(); + } + while (clazz != null) { + try { + final Field field = getField(clazz, fieldName); + if (field != null) { + setFieldValue_Internal(object, field, fieldValue); + return true; + } + } catch (final NoSuchFieldException e) { + Logger.REFLECTION("setField(" + object.toString() + ", " + fieldName + ") failed."); + clazz = clazz.getSuperclass(); + } catch (final Exception e) { + Logger.REFLECTION("setField(" + object.toString() + ", " + fieldName + ") failed."); + throw new IllegalStateException(e); + } + } + return false; + } + + public static boolean setField(final Object object, final Field field, final Object fieldValue) { + if (field == null) return false; + Class clazz; + if (object instanceof Class) { + clazz = (Class) object; + } else { + clazz = object.getClass(); + } + while (clazz != null) { + try { + final Field field2 = getField(clazz, field.getName()); + if (field2 != null) { + setFieldValue_Internal(object, field, fieldValue); + return true; + } + } catch (final NoSuchFieldException e) { + Logger.REFLECTION("setField(" + object.toString() + ", " + field.getName() + ") failed."); + clazz = clazz.getSuperclass(); + } catch (final Exception e) { + Logger.REFLECTION("setField(" + object.toString() + ", " + field.getName() + ") failed."); + throw new IllegalStateException(e); + } + } + return false; + } + + /** + * Allows to change the state of an immutable instance. Huh?!? + */ + public static void setFinalFieldValue(Class clazz, String fieldName, Object newValue) { + Field nameField = getField(clazz, fieldName); + try { + setFieldValue_Internal(clazz, nameField, newValue); + } catch (Throwable t) { + t.printStackTrace(); + } + } + + /** + * Allows to change the state of an immutable instance. Huh?!? + */ + public static void setFinalFieldValue(Class clazz, Field field, Object newValue) { + try { + setFieldValue_Internal(clazz, field, newValue); + } catch (Throwable t) { + t.printStackTrace(); + } + } + + @Deprecated + public static void setFinalStatic(Field field, Object newValue) throws Exception { + field.setAccessible(true); + Field modifiersField = Field.class.getDeclaredField("modifiers"); + modifiersField.setAccessible(true); + modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); + field.set(null, newValue); + } + + public static void setByte(Object clazz, String fieldName, byte newValue) throws Exception { + Field nameField = getField(clazz.getClass(), fieldName); + nameField.setAccessible(true); + int modifiers = nameField.getModifiers(); + Field modifierField = nameField.getClass().getDeclaredField("modifiers"); + modifiers = modifiers & ~Modifier.FINAL; + modifierField.setAccessible(true); + modifierField.setInt(nameField, modifiers); + // Utils.LOG_INFO("O-"+(byte) nameField.get(clazz) + " | "+newValue); + nameField.setByte(clazz, newValue); + // Utils.LOG_INFO("N-"+(byte) nameField.get(clazz)); + + /*final Field fieldA = getField(clazz.getClass(), fieldName); + fieldA.setAccessible(true); + fieldA.setByte(clazz, newValue);*/ + + } + + public static boolean invoke(Object objectInstance, String methodName, Class[] parameters, Object[] values) { + if (objectInstance == null || methodName == null || parameters == null || values == null) { + return false; + } + Class mLocalClass = + (objectInstance instanceof Class ? (Class) objectInstance : objectInstance.getClass()); + Logger.REFLECTION( + "Trying to invoke " + methodName + " on an instance of " + mLocalClass.getCanonicalName() + "."); + try { + Method mInvokingMethod = mLocalClass.getDeclaredMethod(methodName, parameters); + if (mInvokingMethod != null) { + return invoke(objectInstance, mInvokingMethod, values); + } + } catch (NoSuchMethodException | SecurityException | IllegalArgumentException e) { + Logger.REFLECTION( + "Failed to Dynamically invoke " + methodName + " on an object of type: " + mLocalClass.getName()); + } + + Logger.REFLECTION("Invoke failed or did something wrong."); + return false; + } + + public static boolean invoke(Object objectInstance, Method method, Object[] values) { + if (method == null || values == null || (!ReflectionUtils.isStaticMethod(method) && objectInstance == null)) { + // Logger.REFLECTION("Null value when trying to Dynamically invoke "+methodName+" on an object of type: + // "+objectInstance.getClass().getName()); + return false; + } + String methodName = method.getName(); + String classname = objectInstance != null + ? objectInstance.getClass().getCanonicalName() + : method.getDeclaringClass().getCanonicalName(); + Logger.REFLECTION("Trying to invoke " + methodName + " on an instance of " + classname + "."); + try { + Method mInvokingMethod = method; + if (mInvokingMethod != null) { + Logger.REFLECTION(methodName + " was not null."); + if ((boolean) mInvokingMethod.invoke(objectInstance, values)) { + Logger.REFLECTION("Successfully invoked " + methodName + "."); + return true; + } else { + Logger.REFLECTION("Invocation failed for " + methodName + "."); + } + } + } catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + Logger.REFLECTION("Failed to Dynamically invoke " + methodName + " on an object of type: " + classname); + } + Logger.REFLECTION("Invoke failed or did something wrong."); + return false; + } + + public static boolean invokeVoid(Object objectInstance, Method method, Object[] values) { + if (method == null || values == null || (!ReflectionUtils.isStaticMethod(method) && objectInstance == null)) { + // Logger.REFLECTION("Null value when trying to Dynamically invoke "+methodName+" on an object of type: + // "+objectInstance.getClass().getName()); + return false; + } + String methodName = method.getName(); + String classname = objectInstance != null + ? objectInstance.getClass().getCanonicalName() + : method.getDeclaringClass().getCanonicalName(); + Logger.REFLECTION("Trying to invoke " + methodName + " on an instance of " + classname + "."); + try { + Method mInvokingMethod = method; + if (mInvokingMethod != null) { + Logger.REFLECTION(methodName + " was not null."); + mInvokingMethod.invoke(objectInstance, values); + Logger.REFLECTION("Successfully invoked " + methodName + "."); + return true; + } + } catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + Logger.REFLECTION("Failed to Dynamically invoke " + methodName + " on an object of type: " + classname); + } + Logger.REFLECTION("Invoke failed or did something wrong."); + return false; + } + + public static boolean invokeVoid(Object objectInstance, String methodName, Class[] parameters, Object[] values) { + if (objectInstance == null || methodName == null || parameters == null || values == null) { + return false; + } + Class mLocalClass = + (objectInstance instanceof Class ? (Class) objectInstance : objectInstance.getClass()); + Logger.REFLECTION( + "Trying to invoke " + methodName + " on an instance of " + mLocalClass.getCanonicalName() + "."); + try { + Method mInvokingMethod = mLocalClass.getDeclaredMethod(methodName, parameters); + if (mInvokingMethod != null) { + Logger.REFLECTION(methodName + " was not null."); + mInvokingMethod.invoke(objectInstance, values); + Logger.REFLECTION("Successfully invoked " + methodName + "."); + return true; + } else { + Logger.REFLECTION(methodName + " is null."); + } + } catch (NoSuchMethodException + | SecurityException + | IllegalAccessException + | IllegalArgumentException + | InvocationTargetException e) { + Logger.REFLECTION( + "Failed to Dynamically invoke " + methodName + " on an object of type: " + mLocalClass.getName()); + } + + Logger.REFLECTION("Invoke failed or did something wrong."); + return false; + } + + public static Object invokeNonBool(Object objectInstance, Method method, Object[] values) { + if ((!ReflectionUtils.isStaticMethod(method) && objectInstance == null) || method == null || values == null) { + return false; + } + String methodName = method.getName(); + String classname = objectInstance != null + ? objectInstance.getClass().getCanonicalName() + : method.getDeclaringClass().getCanonicalName(); + Logger.REFLECTION("Trying to invoke " + methodName + " on an instance of " + classname + "."); + try { + return method.invoke(objectInstance, values); + } catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + Logger.REFLECTION("Failed to Dynamically invoke " + methodName + " on an object of type: " + classname); + } + + Logger.REFLECTION("Invoke failed or did something wrong."); + return null; + } + + public static Object invokeNonBool(Object objectInstance, String methodName, Class[] parameters, Object[] values) { + if (objectInstance == null || methodName == null || parameters == null || values == null) { + return false; + } + Class mLocalClass = + (objectInstance instanceof Class ? (Class) objectInstance : objectInstance.getClass()); + Logger.REFLECTION( + "Trying to invoke " + methodName + " on an instance of " + mLocalClass.getCanonicalName() + "."); + try { + Method mInvokingMethod = mLocalClass.getDeclaredMethod(methodName, parameters); + if (mInvokingMethod != null) { + Logger.REFLECTION(methodName + " was not null."); + return mInvokingMethod.invoke(objectInstance, values); + } else { + Logger.REFLECTION(methodName + " is null."); + } + } catch (NoSuchMethodException + | SecurityException + | IllegalAccessException + | IllegalArgumentException + | InvocationTargetException e) { + Logger.REFLECTION( + "Failed to Dynamically invoke " + methodName + " on an object of type: " + mLocalClass.getName()); + } + + Logger.REFLECTION("Invoke failed or did something wrong."); + return null; + } + + /* + * Internal Magic that probably should not get exposed. + */ + + /* + * + * Below Code block is used for determining generic types associated with type + * + */ + + // https://xebia.com/blog/acessing-generic-types-at-runtime-in-java/ + // https://www.javacodegeeks.com/2013/12/advanced-java-generics-retreiving-generic-type-arguments.html + public static Class findSuperClassParameterType(Object instance, Class classOfInterest, int parameterIndex) { + Class subClass = instance.getClass(); + while (classOfInterest != subClass.getSuperclass()) { + // instance.getClass() is no subclass of classOfInterest or instance is a direct instance of classOfInterest + subClass = subClass.getSuperclass(); + if (subClass == null) { + return null; + } + } + ParameterizedType parameterizedType = (ParameterizedType) subClass.getGenericSuperclass(); + Class aReturn; + aReturn = (Class) parameterizedType.getActualTypeArguments()[parameterIndex]; + return aReturn; + } + + public static Class findSubClassParameterType(Object instance, Class classOfInterest, int parameterIndex) { + Map typeMap = new HashMap(); + Class instanceClass = instance.getClass(); + while (classOfInterest != instanceClass.getSuperclass()) { + extractTypeArguments(typeMap, instanceClass); + instanceClass = instanceClass.getSuperclass(); + if (instanceClass == null) { + return null; + } + } + + ParameterizedType parameterizedType = (ParameterizedType) instanceClass.getGenericSuperclass(); + Type actualType = parameterizedType.getActualTypeArguments()[parameterIndex]; + if (typeMap.containsKey(actualType)) { + actualType = typeMap.get(actualType); + } + if (actualType instanceof Class) { + return (Class) actualType; + } else if (actualType instanceof TypeVariable) { + return browseNestedTypes(instance, (TypeVariable) actualType); + } else { + return null; + } + } + + private static void extractTypeArguments(Map typeMap, Class clazz) { + Type genericSuperclass = clazz.getGenericSuperclass(); + if (!(genericSuperclass instanceof ParameterizedType)) { + return; + } + + ParameterizedType parameterizedType = (ParameterizedType) genericSuperclass; + Type[] typeParameter = ((Class) parameterizedType.getRawType()).getTypeParameters(); + Type[] actualTypeArgument = parameterizedType.getActualTypeArguments(); + for (int i = 0; i < typeParameter.length; i++) { + if (typeMap.containsKey(actualTypeArgument[i])) { + actualTypeArgument[i] = typeMap.get(actualTypeArgument[i]); + } + typeMap.put(typeParameter[i], actualTypeArgument[i]); + } + } + + private static Class browseNestedTypes(Object instance, TypeVariable actualType) { + Class instanceClass = instance.getClass(); + List> nestedOuterTypes = new LinkedList>(); + for (Class enclosingClass = instanceClass.getEnclosingClass(); + enclosingClass != null; + enclosingClass = enclosingClass.getEnclosingClass()) { + try { + Field this$0 = instanceClass.getDeclaredField("this$0"); + Object outerInstance = this$0.get(instance); + Class outerClass = outerInstance.getClass(); + nestedOuterTypes.add(outerClass); + Map outerTypeMap = new HashMap(); + extractTypeArguments(outerTypeMap, outerClass); + for (Map.Entry entry : outerTypeMap.entrySet()) { + if (!(entry.getKey() instanceof TypeVariable)) { + continue; + } + TypeVariable foundType = (TypeVariable) entry.getKey(); + if (foundType.getName().equals(actualType.getName()) + && isInnerClass(foundType.getGenericDeclaration(), actualType.getGenericDeclaration())) { + if (entry.getValue() instanceof Class) { + return (Class) entry.getValue(); + } + actualType = (TypeVariable) entry.getValue(); + } + } + } catch (NoSuchFieldException | IllegalAccessException e) { + + } + } + return null; + } + + private static boolean isInnerClass(GenericDeclaration outerDeclaration, GenericDeclaration innerDeclaration) { + if (!(outerDeclaration instanceof Class) || !(innerDeclaration instanceof Class)) { + return false; + } + Class outerClass = (Class) outerDeclaration; + Class innerClass = (Class) innerDeclaration; + while ((innerClass = innerClass.getEnclosingClass()) != null) { + if (innerClass == outerClass) { + return true; + } + } + return false; + } + + /* + * + * End of Generics Block + * + */ + + private static Field getField_Internal(final Class clazz, final String fieldName) throws NoSuchFieldException { + try { + Logger.REFLECTION("Field: Internal Lookup: " + fieldName); + Field k = clazz.getDeclaredField(fieldName); + makeFieldAccessible(k); + // Logger.REFLECTION("Got Field from Class. "+fieldName+" did exist within "+clazz.getCanonicalName()+"."); + return k; + } catch (final NoSuchFieldException e) { + Logger.REFLECTION("Field: Internal Lookup Failed: " + fieldName); + final Class superClass = clazz.getSuperclass(); + if (superClass == null) { + Logger.REFLECTION("Unable to find field '" + fieldName + "'"); + // Logger.REFLECTION("Failed to get Field from Class. "+fieldName+" does not existing within + // "+clazz.getCanonicalName()+"."); + throw e; + } + Logger.REFLECTION("Method: Recursion Lookup: " + fieldName + " - Checking in " + superClass.getName()); + // Logger.REFLECTION("Failed to get Field from Class. "+fieldName+" does not existing within + // "+clazz.getCanonicalName()+". Trying super class."); + return getField_Internal(superClass, fieldName); + } + } + + /** + * if (isPresent("com.optionaldependency.DependencyClass")) || + * This block will never execute when the dependency is not present. There is + * therefore no more risk of code throwing NoClassDefFoundException. + */ + private static boolean isClassPresent(final String className) { + try { + Class.forName(className); + return true; + } catch (final Throwable ex) { + // Class or one of its dependencies is not present... + return false; + } + } + + @Deprecated + public static Method getMethodViaReflection( + final Class lookupClass, final String methodName, final boolean invoke) throws Exception { + final Class lookup = lookupClass.getClass(); + final Method m = lookup.getDeclaredMethod(methodName); + m.setAccessible(true); // Abracadabra + if (invoke) { + m.invoke(lookup); // now its OK + } + return m; + } + + private static Method getMethod_Internal(Class aClass, String aMethodName, Class... aTypes) { + Method m = null; + try { + Logger.REFLECTION("Method: Internal Lookup: " + aMethodName); + m = aClass.getDeclaredMethod(aMethodName, aTypes); + if (m != null) { + m.setAccessible(true); + int modifiers = m.getModifiers(); + Field modifierField = m.getClass().getDeclaredField("modifiers"); + modifiers = modifiers & ~Modifier.FINAL; + modifierField.setAccessible(true); + modifierField.setInt(m, modifiers); + } + } catch (Throwable t) { + Logger.REFLECTION("Method: Internal Lookup Failed: " + aMethodName); + try { + m = getMethodRecursively(aClass, aMethodName); + } catch (NoSuchMethodException e) { + Logger.REFLECTION("Unable to find method '" + aMethodName + "'"); + e.printStackTrace(); + dumpClassInfo(aClass); + } + } + return m; + } + + private static Constructor getConstructor_Internal(Class aClass, Class... aTypes) { + Constructor c = null; + try { + Logger.REFLECTION("Constructor: Internal Lookup: " + aClass.getName()); + c = aClass.getDeclaredConstructor(aTypes); + if (c != null) { + c.setAccessible(true); + int modifiers = c.getModifiers(); + Field modifierField = c.getClass().getDeclaredField("modifiers"); + modifiers = modifiers & ~Modifier.FINAL; + modifierField.setAccessible(true); + modifierField.setInt(c, modifiers); + } + } catch (Throwable t) { + Logger.REFLECTION("Constructor: Internal Lookup Failed: " + aClass.getName()); + try { + c = getConstructorRecursively(aClass, aTypes); + } catch (Exception e) { + Logger.REFLECTION("Unable to find method '" + aClass.getName() + "'"); + e.printStackTrace(); + dumpClassInfo(aClass); + } + } + return c; + } + + private static Constructor getConstructorRecursively(Class aClass, Class... aTypes) throws Exception { + try { + Logger.REFLECTION("Constructor: Recursion Lookup: " + aClass.getName()); + Constructor c = aClass.getConstructor(aTypes); + if (c != null) { + c.setAccessible(true); + int modifiers = c.getModifiers(); + Field modifierField = c.getClass().getDeclaredField("modifiers"); + modifiers = modifiers & ~Modifier.FINAL; + modifierField.setAccessible(true); + modifierField.setInt(c, modifiers); + } + return c; + } catch (final NoSuchMethodException | IllegalArgumentException | IllegalAccessException e) { + final Class superClass = aClass.getSuperclass(); + if (superClass == null || superClass == Object.class) { + throw e; + } + return getConstructor_Internal(superClass, aTypes); + } + } + + private static Method getMethodRecursively(final Class clazz, final String aMethodName) + throws NoSuchMethodException { + try { + Logger.REFLECTION("Method: Recursion Lookup: " + aMethodName); + Method k = clazz.getDeclaredMethod(aMethodName); + makeMethodAccessible(k); + return k; + } catch (final NoSuchMethodException e) { + final Class superClass = clazz.getSuperclass(); + if (superClass == null || superClass == Object.class) { + throw e; + } + return getMethod_Internal(superClass, aMethodName); + } + } + + private static void dumpClassInfo(Class aClass) { + Logger.INFO("We ran into an error processing reflection in " + aClass.getName() + + ", dumping all data for debugging."); + // Get the methods + Method[] methods = aClass.getDeclaredMethods(); + Field[] fields = aClass.getDeclaredFields(); + Constructor[] consts = aClass.getDeclaredConstructors(); + + Logger.INFO("Dumping all Methods."); + for (Method method : methods) { + System.out.println( + method.getName() + " | " + StringUtils.getDataStringFromArray(method.getParameterTypes())); + } + Logger.INFO("Dumping all Fields."); + for (Field f : fields) { + System.out.println(f.getName()); + } + Logger.INFO("Dumping all Constructors."); + for (Constructor c : consts) { + System.out.println(c.getName() + " | " + c.getParameterCount() + " | " + + StringUtils.getDataStringFromArray(c.getParameterTypes())); + } + } + + private static Class getNonPublicClass(final String className) { + Class c = null; + try { + c = Class.forName(className); + } catch (final ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // full package name --------^^^^^^^^^^ + // or simpler without Class.forName: + // Class c = package1.A.class; + + if (null != c) { + // In our case we need to use + Constructor constructor = null; + try { + constructor = c.getDeclaredConstructor(); + } catch (NoSuchMethodException | SecurityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // note: getConstructor() can return only public constructors + // so we needed to search for any Declared constructor + + // now we need to make this constructor accessible + if (null != constructor) { + constructor.setAccessible(true); // ABRACADABRA! + + try { + final Object o = constructor.newInstance(); + return (Class) o; + } catch (InstantiationException + | IllegalAccessException + | IllegalArgumentException + | InvocationTargetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + return null; + } + + private static Class getClass_Internal(String string) { + Class aClass = null; + if (ReflectionUtils.doesClassExist(string)) { + try { + aClass = Class.forName(string); + } catch (ClassNotFoundException e) { + aClass = getNonPublicClass(string); + } + } + + if (aClass == null) { + String aClassName = ""; + Logger.REFLECTION("Splitting " + string + " to try look for hidden classes."); + String[] aData = string.split("\\."); + Logger.REFLECTION("Obtained " + aData.length + " pieces."); + for (int i = 0; i < (aData.length - 1); i++) { + aClassName += (i > 0) ? "." + aData[i] : "" + aData[i]; + Logger.REFLECTION("Building: " + aClassName); + } + if (aClassName != null && aClassName.length() > 0) { + Logger.REFLECTION("Trying to search '" + aClassName + "' for inner classes."); + Class clazz = ReflectionUtils.getClass(aClassName); + if (clazz != null) { + Class[] y = clazz.getDeclaredClasses(); + if (y == null || y.length <= 0) { + Logger.REFLECTION("No hidden inner classes found."); + return null; + } else { + boolean found = false; + for (Class h : y) { + Logger.REFLECTION("Found hidden inner class: " + h.getCanonicalName()); + if (h.getSimpleName().toLowerCase().equals(aData[aData.length - 1].toLowerCase())) { + Logger.REFLECTION("Found correct class. [" + aData[aData.length - 1] + + "] Caching at correct location: " + string); + Logger.REFLECTION("Found at location: " + h.getCanonicalName()); + ReflectionUtils.mCachedClasses.put(string, h); + aClass = h; + found = true; + break; + } + } + if (!found) { + return null; + } + } + } else { + return null; + } + } else { + return null; + } + } + return aClass; + } + + /** + * + * Set the value of a field reflectively. + */ + private static void setFieldValue_Internal(Object owner, Field field, Object value) throws Exception { + makeModifiable(field); + field.set(owner, value); + } + + /** + * Force the field to be modifiable and accessible. + */ + private static void makeModifiable(Field nameField) throws Exception { + nameField.setAccessible(true); + Field modifiers = getField(Field.class, "modifiers"); + modifiers.setAccessible(true); + modifiers.setInt(nameField, nameField.getModifiers() & ~Modifier.FINAL); + } + + public static boolean doesFieldExist(String clazz, String string) { + return doesFieldExist(ReflectionUtils.getClass(clazz), string); + } + + public static boolean doesFieldExist(Class clazz, String string) { + if (clazz != null) { + if (ReflectionUtils.getField(clazz, string) != null) { + return true; + } + } + return false; + } + + public static T getFieldValue(Field field) { + return getFieldValue(field, null); + } + + public static T getFieldValue(Field field, Object instance) { + try { + return (T) field.get(instance); + } catch (IllegalArgumentException | IllegalAccessException e) { + } + return null; + } + + public static T createNewInstanceFromConstructor(Constructor aConstructor, Object[] aArgs) { + T aInstance; + try { + aInstance = (T) aConstructor.newInstance(aArgs); + if (aInstance != null) { + return aInstance; + } + } catch (InstantiationException + | IllegalAccessException + | IllegalArgumentException + | InvocationTargetException e) { + e.printStackTrace(); + } + return null; + } + + public static Enum getEnum(Class sgtbees, String name) { + if (sgtbees.isEnum()) { + Object[] aValues = sgtbees.getEnumConstants(); + for (Object o : aValues) { + if (o.toString().toLowerCase().equals(name.toLowerCase())) { + return (Enum) o; + } + } + } + return null; + } } diff --git a/src/main/java/gtPlusPlus/core/util/sys/KeyboardUtils.java b/src/main/java/gtPlusPlus/core/util/sys/KeyboardUtils.java index ea87677ee2..3e26d8ff35 100644 --- a/src/main/java/gtPlusPlus/core/util/sys/KeyboardUtils.java +++ b/src/main/java/gtPlusPlus/core/util/sys/KeyboardUtils.java @@ -1,39 +1,36 @@ package gtPlusPlus.core.util.sys; -import org.lwjgl.input.Keyboard; - import net.minecraft.client.Minecraft; +import org.lwjgl.input.Keyboard; public class KeyboardUtils { - public static boolean isCtrlKeyDown(){ - try { - if (!Keyboard.isCreated()) { - return false; - } - // prioritize CONTROL, but allow OPTION as well on Mac (note: GuiScreen's isCtrlKeyDown only checks for the OPTION key on Mac) - boolean isCtrlKeyDown = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL); - if (!isCtrlKeyDown && Minecraft.isRunningOnMac) - isCtrlKeyDown = Keyboard.isKeyDown(Keyboard.KEY_LMETA) || Keyboard.isKeyDown(Keyboard.KEY_RMETA); - - return isCtrlKeyDown; - } - catch (Throwable t) { - return false; - } - } - - public static boolean isShiftKeyDown(){ - try { - if (!Keyboard.isCreated()) { - return false; - } - return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); - } - catch (Throwable t) { - return false; - } - - } - + public static boolean isCtrlKeyDown() { + try { + if (!Keyboard.isCreated()) { + return false; + } + // prioritize CONTROL, but allow OPTION as well on Mac (note: GuiScreen's isCtrlKeyDown only checks for the + // OPTION key on Mac) + boolean isCtrlKeyDown = + Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL); + if (!isCtrlKeyDown && Minecraft.isRunningOnMac) + isCtrlKeyDown = Keyboard.isKeyDown(Keyboard.KEY_LMETA) || Keyboard.isKeyDown(Keyboard.KEY_RMETA); + + return isCtrlKeyDown; + } catch (Throwable t) { + return false; + } + } + + public static boolean isShiftKeyDown() { + try { + if (!Keyboard.isCreated()) { + return false; + } + return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); + } catch (Throwable t) { + return false; + } + } } diff --git a/src/main/java/gtPlusPlus/core/util/sys/Log.java b/src/main/java/gtPlusPlus/core/util/sys/Log.java index fcd4f34c1b..026bb533c7 100644 --- a/src/main/java/gtPlusPlus/core/util/sys/Log.java +++ b/src/main/java/gtPlusPlus/core/util/sys/Log.java @@ -4,21 +4,21 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; public final class Log { - public static final Logger LOGGER = LogManager.getLogger("MiscUtils"); + public static final Logger LOGGER = LogManager.getLogger("MiscUtils"); - public static void warn(final String msg) { - LOGGER.warn(msg); - } + public static void warn(final String msg) { + LOGGER.warn(msg); + } - public static void error(final String msg) { - LOGGER.error(msg); - } + public static void error(final String msg) { + LOGGER.error(msg); + } - public static void info(final String msg) { - LOGGER.info(msg); - } + public static void info(final String msg) { + LOGGER.info(msg); + } - public static void debug(final String msg) { - LOGGER.debug(msg); - } + public static void debug(final String msg) { + LOGGER.debug(msg); + } } diff --git a/src/main/java/gtPlusPlus/core/util/sys/SystemUtils.java b/src/main/java/gtPlusPlus/core/util/sys/SystemUtils.java index 2788ba688e..662a3261c0 100644 --- a/src/main/java/gtPlusPlus/core/util/sys/SystemUtils.java +++ b/src/main/java/gtPlusPlus/core/util/sys/SystemUtils.java @@ -2,89 +2,84 @@ package gtPlusPlus.core.util.sys; public class SystemUtils { - private static OS SystemType; - - public static OS getOS(){ - if (SystemType != null){ - return SystemType; - } - else { - SystemType = getOperatingSystem(); - return SystemType; - } - } - - /** - * Try invoke the runtime's Garbage Collector. - */ - public static void invokeGC() { - try { - Runtime r = Runtime.getRuntime(); - r.gc(); - } - catch (Throwable t) { - //Do nothing. - } - } - - public static boolean isWindows() { - return (getOSString().indexOf("win") >= 0); - } + private static OS SystemType; - public static boolean isMac() { - return (getOSString().indexOf("mac") >= 0); - } + public static OS getOS() { + if (SystemType != null) { + return SystemType; + } else { + SystemType = getOperatingSystem(); + return SystemType; + } + } - public static boolean isUnix() { - return (getOSString().indexOf("nix") >= 0 || getOSString().indexOf("nux") >= 0 || getOSString().indexOf("aix") > 0 ); - } + /** + * Try invoke the runtime's Garbage Collector. + */ + public static void invokeGC() { + try { + Runtime r = Runtime.getRuntime(); + r.gc(); + } catch (Throwable t) { + // Do nothing. + } + } - public static boolean isSolaris() { - return (getOSString().indexOf("sunos") >= 0); - } + public static boolean isWindows() { + return (getOSString().indexOf("win") >= 0); + } - public static String getOSString(){ - try { - return System.getProperty("os.name").toLowerCase(); - } - catch (Throwable t){ - return "other"; - } - } - - public static OS getOperatingSystem(){ - if (isMac()){ - return OS.MAC; - } - else if (isWindows()){ - return OS.WINDOWS; - } - else if (isUnix()){ - return OS.UNIX; - } - else if (isSolaris()){ - return OS.SOLARIS; - } - else { - return OS.OTHER; - } - } - - public static enum OS { - MAC(1), - WINDOWS(2), - UNIX(3), - SOLARIS(4), - OTHER(0); + public static boolean isMac() { + return (getOSString().indexOf("mac") >= 0); + } - private int mID; - private OS (final int ID){ - this.mID = ID; - } + public static boolean isUnix() { + return (getOSString().indexOf("nix") >= 0 + || getOSString().indexOf("nux") >= 0 + || getOSString().indexOf("aix") > 0); + } - public int getID() { - return this.mID; - } - } - + public static boolean isSolaris() { + return (getOSString().indexOf("sunos") >= 0); + } + + public static String getOSString() { + try { + return System.getProperty("os.name").toLowerCase(); + } catch (Throwable t) { + return "other"; + } + } + + public static OS getOperatingSystem() { + if (isMac()) { + return OS.MAC; + } else if (isWindows()) { + return OS.WINDOWS; + } else if (isUnix()) { + return OS.UNIX; + } else if (isSolaris()) { + return OS.SOLARIS; + } else { + return OS.OTHER; + } + } + + public static enum OS { + MAC(1), + WINDOWS(2), + UNIX(3), + SOLARIS(4), + OTHER(0); + + private int mID; + + private OS(final int ID) { + this.mID = ID; + } + + public int getID() { + return this.mID; + } + } } diff --git a/src/main/java/gtPlusPlus/core/world/damage/BaseCustomDamageSource.java b/src/main/java/gtPlusPlus/core/world/damage/BaseCustomDamageSource.java index 3778beacfb..c3ebf70052 100644 --- a/src/main/java/gtPlusPlus/core/world/damage/BaseCustomDamageSource.java +++ b/src/main/java/gtPlusPlus/core/world/damage/BaseCustomDamageSource.java @@ -3,20 +3,17 @@ package gtPlusPlus.core.world.damage; import net.minecraft.entity.Entity; import net.minecraft.util.EntityDamageSourceIndirect; -public class BaseCustomDamageSource extends EntityDamageSourceIndirect { +public class BaseCustomDamageSource extends EntityDamageSourceIndirect { - public BaseCustomDamageSource(String name, Entity transmitter, Entity indirectSource) { - super(name, transmitter, indirectSource); - this.setDifficultyScaled(); - } - - /** + public BaseCustomDamageSource(String name, Entity transmitter, Entity indirectSource) { + super(name, transmitter, indirectSource); + this.setDifficultyScaled(); + } + + /** * Return whether this damage source will have its damage amount scaled based on the current difficulty. */ - public boolean isDifficultyScaled() - { - return true; + public boolean isDifficultyScaled() { + return true; } - - -} \ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/core/world/explosions/ExplosionHandler.java b/src/main/java/gtPlusPlus/core/world/explosions/ExplosionHandler.java index 8d96aa2ff1..7bbc7a7edd 100644 --- a/src/main/java/gtPlusPlus/core/world/explosions/ExplosionHandler.java +++ b/src/main/java/gtPlusPlus/core/world/explosions/ExplosionHandler.java @@ -5,27 +5,41 @@ import net.minecraft.world.World; public class ExplosionHandler { - /** - * Creates an explosion. Args: entity, x, y, z, strength - */ - public MiningExplosion createExplosion(final World world, final Entity entityObj, final double x, final double y, final double z, final float size, final boolean makesFlames, final boolean makesSmoke) - { - return this.newExplosion(world, entityObj, x, y, z, size, makesFlames, makesSmoke); - } - - /** - * returns a new explosion. - */ - public MiningExplosion newExplosion(final World world, final Entity entityObj, final double x, final double y, final double z, final float size, final boolean makesFlames, final boolean makesSmoke){ - final MiningExplosion explosion = new MiningExplosion(world, entityObj, x, y, z, size); - explosion.isFlaming = makesFlames; - explosion.isSmoking = makesSmoke; - if (net.minecraftforge.event.ForgeEventFactory.onExplosionStart(world, explosion)) { - return explosion; - } - explosion.doExplosionA(); - explosion.doExplosionB(true); - return explosion; - } + /** + * Creates an explosion. Args: entity, x, y, z, strength + */ + public MiningExplosion createExplosion( + final World world, + final Entity entityObj, + final double x, + final double y, + final double z, + final float size, + final boolean makesFlames, + final boolean makesSmoke) { + return this.newExplosion(world, entityObj, x, y, z, size, makesFlames, makesSmoke); + } + /** + * returns a new explosion. + */ + public MiningExplosion newExplosion( + final World world, + final Entity entityObj, + final double x, + final double y, + final double z, + final float size, + final boolean makesFlames, + final boolean makesSmoke) { + final MiningExplosion explosion = new MiningExplosion(world, entityObj, x, y, z, size); + explosion.isFlaming = makesFlames; + explosion.isSmoking = makesSmoke; + if (net.minecraftforge.event.ForgeEventFactory.onExplosionStart(world, explosion)) { + return explosion; + } + explosion.doExplosionA(); + explosion.doExplosionB(true); + return explosion; + } } diff --git a/src/main/java/gtPlusPlus/core/world/explosions/MiningExplosion.java b/src/main/java/gtPlusPlus/core/world/explosions/MiningExplosion.java index 792e47085e..d36c75bfa3 100644 --- a/src/main/java/gtPlusPlus/core/world/explosions/MiningExplosion.java +++ b/src/main/java/gtPlusPlus/core/world/explosions/MiningExplosion.java @@ -1,7 +1,9 @@ package gtPlusPlus.core.world.explosions; +import gtPlusPlus.api.objects.random.XSTR; +import gtPlusPlus.core.entity.EntityPrimedMiningExplosive; +import gtPlusPlus.core.util.math.MathUtils; import java.util.*; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.enchantment.EnchantmentProtection; @@ -14,262 +16,420 @@ import net.minecraft.world.ChunkPosition; import net.minecraft.world.Explosion; import net.minecraft.world.World; -import gtPlusPlus.api.objects.random.XSTR; -import gtPlusPlus.core.entity.EntityPrimedMiningExplosive; -import gtPlusPlus.core.util.math.MathUtils; - public class MiningExplosion extends Explosion { - private final int field_77289_h = 16; - private final Random explosionRNG = new XSTR(); - private final World worldObj; + private final int field_77289_h = 16; + private final Random explosionRNG = new XSTR(); + private final World worldObj; + + private final Map field_77288_k = new HashMap<>(); - private final Map field_77288_k = new HashMap<>(); - public MiningExplosion(final World worldObj, final Entity entityObj, final double x, final double y, final double z, final float size) - { - super(worldObj, entityObj, x, y, z, size); - this.worldObj = worldObj; - this.exploder = entityObj; - this.explosionSize = size; - this.explosionX = x; - this.explosionY = y; - this.explosionZ = z; - } + public MiningExplosion( + final World worldObj, + final Entity entityObj, + final double x, + final double y, + final double z, + final float size) { + super(worldObj, entityObj, x, y, z, size); + this.worldObj = worldObj; + this.exploder = entityObj; + this.explosionSize = size; + this.explosionX = x; + this.explosionY = y; + this.explosionZ = z; + } - /** - * Does the first part of the explosion (destroy blocks) - */ - @SuppressWarnings("unchecked") - @Override - public void doExplosionA() - { - final float f = this.explosionSize; - final HashSet hashset = new HashSet<>(); - int i; - int j; - int k; - double d5; - double d6; - double d7; + /** + * Does the first part of the explosion (destroy blocks) + */ + @SuppressWarnings("unchecked") + @Override + public void doExplosionA() { + final float f = this.explosionSize; + final HashSet hashset = new HashSet<>(); + int i; + int j; + int k; + double d5; + double d6; + double d7; - for (i = 0; i < this.field_77289_h; ++i) - { - for (j = 0; j < this.field_77289_h; ++j) - { - for (k = 0; k < this.field_77289_h; ++k) - { - if ((i == 0) || (i == (this.field_77289_h - 1)) || (j == 0) || (j == (this.field_77289_h - 1)) || (k == 0) || (k == (this.field_77289_h - 1))) - { - double d0 = ((i / (this.field_77289_h - 1.0F)) * 2.0F) - 1.0F; - double d1 = ((j / (this.field_77289_h - 1.0F)) * 2.0F) - 1.0F; - double d2 = ((k / (this.field_77289_h - 1.0F)) * 2.0F) - 1.0F; - final double d3 = Math.sqrt((d0 * d0) + (d1 * d1) + (d2 * d2)); - d0 /= d3; - d1 /= d3; - d2 /= d3; - float f1 = this.explosionSize * (0.7F + (this.worldObj.rand.nextFloat() * 0.6F)); - d5 = this.explosionX; - d6 = this.explosionY; - d7 = this.explosionZ; + for (i = 0; i < this.field_77289_h; ++i) { + for (j = 0; j < this.field_77289_h; ++j) { + for (k = 0; k < this.field_77289_h; ++k) { + if ((i == 0) + || (i == (this.field_77289_h - 1)) + || (j == 0) + || (j == (this.field_77289_h - 1)) + || (k == 0) + || (k == (this.field_77289_h - 1))) { + double d0 = ((i / (this.field_77289_h - 1.0F)) * 2.0F) - 1.0F; + double d1 = ((j / (this.field_77289_h - 1.0F)) * 2.0F) - 1.0F; + double d2 = ((k / (this.field_77289_h - 1.0F)) * 2.0F) - 1.0F; + final double d3 = Math.sqrt((d0 * d0) + (d1 * d1) + (d2 * d2)); + d0 /= d3; + d1 /= d3; + d2 /= d3; + float f1 = this.explosionSize * (0.7F + (this.worldObj.rand.nextFloat() * 0.6F)); + d5 = this.explosionX; + d6 = this.explosionY; + d7 = this.explosionZ; - for (final float f2 = 0.3F; f1 > 0.0F; f1 -= f2 * 0.75F) - { - final int j1 = MathHelper.floor_double(d5); - final int k1 = MathHelper.floor_double(d6); - final int l1 = MathHelper.floor_double(d7); - final Block block = this.worldObj.getBlock(j1, k1, l1); + for (final float f2 = 0.3F; f1 > 0.0F; f1 -= f2 * 0.75F) { + final int j1 = MathHelper.floor_double(d5); + final int k1 = MathHelper.floor_double(d6); + final int l1 = MathHelper.floor_double(d7); + final Block block = this.worldObj.getBlock(j1, k1, l1); - if (block.getMaterial() != Material.air) - { - final float f3 = this.exploder != null ? this.exploder.func_145772_a(this, this.worldObj, j1, k1, l1, block) : block.getExplosionResistance(this.exploder, this.worldObj, j1, k1, l1, this.explosionX, this.explosionY, this.explosionZ); - f1 -= (f3 + 0.3F) * f2; - } + if (block.getMaterial() != Material.air) { + final float f3 = this.exploder != null + ? this.exploder.func_145772_a(this, this.worldObj, j1, k1, l1, block) + : block.getExplosionResistance( + this.exploder, + this.worldObj, + j1, + k1, + l1, + this.explosionX, + this.explosionY, + this.explosionZ); + f1 -= (f3 + 0.3F) * f2; + } - if ((f1 > 0.0F) && ((this.exploder == null) || this.exploder.func_145774_a(this, this.worldObj, j1, k1, l1, block, f1))) - { - hashset.add(new ChunkPosition(j1, k1, l1)); - } + if ((f1 > 0.0F) + && ((this.exploder == null) + || this.exploder.func_145774_a( + this, this.worldObj, j1, k1, l1, block, f1))) { + hashset.add(new ChunkPosition(j1, k1, l1)); + } - d5 += d0 * f2; - d6 += d1 * f2; - d7 += d2 * f2; - } - } - } - } - } + d5 += d0 * f2; + d6 += d1 * f2; + d7 += d2 * f2; + } + } + } + } + } - this.affectedBlockPositions.addAll(hashset); - this.explosionSize *= 2.0F; - i = MathHelper.floor_double(this.explosionX - this.explosionSize - 1.0D); - j = MathHelper.floor_double(this.explosionX + this.explosionSize + 1.0D); - k = MathHelper.floor_double(this.explosionY - this.explosionSize - 1.0D); - final int i2 = MathHelper.floor_double(this.explosionY + this.explosionSize + 1.0D); - final int l = MathHelper.floor_double(this.explosionZ - this.explosionSize - 1.0D); - final int j2 = MathHelper.floor_double(this.explosionZ + this.explosionSize + 1.0D); - final List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this.exploder, AxisAlignedBB.getBoundingBox(i, k, l, j, i2, j2)); - net.minecraftforge.event.ForgeEventFactory.onExplosionDetonate(this.worldObj, this, list, this.explosionSize); - final Vec3 vec3 = Vec3.createVectorHelper(this.explosionX, this.explosionY, this.explosionZ); + this.affectedBlockPositions.addAll(hashset); + this.explosionSize *= 2.0F; + i = MathHelper.floor_double(this.explosionX - this.explosionSize - 1.0D); + j = MathHelper.floor_double(this.explosionX + this.explosionSize + 1.0D); + k = MathHelper.floor_double(this.explosionY - this.explosionSize - 1.0D); + final int i2 = MathHelper.floor_double(this.explosionY + this.explosionSize + 1.0D); + final int l = MathHelper.floor_double(this.explosionZ - this.explosionSize - 1.0D); + final int j2 = MathHelper.floor_double(this.explosionZ + this.explosionSize + 1.0D); + final List list = this.worldObj.getEntitiesWithinAABBExcludingEntity( + this.exploder, AxisAlignedBB.getBoundingBox(i, k, l, j, i2, j2)); + net.minecraftforge.event.ForgeEventFactory.onExplosionDetonate(this.worldObj, this, list, this.explosionSize); + final Vec3 vec3 = Vec3.createVectorHelper(this.explosionX, this.explosionY, this.explosionZ); - for (int i1 = 0; i1 < list.size(); ++i1) - { - final Entity entity = list.get(i1); - final double d4 = entity.getDistance(this.explosionX, this.explosionY, this.explosionZ) / this.explosionSize; + for (int i1 = 0; i1 < list.size(); ++i1) { + final Entity entity = list.get(i1); + final double d4 = + entity.getDistance(this.explosionX, this.explosionY, this.explosionZ) / this.explosionSize; - if (d4 <= 1.0D) - { - d5 = entity.posX - this.explosionX; - d6 = (entity.posY + entity.getEyeHeight()) - this.explosionY; - d7 = entity.posZ - this.explosionZ; - final double d9 = MathHelper.sqrt_double((d5 * d5) + (d6 * d6) + (d7 * d7)); + if (d4 <= 1.0D) { + d5 = entity.posX - this.explosionX; + d6 = (entity.posY + entity.getEyeHeight()) - this.explosionY; + d7 = entity.posZ - this.explosionZ; + final double d9 = MathHelper.sqrt_double((d5 * d5) + (d6 * d6) + (d7 * d7)); - if (d9 != 0.0D) - { - d5 /= d9; - d6 /= d9; - d7 /= d9; - final double d10 = this.worldObj.getBlockDensity(vec3, entity.boundingBox); - final double d11 = (1.0D - d4) * d10; - entity.attackEntityFrom(DamageSource.setExplosionSource(this), ((int)(((((d11 * d11) + d11) / 2.0D) * 8.0D * this.explosionSize) + 1.0D))); - final double d8 = EnchantmentProtection.func_92092_a(entity, d11); - entity.motionX += d5 * d8; - entity.motionY += d6 * d8; - entity.motionZ += d7 * d8; + if (d9 != 0.0D) { + d5 /= d9; + d6 /= d9; + d7 /= d9; + final double d10 = this.worldObj.getBlockDensity(vec3, entity.boundingBox); + final double d11 = (1.0D - d4) * d10; + entity.attackEntityFrom(DamageSource.setExplosionSource(this), ((int) + (((((d11 * d11) + d11) / 2.0D) * 8.0D * this.explosionSize) + 1.0D))); + final double d8 = EnchantmentProtection.func_92092_a(entity, d11); + entity.motionX += d5 * d8; + entity.motionY += d6 * d8; + entity.motionZ += d7 * d8; - if (entity instanceof EntityPlayer) - { - this.field_77288_k.put(entity, Vec3.createVectorHelper(d5 * d11, d6 * d11, d7 * d11)); - } - } - } - } + if (entity instanceof EntityPlayer) { + this.field_77288_k.put(entity, Vec3.createVectorHelper(d5 * d11, d6 * d11, d7 * d11)); + } + } + } + } - this.explosionSize = f; - } + this.explosionSize = f; + } - /** - * Does the second part of the explosion (sound, particles, drop spawn) - */ - @Override - public void doExplosionB(final boolean p_77279_1_) - { - this.worldObj.playSoundEffect(this.explosionX, this.explosionY, this.explosionZ, "random.explode", 4.0F, (1.0F + ((this.worldObj.rand.nextFloat() - this.worldObj.rand.nextFloat()) * 0.2F)) * 0.7F); + /** + * Does the second part of the explosion (sound, particles, drop spawn) + */ + @Override + public void doExplosionB(final boolean p_77279_1_) { + this.worldObj.playSoundEffect( + this.explosionX, + this.explosionY, + this.explosionZ, + "random.explode", + 4.0F, + (1.0F + ((this.worldObj.rand.nextFloat() - this.worldObj.rand.nextFloat()) * 0.2F)) * 0.7F); - if ((this.explosionSize >= 2.0F) && this.isSmoking) - { - this.worldObj.spawnParticle("hugeexplosion", this.explosionX, this.explosionY, this.explosionZ, 1.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("smoke", this.explosionX+MathUtils.randDouble(0, 1), this.explosionY+MathUtils.randDouble(0, 1), this.explosionZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("largesmoke", this.explosionX+MathUtils.randDouble(0, 1), this.explosionY+MathUtils.randDouble(0, 1), this.explosionZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("cloud", this.explosionX+MathUtils.randDouble(0, 1), this.explosionY+MathUtils.randDouble(0, 1), this.explosionZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("flame", this.explosionX+MathUtils.randDouble(0, 1), this.explosionY+MathUtils.randDouble(0, 1), this.explosionZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("explode", this.explosionX+MathUtils.randDouble(0, 1), this.explosionY+MathUtils.randDouble(0, 1), this.explosionZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("largeexplode", this.explosionX+MathUtils.randDouble(0, 1), this.explosionY+MathUtils.randDouble(0, 1), this.explosionZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("hugeexplosion", this.explosionX+MathUtils.randDouble(0, 1), this.explosionY+MathUtils.randDouble(0, 1), this.explosionZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - } - else - { - this.worldObj.spawnParticle("largeexplode", this.explosionX, this.explosionY, this.explosionZ, 1.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("smoke", this.explosionX+MathUtils.randDouble(0, 1), this.explosionY+MathUtils.randDouble(0, 1), this.explosionZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("largesmoke", this.explosionX+MathUtils.randDouble(0, 1), this.explosionY+MathUtils.randDouble(0, 1), this.explosionZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("cloud", this.explosionX+MathUtils.randDouble(0, 1), this.explosionY+MathUtils.randDouble(0, 1), this.explosionZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("flame", this.explosionX+MathUtils.randDouble(0, 1), this.explosionY+MathUtils.randDouble(0, 1), this.explosionZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("explode", this.explosionX+MathUtils.randDouble(0, 1), this.explosionY+MathUtils.randDouble(0, 1), this.explosionZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("largeexplode", this.explosionX+MathUtils.randDouble(0, 1), this.explosionY+MathUtils.randDouble(0, 1), this.explosionZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - } + if ((this.explosionSize >= 2.0F) && this.isSmoking) { + this.worldObj.spawnParticle( + "hugeexplosion", this.explosionX, this.explosionY, this.explosionZ, 1.0D, 0.0D, 0.0D); + this.worldObj.spawnParticle( + "smoke", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largesmoke", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "cloud", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "flame", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "explode", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largeexplode", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "hugeexplosion", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + } else { + this.worldObj.spawnParticle( + "largeexplode", this.explosionX, this.explosionY, this.explosionZ, 1.0D, 0.0D, 0.0D); + this.worldObj.spawnParticle( + "smoke", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largesmoke", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "cloud", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "flame", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "explode", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largeexplode", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + } - Iterator iterator; - ChunkPosition chunkposition; - int i; - int j; - int k; - Block block; + Iterator iterator; + ChunkPosition chunkposition; + int i; + int j; + int k; + Block block; - if (this.isSmoking) - { - iterator = this.affectedBlockPositions.iterator(); + if (this.isSmoking) { + iterator = this.affectedBlockPositions.iterator(); - while (iterator.hasNext()) - { - chunkposition = iterator.next(); - i = chunkposition.chunkPosX; - j = chunkposition.chunkPosY; - k = chunkposition.chunkPosZ; - block = this.worldObj.getBlock(i, j, k); + while (iterator.hasNext()) { + chunkposition = iterator.next(); + i = chunkposition.chunkPosX; + j = chunkposition.chunkPosY; + k = chunkposition.chunkPosZ; + block = this.worldObj.getBlock(i, j, k); - if (p_77279_1_) - { - final double d0 = i + this.worldObj.rand.nextFloat(); - final double d1 = j + this.worldObj.rand.nextFloat(); - final double d2 = k + this.worldObj.rand.nextFloat(); - double d3 = d0 - this.explosionX; - double d4 = d1 - this.explosionY; - double d5 = d2 - this.explosionZ; - final double d6 = MathHelper.sqrt_double((d3 * d3) + (d4 * d4) + (d5 * d5)); - d3 /= d6; - d4 /= d6; - d5 /= d6; - double d7 = 0.5D / ((d6 / this.explosionSize) + 0.1D); - d7 *= (this.worldObj.rand.nextFloat() * this.worldObj.rand.nextFloat()) + 0.3F; - d3 *= d7; - d4 *= d7; - d5 *= d7; - this.worldObj.spawnParticle("explode", (d0 + (this.explosionX * 1.0D)) / 2.0D, (d1 + (this.explosionY * 1.0D)) / 2.0D, (d2 + (this.explosionZ * 1.0D)) / 2.0D, d3, d4, d5); - this.worldObj.spawnParticle("smoke", d0, d1, d2, d3, d4, d5); - this.worldObj.spawnParticle("smoke", this.explosionX+MathUtils.randDouble(0, 1), this.explosionY+MathUtils.randDouble(0, 1), this.explosionZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("largesmoke", this.explosionX+MathUtils.randDouble(0, 1), this.explosionY+MathUtils.randDouble(0, 1), this.explosionZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("cloud", this.explosionX+MathUtils.randDouble(0, 1), this.explosionY+MathUtils.randDouble(0, 1), this.explosionZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("flame", this.explosionX+MathUtils.randDouble(0, 1), this.explosionY+MathUtils.randDouble(0, 1), this.explosionZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("explode", this.explosionX+MathUtils.randDouble(0, 1), this.explosionY+MathUtils.randDouble(0, 1), this.explosionZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("largeexplode", this.explosionX+MathUtils.randDouble(0, 1), this.explosionY+MathUtils.randDouble(0, 1), this.explosionZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - this.worldObj.spawnParticle("hugeexplosion", this.explosionX+MathUtils.randDouble(0, 1), this.explosionY+MathUtils.randDouble(0, 1), this.explosionZ+MathUtils.randDouble(0, 1), 0.0D, 0.0D, 0.0D); - - } + if (p_77279_1_) { + final double d0 = i + this.worldObj.rand.nextFloat(); + final double d1 = j + this.worldObj.rand.nextFloat(); + final double d2 = k + this.worldObj.rand.nextFloat(); + double d3 = d0 - this.explosionX; + double d4 = d1 - this.explosionY; + double d5 = d2 - this.explosionZ; + final double d6 = MathHelper.sqrt_double((d3 * d3) + (d4 * d4) + (d5 * d5)); + d3 /= d6; + d4 /= d6; + d5 /= d6; + double d7 = 0.5D / ((d6 / this.explosionSize) + 0.1D); + d7 *= (this.worldObj.rand.nextFloat() * this.worldObj.rand.nextFloat()) + 0.3F; + d3 *= d7; + d4 *= d7; + d5 *= d7; + this.worldObj.spawnParticle( + "explode", + (d0 + (this.explosionX * 1.0D)) / 2.0D, + (d1 + (this.explosionY * 1.0D)) / 2.0D, + (d2 + (this.explosionZ * 1.0D)) / 2.0D, + d3, + d4, + d5); + this.worldObj.spawnParticle("smoke", d0, d1, d2, d3, d4, d5); + this.worldObj.spawnParticle( + "smoke", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largesmoke", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "cloud", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "flame", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "explode", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "largeexplode", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + this.worldObj.spawnParticle( + "hugeexplosion", + this.explosionX + MathUtils.randDouble(0, 1), + this.explosionY + MathUtils.randDouble(0, 1), + this.explosionZ + MathUtils.randDouble(0, 1), + 0.0D, + 0.0D, + 0.0D); + } - if (block.getMaterial() != Material.air) - { - if (block.canDropFromExplosion(this)) - { - //world, x, y, z, world.getBlockMetadata(x, y, z), dropProb, 0 - block.dropBlockAsItemWithChance(this.worldObj, i, j, k, this.worldObj.getBlockMetadata(i, j, k), 1F, 0); - } + if (block.getMaterial() != Material.air) { + if (block.canDropFromExplosion(this)) { + // world, x, y, z, world.getBlockMetadata(x, y, z), dropProb, 0 + block.dropBlockAsItemWithChance( + this.worldObj, i, j, k, this.worldObj.getBlockMetadata(i, j, k), 1F, 0); + } - block.onBlockExploded(this.worldObj, i, j, k, this); - } - } - } + block.onBlockExploded(this.worldObj, i, j, k, this); + } + } + } - if (this.isFlaming) - { - iterator = this.affectedBlockPositions.iterator(); + if (this.isFlaming) { + iterator = this.affectedBlockPositions.iterator(); - while (iterator.hasNext()) - { - chunkposition = iterator.next(); - i = chunkposition.chunkPosX; - j = chunkposition.chunkPosY; - k = chunkposition.chunkPosZ; - block = this.worldObj.getBlock(i, j, k); - final Block block1 = this.worldObj.getBlock(i, j - 1, k); + while (iterator.hasNext()) { + chunkposition = iterator.next(); + i = chunkposition.chunkPosX; + j = chunkposition.chunkPosY; + k = chunkposition.chunkPosZ; + block = this.worldObj.getBlock(i, j, k); + final Block block1 = this.worldObj.getBlock(i, j - 1, k); - if ((block.getMaterial() == Material.air) && block1.func_149730_j() && (this.explosionRNG.nextInt(3) == 0)) - { - this.worldObj.setBlock(i, j, k, Blocks.fire); - } - } - } - } + if ((block.getMaterial() == Material.air) + && block1.func_149730_j() + && (this.explosionRNG.nextInt(3) == 0)) { + this.worldObj.setBlock(i, j, k, Blocks.fire); + } + } + } + } - @Override - public Map func_77277_b() - { - return this.field_77288_k; - } + @Override + public Map func_77277_b() { + return this.field_77288_k; + } - /** - * Returns either the entity that placed the explosive block, the entity that caused the explosion or null. - */ - @Override - public EntityLivingBase getExplosivePlacedBy() - { - return this.exploder == null ? null : (this.exploder instanceof EntityPrimedMiningExplosive ? ((EntityPrimedMiningExplosive)this.exploder).getTntPlacedBy() : (this.exploder instanceof EntityLivingBase ? (EntityLivingBase)this.exploder : null)); - } -} \ No newline at end of file + /** + * Returns either the entity that placed the explosive block, the entity that caused the explosion or null. + */ + @Override + public EntityLivingBase getExplosivePlacedBy() { + return this.exploder == null + ? null + : (this.exploder instanceof EntityPrimedMiningExplosive + ? ((EntityPrimedMiningExplosive) this.exploder).getTntPlacedBy() + : (this.exploder instanceof EntityLivingBase ? (EntityLivingBase) this.exploder : null)); + } +} -- cgit